Optimize post-WPS scan based on channel used during provisioning
authorJouni Malinen <jouni.malinen@atheros.com>
Sun, 11 Apr 2010 16:06:42 +0000 (19:06 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 11 Apr 2010 16:06:42 +0000 (19:06 +0300)
Scan only the frequency that was used during provisioning during the
first five scans for the connection. This speeds up connection in the
most likely case where the AP remains on the same channel. If the AP is
not found after these initial scans, all channels will be scanned.

wpa_supplicant/scan.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h
wpa_supplicant/wps_supplicant.c

index e2d95b3..1a9eba6 100644 (file)
@@ -386,6 +386,19 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
        }
 
 #ifdef CONFIG_WPS
+       if (params.freqs == NULL && wpa_s->after_wps && wpa_s->wps_freq) {
+               /*
+                * Optimize post-provisioning scan based on channel used
+                * during provisioning.
+                */
+               wpa_printf(MSG_DEBUG, "WPS: Scan only frequency %u MHz that "
+                          "was used during provisioning", wpa_s->wps_freq);
+               params.freqs = os_zalloc(2 * sizeof(int));
+               if (params.freqs)
+                       params.freqs[0] = wpa_s->wps_freq;
+               wpa_s->after_wps--;
+       }
+
        if (wps) {
                wps_ie = wps_build_probe_req_ie(wps == 2, &wpa_s->wps->dev,
                                                wpa_s->wps->uuid, req_type);
index 0eba4a0..15ca6db 100644 (file)
@@ -542,6 +542,7 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
                wpa_s->new_connection = 0;
                wpa_s->reassociated_connection = 1;
                wpa_drv_set_operstate(wpa_s, 1);
+               wpa_s->after_wps = 0;
        } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING ||
                   state == WPA_ASSOCIATED) {
                wpa_s->new_connection = 1;
index ba53451..84d642c 100644 (file)
@@ -425,6 +425,9 @@ struct wpa_supplicant {
        struct wpa_ssid *bgscan_ssid;
        const struct bgscan_ops *bgscan;
        void *bgscan_priv;
+
+       int after_wps;
+       unsigned int wps_freq;
 };
 
 
index fa0123a..ba94d33 100644 (file)
@@ -72,6 +72,8 @@ int wpas_wps_eapol_cb(struct wpa_supplicant *wpa_s)
                           "try to associate with the received credential");
                wpa_supplicant_deauthenticate(wpa_s,
                                              WLAN_REASON_DEAUTH_LEAVING);
+               wpa_s->after_wps = 5;
+               wpa_s->wps_freq = wpa_s->assoc_freq;
                wpa_s->reassociate = 1;
                wpa_supplicant_req_scan(wpa_s, 0, 0);
                return 1;