From: Luciano Coelho <[email protected]>

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 <[email protected]>
---
 iw.h   |  2 +-
 scan.c | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/iw.h b/iw.h
index d6b51cf..193825f 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

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to