diff options
Diffstat (limited to 'package/iwinfo/src/iwinfo_lua.c')
-rw-r--r-- | package/iwinfo/src/iwinfo_lua.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/package/iwinfo/src/iwinfo_lua.c b/package/iwinfo/src/iwinfo_lua.c index 6b78cb7..e4435c1 100644 --- a/package/iwinfo/src/iwinfo_lua.c +++ b/package/iwinfo/src/iwinfo_lua.c @@ -235,6 +235,19 @@ static void iwinfo_L_cryptotable(lua_State *L, struct iwinfo_crypto_entry *c) } +/* Wrapper for mode */ +static int iwinfo_L_mode(lua_State *L, int (*func)(const char *, int *)) +{ + int mode; + const char *ifname = luaL_checkstring(L, 1); + + if ((*func)(ifname, &mode)) + mode = IWINFO_OPMODE_UNKNOWN; + + lua_pushstring(L, IWINFO_OPMODE_NAMES[mode]); + return 1; +} + /* Wrapper for assoclist */ static int iwinfo_L_assoclist(lua_State *L, int (*func)(const char *, char *, int *)) { @@ -383,7 +396,7 @@ static int iwinfo_L_scanlist(lua_State *L, int (*func)(const char *, char *, int lua_setfield(L, -2, "channel"); /* Mode */ - lua_pushstring(L, (char *) e->mode); + lua_pushstring(L, IWINFO_OPMODE_NAMES[e->mode]); lua_setfield(L, -2, "mode"); /* Quality, Signal */ @@ -605,11 +618,11 @@ LUA_WRAP_INT(wl,signal) LUA_WRAP_INT(wl,noise) LUA_WRAP_INT(wl,quality) LUA_WRAP_INT(wl,quality_max) -LUA_WRAP_STRING(wl,mode) LUA_WRAP_STRING(wl,ssid) LUA_WRAP_STRING(wl,bssid) LUA_WRAP_STRING(wl,country) LUA_WRAP_STRING(wl,hardware_name) +LUA_WRAP_STRUCT(wl,mode) LUA_WRAP_STRUCT(wl,assoclist) LUA_WRAP_STRUCT(wl,txpwrlist) LUA_WRAP_STRUCT(wl,scanlist) @@ -633,11 +646,11 @@ LUA_WRAP_INT(madwifi,signal) LUA_WRAP_INT(madwifi,noise) LUA_WRAP_INT(madwifi,quality) LUA_WRAP_INT(madwifi,quality_max) -LUA_WRAP_STRING(madwifi,mode) LUA_WRAP_STRING(madwifi,ssid) LUA_WRAP_STRING(madwifi,bssid) LUA_WRAP_STRING(madwifi,country) LUA_WRAP_STRING(madwifi,hardware_name) +LUA_WRAP_STRUCT(madwifi,mode) LUA_WRAP_STRUCT(madwifi,assoclist) LUA_WRAP_STRUCT(madwifi,txpwrlist) LUA_WRAP_STRUCT(madwifi,scanlist) @@ -661,11 +674,11 @@ LUA_WRAP_INT(nl80211,signal) LUA_WRAP_INT(nl80211,noise) LUA_WRAP_INT(nl80211,quality) LUA_WRAP_INT(nl80211,quality_max) -LUA_WRAP_STRING(nl80211,mode) LUA_WRAP_STRING(nl80211,ssid) LUA_WRAP_STRING(nl80211,bssid) LUA_WRAP_STRING(nl80211,country) LUA_WRAP_STRING(nl80211,hardware_name) +LUA_WRAP_STRUCT(nl80211,mode) LUA_WRAP_STRUCT(nl80211,assoclist) LUA_WRAP_STRUCT(nl80211,txpwrlist) LUA_WRAP_STRUCT(nl80211,scanlist) @@ -688,11 +701,11 @@ LUA_WRAP_INT(wext,signal) LUA_WRAP_INT(wext,noise) LUA_WRAP_INT(wext,quality) LUA_WRAP_INT(wext,quality_max) -LUA_WRAP_STRING(wext,mode) LUA_WRAP_STRING(wext,ssid) LUA_WRAP_STRING(wext,bssid) LUA_WRAP_STRING(wext,country) LUA_WRAP_STRING(wext,hardware_name) +LUA_WRAP_STRUCT(wext,mode) LUA_WRAP_STRUCT(wext,assoclist) LUA_WRAP_STRUCT(wext,txpwrlist) LUA_WRAP_STRUCT(wext,scanlist) |