summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2014-02-17 12:12:25 +0000
committerFelix Fietkau <nbd@openwrt.org>2014-02-17 15:12:45 +0100
commit0244609f376d6b11b98c9488b964fa9133e250fa (patch)
treec7120fd54eaf8515a36898285c246895c79d8f3b
parent700effdec6e66e4a93c88613f2da1d3d8c141fcb (diff)
wireless: load and then ignore disabled devices
Signed-off-by: John Crispin <blogic@openwrt.org>
-rw-r--r--wireless.c13
-rw-r--r--wireless.h1
2 files changed, 11 insertions, 3 deletions
diff --git a/wireless.c b/wireless.c
index 5313119..9a68e01 100644
--- a/wireless.c
+++ b/wireless.c
@@ -261,6 +261,9 @@ wireless_device_run_handler(struct wireless_device *wdev, bool up)
static void
__wireless_device_set_up(struct wireless_device *wdev)
{
+ if (wdev->disabled)
+ return;
+
if (wdev->state != IFS_DOWN || config_init)
return;
@@ -410,15 +413,17 @@ static void
wdev_change_config(struct wireless_device *wdev, struct wireless_device *wd_new)
{
struct blob_attr *new_config = wd_new->config;
+ bool disabled = wd_new->disabled;
free(wd_new);
- if (blob_attr_equal(wdev->config, new_config))
+ if (blob_attr_equal(wdev->config, new_config) || wdev->disabled == disabled)
return;
D(WIRELESS, "Update configuration of wireless device '%s'\n", wdev->name);
free(wdev->config);
wdev->config = blob_memdup(new_config);
+ wdev->disabled = disabled;
wdev_set_config_state(wdev, IFC_RELOAD);
}
@@ -611,10 +616,10 @@ wireless_device_create(struct wireless_driver *drv, const char *name, struct blo
struct blob_attr *disabled;
blobmsg_parse(&wdev_policy, 1, &disabled, blob_data(data), blob_len(data));
- if (disabled && blobmsg_get_bool(disabled))
- return;
wdev = calloc_a(sizeof(*wdev), &name_buf, strlen(name) + 1);
+ if (disabled && blobmsg_get_bool(disabled))
+ wdev->disabled = true;
wdev->drv = drv;
wdev->state = IFS_DOWN;
wdev->config_state = IFC_NORMAL;
@@ -687,6 +692,8 @@ wireless_device_status(struct wireless_device *wdev, struct blob_buf *b)
blobmsg_add_u8(b, "up", wdev->state == IFS_UP);
blobmsg_add_u8(b, "pending", wdev->state == IFS_SETUP || wdev->state == IFS_TEARDOWN);
blobmsg_add_u8(b, "autostart", wdev->autostart);
+ blobmsg_add_u8(b, "disabled", wdev->disabled);
+
i = blobmsg_open_array(b, "interfaces");
vlist_for_each_element(&wdev->interfaces, iface, node)
wireless_interface_status(iface, b);
diff --git a/wireless.h b/wireless.h
index a3eadc1..2608261 100644
--- a/wireless.h
+++ b/wireless.h
@@ -54,6 +54,7 @@ struct wireless_device {
bool config_autostart;
bool autostart;
+ bool disabled;
enum interface_state state;
enum interface_config_state config_state;