[PATCH] wpa_supplicant: Allow vifs to scan only current channel.
greearb at candelatech.com
greearb
Wed May 8 15:35:18 PDT 2013
From: Ben Greear <greearb at candelatech.com>
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 at candelatech.com>
Signed-off-by: Ben Greear <greearb at candelatech.com>
---
:100644 100644 db08ab9... 5b09f50... M wpa_supplicant/config.c
:100644 100644 d533c1c... 7199aa6... M wpa_supplicant/config.h
:100644 100644 8ff4285... 9178226... M wpa_supplicant/config_file.c
:100644 100644 f5763ab... b857754... M wpa_supplicant/scan.c
:100644 100644 87dd397... 09023b4... M wpa_supplicant/wpa_supplicant.conf
wpa_supplicant/config.c | 2 ++
wpa_supplicant/config.h | 7 +++++++
wpa_supplicant/config_file.c | 3 +++
wpa_supplicant/scan.c | 17 +++++++++++++++--
wpa_supplicant/wpa_supplicant.conf | 13 +++++++++++++
5 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index db08ab9..5b09f50 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -2585,6 +2585,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;
@@ -3039,6 +3040,7 @@ static const struct global_parse_data global_fields[] = {
{ STR(pkcs11_module_path), 0 },
{ STR(pcsc_reader), 0 },
{ STR(pcsc_pin), 0 },
+ { INT(scan_cur_freq), 0 },
{ STR(driver_param), 0 },
{ INT(dot11RSNAConfigPMKLifetime), 0 },
{ INT(dot11RSNAConfigPMKReauthThreshold), 0 },
diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index d533c1c..7199aa6 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -21,6 +21,7 @@
#define DEFAULT_P2P_INTRA_BSS 1
#define DEFAULT_P2P_GO_MAX_INACTIVITY (5 * 60)
#define DEFAULT_BSS_MAX_COUNT 200
+#define DEFAULT_SCAN_CUR_FREQ 0
#define DEFAULT_BSS_EXPIRATION_AGE 180
#define DEFAULT_BSS_EXPIRATION_SCAN_COUNT 2
#define DEFAULT_MAX_NUM_STA 128
@@ -655,6 +656,12 @@ struct wpa_config {
*/
int *freq_list;
+
+ /* 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
*/
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index 8ff4285..9178226 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -945,6 +945,9 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
fprintf(f, "filter_ssids=%d\n", config->filter_ssids);
if (config->max_num_sta != DEFAULT_MAX_NUM_STA)
fprintf(f, "max_num_sta=%u\n", config->max_num_sta);
+ if (config->scan_cur_freq != DEFAULT_SCAN_CUR_FREQ)
+ fprintf(f, "scan_cur_freq=%d\n", config->scan_cur_freq);
+
if (config->disassoc_low_ack)
fprintf(f, "disassoc_low_ack=%u\n", config->disassoc_low_ack);
#ifdef CONFIG_HS20
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index f5763ab..b857754 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -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 */
-
void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
{
@@ -757,6 +756,20 @@ ssid_list_set:
int_array_concat(¶ms.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, ¶ms.num_filter_ssids);
if (extra_ie) {
diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf
index 87dd397..09023b4 100644
--- a/wpa_supplicant/wpa_supplicant.conf
+++ b/wpa_supplicant/wpa_supplicant.conf
@@ -527,6 +527,11 @@ fast_reauth=1
# This can also be set on the outside of the network block. In this case,
# it limits the frequencies that will be scanned.
#
+# scan_cur_freq: Scan current frequency.
+# 0: Scan all available frequencies. (Default)
+# 1: Scan current operating frequency if another VIF on the same radio
+# is already associated.
+#
# bgscan: Background scanning
# wpa_supplicant behavior for background scanning can be specified by
# configuring a bgscan module. These modules are responsible for requesting
@@ -1241,3 +1246,11 @@ freq_list=5180
network={
key_mgmt=NONE
}
+
+
+# Example config file that will scan on existing frequency if
+# another VIF on the same radio is already associated.
+scan_cur_freq=1
+network={
+ key_mgmt=NONE
+}
--
1.7.3.4
More information about the Hostap
mailing list