[PATCH] wpa_supplicant: Allow configuring scan frequencies.

Jouni Malinen j
Tue Apr 30 15:48:08 PDT 2013


On Tue, Apr 30, 2013 at 03:10:13PM -0700, greearb at candelatech.com wrote:
> 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.

Could you please add an example to wpa_supplicant.conf with some
documentation?

> Signed-hostap: Ben Greear <greearb at candelatech.com>
> Signed-off-by: Ben Greear <greearb at candelatech.com>

Not that the extra line really causes any problems here, but just to
note that I will drop the second one.

> diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
> +static int wpa_config_process_freq_list(const struct parse_data *data,

> +	freqs = wpa_config_parse_int_array(value);
> +	if (freqs == NULL)
> +		return -1;
> +	os_free(config->freq_list);
> +	config->freq_list = freqs;
> +	return 0;
> +}

Where does this config->freq_list get freed when the interface is
removed?

> diff --git 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;

Could you please clarify what that TODO item means? I have a slight
preference of not included it there as part of wpa_config documentation.

> diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
> @@ -750,6 +750,20 @@ ssid_list_set:
> +	/* See if user specified frequencies..if so, scan only those */
> +	if ((!params.freqs) && wpa_s->conf->freq_list) {

No need for the extra parenthesis around !freqs.

> +		for (i = 0; wpa_s->conf->freq_list[i]; i++) { }

Hmm.. This style is not used elsewhere in hostap.git, I think and I
cannot really say that I would be a fan of that "{ }" on the same line
with a for loop.. Anyway, this should use int_array_len().

> +		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];

os_zalloc() may return NULL..

Wouldn't int_array_concat(&params.freqs, wpa_s->conf->freq_list) work
here to replace both for loops and memory allocation?

-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list