diff --git a/src/cntlr.c b/src/cntlr.c index 9d290cd4bcacf475b2954ede6de9eab2cd8abd65..980c0116c38811195e9179f910058e13450d19ab 100644 --- a/src/cntlr.c +++ b/src/cntlr.c @@ -231,6 +231,23 @@ struct node *cntlr_find_node_with_bssid(struct controller *c, uint8_t *bssid) return NULL; } +/* find node to which given STA is connected */ +struct node *cntlr_find_node_with_sta(struct controller *c, uint8_t *sta_mac) +{ + struct node *n = NULL; + + list_for_each_entry(n, &c->nodelist, list) { + struct sta *s = NULL; + + list_for_each_entry(s, &n->stalist, list) { + if (!memcmp(s->macaddr, sta_mac, 6)) + return n; + } + } + + return NULL; +} + #if (EASYMESH_VERSION >= 6) bool cntlr_radio_support_ap_wifi7(struct wifi7_radio_capabilities *wifi7_caps) { @@ -547,9 +564,14 @@ static void cntlr_freeze_sta(struct controller *c, struct sta *s) static void cntlr_remove_sta(struct controller *c, struct node *n, struct sta *s) { - cntlr_freeze_sta(c, s); + struct node *curr_sta_node; + node_del_sta(n, s); - cntlr_del_sta(c->sta_table, s->macaddr); + curr_sta_node = cntlr_find_node_with_sta(c, s->macaddr); + if (!curr_sta_node) { + cntlr_freeze_sta(c, s); + cntlr_del_sta(c->sta_table, s->macaddr); + } } struct cmdu_buff *cntlr_query_sta_metric(struct controller *c, struct sta *s) diff --git a/src/cntlr.h b/src/cntlr.h index 0fb959de6a3b13ac11b4184cecba4ca2facad5ab..cd5827036cedc4805bdf65979f9770407af8cda0 100644 --- a/src/cntlr.h +++ b/src/cntlr.h @@ -367,6 +367,7 @@ struct node *cntlr_add_node(struct controller *c, uint8_t *almacaddr); struct node *cntlr_alloc_node(struct controller *c, uint8_t *almacaddr); struct node *cntlr_find_node(struct controller *c, uint8_t *almacaddr); struct node *cntlr_find_node_with_bssid(struct controller *c, uint8_t *bssid); +struct node *cntlr_find_node_with_sta(struct controller *c, uint8_t *sta_mac); struct netif_link *cntlr_alloc_link(struct controller *c, uint8_t *upstream, uint8_t *downstream);