From: Robert Marko Date: Wed, 13 Mar 2019 18:19:19 +0000 (+0100) Subject: iwinfo: Add support for 802.11ad X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a8e827592338d7f10d93b4b93d04f367221465c2;p=oweals%2Fiwinfo.git iwinfo: Add support for 802.11ad 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 [Increase buffer size for hwmodes] Signed-off-by: Hauke Mehrtens --- 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..dba7529 100644 --- a/iwinfo_cli.c +++ b/iwinfo_cli.c @@ -263,17 +263,18 @@ static char * format_encryption(struct iwinfo_crypto_entry *c) static char * format_hwmodes(int modes) { - static char buf[12]; + static char buf[15]; 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;