WPS: Skip rescanning after provisioning if AP was configured
authorMasashi Honma <masashi.honma@gmail.com>
Sun, 31 Mar 2013 17:06:42 +0000 (20:06 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 31 Mar 2013 17:06:42 +0000 (20:06 +0300)
If WPS provisioning step is completed with an AP that is in WPS
configured state, we can skip a second scan after the provisioning step
since the AP is unlikely to change its configuration in such a case.
This can speed up WPS connection a bit by removing an unneeded scan.

Signed-hostap: Masashi Honma <masashi.honma@gmail.com>

wpa_supplicant/events.c
wpa_supplicant/wpa_supplicant_i.h
wpa_supplicant/wps_supplicant.c

index d291990..8d276c5 100644 (file)
@@ -851,9 +851,8 @@ wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s,
 }
 
 
-static struct wpa_bss *
-wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
-                           struct wpa_ssid **selected_ssid)
+struct wpa_bss * wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
+                                            struct wpa_ssid **selected_ssid)
 {
        struct wpa_bss *selected = NULL;
        int prio;
index ac745d5..1a35a89 100644 (file)
@@ -791,6 +791,8 @@ 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 wpa_supplicant_fast_associate(struct wpa_supplicant *wpa_s);
+struct wpa_bss * wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
+                                            struct wpa_ssid **selected_ssid);
 
 /* eap_register.c */
 int eap_register_methods(void);
index 8ffc692..603ce91 100644 (file)
@@ -84,6 +84,10 @@ int wpas_wps_eapol_cb(struct wpa_supplicant *wpa_s)
            !(wpa_s->current_ssid->key_mgmt & WPA_KEY_MGMT_WPS)) {
                int disabled = wpa_s->current_ssid->disabled;
                unsigned int freq = wpa_s->assoc_freq;
+               struct wpa_bss *bss;
+               struct wpa_ssid *ssid = NULL;
+               int use_fast_assoc = 0;
+
                wpa_printf(MSG_DEBUG, "WPS: Network configuration replaced - "
                           "try to associate with the received credential "
                           "(freq=%u)", freq);
@@ -98,7 +102,26 @@ int wpas_wps_eapol_cb(struct wpa_supplicant *wpa_s)
                wpa_s->wps_freq = freq;
                wpa_s->normal_scans = 0;
                wpa_s->reassociate = 1;
-               wpa_supplicant_req_scan(wpa_s, 0, 0);
+
+               wpa_printf(MSG_DEBUG, "WPS: Checking whether fast association "
+                          "without a new scan can be used");
+               bss = wpa_supplicant_pick_network(wpa_s, &ssid);
+               if (bss) {
+                       struct wpabuf *wps;
+                       struct wps_parse_attr attr;
+
+                       wps = wpa_bss_get_vendor_ie_multi(bss,
+                                                         WPS_IE_VENDOR_TYPE);
+                       if (wps && wps_parse_msg(wps, &attr) == 0 &&
+                           attr.wps_state &&
+                           *attr.wps_state == WPS_STATE_CONFIGURED)
+                               use_fast_assoc = 1;
+                       wpabuf_free(wps);
+               }
+
+               if (!use_fast_assoc ||
+                   wpa_supplicant_fast_associate(wpa_s) != 1)
+                       wpa_supplicant_req_scan(wpa_s, 0, 0);
                return 1;
        }