#include "iwinfo_lualib.h"
/* Determine type */
-int iwinfo_L_type(lua_State *L)
+static int iwinfo_L_type(lua_State *L)
{
const char *ifname = luaL_checkstring(L, 1);
}
/* Wrapper for assoclist */
-int iwinfo_L_assoclist(lua_State *L, int (*func)(const char *, char *, int *))
+static int iwinfo_L_assoclist(lua_State *L, int (*func)(const char *, char *, int *))
{
int i, len;
char rv[IWINFO_BUFSIZE];
return 1;
}
+/* Wrapper for tx power list */
+static int iwinfo_L_txpwrlist(lua_State *L, int (*func)(const char *, char *, int *))
+{
+ int i, x, len;
+ char rv[IWINFO_BUFSIZE];
+ const char *ifname = luaL_checkstring(L, 1);
+ struct iwinfo_txpwrlist_entry *e;
+
+ lua_newtable(L);
+ memset(rv, 0, sizeof(rv));
+
+ if( !(*func)(ifname, rv, &len) )
+ {
+ for( i = 0, x = 1; i < len; i += sizeof(struct iwinfo_txpwrlist_entry), x++ )
+ {
+ e = (struct iwinfo_txpwrlist_entry *) &rv[i];
+
+ lua_newtable(L);
+
+ lua_pushnumber(L, e->mw);
+ lua_setfield(L, -2, "mw");
+
+ lua_pushnumber(L, e->dbm);
+ lua_setfield(L, -2, "dbm");
+
+ lua_rawseti(L, -2, x);
+ }
+ }
+
+ return 1;
+}
+
/* Broadcom */
LUA_WRAP_INT(wl,channel)
LUA_WRAP_INT(wl,frequency)
LUA_WRAP_INT(wl,noise)
LUA_WRAP_INT(wl,quality)
LUA_WRAP_INT(wl,quality_max)
+LUA_WRAP_INT(wl,mbssid_support)
LUA_WRAP_STRING(wl,mode)
LUA_WRAP_STRING(wl,ssid)
LUA_WRAP_STRING(wl,bssid)
LUA_WRAP_STRING(wl,enctype)
-LUA_WRAP_ASSOCLIST(wl)
+LUA_WRAP_LIST(wl,assoclist)
+LUA_WRAP_LIST(wl,txpwrlist)
/* Madwifi */
LUA_WRAP_INT(madwifi,channel)
LUA_WRAP_INT(madwifi,noise)
LUA_WRAP_INT(madwifi,quality)
LUA_WRAP_INT(madwifi,quality_max)
+LUA_WRAP_INT(madwifi,mbssid_support)
LUA_WRAP_STRING(madwifi,mode)
LUA_WRAP_STRING(madwifi,ssid)
LUA_WRAP_STRING(madwifi,bssid)
LUA_WRAP_STRING(madwifi,enctype)
-LUA_WRAP_ASSOCLIST(madwifi)
+LUA_WRAP_LIST(madwifi,assoclist)
+LUA_WRAP_LIST(madwifi,txpwrlist)
/* Wext */
LUA_WRAP_INT(wext,channel)
LUA_WRAP_INT(wext,noise)
LUA_WRAP_INT(wext,quality)
LUA_WRAP_INT(wext,quality_max)
+LUA_WRAP_INT(wext,mbssid_support)
LUA_WRAP_STRING(wext,mode)
LUA_WRAP_STRING(wext,ssid)
LUA_WRAP_STRING(wext,bssid)
LUA_WRAP_STRING(wext,enctype)
-LUA_WRAP_ASSOCLIST(wext)
+LUA_WRAP_LIST(wext,assoclist)
+LUA_WRAP_LIST(wext,txpwrlist)
/* Broadcom table */
static const luaL_reg R_wl[] = {
LUA_REG(wl,bssid),
LUA_REG(wl,enctype),
LUA_REG(wl,assoclist),
+ LUA_REG(wl,txpwrlist),
+ LUA_REG(wl,mbssid_support),
{ NULL, NULL }
};
LUA_REG(madwifi,bssid),
LUA_REG(madwifi,enctype),
LUA_REG(madwifi,assoclist),
+ LUA_REG(madwifi,txpwrlist),
+ LUA_REG(madwifi,mbssid_support),
{ NULL, NULL }
};
LUA_REG(wext,bssid),
LUA_REG(wext,enctype),
LUA_REG(wext,assoclist),
+ LUA_REG(wext,txpwrlist),
+ LUA_REG(wext,mbssid_support),
{ NULL, NULL }
};