From patchwork Sun Dec 6 01:11:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1411656 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=AYfWbQuD; 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=FwxWCpoT; 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 4CpT5h1r97z9sW8 for ; Sun, 6 Dec 2020 12:15:36 +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=kTUaqjKdvke96WE7ViOf6FaAVao5uUayoFq9N8Qieo0=; b=AYfWbQuDOp9CnaqrDTUIb95bx Ayfz9B2INEHUoV4qwJxX+pYVpni6fZBhbYnr2q43Nq6HeWCWUqTQpOjiHAxK9N0X+z71YVZZDzOT6 VUBYxCRxVQ2wn13+WdcM9/iBY0x8YO/gKX+KSfYR7keqSs3KVXWFFLHpE3hhphYW43PsqKGEfgCaj Sv4jZ9L3S0dX58RQgtmUOaloZRKs16KXxIq6MZgQcKCJTc3S1rRl0Zo8f031En62ogytPURsffSlL z/QiAfzdsj4pzCzKirNqyEetZ4AjPPIIY3hdxhQCUurWDYpcaxNHdhePk/FpeR0EF6KPSMUw/mm4J ILzndiiYA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1klicD-0006PQ-0U; Sun, 06 Dec 2020 01:13:29 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1klic3-0006MR-4O for openwrt-devel@lists.openwrt.org; Sun, 06 Dec 2020 01:13:20 +0000 Received: by mail-wm1-x341.google.com with SMTP id x22so8440923wmc.5 for ; Sat, 05 Dec 2020 17:13:17 -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=TSG8lT1y3YbOqorrhNljGcq1X4pYFYQSMagql05GyUQ=; b=FwxWCpoT6HFzahEh9pSGblu1aVkXGn0ot3o5utT7uhX+5Rc9RmlVKTiF3W3X0qIjFi EFYoy/IUlbEvxSWFKuLxZiwc9ls4d4OwvSfxeP+hpnxdGPOd/sEc8O0pl3T0PvGaSgA0 aMqbnmgftdTghuIA79A56tHkkaX5yjt7FTy2FLxTyzaU/Im/HX+O4839Qba4NuGxw4tY koeEK4uT93JdvREQF9UEae93nDVD+84xOAokdG2Rn62/rXGRgxs7Wgswc9DMEH0uNk0z H6VXO9UqyROw73E8Wd9mATU/loxNB3i9bLXBmZkFcc18dZI06NYkg25gcPzpfJ6LwHdy l5HQ== 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=TSG8lT1y3YbOqorrhNljGcq1X4pYFYQSMagql05GyUQ=; b=GD7EtAZEI9bhbcprrLlxUJHZ1Tt5wEMzTLLS7pFm6KnsXx8XwmM72ZhEHsxikCfZ+6 cBgcsUQ8ioHEHi1QP2m5nI4s8RuOrWxzdChjc98q+3gXLS2ichjYEatA4DhAEryhWw+5 hFE0ENEoCAEKTkSH3U2T6bjPLUj5m1tB6M8y2V/UK1PE+CdOHBG7CUHT8GJs+O1aNq5q A4E6C4eFgyzRdf2a7ga5EuVZqCL437l2Lh0gy4Oc+ns2/gXCUxVydi6yhNaf7iIqI7/C 1+E10tuJsF4YkBWYf4Pszab6oe1yikWHJZ7Mk5sj8ZT9eno+zd9bCmCX0OiYPLkDL8tf Xh4g== X-Gm-Message-State: AOAM531AOgJ76/msEcV/yXPIJb9iXfvCfmcU6X6lFfhiORWwDaWOTfXJ d5Xcxt+DlVk4UFDEM+LVx3w8CEKFyxI= X-Google-Smtp-Source: ABdhPJwDvKvlum9dyBWDIjATArS+AyNOqg8zSud6DvDQk4eNWdUGSTlgGMk8Zu/WCze1jou4LQSusw== X-Received: by 2002:a1c:4907:: with SMTP id w7mr3601692wma.175.1607217196015; Sat, 05 Dec 2020 17:13:16 -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 b73sm7328415wmb.0.2020.12.05.17.13.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 17:13:15 -0800 (PST) From: Ansuel Smith To: openwrt-devel@lists.openwrt.org Subject: [IWINFO PATCH v3 1/4] iwinfo: export ht and vht operation in scan results Date: Sun, 6 Dec 2020 02:11:15 +0100 Message-Id: <20201206011118.20601-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201206011118.20601-1-ansuelsmth@gmail.com> References: <20201206011118.20601-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_201319_272856_763DF537 X-CRM114-Status: GOOD ( 16.01 ) 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:341 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(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(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;