libiwinfo: probe for vap availability in mbssid_support(), fix return type, fix description string for no crypto

remotes/tags/0.10.0
Jo-Philipp Wich 2010-10-23 01:37:05 +00:00
parent b64f2d6079
commit 50bd4a979b
3 changed files with 60 additions and 19 deletions

View File

@ -62,7 +62,10 @@ function print_info(api, dev)
n(iw.bitrate(dev)) / 1000)
printf(" Encryption: %s",
s(enc and enc.description))
s(enc and enc.description or "None"))
printf(" Supports VAPs: %s",
iw.mbssid_support(dev) and "yes" or "no")
print("")
end
@ -85,7 +88,7 @@ function print_scan(api, dev)
s(se.signal), n(se.quality), n(se.quality_max))
printf(" Encryption: %s",
s(se.encryption.description))
s(se.encryption.description or "None"))
print("")
end

View File

@ -432,6 +432,10 @@ static char * iwinfo_crypto_desc(struct iwinfo_crypto_entry *c)
break;
}
}
else
{
sprintf(desc, "None");
}
}
else
{
@ -694,11 +698,12 @@ static int iwinfo_L_encryption(lua_State *L, int (*func)(const char *, char *))
return 1;
}
return 0;
lua_pushnil(L);
return 1;
}
/* Wrapper for hwmode list */
static int iwinfo_L_hwmodelist(lua_State *L, int (*func)(const char*, int *))
static int iwinfo_L_hwmodelist(lua_State *L, int (*func)(const char *, int *))
{
const char *ifname = luaL_checkstring(L, 1);
int hwmodes = 0;
@ -722,7 +727,24 @@ static int iwinfo_L_hwmodelist(lua_State *L, int (*func)(const char*, int *))
return 1;
}
return 0;
lua_pushnil(L);
return 1;
}
/* Wrapper for mbbsid_support */
static int iwinfo_L_mbssid_support(lua_State *L, int (*func)(const char *, int *))
{
const char *ifname = luaL_checkstring(L, 1);
int support = 0;
if( !(*func)(ifname, &support) )
{
lua_pushboolean(L, support);
return 1;
}
lua_pushnil(L);
return 1;
}
/* Wrapper for country list */
@ -792,7 +814,6 @@ LUA_WRAP_INT(wl,signal)
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)
@ -804,6 +825,7 @@ LUA_WRAP_LIST(wl,freqlist)
LUA_WRAP_LIST(wl,countrylist)
LUA_WRAP_LIST(wl,hwmodelist)
LUA_WRAP_LIST(wl,encryption)
LUA_WRAP_LIST(wl,mbssid_support)
#endif
#ifdef USE_MADWIFI
@ -816,7 +838,6 @@ LUA_WRAP_INT(madwifi,signal)
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)
@ -828,6 +849,7 @@ LUA_WRAP_LIST(madwifi,freqlist)
LUA_WRAP_LIST(madwifi,countrylist)
LUA_WRAP_LIST(madwifi,hwmodelist)
LUA_WRAP_LIST(madwifi,encryption)
LUA_WRAP_LIST(madwifi,mbssid_support)
#endif
#ifdef USE_NL80211
@ -840,7 +862,6 @@ LUA_WRAP_INT(nl80211,signal)
LUA_WRAP_INT(nl80211,noise)
LUA_WRAP_INT(nl80211,quality)
LUA_WRAP_INT(nl80211,quality_max)
LUA_WRAP_INT(nl80211,mbssid_support)
LUA_WRAP_STRING(nl80211,mode)
LUA_WRAP_STRING(nl80211,ssid)
LUA_WRAP_STRING(nl80211,bssid)
@ -852,6 +873,7 @@ LUA_WRAP_LIST(nl80211,freqlist)
LUA_WRAP_LIST(nl80211,countrylist)
LUA_WRAP_LIST(nl80211,hwmodelist)
LUA_WRAP_LIST(nl80211,encryption)
LUA_WRAP_LIST(nl80211,mbssid_support)
#endif
/* Wext */
@ -863,7 +885,6 @@ LUA_WRAP_INT(wext,signal)
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)
@ -875,6 +896,7 @@ LUA_WRAP_LIST(wext,freqlist)
LUA_WRAP_LIST(wext,countrylist)
LUA_WRAP_LIST(wext,hwmodelist)
LUA_WRAP_LIST(wext,encryption)
LUA_WRAP_LIST(wext,mbssid_support)
#ifdef USE_WL
/* Broadcom table */

View File

@ -159,7 +159,9 @@ static struct nl80211_msg_conveyor * nl80211_msg(const char *ifname, int cmd, in
if( nl80211_init() < 0 )
goto err;
if( !strncmp(ifname, "radio", 5) )
if( !strncmp(ifname, "phy", 3) )
phyidx = atoi(&ifname[3]);
else if( !strncmp(ifname, "radio", 5) )
phyidx = atoi(&ifname[5]);
else if( !strncmp(ifname, "mon.", 4) )
ifidx = if_nametoindex(&ifname[4]);
@ -414,17 +416,20 @@ out:
static char * nl80211_phy2ifname(const char *ifname)
{
int fd, phyidx = 0;
int fd, phyidx = -1;
char buffer[64];
static char nif[IFNAMSIZ] = { 0 };
DIR *d;
struct dirent *e;
if( !strncmp(ifname, "radio", 5) )
{
if( !strncmp(ifname, "phy", 3) )
phyidx = atoi(&ifname[3]);
else if( !strncmp(ifname, "radio", 5) )
phyidx = atoi(&ifname[5]);
if( phyidx > -1 )
{
if( (d = opendir("/sys/class/net")) != NULL )
{
while( (e = readdir(d)) != NULL )
@ -546,7 +551,7 @@ static void nl80211_hostapd_hup(const char *ifname)
{
int fd, pid = 0;
char buf[32];
char *phy = strncmp(ifname, "phy", 3) ? nl80211_ifname2phy(ifname) : ifname;
char *phy = nl80211_ifname2phy(ifname);
if( phy )
{
@ -1508,8 +1513,8 @@ int nl80211_get_hwmodelist(const char *ifname, int *buf)
if( bands[NL80211_BAND_ATTR_HT_CAPA] )
caps = nla_get_u16(bands[NL80211_BAND_ATTR_HT_CAPA]);
/* Treat HT20/HT40 as 11n */
if( caps & (1 << 1) )
/* Treat any nonzero capability as 11n */
if( caps > 0 )
*buf |= IWINFO_80211_N;
nla_for_each_nested(freq,
@ -1542,7 +1547,18 @@ int nl80211_get_hwmodelist(const char *ifname, int *buf)
int nl80211_get_mbssid_support(const char *ifname, int *buf)
{
/* We assume that multi bssid is always possible */
*buf = 1;
return 0;
/* test whether we can create another interface */
char *nif = nl80211_ifadd(ifname);
if( nif )
{
*buf = (nl80211_ifmac(nif) && nl80211_ifup(nif));
nl80211_ifdown(nif);
nl80211_ifdel(nif);
return 0;
}
return -1;
}