diff --git a/src/agent.c b/src/agent.c index 6a7ca49caccbabe0bff3946ac65d419cff9a580f..f8f8b262362f89a907e05cb0543cf74490f20661 100644 --- a/src/agent.c +++ b/src/agent.c @@ -5782,7 +5782,7 @@ int agent_init_interfaces(struct agent *a) ap->enabled = false; #if (EASYMESH_VERSIN >= 6) if (ap->is_affiliated_ap) - mld_del_ap(ap); + mld_del_ap(a, ap); #endif } } @@ -5968,13 +5968,13 @@ int agent_init_interfaces(struct agent *a) /* if an MLD is gone from config free it */ list_for_each_entry_safe(mld, tmp, &a->apmldlist, list) { if (!agent_get_mld_credential_by_ifname(&a->cfg, mld->ifname)) - clear_apmld(mld); + apmld_clean(a, mld); } if (a->has_bstamld) { /* if bsta config has gone away clear bstamld */ if (!agent_get_bsta_mld_credential(&a->cfg)) - bstamld_free(a); + agent_clear_bsta_mld(a); } #endif @@ -6541,7 +6541,7 @@ static void netif_reset(struct netif_ap *ap) #if (EASYMESH_VERSION >= 6) if (ap->is_affiliated_ap) - mld_del_ap(ap); + mld_del_ap(ap->agent, ap); #endif } @@ -6996,8 +6996,8 @@ void run_agent(void) qos_rule_free_all(&w->qos_rules); #endif #if (EASYMESH_VERSION >= 6) - bstamld_free(w); - clear_apmldlist(w); + agent_clear_bsta_mld(w); + apmld_free_all(w); #endif ubus_unregister_event_handler(ctx, &w->evh); #ifdef VENDOR_EXTENSION @@ -7253,7 +7253,7 @@ int wifiagent_get_status(struct ubus_context *ctx, blobmsg_add_u32(&bb, "num_sta", ap->num_sta); b = blobmsg_open_array(&bb, "neighbor"); - list_for_each_entry(n, &p->nbrlist, list) { + list_for_each_entry(n, &ap->nbrlist, list) { void *ttt; ttt = blobmsg_open_table(&bb, ""); @@ -7264,7 +7264,7 @@ int wifiagent_get_status(struct ubus_context *ctx, blobmsg_close_array(&bb, b); b = blobmsg_open_array(&bb, "stations"); - list_for_each_entry(s, &p->stalist, list) { + list_for_each_entry(s, &ap->stalist, list) { void *aa, *ttt, *tttt; struct pref_neighbor *pn; @@ -7272,10 +7272,15 @@ int wifiagent_get_status(struct ubus_context *ctx, blobmsg_add_macaddr(&bb, "macaddr", s->macaddr); #if (EASYMESH_VERSION >= 6) blobmsg_add_u8(&bb, "is_affiliated_sta", s->is_affiliated_sta); - if (s->is_affiliated_sta && s->mld) { - blobmsg_add_macaddr(&bb, "mld_macaddr", s->mld->macaddr); - blobmsg_add_macaddr(&bb, "mld_bssid", s->mld->bssid); - blobmsg_add_u32(&bb, "mlo_linkid", s->mlo_link_id); + if (s->is_affiliated_sta) { + struct sta_mld *smld; + + smld = agent_get_stamld(a, s->mld_macaddr); + if (smld) { + blobmsg_add_macaddr(&bb, "mld_macaddr", smld->macaddr); + blobmsg_add_macaddr(&bb, "mld_bssid", smld->bssid); + blobmsg_add_u32(&bb, "mlo_linkid", s->mlo_link_id); + } } #endif /* blobmsg_add_u32(&bb, "conn_time", s->connected_ms / 1000); */ @@ -7350,15 +7355,15 @@ int wifiagent_get_status(struct ubus_context *ctx, aa = blobmsg_open_array(&bb, "affiliated_ap"); for (i = 0; i < mld->num_affiliated_ap; i++) { + struct netif_ap *ap; void *tt; - p = mld->affiliated_ap[i]; - - if (!p) - break; + ap = agent_get_ap(a, mld->affiliated_ap[i]); + if (!ap) + continue; tt = blobmsg_open_table(&bb, ""); - blobmsg_add_string(&bb, "ifname", p->ifname); + blobmsg_add_string(&bb, "ifname", ap->ifname); blobmsg_close_table(&bb, tt); } blobmsg_close_array(&bb, aa); @@ -7377,8 +7382,12 @@ int wifiagent_get_status(struct ubus_context *ctx, for (i = 0; i < smld->num_affiliated_sta; i++) { void *ttttt; struct sta *s; + ttttt = blobmsg_open_table(&bb, ""); - s = smld->affiliated_sta[i]; + s = agent_get_sta(a, smld->affiliated_sta[i]); + if (!s) + continue; + blobmsg_add_macaddr(&bb, "macaddr", s->macaddr); blobmsg_add_macaddr(&bb, "bssid", s->bssid); blobmsg_add_u32(&bb, "linkid", s->mlo_link_id); @@ -7410,10 +7419,9 @@ int wifiagent_get_status(struct ubus_context *ctx, struct netif_bk *bk; void *tt; - bk = agent->bstamld.affiliated_bsta[i]; - + bk = agent_get_bsta(a, agent->bstamld.affiliated_bsta[i]); if (!bk) - break; + continue; tt = blobmsg_open_table(&bb, ""); blobmsg_add_string(&bb, "ifname", bk->ifname); diff --git a/src/agent_cmdu.c b/src/agent_cmdu.c index 2548b7633986c17b993cdf089f2be5c726b5843e..987a7166a65abf685902467fbb17bf034082f35f 100644 --- a/src/agent_cmdu.c +++ b/src/agent_cmdu.c @@ -330,7 +330,9 @@ struct cmdu_buff *agent_gen_ap_metrics_response(struct agent *a, list_for_each_entry(smld, &mld->stamldlist, list) { for (i = 0; i < smld->num_affiliated_sta; i++) { - s = smld->affiliated_sta[i]; + s = agent_get_sta(a, smld->affiliated_sta[i]); + if (!s) + continue; if (memcmp(s->bssid, bssid, 6)) continue; @@ -354,14 +356,14 @@ struct cmdu_buff *agent_gen_ap_metrics_response(struct agent *a, } /* TODO: traffic stats are per-mld, today use first client statistics */ - ret = agent_gen_assoc_sta_traffic_stats(a, frm, smld->macaddr, smld->affiliated_sta[0]); + ret = agent_gen_assoc_sta_traffic_stats(a, frm, smld->macaddr, s); if (ret) goto out; if (rcfg->include_wifi6_sta_status && a->cfg.map_profile > 2) { /* TLV is sent only for SLO and MLD clients */ - ret = agent_gen_assoc_wifi6_sta_status_report(a, frm, smld->affiliated_sta[0]); + ret = agent_gen_assoc_wifi6_sta_status_report(a, frm, s); if (ret) goto out; } @@ -1265,8 +1267,8 @@ struct cmdu_buff *agent_gen_topology_notification(struct agent *agent, uint8_t origin[6] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x13}; #if (EASYMESH_VERSION >= 6) - if (s->is_affiliated_sta && s->mld) - macaddr = s->mld->macaddr; + if (s->is_affiliated_sta) + macaddr = s->mld_macaddr; #endif frm = cmdu_alloc_simple(CMDU_TYPE_TOPOLOGY_NOTIFICATION, &mid); @@ -1312,14 +1314,22 @@ struct cmdu_buff *agent_gen_client_disassoc(struct agent *a, memcpy(cmdu->origin, a->cntlr_almac, 6); #if (EASYMESH_VERSION >= 6) - if (s->is_affiliated_sta && s->mld) { - macaddr = s->mld->macaddr; + if (s->is_affiliated_sta) { + struct sta_mld *smld; + + macaddr = s->mld_macaddr; ret = agent_gen_affiliated_sta_metrics(a, cmdu, s); if (ret) goto error; /* TODO: overwrite s as STA traffic are currently only available on first link */ - s = s->mld->affiliated_sta[0]; + smld = agent_get_stamld(a, s->mld_macaddr); + if (!smld) + goto error; + + s = agent_get_sta(a, smld->affiliated_sta[0]); + if (!s) + goto error; } #endif @@ -1422,8 +1432,6 @@ struct cmdu_buff *agent_gen_topology_response(struct agent *a, uint8_t *origin, #if (EASYMESH_VERSION >= 6) /* Backhaul STA Radio Capabilities TLV */ list_for_each_entry(re, &a->radiolist, list) { - agent_radio_support_bsta_wifi7(&re->wifi7_caps); - ret = agent_gen_bk_sta_radio_cap_tlv(a, resp, re); if (ret) goto error; diff --git a/src/agent_map.c b/src/agent_map.c index 0af4c2a9b6108c620633f2e3b7144a5b2576566e..48fdd48ce72c2ea2a659b91ec574abedc4899167 100644 --- a/src/agent_map.c +++ b/src/agent_map.c @@ -2434,7 +2434,7 @@ static int mlo_process_bsta_mld_config(struct agent *a, uint8_t *tlv_data) continue; if (!re->bk.cfg->is_mld_netdev && re->bk.is_affiliated_sta) - wifi_sta_mld_del_bsta(a, &re->bk); + mld_del_bsta(a, &re->bk); } num_affiliated_bstas = tlv_data[offset++]; diff --git a/src/agent_tlv.c b/src/agent_tlv.c index 66a59ddcef5c100117ae83a47b7033beac83f03c..5c26b35c6deb7a41ada987b5d65fd4fcbc4896d1 100644 --- a/src/agent_tlv.c +++ b/src/agent_tlv.c @@ -3670,12 +3670,16 @@ int agent_gen_assoc_client_tlv(struct agent *a, struct cmdu_buff *frm) offset += 6; if (smld->num_affiliated_sta > 0) { - /** conntime is not (yet) available for MLD dev - * use first affiliated STA conntime - */ - conntime = ((smld->affiliated_sta[0]->connected_ms / 1000) > 0xFFFF) - ? 0xFFFF - : (smld->affiliated_sta[0]->connected_ms / 1000) & 0xFFFF; + struct sta *s; + + s = agent_get_sta(a, smld->affiliated_sta[0]); + if (s) { + /** conntime is not (yet) available for MLD dev + * use first affiliated STA conntime + */ + conntime = ((s->connected_ms / 1000) > 0xFFFF) + ? 0xFFFF : (s->connected_ms / 1000) & 0xFFFF; + } } /* conntime */ @@ -4227,8 +4231,8 @@ int agent_gen_assoc_wifi6_sta_status_report(struct agent *a, data = (struct tlv_assoc_wifi6_sta_status_report *)t->data; memcpy(data->macaddr, s->macaddr, 6); #if (EASYMESH_VERSION >= 6) - if (s->is_affiliated_sta && s->mld) - memcpy(data->macaddr, s->mld->macaddr, 6); + if (s->is_affiliated_sta) + memcpy(data->macaddr, s->mld_macaddr, 6); #endif offset += sizeof(*data); /* TODO: @@ -4531,7 +4535,6 @@ int agent_gen_ap_mld_config(struct agent *a, struct cmdu_buff *frm) list_for_each_entry(mld, &a->apmldlist, list) { int ssid_len = strlen(mld->ssid); - struct netif_ap *ap = NULL; int i; /* AP MLD MAC Addr Valid */ @@ -4569,8 +4572,9 @@ int agent_gen_ap_mld_config(struct agent *a, struct cmdu_buff *frm) t->data[offset++] = mld->num_affiliated_ap; for (i = 0; i < mld->num_affiliated_ap; i++) { struct wifi_radio_element *re = NULL; - ap = mld->affiliated_ap[i]; + struct netif_ap *ap; + ap = agent_get_ap(a, mld->affiliated_ap[i]); if (!ap || !ap->is_affiliated_ap) continue; @@ -4591,7 +4595,7 @@ int agent_gen_ap_mld_config(struct agent *a, struct cmdu_buff *frm) offset += 6; /* LinkID */ - t->data[offset++] = ap->linkid; + t->data[offset++] = ap->mlo_link_id; offset += 18; /* reserved */ } @@ -4618,7 +4622,7 @@ int agent_gen_bsta_mld_config(struct agent *a, struct cmdu_buff *frm) //struct mld_credential *mld = NULL; int offset = 0; uint8_t *num_aff_bstas; - struct bsta_mld *bsta = &a->bstamld; + struct bsta_mld *bstamld = &a->bstamld; uint8_t valid_flag = BSTA_MLD_CONF_AFFILIATED_BSTA_MLD_ADDR_VALID; int ret; @@ -4641,28 +4645,28 @@ int agent_gen_bsta_mld_config(struct agent *a, struct cmdu_buff *frm) data->flag = 0; /* bSTA_MLD_MAC_Addr */ - if (!hwaddr_is_zero(bsta->macaddr)) { - memcpy(&t->data[offset], bsta->macaddr, 6); + if (!hwaddr_is_zero(bstamld->macaddr)) { + memcpy(&t->data[offset], bstamld->macaddr, 6); data->flag |= BSTA_MLD_CONF_BSTA_MLD_ADDR_VALID; } offset += 6; /* AP_MLD_MAC_Addr */ /* "addr of the AP MLD to which the bSTA MLD is associated" */ - if (!hwaddr_is_zero(bsta->bssid)) { - memcpy(&t->data[offset], bsta->bssid, 6); + if (!hwaddr_is_zero(bstamld->bssid)) { + memcpy(&t->data[offset], bstamld->bssid, 6); data->flag |= BSTA_MLD_CONF_AP_MLD_ADDR_VALID; } offset += 6; /* STR/NSTR/EMLSR/EMLMR */ - if (bsta->str_enabled) + if (bstamld->str_enabled) caps_flag |= BSTA_MLD_CONFIG_STR; - if (bsta->nstr_enabled) + if (bstamld->nstr_enabled) caps_flag |= BSTA_MLD_CONFIG_NSTR; - if (bsta->emlsr_enabled) + if (bstamld->emlsr_enabled) caps_flag |= BSTA_MLD_CONFIG_EMLSR; - if (bsta->emlmr_enabled) + if (bstamld->emlmr_enabled) caps_flag |= BSTA_MLD_CONFIG_EMLMR; data->flag2 = caps_flag; @@ -4673,20 +4677,21 @@ int agent_gen_bsta_mld_config(struct agent *a, struct cmdu_buff *frm) /* numAffiliatedbSTAs */ num_aff_bstas = &t->data[offset]; - *num_aff_bstas = bsta->num_affiliated_bsta; + *num_aff_bstas = bstamld->num_affiliated_bsta; offset++; if (*num_aff_bstas) { int i; for (i = 0; i < *num_aff_bstas; i++) { - struct netif_bk *affsta = bsta->affiliated_bsta[i]; + struct netif_bk *bsta; struct wifi_radio_element *re; - if (!affsta->cfg) + bsta = agent_get_bsta(a, bstamld->affiliated_bsta[i]); + if (!bsta || !bsta->cfg) continue; - re = agent_get_radio_by_band(a, affsta->cfg->band); + re = agent_get_radio_by_band(a, bsta->cfg->band); if (!re) continue; @@ -4699,7 +4704,7 @@ int agent_gen_bsta_mld_config(struct agent *a, struct cmdu_buff *frm) offset += 6; /* Affilated_bSTA_MAC_Addr */ - memcpy(&t->data[offset], affsta->macaddr, 6); + memcpy(&t->data[offset], bsta->macaddr, 6); offset += 6; /* reserved */ @@ -4902,7 +4907,11 @@ int agent_gen_associated_sta_mld_config(struct agent *a, struct cmdu_buff *frm, offset += 1; for (i = 0; i < mld->num_affiliated_sta; i++) { - struct sta *s = mld->affiliated_sta[i]; + struct sta *s; + + s = agent_get_sta(a, mld->affiliated_sta[i]); + if (!s) + continue; memcpy(&t->data[offset], s->bssid, 6); offset += 6; diff --git a/src/backhaul.c b/src/backhaul.c index c70072e8593e7d81cf630bfd0b4a4bebb40b75be..7683f1f7f504b0d367941e624aa9c996ff089b48 100644 --- a/src/backhaul.c +++ b/src/backhaul.c @@ -535,9 +535,12 @@ void agent_check_bsta_connections(struct agent *a) #if (EASYMESH_VERSION >= 6) - if (bk->is_affiliated_sta) { - snprintf(objname, 31, "wifi.bstamld.%s", bk->mld->ifname); - cb = parse_bstamld; + if (bk->is_affiliated_sta && a->has_bstamld) { + struct bsta_mld *bstamld; + + bstamld = &a->bstamld; + snprintf(objname, 31, "wifi.bstamld.%s", bstamld->ifname); + cb = bstamld_parse; } if (bk->cfg->is_mld_netdev) diff --git a/src/mld.c b/src/mld.c index ca6253ba2f705dd5665db1430e4e921319b14f7e..19f8d5283732605a3f59323bd5f6c617800bc205 100644 --- a/src/mld.c +++ b/src/mld.c @@ -6,10 +6,14 @@ #include "utils/debug.h" #include "utils/utils.h" #include "backhaul.h" -#include "agent.h -" -void stamld_update(struct agent *a, ) +#include "agent.h" + +void stamld_update(struct agent *a, struct netif_ap *ap, + struct wifi_mlsta *mlsta, struct sta *s) { + struct sta_mld *mld; + int num_sta = 0; + mld = agent_get_stamld(a, mlsta->macaddr); if (!mld) { struct netif_mld *apmld; @@ -26,7 +30,7 @@ void stamld_update(struct agent *a, ) memcpy(mld->bssid, mlsta->bssid, 6); num_sta = mld->num_affiliated_sta; - memcpy(s->mld_macaddr, mld->macaddr); + memcpy(s->mld_macaddr, mld->macaddr, 6); s->is_affiliated_sta = true; s->mlo_link_id = mlsta->sta[0].mlo_link_id; @@ -67,7 +71,7 @@ void mlsta_update_sta_mld(struct agent *a, struct netif_ap *ap, memcpy(mld->bssid, mlsta->bssid, 6); num_sta = mld->num_affiliated_sta; - memcpy(s->mld_macaddr, mld->macaddr); + memcpy(s->mld_macaddr, mld->macaddr, 6); s->is_affiliated_sta = true; s->mlo_link_id = mlsta->sta[0].mlo_link_id; @@ -93,15 +97,13 @@ int mld_del_sta(struct agent *a, struct sta *s) return -1; for (i = 0; i < mld->num_affiliated_sta; i++) { - int j; - - if (memcmp(mld->affiliated_sta[i]->macaddr, s->macaddr, 6)) + if (memcmp(mld->affiliated_sta[i], s->macaddr, 6)) continue; - for (j = (i + 1); j < mld->num_affiliated_sta; j++) - mld->affiliated_sta[j-1] = mld->affiliated_sta[j]; + if (i < mld->num_affiliated_sta) + memcpy(mld->affiliated_sta[i], mld->affiliated_sta[i + 1], (mld->num_affiliated_sta - (i + 1)) * 6); - memset(mld->affiliated_sta[j], 0, 6) + memset(mld->affiliated_sta[mld->num_affiliated_sta - 1], 0, 6); mld->num_affiliated_sta--; break; } @@ -118,20 +120,20 @@ int mld_del_sta(struct agent *a, struct sta *s) int mld_del_bsta(struct agent *a, struct netif_bk *bk) { struct bsta_mld *mld; - int i, j; + int i; if (!a->has_bstamld || bk->cfg->is_mld_netdev) return -1; mld = &a->bstamld; for (i = 0; i < mld->num_affiliated_bsta; i++) { - if (memcmp(mld->affiliated_bsta[i]->macaddr, bk->macaddr, 6)) + if (memcmp(mld->affiliated_bsta[i], bk->macaddr, 6)) continue; - for (j = (i + 1); j < mld->num_affiliated_bsta; j++) - mld->affiliated_bsta[j-1] = mld->affiliated_bsta[j]; + if (i < mld->num_affiliated_bsta) + memcpy(mld->affiliated_bsta[i], mld->affiliated_bsta[i + 1], (mld->num_affiliated_bsta - (i + 1)) * 6); - memset(mld->affiliated_bsta[j], 0, 6) + memset(mld->affiliated_bsta[mld->num_affiliated_bsta - 1], 0, 6); mld->num_affiliated_bsta--; } @@ -153,15 +155,13 @@ int mld_del_ap(struct agent *a, struct netif_ap *ap) return -1; for (i = 0; i < mld->num_affiliated_ap; i++) { - int j; - - if (memcmp(mld->affiliated_ap[i]->bssid, ap->bssid, 6)) + if (memcmp(mld->affiliated_ap[i], ap->bssid, 6)) continue; - for (j = (i + 1); j < mld->num_affiliated_ap; j++) - mld->affiliated_ap[j-1] = mld->affiliated_ap[j]; + if (i < mld->num_affiliated_ap) + memcpy(mld->affiliated_ap[i], mld->affiliated_ap[i + 1], (mld->num_affiliated_ap - (i + 1)) * 6); - memset(mld->affiliated_bsta[j], 0, 6) + memset(mld->affiliated_ap[mld->num_affiliated_ap - 1], 0, 6); mld->num_affiliated_ap--; } @@ -321,7 +321,7 @@ int mld_parse_affiliated_ap(struct ubus_request *req, int type, if (band != ap->band) return -1; - ap->linkid = blobmsg_get_u32(tb[0]); + ap->mlo_link_id = blobmsg_get_u32(tb[0]); hwaddr_aton(blobmsg_data(tb[6]), ap->bssid); if (tb[2]) @@ -369,9 +369,9 @@ void apmld_parse(struct ubus_request *req, int type, if (strlen(ifname) == 0) return; - mld = agent_get_mld_by_ifname(a, ifname); + mld = agent_get_apmld_by_ifname(a, ifname); if (!mld) { - mld = agent_alloc_mld(a, ifname); + mld = agent_alloc_apmld(a, ifname); if (!mld) { err("|%s:%d| failed to alloc MLD\n", __func__, __LINE__); return; @@ -415,7 +415,7 @@ void apmld_parse(struct ubus_request *req, int type, continue; strncpy(ap->mld_ifname, ifname, sizeof(ap->mld_ifname) - 1); - memcmpy(ap->mld_macaddr, mld->macaddr, 6); + memcpy(ap->mld_macaddr, mld->macaddr, 6); ap->is_affiliated_ap = true; strncpy(ap->ssid, ssid, sizeof(ap->ssid)); ap->enabled = true; @@ -423,7 +423,7 @@ void apmld_parse(struct ubus_request *req, int type, num_ap = mld->num_affiliated_ap; if (!mld_contains_ap(a, mld, ap->bssid) && num_ap < MAX_AFFILIATED_AP_LINKS_NUM) { - mld->affiliated_ap[num_ap] = ap; + memcpy(mld->affiliated_ap[num_ap], ap->bssid, 6); mld->num_affiliated_ap++; } else { err("|%s:%d| link with bssid:"MACFMT" was already in the MLD (or num_ap too high:%d)\n", __func__, __LINE__, MAC2STR(ap->bssid), mld->num_affiliated_ap); @@ -502,7 +502,7 @@ void mld_parse_affiliated_bsta(struct agent *a, struct bsta_mld *mld, if (!mld_contains_bsta(a, mld, bk->macaddr) && num_sta < MAX_AFFILIATED_STA_LINKS_NUM) { - mld->affiliated_bsta[num_sta] = bk; + memcpy(mld->affiliated_bsta[num_sta], bk->macaddr, 6); mld->num_affiliated_bsta++; } @@ -611,7 +611,7 @@ struct netif_mld *agent_get_apmld(struct agent *a, uint8_t *macaddr) return NULL; } -struct netif_mld *agent_get_mld_by_ifname(struct agent *a, const char *ifname) +struct netif_mld *agent_get_apmld_by_ifname(struct agent *a, const char *ifname) { struct netif_mld *mld = NULL; @@ -623,7 +623,7 @@ struct netif_mld *agent_get_mld_by_ifname(struct agent *a, const char *ifname) return NULL; } -struct netif_mld *agent_alloc_mld(struct agent *a, const char *ifname) +struct netif_mld *agent_alloc_apmld(struct agent *a, const char *ifname) { struct netif_mld *mld; @@ -654,7 +654,7 @@ bool mld_contains_ap(struct agent *a, struct netif_mld *mld, int i; for (i = 0; i < mld->num_affiliated_ap; i++) { - if (!memcmp(mld->affiliated_ap[i]->bssid, macaddr, 6)) + if (!memcmp(mld->affiliated_ap[i], macaddr, 6)) return true; } @@ -667,7 +667,7 @@ bool mld_contains_sta(struct agent *a, struct sta_mld *mld, int i; for (i = 0; i < mld->num_affiliated_sta; i++) { - if (!memcmp(mld->affiliated_sta[i]->macaddr, macaddr, 6)) + if (!memcmp(mld->affiliated_sta[i], macaddr, 6)) return true; } @@ -681,7 +681,7 @@ bool mld_contains_bsta(struct agent *a, struct bsta_mld *mld, int i; for (i = 0; i < mld->num_affiliated_bsta; i++) { - if (!memcmp(mld->affiliated_bsta[i]->macaddr, macaddr, 6)) + if (!memcmp(mld->affiliated_bsta[i], macaddr, 6)) return true; } @@ -739,28 +739,29 @@ struct bsta_mld *agent_init_bstamld(struct agent *a, char *ifname, return bsta; } -void stamld_clean(struct sta_mld *mld) +void stamld_clean(struct agent *a, struct sta_mld *mld) { int i; for (i = (mld->num_affiliated_sta - 1); i >= 0; i--) { - struct sta *s = mld->affiliated_sta[i]; + struct sta *s; + s = agent_get_sta(a, mld->affiliated_sta[i]); if (!s) continue; memset(s->mld_macaddr, 0, 6); s->is_affiliated_sta = false; - mld->affiliated_sta[i] = NULL; + memset(mld->affiliated_sta[i], 0, 6);; } mld->num_affiliated_sta = 0; } -void stamld_free(struct sta_mld *mld) +void stamld_free(struct agent *a, struct sta_mld *mld) { - stamld_clean(mld); + stamld_clean(a, mld); list_del(&mld->list); free(mld); @@ -780,19 +781,20 @@ void clear_stamldlist(struct agent *a) } */ -void bstamld_clean(struct bsta_mld *mld) +void bstamld_clean(struct agent *a, struct bsta_mld *mld) { int i; for (i = 0; i < mld->num_affiliated_bsta; i++) { - struct netif_bk *bk = mld->affiliated_bsta[i]; + struct netif_bk *bk; + bk = agent_get_bsta(a, mld->affiliated_bsta[i]); if (!bk) continue; memset(bk->mld_macaddr, 0, 6); bk->is_affiliated_sta = false; - mld->affiliated_bsta[i] = NULL; + memset(mld->affiliated_bsta[i], 0, 6); } mld->num_affiliated_bsta = 0; @@ -803,37 +805,38 @@ void agent_clear_bsta_mld(struct agent *a) { struct bsta_mld *mld = &a->bstamld; - bstamld_clean(mld); + bstamld_clean(a, mld); a->has_bstamld = false; } -void apmld_clean(struct netif_mld *mld) +void apmld_clean(struct agent *a, struct netif_mld *mld) { int i; for (i = (mld->num_affiliated_ap - 1); i >= 0; i--) { - struct netif_ap *ap = mld->affiliated_ap[i]; + struct netif_ap *ap; + ap = agent_get_ap(a, mld->affiliated_ap[i]); if (!ap) continue; memset(ap->mld_macaddr, 0, 6); ap->is_affiliated_ap = false; - mld->affiliated_ap[i] = NULL; + memset(mld->affiliated_ap[i], 0, 6); } mld->num_affiliated_ap = 0; } -void apmld_free(struct netif_mld *mld) +void apmld_free(struct agent *a, struct netif_mld *mld) { struct sta_mld *smld = NULL, *stmp; list_for_each_entry_safe(smld, stmp, &mld->stamldlist, list) - stamld_free(smld); + stamld_free(a, smld); - apmld_clean(mld); + apmld_clean(a, mld); list_del(&mld->list); free(mld); @@ -844,7 +847,7 @@ void apmld_free_all(struct agent *a) struct netif_mld *mld = NULL, *tmp; list_for_each_entry_safe(mld, tmp, &a->apmldlist, list) { - apmld_free(mld); + apmld_free(a, mld); } a->num_ap_mld = 0; diff --git a/src/mld.h b/src/mld.h index c8bb720e0e60b06d2161a94979dca604cf82e6ff..ecec4f49337d00c957abd644a470c649ea163059 100644 --- a/src/mld.h +++ b/src/mld.h @@ -41,7 +41,7 @@ struct netif_mld { int num_affiliated_ap; #define MAX_AFFILIATED_AP_LINKS_NUM 14 - uint8_t affliated_ap[MAX_AFFILIATED_AP_LINKS_NUM][6]; + uint8_t affiliated_ap[MAX_AFFILIATED_AP_LINKS_NUM][6]; struct list_head list; }; @@ -70,7 +70,7 @@ void mlsta_update_sta_mld(struct agent *a, struct netif_ap *ap, struct wifi_mlsta *mlsta, struct sta *s); 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 mld_del_ap(struct agent *a, struct netif_ap *ap); int wifi_process_ml_ie(struct agent *a, struct sta_mld *stamld, uint8_t *assocframe, int framelen); void mld_event_handler(void *agent, struct blob_attr *msg); @@ -97,13 +97,13 @@ 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 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 stamld_clean(struct agent *a, struct sta_mld *mld); +void stamld_free(struct agent *a, struct sta_mld *mld); +void bstamld_clean(struct agent *a, struct bsta_mld *mld); +void agent_clear_bsta_mld(struct agent *a); +void apmld_clean(struct agent *a, struct netif_mld *mld); +void apmld_free(struct agent *a, struct netif_mld *mld); +void apmld_free_all(struct agent *a); void clear_apmldlist(struct agent *a); bool is_affiliated_ap(struct agent *a, uint8_t *bssid); bool agent_radio_support_ap_mlo(struct wifi7_radio_capabilities *wifi7_caps); @@ -111,4 +111,4 @@ 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 +#endif