[OpenWrt-Devel] [PATCH v2] iwinfo: Add support for 802.11ad

Robert Marko robimarko at gmail.com
Wed Mar 13 14:19:19 EDT 2019


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.

Changes from v1:
Use strcmp to compare strings.

Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 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..13c69e3 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 ( strcmp(band, "ad") == 0)
+	{
+		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;
-- 
2.20.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list