Commit 7a723d0c authored by John Crispin's avatar John Crispin Committed by Daniel Golle

wireless: add ubus method for reloading configuration

Signed-off-by: default avatarDaniel Golle <daniel@makrotopia.org>
parent 5e02f944
......@@ -1081,6 +1081,28 @@ get_wdev(struct blob_attr *msg, int *ret)
return wdev;
}
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,
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment