WPS: Skip rescanning after provisioning if AP was configured

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>
This commit is contained in:
Masashi Honma 2013-03-31 20:06:42 +03:00 committed by Jouni Malinen
parent 6dacb8e98b
commit 97236cee6a
3 changed files with 28 additions and 4 deletions

View file

@ -851,9 +851,8 @@ wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s,
} }
static struct wpa_bss * struct wpa_bss * wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s, struct wpa_ssid **selected_ssid)
struct wpa_ssid **selected_ssid)
{ {
struct wpa_bss *selected = NULL; struct wpa_bss *selected = NULL;
int prio; int prio;

View 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 wpa_supplicant_delayed_mic_error_report(void *eloop_ctx, void *sock_ctx);
void wnm_bss_keep_alive_deinit(struct wpa_supplicant *wpa_s); void wnm_bss_keep_alive_deinit(struct wpa_supplicant *wpa_s);
int wpa_supplicant_fast_associate(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 */ /* eap_register.c */
int eap_register_methods(void); int eap_register_methods(void);

View 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)) { !(wpa_s->current_ssid->key_mgmt & WPA_KEY_MGMT_WPS)) {
int disabled = wpa_s->current_ssid->disabled; int disabled = wpa_s->current_ssid->disabled;
unsigned int freq = wpa_s->assoc_freq; 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 - " wpa_printf(MSG_DEBUG, "WPS: Network configuration replaced - "
"try to associate with the received credential " "try to associate with the received credential "
"(freq=%u)", freq); "(freq=%u)", freq);
@ -98,7 +102,26 @@ int wpas_wps_eapol_cb(struct wpa_supplicant *wpa_s)
wpa_s->wps_freq = freq; wpa_s->wps_freq = freq;
wpa_s->normal_scans = 0; wpa_s->normal_scans = 0;
wpa_s->reassociate = 1; 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; return 1;
} }