aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/events.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2012-09-02 14:39:35 (GMT)
committerJouni Malinen <j@w1.fi>2012-09-02 14:39:35 (GMT)
commit20ed5e40ba95440a1946cf2dffad3047fb620582 (patch)
treec5b54f9f3f0f6300098b9ebacceb4aee3a5006e2 /wpa_supplicant/events.c
parente026159a8e8e38feb0ec455bf7ae09146033016f (diff)
downloadhostap-20ed5e40ba95440a1946cf2dffad3047fb620582.zip
hostap-20ed5e40ba95440a1946cf2dffad3047fb620582.tar.gz
hostap-20ed5e40ba95440a1946cf2dffad3047fb620582.tar.bz2
Use BSS table instead of scan results in need-to-roam determination
The same information is available in the BSS table, so we can reduce the need for using the raw scan results in wpa_supplicant_need_to_roam(). Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/events.c')
-rw-r--r--wpa_supplicant/events.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 7780e9a..d9dfb93 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -966,11 +966,9 @@ static void wpa_supplicant_rsn_preauth_scan_results(
static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s,
struct wpa_bss *selected,
- struct wpa_ssid *ssid,
- struct wpa_scan_results *scan_res)
+ struct wpa_ssid *ssid)
{
- size_t i;
- struct wpa_scan_res *current_bss = NULL;
+ struct wpa_bss *current_bss = NULL;
int min_diff;
if (wpa_s->reassociate)
@@ -985,25 +983,22 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s,
if (wpas_driver_bss_selection(wpa_s))
return 0; /* Driver-based roaming */
- for (i = 0; i < scan_res->num; i++) {
- struct wpa_scan_res *res = scan_res->res[i];
- const u8 *ie;
- if (os_memcmp(res->bssid, wpa_s->bssid, ETH_ALEN) != 0)
- continue;
-
- ie = wpa_scan_get_ie(res, WLAN_EID_SSID);
- if (ie == NULL)
- continue;
- if (ie[1] != wpa_s->current_ssid->ssid_len ||
- os_memcmp(ie + 2, wpa_s->current_ssid->ssid, ie[1]) != 0)
- continue;
- current_bss = res;
- break;
- }
+ if (wpa_s->current_ssid->ssid)
+ current_bss = wpa_bss_get(wpa_s, wpa_s->bssid,
+ wpa_s->current_ssid->ssid,
+ wpa_s->current_ssid->ssid_len);
+ if (!current_bss)
+ current_bss = wpa_bss_get_bssid(wpa_s, wpa_s->bssid);
if (!current_bss)
return 1; /* current BSS not seen in scan results */
+ if (current_bss == selected)
+ return 0;
+
+ if (selected->last_update_idx > current_bss->last_update_idx)
+ return 1; /* current BSS not seen in the last scan */
+
#ifndef CONFIG_NO_ROAMING
wpa_dbg(wpa_s, MSG_DEBUG, "Considering within-ESS reassociation");
wpa_dbg(wpa_s, MSG_DEBUG, "Current BSS: " MACSTR " level=%d",
@@ -1165,11 +1160,11 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
selected = wpa_supplicant_pick_network(wpa_s, scan_res, &ssid);
+ wpa_scan_results_free(scan_res);
+
if (selected) {
int skip;
- skip = !wpa_supplicant_need_to_roam(wpa_s, selected, ssid,
- scan_res);
- wpa_scan_results_free(scan_res);
+ skip = !wpa_supplicant_need_to_roam(wpa_s, selected, ssid);
if (skip) {
wpa_supplicant_rsn_preauth_scan_results(wpa_s);
return 0;
@@ -1181,7 +1176,6 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
}
wpa_supplicant_rsn_preauth_scan_results(wpa_s);
} else {
- wpa_scan_results_free(scan_res);
wpa_dbg(wpa_s, MSG_DEBUG, "No suitable network found");
ssid = wpa_supplicant_pick_new_network(wpa_s);
if (ssid) {