From patchwork Fri Mar 13 20:27:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Coelho X-Patchwork-Id: 6009081 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1117C9F399 for ; Fri, 13 Mar 2015 20:27:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 39F9320256 for ; Fri, 13 Mar 2015 20:27:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5AC1C20266 for ; Fri, 13 Mar 2015 20:27:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754234AbbCMU1k (ORCPT ); Fri, 13 Mar 2015 16:27:40 -0400 Received: from dedo.coelho.fi ([88.198.205.34]:41883 "EHLO dedo.coelho.fi" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751308AbbCMU1e (ORCPT ); Fri, 13 Mar 2015 16:27:34 -0400 Received: from a88-113-225-236.elisa-laajakaista.fi ([88.113.225.236] helo=dubbel.amr.corp.intel.com) by dedo.coelho.fi with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA256:128) (Exim 4.80) (envelope-from ) id 1YWWBB-0006LU-61; Fri, 13 Mar 2015 22:27:33 +0200 From: Luca Coelho To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org Date: Fri, 13 Mar 2015 22:27:21 +0200 Message-Id: <1426278441-10304-5-git-send-email-luca@coelho.fi> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1426278441-10304-1-git-send-email-luca@coelho.fi> References: <1426278441-10304-1-git-send-email-luca@coelho.fi> X-SA-Exim-Connect-IP: 88.113.225.236 X-SA-Exim-Mail-From: luca@coelho.fi X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Subject: [PATCH iw 4/4] iw: add randomise option for sched_scan X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on dedo.coelho.fi) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Luciano Coelho 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 --- 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 [delay " \ - "[freqs +] [matches [ssid ]+]] [active [ssid ]+|passive] " + "[freqs +] [matches [ssid ]+]] [active [ssid ]+|passive] [randomise[=/]]" 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)