iwinfo: Add support for 802.11ad
authorRobert Marko <robimarko@gmail.com>
Wed, 13 Mar 2019 18:19:19 +0000 (19:19 +0100)
committerHauke Mehrtens <hauke@hauke-m.de>
Thu, 21 Mar 2019 15:28:39 +0000 (16:28 +0100)
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 <robimarko@gmail.com>
[Increase buffer size for hwmodes]
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
include/iwinfo.h
iwinfo_cli.c
iwinfo_lua.c
iwinfo_nl80211.c

index 02ad623ac1d86b5c4eccff63b74b6a97ea667d3e..9b2ffd1ea1116fb63bcf152361abed9c725423c4 100644 (file)
@@ -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];
index 49c9035664c9ceb6657f299d9952520da4ccde1f..dba752999996897569eff49d03b61688e6fd92db 100644 (file)
@@ -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;
 }
index eebab8e8987d2f95ecae8d85d5f494854261875a..bb43438d8dd531b745dd27935e11cb7c9a2073c2 100644 (file)
@@ -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;
        }
 
index 51542307f887ca3783a752bc5b44634a637e99eb..13c69e3112292db0a513590ca1427904e6bca81c 100644 (file)
@@ -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;