]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS NFC: Connect using learnt credential after NFC Tag read
authorJouni Malinen <jouni@qca.qualcomm.com>
Wed, 15 May 2013 13:46:45 +0000 (16:46 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 15 May 2013 13:46:45 +0000 (16:46 +0300)
Instead of just adding the new network, prefer the network learnt from a
configuration token during the first connection attempt. This makes the
WPS NFC case behave similarly to the in-band provisioning cases if there
are more preferred networks in the scan results.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

wpa_supplicant/wps_supplicant.c

index b376fb08c06fb77eb88e8b146b87835e62d40269..72f03e53138152cbfcd76d61f314400e04ed71f4 100644 (file)
@@ -964,21 +964,10 @@ static struct wpa_ssid * wpas_wps_add_network(struct wpa_supplicant *wpa_s,
 }
 
 
-static void wpas_wps_reassoc(struct wpa_supplicant *wpa_s,
-                            struct wpa_ssid *selected, const u8 *bssid)
+static void wpas_wps_temp_disable(struct wpa_supplicant *wpa_s,
+                                 struct wpa_ssid *selected)
 {
        struct wpa_ssid *ssid;
-       struct wpa_bss *bss;
-
-       wpa_s->after_wps = 0;
-       wpa_s->known_wps_freq = 0;
-       if (bssid) {
-               bss = wpa_bss_get_bssid_latest(wpa_s, bssid);
-               if (bss && bss->freq > 0) {
-                       wpa_s->known_wps_freq = 1;
-                       wpa_s->wps_freq = bss->freq;
-               }
-       }
 
        if (wpa_s->current_ssid)
                wpa_supplicant_deauthenticate(
@@ -1006,6 +995,26 @@ static void wpas_wps_reassoc(struct wpa_supplicant *wpa_s,
                }
                ssid = ssid->next;
        }
+}
+
+
+static void wpas_wps_reassoc(struct wpa_supplicant *wpa_s,
+                            struct wpa_ssid *selected, const u8 *bssid)
+{
+       struct wpa_bss *bss;
+
+       wpa_s->after_wps = 0;
+       wpa_s->known_wps_freq = 0;
+       if (bssid) {
+               bss = wpa_bss_get_bssid_latest(wpa_s, bssid);
+               if (bss && bss->freq > 0) {
+                       wpa_s->known_wps_freq = 1;
+                       wpa_s->wps_freq = bss->freq;
+               }
+       }
+
+       wpas_wps_temp_disable(wpa_s, selected);
+
        wpa_s->disconnected = 0;
        wpa_s->reassociate = 1;
        wpa_s->scan_runs = 0;
@@ -2087,6 +2096,15 @@ static int wpas_wps_use_cred(struct wpa_supplicant *wpa_s,
 {
        wpa_s->wps_ap_channel = 0;
 
+       /*
+        * Disable existing networks temporarily to allow the newly learned
+        * credential to be preferred. Enable the temporarily disabled networks
+        * after 10 seconds.
+        */
+       wpas_wps_temp_disable(wpa_s, NULL);
+       eloop_register_timeout(10, 0, wpas_wps_reenable_networks_cb, wpa_s,
+                              NULL);
+
        if (wps_oob_use_cred(wpa_s->wps, attr) < 0)
                return -1;