X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fiwinfo.git;a=blobdiff_plain;f=iwinfo_lua.c;h=2154ecc534078d9dd29899dd29eea37988f6fd9e;hp=3201af4f0110c98cb8ce9a03cd0d2c8673e8b19b;hb=8d5afddf221172c9bb00198b1b67fdbf5deb1b96;hpb=8ae758db52957939eeb6bc1c7da7be9d0339d3aa diff --git a/iwinfo_lua.c b/iwinfo_lua.c index 3201af4..2154ecc 100644 --- a/iwinfo_lua.c +++ b/iwinfo_lua.c @@ -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)) { @@ -509,6 +509,29 @@ static int iwinfo_L_hwmodelist(lua_State *L, int (*func)(const char *, int *)) 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; + } + + lua_pushnil(L); + return 1; +} + /* Wrapper for mbssid_support */ static int iwinfo_L_mbssid_support(lua_State *L, int (*func)(const char *, int *)) { @@ -574,7 +597,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); @@ -585,7 +608,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) { @@ -603,7 +626,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++); } } } @@ -636,6 +659,7 @@ LUA_WRAP_STRUCT_OP(wl,scanlist) 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) @@ -665,6 +689,7 @@ LUA_WRAP_STRUCT_OP(madwifi,scanlist) 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) @@ -694,6 +719,7 @@ LUA_WRAP_STRUCT_OP(nl80211,scanlist) 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) @@ -722,6 +748,7 @@ LUA_WRAP_STRUCT_OP(wext,scanlist) 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) @@ -749,6 +776,7 @@ static const luaL_reg R_wl[] = { 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), @@ -781,6 +809,7 @@ static const luaL_reg R_madwifi[] = { 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), @@ -813,6 +842,7 @@ static const luaL_reg R_nl80211[] = { 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), @@ -844,6 +874,7 @@ static const luaL_reg R_wext[] = { 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),