X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/c02a9bd7aaf1e6fbfa829ec2e1b66cefce3268c5..b8d5619ca8ac95b4a0365a7adcce4b0d9c7305ce:/package/iwinfo/src/iwinfo_lua.c?ds=sidebyside diff --git a/package/iwinfo/src/iwinfo_lua.c b/package/iwinfo/src/iwinfo_lua.c index 08eec18bd..e4435c1ff 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 *)) { @@ -265,6 +278,45 @@ static int iwinfo_L_assoclist(lua_State *L, int (*func)(const char *, char *, in lua_pushnumber(L, e->noise); lua_setfield(L, -2, "noise"); + lua_pushnumber(L, e->inactive); + lua_setfield(L, -2, "inactive"); + + lua_pushnumber(L, e->rx_packets); + lua_setfield(L, -2, "rx_packets"); + + 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"); + + lua_pushboolean(L, e->tx_rate.is_short_gi); + lua_setfield(L, -2, "tx_short_gi"); + } + lua_setfield(L, -2, macstr); } } @@ -344,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 */ @@ -558,17 +610,19 @@ static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *, /* Broadcom */ LUA_WRAP_INT(wl,channel) LUA_WRAP_INT(wl,frequency) +LUA_WRAP_INT(wl,frequency_offset) LUA_WRAP_INT(wl,txpower) +LUA_WRAP_INT(wl,txpower_offset) LUA_WRAP_INT(wl,bitrate) 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) @@ -584,17 +638,19 @@ LUA_WRAP_STRUCT(wl,hardware_id) /* Madwifi */ LUA_WRAP_INT(madwifi,channel) LUA_WRAP_INT(madwifi,frequency) +LUA_WRAP_INT(madwifi,frequency_offset) LUA_WRAP_INT(madwifi,txpower) +LUA_WRAP_INT(madwifi,txpower_offset) LUA_WRAP_INT(madwifi,bitrate) 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) @@ -610,17 +666,19 @@ LUA_WRAP_STRUCT(madwifi,hardware_id) /* NL80211 */ LUA_WRAP_INT(nl80211,channel) LUA_WRAP_INT(nl80211,frequency) +LUA_WRAP_INT(nl80211,frequency_offset) LUA_WRAP_INT(nl80211,txpower) +LUA_WRAP_INT(nl80211,txpower_offset) LUA_WRAP_INT(nl80211,bitrate) 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) @@ -635,17 +693,19 @@ LUA_WRAP_STRUCT(nl80211,hardware_id) /* Wext */ LUA_WRAP_INT(wext,channel) LUA_WRAP_INT(wext,frequency) +LUA_WRAP_INT(wext,frequency_offset) LUA_WRAP_INT(wext,txpower) +LUA_WRAP_INT(wext,txpower_offset) LUA_WRAP_INT(wext,bitrate) 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) @@ -661,7 +721,9 @@ LUA_WRAP_STRUCT(wext,hardware_id) static const luaL_reg R_wl[] = { LUA_REG(wl,channel), LUA_REG(wl,frequency), + LUA_REG(wl,frequency_offset), LUA_REG(wl,txpower), + LUA_REG(wl,txpower_offset), LUA_REG(wl,bitrate), LUA_REG(wl,signal), LUA_REG(wl,noise), @@ -690,7 +752,9 @@ static const luaL_reg R_wl[] = { static const luaL_reg R_madwifi[] = { LUA_REG(madwifi,channel), LUA_REG(madwifi,frequency), + LUA_REG(madwifi,frequency_offset), LUA_REG(madwifi,txpower), + LUA_REG(madwifi,txpower_offset), LUA_REG(madwifi,bitrate), LUA_REG(madwifi,signal), LUA_REG(madwifi,noise), @@ -719,7 +783,9 @@ static const luaL_reg R_madwifi[] = { static const luaL_reg R_nl80211[] = { LUA_REG(nl80211,channel), LUA_REG(nl80211,frequency), + LUA_REG(nl80211,frequency_offset), LUA_REG(nl80211,txpower), + LUA_REG(nl80211,txpower_offset), LUA_REG(nl80211,bitrate), LUA_REG(nl80211,signal), LUA_REG(nl80211,noise), @@ -747,7 +813,9 @@ static const luaL_reg R_nl80211[] = { static const luaL_reg R_wext[] = { LUA_REG(wext,channel), LUA_REG(wext,frequency), + LUA_REG(wext,frequency_offset), LUA_REG(wext,txpower), + LUA_REG(wext,txpower_offset), LUA_REG(wext,bitrate), LUA_REG(wext,signal), LUA_REG(wext,noise),