WPS: Use single channel scan if AP channel already known

If the BSSID of the AP is specified in the WPS command, the target
AP is likely already in the BSS table and its operating channel is
known. Use this information to speed up connection by only scanning
the known channel.

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2011-12-31 13:17:20 +02:00
parent ee9fc67ab7
commit 1e7fb4f1b7
3 changed files with 25 additions and 4 deletions

View file

@ -344,6 +344,16 @@ static void wpa_supplicant_optimize_freqs(
wpa_s->after_wps--;
}
if (params->freqs == NULL && wpa_s->known_wps_freq && wpa_s->wps_freq)
{
/* Optimize provisioning scan based on already known channel */
wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Scan only frequency %u MHz",
wpa_s->wps_freq);
params->freqs = os_zalloc(2 * sizeof(int));
if (params->freqs)
params->freqs[0] = wpa_s->wps_freq;
wpa_s->known_wps_freq = 0; /* only do this once */
}
#endif /* CONFIG_WPS */
}

View file

@ -495,6 +495,7 @@ struct wpa_supplicant {
struct wpa_ssid *connect_without_scan;
int after_wps;
int known_wps_freq;
unsigned int wps_freq;
int wps_fragment_size;
int auto_reconnect_disabled;

View file

@ -790,9 +790,19 @@ 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)
struct wpa_ssid *selected, const u8 *bssid)
{
struct wpa_ssid *ssid;
struct wpa_bss *bss;
wpa_s->known_wps_freq = 0;
if (bssid) {
bss = wpa_bss_get_bssid(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(
@ -853,7 +863,7 @@ int wpas_wps_start_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid,
ssid->eap.fragment_size = wpa_s->wps_fragment_size;
eloop_register_timeout(WPS_PBC_WALK_TIME, 0, wpas_wps_timeout,
wpa_s, NULL);
wpas_wps_reassoc(wpa_s, ssid);
wpas_wps_reassoc(wpa_s, ssid, bssid);
return 0;
}
@ -896,7 +906,7 @@ int wpas_wps_start_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
ssid->eap.fragment_size = wpa_s->wps_fragment_size;
eloop_register_timeout(WPS_PBC_WALK_TIME, 0, wpas_wps_timeout,
wpa_s, NULL);
wpas_wps_reassoc(wpa_s, ssid);
wpas_wps_reassoc(wpa_s, ssid, bssid);
return rpin;
}
@ -1016,7 +1026,7 @@ int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid,
ssid->eap.fragment_size = wpa_s->wps_fragment_size;
eloop_register_timeout(WPS_PBC_WALK_TIME, 0, wpas_wps_timeout,
wpa_s, NULL);
wpas_wps_reassoc(wpa_s, ssid);
wpas_wps_reassoc(wpa_s, ssid, bssid);
return 0;
}