]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Interleave wildcard and specific SSID scans when max_ssids=1
authorEyal Shapira <eyal@wizery.com>
Sun, 29 Jan 2012 15:39:08 +0000 (17:39 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 29 Jan 2012 15:39:08 +0000 (17:39 +0200)
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>

wpa_supplicant/scan.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index 51358920801b82f1410aee6bec309317ed755681..cceee616f7584c6be70766fccb357c2aeba0d9c1 100644 (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) {
                wpa_s->connect_without_scan = NULL;
+               wpa_s->prev_scan_wildcard = 0;
                wpa_supplicant_assoc_try(wpa_s, ssid);
                return;
        } 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);
        }
 
-       if (ssid) {
-               wpa_s->prev_scan_ssid = ssid;
-               if (max_ssids > 1) {
-                       wpa_dbg(wpa_s, MSG_DEBUG, "Include wildcard SSID in "
-                               "the scan request");
-                       params.num_ssids++;
+       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));
                }
-               wpa_dbg(wpa_s, MSG_DEBUG, "Starting AP scan for specific "
-                       "SSID(s)");
+       } else if (ssid) {
+               /* max_ssids > 1 */
+
+               wpa_s->prev_scan_ssid = ssid;
+               wpa_dbg(wpa_s, MSG_DEBUG, "Include wildcard SSID in "
+                       "the scan request");
+               params.num_ssids++;
        } else {
                wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN;
                params.num_ssids++;
index e79011ff3b7984ab7bf73d6547b4b989cbb496b2..90363fed79c0f85163462cc39d5a5f6112a763f4 100644 (file)
@@ -2137,6 +2137,8 @@ int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s)
        wpa_drv_flush_pmkid(wpa_s);
 
        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_delayed_sched_scan(wpa_s, interface_count,
                                                      100000))
index 3e3b23de2c1d19b5ae2026dbdddf14376c0c6c27..8ae2500e42147c530aac3498b1d9801c78ef6e56 100644 (file)
@@ -285,6 +285,9 @@ struct wpa_supplicant {
        void *drv_priv; /* private data used by driver_ops */
        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;
                                          * NULL = not yet initialized (start
                                          * with wildcard SSID)