[PATCH] WNM: Lower rankings of current AP if disassociation imminent bit set
Po-Hao Huang
berniehuang0507 at gmail.com
Fri Jun 9 01:48:42 PDT 2023
If the current AP advertises disassociation imminent, move it to the
back of the candidate list so we don't select it again while other
candidates are available.
---
wpa_supplicant/wnm_sta.c | 12 ++++++++++--
wpa_supplicant/wnm_sta.h | 1 +
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c
index ac0dd1aa0..e1c9dc42a 100644
--- a/wpa_supplicant/wnm_sta.c
+++ b/wpa_supplicant/wnm_sta.c
@@ -1207,6 +1207,12 @@ static int cand_pref_compar(const void *a, const void *b)
const struct neighbor_report *aa = a;
const struct neighbor_report *bb = b;
+ if (aa->disassoc_imminent && bb->disassoc_imminent)
+ return 0;
+ if (aa->disassoc_imminent)
+ return 1;
+ if (bb->disassoc_imminent)
+ return -1;
if (!aa->preference_present && !bb->preference_present)
return 0;
if (!aa->preference_present)
@@ -1485,8 +1491,6 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s,
wpa_msg(wpa_s, MSG_INFO, "WNM: Disassociation Imminent - "
"Disassociation Timer %u", wpa_s->wnm_dissoc_timer);
if (wpa_s->wnm_dissoc_timer && !wpa_s->scanning) {
- /* TODO: mark current BSS less preferred for
- * selection */
wpa_printf(MSG_DEBUG, "Trying to find another BSS");
wpa_supplicant_req_scan(wpa_s, 0, 0);
}
@@ -1526,6 +1530,10 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s,
rep = &wpa_s->wnm_neighbor_report_elements[
wpa_s->wnm_num_neighbor_report];
wnm_parse_neighbor_report(wpa_s, pos, len, rep);
+ if (wpa_s->wnm_mode & WNM_BSS_TM_REQ_DISASSOC_IMMINENT
+ && os_memcmp(rep->bssid, wpa_s->bssid, ETH_ALEN) == 0)
+ rep->disassoc_imminent = 1;
+
wpa_s->wnm_num_neighbor_report++;
#ifdef CONFIG_MBO
if (wpa_s->wnm_mbo_trans_reason_present &&
diff --git a/wpa_supplicant/wnm_sta.h b/wpa_supplicant/wnm_sta.h
index 29625f8ca..8d89b799b 100644
--- a/wpa_supplicant/wnm_sta.h
+++ b/wpa_supplicant/wnm_sta.h
@@ -37,6 +37,7 @@ struct neighbor_report {
u32 distance; /* valid if bearing_present=1 */
u64 bss_term_tsf; /* valid if bss_term_present=1 */
u16 bss_term_dur; /* valid if bss_term_present=1 */
+ u8 disassoc_imminent;
unsigned int preference_present:1;
unsigned int tsf_present:1;
unsigned int country_present:1;
--
2.25.1
More information about the Hostap
mailing list