From 170f5663dc5fd426b25fe3f680d34bd7d40f510e Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 15 May 2013 16:46:45 +0300 Subject: [PATCH] WPS NFC: Connect using learnt credential after NFC Tag read 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 --- wpa_supplicant/wps_supplicant.c | 44 +++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c index b376fb0..72f03e5 100644 --- a/wpa_supplicant/wps_supplicant.c +++ b/wpa_supplicant/wps_supplicant.c @@ -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; -- 2.1.4