[PATCH] wpa_supplicant: Allow configuring scan frequencies.

greearb at candelatech.com greearb
Tue Apr 30 15:10:13 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>
Signed-off-by: Ben Greear <greearb at candelatech.com>
---
:100644 100644 638cf40... a1f5010... M	wpa_supplicant/config.c
:100644 100644 2f49e1e... 0c7c477... M	wpa_supplicant/config.h
:100644 100644 f409e98... 51f34df... M	wpa_supplicant/scan.c
 wpa_supplicant/config.c |   15 +++++++++++++++
 wpa_supplicant/config.h |    9 +++++++++
 wpa_supplicant/scan.c   |   14 ++++++++++++++
 3 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index 638cf40..a1f5010 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -897,6 +897,20 @@ static int wpa_config_parse_freq_list(const struct parse_data *data,
 	return 0;
 }
 
+static int wpa_config_process_freq_list(const struct 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;
+}
+
 
 #ifndef NO_CONFIG_WRITE
 static char * wpa_config_write_freqs(const struct parse_data *data,
@@ -3026,6 +3040,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..0c7c477 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -648,6 +648,15 @@ 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.
+	 * TODO:  Could make it limit ssid freq_lists as well.
+	 */
+	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..51f34df 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -750,6 +750,20 @@ 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 ((!params.freqs) && wpa_s->conf->freq_list) {
+		int cnt = 0;
+		int i;
+
+		wpa_dbg(wpa_s, MSG_DEBUG,
+			"Optimize scan based on conf->freq_list");
+		for (i = 0; wpa_s->conf->freq_list[i]; i++) { }
+		
+		params.freqs = os_zalloc(sizeof(int) * (i + 1));
+		for (i = 0; wpa_s->conf->freq_list[i]; i++)
+			params.freqs[i] = wpa_s->conf->freq_list[i];
+	}
+
 	params.filter_ssids = wpa_supplicant_build_filter_ssids(
 		wpa_s->conf, &params.num_filter_ssids);
 	if (extra_ie) {
-- 
1.7.3.4




More information about the Hostap mailing list