From patchwork Tue Nov 24 01:32:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1405195 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=nCBR25kj; 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=TAEKhxz9; 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 4Cg66012yDz9sT6 for ; Tue, 24 Nov 2020 12:35:20 +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=aySprKGEa9ASTzxqXoPEhhSjBADe6u/AEy7122O70og=; b=nCBR25kjDZ4y/UfSi8TbTksZu u41bDoxhY+sx0ArNRluDt2J5jr6koLlRQ8qyaZ6MgQx4HtOJSpn19n/kJ/87rAFl/FpJAE1wGgYNr WDS2Z/+Evg7t8N0Hka0Rv96HIinvtqGx3gKYbRZzdF+PkAnNFTaJLqxvEeaQs38v4Mx6H9rgxmpg4 NzOUS5uil3mM8DyrEkLRIS1kXKEBTxPxA/0Go8RtnvT6ikz1nDUs3aaCu61vPeOQeoftc8qScN6hz ZX790Cbr90GBpX+qky+gQWZYxpRuMhzodSegNtWOkQAwK8hEjUv4dSHtcp7TGQOP6hgrqlOJ+mkuF XNLcV66mg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1khNCo-0000YG-Oh; Tue, 24 Nov 2020 01:33:19 +0000 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1khNCb-0000U5-5z for openwrt-devel@lists.openwrt.org; Tue, 24 Nov 2020 01:33:06 +0000 Received: by mail-qt1-x843.google.com with SMTP id f27so5458270qtv.6 for ; Mon, 23 Nov 2020 17:33:04 -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=ywMZQPMdK5vNMaesNuWHGc8u2FwPc6189peW93v3eFk=; b=TAEKhxz9kOEWq0YHG6ZdS5MKt6hWmBYklNKqRT80Ycl3q9s3g4Su/yGU+Zyloy4lD2 Wkg89XRKocU0RgInWCjj9xLkudMO6rs9e3/92h77DlSE87lU3gLARxlUnCsD0+0j1J/6 /W+QMSPTbtHVWxNnmPRhewsHuNl8K6c/OPSGgskZaVSQsWd347VzM2L8+iAUiC5/NLQP lJjnlrE0EdwZeW0pNwXYRnOU4RBcdAEJdtbT+htOd4Sw72fP4zCJ+f4Z/RVqQ1ClM1Ja lGlZqkAbp8XT7NC0A6ZUApEXzS9qu/4BMf7OIjyKjd6QpdoFrTk4FUjFT7wq0zwqE0Yp V+Zw== 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=ywMZQPMdK5vNMaesNuWHGc8u2FwPc6189peW93v3eFk=; b=U/o5BtjUxvQrK2pXUFbZA2pBhNTZnvMLf7Ts5qJWhBmUwAApMptrywibfpswgm3RqV MYPQKtHBCjSLIQaiHkNJ0OjVkw2v+TiwITZDLU2M3XSJ1SAxO1cIeaJCN4xvKoNaPkwY 3x4Gz3wZexEcUuVerqFkEt9Viw1SMKisB1nUPycLre0xYvqSgdA6woBQOdla1EfPC28P kYX2eheOuIEXs334+OPoXBRzFMuIu2MKa0ka3ols8iIVvrPHN7fbpENOmAKQvIy/gBhm 31N6YETUg3LXqx9IXh32iIhiPimfRNVoAwaS2ovv21hscudrvAJs2J3HfwlJSCaEqqnX xyDw== X-Gm-Message-State: AOAM530ovUXKf+jPAgARLtaiFBaTQ+45rZ3q2eM+jcliq7mVTac8kM+0 C9F+TBaOrQmLYfgdyVvOQs3wDMgjGL0= X-Google-Smtp-Source: ABdhPJxTXUS9CMxbLTeDG0gUR8EO5e1uKZB4RMqt0TK/kdJEBR+1F1j/uDgtDlpyrheU9X4kr3ex1w== X-Received: by 2002:ac8:6f46:: with SMTP id n6mr2130968qtv.151.1606181583135; Mon, 23 Nov 2020 17:33:03 -0800 (PST) Received: from ansuel-xps20.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id g18sm11025872qtv.79.2020.11.23.17.32.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 17:33:00 -0800 (PST) From: Ansuel Smith To: openwrt-devel@lists.openwrt.org Subject: [IWINFO PATCH v2 1/4] iwinfo: export ht and vht operation in scan results Date: Tue, 24 Nov 2020 02:32:49 +0100 Message-Id: <20201124013252.18323-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201124013252.18323-1-ansuelsmth@gmail.com> References: <20201124013252.18323-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201123_203305_936914_AE0D195E X-CRM114-Status: GOOD ( 15.08 ) 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 [2607:f8b0:4864:20:0:0:0:843 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [ansuelsmth[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 | 21 ++++++++++++++++++++- iwinfo_nl80211.c | 10 ++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/include/iwinfo.h b/include/iwinfo.h index 5e64294..afb738f 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 const char *ht_chan_width[2] = { + "20 MHz", + "any", +}; + +static const char *vht_chan_width[] = { + [0] = "20 or 40 MHz", + [1] = "80 MHz", + [3] = "80+80 MHz", + [2] = "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..5885d06 100644 --- a/iwinfo_cli.c +++ b/iwinfo_cli.c @@ -612,8 +612,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", + 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", + 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;