[PATCH] Add freq= parameter to 'set pno' command
Dmitry Shmidt
dimitrysh
Fri Mar 14 13:55:25 PDT 2014
Change-Id: Id27791d81963caca704ca8afb99d86208c6b9fb6
Signed-off-by: Dmitry Shmidt <dimitrysh at google.com>
---
wpa_supplicant/ctrl_iface.c | 33 +++++++++++++++++++++++++++++----
wpa_supplicant/scan.c | 5 +++++
wpa_supplicant/wpa_supplicant.c | 3 +++
wpa_supplicant/wpa_supplicant_i.h | 1 +
4 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 98c4b65..deb8902 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)
{
@@ -206,6 +208,32 @@ static int set_disallow_aps(struct wpa_supplicant *wpa_s, char *val)
}
+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)
{
@@ -289,10 +317,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 1d8e8a6..48e94b6 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 6a04e5a..b729fbd 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 739b11f..8a33286 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;
--
1.9.0.279.gdc9e3eb
More information about the Hostap
mailing list