iwinfo: add phyname attribute, this is useful to group networks by radio phy

SVN-Revision: 36889
lede-17.01
Jo-Philipp Wich 2013-06-09 14:39:14 +00:00
parent cb24c37858
commit bc73ca5619
12 changed files with 95 additions and 3 deletions

View File

@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=libiwinfo
PKG_RELEASE:=45
PKG_RELEASE:=46
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_CONFIG_DEPENDS := \

View File

@ -167,6 +167,7 @@ struct iwinfo_ops {
int (*hardware_id)(const char *, char *);
int (*hardware_name)(const char *, char *);
int (*encryption)(const char *, char *);
int (*phyname)(const char *, char *);
int (*assoclist)(const char *, char *, int *);
int (*txpwrlist)(const char *, char *, int *);
int (*scanlist)(const char *, char *, int *);

View File

@ -41,6 +41,7 @@ int madwifi_get_noise(const char *ifname, int *buf);
int madwifi_get_quality(const char *ifname, int *buf);
int madwifi_get_quality_max(const char *ifname, int *buf);
int madwifi_get_encryption(const char *ifname, char *buf);
int madwifi_get_phyname(const char *ifname, char *buf);
int madwifi_get_assoclist(const char *ifname, char *buf, int *len);
int madwifi_get_txpwrlist(const char *ifname, char *buf, int *len);
int madwifi_get_scanlist(const char *ifname, char *buf, int *len);
@ -72,6 +73,7 @@ static const struct iwinfo_ops madwifi_ops = {
.hardware_id = madwifi_get_hardware_id,
.hardware_name = madwifi_get_hardware_name,
.encryption = madwifi_get_encryption,
.phyname = madwifi_get_phyname,
.assoclist = madwifi_get_assoclist,
.txpwrlist = madwifi_get_txpwrlist,
.scanlist = madwifi_get_scanlist,

View File

@ -83,6 +83,7 @@ int nl80211_get_noise(const char *ifname, int *buf);
int nl80211_get_quality(const char *ifname, int *buf);
int nl80211_get_quality_max(const char *ifname, int *buf);
int nl80211_get_encryption(const char *ifname, char *buf);
int nl80211_get_phyname(const char *ifname, char *buf);
int nl80211_get_assoclist(const char *ifname, char *buf, int *len);
int nl80211_get_txpwrlist(const char *ifname, char *buf, int *len);
int nl80211_get_scanlist(const char *ifname, char *buf, int *len);
@ -114,6 +115,7 @@ static const struct iwinfo_ops nl80211_ops = {
.hardware_id = nl80211_get_hardware_id,
.hardware_name = nl80211_get_hardware_name,
.encryption = nl80211_get_encryption,
.phyname = nl80211_get_phyname,
.assoclist = nl80211_get_assoclist,
.txpwrlist = nl80211_get_txpwrlist,
.scanlist = nl80211_get_scanlist,

View File

@ -42,6 +42,7 @@ int wext_get_noise(const char *ifname, int *buf);
int wext_get_quality(const char *ifname, int *buf);
int wext_get_quality_max(const char *ifname, int *buf);
int wext_get_encryption(const char *ifname, char *buf);
int wext_get_phyname(const char *ifname, char *buf);
int wext_get_assoclist(const char *ifname, char *buf, int *len);
int wext_get_txpwrlist(const char *ifname, char *buf, int *len);
int wext_get_scanlist(const char *ifname, char *buf, int *len);
@ -73,6 +74,7 @@ static const struct iwinfo_ops wext_ops = {
.hardware_id = wext_get_hardware_id,
.hardware_name = wext_get_hardware_name,
.encryption = wext_get_encryption,
.phyname = wext_get_phyname,
.assoclist = wext_get_assoclist,
.txpwrlist = wext_get_txpwrlist,
.scanlist = wext_get_scanlist,

View File

@ -42,6 +42,7 @@ int wl_get_quality(const char *ifname, int *buf);
int wl_get_quality_max(const char *ifname, int *buf);
int wl_get_enctype(const char *ifname, char *buf);
int wl_get_encryption(const char *ifname, char *buf);
int wl_get_phyname(const char *ifname, char *buf);
int wl_get_assoclist(const char *ifname, char *buf, int *len);
int wl_get_txpwrlist(const char *ifname, char *buf, int *len);
int wl_get_scanlist(const char *ifname, char *buf, int *len);
@ -73,6 +74,7 @@ static const struct iwinfo_ops wl_ops = {
.hardware_id = wl_get_hardware_id,
.hardware_name = wl_get_hardware_name,
.encryption = wl_get_encryption,
.phyname = wl_get_phyname,
.assoclist = wl_get_assoclist,
.txpwrlist = wl_get_txpwrlist,
.scanlist = wl_get_scanlist,

View File

@ -512,6 +512,16 @@ static char * print_mbssid_supp(const struct iwinfo_ops *iw, const char *ifname)
return buf;
}
static char * print_phyname(const struct iwinfo_ops *iw, const char *ifname)
{
static char buf[32];
if (!iw->phyname(ifname, buf))
return buf;
return "?";
}
static void print_info(const struct iwinfo_ops *iw, const char *ifname)
{
@ -545,8 +555,9 @@ static void print_info(const struct iwinfo_ops *iw, const char *ifname)
print_txpower_offset(iw, ifname));
printf(" Frequency offset: %s\n",
print_frequency_offset(iw, ifname));
printf(" Supports VAPs: %s\n",
print_mbssid_supp(iw, ifname));
printf(" Supports VAPs: %s PHY name: %s\n",
print_mbssid_supp(iw, ifname),
print_phyname(iw, ifname));
}

View File

@ -625,6 +625,7 @@ LUA_WRAP_STRING(wl,ssid)
LUA_WRAP_STRING(wl,bssid)
LUA_WRAP_STRING(wl,country)
LUA_WRAP_STRING(wl,hardware_name)
LUA_WRAP_STRING(wl,phyname)
LUA_WRAP_STRUCT(wl,mode)
LUA_WRAP_STRUCT(wl,assoclist)
LUA_WRAP_STRUCT(wl,txpwrlist)
@ -653,6 +654,7 @@ LUA_WRAP_STRING(madwifi,ssid)
LUA_WRAP_STRING(madwifi,bssid)
LUA_WRAP_STRING(madwifi,country)
LUA_WRAP_STRING(madwifi,hardware_name)
LUA_WRAP_STRING(madwifi,phyname)
LUA_WRAP_STRUCT(madwifi,mode)
LUA_WRAP_STRUCT(madwifi,assoclist)
LUA_WRAP_STRUCT(madwifi,txpwrlist)
@ -681,6 +683,7 @@ LUA_WRAP_STRING(nl80211,ssid)
LUA_WRAP_STRING(nl80211,bssid)
LUA_WRAP_STRING(nl80211,country)
LUA_WRAP_STRING(nl80211,hardware_name)
LUA_WRAP_STRING(nl80211,phyname)
LUA_WRAP_STRUCT(nl80211,mode)
LUA_WRAP_STRUCT(nl80211,assoclist)
LUA_WRAP_STRUCT(nl80211,txpwrlist)
@ -708,6 +711,7 @@ LUA_WRAP_STRING(wext,ssid)
LUA_WRAP_STRING(wext,bssid)
LUA_WRAP_STRING(wext,country)
LUA_WRAP_STRING(wext,hardware_name)
LUA_WRAP_STRING(wext,phyname)
LUA_WRAP_STRUCT(wext,mode)
LUA_WRAP_STRUCT(wext,assoclist)
LUA_WRAP_STRUCT(wext,txpwrlist)
@ -746,6 +750,7 @@ static const luaL_reg R_wl[] = {
LUA_REG(wl,mbssid_support),
LUA_REG(wl,hardware_id),
LUA_REG(wl,hardware_name),
LUA_REG(wl,phyname),
{ NULL, NULL }
};
#endif
@ -777,6 +782,7 @@ static const luaL_reg R_madwifi[] = {
LUA_REG(madwifi,mbssid_support),
LUA_REG(madwifi,hardware_id),
LUA_REG(madwifi,hardware_name),
LUA_REG(madwifi,phyname),
{ NULL, NULL }
};
#endif
@ -808,6 +814,7 @@ static const luaL_reg R_nl80211[] = {
LUA_REG(nl80211,mbssid_support),
LUA_REG(nl80211,hardware_id),
LUA_REG(nl80211,hardware_name),
LUA_REG(nl80211,phyname),
{ NULL, NULL }
};
#endif
@ -838,6 +845,7 @@ static const luaL_reg R_wext[] = {
LUA_REG(wext,mbssid_support),
LUA_REG(wext,hardware_id),
LUA_REG(wext,hardware_name),
LUA_REG(wext,phyname),
{ NULL, NULL }
};

View File

@ -721,6 +721,26 @@ int madwifi_get_encryption(const char *ifname, char *buf)
return 0;
}
int madwifi_get_phyname(const char *ifname, char *buf)
{
const char *wifidev;
wifidev = madwifi_isvap(ifname, NULL);
if (wifidev)
{
strcpy(buf, wifidev);
return 0;
}
else if (madwifi_iswifi(ifname))
{
strcpy(buf, madwifi_phyname(ifname));
return 0;
}
return -1;
}
int madwifi_get_assoclist(const char *ifname, char *buf, int *len)
{
int bl, tl, noise;

View File

@ -1407,6 +1407,31 @@ int nl80211_get_encryption(const char *ifname, char *buf)
return -1;
}
int nl80211_get_phyname(const char *ifname, char *buf)
{
const char *name;
name = nl80211_ifname2phy(ifname);
if (name)
{
strcpy(buf, name);
return 0;
}
else if ((name = nl80211_phy2ifname(ifname)) != NULL)
{
name = nl80211_ifname2phy(name);
if (name)
{
strcpy(buf, ifname);
return 0;
}
}
return -1;
}
static int nl80211_get_assoclist_cb(struct nl_msg *msg, void *arg)
{

View File

@ -446,6 +446,13 @@ int wext_get_encryption(const char *ifname, char *buf)
return -1;
}
int wext_get_phyname(const char *ifname, char *buf)
{
/* No suitable api in wext */
strcpy(buf, ifname);
return 0;
}
int wext_get_mbssid_support(const char *ifname, int *buf)
{
/* No multi bssid support atm */

View File

@ -321,6 +321,18 @@ int wl_get_encryption(const char *ifname, char *buf)
return 0;
}
int wl_get_phyname(const char *ifname, char *buf)
{
char *p;
strcpy(buf, ifname);
if ((p = strchr(buf, '.')) != NULL)
*p = 0;
return 0;
}
int wl_get_enctype(const char *ifname, char *buf)
{
uint32_t wsec, wpa;