From patchwork Tue Mar 17 14:11:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Coelho X-Patchwork-Id: 6032091 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 088F4BF90F for ; Tue, 17 Mar 2015 14:12:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0783120412 for ; Tue, 17 Mar 2015 14:12:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7E498203FB for ; Tue, 17 Mar 2015 14:12:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932547AbbCQOMQ (ORCPT ); Tue, 17 Mar 2015 10:12:16 -0400 Received: from dedo.coelho.fi ([88.198.205.34]:44733 "EHLO dedo.coelho.fi" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753924AbbCQOMM (ORCPT ); Tue, 17 Mar 2015 10:12:12 -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 1YXsE5-0004L5-Ev; Tue, 17 Mar 2015 16:12:09 +0200 From: Luca Coelho To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org Date: Tue, 17 Mar 2015 16:11:50 +0200 Message-Id: <1426601510-8251-5-git-send-email-luca@coelho.fi> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1426601510-8251-1-git-send-email-luca@coelho.fi> References: <1426601510-8251-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 v2 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 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 [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)