if (ciphers & IWINFO_CIPHER_CCMP)
pos += sprintf(pos, "CCMP, ");
+ if (ciphers & IWINFO_CIPHER_CCMP256)
+ pos += sprintf(pos, "CCMP-256, ");
+
+ if (ciphers & IWINFO_CIPHER_GCMP)
+ pos += sprintf(pos, "GCMP, ");
+
+ if (ciphers & IWINFO_CIPHER_GCMP256)
+ pos += sprintf(pos, "GCMP-256, ");
+
if (ciphers & IWINFO_CIPHER_WRAP)
pos += sprintf(pos, "WRAP, ");
if (suites & IWINFO_KMGMT_8021x)
pos += sprintf(pos, "802.1X/");
+ if (suites & IWINFO_KMGMT_SAE)
+ pos += sprintf(pos, "SAE/");
+
+ if (suites & IWINFO_KMGMT_OWE)
+ pos += sprintf(pos, "OWE/");
+
if (!suites || (suites & IWINFO_KMGMT_NONE))
pos += sprintf(pos, "NONE/");
static char * iwinfo_crypto_desc(struct iwinfo_crypto_entry *c)
{
static char desc[512] = { 0 };
+ char *pos = desc;
+ int i, n;
if (c)
{
/* WPA */
else if (c->wpa_version)
{
- switch (c->wpa_version) {
- case 3:
- sprintf(desc, "mixed WPA/WPA2 %s (%s)",
- iwinfo_crypto_print_suites(c->auth_suites),
- iwinfo_crypto_print_ciphers(
- c->pair_ciphers & c->group_ciphers));
- break;
-
- case 2:
- sprintf(desc, "WPA2 %s (%s)",
- iwinfo_crypto_print_suites(c->auth_suites),
- iwinfo_crypto_print_ciphers(
- c->pair_ciphers & c->group_ciphers));
- break;
-
- case 1:
- sprintf(desc, "WPA %s (%s)",
- iwinfo_crypto_print_suites(c->auth_suites),
- iwinfo_crypto_print_ciphers(
- c->pair_ciphers & c->group_ciphers));
- break;
- }
+ for (i = 0, n = 0; i < 3; i++)
+ if (c->wpa_version & (1 << i))
+ n++;
+
+ if (n > 1)
+ pos += sprintf(pos, "mixed ");
+
+ for (i = 0; i < 3; i++)
+ if (c->wpa_version & (1 << i))
+ if (i)
+ pos += sprintf(pos, "WPA%d/", i + 1);
+ else
+ pos += sprintf(pos, "WPA/");
+
+ pos--;
+
+ sprintf(pos, " %s (%s)",
+ iwinfo_crypto_print_suites(c->auth_suites),
+ iwinfo_crypto_print_ciphers(
+ c->pair_ciphers | c->group_ciphers));
}
else
{
lua_setfield(L, -2, "wpa");
lua_newtable(L);
- for (i = 0, j = 1; i < 8; i++)
+ for (i = 0, j = 1; i < ARRAY_SIZE(IWINFO_CIPHER_NAMES); i++)
{
if (c->pair_ciphers & (1 << i))
{
lua_setfield(L, -2, "pair_ciphers");
lua_newtable(L);
- for (i = 0, j = 1; i < 8; i++)
+ for (i = 0, j = 1; i < ARRAY_SIZE(IWINFO_CIPHER_NAMES); i++)
{
if (c->group_ciphers & (1 << i))
{
lua_setfield(L, -2, "group_ciphers");
lua_newtable(L);
- for (i = 0, j = 1; i < 8; i++)
+ for (i = 0, j = 1; i < ARRAY_SIZE(IWINFO_KMGMT_NAMES); i++)
{
if (c->auth_suites & (1 << i))
{
lua_setfield(L, -2, "auth_suites");
lua_newtable(L);
- for (i = 0, j = 1; i < 8; i++)
+ for (i = 0, j = 1; i < ARRAY_SIZE(IWINFO_AUTH_NAMES); i++)
{
if (c->auth_algs & (1 << i))
{
return 1;
}
+static void set_rateinfo(lua_State *L, struct iwinfo_rate_entry *r, bool rx)
+{
+ lua_pushnumber(L, r->rate);
+ lua_setfield(L, -2, rx ? "rx_rate" : "tx_rate");
+
+ lua_pushboolean(L, r->is_ht);
+ lua_setfield(L, -2, rx ? "rx_ht" : "tx_ht");
+
+ lua_pushboolean(L, r->is_vht);
+ lua_setfield(L, -2, rx ? "rx_vht" : "tx_vht");
+
+ lua_pushboolean(L, r->is_he);
+ lua_setfield(L, -2, rx ? "rx_he" : "tx_he");
+
+ lua_pushnumber(L, r->mhz);
+ lua_setfield(L, -2, rx ? "rx_mhz" : "tx_mhz");
+
+ if (r->is_ht)
+ {
+ lua_pushboolean(L, r->is_40mhz);
+ lua_setfield(L, -2, rx ? "rx_40mhz" : "tx_40mhz");
+
+ lua_pushnumber(L, r->mcs);
+ lua_setfield(L, -2, rx ? "rx_mcs" : "tx_mcs");
+
+ lua_pushboolean(L, r->is_short_gi);
+ lua_setfield(L, -2, rx ? "rx_short_gi" : "tx_short_gi");
+ }
+ else if (r->is_vht || r->is_he)
+ {
+ lua_pushnumber(L, r->mcs);
+ lua_setfield(L, -2, rx ? "rx_mcs" : "tx_mcs");
+
+ lua_pushnumber(L, r->nss);
+ lua_setfield(L, -2, rx ? "rx_nss" : "tx_nss");
+
+ if (r->is_he) {
+ lua_pushnumber(L, r->he_gi);
+ lua_setfield(L, -2, rx ? "rx_he_gi" : "tx_he_gi");
+
+ lua_pushnumber(L, r->he_dcm);
+ lua_setfield(L, -2, rx ? "rx_he_dcm" : "tx_he_dcm");
+ }
+
+ if (r->is_vht) {
+ lua_pushboolean(L, r->is_short_gi);
+ lua_setfield(L, -2, rx ? "rx_short_gi" : "tx_short_gi");
+ }
+ }
+}
+
/* Wrapper for assoclist */
static int iwinfo_L_assoclist(lua_State *L, int (*func)(const char *, char *, int *))
{
lua_pushnumber(L, e->tx_packets);
lua_setfield(L, -2, "tx_packets");
- lua_pushnumber(L, e->rx_rate.rate);
- lua_setfield(L, -2, "rx_rate");
-
- lua_pushnumber(L, e->tx_rate.rate);
- lua_setfield(L, -2, "tx_rate");
-
- if (e->rx_rate.mcs >= 0)
- {
- lua_pushnumber(L, e->rx_rate.mcs);
- lua_setfield(L, -2, "rx_mcs");
-
- lua_pushboolean(L, e->rx_rate.is_40mhz);
- lua_setfield(L, -2, "rx_40mhz");
-
- lua_pushboolean(L, e->rx_rate.is_short_gi);
- lua_setfield(L, -2, "rx_short_gi");
- }
-
- if (e->tx_rate.mcs >= 0)
- {
- lua_pushnumber(L, e->tx_rate.mcs);
- lua_setfield(L, -2, "tx_mcs");
-
- lua_pushboolean(L, e->tx_rate.is_40mhz);
- lua_setfield(L, -2, "tx_40mhz");
+ set_rateinfo(L, &e->rx_rate, true);
+ set_rateinfo(L, &e->tx_rate, false);
- lua_pushboolean(L, e->tx_rate.is_short_gi);
- lua_setfield(L, -2, "tx_short_gi");
+ if (e->thr) {
+ lua_pushnumber(L, e->thr);
+ lua_setfield(L, -2, "expected_throughput");
}
lua_setfield(L, -2, macstr);
lua_pushboolean(L, hwmodes & IWINFO_80211_AC);
lua_setfield(L, -2, "ac");
+ lua_pushboolean(L, hwmodes & IWINFO_80211_AD);
+ lua_setfield(L, -2, "ad");
+
+ lua_pushboolean(L, hwmodes & IWINFO_80211_AX);
+ lua_setfield(L, -2, "ax");
+
+ return 1;
+ }
+
+ lua_pushnil(L);
+ return 1;
+}
+
+/* Wrapper for htmode list */
+static int iwinfo_L_htmodelist(lua_State *L, int (*func)(const char *, int *))
+{
+ const char *ifname = luaL_checkstring(L, 1);
+ int i, htmodes = 0;
+
+ if (!(*func)(ifname, &htmodes))
+ {
+ lua_newtable(L);
+
+ for (i = 0; i < ARRAY_SIZE(IWINFO_HTMODE_NAMES); i++)
+ {
+ lua_pushboolean(L, htmodes & (1 << i));
+ lua_setfield(L, -2, IWINFO_HTMODE_NAMES[i]);
+ }
+
return 1;
}
static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *, int *))
{
- int len, i, j;
+ int len, i;
char rv[IWINFO_BUFSIZE], alpha2[3];
char *ccode;
const char *ifname = luaL_checkstring(L, 1);
if (!(*func)(ifname, rv, &len))
{
- for (l = IWINFO_ISO3166_NAMES, j = 1; l->iso3166; l++)
+ for (l = IWINFO_ISO3166_NAMES, i = 1; l->iso3166; l++)
{
if ((ccode = iwinfo_L_country_lookup(rv, len, l->iso3166)) != NULL)
{
lua_pushstring(L, l->name);
lua_setfield(L, -2, "name");
- lua_rawseti(L, -2, j++);
+ lua_rawseti(L, -2, i++);
}
}
}
LUA_WRAP_STRUCT_OP(wl,freqlist)
LUA_WRAP_STRUCT_OP(wl,countrylist)
LUA_WRAP_STRUCT_OP(wl,hwmodelist)
+LUA_WRAP_STRUCT_OP(wl,htmodelist)
LUA_WRAP_STRUCT_OP(wl,encryption)
LUA_WRAP_STRUCT_OP(wl,mbssid_support)
LUA_WRAP_STRUCT_OP(wl,hardware_id)
LUA_WRAP_STRUCT_OP(madwifi,freqlist)
LUA_WRAP_STRUCT_OP(madwifi,countrylist)
LUA_WRAP_STRUCT_OP(madwifi,hwmodelist)
+LUA_WRAP_STRUCT_OP(madwifi,htmodelist)
LUA_WRAP_STRUCT_OP(madwifi,encryption)
LUA_WRAP_STRUCT_OP(madwifi,mbssid_support)
LUA_WRAP_STRUCT_OP(madwifi,hardware_id)
LUA_WRAP_STRUCT_OP(nl80211,freqlist)
LUA_WRAP_STRUCT_OP(nl80211,countrylist)
LUA_WRAP_STRUCT_OP(nl80211,hwmodelist)
+LUA_WRAP_STRUCT_OP(nl80211,htmodelist)
LUA_WRAP_STRUCT_OP(nl80211,encryption)
LUA_WRAP_STRUCT_OP(nl80211,mbssid_support)
LUA_WRAP_STRUCT_OP(nl80211,hardware_id)
#endif
/* Wext */
+#ifdef USE_WEXT
LUA_WRAP_INT_OP(wext,channel)
LUA_WRAP_INT_OP(wext,frequency)
LUA_WRAP_INT_OP(wext,frequency_offset)
LUA_WRAP_STRUCT_OP(wext,freqlist)
LUA_WRAP_STRUCT_OP(wext,countrylist)
LUA_WRAP_STRUCT_OP(wext,hwmodelist)
+LUA_WRAP_STRUCT_OP(wext,htmodelist)
LUA_WRAP_STRUCT_OP(wext,encryption)
LUA_WRAP_STRUCT_OP(wext,mbssid_support)
LUA_WRAP_STRUCT_OP(wext,hardware_id)
+#endif
#ifdef USE_WL
/* Broadcom table */
LUA_REG(wl,freqlist),
LUA_REG(wl,countrylist),
LUA_REG(wl,hwmodelist),
+ LUA_REG(wl,htmodelist),
LUA_REG(wl,encryption),
LUA_REG(wl,mbssid_support),
LUA_REG(wl,hardware_id),
LUA_REG(madwifi,freqlist),
LUA_REG(madwifi,countrylist),
LUA_REG(madwifi,hwmodelist),
+ LUA_REG(madwifi,htmodelist),
LUA_REG(madwifi,encryption),
LUA_REG(madwifi,mbssid_support),
LUA_REG(madwifi,hardware_id),
LUA_REG(nl80211,freqlist),
LUA_REG(nl80211,countrylist),
LUA_REG(nl80211,hwmodelist),
+ LUA_REG(nl80211,htmodelist),
LUA_REG(nl80211,encryption),
LUA_REG(nl80211,mbssid_support),
LUA_REG(nl80211,hardware_id),
#endif
/* Wext table */
+#ifdef USE_WEXT
static const luaL_reg R_wext[] = {
LUA_REG(wext,channel),
LUA_REG(wext,frequency),
LUA_REG(wext,freqlist),
LUA_REG(wext,countrylist),
LUA_REG(wext,hwmodelist),
+ LUA_REG(wext,htmodelist),
LUA_REG(wext,encryption),
LUA_REG(wext,mbssid_support),
LUA_REG(wext,hardware_id),
LUA_REG(wext,phyname),
{ NULL, NULL }
};
+#endif
/* Common */
static const luaL_reg R_common[] = {
lua_setfield(L, -2, "nl80211");
#endif
+#ifdef USE_WEXT
luaL_newmetatable(L, IWINFO_WEXT_META);
luaL_register(L, NULL, R_common);
luaL_register(L, NULL, R_wext);
lua_pushvalue(L, -1);
lua_setfield(L, -2, "__index");
lua_setfield(L, -2, "wext");
+#endif
return 1;
}