From patchwork Sun Dec 6 01:18:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1411666 X-Patchwork-Delegate: ansuelsmth@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=eeAFfGRY; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=hTmE4/Ls; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CpTCz4XlVz9sW1 for ; Sun, 6 Dec 2020 12:21:03 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+1efVk5p5BzWTjg8/4NLQ8u9q4J/NteJOCh943XDSug=; b=eeAFfGRYyXxRbDnh4oI4kLCDy j+ehd78xed+MbMXNGUOaJGJ8zgfg+/kFOfb9/otnWenQmJKsvrsNadzs+cg3wZwcgHQI9mCdoLEYM Mq85OKil0SlWznLP2LBBYQmLz3BsHctXHMmuwjq+qR6NSmRDJxNs74/hzdg9+sKGmvlWEYPHBasJp 6QbOGpy7CHd0LeiwK1++Vq1ixUcQ/HABJsclgLk6nuZJT0uBxcZHoyeNaXIEjT4UCxY3Q/WMXwFRw zb0YgdT48cdIflGi8gKC/L8nAxPoQNIJ1OanLqLlbVzePj0Cu15drdIEvQBqxuAKVW6HbmOnbNXNK qO/G1R/vA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1klihN-0007Io-S1; Sun, 06 Dec 2020 01:18:49 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1klih9-0007G6-N4 for openwrt-devel@lists.openwrt.org; Sun, 06 Dec 2020 01:18:36 +0000 Received: by mail-wm1-x344.google.com with SMTP id a6so8486276wmc.2 for ; Sat, 05 Dec 2020 17:18:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NjzMDLda5sPn50JdlNWYkr5z7VaLoJlf0E0wIkDdi38=; b=hTmE4/Ls/IRZG/eBgAako98dszXofa+N+GnBrdtjDyx8FwrDQMxGkhea11k4U5cm4l 9RPFFLUUoe4hzIGKkLMb0LeAXF0aNdbIoQz0afiGfF2eEPLQEqWUmo/FycfjChna03en HqLOfq5imxupIPcRErP+WmDNLLUOyW3XeaOHae879RcBWz/WHFLnq0bt0JIIvun/hKbu pVjYJMWBMM+/ZiGrVzmaVODQCs4mrKs01EJYzu3N8nEjjc6MfrVe0AiTDMPSTVQR+2LV LNGn5hGbRyyw7IZsZ/ejmdqZhi2OzhlpoOMcn1KhGy42w+eWGHXmW7zqG8BgxK3JK6+x X2eA== 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:mime-version:content-transfer-encoding; bh=NjzMDLda5sPn50JdlNWYkr5z7VaLoJlf0E0wIkDdi38=; b=qojQiIHs7z69Stz+6npnuLmaiE2GC+z6778v5gy9Tl3d2pjYSLsfobTbP9c+mU88I3 p3LtNvMCUqafXOCWubWA+OytA7Gj8wqmKhTL5UXIMA7dpvX5bn9IS5C9RDMgjqZJtMlX vavTi4NW6apsbNxLst2wM/OfMftnnIvoJiHEv3wdY1VqWUefcVfIN+jqhIzwjhs9cGD7 wRIoyRtrNschURimpRhMuEmbMnaG0SXy559MsSK8mMT6q6zyT5RwF9IyQUNC1hG4/31c wtPq/Y4clFPdnM1CkP6ZV0h4qGeoxR7q3fVBCMFUWvWM/hYRQi8m1VP7vZc2v+EUR7Kx 0rHA== X-Gm-Message-State: AOAM530+UFhifWNvwkDqr3fu2S2+qG6PKNvWmvgnN61/wv/697isw/hy OtKYWlbwK/I7ojgTyv2xvwKGBEXte6w= X-Google-Smtp-Source: ABdhPJynTf1ammlW7Gnop8eylRNUK3S5vNgsziPE72FSh0v0pPHsC0NJDB/+vZRjzTdHBIpo9uhEew== X-Received: by 2002:a1c:9e0e:: with SMTP id h14mr11280091wme.63.1607217514044; Sat, 05 Dec 2020 17:18:34 -0800 (PST) Received: from ansuel-xps20.localdomain (host-87-1-248-10.retail.telecomitalia.it. [87.1.248.10]) by smtp.googlemail.com with ESMTPSA id q12sm9143174wrx.86.2020.12.05.17.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 17:18:33 -0800 (PST) From: Ansuel Smith To: openwrt-devel@lists.openwrt.org Subject: [IWINFO PATCH v4 1/4] iwinfo: export ht and vht operation in scan results Date: Sun, 6 Dec 2020 02:18:24 +0100 Message-Id: <20201206011827.20782-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201206011827.20782-1-ansuelsmth@gmail.com> References: <20201206011827.20782-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201205_201835_890115_C35039F7 X-CRM114-Status: GOOD ( 15.71 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:344 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [ansuelsmth[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ansuel Smith Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Export ht and vht operation data in scan results. These additional data can be usefull to check wifi channel utilizzation by neraby stations. Signed-off-by: Ansuel Smith --- include/iwinfo.h | 34 ++++++++++++++++++++++++++++++++++ iwinfo_cli.c | 35 ++++++++++++++++++++++++++++++++++- iwinfo_nl80211.c | 10 ++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) diff --git a/include/iwinfo.h b/include/iwinfo.h index 5e64294..676db91 100644 --- a/include/iwinfo.h +++ b/include/iwinfo.h @@ -170,6 +170,38 @@ struct iwinfo_crypto_entry { uint8_t auth_algs; }; +struct iwinfo_scanlist_ht_chan_entry { + uint8_t primary_chan; + uint8_t secondary_chan_off; + uint8_t chan_width; +}; + +struct iwinfo_scanlist_vht_chan_entry { + uint8_t chan_width; + uint8_t center_chan_1; + uint8_t center_chan_2; +}; + +static const char *ht_secondary_offset[4] = { + "no secondary", + "above", + "[reserved!]", + "below", +}; + + +static uint16_t ht_chan_width[2] = { + 20, /* 20 MHz */ + 2040, /* 40 MHz or higher (refer to vht if supported) */ +}; + +static uint16_t vht_chan_width[] = { + [0] = 40, /* 40 MHz or lower (refer to ht to a more precise width) */ + [1] = 80, /* 80 MHz */ + [3] = 8080, /* 80+80 MHz */ + [2] = 160, /* 160 MHz */ +}; + struct iwinfo_scanlist_entry { uint8_t mac[6]; char ssid[IWINFO_ESSID_MAX_SIZE+1]; @@ -179,6 +211,8 @@ struct iwinfo_scanlist_entry { uint8_t quality; uint8_t quality_max; struct iwinfo_crypto_entry crypto; + struct iwinfo_scanlist_ht_chan_entry ht_chan_info; + struct iwinfo_scanlist_vht_chan_entry vht_chan_info; }; struct iwinfo_country_entry { diff --git a/iwinfo_cli.c b/iwinfo_cli.c index 0332bc2..6bfe0ab 100644 --- a/iwinfo_cli.c +++ b/iwinfo_cli.c @@ -323,6 +323,20 @@ static char * format_assocrate(struct iwinfo_rate_entry *r) return buf; } +static const char* format_chan_width(uint16_t width) +{ + switch (width) { + case 20: return "20 MHz"; + case 2040: return "40 MHz and upper or 20 MHz with intolerant bit"; + case 40: return "40 MHz or lower"; + case 80: return "80 MHz"; + case 8080: return "80+80 MHz"; + case 160: return "160 MHz"; + } + + return "unknown"; +} + static const char * print_type(const struct iwinfo_ops *iw, const char *ifname) { @@ -612,8 +626,27 @@ static void print_scanlist(const struct iwinfo_ops *iw, const char *ifname) format_signal(e->signal - 0x100), format_quality(e->quality), format_quality_max(e->quality_max)); - printf(" Encryption: %s\n\n", + printf(" Encryption: %s\n", format_encryption(&e->crypto)); + printf(" HT Operation:\n"); + printf(" Primary Channel: %d\n", + e->ht_chan_info.primary_chan); + printf(" Secondary Channel Offset: %s\n", + ht_secondary_offset[e->ht_chan_info.secondary_chan_off]); + printf(" Channel Width: %s\n", + format_chan_width(ht_chan_width[e->ht_chan_info.chan_width])); + + if (e->vht_chan_info.center_chan_1) { + printf(" VHT Operation:\n"); + printf(" Channel Width: %s\n", + format_chan_width(vht_chan_width[e->vht_chan_info.chan_width])); + printf(" Center Frequency 1: %d\n", + e->vht_chan_info.center_chan_1); + printf(" Center Frequency 2: %d\n", + e->vht_chan_info.center_chan_2); + } + + printf("\n"); } } diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c index 2b2a043..5917e3a 100644 --- a/iwinfo_nl80211.c +++ b/iwinfo_nl80211.c @@ -2306,6 +2306,16 @@ static void nl80211_get_scanlist_ie(struct nlattr **bss, iwinfo_parse_rsn(&e->crypto, ie + 6, ie[1] - 4, IWINFO_CIPHER_TKIP, IWINFO_KMGMT_PSK); break; + case 61: /* HT oeration */ + e->ht_chan_info.primary_chan = ie[2]; + e->ht_chan_info.secondary_chan_off = ie[3] & 0x3; + e->ht_chan_info.chan_width = (ie[4] & 0x4)>>2; + break; + case 192: /* VHT operation */ + e->vht_chan_info.chan_width = ie[2]; + e->vht_chan_info.center_chan_1 = ie[3]; + e->vht_chan_info.center_chan_2 = ie[4]; + break; } ielen -= ie[1] + 2;