From 75d65857d5b42e0ea9503260447aff48d6ac18fb Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 22 Nov 2014 20:12:12 +0200 Subject: [PATCH] WNM: Use recent scan results on BSS transition request If the last scans are recent (for now, less than ten seconds old), use them instead of triggering a new scan when a BSS Transition Management Request frame is received. As a fallback, allow a new scan to be triggered if no matches were found. Signed-off-by: Jouni Malinen --- wpa_supplicant/events.c | 2 +- wpa_supplicant/wnm_sta.c | 22 ++++++++++++++++++++-- wpa_supplicant/wnm_sta.h | 5 +++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index ee2801c..0ffda4d 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1314,7 +1314,7 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, return 0; } - if (wnm_scan_process(wpa_s) > 0) + if (wnm_scan_process(wpa_s, 1) > 0) goto scan_work_done; if (sme_proc_obss_scan(wpa_s) > 0) diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c index 7aa2f7f..019dca1 100644 --- a/wpa_supplicant/wnm_sta.c +++ b/wpa_supplicant/wnm_sta.c @@ -576,7 +576,7 @@ static void wnm_send_bss_transition_mgmt_resp( } -int wnm_scan_process(struct wpa_supplicant *wpa_s) +int wnm_scan_process(struct wpa_supplicant *wpa_s, int reply_on_fail) { struct wpa_bss *bss; struct wpa_ssid *ssid = wpa_s->current_ssid; @@ -628,8 +628,12 @@ int wnm_scan_process(struct wpa_supplicant *wpa_s) wnm_deallocate_memory(wpa_s); return 1; - /* Send reject response for all the failures */ send_bss_resp_fail: + if (!reply_on_fail) + return 0; + + /* Send reject response for all the failures */ + if (wpa_s->wnm_reply) { wpa_s->wnm_reply = 0; wnm_send_bss_transition_mgmt_resp(wpa_s, @@ -874,6 +878,20 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s, wpa_s->wnm_cand_valid_until.usec %= 1000000; os_memcpy(wpa_s->wnm_cand_from_bss, wpa_s->bssid, ETH_ALEN); + if (wpa_s->last_scan_res_used > 0) { + struct os_reltime now; + + os_get_reltime(&now); + if (!os_reltime_expired(&now, &wpa_s->last_scan, 10)) { + wpa_printf(MSG_DEBUG, + "WNM: Try to use recent scan results"); + if (wnm_scan_process(wpa_s, 0) > 0) + return; + wpa_printf(MSG_DEBUG, + "WNM: No match in previous scan results - try a new scan"); + } + } + wnm_set_scan_freqs(wpa_s); wpa_supplicant_req_scan(wpa_s, 0, 0); } else if (reply) { diff --git a/wpa_supplicant/wnm_sta.h b/wpa_supplicant/wnm_sta.h index fd3a5dd..8de4348 100644 --- a/wpa_supplicant/wnm_sta.h +++ b/wpa_supplicant/wnm_sta.h @@ -62,11 +62,12 @@ void wnm_deallocate_memory(struct wpa_supplicant *wpa_s); #ifdef CONFIG_WNM -int wnm_scan_process(struct wpa_supplicant *wpa_s); +int wnm_scan_process(struct wpa_supplicant *wpa_s, int reply_on_fail); #else /* CONFIG_WNM */ -static inline int wnm_scan_process(struct wpa_supplicant *wpa_s) +static inline int wnm_scan_process(struct wpa_supplicant *wpa_s, + int reply_on_fail) { return 0; } -- 2.1.4