From 10400f7d852ab01bef6e14dde68db7b152596de1 Mon Sep 17 00:00:00 2001
From: Jakob Olsson <jakob.olsson@iopsys.eu>
Date: Wed, 19 Mar 2025 16:27:49 +0100
Subject: [PATCH] wip2 dump
---
src/agent.c | 122 ++++++++++++++---------------
src/agent.h | 18 +++--
src/agent_map.c | 10 +--
src/agent_tlv.c | 2 +-
src/mld.c | 199 ++++++++++++++++++++++++++++--------------------
src/mld.h | 56 +++++++-------
src/wifi_ubus.c | 5 +-
7 files changed, 224 insertions(+), 188 deletions(-)
diff --git a/src/agent.c b/src/agent.c
index 539e91f8a..6a7ca49ca 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -95,7 +95,6 @@ static int agent_req_btm_steer(struct agent *a, const char *ifname,
uint32_t validity_int);
static void netif_free(struct netif_ap *ap);
static void netif_reset(struct netif_ap *ap);
-void agent_clear_bsta_mld(struct agent *a);
static void bsta_steer_cb(atimer_t *t)
{
@@ -1462,10 +1461,10 @@ static void wifi_sta_periodic_run(atimer_t *t)
{
struct sta *s = container_of(t, struct sta, sta_timer);
struct pref_neighbor *pref_nbr = NULL;
- struct netif_ap *ap;
+ struct agent *a = s->agent;
struct wifi_sta sta = {};
+ struct netif_ap *ap;
unsigned int reason;
- struct agent *a = s->agent;
int ret = 0;
ap = agent_get_ap(a, s->bssid);
@@ -1497,12 +1496,8 @@ static void wifi_sta_periodic_run(atimer_t *t)
#if (EASYMESH_VERSION >= 6)
} else {
struct wifi_mlsta mlsta = {0};
- uint8_t *mld_macaddr = NULL;
- if (s->mld)
- mld_macaddr = s->mld->macaddr;
-
- ret = wifi_get_mld_station(ap, mld_macaddr, s->macaddr, &mlsta);
+ ret = wifi_get_mld_station(ap, s->mld_macaddr, s->macaddr, &mlsta);
if (ret)
goto rearm_periodic;
@@ -1516,17 +1511,10 @@ static void wifi_sta_periodic_run(atimer_t *t)
return;
}
-
- //err("%s: mac:"MACFMT" linkbssid:"MACFMT" mlo_link_id:%d\n",
- // __func__, MAC2STR(s->macaddr),
- // MAC2STR(mlsta.sta[0].bssid),
- // mlsta.sta[0].mlo_link_id);
-
- if (mlsta.mlo_capable == true
- && !hwaddr_is_zero(mlsta.sta[0].bssid)
- && ap->mld) {
+ if (mlsta.mlo_capable == true &&
+ !hwaddr_is_zero(mlsta.sta[0].bssid))
mlsta_update_sta_mld(a, ap, &mlsta, s);
- }
+
update_sta_entry(a, ap, &(mlsta.sta[0]));
}
#endif
@@ -2281,6 +2269,7 @@ static uint16_t wifi_process_pvid_assoc_frame(struct agent *a, uint8_t *frame,
}
#define ASSOC_TIMEOUT 60
+/* TODO: add dedicated handler for each event type */
static void wifi_sta_event_handler(void *c, struct blob_attr *msg)
{
struct agent *a = (struct agent *)c;
@@ -2341,10 +2330,8 @@ static void wifi_sta_event_handler(void *c, struct blob_attr *msg)
return;
ap = agent_get_ap(a, bssid);
- if (!ap) {
- /* could also do link-id check here? */
+ if (!ap)
return;
- }
strncpy(ifname, ap->ifname, sizeof(ifname) - 1);
}
#endif
@@ -2354,20 +2341,21 @@ static void wifi_sta_event_handler(void *c, struct blob_attr *msg)
s = wifi_add_sta(a, ifname, macaddr);
else
s = agent_get_sta(a, macaddr);
+#else
+ s = agent_get_sta(a, macaddr);
+#endif
if (!s) {
dbg("%s: Failed to add STA or STA has already disconnected\n", __func__);
return;
}
-#endif
-
#if (EASYMESH_VERSION >= 6)
/* Affiliated STA MAC in-case of MLO client*/
if (add && data[2] && data[3] && data[4]) {
- uint8_t linkid = 0;
+ uint8_t mlo_link_id = 0;
- linkid = (uint8_t) blobmsg_get_u32(data[4]);
+ mlo_link_id = (uint8_t) blobmsg_get_u32(data[4]);
- if (ap && ap->mld) {
+ if (ap) {
uint8_t mlo_bssid[6] = {0};
struct sta_mld *mld;
int num_sta = 0;
@@ -2378,7 +2366,13 @@ static void wifi_sta_event_handler(void *c, struct blob_attr *msg)
return;
mld = agent_get_stamld(a, mlo_macaddr);
if (!mld) {
- mld = agent_alloc_stamld(a, ap->mld, mlo_macaddr);
+ struct netif_mld *apmld;
+
+ apmld = agent_get_apmld(a, ap->mld_macaddr);
+ if(!apmld)
+ return;
+
+ mld = agent_alloc_stamld(a, apmld, mlo_macaddr);
if (!mld) {
err("%s: Failed to allocate MLD:"MACFMT"\n", __func__, MAC2STR(mlo_macaddr));
return;
@@ -2390,13 +2384,13 @@ static void wifi_sta_event_handler(void *c, struct blob_attr *msg)
/* TODO: code is copy pasted from mlsta_update_sta_mld() */
num_sta = mld->num_affiliated_sta;
- s->mld = mld;
+ memcpy(s->mld_macaddr, mld->macaddr, 6);
s->is_affiliated_sta = true;
- s->mlo_link_id = linkid;
+ s->mlo_link_id = mlo_link_id;
- if (!agent_is_sta_in_sta_mld(a, mld, macaddr) &&
+ if (!mld_contains_sta(a, mld, macaddr) &&
num_sta < MAX_AFFILIATED_STA_LINKS_NUM) {
- mld->affiliated_sta[num_sta] = s;
+ memcpy(mld->affiliated_sta[num_sta], s->macaddr, 6);
mld->num_affiliated_sta++;
}
@@ -4490,7 +4484,7 @@ static void agent_event_handler(struct ubus_context *ctx,
#endif
#endif
#if (EASYMESH_VERSION >= 6)
- { "wifi.mld", wifi_mld_event_handler },
+ { "wifi.mld", mld_event_handler },
#endif
};
@@ -5546,7 +5540,7 @@ static void parse_ap(struct ubus_request *req, int type,
}
if (tb[12])
- ap->linkid = blobmsg_get_u32(tb[12]);
+ ap->mlo_link_id = blobmsg_get_u32(tb[12]);
#endif
if (tb[13]) {
@@ -5788,7 +5782,7 @@ int agent_init_interfaces(struct agent *a)
ap->enabled = false;
#if (EASYMESH_VERSIN >= 6)
if (ap->is_affiliated_ap)
- wifi_mld_del_ap(ap);
+ mld_del_ap(ap);
#endif
}
}
@@ -5855,7 +5849,7 @@ int agent_init_interfaces(struct agent *a)
f->mld_id);
if (mldcred) {
snprintf(objname, 31, "wifi.apmld.%s", mldcred->ifname);
- fn_parser = parse_apmld;
+ fn_parser = apmld_parse;
band = band_to_int(re->band);
}
}
@@ -5886,7 +5880,7 @@ int agent_init_interfaces(struct agent *a)
blob_buf_init(&bb, 0);
#if (EASYMESH_VERSION >= 6)
- if (band)
+ if (f->mld_id)
blobmsg_add_u32(&bb, "band", band);
#endif
ubus_call_object_args(a, uobj_id, &bb, "stats", parse_ap_stats, bss);
@@ -5895,7 +5889,7 @@ int agent_init_interfaces(struct agent *a)
}
/** if AP is gone from config free it altogether
- * if AP is disabled, cancel all timers/data
+ * if AP is disabled, cancel all timers and clear data
*/
list_for_each_entry(re, &a->radiolist, list) {
struct netif_ap *ap, *tmp;
@@ -5947,7 +5941,7 @@ int agent_init_interfaces(struct agent *a)
b->mld_id);
if (mldcred) {
snprintf(objname, 31, "wifi.bstamld.%s", mldcred->ifname);
- bk_parser = parse_bstamld;
+ bk_parser = bstamld_parse;
}
}
#endif
@@ -5978,9 +5972,9 @@ int agent_init_interfaces(struct agent *a)
}
if (a->has_bstamld) {
- /* if bsta config has gone away free bstamld */
+ /* if bsta config has gone away clear bstamld */
if (!agent_get_bsta_mld_credential(&a->cfg))
- agent_clear_bsta_mld(a);
+ bstamld_free(a);
}
#endif
@@ -6491,7 +6485,7 @@ void clear_sta(struct sta *s)
}
#if (EASYMESH_VERSION >= 6)
if (s->is_affiliated_sta)
- wifi_sta_mld_del_sta(s->agent, s);
+ mld_del_sta(s->agent, s);
#endif
free(s);
}
@@ -6547,7 +6541,7 @@ static void netif_reset(struct netif_ap *ap)
#if (EASYMESH_VERSION >= 6)
if (ap->is_affiliated_ap)
- wifi_mld_del_ap(ap);
+ mld_del_ap(ap);
#endif
}
@@ -6598,7 +6592,7 @@ void clear_bk(struct agent *a, struct netif_bk *bk)
{
#if (EASYMESH_VERSION >= 6)
if (bk->is_affiliated_sta)
- wifi_sta_mld_del_bsta(a, bk);
+ mld_del_bsta(a, bk);
#endif
memset(bk, 0, sizeof(*bk));
}
@@ -7002,7 +6996,7 @@ void run_agent(void)
qos_rule_free_all(&w->qos_rules);
#endif
#if (EASYMESH_VERSION >= 6)
- agent_clear_bsta_mld(w);
+ bstamld_free(w);
clear_apmldlist(w);
#endif
ubus_unregister_event_handler(ctx, &w->evh);
@@ -7194,7 +7188,6 @@ int wifiagent_get_status(struct ubus_context *ctx,
{
struct agent *agent = this_agent;
struct wifi_radio_element *re;
- struct netif_ap *p = NULL;
struct neighbor *n;
struct blob_buf bb;
void *a, *b, *c, *d, *t;
@@ -7204,6 +7197,8 @@ int wifiagent_get_status(struct ubus_context *ctx,
a = blobmsg_open_array(&bb, "radios");
list_for_each_entry(re, &agent->radiolist, list) {
+ struct netif_ap *ap = NULL;
+
t = blobmsg_open_table(&bb, "");
blobmsg_add_string(&bb, "name", re->name);
blobmsg_add_macaddr(&bb, "macaddr", re->macaddr);
@@ -7220,37 +7215,42 @@ int wifiagent_get_status(struct ubus_context *ctx,
blobmsg_close_table(&bb, b);
d = blobmsg_open_array(&bb, "fronthaul");
- list_for_each_entry(p, &re->aplist, list) {
+ list_for_each_entry(ap, &re->aplist, list) {
struct sta *s;
void *tt;
- if (!p->cfg)
+ if (!ap->cfg)
continue;
tt = blobmsg_open_table(&bb, "");
- blobmsg_add_string(&bb, "name", p->ifname);
+ blobmsg_add_string(&bb, "name", ap->ifname);
#if (EASYMESH_VERSION >= 6)
- blobmsg_add_u8(&bb, "is_affiliated_ap", p->is_affiliated_ap);
- if (p->is_affiliated_ap && p->mld) {
- blobmsg_add_string(&bb, "mld_ifname", p->mld->ifname);
- blobmsg_add_u32(&bb, "mlo_linkid", p->linkid);
+ blobmsg_add_u8(&bb, "is_affiliated_ap", ap->is_affiliated_ap);
+ if (ap->is_affiliated_ap) {
+ struct netif_mld *apmld;
+
+ apmld = agent_get_apmld(a, ap->mld_macaddr);
+ if (apmld) {
+ blobmsg_add_string(&bb, "mld_ifname", apmld->ifname);
+ blobmsg_add_u32(&bb, "mlo_link_id", ap->mlo_link_id);
+ }
}
#endif
- if (p->band == BAND_2)
+ if (ap->band == BAND_2)
blobmsg_add_string(&bb, "band", "2.4GHz");
- else if (p->band == BAND_5)
+ else if (ap->band == BAND_5)
blobmsg_add_string(&bb, "band", "5GHz");
- else if (p->band == BAND_6)
+ else if (ap->band == BAND_6)
blobmsg_add_string(&bb, "band", "6GHz");
else
blobmsg_add_string(&bb, "band", "Unknown");
- blobmsg_add_u8(&bb, "enabled", p->enabled);
- blobmsg_add_macaddr(&bb, "bssid", p->bssid);
- blobmsg_add_string(&bb, "ssid", p->ssid);
- blobmsg_add_u32(&bb, "channel", p->channel);
- blobmsg_add_u32(&bb, "load", p->bssload);
- blobmsg_add_u32(&bb, "num_sta", p->num_sta);
+ blobmsg_add_u8(&bb, "enabled", ap->enabled);
+ blobmsg_add_macaddr(&bb, "bssid", ap->bssid);
+ blobmsg_add_string(&bb, "ssid", ap->ssid);
+ blobmsg_add_u32(&bb, "channel", ap->channel);
+ blobmsg_add_u32(&bb, "load", ap->bssload);
+ blobmsg_add_u32(&bb, "num_sta", ap->num_sta);
b = blobmsg_open_array(&bb, "neighbor");
list_for_each_entry(n, &p->nbrlist, list) {
diff --git a/src/agent.h b/src/agent.h
index ba5174f9f..8f9b458f1 100644
--- a/src/agent.h
+++ b/src/agent.h
@@ -318,8 +318,8 @@ struct netif_ap {
#if (EASYMESH_VERSION >= 6)
bool is_affiliated_ap;
char mld_ifname[16];
- uint32_t linkid;
- struct netif_mld *mld;
+ uint32_t mlo_link_id;
+ uint8_t mld_macaddr[6];
#endif
struct wifi_bss_element bss;
@@ -351,9 +351,9 @@ struct netif_bk {
#if (EASYMESH_VERSION >= 6)
bool is_affiliated_sta;
char mld_ifname[16];
- uint32_t linkid;
- struct bsta_mld *mld;
- bool is_mld_netdev;
+ uint32_t mlo_link_id;
+ //struct bsta_mld *mld;
+ uint8_t mld_macaddr[6];
#endif
/* enum netif_type iftype; */
struct agent *agent;
@@ -386,7 +386,8 @@ struct sta {
#if (EASYMESH_VERSION >= 6)
bool is_affiliated_sta;
uint8_t mlo_link_id;
- struct sta_mld *mld;
+ //struct sta_mld *mld;
+ uint8_t mld_macaddr[6];
uint8_t ruid[6];
#endif
uint32_t caps; /** capability bitmap */
@@ -763,7 +764,6 @@ struct wifi_sta_steer_list {
#if (EASYMESH_VERSION >= 6)
/* TODO: FIXME!! MUST BE MOVED TO MLD.H */
struct bsta_mld {
-#define MAX_AFFILIATED_BSTA_LINKS_NUM 14
uint8_t macaddr[6];
uint8_t bssid[6];
char ifname[16];
@@ -776,7 +776,9 @@ struct bsta_mld {
bool emlmr_enabled;
int num_affiliated_bsta;
- struct netif_bk *affiliated_bsta[MAX_AFFILIATED_BSTA_LINKS_NUM];
+ //struct netif_bk *affiliated_bsta[MAX_AFFILIATED_BSTA_LINKS_NUM];
+#define MAX_AFFILIATED_BSTA_LINKS_NUM 14
+ uint8_t affiliated_bsta[MAX_AFFILIATED_BSTA_LINKS_NUM][6];
struct list_head list;
};
diff --git a/src/agent_map.c b/src/agent_map.c
index 4eb3de3e4..0af4c2a9b 100644
--- a/src/agent_map.c
+++ b/src/agent_map.c
@@ -2224,7 +2224,7 @@ static int mlo_process_ap_mld_config(struct agent *a, uint8_t *tlv_data)
if (apcfg->mld_id) {
struct netif_ap *ap;
- mlo_update_id_in_configs(apcfg->name, 0);
+ mld_set_config_id(apcfg->name, 0);
apcfg->mld_id = 0;
ap = agent_get_ap_by_ifname(a, apcfg->name);
if (ap)
@@ -2380,7 +2380,7 @@ static int mlo_process_ap_mld_config(struct agent *a, uint8_t *tlv_data)
mld_complete = true;
/* Set mld_id/mld in ap/wifi-iface sections of cfg files */
- mlo_update_id_in_configs(apcfg->name, id);
+ mld_set_config_id(apcfg->name, id);
apcfg->mld_id = id;
}
}
@@ -2800,7 +2800,7 @@ int handle_ap_autoconfig_wsc(void *agent, struct cmdu_buff *rx_cmdu,
ret = mlo_process_bsta_mld_config(a,
tv[AP_AUTOCONFIGURATION_WSC_M2_BACKHAUL_STA_MLD_CONFIG_IDX][0]->data);
if (ret)
- wifi_teardown_map_bsta_mld(a, radio->band);
+ bstamld_teardown_band(a, radio->band);
update_tlv_hash(a, tv[AP_AUTOCONFIGURATION_WSC_M2_BACKHAUL_STA_MLD_CONFIG_IDX][0],
a->bsta_mld_cfg_sha256);
a->reconfig_reason |= AGENT_RECONFIG_REASON_MLD_ID;
@@ -2808,7 +2808,7 @@ int handle_ap_autoconfig_wsc(void *agent, struct cmdu_buff *rx_cmdu,
} else {
dbg("%s: Missing BSTA MLD config TLV, teardown\n",
__func__);
- wifi_teardown_map_bsta_mld(a, radio->band);
+ bstamld_teardown_band(a, radio->band);
}
#endif
@@ -6697,7 +6697,7 @@ int handle_bsta_mld_config_request(void *agent, struct cmdu_buff *cmdu, struct n
if (ret) {
uint32_t band_all = BAND_2 | BAND_5 | BAND_6;
- wifi_teardown_map_bsta_mld(a, band_all);
+ bstamld_teardown_band(a, band_all);
} else {
/* re-do all MLD configuration in case TLV has changed */
dbg("%s: MLD configuration changed, schedule reconfig\n",
diff --git a/src/agent_tlv.c b/src/agent_tlv.c
index 6ea3380a9..66a59ddce 100644
--- a/src/agent_tlv.c
+++ b/src/agent_tlv.c
@@ -4798,7 +4798,7 @@ int agent_gen_affiliated_ap_metrics(struct agent *a, struct cmdu_buff *frm,
struct tlv *t;
int ret;
- if (!wifi_is_affiliated_ap(a, bss->bssid))
+ if (!is_affiliated_ap(a, bss->bssid))
return 0;
t = cmdu_reserve_tlv(frm, sizeof(*data));
diff --git a/src/mld.c b/src/mld.c
index 961383c38..ca6253ba2 100644
--- a/src/mld.c
+++ b/src/mld.c
@@ -6,9 +6,40 @@
#include "utils/debug.h"
#include "utils/utils.h"
#include "backhaul.h"
-#include "agent.h"
+#include "agent.h
+"
+void stamld_update(struct agent *a, )
+{
+ mld = agent_get_stamld(a, mlsta->macaddr);
+ if (!mld) {
+ struct netif_mld *apmld;
+
+ apmld = agent_get_apmld(a, ap->mld_macaddr);
+ if (!apmld)
+ return;
+
+ mld = agent_alloc_stamld(a, apmld, mlsta->macaddr);
+ if (!mld)
+ return;
+ }
+
+ memcpy(mld->bssid, mlsta->bssid, 6);
+ num_sta = mld->num_affiliated_sta;
+
+ memcpy(s->mld_macaddr, mld->macaddr);
+ s->is_affiliated_sta = true;
+ s->mlo_link_id = mlsta->sta[0].mlo_link_id;
+
+ if (!mld_contains_sta(a, mld, mlsta->sta[0].macaddr) &&
+ num_sta < MAX_AFFILIATED_STA_LINKS_NUM) {
+ memcpy(mld->affiliated_sta[num_sta], s->macaddr, 6);
+ mld->num_affiliated_sta++;
+ }
+
+}
+
void mlsta_update_sta_mld(struct agent *a, struct netif_ap *ap,
- struct wifi_mlsta *mlsta, struct sta *s)
+ struct wifi_mlsta *mlsta, struct sta *s)
{
struct sta_mld *mld;
int num_sta = 0;
@@ -22,7 +53,13 @@ void mlsta_update_sta_mld(struct agent *a, struct netif_ap *ap,
mld = agent_get_stamld(a, mlsta->macaddr);
if (!mld) {
- mld = agent_alloc_stamld(a, ap->mld, mlsta->macaddr);
+ struct netif_mld *apmld;
+
+ apmld = agent_get_apmld(a, ap->mld_macaddr);
+ if (!apmld)
+ return;
+
+ mld = agent_alloc_stamld(a, apmld, mlsta->macaddr);
if (!mld)
return;
}
@@ -30,13 +67,13 @@ void mlsta_update_sta_mld(struct agent *a, struct netif_ap *ap,
memcpy(mld->bssid, mlsta->bssid, 6);
num_sta = mld->num_affiliated_sta;
- s->mld = mld;
+ memcpy(s->mld_macaddr, mld->macaddr);
s->is_affiliated_sta = true;
s->mlo_link_id = mlsta->sta[0].mlo_link_id;
- if (!agent_is_sta_in_sta_mld(a, mld, mlsta->sta[0].macaddr) &&
+ if (!mld_contains_sta(a, mld, mlsta->sta[0].macaddr) &&
num_sta < MAX_AFFILIATED_STA_LINKS_NUM) {
- mld->affiliated_sta[num_sta] = s;
+ memcpy(mld->affiliated_sta[num_sta], s->macaddr, 6);
mld->num_affiliated_sta++;
}
@@ -46,15 +83,15 @@ void mlsta_update_sta_mld(struct agent *a, struct netif_ap *ap,
}
/* remove passed affiliated STA from mld */
-int wifi_sta_mld_del_sta(struct agent *a, struct sta *s)
+int mld_del_sta(struct agent *a, struct sta *s)
{
struct sta_mld *mld;
int i;
- if (!s->mld)
+ mld = agent_get_stamld(a, s->mld_macaddr);
+ if (!mld)
return -1;
- mld = s->mld;
for (i = 0; i < mld->num_affiliated_sta; i++) {
int j;
@@ -64,8 +101,9 @@ int wifi_sta_mld_del_sta(struct agent *a, struct sta *s)
for (j = (i + 1); j < mld->num_affiliated_sta; j++)
mld->affiliated_sta[j-1] = mld->affiliated_sta[j];
- mld->affiliated_sta[j] = NULL;
+ memset(mld->affiliated_sta[j], 0, 6)
mld->num_affiliated_sta--;
+ break;
}
if (mld->num_affiliated_sta == 0) {
@@ -77,38 +115,32 @@ int wifi_sta_mld_del_sta(struct agent *a, struct sta *s)
}
/* remove passed affiliated backhaul STA from mld */
-int wifi_sta_mld_del_bsta(struct agent *a, struct netif_bk *bk)
+int mld_del_bsta(struct agent *a, struct netif_bk *bk)
{
struct bsta_mld *mld;
int i, j;
- /* bk->mld may be NULL if bSTAMLD is not connected (Eth backhaul) */
- if (!bk || bk->cfg->is_mld_netdev || !bk->mld)
+ if (!a->has_bstamld || bk->cfg->is_mld_netdev)
return -1;
- mld = bk->mld;
+ mld = &a->bstamld;
for (i = 0; i < mld->num_affiliated_bsta; i++) {
- if (!memcmp(mld->affiliated_bsta[i]->macaddr, bk->macaddr, 6))
- break;
- }
-
- if (i == mld->num_affiliated_bsta)
- return -1;
+ if (memcmp(mld->affiliated_bsta[i]->macaddr, bk->macaddr, 6))
+ continue;
- for (j = (i + 1); j < mld->num_affiliated_bsta; j++)
- mld->affiliated_bsta[j-1] = mld->affiliated_bsta[j];
+ for (j = (i + 1); j < mld->num_affiliated_bsta; j++)
+ mld->affiliated_bsta[j-1] = mld->affiliated_bsta[j];
- mld->affiliated_bsta[j] = NULL;
- mld->num_affiliated_bsta--;
+ memset(mld->affiliated_bsta[j], 0, 6)
+ mld->num_affiliated_bsta--;
+ }
- bk->mld = NULL;
bk->is_affiliated_sta = false;
-
return 0;
}
/* remove passed affiliated AP from mld */
-int wifi_mld_del_ap(struct netif_ap *ap)
+int mld_del_ap(struct agent *a, struct netif_ap *ap)
{
struct netif_mld *mld;
int i;
@@ -116,13 +148,9 @@ int wifi_mld_del_ap(struct netif_ap *ap)
if (!ap->is_affiliated_ap)
return -1;
- if (!ap->mld) {
- warn("|%s:%d| MLD for given netif is not assigned!\n",
- __func__, __LINE__);
+ mld = agent_get_apmld(a, ap->mld_macaddr);
+ if (!mld)
return -1;
- }
-
- mld = ap->mld;
for (i = 0; i < mld->num_affiliated_ap; i++) {
int j;
@@ -133,12 +161,11 @@ int wifi_mld_del_ap(struct netif_ap *ap)
for (j = (i + 1); j < mld->num_affiliated_ap; j++)
mld->affiliated_ap[j-1] = mld->affiliated_ap[j];
- mld->affiliated_ap[j] = NULL;
+ memset(mld->affiliated_bsta[j], 0, 6)
mld->num_affiliated_ap--;
}
- ap->mld = NULL;
- ap->is_affiliated_ap = false;
+ ap->is_affiliated_ap = false;
return 0;
}
@@ -221,7 +248,7 @@ int wifi_process_ml_ie(struct agent *a, struct sta_mld *stamld,
return 0;
}
-void wifi_mld_event_handler(void *agent, struct blob_attr *msg)
+void mld_event_handler(void *agent, struct blob_attr *msg)
{
char ifname[16] = {0}, event[16] = {0};
struct agent *a = (struct agent *) agent;
@@ -255,7 +282,7 @@ void wifi_mld_event_handler(void *agent, struct blob_attr *msg)
}
}
-int parse_affiliated_ap(struct ubus_request *req, int type,
+int mld_parse_affiliated_ap(struct ubus_request *req, int type,
struct blob_attr *msg)
{
struct netif_ap *ap = (struct netif_ap *) req->priv;
@@ -312,7 +339,7 @@ int parse_affiliated_ap(struct ubus_request *req, int type,
return 0;
}
-void parse_apmld(struct ubus_request *req, int type,
+void apmld_parse(struct ubus_request *req, int type,
struct blob_attr *msg)
{
static const struct blobmsg_policy ap_attr[] = {
@@ -383,17 +410,18 @@ void parse_apmld(struct ubus_request *req, int type,
continue;
}
- ret = parse_affiliated_ap(req, type, link);
+ ret = mld_parse_affiliated_ap(req, type, link);
if (ret)
continue;
strncpy(ap->mld_ifname, ifname, sizeof(ap->mld_ifname) - 1);
+ memcmpy(ap->mld_macaddr, mld->macaddr, 6);
ap->is_affiliated_ap = true;
strncpy(ap->ssid, ssid, sizeof(ap->ssid));
ap->enabled = true;
num_ap = mld->num_affiliated_ap;
- if (!agent_is_ap_in_mld(a, mld, ap->bssid) &&
+ if (!mld_contains_ap(a, mld, ap->bssid) &&
num_ap < MAX_AFFILIATED_AP_LINKS_NUM) {
mld->affiliated_ap[num_ap] = ap;
mld->num_affiliated_ap++;
@@ -417,7 +445,6 @@ void parse_apmld(struct ubus_request *req, int type,
mld->ap_emlmr_enabled = true;
}
}
- ap->mld = mld;
break;
}
@@ -429,7 +456,7 @@ void parse_apmld(struct ubus_request *req, int type,
}
}
-void parse_affiliated_bsta(struct agent *a, struct bsta_mld *mld,
+void mld_parse_affiliated_bsta(struct agent *a, struct bsta_mld *mld,
struct netif_bk *bk, int type,
struct blob_attr *msg)
{
@@ -469,11 +496,11 @@ void parse_affiliated_bsta(struct agent *a, struct bsta_mld *mld,
hwaddr_aton(blobmsg_data(data[2]), bk->bssid);
num_sta = mld->num_affiliated_bsta;
- bk->mld = mld;
+ memcpy(bk->mld_macaddr, mld->macaddr, 6);
bk->is_affiliated_sta = true;
- bk->linkid = link_id;
+ bk->mlo_link_id = link_id;
- if (!agent_is_sta_in_bsta_mld(a, mld, bk->macaddr) &&
+ if (!mld_contains_bsta(a, mld, bk->macaddr) &&
num_sta < MAX_AFFILIATED_STA_LINKS_NUM) {
mld->affiliated_bsta[num_sta] = bk;
mld->num_affiliated_bsta++;
@@ -483,7 +510,7 @@ void parse_affiliated_bsta(struct agent *a, struct bsta_mld *mld,
}
}
-void parse_bstamld(struct ubus_request *req, int type,
+void bstamld_parse(struct ubus_request *req, int type,
struct blob_attr *msg)
{
static const struct blobmsg_policy ap_attr[] = {
@@ -543,7 +570,7 @@ void parse_bstamld(struct ubus_request *req, int type,
memcpy(mld->bssid, bssid, 6);
if (bk->cfg->is_mld_netdev && !hwaddr_is_zero(bssid)) {
- bk->mld = mld;
+ memcpy(bk->mld_macaddr, mld->macaddr, 6);
memcpy(bk->macaddr, macaddr, 6);
memcpy(bk->bssid, bssid, 6);
}
@@ -558,13 +585,13 @@ void parse_bstamld(struct ubus_request *req, int type,
continue;
}
- parse_affiliated_bsta(a, mld, bk, type, link);
+ mld_parse_affiliated_bsta(a, mld, bk, type, link);
strncpy(bk->mld_ifname, ifname, sizeof(bk->mld_ifname) - 1);
+ memcpy(bk->mld_macaddr, mld->macaddr, 6);
bk->is_affiliated_sta = true;
if (ssid)
strncpy(bk->ssid, ssid, sizeof(bk->ssid));
bk->enabled = true;
- bk->mld = mld;
}
}
@@ -572,6 +599,18 @@ void parse_bstamld(struct ubus_request *req, int type,
bk_toggle(a, bk, bssid, 0);
}
+struct netif_mld *agent_get_apmld(struct agent *a, uint8_t *macaddr)
+{
+ struct netif_mld *mld = NULL;
+
+ list_for_each_entry(mld, &a->apmldlist, list) {
+ if (!memcmp(macaddr, mld->macaddr, 6))
+ return mld;
+ }
+
+ return NULL;
+}
+
struct netif_mld *agent_get_mld_by_ifname(struct agent *a, const char *ifname)
{
struct netif_mld *mld = NULL;
@@ -609,7 +648,7 @@ struct netif_mld *agent_alloc_mld(struct agent *a, const char *ifname)
}
-bool agent_is_ap_in_mld(struct agent *a, struct netif_mld *mld,
+bool mld_contains_ap(struct agent *a, struct netif_mld *mld,
uint8_t *macaddr)
{
int i;
@@ -622,7 +661,7 @@ bool agent_is_ap_in_mld(struct agent *a, struct netif_mld *mld,
return false;
}
-bool agent_is_sta_in_sta_mld(struct agent *a, struct sta_mld *mld,
+bool mld_contains_sta(struct agent *a, struct sta_mld *mld,
uint8_t *macaddr)
{
int i;
@@ -636,7 +675,7 @@ bool agent_is_sta_in_sta_mld(struct agent *a, struct sta_mld *mld,
}
-bool agent_is_sta_in_bsta_mld(struct agent *a, struct bsta_mld *mld,
+bool mld_contains_bsta(struct agent *a, struct bsta_mld *mld,
uint8_t *macaddr)
{
int i;
@@ -700,7 +739,7 @@ struct bsta_mld *agent_init_bstamld(struct agent *a, char *ifname,
return bsta;
}
-void agent_clean_affiliated_sta_mld(struct sta_mld *mld)
+void stamld_clean(struct sta_mld *mld)
{
int i;
@@ -710,7 +749,7 @@ void agent_clean_affiliated_sta_mld(struct sta_mld *mld)
if (!s)
continue;
- s->mld = NULL;
+ memset(s->mld_macaddr, 0, 6);
s->is_affiliated_sta = false;
mld->affiliated_sta[i] = NULL;
}
@@ -719,9 +758,9 @@ void agent_clean_affiliated_sta_mld(struct sta_mld *mld)
}
-void agent_free_sta_mld(struct sta_mld *mld)
+void stamld_free(struct sta_mld *mld)
{
- agent_clean_affiliated_sta_mld(mld);
+ stamld_clean(mld);
list_del(&mld->list);
free(mld);
@@ -736,12 +775,12 @@ void clear_stamldlist(struct agent *a)
struct sta_mld *smld = NULL, *tmp;
list_for_each_entry_safe(smld, tmp, &mld->stamldlist, list)
- agent_free_sta_mld(mld);
+ stamld_free(mld);
}
}
*/
-void agent_clean_affiliated_bsta_mld(struct bsta_mld *mld)
+void bstamld_clean(struct bsta_mld *mld)
{
int i;
@@ -751,7 +790,7 @@ void agent_clean_affiliated_bsta_mld(struct bsta_mld *mld)
if (!bk)
continue;
- bk->mld = NULL;
+ memset(bk->mld_macaddr, 0, 6);
bk->is_affiliated_sta = false;
mld->affiliated_bsta[i] = NULL;
}
@@ -764,12 +803,12 @@ void agent_clear_bsta_mld(struct agent *a)
{
struct bsta_mld *mld = &a->bstamld;
- agent_clean_affiliated_bsta_mld(mld);
+ bstamld_clean(mld);
a->has_bstamld = false;
}
-void agent_clean_affiliated_ap_mld(struct netif_mld *mld)
+void apmld_clean(struct netif_mld *mld)
{
int i;
@@ -779,7 +818,7 @@ void agent_clean_affiliated_ap_mld(struct netif_mld *mld)
if (!ap)
continue;
- ap->mld = NULL;
+ memset(ap->mld_macaddr, 0, 6);
ap->is_affiliated_ap = false;
mld->affiliated_ap[i] = NULL;
}
@@ -787,39 +826,31 @@ void agent_clean_affiliated_ap_mld(struct netif_mld *mld)
mld->num_affiliated_ap = 0;
}
-
-void agent_free_ap_mld(struct netif_mld *mld)
-{
- agent_clean_affiliated_ap_mld(mld);
-
- list_del(&mld->list);
- free(mld);
-}
-
-/* TODO: fix mld free funcs... too many and they are all different */
-
-void clear_apmld(struct netif_mld *mld)
+void apmld_free(struct netif_mld *mld)
{
struct sta_mld *smld = NULL, *stmp;
list_for_each_entry_safe(smld, stmp, &mld->stamldlist, list)
- agent_free_sta_mld(smld);
+ stamld_free(smld);
- agent_free_ap_mld(mld);
+ apmld_clean(mld);
+
+ list_del(&mld->list);
+ free(mld);
}
-void clear_apmldlist(struct agent *a)
+void apmld_free_all(struct agent *a)
{
struct netif_mld *mld = NULL, *tmp;
list_for_each_entry_safe(mld, tmp, &a->apmldlist, list) {
- clear_apmld(mld);
+ apmld_free(mld);
}
a->num_ap_mld = 0;
}
-bool wifi_is_affiliated_ap(struct agent *a, uint8_t *bssid)
+bool is_affiliated_ap(struct agent *a, uint8_t *bssid)
{
struct netif_ap *ap;
@@ -831,7 +862,7 @@ bool wifi_is_affiliated_ap(struct agent *a, uint8_t *bssid)
}
-bool agent_radio_support_ap_wifi7(struct wifi7_radio_capabilities *wifi7_caps)
+bool agent_radio_support_ap_mlo(struct wifi7_radio_capabilities *wifi7_caps)
{
if (wifi7_caps->ap_str_support || wifi7_caps->ap_nstr_support ||
wifi7_caps->ap_emlsr_support || wifi7_caps->ap_emlmr_support)
@@ -840,7 +871,7 @@ bool agent_radio_support_ap_wifi7(struct wifi7_radio_capabilities *wifi7_caps)
return false;
}
-bool agent_radio_support_bsta_wifi7(struct wifi7_radio_capabilities *wifi7_caps)
+bool agent_radio_support_bsta_mlo(struct wifi7_radio_capabilities *wifi7_caps)
{
if (wifi7_caps->bsta_str_support || wifi7_caps->bsta_nstr_support ||
wifi7_caps->bsta_emlsr_support || wifi7_caps->bsta_emlmr_support)
@@ -850,7 +881,7 @@ bool agent_radio_support_bsta_wifi7(struct wifi7_radio_capabilities *wifi7_caps)
}
-int wifi_teardown_map_bsta_mld(struct agent *a, uint32_t band)
+int bstamld_teardown_band(struct agent *a, uint32_t band)
{
struct wifi_radio_element *re;
char fmt[128] = {0};
@@ -885,7 +916,7 @@ int wifi_teardown_map_bsta_mld(struct agent *a, uint32_t band)
return 0;
}
-void mlo_update_id_in_configs(char *ifname, uint8_t mld_id)
+void mld_set_config_id(char *ifname, uint8_t mld_id)
{
char mldname[16] = {0};
char idstr[4] = {0};
diff --git a/src/mld.h b/src/mld.h
index da3356d85..c8bb720e0 100644
--- a/src/mld.h
+++ b/src/mld.h
@@ -16,6 +16,7 @@ struct wifi7_radio_capabilities;
struct netif_bk;
struct netif_ap;
struct bsta_mld;
+struct sta;
/* multi-link device */
struct netif_mld {
@@ -40,7 +41,7 @@ struct netif_mld {
int num_affiliated_ap;
#define MAX_AFFILIATED_AP_LINKS_NUM 14
- struct netif_ap *affiliated_ap[MAX_AFFILIATED_AP_LINKS_NUM];
+ uint8_t affliated_ap[MAX_AFFILIATED_AP_LINKS_NUM][6];
struct list_head list;
};
@@ -48,7 +49,6 @@ struct netif_mld {
// struct used for client MLO STAs and own MLO bSTAs
struct sta_mld {
-#define MAX_AFFILIATED_STA_LINKS_NUM 14
uint8_t macaddr[6];
uint8_t bssid[6];
@@ -58,7 +58,8 @@ struct sta_mld {
bool emlmr_enabled;
int num_affiliated_sta;
- struct sta *affiliated_sta[MAX_AFFILIATED_STA_LINKS_NUM];
+#define MAX_AFFILIATED_STA_LINKS_NUM 14
+ uint8_t affiliated_sta[MAX_AFFILIATED_STA_LINKS_NUM][6];
struct list_head list;
};
@@ -67,46 +68,47 @@ struct sta_mld {
void mlsta_update_sta_mld(struct agent *a, struct netif_ap *ap,
struct wifi_mlsta *mlsta, struct sta *s);
-int wifi_sta_mld_del_sta(struct agent *a, struct sta *s);
-int wifi_sta_mld_del_bsta(struct agent *a, struct netif_bk *bk);
-int wifi_mld_del_ap(struct netif_ap *ap);
+int mld_del_sta(struct agent *a, struct sta *s);
+int mld_del_bsta(struct agent *a, struct netif_bk *bk);
+int mld_del_ap(struct netif_ap *ap);
int wifi_process_ml_ie(struct agent *a, struct sta_mld *stamld,
uint8_t *assocframe, int framelen);
-void wifi_mld_event_handler(void *agent, struct blob_attr *msg);
-int parse_affiliated_ap(struct ubus_request *req, int type,
+void mld_event_handler(void *agent, struct blob_attr *msg);
+int mld_parse_affiliated_ap(struct ubus_request *req, int type,
struct blob_attr *msg);
-void parse_apmld(struct ubus_request *req, int type,
+void apmld_parse(struct ubus_request *req, int type,
struct blob_attr *msg);
-void parse_affiliated_bsta(struct agent *a, struct bsta_mld *mld,
+void mld_parse_affiliated_bsta(struct agent *a, struct bsta_mld *mld,
struct netif_bk *bk, int type,
struct blob_attr *msg);
-void parse_bstamld(struct ubus_request *req, int type,
+void bstamld_parse(struct ubus_request *req, int type,
struct blob_attr *msg);
-struct netif_mld *agent_get_mld_by_ifname(struct agent *a, const char *ifname);
-struct netif_mld *agent_alloc_mld(struct agent *a, const char *ifname);
-bool agent_is_ap_in_mld(struct agent *a, struct netif_mld *mld,
+struct netif_mld *agent_get_apmld(struct agent *a, uint8_t *macaddr);
+struct netif_mld *agent_get_apmld_by_ifname(struct agent *a, const char *ifname);
+struct netif_mld *agent_alloc_apmld(struct agent *a, const char *ifname);
+bool mld_contains_ap(struct agent *a, struct netif_mld *mld,
uint8_t *macaddr);
-bool agent_is_sta_in_sta_mld(struct agent *a, struct sta_mld *mld,
+bool mld_contains_sta(struct agent *a, struct sta_mld *mld,
uint8_t *macaddr);
-bool agent_is_sta_in_bsta_mld(struct agent *a, struct bsta_mld *mld,
+bool mld_contains_bsta(struct agent *a, struct bsta_mld *mld,
uint8_t *macaddr);
struct sta_mld *agent_get_stamld(struct agent *a, uint8_t *macaddr);
struct sta_mld *agent_alloc_stamld(struct agent *a, struct netif_mld *mld,
uint8_t *macaddr);
struct bsta_mld *agent_init_bstamld(struct agent *a, char *ifname,
struct wifi7_radio_capabilities *caps);
-void agent_clean_affiliated_sta_mld(struct sta_mld *mld);
-void agent_free_sta_mld(struct sta_mld *mld);
-void agent_clean_affiliated_bsta_mld(struct bsta_mld *mld);
-void agent_clear_bsta_mld(struct agent *a);
-void agent_clean_affiliated_ap_mld(struct netif_mld *mld);
-void agent_free_ap_mld(struct netif_mld *mld);
+void stamld_clean(struct sta_mld *mld);
+void stamld_free(struct sta_mld *mld);
+void bstamld_clean(struct bsta_mld *mld);
+void bstamld_free(struct agent *a);
+void apmld_clean(struct netif_mld *mld);
+void apmld_free(struct netif_mld *mld);
void clear_apmld(struct netif_mld *mld);
void clear_apmldlist(struct agent *a);
-bool wifi_is_affiliated_ap(struct agent *a, uint8_t *bssid);
-bool agent_radio_support_ap_wifi7(struct wifi7_radio_capabilities *wifi7_caps);
-bool agent_radio_support_bsta_wifi7(struct wifi7_radio_capabilities *wifi7_caps);
-int wifi_teardown_map_bsta_mld(struct agent *a, uint32_t band);
-void mlo_update_id_in_configs(char *ifname, uint8_t mld_id);
+bool is_affiliated_ap(struct agent *a, uint8_t *bssid);
+bool agent_radio_support_ap_mlo(struct wifi7_radio_capabilities *wifi7_caps);
+bool agent_radio_support_bsta_mlo(struct wifi7_radio_capabilities *wifi7_caps);
+int bstamld_teardown_band(struct agent *a, uint32_t band);
+void mld_set_config_id(char *ifname, uint8_t mld_id);
#endif
#endif
\ No newline at end of file
diff --git a/src/wifi_ubus.c b/src/wifi_ubus.c
index 7248f5997..d8c9702f2 100644
--- a/src/wifi_ubus.c
+++ b/src/wifi_ubus.c
@@ -2137,7 +2137,6 @@ static int wifi_ubus_get_mld_sta_links(struct ubus_context *ubus_ctx, struct net
.status = -1,
};
struct blob_buf bb = {};
- char mld_addr_str[18] = {};
char name[256] = {};
uint32_t id;
int ret;
@@ -2153,7 +2152,9 @@ static int wifi_ubus_get_mld_sta_links(struct ubus_context *ubus_ctx, struct net
blob_buf_init(&bb, 0);
- if (mld_addr) {
+ if (mld_addr && !hwaddr_is_zero(mld_addr)) {
+ char mld_addr_str[18] = {};
+
hwaddr_ntoa(mld_addr, mld_addr_str);
blobmsg_add_string(&bb, "sta", mld_addr_str);
ctx.mld_macaddr = mld_addr;
--
GitLab