From patchwork Tue Apr 30 22:10:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 240700 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 69AA02C00BA for ; Wed, 1 May 2013 08:10:49 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 38A279C0B4; Tue, 30 Apr 2013 18:10:47 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xz5md0r-I1bl; Tue, 30 Apr 2013 18:10:46 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id E61159C050; Tue, 30 Apr 2013 18:10:41 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 977CA9C0DF for ; Tue, 30 Apr 2013 18:10:40 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qcQSkNOTs00c for ; Tue, 30 Apr 2013 18:10:34 -0400 (EDT) Received: from ns3.lanforge.com (mail.candelatech.com [208.74.158.172]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 8F6989C050 for ; Tue, 30 Apr 2013 18:10:34 -0400 (EDT) Received: from localhost.localdomain (firewall.candelatech.com [70.89.124.249]) by ns3.lanforge.com (8.14.2/8.14.2) with ESMTP id r3UMAKGr018353 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 30 Apr 2013 15:10:21 -0700 From: greearb@candelatech.com To: hostap@lists.shmoo.com Subject: [PATCH] wpa_supplicant: Allow configuring scan frequencies. Date: Tue, 30 Apr 2013 15:10:13 -0700 Message-Id: <1367359813-10928-1-git-send-email-greearb@candelatech.com> X-Mailer: git-send-email 1.7.3.4 Cc: Ben Greear X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com From: Ben Greear 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 Signed-off-by: Ben Greear --- :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, ¶ms.num_filter_ssids); if (extra_ie) {