From 5790862a5223d89968c8546886c0fb2e6ad0f6f7 Mon Sep 17 00:00:00 2001 From: Jakob Olsson <jakob.olsson@iopsys.eu> Date: Wed, 9 Mar 2022 13:10:33 +0100 Subject: [PATCH] prevent bssid from being written to bsta if band is not onboarded --- src/agent.c | 19 +++++++++++++++++++ src/config.c | 12 +++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/agent.c b/src/agent.c index 9c8eb0c9d..afa06ee07 100644 --- a/src/agent.c +++ b/src/agent.c @@ -3424,6 +3424,18 @@ static void agent_update_active_uplink(struct agent *a, char *ifname) runCmd("/lib/wifi/multiap set_uplink wifi %s", ifname); } +static bool wifi_is_band_onboarded(struct agent *a, enum wifi_band band) +{ + struct agent_config_radio *rcfg = NULL; + + list_for_each_entry(rcfg, &a->cfg.radiolist, list) { + if (rcfg->onboarded && rcfg->band == band) + return true; + } + + return false; +} + static void wifi_bsta_connect(struct agent *a, struct netif_bk *bk, uint8_t *bssid) { @@ -3431,6 +3443,13 @@ static void wifi_bsta_connect(struct agent *a, struct netif_bk *bk, char fmt[64] = {0}; int bssid_expired = 0; + /* no operation if no bsta on same band is onboarded! */ + if (!wifi_is_band_onboarded(a, bk->cfg->band)) { + dbg("|%s:%d| band %d is not onboard\n", __func__, __LINE__, + bk->cfg->band); + return; + } + bk->connected = true; a->connected = true; diff --git a/src/config.c b/src/config.c index a8982ea57..15c1637b4 100644 --- a/src/config.c +++ b/src/config.c @@ -1986,13 +1986,23 @@ static int agent_config_get_wifi_radio(struct agent_config *a, strncpy(n->name, ifname, 16); n->name[15] = '\0'; - n->band = band; + if (band == 2) + n->band = BAND_2; + else if (band == 5) + n->band = BAND_5; + else + n->band = BAND_UNKNOWN; if (tb[WIFI_RADIO_CONFIGURED]) { n->configured = atoi(tb[WIFI_RADIO_CONFIGURED]->v.string) == 1 ? true : false; } + if (tb[WIFI_RADIO_ONBOARDED]) { + n->onboarded = atoi(tb[WIFI_RADIO_ONBOARDED]->v.string) == 1 ? + true : false; + } + if (tb[WIFI_RADIO_DEDICATED]) { n->dedicated_backhaul = atoi(tb[WIFI_RADIO_DEDICATED]->v.string) == 1 ? true : false; -- GitLab