wpa_supplicant: Implement fast-associate on SelectNetwork
authorPaul Stewart <pstew@chromium.org>
Sun, 3 Feb 2013 19:08:31 +0000 (21:08 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 3 Feb 2013 19:08:31 +0000 (21:08 +0200)
If scan results are available when we perform a SelectNetwork, use
them to make an associate decision.  This can save an entire scan
interval-worth of time in situations where something external to
wpa_supplicant (like a connection manager) has just previously
requested a scan before calling SelectNetwork.

Signed-hostap: Paul Stewart <pstew@chromium.org>

wpa_supplicant/events.c
wpa_supplicant/interworking.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index 7fe9c7f..47e7eb8 100644 (file)
@@ -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)
index b8a8bb2..e1f58a6 100644 (file)
@@ -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);
 }
index 21bd73a..ae4f22f 100644 (file)
@@ -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);
index ecbdedf..807c7cd 100644 (file)
@@ -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);