From patchwork Tue May 8 17:20:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pradeep Kumar Chitrapu X-Patchwork-Id: 10386585 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1CF45602C2 for ; Tue, 8 May 2018 17:20:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A227290B1 for ; Tue, 8 May 2018 17:20:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F363D290B9; Tue, 8 May 2018 17:20:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68571290B1 for ; Tue, 8 May 2018 17:20:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932234AbeEHRUj (ORCPT ); Tue, 8 May 2018 13:20:39 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:46188 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932204AbeEHRUi (ORCPT ); Tue, 8 May 2018 13:20:38 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 30A8660D81; Tue, 8 May 2018 17:20:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525800038; bh=QgBIm9FDREGpdk4gskh8XvaLD2v5mrj2mxlNeBq1Poc=; h=From:To:Cc:Subject:Date:From; b=HCB/uuE6bWxUROFs5rf+b7eLPh20qzZCv7WgBxoWaqrOw8CRvcxUtn+lO2K/KCDCy JyEYZQx9k9jdo2lbE3ZhEoCkZRAgWYe5NHAHflPuoZC5ViJ+2rXqtP50t2OcZavS5Y GElM8kURjDV2qY7wQP4Nyo/Z/fudDzHgz5MqT1Ig= Received: from pradeepc-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pradeepc@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7F83C60FA9; Tue, 8 May 2018 17:20:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525800035; bh=QgBIm9FDREGpdk4gskh8XvaLD2v5mrj2mxlNeBq1Poc=; h=From:To:Cc:Subject:Date:From; b=HPPTGaxNId96pmiJfgfIBWCaOFHPUarRcdEFz32D861V5upCfLBQ5H1PCzxeTho0+ PhfTa2ZE/WZ3imMeeQ6uy3H6CQtebDEbhT7hqgDAvULIhjfkyBXrsY9/4XgCyr3v8a NAc8gmJZDzPiF9iWUK96pz9cY8ULFIpN5EZX2+pU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7F83C60FA9 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=pradeepc@codeaurora.org From: Pradeep Kumar Chitrapu To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Pradeep Kumar Chitrapu Subject: [PATCH] iw: Add duration parameter to scan command Date: Tue, 8 May 2018 10:20:30 -0700 Message-Id: <1525800030-19322-1-git-send-email-pradeepc@codeaurora.org> X-Mailer: git-send-email 1.9.1 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 This patch lets user to specify duration(TUs) and set duration-mandatory flag in scan command. Signed-off-by: Pradeep Kumar Chitrapu --- scan.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/scan.c b/scan.c index 74ccc06..3e9daef 100644 --- a/scan.c +++ b/scan.c @@ -411,10 +411,13 @@ static int handle_scan(struct nl80211_state *state, IES, SSID, MESHID, + DURATION, DONE, } parse = NONE; int freq; + unsigned int duration = 0; bool passive = false, have_ssids = false, have_freqs = false; + bool duration_mandatory = false; size_t ies_len = 0, meshid_len = 0; unsigned char *ies = NULL, *meshid = NULL, *tmpies; unsigned int flags = 0; @@ -448,6 +451,9 @@ static int handle_scan(struct nl80211_state *state, } else if (strcmp(argv[i], "ap-force") == 0) { flags |= NL80211_SCAN_FLAG_AP; break; + } else if (strcmp(argv[i], "duration-mandatory") == 0) { + duration_mandatory = true; + break; } else if (strncmp(argv[i], "randomise", 9) == 0 || strncmp(argv[i], "randomize", 9) == 0) { flags |= NL80211_SCAN_FLAG_RANDOM_ADDR; @@ -466,6 +472,9 @@ static int handle_scan(struct nl80211_state *state, } else if (strcmp(argv[i], "meshid") == 0) { parse = MESHID; break; + } else if (strcmp(argv[i], "duration") == 0) { + parse = DURATION; + break; } case DONE: nlmsg_free(ssids); @@ -501,6 +510,10 @@ static int handle_scan(struct nl80211_state *state, meshid_len += 2; parse = NONE; break; + case DURATION: + duration = strtoul(argv[i], &eptr, 10); + parse = NONE; + break; } } @@ -535,6 +548,17 @@ static int handle_scan(struct nl80211_state *state, nla_put_nested(msg, NL80211_ATTR_SCAN_FREQUENCIES, freqs); if (flags) NLA_PUT_U32(msg, NL80211_ATTR_SCAN_FLAGS, flags); + if (duration) + NLA_PUT_U16(msg, NL80211_ATTR_MEASUREMENT_DURATION, duration); + if (duration_mandatory) { + if (duration) { + NLA_PUT_FLAG(msg, + NL80211_ATTR_MEASUREMENT_DURATION_MANDATORY); + } else { + err = -EINVAL; + goto nla_put_failure; + } + } err = 0; nla_put_failure: @@ -2275,7 +2299,7 @@ static int handle_scan_combined(struct nl80211_state *state, dump_argv[0] = argv[0]; return handle_cmd(state, id, dump_argc, dump_argv); } -TOPLEVEL(scan, "[-u] [freq *] [ies ] [meshid ] [lowpri,flush,ap-force] [randomise[=/]] [ssid *|passive]", 0, 0, +TOPLEVEL(scan, "[-u] [freq *] [duration ] [ies ] [meshid ] [lowpri,flush,ap-force,duration-mandatory] [randomise[=/]] [ssid *|passive]", 0, 0, CIB_NETDEV, handle_scan_combined, "Scan on the given frequencies and probe for the given SSIDs\n" "(or wildcard if not given) unless passive scanning is requested.\n" @@ -2285,10 +2309,11 @@ COMMAND(scan, dump, "[-u]", NL80211_CMD_GET_SCAN, NLM_F_DUMP, CIB_NETDEV, handle_scan_dump, "Dump the current scan results. If -u is specified, print unknown\n" "data in scan results."); -COMMAND(scan, trigger, "[freq *] [ies ] [meshid ] [lowpri,flush,ap-force] [randomise[=/]] [ssid *|passive]", +COMMAND(scan, trigger, "[freq *] [duration ] [ies ] [meshid ] [lowpri,flush,ap-force,duration-mandatory] [randomise[=/]] [ssid *|passive]", 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."); + "SSIDs (or wildcard if not given) unless passive scanning is requested.\n" + "Duration(in TUs), if specified, will be used to set dwell times.\n"); static int handle_scan_abort(struct nl80211_state *state,