From patchwork Wed Jul 26 00:01:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ningyuan Wang X-Patchwork-Id: 9864045 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 A66DC60380 for ; Wed, 26 Jul 2017 00:02:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 971BF28713 for ; Wed, 26 Jul 2017 00:02:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C14728725; Wed, 26 Jul 2017 00:02: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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI 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 363E528713 for ; Wed, 26 Jul 2017 00:02:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751777AbdGZACi (ORCPT ); Tue, 25 Jul 2017 20:02:38 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:35700 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751655AbdGZACi (ORCPT ); Tue, 25 Jul 2017 20:02:38 -0400 Received: by mail-pf0-f169.google.com with SMTP id h29so29043246pfd.2 for ; Tue, 25 Jul 2017 17:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PZwJtzD3X4Hvzd1umyE9b1MQkZXKqxCHtscAp9FN8xY=; b=r9z+3gSctnKu15Jm9B98ZczvVvOFoCpEuhNoOpdYUDTisNV8D8BV/yE95ePw5ITGOq 0GUcI65rPG6AU7fmIoMvKzGXZmTzJTBVgnrz+8Dj5k699YCB/rLwMrT+g7B33jI4f0te KQNdI83ZLeVGH+ZyDte7XydPZ7xp/c9srmlrEXNDsQ0zWz0Xr9Ja8Kdv3ZjgCv1LAVap V90xEsKdWjflX3vq4uEMTNaXQ4n39BbynMUpa0zDYMO4TBkqp42dW/PVUWrGuUaQZOnM oLvJIyd7lNNbxHpan7xZFbOxgcNKJEpmtNBvRSvL16Rca8gpuMmMhN7csfcH3QW220OU DJZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PZwJtzD3X4Hvzd1umyE9b1MQkZXKqxCHtscAp9FN8xY=; b=m+hetDxcdzJPN6mK3w6ceBaXTqCm+KSdQ+M4CyDs10yG0+VtxNXVZeW7haiWd9QxG/ M4DNjlMLZIJk8CkVSX1YyK18ueGdTThnlIEus7k2YXmL+xPo+xbVssGBqdF5UslBUgJn 76Jb3er5WddpiC8aqSlKt03dyrDKakeGfwN/qPbuyncZpYgAHrxMBbGGgrUMwO3yeanU tWU80TtTNRi09coAEA905Qnwh1Kcu8PxxNuiSxTo2UxKm2SXU3p6Q5LS9VakvMnzcfC+ h6VqH06XkjGd48vNfgyQrb4flaUZmnOqLzAOnRFMOAbkBL8/p4yKA2i3kzLnB/vFG6vq unMQ== X-Gm-Message-State: AIVw111JNWE2jFj3IxV/mctFMoL2jPguYPlGiBKWu7hTwTd5EkwnbrWM 2LrupOBhdVcQoIWS X-Received: by 10.98.80.89 with SMTP id e86mr20845188pfb.195.1501027357534; Tue, 25 Jul 2017 17:02:37 -0700 (PDT) Received: from nywang2.mtv.corp.google.com ([172.22.120.61]) by smtp.gmail.com with ESMTPSA id e79sm22931649pfl.40.2017.07.25.17.02.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 17:02:36 -0700 (PDT) From: Ningyuan Wang To: johannes@sipsolutions.net Cc: Ningyuan Wang , linux-wireless@vger.kernel.org Subject: [PATCH] Print NL80211_BSS_LAST_SEEN_BOOTTIME and beacon tsf Date: Tue, 25 Jul 2017 17:01:18 -0700 Message-Id: <20170726000118.77660-1-nywang@google.com> X-Mailer: git-send-email 2.14.0.rc0.400.g1c36432dff-goog In-Reply-To: <20170711004746.142837-1-nywang@google.com> References: <20170711004746.142837-1-nywang@google.com> 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 allows iw to print NL80211_BSS_LAST_SEEN_BOOTTIME values on scan results. Signed-off-by: Ningyuan Wang --- nl80211.h | 4 ++++ scan.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/nl80211.h b/nl80211.h index 241220c..5ea103c 100644 --- a/nl80211.h +++ b/nl80211.h @@ -3360,6 +3360,9 @@ enum nl80211_bss_scan_width { * (not present if no beacon frame has been received yet) * @NL80211_BSS_PRESP_DATA: the data in @NL80211_BSS_INFORMATION_ELEMENTS and * @NL80211_BSS_TSF is known to be from a probe response (flag attribute) + * @NL80211_BSS_LAST_SEEN_BOOTTIME: CLOCK_BOOTTIME timestamp when this entry + * was last updated by a received frame. The value is expected to be + * accurate to about 10ms. (u64, nanoseconds) * @__NL80211_BSS_AFTER_LAST: internal * @NL80211_BSS_MAX: highest BSS attribute */ @@ -3379,6 +3382,7 @@ enum nl80211_bss { NL80211_BSS_CHAN_WIDTH, NL80211_BSS_BEACON_TSF, NL80211_BSS_PRESP_DATA, + NL80211_BSS_LAST_SEEN_BOOTTIME, /* keep last */ __NL80211_BSS_AFTER_LAST, diff --git a/scan.c b/scan.c index bf39f34..6646732 100644 --- a/scan.c +++ b/scan.c @@ -1853,6 +1853,8 @@ static int print_bss_handler(struct nl_msg *msg, void *arg) char mac_addr[20], dev[20]; static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = { [NL80211_BSS_TSF] = { .type = NLA_U64 }, + [NL80211_BSS_BEACON_TSF] = { .type = NLA_U64 }, + [NL80211_BSS_LAST_SEEN_BOOTTIME] = { .type = NLA_U64 }, [NL80211_BSS_FREQUENCY] = { .type = NLA_U32 }, [NL80211_BSS_BSSID] = { }, [NL80211_BSS_BEACON_INTERVAL] = { .type = NLA_U16 }, @@ -1918,6 +1920,23 @@ static int print_bss_handler(struct nl_msg *msg, void *arg) tsf, tsf/1000/1000/60/60/24, (tsf/1000/1000/60/60) % 24, (tsf/1000/1000/60) % 60, (tsf/1000/1000) % 60); } + if (bss[NL80211_BSS_BEACON_TSF]) { + unsigned long long tsf; + tsf = (unsigned long long)nla_get_u64(bss[NL80211_BSS_BEACON_TSF]); + printf("\tBeacon TSF: %llu usec (%llud, %.2lld:%.2llu:%.2llu)\n", + tsf, tsf/1000/1000/60/60/24, (tsf/1000/1000/60/60) % 24, + (tsf/1000/1000/60) % 60, (tsf/1000/1000) % 60); + } + if (bss[NL80211_BSS_LAST_SEEN_BOOTTIME]) { + unsigned long long last_seen_since_boot; + last_seen_since_boot = + (unsigned long long)nla_get_u64(bss[NL80211_BSS_LAST_SEEN_BOOTTIME]); + printf("\tlast seen since boot time: %llu usec (%llud, %.2lld:%.2llu:%.2llu)\n", + last_seen_since_boot, last_seen_since_boot /1000/1000/1000/60/60/24, + (last_seen_since_boot /1000/1000/1000/60/60) % 24, + (last_seen_since_boot/1000/1000/1000/60) % 60, + (last_seen_since_boot/1000/1000/1000) % 60); + } if (bss[NL80211_BSS_FREQUENCY]) { int freq = nla_get_u32(bss[NL80211_BSS_FREQUENCY]); printf("\tfreq: %d\n", freq);