From patchwork Fri Mar 13 12:17:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Coelho X-Patchwork-Id: 6004881 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 4A44F9F54F for ; Fri, 13 Mar 2015 12:17:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6475420251 for ; Fri, 13 Mar 2015 12:17:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 76C0820225 for ; Fri, 13 Mar 2015 12:17:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752869AbbCMMRZ (ORCPT ); Fri, 13 Mar 2015 08:17:25 -0400 Received: from dedo.coelho.fi ([88.198.205.34]:41326 "EHLO dedo.coelho.fi" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751694AbbCMMRV (ORCPT ); Fri, 13 Mar 2015 08:17:21 -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 1YWOWl-0005A3-KU; Fri, 13 Mar 2015 14:17:20 +0200 From: Luca Coelho To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org Date: Fri, 13 Mar 2015 14:17:07 +0200 Message-Id: <1426249027-22165-3-git-send-email-luca@coelho.fi> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1426249027-22165-1-git-send-email-luca@coelho.fi> References: <1426249027-22165-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 2/2] iw: add a delay option to net-detect 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 Add an option that allows the initial net-detect scan to be delayed by the specified number of seconds. Signed-off-by: Luciano Coelho --- wowlan.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/wowlan.c b/wowlan.c index fb7d956..12abc76 100644 --- a/wowlan.c +++ b/wowlan.c @@ -193,7 +193,7 @@ static int wowlan_parse_net_detect(struct nl_msg *msg, int *argc, char ***argv) int c = *argc; char *end, **v = *argv; int err = 0, i = 0; - unsigned int freq, interval = 0; + unsigned int freq, interval = 0, delay = 0; bool have_matchset = false, have_freqs = false; nd = nla_nest_start(msg, NL80211_WOWLAN_TRIG_NET_DETECT); @@ -236,6 +236,25 @@ static int wowlan_parse_net_detect(struct nl_msg *msg, int *argc, char ***argv) 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) { @@ -454,7 +473,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 [freqs +] [matches [ssid ]+]]" + " [4way-handshake] [rfkill-release] [net-detect interval [delay [freqs +] [matches [ssid ]+]]" " [tcp ] [patterns [offset1+] ...]", NL80211_CMD_SET_WOWLAN, 0, CIB_PHY, handle_wowlan_enable, "Enable WoWLAN with the given triggers.\n" @@ -472,7 +491,7 @@ COMMAND(wowlan, enable, "[any] [disconnect] [magic-packet] [gtk-rekey-failure] [ " [data.seq=len,offset[,start]]\n" " [data.tok=len,offset,]\n\n" "Net-detect configuration example:\n" - " iw phy0 wowlan enable net-detect interval 5000 freqs 2412 2422 matches ssid foo ssid bar"); + " iw phy0 wowlan enable net-detect interval 5000 delay 30 freqs 2412 2422 matches ssid foo ssid bar"); static int handle_wowlan_disable(struct nl80211_state *state, struct nl_cb *cb, @@ -534,9 +553,13 @@ static int print_wowlan_handler(struct nl_msg *msg, void *arg) nla_len(trig[NL80211_WOWLAN_TRIG_NET_DETECT]), NULL); if (nd[NL80211_ATTR_SCHED_SCAN_INTERVAL]) - printf("\tscan interval: %d msecs\n", + printf("\tscan interval: %u msecs\n", nla_get_u32(nd[NL80211_ATTR_SCHED_SCAN_INTERVAL])); + if (nd[NL80211_ATTR_SCHED_SCAN_DELAY]) + printf("\tintial scan delay: %u secs\n", + nla_get_u32(nd[NL80211_ATTR_SCHED_SCAN_DELAY])); + if (nd[NL80211_ATTR_SCHED_SCAN_MATCH]) { printf("\tmatches:\n"); nla_for_each_nested(match,