From 03a85b04d10c08dccd96381ef6f2ece91d16dc52 Mon Sep 17 00:00:00 2001 From: Kamil Zulewski <kamil.zulewski@iopsys.eu> Date: Tue, 19 Sep 2023 17:45:24 +0200 Subject: [PATCH] During init drop connected STAs if assoc. not allowed --- src/agent.c | 21 +++++++++++++++++++-- src/wifidefs.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/agent.c b/src/agent.c index d9e582294..ef0e69e7b 100644 --- a/src/agent.c +++ b/src/agent.c @@ -2604,11 +2604,28 @@ out_str: } } +static void agent_iface_disconnect_all_sta(const struct netif_ap *iface, + uint16_t reason) +{ + struct sta *sta; + + list_for_each_entry(sta, &iface->stalist, list) { + wifi_disconnect_sta(iface->name, sta->macaddr, reason); + } + +} + static void agent_init_ifaces_assoc_mode(struct agent *a) { const struct netif_ap *iface; list_for_each_entry(iface, &a->aplist, list) { + if (iface->cfg->disallow_assoc) { + agent_iface_disconnect_all_sta( + iface, + WIFI_REASON_SERVICE_NOT_AUTHORIZED_IN_THIS_LOCATION); + } + wifi_set_backhaul_bss_association_mode(iface->name, iface->cfg->disallow_assoc); } @@ -2624,6 +2641,7 @@ static void apply_iface_assocation_mode(struct agent *a, const char *ifname) } } + static void wifi_iface_event_handler(void *c, struct blob_attr *msg) { struct agent *a = (struct agent *)c; @@ -6818,8 +6836,6 @@ 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); @@ -6854,6 +6870,7 @@ void run_agent(void) timer_init(&w->cfg.metric_report_timer, agent_metric_report_timer_cb); agent_init_interfaces(w); + agent_init_ifaces_assoc_mode(w); /* switch to the channel according to the prefrence */ //agent_switch_according_to_pref(w); diff --git a/src/wifidefs.h b/src/wifidefs.h index b068c93aa..9e47aa45a 100644 --- a/src/wifidefs.h +++ b/src/wifidefs.h @@ -39,6 +39,7 @@ extern "C" { #define WIFI_REASON_DISASSOC_STA_HAS_LEFT 8 #define WIFI_REASON_BSS_TRANSITION_DISASSOC 12 +#define WIFI_REASON_SERVICE_NOT_AUTHORIZED_IN_THIS_LOCATION 30 /** wifi status and reason code as per IEEE802.11 Std. */ typedef uint16_t wifi_status_t, wifi_reason_t; -- GitLab