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 <robimarko@gmail.com>
[Increase buffer size for hwmodes]
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
Robert Marko 2019-03-13 19:19:19 +01:00 committed by Hauke Mehrtens
parent ce1814baec
commit a8e8275923
4 changed files with 19 additions and 3 deletions

View 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];

View 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;
}

View 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;
}

View 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;