libs/iwinfo: conditionally compile wl.o or madwifi support, make it depend on $(CRAP)
This commit is contained in:
parent
89ece183ef
commit
2a68a29c57
4 changed files with 39 additions and 8 deletions
|
@ -7,10 +7,10 @@ include standalone.mk
|
|||
endif
|
||||
|
||||
IWINFO_LDFLAGS =
|
||||
IWINFO_CFLAGS = -fstrict-aliasing
|
||||
IWINFO_CFLAGS = -fstrict-aliasing $(if $(CRAP),-DUSE_WL,-DUSE_MADWIFI)
|
||||
IWINFO_SO = iwinfo.so
|
||||
IWINFO_LUA = iwinfo.lua
|
||||
IWINFO_OBJ = src/iwinfo_wl.o src/iwinfo_madwifi.o \
|
||||
IWINFO_OBJ = $(if $(CRAP),src/iwinfo_wl.o,src/iwinfo_madwifi.o) \
|
||||
src/iwinfo_wext.o src/iwinfo_wext_scan.o src/iwinfo_lualib.o
|
||||
|
||||
%.o: %.c
|
||||
|
|
|
@ -18,10 +18,16 @@
|
|||
#include <net/if.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "iwinfo_wl.h"
|
||||
#include "iwinfo_madwifi.h"
|
||||
#include "iwinfo_wext.h"
|
||||
|
||||
#ifdef USE_WL
|
||||
#include "iwinfo_wl.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_MADWIFI
|
||||
#include "iwinfo_madwifi.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define IWINFO_BUFSIZE 24 * 1024
|
||||
|
||||
|
|
|
@ -23,13 +23,19 @@ static int iwinfo_L_type(lua_State *L)
|
|||
{
|
||||
const char *ifname = luaL_checkstring(L, 1);
|
||||
|
||||
#ifdef USE_MADWIFI
|
||||
if( madwifi_probe(ifname) )
|
||||
lua_pushstring(L, "madwifi");
|
||||
else
|
||||
#endif
|
||||
|
||||
else if( wl_probe(ifname) )
|
||||
#ifdef USE_WL
|
||||
if( wl_probe(ifname) )
|
||||
lua_pushstring(L, "wl");
|
||||
else
|
||||
#endif
|
||||
|
||||
else if( wext_probe(ifname) )
|
||||
if( wext_probe(ifname) )
|
||||
lua_pushstring(L, "wext");
|
||||
|
||||
else
|
||||
|
@ -244,6 +250,7 @@ static int iwinfo_L_freqlist(lua_State *L, int (*func)(const char *, char *, int
|
|||
return 1;
|
||||
}
|
||||
|
||||
#ifdef USE_WL
|
||||
/* Broadcom */
|
||||
LUA_WRAP_INT(wl,channel)
|
||||
LUA_WRAP_INT(wl,frequency)
|
||||
|
@ -261,7 +268,9 @@ LUA_WRAP_LIST(wl,assoclist)
|
|||
LUA_WRAP_LIST(wl,txpwrlist)
|
||||
LUA_WRAP_LIST(wl,scanlist)
|
||||
LUA_WRAP_LIST(wl,freqlist)
|
||||
#endif
|
||||
|
||||
#ifdef USE_MADWIFI
|
||||
/* Madwifi */
|
||||
LUA_WRAP_INT(madwifi,channel)
|
||||
LUA_WRAP_INT(madwifi,frequency)
|
||||
|
@ -279,6 +288,7 @@ LUA_WRAP_LIST(madwifi,assoclist)
|
|||
LUA_WRAP_LIST(madwifi,txpwrlist)
|
||||
LUA_WRAP_LIST(madwifi,scanlist)
|
||||
LUA_WRAP_LIST(madwifi,freqlist)
|
||||
#endif
|
||||
|
||||
/* Wext */
|
||||
LUA_WRAP_INT(wext,channel)
|
||||
|
@ -298,6 +308,7 @@ LUA_WRAP_LIST(wext,txpwrlist)
|
|||
LUA_WRAP_LIST(wext,scanlist)
|
||||
LUA_WRAP_LIST(wext,freqlist)
|
||||
|
||||
#ifdef USE_WL
|
||||
/* Broadcom table */
|
||||
static const luaL_reg R_wl[] = {
|
||||
LUA_REG(wl,channel),
|
||||
|
@ -318,7 +329,9 @@ static const luaL_reg R_wl[] = {
|
|||
LUA_REG(wl,mbssid_support),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef USE_MADWIFI
|
||||
/* Madwifi table */
|
||||
static const luaL_reg R_madwifi[] = {
|
||||
LUA_REG(madwifi,channel),
|
||||
|
@ -339,6 +352,7 @@ static const luaL_reg R_madwifi[] = {
|
|||
LUA_REG(madwifi,mbssid_support),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Wext table */
|
||||
static const luaL_reg R_wext[] = {
|
||||
|
@ -371,17 +385,21 @@ static const luaL_reg R_common[] = {
|
|||
LUALIB_API int luaopen_iwinfo(lua_State *L) {
|
||||
luaL_register(L, IWINFO_META, R_common);
|
||||
|
||||
#ifdef USE_WL
|
||||
luaL_newmetatable(L, IWINFO_WL_META);
|
||||
luaL_register(L, NULL, R_wl);
|
||||
lua_pushvalue(L, -1);
|
||||
lua_setfield(L, -2, "__index");
|
||||
lua_setfield(L, -2, "wl");
|
||||
#endif
|
||||
|
||||
#ifdef USE_MADWIFI
|
||||
luaL_newmetatable(L, IWINFO_MADWIFI_META);
|
||||
luaL_register(L, NULL, R_madwifi);
|
||||
lua_pushvalue(L, -1);
|
||||
lua_setfield(L, -2, "__index");
|
||||
lua_setfield(L, -2, "madwifi");
|
||||
#endif
|
||||
|
||||
luaL_newmetatable(L, IWINFO_WEXT_META);
|
||||
luaL_register(L, NULL, R_wext);
|
||||
|
|
|
@ -28,10 +28,17 @@
|
|||
|
||||
|
||||
#define IWINFO_META "iwinfo"
|
||||
#define IWINFO_WL_META "iwinfo.wl"
|
||||
#define IWINFO_MADWIFI_META "iwinfo.madwifi"
|
||||
#define IWINFO_WEXT_META "iwinfo.wext"
|
||||
|
||||
#ifdef USE_WL
|
||||
#define IWINFO_WL_META "iwinfo.wl"
|
||||
#endif
|
||||
|
||||
#ifdef USE_MADWIFI
|
||||
#define IWINFO_MADWIFI_META "iwinfo.madwifi"
|
||||
#endif
|
||||
|
||||
|
||||
#define LUA_REG(type,op) \
|
||||
{ #op, iwinfo_L_##type##_##op }
|
||||
|
||||
|
|
Loading…
Reference in a new issue