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 <dimitrysh@google.com>
This commit is contained in:
Dmitry Shmidt 2014-03-14 13:55:25 -07:00 committed by Jouni Malinen
parent b998236543
commit d3c9c35f32
4 changed files with 39 additions and 4 deletions

View file

@ -46,6 +46,8 @@ static int wpa_supplicant_global_iface_list(struct wpa_global *global,
char *buf, int len); char *buf, int len);
static int wpa_supplicant_global_iface_interfaces(struct wpa_global *global, static int wpa_supplicant_global_iface_interfaces(struct wpa_global *global,
char *buf, int len); 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) 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 */ #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, static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s,
char *cmd) 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); wpa_tdls_enable(wpa_s->wpa, !disabled);
#endif /* CONFIG_TDLS */ #endif /* CONFIG_TDLS */
} else if (os_strcasecmp(cmd, "pno") == 0) { } else if (os_strcasecmp(cmd, "pno") == 0) {
if (atoi(value)) ret = wpas_ctrl_pno(wpa_s, value);
ret = wpas_start_pno(wpa_s);
else
ret = wpas_stop_pno(wpa_s);
} else if (os_strcasecmp(cmd, "radio_disabled") == 0) { } else if (os_strcasecmp(cmd, "radio_disabled") == 0) {
int disabled = atoi(value); int disabled = atoi(value);
if (wpa_drv_radio_disable(wpa_s, disabled) < 0) if (wpa_drv_radio_disable(wpa_s, disabled) < 0)

View file

@ -1923,6 +1923,11 @@ int wpas_start_pno(struct wpa_supplicant *wpa_s)
interval = wpa_s->conf->sched_scan_interval ? interval = wpa_s->conf->sched_scan_interval ?
wpa_s->conf->sched_scan_interval : 10; 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, &params, interval); ret = wpa_supplicant_start_sched_scan(wpa_s, &params, interval);
os_free(params.filter_ssids); os_free(params.filter_ssids);
if (ret == 0) if (ret == 0)

View file

@ -460,6 +460,9 @@ static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s)
os_free(wpa_s->manual_scan_freqs); os_free(wpa_s->manual_scan_freqs);
wpa_s->manual_scan_freqs = NULL; 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); gas_query_deinit(wpa_s->gas);
wpa_s->gas = NULL; wpa_s->gas = NULL;

View file

@ -547,6 +547,7 @@ struct wpa_supplicant {
int scan_runs; /* number of scan runs since WPS was started */ int scan_runs; /* number of scan runs since WPS was started */
int *next_scan_freqs; int *next_scan_freqs;
int *manual_scan_freqs; int *manual_scan_freqs;
int *manual_sched_scan_freqs;
unsigned int manual_scan_passive:1; unsigned int manual_scan_passive:1;
unsigned int manual_scan_use_id:1; unsigned int manual_scan_use_id:1;
unsigned int manual_scan_only_new:1; unsigned int manual_scan_only_new:1;