diff options
-rw-r--r-- | ubus.c | 23 | ||||
-rw-r--r-- | wireless.c | 18 | ||||
-rw-r--r-- | wireless.h | 1 |
3 files changed, 37 insertions, 5 deletions
@@ -1082,6 +1082,28 @@ get_wdev(struct blob_attr *msg, int *ret) } static int +netifd_handle_wdev_reconf(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + struct wireless_device *wdev; + int ret; + + wdev = get_wdev(msg, &ret); + if (ret == UBUS_STATUS_NOT_FOUND) + return ret; + + if (wdev) { + wireless_device_reconf(wdev); + } else { + vlist_for_each_element(&wireless_devices, wdev, node) + wireless_device_reconf(wdev); + } + + return 0; +} + +static int netifd_handle_wdev_up(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg) @@ -1189,6 +1211,7 @@ netifd_handle_wdev_notify(struct ubus_context *ctx, struct ubus_object *obj, static struct ubus_method wireless_object_methods[] = { { .name = "up", .handler = netifd_handle_wdev_up }, { .name = "down", .handler = netifd_handle_wdev_down }, + { .name = "reconf", .handler = netifd_handle_wdev_reconf }, { .name = "status", .handler = netifd_handle_wdev_status }, { .name = "notify", .handler = netifd_handle_wdev_notify }, { .name = "get_validate", .handler = netifd_handle_wdev_get_validate }, @@ -282,7 +282,7 @@ wireless_device_run_handler(struct wireless_device *wdev, bool up) } static void -__wireless_device_set_up(struct wireless_device *wdev) +__wireless_device_set_up(struct wireless_device *wdev, int force) { if (wdev->disabled) return; @@ -293,7 +293,7 @@ __wireless_device_set_up(struct wireless_device *wdev) if (!wdev->autostart) return; - if (wdev->state != IFS_DOWN || config_init) + if (!force && (wdev->state != IFS_DOWN || config_init)) return; free(wdev->prev_config); @@ -320,7 +320,7 @@ wdev_handle_config_change(struct wireless_device *wdev) switch(state) { case IFC_NORMAL: case IFC_RELOAD: - __wireless_device_set_up(wdev); + __wireless_device_set_up(wdev, 0); wdev->config_state = IFC_NORMAL; break; @@ -363,7 +363,15 @@ wireless_device_set_up(struct wireless_device *wdev) { wdev->retry = WIRELESS_SETUP_RETRY; wdev->autostart = true; - __wireless_device_set_up(wdev); + __wireless_device_set_up(wdev, 0); +} + +void +wireless_device_reconf(struct wireless_device *wdev) +{ + wdev->retry = WIRELESS_SETUP_RETRY; + wdev->autostart = true; + __wireless_device_set_up(wdev, 1); } static void @@ -1001,5 +1009,5 @@ wireless_start_pending(void) struct wireless_device *wdev; vlist_for_each_element(&wireless_devices, wdev, node) - __wireless_device_set_up(wdev); + __wireless_device_set_up(wdev, 0); } @@ -93,6 +93,7 @@ struct wireless_process { void wireless_device_create(struct wireless_driver *drv, const char *name, struct blob_attr *data); void wireless_device_set_up(struct wireless_device *wdev); void wireless_device_set_down(struct wireless_device *wdev); +void wireless_device_reconf(struct wireless_device *wdev); void wireless_device_status(struct wireless_device *wdev, struct blob_buf *b); void wireless_device_get_validate(struct wireless_device *wdev, struct blob_buf *b); void wireless_interface_create(struct wireless_device *wdev, struct blob_attr *data, const char *section); |