* [PATCH iw v2 0/4] iw: add scheduled scan support
@ 2015-03-17 14:11 Luca Coelho
2015-03-17 14:11 ` [PATCH iw v2 1/4] iw: move generic sched scan parsing code out of net detect Luca Coelho
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Luca Coelho @ 2015-03-17 14:11 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless
From: Luciano Coelho <luciano.coelho@intel.com>
This series adds scheduled scan support to the iw tool (finally! ;).
In v2, just rebased.
Luciano Coelho (4):
iw: move generic sched scan parsing code out of net detect
iw: implement scheduled scan
iw: add support for active scheduled scan
iw: add randomise option for sched_scan
event.c | 9 +++
info.c | 6 ++
iw.h | 4 +
scan.c | 266 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
wowlan.c | 174 ++---------------------------------------
5 files changed, 292 insertions(+), 167 deletions(-)
--
2.1.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH iw v2 1/4] iw: move generic sched scan parsing code out of net detect
2015-03-17 14:11 [PATCH iw v2 0/4] iw: add scheduled scan support Luca Coelho
@ 2015-03-17 14:11 ` Luca Coelho
2015-03-17 14:11 ` [PATCH iw v2 2/4] iw: implement scheduled scan Luca Coelho
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Luca Coelho @ 2015-03-17 14:11 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless
From: Luciano Coelho <luciano.coelho@intel.com>
The scheduled scan structure is pretty much the same as the net-detect
WoWLAN trigger's. Move the bulk of the command line parsing code to
a generic function so we can reuse it for sched_scan.
Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
---
iw.h | 4 ++
scan.c | 170 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
wowlan.c | 174 +++------------------------------------------------------------
3 files changed, 181 insertions(+), 167 deletions(-)
diff --git a/iw.h b/iw.h
index db88a86..efc21d6 100644
--- a/iw.h
+++ b/iw.h
@@ -173,6 +173,10 @@ void print_ies(unsigned char *ie, int ielen, bool unknown,
void parse_bitrate(struct nlattr *bitrate_attr, char *buf, int buflen);
void iw_hexdump(const char *prefix, const __u8 *data, size_t len);
+#define SCHED_SCAN_OPTIONS "interval <in_msecs> [delay <in_secs>] " \
+ "[freqs <freq>+] [matches [ssid <ssid>]+]]"
+int parse_sched_scan(struct nl_msg *msg, int *argc, char ***argv);
+
DECLARE_SECTION(set);
DECLARE_SECTION(get);
diff --git a/scan.c b/scan.c
index 538b30e..d1c3bf2 100644
--- a/scan.c
+++ b/scan.c
@@ -99,6 +99,176 @@ static int parse_random_mac_addr(struct nl_msg *msg, char *arg)
return -ENOBUFS;
}
+int parse_sched_scan(struct nl_msg *msg, int *argc, char ***argv)
+{
+ struct nl_msg *matchset = NULL, *freqs = NULL;
+ struct nlattr *match = NULL;
+ enum {
+ ND_TOPLEVEL,
+ ND_MATCH,
+ ND_FREQS,
+ } parse_state = ND_TOPLEVEL;
+ int c = *argc;
+ char *end, **v = *argv;
+ int err = 0, i = 0;
+ unsigned int freq, interval = 0, delay = 0;
+ bool have_matchset = false, have_freqs = false;
+
+ matchset = nlmsg_alloc();
+ if (!matchset) {
+ err = -ENOBUFS;
+ goto out;
+ }
+
+ freqs = nlmsg_alloc();
+ if (!freqs) {
+ err = -ENOBUFS;
+ goto out;
+ }
+
+ while (c) {
+ switch (parse_state) {
+ case ND_TOPLEVEL:
+ if (!strcmp(v[0], "interval")) {
+ c--; v++;
+ if (c == 0) {
+ err = -EINVAL;
+ goto nla_put_failure;
+ }
+
+ if (interval) {
+ err = -EINVAL;
+ goto nla_put_failure;
+ }
+ interval = strtoul(v[0], &end, 10);
+ if (*end || !interval) {
+ err = -EINVAL;
+ goto nla_put_failure;
+ }
+ NLA_PUT_U32(msg,
+ NL80211_ATTR_SCHED_SCAN_INTERVAL,
+ interval);
+ } else if (!strcmp(v[0], "delay")) {
+ c--; v++;
+ if (c == 0) {
+ err = -EINVAL;
+ goto nla_put_failure;
+ }
+
+ if (delay) {
+ err = -EINVAL;
+ goto nla_put_failure;
+ }
+ delay = strtoul(v[0], &end, 10);
+ if (*end) {
+ err = -EINVAL;
+ goto nla_put_failure;
+ }
+ NLA_PUT_U32(msg,
+ NL80211_ATTR_SCHED_SCAN_DELAY,
+ delay);
+ } else if (!strcmp(v[0], "matches")) {
+ parse_state = ND_MATCH;
+ if (have_matchset) {
+ err = -EINVAL;
+ goto nla_put_failure;
+ }
+
+ i = 0;
+ } else if (!strcmp(v[0], "freqs")) {
+ parse_state = ND_FREQS;
+ if (have_freqs) {
+ err = -EINVAL;
+ goto nla_put_failure;
+ }
+
+ have_freqs = true;
+ i = 0;
+ } else {
+ /* this element is not for us, so
+ * return to continue parsing.
+ */
+ goto nla_put_failure;
+ }
+ c--; v++;
+
+ break;
+ case ND_MATCH:
+ if (!strcmp(v[0], "ssid")) {
+ c--; v++;
+ if (c == 0) {
+ err = -EINVAL;
+ goto nla_put_failure;
+ }
+
+ /* TODO: for now we can only have an
+ * SSID in the match, so we can start
+ * the match nest here.
+ */
+ match = nla_nest_start(matchset, i);
+ if (!match) {
+ err = -ENOBUFS;
+ goto nla_put_failure;
+ }
+
+ NLA_PUT(matchset,
+ NL80211_SCHED_SCAN_MATCH_ATTR_SSID,
+ strlen(v[0]), v[0]);
+ nla_nest_end(matchset, match);
+ match = NULL;
+
+ have_matchset = true;
+ i++;
+ c--; v++;
+ } else {
+ /* other element that cannot be part
+ * of a match indicates the end of the
+ * match. */
+ /* need at least one match in the matchset */
+ if (i == 0) {
+ err = -EINVAL;
+ goto nla_put_failure;
+ }
+
+ parse_state = ND_TOPLEVEL;
+ }
+
+ break;
+ case ND_FREQS:
+ freq = strtoul(v[0], &end, 10);
+ if (*end) {
+ if (i == 0) {
+ err = -EINVAL;
+ goto nla_put_failure;
+ }
+
+ parse_state = ND_TOPLEVEL;
+ } else {
+ NLA_PUT_U32(freqs, i, freq);
+ i++;
+ c--; v++;
+ }
+ break;
+ }
+ }
+
+ if (have_freqs)
+ nla_put_nested(msg, NL80211_ATTR_SCAN_FREQUENCIES, freqs);
+ if (have_matchset)
+ nla_put_nested(msg, NL80211_ATTR_SCHED_SCAN_MATCH, matchset);
+
+nla_put_failure:
+ if (match)
+ nla_nest_end(msg, match);
+ nlmsg_free(freqs);
+ nlmsg_free(matchset);
+
+out:
+ *argc = c;
+ *argv = v;
+ return err;
+}
+
static int handle_scan(struct nl80211_state *state,
struct nl_cb *cb,
struct nl_msg *msg,
diff --git a/wowlan.c b/wowlan.c
index 82932e8..3a87665 100644
--- a/wowlan.c
+++ b/wowlan.c
@@ -183,177 +183,17 @@ static int wowlan_parse_tcp_file(struct nl_msg *msg, const char *fn)
static int wowlan_parse_net_detect(struct nl_msg *msg, int *argc, char ***argv)
{
- struct nl_msg *matchset = NULL, *freqs = NULL;
- struct nlattr *nd, *match = NULL;
- enum {
- ND_TOPLEVEL,
- ND_MATCH,
- ND_FREQS,
- } parse_state = ND_TOPLEVEL;
- int c = *argc;
- char *end, **v = *argv;
- int err = 0, i = 0;
- unsigned int freq, interval = 0, delay = 0;
- bool have_matchset = false, have_freqs = false;
+ struct nlattr *nd;
+ int err = 0;
nd = nla_nest_start(msg, NL80211_WOWLAN_TRIG_NET_DETECT);
- if (!nd) {
- err = -ENOBUFS;
- goto out;
- }
-
- matchset = nlmsg_alloc();
- if (!matchset) {
- err = -ENOBUFS;
- goto out;
- }
-
- freqs = nlmsg_alloc();
- if (!freqs) {
- err = -ENOBUFS;
- goto out;
- }
-
- while (c) {
- switch (parse_state) {
- case ND_TOPLEVEL:
- if (!strcmp(v[0], "interval")) {
- c--; v++;
- if (c == 0) {
- err = -EINVAL;
- goto nla_put_failure;
- }
-
- if (interval) {
- err = -EINVAL;
- goto nla_put_failure;
- }
- interval = strtoul(v[0], &end, 10);
- if (*end || !interval) {
- err = -EINVAL;
- goto nla_put_failure;
- }
- NLA_PUT_U32(msg,
- NL80211_ATTR_SCHED_SCAN_INTERVAL,
- interval);
- } else if (!strcmp(v[0], "delay")) {
- c--; v++;
- if (c == 0) {
- err = -EINVAL;
- goto nla_put_failure;
- }
-
- if (delay) {
- err = -EINVAL;
- goto nla_put_failure;
- }
- delay = strtoul(v[0], &end, 10);
- if (*end) {
- err = -EINVAL;
- goto nla_put_failure;
- }
- NLA_PUT_U32(msg,
- NL80211_ATTR_SCHED_SCAN_DELAY,
- delay);
- } else if (!strcmp(v[0], "matches")) {
- parse_state = ND_MATCH;
- if (have_matchset) {
- err = -EINVAL;
- goto nla_put_failure;
- }
-
- i = 0;
- } else if (!strcmp(v[0], "freqs")) {
- parse_state = ND_FREQS;
- if (have_freqs) {
- err = -EINVAL;
- goto nla_put_failure;
- }
-
- have_freqs = true;
- i = 0;
- } else {
- /* this element is not for us, so
- * return to continue parsing.
- */
- goto nla_put_failure;
- }
- c--; v++;
-
- break;
- case ND_MATCH:
- if (!strcmp(v[0], "ssid")) {
- c--; v++;
- if (c == 0) {
- err = -EINVAL;
- goto nla_put_failure;
- }
-
- /* TODO: for now we can only have an
- * SSID in the match, so we can start
- * the match nest here.
- */
- match = nla_nest_start(matchset, i);
- if (!match) {
- err = -ENOBUFS;
- goto nla_put_failure;
- }
-
- NLA_PUT(matchset,
- NL80211_SCHED_SCAN_MATCH_ATTR_SSID,
- strlen(v[0]), v[0]);
- nla_nest_end(matchset, match);
- match = NULL;
-
- have_matchset = true;
- i++;
- c--; v++;
- } else {
- /* other element that cannot be part
- * of a match indicates the end of the
- * match. */
- /* need at least one match in the matchset */
- if (i == 0) {
- err = -EINVAL;
- goto nla_put_failure;
- }
-
- parse_state = ND_TOPLEVEL;
- }
-
- break;
- case ND_FREQS:
- freq = strtoul(v[0], &end, 10);
- if (*end) {
- if (i == 0) {
- err = -EINVAL;
- goto nla_put_failure;
- }
-
- parse_state = ND_TOPLEVEL;
- } else {
- NLA_PUT_U32(freqs, i, freq);
- i++;
- c--; v++;
- }
- break;
- }
- }
+ if (!nd)
+ return -ENOBUFS;
- if (have_freqs)
- nla_put_nested(msg, NL80211_ATTR_SCAN_FREQUENCIES, freqs);
- if (have_matchset)
- nla_put_nested(msg, NL80211_ATTR_SCHED_SCAN_MATCH, matchset);
+ err = parse_sched_scan(msg, argc, argv);
-nla_put_failure:
- if (match)
- nla_nest_end(msg, match);
- nlmsg_free(freqs);
- nlmsg_free(matchset);
nla_nest_end(msg, nd);
-out:
- *argc = c;
- *argv = v;
+
return err;
}
@@ -473,7 +313,7 @@ static int handle_wowlan_enable(struct nl80211_state *state, struct nl_cb *cb,
return err;
}
COMMAND(wowlan, enable, "[any] [disconnect] [magic-packet] [gtk-rekey-failure] [eap-identity-request]"
- " [4way-handshake] [rfkill-release] [net-detect interval <in_msecs> [delay <in_secs>] [freqs <freq>+] [matches [ssid <ssid>]+]]"
+ " [4way-handshake] [rfkill-release] [net-detect " SCHED_SCAN_OPTIONS "]"
" [tcp <config-file>] [patterns [offset1+]<pattern1> ...]",
NL80211_CMD_SET_WOWLAN, 0, CIB_PHY, handle_wowlan_enable,
"Enable WoWLAN with the given triggers.\n"
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH iw v2 2/4] iw: implement scheduled scan
2015-03-17 14:11 [PATCH iw v2 0/4] iw: add scheduled scan support Luca Coelho
2015-03-17 14:11 ` [PATCH iw v2 1/4] iw: move generic sched scan parsing code out of net detect Luca Coelho
@ 2015-03-17 14:11 ` Luca Coelho
2015-03-17 14:11 ` [PATCH iw v2 3/4] iw: add support for active " Luca Coelho
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Luca Coelho @ 2015-03-17 14:11 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless
From: Luciano Coelho <luciano.coelho@nokia.com>
Add sched_start, sched_stop and events parsing for scheduled scan.
For now, only passive scans are supported.
Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
---
event.c | 9 +++++++++
info.c | 6 ++++++
scan.c | 29 +++++++++++++++++++++++++++++
3 files changed, 44 insertions(+)
diff --git a/event.c b/event.c
index 71ab7f7..929854b 100644
--- a/event.c
+++ b/event.c
@@ -359,6 +359,15 @@ static int print_event(struct nl_msg *msg, void *arg)
}
printf("\n");
break;
+ case NL80211_CMD_START_SCHED_SCAN:
+ printf("scheduled scan started\n");
+ break;
+ case NL80211_CMD_SCHED_SCAN_STOPPED:
+ printf("sched scan stopped\n");
+ break;
+ case NL80211_CMD_SCHED_SCAN_RESULTS:
+ printf("got scheduled scan results\n");
+ break;
case NL80211_CMD_REG_CHANGE:
printf("regulatory domain change: ");
diff --git a/info.c b/info.c
index 1df503f..66887e3 100644
--- a/info.c
+++ b/info.c
@@ -232,6 +232,12 @@ next:
if (tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN])
printf("\tmax scan IEs length: %d bytes\n",
nla_get_u16(tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN]));
+ if (tb_msg[NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS])
+ printf("\tmax # sched scan SSIDs: %d\n",
+ nla_get_u8(tb_msg[NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS]));
+ if (tb_msg[NL80211_ATTR_MAX_MATCH_SETS])
+ printf("\tmax # match sets: %d\n",
+ nla_get_u8(tb_msg[NL80211_ATTR_MAX_MATCH_SETS]));
if (tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]) {
unsigned int frag;
diff --git a/scan.c b/scan.c
index d1c3bf2..e534fd4 100644
--- a/scan.c
+++ b/scan.c
@@ -1980,3 +1980,32 @@ COMMAND(scan, trigger, "[freq <freq>*] [ies <hex as 00:11:..>] [meshid <meshid>]
NL80211_CMD_TRIGGER_SCAN, 0, CIB_NETDEV, handle_scan,
"Trigger a scan on the given frequencies with probing for the given\n"
"SSIDs (or wildcard if not given) unless passive scanning is requested.");
+
+
+static int handle_start_sched_scan(struct nl80211_state *state,
+ struct nl_cb *cb, struct nl_msg *msg,
+ int argc, char **argv, enum id_input id)
+{
+ return parse_sched_scan(msg, &argc, &argv);
+}
+
+static int handle_stop_sched_scan(struct nl80211_state *state, struct nl_cb *cb,
+ struct nl_msg *msg, int argc, char **argv,
+ enum id_input id)
+{
+ if (argc != 0)
+ return 1;
+
+ return 0;
+}
+
+COMMAND(scan, sched_start,
+ SCHED_SCAN_OPTIONS,
+ NL80211_CMD_START_SCHED_SCAN, 0, CIB_NETDEV, handle_start_sched_scan,
+ "Start a scheduled scan at the specified interval on the given frequencies\n"
+ "with probing for the given SSIDs (or wildcard if not given) unless passive\n"
+ "scanning is requested. If matches are specified, only matching results\n"
+ "will be returned.");
+COMMAND(scan, sched_stop, "",
+ NL80211_CMD_STOP_SCHED_SCAN, 0, CIB_NETDEV, handle_stop_sched_scan,
+ "Stop an ongoing scheduled scan.");
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH iw v2 3/4] iw: add support for active scheduled scan
2015-03-17 14:11 [PATCH iw v2 0/4] iw: add scheduled scan support Luca Coelho
2015-03-17 14:11 ` [PATCH iw v2 1/4] iw: move generic sched scan parsing code out of net detect Luca Coelho
2015-03-17 14:11 ` [PATCH iw v2 2/4] iw: implement scheduled scan Luca Coelho
@ 2015-03-17 14:11 ` Luca Coelho
2015-03-17 14:11 ` [PATCH iw v2 4/4] iw: add randomise option for sched_scan Luca Coelho
2015-03-17 15:10 ` [PATCH iw v2 0/4] iw: add scheduled scan support Johannes Berg
4 siblings, 0 replies; 6+ messages in thread
From: Luca Coelho @ 2015-03-17 14:11 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless
From: Luciano Coelho <luciano.coelho@intel.com>
Add options to explicitly use active or passive scans on schedule
scans (and net-detect). If neither active nor passive parameters are
passed, the default is to do active scans with the wildcard SSID.
Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
---
iw.h | 2 +-
scan.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 59 insertions(+), 3 deletions(-)
diff --git a/iw.h b/iw.h
index efc21d6..fc20838 100644
--- a/iw.h
+++ b/iw.h
@@ -174,7 +174,7 @@ void parse_bitrate(struct nlattr *bitrate_attr, char *buf, int buflen);
void iw_hexdump(const char *prefix, const __u8 *data, size_t len);
#define SCHED_SCAN_OPTIONS "interval <in_msecs> [delay <in_secs>] " \
- "[freqs <freq>+] [matches [ssid <ssid>]+]]"
+ "[freqs <freq>+] [matches [ssid <ssid>]+]] [active [ssid <ssid>]+|passive] "
int parse_sched_scan(struct nl_msg *msg, int *argc, char ***argv);
DECLARE_SECTION(set);
diff --git a/scan.c b/scan.c
index e534fd4..7ff04ec 100644
--- a/scan.c
+++ b/scan.c
@@ -101,18 +101,20 @@ static int parse_random_mac_addr(struct nl_msg *msg, char *arg)
int parse_sched_scan(struct nl_msg *msg, int *argc, char ***argv)
{
- struct nl_msg *matchset = NULL, *freqs = NULL;
+ struct nl_msg *matchset = NULL, *freqs = NULL, *ssids = NULL;
struct nlattr *match = NULL;
enum {
ND_TOPLEVEL,
ND_MATCH,
ND_FREQS,
+ ND_ACTIVE,
} parse_state = ND_TOPLEVEL;
int c = *argc;
char *end, **v = *argv;
int err = 0, i = 0;
unsigned int freq, interval = 0, delay = 0;
- bool have_matchset = false, have_freqs = false;
+ bool have_matchset = false, have_freqs = false, have_ssids = false;
+ bool have_active = false, have_passive = false;
matchset = nlmsg_alloc();
if (!matchset) {
@@ -126,6 +128,12 @@ int parse_sched_scan(struct nl_msg *msg, int *argc, char ***argv)
goto out;
}
+ ssids = nlmsg_alloc();
+ if (!ssids) {
+ err = -ENOMEM;
+ goto out;
+ }
+
while (c) {
switch (parse_state) {
case ND_TOPLEVEL:
@@ -184,6 +192,22 @@ int parse_sched_scan(struct nl_msg *msg, int *argc, char ***argv)
have_freqs = true;
i = 0;
+ } else if (!strcmp(v[0], "active")) {
+ parse_state = ND_ACTIVE;
+ if (have_active || have_passive) {
+ err = -EINVAL;
+ goto nla_put_failure;
+ }
+
+ have_active = true;
+ i = 0;
+ } else if (!strcmp(v[0], "passive")) {
+ if (have_active || have_passive) {
+ err = -EINVAL;
+ goto nla_put_failure;
+ }
+
+ have_passive = true;
} else {
/* this element is not for us, so
* return to continue parsing.
@@ -249,9 +273,41 @@ int parse_sched_scan(struct nl_msg *msg, int *argc, char ***argv)
c--; v++;
}
break;
+ case ND_ACTIVE:
+ if (!strcmp(v[0], "ssid")) {
+ c--; v++;
+ if (c == 0) {
+ err = -EINVAL;
+ goto nla_put_failure;
+ }
+
+ NLA_PUT(ssids,
+ NL80211_SCHED_SCAN_MATCH_ATTR_SSID,
+ strlen(v[0]), v[0]);
+
+ have_ssids = true;
+ i++;
+ c--; v++;
+ } else {
+ /* other element that cannot be part
+ * of a match indicates the end of the
+ * active set. */
+ /* need at least one item in the set */
+ if (i == 0) {
+ err = -EINVAL;
+ goto nla_put_failure;
+ }
+
+ parse_state = ND_TOPLEVEL;
+ }
+ break;
}
}
+ if (!have_ssids)
+ NLA_PUT(ssids, 1, 0, "");
+ if (!have_passive)
+ nla_put_nested(msg, NL80211_ATTR_SCAN_SSIDS, ssids);
if (have_freqs)
nla_put_nested(msg, NL80211_ATTR_SCAN_FREQUENCIES, freqs);
if (have_matchset)
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH iw v2 4/4] iw: add randomise option for sched_scan
2015-03-17 14:11 [PATCH iw v2 0/4] iw: add scheduled scan support Luca Coelho
` (2 preceding siblings ...)
2015-03-17 14:11 ` [PATCH iw v2 3/4] iw: add support for active " Luca Coelho
@ 2015-03-17 14:11 ` Luca Coelho
2015-03-17 15:10 ` [PATCH iw v2 0/4] iw: add scheduled scan support Johannes Berg
4 siblings, 0 replies; 6+ messages in thread
From: Luca Coelho @ 2015-03-17 14:11 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless
From: Luciano Coelho <luciano.coelho@intel.com>
Like with normal scans, we can randomise the MAC address sent out in
active scheduled scans. Add the randomise option to sched_scan (and
net-detect) parsing code.
Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
---
iw.h | 2 +-
scan.c | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/iw.h b/iw.h
index fc20838..78195ea 100644
--- a/iw.h
+++ b/iw.h
@@ -174,7 +174,7 @@ void parse_bitrate(struct nlattr *bitrate_attr, char *buf, int buflen);
void iw_hexdump(const char *prefix, const __u8 *data, size_t len);
#define SCHED_SCAN_OPTIONS "interval <in_msecs> [delay <in_secs>] " \
- "[freqs <freq>+] [matches [ssid <ssid>]+]] [active [ssid <ssid>]+|passive] "
+ "[freqs <freq>+] [matches [ssid <ssid>]+]] [active [ssid <ssid>]+|passive] [randomise[=<addr>/<mask>]]"
int parse_sched_scan(struct nl_msg *msg, int *argc, char ***argv);
DECLARE_SECTION(set);
diff --git a/scan.c b/scan.c
index 7ff04ec..e959c1b 100644
--- a/scan.c
+++ b/scan.c
@@ -115,6 +115,7 @@ int parse_sched_scan(struct nl_msg *msg, int *argc, char ***argv)
unsigned int freq, interval = 0, delay = 0;
bool have_matchset = false, have_freqs = false, have_ssids = false;
bool have_active = false, have_passive = false;
+ uint32_t flags = 0;
matchset = nlmsg_alloc();
if (!matchset) {
@@ -208,6 +209,14 @@ int parse_sched_scan(struct nl_msg *msg, int *argc, char ***argv)
}
have_passive = true;
+ } else if (!strncmp(v[0], "randomise", 9) ||
+ !strncmp(v[0], "randomize", 9)) {
+ flags |= NL80211_SCAN_FLAG_RANDOM_ADDR;
+ if (c > 0) {
+ err = parse_random_mac_addr(msg, v[0]);
+ if (err)
+ goto nla_put_failure;
+ }
} else {
/* this element is not for us, so
* return to continue parsing.
@@ -312,6 +321,8 @@ int parse_sched_scan(struct nl_msg *msg, int *argc, char ***argv)
nla_put_nested(msg, NL80211_ATTR_SCAN_FREQUENCIES, freqs);
if (have_matchset)
nla_put_nested(msg, NL80211_ATTR_SCHED_SCAN_MATCH, matchset);
+ if (flags)
+ NLA_PUT_U32(msg, NL80211_ATTR_SCAN_FLAGS, flags);
nla_put_failure:
if (match)
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH iw v2 0/4] iw: add scheduled scan support
2015-03-17 14:11 [PATCH iw v2 0/4] iw: add scheduled scan support Luca Coelho
` (3 preceding siblings ...)
2015-03-17 14:11 ` [PATCH iw v2 4/4] iw: add randomise option for sched_scan Luca Coelho
@ 2015-03-17 15:10 ` Johannes Berg
4 siblings, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2015-03-17 15:10 UTC (permalink / raw)
To: Luca Coelho; +Cc: linux-wireless
On Tue, 2015-03-17 at 16:11 +0200, Luca Coelho wrote:
> From: Luciano Coelho <luciano.coelho@intel.com>
>
> This series adds scheduled scan support to the iw tool (finally! ;).
>
> In v2, just rebased.
Great, thanks; all applied.
johannes
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-03-17 15:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-17 14:11 [PATCH iw v2 0/4] iw: add scheduled scan support Luca Coelho
2015-03-17 14:11 ` [PATCH iw v2 1/4] iw: move generic sched scan parsing code out of net detect Luca Coelho
2015-03-17 14:11 ` [PATCH iw v2 2/4] iw: implement scheduled scan Luca Coelho
2015-03-17 14:11 ` [PATCH iw v2 3/4] iw: add support for active " Luca Coelho
2015-03-17 14:11 ` [PATCH iw v2 4/4] iw: add randomise option for sched_scan Luca Coelho
2015-03-17 15:10 ` [PATCH iw v2 0/4] iw: add scheduled scan support Johannes Berg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.