[PATCH v2] wpa_supplicant: Allow configuring scan frequencies.
greearb at candelatech.com
greearb
Tue Apr 30 17:16:50 PDT 2013
From: Ben Greear <greearb at candelatech.com>
This allows one to limit the channels that wpa_supplicant will
scan. This is a useful addition to the freq_list configurable
in the network {} section.
Signed-hostap: Ben Greear <greearb at candelatech.com>
---
:100644 100644 f8647bb... 28c40a1... M wpa_supplicant/config.c
:100644 100644 2f49e1e... ef95650... M wpa_supplicant/config.h
:100644 100644 f409e98... 5ed4097... M wpa_supplicant/scan.c
:100644 100644 0935a06... 6aed57a... M wpa_supplicant/wpa_supplicant.conf
wpa_supplicant/config.c | 16 ++++++++++++++++
wpa_supplicant/config.h | 8 ++++++++
wpa_supplicant/scan.c | 7 +++++++
wpa_supplicant/wpa_supplicant.conf | 10 ++++++++++
4 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index f8647bb..28c40a1 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -1826,6 +1826,7 @@ void wpa_config_free(struct wpa_config *config)
os_free(config->pssid);
os_free(config->p2p_pref_chan);
os_free(config->autoscan);
+ os_free(config->freq_list);
wpabuf_free(config->wps_nfc_dh_pubkey);
wpabuf_free(config->wps_nfc_dh_privkey);
wpabuf_free(config->wps_nfc_dev_pw);
@@ -2735,6 +2736,20 @@ static int wpa_global_config_parse_bin(const struct global_parse_data *data,
return 0;
}
+static int wpa_config_process_freq_list(const struct global_parse_data *data,
+ struct wpa_config *config, int line,
+ const char *value)
+{
+ int *freqs;
+
+ freqs = wpa_config_parse_int_array(value);
+ if (freqs == NULL)
+ return -1;
+ os_free(config->freq_list);
+ config->freq_list = freqs;
+ return 0;
+}
+
static int wpa_config_process_country(const struct global_parse_data *data,
struct wpa_config *config, int line,
@@ -3024,6 +3039,7 @@ static const struct global_parse_data global_fields[] = {
{ STR(pcsc_reader), 0 },
{ STR(pcsc_pin), 0 },
{ STR(driver_param), 0 },
+ { FUNC(freq_list), 0 },
{ INT(dot11RSNAConfigPMKLifetime), 0 },
{ INT(dot11RSNAConfigPMKReauthThreshold), 0 },
{ INT(dot11RSNAConfigSATimeout), 0 },
diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index 2f49e1e..ef95650 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -648,6 +648,14 @@ struct wpa_config {
unsigned int max_num_sta;
/**
+ * freq_list - Array of allowed scan frequencies or %NULL for all
+ *
+ * This is an optional zero-terminated array of frequencies in
+ * megahertz (MHz) to allow for narrowing scanning range.
+ */
+ int *freq_list;
+
+ /**
* changed_parameters - Bitmap of changed parameters since last update
*/
unsigned int changed_parameters;
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index f409e98..5ed4097 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -750,6 +750,13 @@ ssid_list_set:
os_free(wpa_s->next_scan_freqs);
wpa_s->next_scan_freqs = NULL;
+ /* See if user specified frequencies..if so, scan only those */
+ if (wpa_s->conf->freq_list && !params.freqs) {
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "Optimize scan based on conf->freq_list");
+ int_array_concat(¶ms.freqs, wpa_s->conf->freq_list);
+ }
+
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 0935a06..6aed57a 100644
--- a/wpa_supplicant/wpa_supplicant.conf
+++ b/wpa_supplicant/wpa_supplicant.conf
@@ -524,6 +524,9 @@ fast_reauth=1
# set, scan results that do not match any of the specified frequencies are not
# considered when selecting a BSS.
#
+# This can also be set on the outside of the network block. In this case,
+# it limits the frequencies that will be scanned.
+#
# bgscan: Background scanning
# wpa_supplicant behavior for background scanning can be specified by
# configuring a bgscan module. These modules are responsible for requesting
@@ -1231,3 +1234,10 @@ SGVsbG8gV29ybGQhCg==
network={
key_mgmt=NONE
}
+
+
+# Example config file that will only scan on channel 36.
+freq_list=5180
+network={
+ key_mgmt=NONE
+}
--
1.7.3.4
More information about the Hostap
mailing list