]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpa_supplicant: Allow vifs to scan only current channel
authorBen Greear <greearb@candelatech.com>
Thu, 9 May 2013 09:43:40 +0000 (12:43 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 9 May 2013 09:43:40 +0000 (12:43 +0300)
If a VIF is already associated, then only scan on the associated
frequency if user requests such. This is a big help when using
lots of virtual stations.

Signed-hostap: Ben Greear <greearb@candelatech.com>
Signed-off-by: Ben Greear <greearb@candelatech.com>
wpa_supplicant/config.c
wpa_supplicant/config.h
wpa_supplicant/config_file.c
wpa_supplicant/scan.c
wpa_supplicant/wpa_supplicant.conf

index b25e0f673752bf916717df8e1dc6e204e723e105..7a860b660e1aec523ea886f8f89cf928e377f19d 100644 (file)
@@ -2584,6 +2584,7 @@ struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface,
        config->bss_expiration_scan_count = DEFAULT_BSS_EXPIRATION_SCAN_COUNT;
        config->max_num_sta = DEFAULT_MAX_NUM_STA;
        config->access_network_type = DEFAULT_ACCESS_NETWORK_TYPE;
+       config->scan_cur_freq = DEFAULT_SCAN_CUR_FREQ;
        config->wmm_ac_params[0] = ac_be;
        config->wmm_ac_params[1] = ac_bk;
        config->wmm_ac_params[2] = ac_vi;
@@ -3105,6 +3106,7 @@ static const struct global_parse_data global_fields[] = {
        { FUNC(ap_vendor_elements), 0 },
        { INT_RANGE(ignore_old_scan_res, 0, 1), 0 },
        { FUNC(freq_list), 0 },
+       { INT(scan_cur_freq), 0 },
        { INT(sched_scan_interval), 0 },
 };
 
index a1a5239920da702d970e02dacbb61f9af20cf3b7..1748cf3b8606d870fc0cb956d62b03c614fa4e1b 100644 (file)
@@ -24,6 +24,7 @@
 #define DEFAULT_BSS_EXPIRATION_SCAN_COUNT 2
 #define DEFAULT_MAX_NUM_STA 128
 #define DEFAULT_ACCESS_NETWORK_TYPE 15
+#define DEFAULT_SCAN_CUR_FREQ 0
 
 #include "config_ssid.h"
 #include "wps/wps.h"
@@ -652,6 +653,14 @@ struct wpa_config {
         */
        int *freq_list;
 
+       /**
+        * scan_cur_freq - Whether to scan only the current channel
+        *
+        * If true, attempt to scan only the current channel if any other
+        * VIFs on this radio are already associated on a particular channel.
+        */
+       int scan_cur_freq;
+
        /**
         * changed_parameters - Bitmap of changed parameters since last update
         */
index 8ff42852d5f28cff46080209f3bff6c4579d1b7e..d03de0b2a208c9f2b918b5efcbf1f59d19f185dc 100644 (file)
@@ -1025,6 +1025,8 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
                }
                fprintf(f, "\n");
        }
+       if (config->scan_cur_freq != DEFAULT_SCAN_CUR_FREQ)
+               fprintf(f, "scan_cur_freq=%d\n", config->scan_cur_freq);
 
        if (config->sched_scan_interval)
                fprintf(f, "sched_scan_interval=%u\n",
index 2399692449cfd9449e873f3e7efed29be6e0e2a0..682e1be7022711a69e3676a6bfa2ded0b3776692 100644 (file)
@@ -481,6 +481,7 @@ static int non_p2p_network_enabled(struct wpa_supplicant *wpa_s)
        return 0;
 }
 
+#endif /* CONFIG_P2P */
 
 /*
  * Find the operating frequency of any other virtual interface that is using
@@ -520,8 +521,6 @@ static int shared_vif_oper_freq(struct wpa_supplicant *wpa_s)
        return 0;
 }
 
-#endif /* CONFIG_P2P */
-
 
 static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
 {
@@ -756,6 +755,19 @@ ssid_list_set:
                int_array_concat(&params.freqs, wpa_s->conf->freq_list);
        }
 
+       /* Use current associated channel? */
+       if (wpa_s->conf->scan_cur_freq && !params.freqs) {
+               int freq = shared_vif_oper_freq(wpa_s);
+               if (freq > 0) {
+                       wpa_dbg(wpa_s, MSG_DEBUG, "Scan only the current "
+                               "operating channel (%d MHz) since "
+                               "scan_cur_freq is enabled", freq);
+                       params.freqs = os_zalloc(sizeof(int) * 2);
+                       if (params.freqs)
+                               params.freqs[0] = freq;
+               }
+       }
+
        params.filter_ssids = wpa_supplicant_build_filter_ssids(
                wpa_s->conf, &params.num_filter_ssids);
        if (extra_ie) {
index 87dd3970a8118ec7be0a36fa9cc94a65791edca0..8e21a3aee68b46fd950b1ad5de1ee643f1a242dd 100644 (file)
@@ -310,6 +310,10 @@ fast_reauth=1
 # allowing it to update the internal BSS table.
 #ignore_old_scan_res=0
 
+# scan_cur_freq: Whether to scan only the current frequency
+# 0:  Scan all available frequencies. (Default)
+# 1:  Scan current operating frequency if another VIF on the same radio
+#     is already associated.
 
 # Interworking (IEEE 802.11u)