From a56b457656218e5b6142b6238286ea54801ac4b2 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Mon, 25 May 2020 11:49:19 +0200 Subject: netifd: wireless: add support for tracking wifi-station sections This new section allows us to assign mac specific key/vid settings to a station. Signed-off-by: John Crispin --- config.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'config.c') diff --git a/config.c b/config.c index 1bb3737..b1b4bf3 100644 --- a/config.c +++ b/config.c @@ -364,6 +364,19 @@ config_parse_wireless_vlan(struct wireless_device *wdev, char *vif, struct uci_s wireless_vlan_create(wdev, vif, b.head, s->anonymous ? name : s->e.name); } +static void +config_parse_wireless_station(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->station.config); + wireless_station_create(wdev, vif, b.head, s->anonymous ? name : s->e.name); +} + static void config_init_wireless(void) { @@ -393,6 +406,8 @@ config_init_wireless(void) vlist_update(&wdev->interfaces); wdev->vlan_idx = 0; vlist_update(&wdev->vlans); + wdev->sta_idx = 0; + vlist_update(&wdev->stations); } uci_foreach_element(&uci_wireless->sections, e) { @@ -429,11 +444,25 @@ config_init_wireless(void) continue; config_parse_wireless_vlan(wdev, vif->name, s); } + + uci_foreach_element(&uci_wireless->sections, f) { + struct uci_section *s = uci_to_section(f); + const char *vif_name; + + if (strcmp(s->type, "wifi-station") != 0) + continue; + + vif_name = uci_lookup_option_string(uci_ctx, s, "iface"); + if (vif_name && strcmp(e->name, vif_name)) + continue; + config_parse_wireless_station(wdev, vif->name, s); + } } vlist_for_each_element(&wireless_devices, wdev, node) { vlist_flush(&wdev->interfaces); vlist_flush(&wdev->vlans); + vlist_flush(&wdev->stations); } } -- cgit v1.2.1