From d3c9c35f32950a9636c3fe4b875e4189f838fc3b Mon Sep 17 00:00:00 2001 From: Dmitry Shmidt Date: Fri, 14 Mar 2014 13:55:25 -0700 Subject: [PATCH] Add freq= parameter to 'set pno' command This allows channels-to-be-scanned to be specified for PNO similarly to the scan command. Signed-off-by: Dmitry Shmidt --- wpa_supplicant/ctrl_iface.c | 34 +++++++++++++++++++++++++++---- wpa_supplicant/scan.c | 5 +++++ wpa_supplicant/wpa_supplicant.c | 3 +++ wpa_supplicant/wpa_supplicant_i.h | 1 + 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 87ed3e26c..704caa1e2 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -46,6 +46,8 @@ static int wpa_supplicant_global_iface_list(struct wpa_global *global, char *buf, int len); static int wpa_supplicant_global_iface_interfaces(struct wpa_global *global, char *buf, int len); +static int * freq_range_to_channel_list(struct wpa_supplicant *wpa_s, + char *val); static int set_bssid_filter(struct wpa_supplicant *wpa_s, char *val) { @@ -245,6 +247,33 @@ static int wpas_ctrl_set_blob(struct wpa_supplicant *wpa_s, char *pos) } #endif /* CONFIG_NO_CONFIG_BLOBS */ + +static int wpas_ctrl_pno(struct wpa_supplicant *wpa_s, char *cmd) +{ + char *params; + char *pos; + int *freqs = NULL; + int ret; + + if (atoi(cmd)) { + params = os_strchr(cmd, ' '); + os_free(wpa_s->manual_sched_scan_freqs); + if (params) { + params++; + pos = os_strstr(params, "freq="); + if (pos) + freqs = freq_range_to_channel_list(wpa_s, + pos + 5); + } + wpa_s->manual_sched_scan_freqs = freqs; + ret = wpas_start_pno(wpa_s); + } else { + ret = wpas_stop_pno(wpa_s); + } + return ret; +} + + static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s, char *cmd) { @@ -328,10 +357,7 @@ static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s, wpa_tdls_enable(wpa_s->wpa, !disabled); #endif /* CONFIG_TDLS */ } else if (os_strcasecmp(cmd, "pno") == 0) { - if (atoi(value)) - ret = wpas_start_pno(wpa_s); - else - ret = wpas_stop_pno(wpa_s); + ret = wpas_ctrl_pno(wpa_s, value); } else if (os_strcasecmp(cmd, "radio_disabled") == 0) { int disabled = atoi(value); if (wpa_drv_radio_disable(wpa_s, disabled) < 0) diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 1d8e8a609..48e94b612 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -1923,6 +1923,11 @@ int wpas_start_pno(struct wpa_supplicant *wpa_s) interval = wpa_s->conf->sched_scan_interval ? wpa_s->conf->sched_scan_interval : 10; + if (params.freqs == NULL && wpa_s->manual_sched_scan_freqs) { + wpa_dbg(wpa_s, MSG_DEBUG, "Limit sched scan to specified channels"); + params.freqs = wpa_s->manual_sched_scan_freqs; + } + ret = wpa_supplicant_start_sched_scan(wpa_s, ¶ms, interval); os_free(params.filter_ssids); if (ret == 0) diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 690fd0672..dce1c008b 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -460,6 +460,9 @@ static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s) os_free(wpa_s->manual_scan_freqs); wpa_s->manual_scan_freqs = NULL; + os_free(wpa_s->manual_sched_scan_freqs); + wpa_s->manual_sched_scan_freqs = NULL; + gas_query_deinit(wpa_s->gas); wpa_s->gas = NULL; diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 739b11f70..8a3328661 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -547,6 +547,7 @@ struct wpa_supplicant { int scan_runs; /* number of scan runs since WPS was started */ int *next_scan_freqs; int *manual_scan_freqs; + int *manual_sched_scan_freqs; unsigned int manual_scan_passive:1; unsigned int manual_scan_use_id:1; unsigned int manual_scan_only_new:1;