From: Jo-Philipp Wich Date: Sun, 9 Jun 2013 14:39:14 +0000 (+0000) Subject: iwinfo: add phyname attribute, this is useful to group networks by radio phy X-Git-Tag: reboot~10255 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=bc73ca56198ce61623db3061e00c1d246d1e20a5;p=openwrt%2Fstaging%2Fpepe2k.git iwinfo: add phyname attribute, this is useful to group networks by radio phy SVN-Revision: 36889 --- diff --git a/package/network/utils/iwinfo/Makefile b/package/network/utils/iwinfo/Makefile index 018832fffc..aa534112ed 100644 --- a/package/network/utils/iwinfo/Makefile +++ b/package/network/utils/iwinfo/Makefile @@ -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 := \ diff --git a/package/network/utils/iwinfo/src/include/iwinfo.h b/package/network/utils/iwinfo/src/include/iwinfo.h index 0d92d8db1e..ebea319d10 100644 --- a/package/network/utils/iwinfo/src/include/iwinfo.h +++ b/package/network/utils/iwinfo/src/include/iwinfo.h @@ -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 *); diff --git a/package/network/utils/iwinfo/src/include/iwinfo/madwifi.h b/package/network/utils/iwinfo/src/include/iwinfo/madwifi.h index 14d81352b7..3662d9f95f 100644 --- a/package/network/utils/iwinfo/src/include/iwinfo/madwifi.h +++ b/package/network/utils/iwinfo/src/include/iwinfo/madwifi.h @@ -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, diff --git a/package/network/utils/iwinfo/src/include/iwinfo/nl80211.h b/package/network/utils/iwinfo/src/include/iwinfo/nl80211.h index 28545141d0..0611feed3c 100644 --- a/package/network/utils/iwinfo/src/include/iwinfo/nl80211.h +++ b/package/network/utils/iwinfo/src/include/iwinfo/nl80211.h @@ -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, diff --git a/package/network/utils/iwinfo/src/include/iwinfo/wext.h b/package/network/utils/iwinfo/src/include/iwinfo/wext.h index 68b596ea8b..e84f6a6f92 100644 --- a/package/network/utils/iwinfo/src/include/iwinfo/wext.h +++ b/package/network/utils/iwinfo/src/include/iwinfo/wext.h @@ -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, diff --git a/package/network/utils/iwinfo/src/include/iwinfo/wl.h b/package/network/utils/iwinfo/src/include/iwinfo/wl.h index db37e3759d..077a51bbd4 100644 --- a/package/network/utils/iwinfo/src/include/iwinfo/wl.h +++ b/package/network/utils/iwinfo/src/include/iwinfo/wl.h @@ -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, diff --git a/package/network/utils/iwinfo/src/iwinfo_cli.c b/package/network/utils/iwinfo/src/iwinfo_cli.c index 8da216a6ef..87cc10fb73 100644 --- a/package/network/utils/iwinfo/src/iwinfo_cli.c +++ b/package/network/utils/iwinfo/src/iwinfo_cli.c @@ -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)); } diff --git a/package/network/utils/iwinfo/src/iwinfo_lua.c b/package/network/utils/iwinfo/src/iwinfo_lua.c index bd8faf91fe..fc4fd4a126 100644 --- a/package/network/utils/iwinfo/src/iwinfo_lua.c +++ b/package/network/utils/iwinfo/src/iwinfo_lua.c @@ -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 } }; diff --git a/package/network/utils/iwinfo/src/iwinfo_madwifi.c b/package/network/utils/iwinfo/src/iwinfo_madwifi.c index 832f40bd3d..293c28e7d1 100644 --- a/package/network/utils/iwinfo/src/iwinfo_madwifi.c +++ b/package/network/utils/iwinfo/src/iwinfo_madwifi.c @@ -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; diff --git a/package/network/utils/iwinfo/src/iwinfo_nl80211.c b/package/network/utils/iwinfo/src/iwinfo_nl80211.c index 051d34dd1c..9486ffc3f9 100644 --- a/package/network/utils/iwinfo/src/iwinfo_nl80211.c +++ b/package/network/utils/iwinfo/src/iwinfo_nl80211.c @@ -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) { diff --git a/package/network/utils/iwinfo/src/iwinfo_wext.c b/package/network/utils/iwinfo/src/iwinfo_wext.c index cf3dccc189..890a36d2f0 100644 --- a/package/network/utils/iwinfo/src/iwinfo_wext.c +++ b/package/network/utils/iwinfo/src/iwinfo_wext.c @@ -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 */ diff --git a/package/network/utils/iwinfo/src/iwinfo_wl.c b/package/network/utils/iwinfo/src/iwinfo_wl.c index 3d15fc9ca7..0a1439bb89 100644 --- a/package/network/utils/iwinfo/src/iwinfo_wl.c +++ b/package/network/utils/iwinfo/src/iwinfo_wl.c @@ -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;