Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5360802ybe; Tue, 10 Sep 2019 02:27:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxBx/nWl/2c9FBz7v167qnJJxyPnI2//buzetf4Syz3wkl/Mb/CGaLjLTJeyzYVUFsH6SC X-Received: by 2002:a50:f04e:: with SMTP id u14mr29330866edl.247.1568107673585; Tue, 10 Sep 2019 02:27:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568107673; cv=none; d=google.com; s=arc-20160816; b=ya4gfxgtg8LZs93nlfXl6QWUfTX7tpIBbVK2cKxCQNY1ptwdkJJbKZe0HgP1gQ2o0c seW9kUbVhEDODAQtTSz1Wk8CPwLhac7me1aR0nOFmRCkK2lyV5Fth2gy/TaysB446hgb 6PdcycPQg4lOBWa3FtWmW5jfSNV2wt5vBsx78UOZdB33yB9k2u19p5OVA6OWxy0MzzXI ar7AqNCXkA3yqCOSW/dQs4OLXKwxIfA7kDNDOVdc9IutGnXNDxDlziHJr4ozPZhBCF1x FowO3C6I7wTJRwxzNq5zntl3yHsyFXnoqVWimIEpjHl401gHPoTicnYPcnPhtHxg+lJl ztZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=USABQoX//hD5dW5Qiz6XOP4o7RaPj+SYqbl1UnBeoYI=; b=lRUC77Hgm22GWBX+s4X/Gyi2JalJkZpd6wJYmw6tAsbw8LyQf0cDeoOIcz1r6ugSSN JftR+X0tARPGouZ4w/fBaer5rRFLiIA8ZKT2pLI6k0xZkxpXrPJYGKi0QSD+fogM8aci iGm2xLBtbYH6teUBsXjz//hmXQyWPU/or3+IqWglcaSm9lIm0Vqx/hh1NgLQVYbqnLra 0mtGxmLMBljxBIzBfbFvuS2GQV4yXLRIini2/kA4eQfsm6c2UDO/wVB3SCdKZEs8VgTf kxtd6XH5cyu+eR43UJk1/vm6C/pj24nacsCljbK5f17hbm5A+PqFLzWZD7cZNOQ1y7e+ gGRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@candelatech.com header.s=default header.b=jR94SEQi; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=candelatech.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gr19si2851677ejb.371.2019.09.10.02.27.30; Tue, 10 Sep 2019 02:27:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@candelatech.com header.s=default header.b=jR94SEQi; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=candelatech.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387423AbfIIUOG (ORCPT + 99 others); Mon, 9 Sep 2019 16:14:06 -0400 Received: from mail2.candelatech.com ([208.74.158.173]:52486 "EHLO mail3.candelatech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731972AbfIIUOG (ORCPT ); Mon, 9 Sep 2019 16:14:06 -0400 Received: from v-f24-64.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id 3AA96104B; Mon, 9 Sep 2019 13:14:05 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 3AA96104B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1568060045; bh=w6y9HuM2L42xLMAW9g5SiLkogh8H80Jjpx9kY/hroqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jR94SEQiDlMDA6n4xJVBFuxK1ph3e48gRJNL1pK18r9E1Jk1OxR4HiNRvNQz6shrP tKTbNO2Vy9eiFsOOMFpxXKpik5Vjb3852mNgnY/2U5J/miQN2ZfEj1dMMYSarZtSr5 l8xHk3iGuQx/aPPrFUCGGiNppfSw7AC2OHvKnMZo= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ben Greear Subject: [PATCH-v2 2/2] iw: Print current time in station info dump Date: Mon, 9 Sep 2019 13:13:57 -0700 Message-Id: <1568060037-7481-2-git-send-email-greearb@candelatech.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1568060037-7481-1-git-send-email-greearb@candelatech.com> References: <1568060037-7481-1-git-send-email-greearb@candelatech.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear This lets us more precisely calculate the absolute timestamp of last-rix (ie, now - idle). Signed-off-by: Ben Greear --- station.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/station.c b/station.c index 61a317d..1be3974 100644 --- a/station.c +++ b/station.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "nl80211.h" #include "iw.h" @@ -326,6 +327,12 @@ static int print_sta_handler(struct nl_msg *msg, void *arg) [NL80211_STA_INFO_ACK_SIGNAL_AVG] = { .type = NLA_U8 }, }; char *chain; + struct timeval now; + unsigned long long now_ms; + + gettimeofday(&now, NULL); + now_ms = now.tv_sec * 1000; + now_ms += (now.tv_usec / 1000); nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), NULL); @@ -571,12 +578,22 @@ static int print_sta_handler(struct nl_msg *msg, void *arg) nla_get_u32(sinfo[NL80211_STA_INFO_CONNECTED_TIME])); if (sinfo[NL80211_STA_INFO_ASSOC_AT_BOOTTIME]) { unsigned long long bt; + struct timespec now_ts; + unsigned long long boot_ns; + unsigned long long assoc_at_ms; + + clock_gettime(CLOCK_BOOTTIME, &now_ts); + boot_ns = now_ts.tv_sec * 1000000000; + boot_ns += now_ts.tv_nsec; + bt = (unsigned long long)nla_get_u64(sinfo[NL80211_STA_INFO_ASSOC_AT_BOOTTIME]); - printf("\n\tassociated at:\t%llu.%.3llus [boottime]", + printf("\n\tassociated at [boottime]:\t%llu.%.3llus", bt/1000000000, (bt%1000000000)/1000000); + assoc_at_ms = now_ms - ((boot_ns - bt) / 1000000); + printf("\n\tassociated at:\t%llu ms", assoc_at_ms); } - printf("\n"); + printf("\n\tcurrent time:\t%llu ms\n", now_ms); return NL_SKIP; } -- 2.7.5