Interleave wildcard and specific SSID scans when max_ssids=1

For drivers limited to scan a single SSID at a time, this prevents
waiting too long for a wildcard scan in case there are several
scan_ssid networks in the configuration.

Signed-hostap: Eyal Shapira <eyal@wizery.com>
This commit is contained in:
Eyal Shapira 2012-01-29 17:39:08 +02:00 committed by Jouni Malinen
parent ea5cb06ef9
commit b3aa456b3e
3 changed files with 31 additions and 8 deletions

View file

@ -530,6 +530,7 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
if (scan_req != 2 && wpa_s->conf->ap_scan == 2) { if (scan_req != 2 && wpa_s->conf->ap_scan == 2) {
wpa_s->connect_without_scan = NULL; wpa_s->connect_without_scan = NULL;
wpa_s->prev_scan_wildcard = 0;
wpa_supplicant_assoc_try(wpa_s, ssid); wpa_supplicant_assoc_try(wpa_s, ssid);
return; return;
} else if (wpa_s->conf->ap_scan == 2) { } else if (wpa_s->conf->ap_scan == 2) {
@ -578,15 +579,32 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
int_array_sort_unique(params.freqs); int_array_sort_unique(params.freqs);
} }
if (ssid) { if (ssid && max_ssids == 1) {
/*
* If the driver is limited to 1 SSID at a time interleave
* wildcard SSID scans with specific SSID scans to avoid
* waiting a long time for a wildcard scan.
*/
if (!wpa_s->prev_scan_wildcard) {
params.ssids[0].ssid = NULL;
params.ssids[0].ssid_len = 0;
wpa_s->prev_scan_wildcard = 1;
wpa_dbg(wpa_s, MSG_DEBUG, "Starting AP scan for "
"wildcard SSID (Interleave with specific)");
} else {
wpa_s->prev_scan_ssid = ssid;
wpa_s->prev_scan_wildcard = 0;
wpa_dbg(wpa_s, MSG_DEBUG,
"Starting AP scan for specific SSID: %s",
wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
}
} else if (ssid) {
/* max_ssids > 1 */
wpa_s->prev_scan_ssid = ssid; wpa_s->prev_scan_ssid = ssid;
if (max_ssids > 1) {
wpa_dbg(wpa_s, MSG_DEBUG, "Include wildcard SSID in " wpa_dbg(wpa_s, MSG_DEBUG, "Include wildcard SSID in "
"the scan request"); "the scan request");
params.num_ssids++; params.num_ssids++;
}
wpa_dbg(wpa_s, MSG_DEBUG, "Starting AP scan for specific "
"SSID(s)");
} else { } else {
wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN; wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN;
params.num_ssids++; params.num_ssids++;

View file

@ -2137,6 +2137,8 @@ int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s)
wpa_drv_flush_pmkid(wpa_s); wpa_drv_flush_pmkid(wpa_s);
wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN; wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN;
wpa_s->prev_scan_wildcard = 0;
if (wpa_supplicant_enabled_networks(wpa_s->conf)) { if (wpa_supplicant_enabled_networks(wpa_s->conf)) {
if (wpa_supplicant_delayed_sched_scan(wpa_s, interface_count, if (wpa_supplicant_delayed_sched_scan(wpa_s, interface_count,
100000)) 100000))

View file

@ -285,6 +285,9 @@ struct wpa_supplicant {
void *drv_priv; /* private data used by driver_ops */ void *drv_priv; /* private data used by driver_ops */
void *global_drv_priv; void *global_drv_priv;
/* previous scan was wildcard when interleaving between
* wildcard scans and specific SSID scan when max_ssids=1 */
int prev_scan_wildcard;
struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID; struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
* NULL = not yet initialized (start * NULL = not yet initialized (start
* with wildcard SSID) * with wildcard SSID)