diff options
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 42 |
1 files changed, 38 insertions, 4 deletions
@@ -338,7 +338,7 @@ config_parse_wireless_device(struct uci_section *s) wireless_device_create(drv, s->e.name, b.head); } -static void +static struct wireless_interface* config_parse_wireless_interface(struct wireless_device *wdev, struct uci_section *s) { char *name; @@ -348,7 +348,20 @@ config_parse_wireless_interface(struct wireless_device *wdev, struct uci_section blob_buf_init(&b, 0); uci_to_blob(&b, s, wdev->drv->interface.config); - wireless_interface_create(wdev, b.head, s->anonymous ? name : s->e.name); + return wireless_interface_create(wdev, b.head, s->anonymous ? name : s->e.name); +} + +static void +config_parse_wireless_vlan(struct wireless_device *wdev, char *vif, struct uci_section *s) +{ + char *name; + + name = alloca(strlen(s->type) + 16); + sprintf(name, "@%s[%d]", s->type, config_section_idx(s)); + + blob_buf_init(&b, 0); + uci_to_blob(&b, s, wdev->drv->vlan.config); + wireless_vlan_create(wdev, vif, b.head, s->anonymous ? name : s->e.name); } static void @@ -378,10 +391,14 @@ config_init_wireless(void) vlist_for_each_element(&wireless_devices, wdev, node) { wdev->vif_idx = 0; vlist_update(&wdev->interfaces); + wdev->vlan_idx = 0; + vlist_update(&wdev->vlans); } uci_foreach_element(&uci_wireless->sections, e) { struct uci_section *s = uci_to_section(e); + struct wireless_interface *vif; + struct uci_element *f; if (strcmp(s->type, "wifi-iface") != 0) continue; @@ -396,11 +413,28 @@ config_init_wireless(void) continue; } - config_parse_wireless_interface(wdev, s); + vif = config_parse_wireless_interface(wdev, s); + + if (!vif || s->anonymous) + continue; + uci_foreach_element(&uci_wireless->sections, f) { + struct uci_section *s = uci_to_section(f); + const char *vif_name; + + if (strcmp(s->type, "wifi-vlan") != 0) + continue; + + vif_name = uci_lookup_option_string(uci_ctx, s, "iface"); + if (vif_name && strcmp(e->name, vif_name)) + continue; + config_parse_wireless_vlan(wdev, vif->name, s); + } } - vlist_for_each_element(&wireless_devices, wdev, node) + vlist_for_each_element(&wireless_devices, wdev, node) { vlist_flush(&wdev->interfaces); + vlist_flush(&wdev->vlans); + } } int |