From a594e2a9ab469e2d89f9dbd54b8aaf0f47dc66dc Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 2 Sep 2012 20:18:48 +0300 Subject: [PATCH] Interworking: Skip extra scan after network auto-select If the scan results from before ANQP fetch are fresh (less than five seconds old), do not run a new scan when selecting the BSS after having used Interworking network selection. Signed-hostap: Jouni Malinen --- wpa_supplicant/events.c | 11 +++++++++-- wpa_supplicant/interworking.c | 12 ++++++++++++ wpa_supplicant/wpa_supplicant_i.h | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index ee0ebe2ed..6dd578796 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1035,8 +1035,6 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, union wpa_event_data *data) { - struct wpa_bss *selected; - struct wpa_ssid *ssid = NULL; struct wpa_scan_results *scan_res; int ap = 0; #ifndef CONFIG_NO_RANDOM_POOL @@ -1150,6 +1148,15 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, wpa_scan_results_free(scan_res); + return wpas_select_network_from_last_scan(wpa_s); +} + + +int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s) +{ + struct wpa_bss *selected; + struct wpa_ssid *ssid = NULL; + selected = wpa_supplicant_pick_network(wpa_s, &ssid); if (selected) { diff --git a/wpa_supplicant/interworking.c b/wpa_supplicant/interworking.c index 7741fdce9..987c79b5f 100644 --- a/wpa_supplicant/interworking.c +++ b/wpa_supplicant/interworking.c @@ -52,6 +52,18 @@ static void interworking_reconnect(struct wpa_supplicant *wpa_s) } wpa_s->disconnected = 0; wpa_s->reassociate = 1; + + if (wpa_s->last_scan_res_used > 0) { + struct os_time now; + os_get_time(&now); + if (now.sec - wpa_s->last_scan.sec <= 5) { + wpa_printf(MSG_DEBUG, "Interworking: Old scan results " + "are fresh - connect without new scan"); + if (wpas_select_network_from_last_scan(wpa_s) == 0) + return; + } + } + wpa_supplicant_req_scan(wpa_s, 0, 0); } diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 42055ec76..4c520bacf 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -717,6 +717,7 @@ int wpa_supplicant_connect(struct wpa_supplicant *wpa_s, void wpa_supplicant_stop_countermeasures(void *eloop_ctx, void *sock_ctx); void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx, void *sock_ctx); void wnm_bss_keep_alive_deinit(struct wpa_supplicant *wpa_s); +int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s); /* eap_register.c */ int eap_register_methods(void);