X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=iwinfo_lua.c;h=eebab8e8987d2f95ecae8d85d5f494854261875a;hb=HEAD;hp=21d6bbc16334537d3cba9ba6a3a71a8e8b0ae6b0;hpb=7b39bee1c62dc68c84938cda43115e4d30724d1e;p=project%2Fiwinfo.git diff --git a/iwinfo_lua.c b/iwinfo_lua.c index 21d6bbc..eebab8e 100644 --- a/iwinfo_lua.c +++ b/iwinfo_lua.c @@ -134,21 +134,21 @@ static char * iwinfo_crypto_desc(struct iwinfo_crypto_entry *c) sprintf(desc, "mixed WPA/WPA2 %s (%s)", iwinfo_crypto_print_suites(c->auth_suites), iwinfo_crypto_print_ciphers( - c->pair_ciphers & c->group_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)); + 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)); + c->pair_ciphers | c->group_ciphers)); break; } } @@ -190,7 +190,7 @@ static void iwinfo_L_cryptotable(lua_State *L, struct iwinfo_crypto_entry *c) 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)) { @@ -201,7 +201,7 @@ static void iwinfo_L_cryptotable(lua_State *L, struct iwinfo_crypto_entry *c) 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)) { @@ -212,7 +212,7 @@ static void iwinfo_L_cryptotable(lua_State *L, struct iwinfo_crypto_entry *c) 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)) { @@ -223,7 +223,7 @@ static void iwinfo_L_cryptotable(lua_State *L, struct iwinfo_crypto_entry *c) 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)) { @@ -248,6 +248,44 @@ static int iwinfo_L_mode(lua_State *L, int (*func)(const char *, int *)) 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_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) + { + 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"); + + 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 *)) { @@ -287,34 +325,12 @@ static int iwinfo_L_assoclist(lua_State *L, int (*func)(const char *, char *, in 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); @@ -597,7 +613,7 @@ static char * iwinfo_L_country_lookup(char *buf, int len, int iso3166) 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); @@ -608,7 +624,7 @@ static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *, 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) { @@ -626,7 +642,7 @@ static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *, lua_pushstring(L, l->name); lua_setfield(L, -2, "name"); - lua_rawseti(L, -2, j++); + lua_rawseti(L, -2, i++); } } }