diff --git a/src/agent.c b/src/agent.c index 314087dcc142ede0fac0c0528ee11ed081432e47..d9e58229468b191a862167ff27a7deb0a8bd6050 100644 --- a/src/agent.c +++ b/src/agent.c @@ -2604,9 +2604,19 @@ out_str: } } +static void agent_init_ifaces_assoc_mode(struct agent *a) +{ + const struct netif_ap *iface; + + list_for_each_entry(iface, &a->aplist, list) { + wifi_set_backhaul_bss_association_mode(iface->name, + iface->cfg->disallow_assoc); + } +} + static void apply_iface_assocation_mode(struct agent *a, const char *ifname) { - struct netif_ap *iface = get_netif_by_name(a, ifname); + const struct netif_ap *iface = get_netif_by_name(a, ifname); if (iface) { wifi_set_backhaul_bss_association_mode(ifname, @@ -6808,6 +6818,8 @@ void run_agent(void) agent_init_wsc_attributes(w); + agent_init_ifaces_assoc_mode(w); + //memcpy(w->cntlr_almac, w->cfg.cntlr_almac, 6); //agent_config_dump(&w->cfg); diff --git a/src/agent_map.c b/src/agent_map.c index 644f9f9ce12989b4b5a8e41166c75ced08ab1e0d..4e9e340fa0d426ff7d57d08a7708502a15d5ccda 100644 --- a/src/agent_map.c +++ b/src/agent_map.c @@ -3982,8 +3982,10 @@ int agent_process_assoc_cntl_tlv(void *agent, uint8_t *p, __func__, disallow ? "Disallow" : "Allow", MAC2STR(data->bssid), ap->name); ret = wifi_set_backhaul_bss_association_mode(ap->name, disallow); - if (!ret) + if (!ret) { ap->cfg->disallow_assoc = disallow; + uci_apply_bss_association_mode(ap->name, disallow); + } return ret; } diff --git a/src/config.c b/src/config.c index 471060873e4cfdd90ab22aadb7fde56866463b42..240c123b19136262628e44d118f3024b9ff04e0a 100644 --- a/src/config.c +++ b/src/config.c @@ -623,8 +623,8 @@ out: } /* below functions are mostly taken from ieee1905d */ -bool uci_check_wifi_iface(char *package_name, char *ifname, - char *section) +bool uci_check_wifi_iface(const char *package_name, const char *ifname, + const char *section) { bool ret; struct uci_context *ctx; @@ -665,9 +665,9 @@ bool uci_check_wifi_iface(char *package_name, char *ifname, return ret; } -bool uci_set_wireless_interface_option(char *package_name, - char *section_type, char *search_key, char *search_val, - char *option, char *value) +bool uci_set_wireless_interface_option(const char *package_name, + const char *section_type, const char *search_key, const char *search_val, + const char *option, const char *value) { struct uci_context *ctx; struct uci_package *pkg; @@ -767,8 +767,8 @@ static bool get_encryption_value(uint16_t auth_type, uint16_t encryption_type, return true; } -bool uci_add_wireless_iface_sec(char *package_name, char *interface_name, - char *section_type, char *section_name) +bool uci_add_wireless_iface_sec(const char *package_name, const char *interface_name, + const char *section_type, const char *section_name) { struct uci_context *ctx; struct uci_package *pkg; @@ -2496,6 +2496,7 @@ static int agent_config_get_ap(struct agent_config *a, AP_VID, AP_TYPE, AP_BSTA_DISALLOW, + AP_DISALLOW_ASSOC, NUM_POLICIES, }; const struct uci_parse_option opts[] = { @@ -2516,7 +2517,8 @@ static int agent_config_get_ap(struct agent_config *a, { .name = "enabled", .type = UCI_TYPE_STRING }, { .name = "vid", .type = UCI_TYPE_STRING }, { .name = "type", .type = UCI_TYPE_STRING }, - { .name = "disallow_bsta_profile", .type = UCI_TYPE_LIST } + { .name = "disallow_bsta_profile", .type = UCI_TYPE_LIST }, + { .name = "disallow_assoc", .type = UCI_TYPE_STRING } }; struct uci_option *tb[NUM_POLICIES]; struct netif_apcfg *ap; @@ -2677,6 +2679,9 @@ static int agent_config_get_ap(struct agent_config *a, } } + if (tb[AP_DISALLOW_ASSOC]) + ap->disallow_assoc = atoi(tb[AP_DISALLOW_ASSOC]->v.string); + return 0; } @@ -4029,3 +4034,18 @@ int agent_config_opclass(struct wifi_radio_element *radio) return 0; } +void uci_apply_bss_association_mode(const char *interface_name, bool disallow_assoc) +{ + bool ret = uci_check_wifi_iface(UCI_AGENT, interface_name, UCI_AP_AGENT); + + if (!ret) { + ret = uci_add_wireless_iface_sec(UCI_AGENT, interface_name, + UCI_AP_AGENT, NULL); + if (!ret) + return; + } + + uci_set_wireless_interface_option(UCI_AGENT, UCI_AP_AGENT, "ifname", + interface_name, "disallow_assoc", + disallow_assoc ? "1" : "0"); +} diff --git a/src/config.h b/src/config.h index 2cb7c6840e201e4d614ff83d0a3b36dfbe8c52a6..80dab5281ffaf835a27ded6cdb77b24286cf6fc7 100644 --- a/src/config.h +++ b/src/config.h @@ -331,13 +331,13 @@ int config_add_default_wifi_iface(const char *config, const char *type, const char *ifname, const char *device, const char *network, const char *mode); -bool uci_check_wifi_iface(char *package_name, char *ifname, - char *section); -bool uci_set_wireless_interface_option(char *package_name, - char *section_type, char *search_key, char *search_val, - char *option, char *value); -bool uci_add_wireless_iface_sec(char *package_name, char *interface_name, - char *section_type, char *section_name); +bool uci_check_wifi_iface(const char *package_name, const char *ifname, + const char *section); +bool uci_set_wireless_interface_option(const char *package_name, + const char *section_type, const char *search_key, const char *search_val, + const char *option, const char *value); +bool uci_add_wireless_iface_sec(const char *package_name, const char *interface_name, + const char *section_type, const char *section_name); int agent_init_wsc_attributes(struct agent *a); int wifi_get_section_option(const char *package, const char *sec_type, const char *sec_key, const char *sec_value, @@ -369,5 +369,6 @@ void uci_apply_traffic_sep(struct tlv_traffic_sep_policy *tlv); int wifi_set_opclass_preference(char *radio_name, uint32_t opclass_id, uint32_t preference, uint8_t *channel_list, int channel_num); int agent_config_opclass(struct wifi_radio_element *radio); +void uci_apply_bss_association_mode(const char *interface_name, bool disallow_assoc); #endif