Optimize post-WPS scan based on channel used during provisioning

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.
This commit is contained in:
Jouni Malinen 2010-04-11 19:06:42 +03:00 committed by Jouni Malinen
parent addb584881
commit 17a4734dc4
4 changed files with 19 additions and 0 deletions

View 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);

View 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;

View 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;
};

View 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;