diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 7fe9c7fd9..47e7eb8f6 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1308,6 +1308,26 @@ static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, #endif /* CONFIG_NO_SCAN_PROCESSING */ +int wpa_supplicant_fast_associate(struct wpa_supplicant *wpa_s) +{ +#ifdef CONFIG_NO_SCAN_PROCESSING + return -1; +#else /* CONFIG_NO_SCAN_PROCESSING */ + struct os_time now; + + if (wpa_s->last_scan_res_used <= 0) + return -1; + + os_get_time(&now); + if (now.sec - wpa_s->last_scan.sec > 5) { + wpa_printf(MSG_DEBUG, "Fast associate: Old scan results"); + return -1; + } + + return wpas_select_network_from_last_scan(wpa_s); +#endif /* CONFIG_NO_SCAN_PROCESSING */ +} + #ifdef CONFIG_WNM static void wnm_bss_keep_alive(void *eloop_ctx, void *sock_ctx) diff --git a/wpa_supplicant/interworking.c b/wpa_supplicant/interworking.c index b8a8bb2b6..e1f58a67e 100644 --- a/wpa_supplicant/interworking.c +++ b/wpa_supplicant/interworking.c @@ -54,16 +54,8 @@ 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; - } - } + if (wpa_supplicant_fast_associate(wpa_s) >= 0) + return; wpa_supplicant_req_scan(wpa_s, 0, 0); } diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 21bd73a73..ae4f22f4e 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -1875,7 +1875,9 @@ void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s, wpa_s->connect_without_scan = NULL; wpa_s->disconnected = 0; wpa_s->reassociate = 1; - wpa_supplicant_req_scan(wpa_s, 0, disconnected ? 100000 : 0); + + if (wpa_supplicant_fast_associate(wpa_s) != 1) + wpa_supplicant_req_scan(wpa_s, 0, disconnected ? 100000 : 0); if (ssid) wpas_notify_network_selected(wpa_s, ssid); diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index ecbdedf0d..807c7cd0e 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -786,6 +786,7 @@ 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); +int wpa_supplicant_fast_associate(struct wpa_supplicant *wpa_s); /* eap_register.c */ int eap_register_methods(void);