madwifi.sh now uses radio%d instead of wifi%d as phy interface name since https://dev.openwrt.org/changeset/28785
This confuses libiwinfo which cannot find any radio%d interface. I therefore made a quick hack to replace radio%d to wifi%d in the places where it seems necessary. This is as elegant as it gets for this ;) Signed-off-by: Daniel Golle <[email protected]> --- package/iwinfo/src/iwinfo_madwifi.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/package/iwinfo/src/iwinfo_madwifi.c b/package/iwinfo/src/iwinfo_madwifi.c index 50efcbf..dd2d239 100644 --- a/package/iwinfo/src/iwinfo_madwifi.c +++ b/package/iwinfo/src/iwinfo_madwifi.c @@ -195,9 +195,19 @@ static struct ISO3166_to_CCode { 0x5A57 /* ZW */, 716 }, /* Zimbabwe */ }; +static void unify_phyname(const char *iifname, char *ifname) +{ + if( strlen(iifname) >= 6 && strstr(iifname, "radio") == iifname ) + snprintf(ifname, 9, "wifi%s", &(iifname[5])); + else + strncpy(ifname, iifname, 9); +} -static int madwifi_wrq(struct iwreq *wrq, const char *ifname, int cmd, void *data, size_t len) +static int madwifi_wrq(struct iwreq *wrq, const char *iifname, int cmd, void *data, size_t len) { + char ifname[10]; + unify_phyname(iifname, ifname); + strncpy(wrq->ifr_name, ifname, IFNAMSIZ); if( data != NULL ) @@ -258,11 +268,13 @@ static char * madwifi_isvap(const char *ifname, const char *wifiname) return ret; } -static int madwifi_iswifi(const char *ifname) +static int madwifi_iswifi(const char *iifname) { int ret; char path[32]; struct stat s; + char ifname[10]; + unify_phyname(iifname, ifname); ret = 0; @@ -277,12 +289,14 @@ static int madwifi_iswifi(const char *ifname) return ret; } -static char * madwifi_ifadd(const char *ifname) +static char * madwifi_ifadd(const char *iifname) { char *wifidev = NULL; struct ifreq ifr = { 0 }; struct ieee80211_clone_params cp = { 0 }; static char nif[IFNAMSIZ] = { 0 }; + char ifname[10]; + unify_phyname(iifname, ifname); if( !(wifidev = madwifi_isvap(ifname, NULL)) && madwifi_iswifi(ifname) ) wifidev = (char *)ifname; @@ -1008,12 +1022,14 @@ int madwifi_get_mbssid_support(const char *ifname, int *buf) return -1; } -int madwifi_get_hardware_id(const char *ifname, char *buf) +int madwifi_get_hardware_id(const char *iifname, char *buf) { char vendor[64]; char device[64]; struct iwinfo_hardware_id *ids; struct iwinfo_hardware_entry *e; + char ifname[10]; + unify_phyname(iifname, ifname); if (wext_get_hardware_id(ifname, buf)) return iwinfo_hardware_id_from_mtd((struct iwinfo_hardware_id *)buf); -- 1.7.11.4
pgpHU2ak8fu6m.pgp
Description: PGP signature
_______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/mailman/listinfo/openwrt-devel
