static void
put_container(struct blob_buf *buf, struct blob_attr *attr, const char *name)
{
- void *c = blobmsg_open_table(&b, name);
- blob_put_raw(&b, blob_data(attr), blob_len(attr));
- blobmsg_close_table(&b, c);
+ void *c = blobmsg_open_table(buf, name);
+ blob_put_raw(buf, blob_data(attr), blob_len(attr));
+ blobmsg_close_table(buf, c);
}
static void
if (!vif->network || !vif->ifname)
return;
+ if (up) {
+ struct device *dev = device_get(vif->ifname, 2);
+ if (dev)
+ dev->wireless = true;
+ }
+
blobmsg_for_each_attr(cur, vif->network, rem) {
network = blobmsg_data(cur);
if (!iface)
continue;
- interface_handle_link(iface, vif->ifname, up);
+ interface_handle_link(iface, vif->ifname, up, true);
}
}
}
static void
-wireless_device_mark_up(struct wireless_device *wdev)
-{
- struct wireless_interface *vif;
-
- D(WIRELESS, "Wireless device '%s' is now up\n", wdev->name);
- wdev->state = IFS_UP;
- vlist_for_each_element(&wdev->interfaces, vif, node)
- wireless_interface_handle_link(vif, true);
-}
-
-static void
wireless_device_setup_timeout(struct uloop_timeout *timeout)
{
struct wireless_device *wdev = container_of(timeout, struct wireless_device, timeout);
}
static void
+wireless_device_mark_up(struct wireless_device *wdev)
+{
+ struct wireless_interface *vif;
+
+ if (wdev->cancel) {
+ wdev->cancel = false;
+ __wireless_device_set_down(wdev);
+ return;
+ }
+
+ D(WIRELESS, "Wireless device '%s' is now up\n", wdev->name);
+ wdev->state = IFS_UP;
+ vlist_for_each_element(&wdev->interfaces, vif, node)
+ wireless_interface_handle_link(vif, true);
+}
+
+static void
wireless_device_retry_setup(struct wireless_device *wdev)
{
if (wdev->state == IFS_TEARDOWN || wdev->state == IFS_DOWN || wdev->cancel)
struct wireless_interface *vif;
struct blob_attr *tb[__VIF_ATTR_MAX];
struct blob_attr *cur;
- char *name_buf;
+ char *name_buf, *section_buf;
char name[8];
blobmsg_parse(vif_policy, __VIF_ATTR_MAX, tb, blob_data(data), blob_len(data));
sprintf(name, "%d", wdev->vif_idx++);
- vif = calloc_a(sizeof(*vif), &name_buf, strlen(name) + 1);
+ vif = calloc_a(sizeof(*vif),
+ &name_buf, strlen(name) + 1,
+ §ion_buf, strlen(section) + 1);
vif->name = strcpy(name_buf, name);
vif->wdev = wdev;
vif->config = data;
- vif->section = section;
+ vif->section = strcpy(section_buf, section);
vlist_add(&wdev->interfaces, &vif->node, vif->name);
}
blobmsg_add_string(b, "section", iface->section);
if (iface->ifname)
blobmsg_add_string(b, "ifname", iface->ifname);
- if (iface->data)
- blob_put_raw(b, blob_data(iface->data), blob_len(iface->data));
+ put_container(b, iface->config, "config");
blobmsg_close_table(b, i);
}
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);
+ put_container(b, wdev->config, "config");
i = blobmsg_open_array(b, "interfaces");
vlist_for_each_element(&wdev->interfaces, iface, node)
if (wdev->state != IFS_SETUP)
return UBUS_STATUS_PERMISSION_DENIED;
- if (wdev->cancel)
- return 0;
-
wireless_device_mark_up(wdev);
break;
case NOTIFY_CMD_SET_DATA: