]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
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 e2d95b3d19920599f6f803f4bde24e3acd59e052..1a9eba690e763cbd03747fc2830506793806c64b 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 0eba4a0b77504d7956151d98331998bea0ee8a3e..15ca6dbda9477ff4fd3478d5da76a519bffa6b40 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 ba53451294a628ec69d066cf8873f13c06e4bea0..84d642cf671ec5d775e43ab4b9c868127d512577 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 fa0123aeb217cf840ea426aa51ffb5a5a8851e29..ba94d330b46379c7adc47890f9745419496a9585 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;