From patchwork Wed Mar 13 13:39:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Marko X-Patchwork-Id: 1056048 X-Patchwork-Delegate: hauke@hauke-m.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.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; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hmFwIkXT"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="qtr04goN"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44KCdX2YVMz9s70 for ; Thu, 14 Mar 2019 00:40:16 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=z022fNa0ds/NdDLeGu0sUF6cA5OmU6ve2KdgQ4WH+cg=; b=hmFwIkXTyClzYN 8LNYh9QTtjPr+HjoArEwe2M1W5d9NVhyoEbRZ/z5n/gLMadSFAV1uOXGIJzgOtPX7PHjiJb7d/Es9 XYDOqxJOeuftpu4f8rn3w+Z+aX4L15rOiOuU2kbW4NiQnySRv5jN7q3gEvIz+ZwBLsPHi0weU6Ubh I3UAfcwwBfwOxwaJAat59xaz0s4CISbK97yHY/E1RVCvzzzSZxBd6z/0F4RQObEr4d1m8UaA0vo9s ef7/rG9wugAB4FYCI5pZRdtOgex8Ul6dqRcRd9DdpvlSAXMaxzRjqZZ9B9app9iZms/fo99FLM915 FiBp4mdWSxk77RcOjEyw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h4473-00010M-Dr; Wed, 13 Mar 2019 13:40:05 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h4470-0000Nf-Kg for openwrt-devel@lists.openwrt.org; Wed, 13 Mar 2019 13:40:04 +0000 Received: by mail-wr1-x444.google.com with SMTP id g12so2059793wrm.5 for ; Wed, 13 Mar 2019 06:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ffGDaEBZGDjMJPGBn1sMEjgCvNeaRICIjJuJIhfu8P8=; b=qtr04goN776ULhQ71ulwrBGs5NLKD1ESAAZehIZkAEsCtcrLJA2KN2y9UBwcz+Srs6 ljx1bur0l/WwbiSL7fvtfX47Beug6qHfn4icpp2DuOBDrRkLe9XSQhrY6ctAl3WY/42u 2rNHffWypBZhRs2jP13xrH1MtR8dS3lxVgL6053luVglVTmCFpL2qRY/vgI5GCR2sa8E UCGY5ERp3ZkOfapjNDJMxnvLihLcrblv6D41x/rWpyweSpie6Yibny6MuvKM7eq1MA08 s8/Qh8/QaCYGkOwjmkHprdC76Hgtgc//dvKff1jpZGdbKs4iRoSct1hWhXC9b7sB66J9 FUgA== 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:mime-version :content-transfer-encoding; bh=ffGDaEBZGDjMJPGBn1sMEjgCvNeaRICIjJuJIhfu8P8=; b=Zstg/0bIsooayPDQ6cMl3w5B9I4VPPAZj9jyhEKZJC3PK3O5qv9lP1XDv9cLU+F5px XbCeK3IKhMhmFHhIDMqCOcxSZYj9egJgIm8huqCwANKz2Eutm8oNcADOk9CkvAkV63QA pUs4c6KnkXKs+3uld/SHyycY9tIWnQIR/emEoXUbbGASby5UOs4MVEX5ey7dRQOJHS5P HNanEncm7VjHLbHAekWBiNEQxyNsJ9+WmKVjFIf4r3hrJdDFWW4WejPK+fwYSqdVt2cm nQQrfwFm3Ljtb7fpKYL2+ibqPtwpCPqAouBSc2dxcnT5HX4XAGaMxG55Jqwjmsg85Wr8 vVuA== X-Gm-Message-State: APjAAAVdOMtvZNFVZw9cFGwVxnud9nGMdfbxG6JDC0riusL0r20XPwKR ffF2C55FSWN0cTwjTflK23oWbc6e X-Google-Smtp-Source: APXvYqw4DSGFyJvvhdHY79pksj9w/sxBsLp6w8sfi2p/f1sCrDTcHUNLARTrK1bB0PeSD4DnO3jBlw== X-Received: by 2002:adf:fd46:: with SMTP id h6mr27245135wrs.170.1552484400458; Wed, 13 Mar 2019 06:40:00 -0700 (PDT) Received: from localhost.localdomain (93-143-239-132.adsl.net.t-com.hr. [93.143.239.132]) by smtp.gmail.com with ESMTPSA id u17sm37167806wrg.71.2019.03.13.06.39.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Mar 2019 06:39:59 -0700 (PDT) From: Robert Marko To: openwrt-devel@lists.openwrt.org Date: Wed, 13 Mar 2019 14:39:54 +0100 Message-Id: <20190313133954.18504-1-robimarko@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190313_064002_687504_7DA7B1E7 X-CRM114-Status: GOOD ( 12.31 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.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:444 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (robimarko[at]gmail.com) -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 Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain Subject: [OpenWrt-Devel] [PATCH] iwinfo: Add support for 802.11ad X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Robert Marko Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This patch adds support for identifying, calculating channels from frequency and vice versa as well as Lua hwmode for 802.11ad. Support has been added for channels 1-6. Signed-off-by: Robert Marko --- include/iwinfo.h | 2 ++ iwinfo_cli.c | 5 +++-- iwinfo_lua.c | 3 +++ iwinfo_nl80211.c | 10 ++++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/iwinfo.h b/include/iwinfo.h index 02ad623..9b2ffd1 100644 --- a/include/iwinfo.h +++ b/include/iwinfo.h @@ -28,6 +28,7 @@ #define IWINFO_80211_G (1 << 2) #define IWINFO_80211_N (1 << 3) #define IWINFO_80211_AC (1 << 4) +#define IWINFO_80211_AD (1 << 5) #define IWINFO_CIPHER_NONE (1 << 0) #define IWINFO_CIPHER_WEP40 (1 << 1) @@ -54,6 +55,7 @@ #define IWINFO_FREQ_NO_HT40MINUS (1 << 3) #define IWINFO_FREQ_NO_80MHZ (1 << 4) #define IWINFO_FREQ_NO_160MHZ (1 << 5) +#define IWINFO_FREQ_NO_2160MHZ (1 << 6) extern const char *IWINFO_CIPHER_NAMES[IWINFO_CIPHER_COUNT]; extern const char *IWINFO_KMGMT_NAMES[IWINFO_KMGMT_COUNT]; diff --git a/iwinfo_cli.c b/iwinfo_cli.c index 49c9035..6f6c7d1 100644 --- a/iwinfo_cli.c +++ b/iwinfo_cli.c @@ -268,12 +268,13 @@ static char * format_hwmodes(int modes) if (modes <= 0) snprintf(buf, sizeof(buf), "unknown"); else - snprintf(buf, sizeof(buf), "802.11%s%s%s%s%s", + snprintf(buf, sizeof(buf), "802.11%s%s%s%s%s%s", (modes & IWINFO_80211_A) ? "a" : "", (modes & IWINFO_80211_B) ? "b" : "", (modes & IWINFO_80211_G) ? "g" : "", (modes & IWINFO_80211_N) ? "n" : "", - (modes & IWINFO_80211_AC) ? "ac" : ""); + (modes & IWINFO_80211_AC) ? "ac" : "", + (modes & IWINFO_80211_AD) ? "ad" : ""); return buf; } diff --git a/iwinfo_lua.c b/iwinfo_lua.c index eebab8e..bb43438 100644 --- a/iwinfo_lua.c +++ b/iwinfo_lua.c @@ -518,6 +518,9 @@ static int iwinfo_L_hwmodelist(lua_State *L, int (*func)(const char *, int *)) lua_pushboolean(L, hwmodes & IWINFO_80211_AC); lua_setfield(L, -2, "ac"); + lua_pushboolean(L, hwmodes & IWINFO_80211_AD); + lua_setfield(L, -2, "ad"); + return 1; } diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c index 5154230..ab96f8f 100644 --- a/iwinfo_nl80211.c +++ b/iwinfo_nl80211.c @@ -568,6 +568,8 @@ static int nl80211_freq2channel(int freq) return (freq - 2407) / 5; else if (freq >= 4910 && freq <= 4980) return (freq - 4000) / 5; + else if(freq >= 56160 + 2160 * 1 && freq <= 56160 + 2160 * 6) + return (freq - 56160) / 2160; else return (freq - 5000) / 5; } @@ -581,6 +583,10 @@ static int nl80211_channel2freq(int channel, const char *band) else if (channel < 14) return (channel * 5) + 2407; } + else if ( band = "ad") + { + return 56160 + 2160 * channel; + } else { if (channel >= 182 && channel <= 196) @@ -2800,6 +2806,10 @@ static int nl80211_get_modelist_cb(struct nl_msg *msg, void *arg) } } } + else if (nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]) >= 56160) + { + m->hw |= IWINFO_80211_AD; + } else if (!(m->hw & IWINFO_80211_AC)) { m->hw |= IWINFO_80211_A;