/* Determine type */ static int iwinfo_L_type(lua_State *L) { const char *ifname = luaL_checkstring(L, 1); #ifdef USE_NL80211 if( nl80211_probe(ifname) ) lua_pushstring(L, "nl80211"); else #endif #ifdef USE_MADWIFI if( madwifi_probe(ifname) ) lua_pushstring(L, "madwifi"); else #endif #ifdef USE_WL if( wl_probe(ifname) ) lua_pushstring(L, "wl"); else #endif if( wext_probe(ifname) ) lua_pushstring(L, "wext"); else lua_pushnil(L); return 1; }
const char * iwinfo_type(const char *ifname) { #ifdef USE_NL80211 if (nl80211_probe(ifname)) return "nl80211"; else #endif #ifdef USE_MADWIFI if (madwifi_probe(ifname)) return "madwifi"; else #endif #ifdef USE_WL if (wl_probe(ifname)) return "wl"; else #endif if (wext_probe(ifname)) return "wext"; return NULL; }
int mevent_app_enabled(char *name) { char value[128], comb[32], prefix[8]; char os_name[IFNAMSIZ]; int unit; memset(os_name, 0, sizeof(os_name)); if (nvifname_to_osifname(name, os_name, sizeof(os_name))) return 0; if (wl_probe(os_name) || wl_ioctl(os_name, WLC_GET_INSTANCE, &unit, sizeof(unit))) return 0; if (osifname_to_nvifname(name, prefix, sizeof(prefix))) return 0; strcat(prefix, "_"); /* ignore if disabled */ eapd_safe_get_conf(value, sizeof(value), strcat_r(prefix, "radio", comb)); if (atoi(value) == 0) { EAPD_INFO("MEVENT:ignored interface %s. radio disabled\n", os_name); return 0; } /* ignore if BSS is disabled */ eapd_safe_get_conf(value, sizeof(value), strcat_r(prefix, "bss_enabled", comb)); if (atoi(value) == 0) { EAPD_INFO("MEVENT: ignored interface %s, %s is disabled \n", os_name, comb); return 0; } /* if come to here return enabled */ return 1; }
bool wl_wlif_is_psta(char *ifname) { int32 psta = FALSE; if (wl_probe(ifname) < 0) return FALSE; wl_iovar_getint(ifname, "psta_if", &psta); return psta ? TRUE : FALSE; }
int get_wl_instance(char *name) { int unit; int ret; if (!ifexists(name)) return -1; if (wl_probe(name)) return -1; ret = wl_ioctl(name, WLC_GET_INSTANCE, &unit, sizeof(unit)); // fprintf(stderr,"wl_instance = %d\n",unit); if (ret == 0) return unit; return ret; }
int foreach_wif(int include_vifs, void *param, int (*func)(int idx, int unit, int subunit, void *param)) { char ifnames[256]; char name[64], ifname[64], *next = NULL; int unit = -1, subunit = -1; int i; int ret = 0; snprintf(ifnames, sizeof(ifnames), "%s %s %s %s %s %s %s %s %s %s", nvram_safe_get("lan_ifnames"), nvram_safe_get("lan1_ifnames"), nvram_safe_get("lan2_ifnames"), nvram_safe_get("lan3_ifnames"), nvram_safe_get("wan_ifnames"), nvram_safe_get("wl_ifname"), nvram_safe_get("wl0_ifname"), nvram_safe_get("wl0_vifs"), nvram_safe_get("wl1_ifname"), nvram_safe_get("wl1_vifs")); remove_dups(ifnames, sizeof(ifnames)); sort_list(ifnames, sizeof(ifnames)); i = 0; foreach(name, ifnames, next) { if (nvifname_to_osifname(name, ifname, sizeof(ifname)) != 0) continue; if (wl_probe(ifname) || wl_ioctl(ifname, WLC_GET_INSTANCE, &unit, sizeof(unit))) continue; // Convert eth name to wl name if (osifname_to_nvifname(name, ifname, sizeof(ifname)) != 0) continue; // Slave intefaces have a '.' in the name if (strchr(ifname, '.') && !include_vifs) continue; if (get_ifname_unit(ifname, &unit, &subunit) < 0) continue; ret |= func(i++, unit, subunit, param); } return ret; }
static int build_ifnames(char *type, char *names, int *size) { char name[32], *next; int len = 0; int s; /* open a raw scoket for ioctl */ if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) return -1; /* * go thru all device names (wl<N> il<N> et<N> vlan<N>) and interfaces to * build an interface name list in which each i/f name coresponds to a device * name in device name list. Interface/device name matching rule is device * type dependant: * * wl: by unit # provided by the driver, for example, if eth1 is wireless * i/f and its unit # is 0, then it will be in the i/f name list if * wl0 is in the device name list. * il/et: by mac address, for example, if et0's mac address is identical to * that of eth2's, then eth2 will be in the i/f name list if et0 is * in the device name list. * vlan: by name, for example, vlan0 will be in the i/f name list if vlan0 * is in the device name list. */ foreach (name, type, next) { struct ifreq ifr; int i, unit; char var[32], *mac, ea[ETHER_ADDR_LEN]; /* vlan: add it to interface name list */ if (!strncmp(name, "vlan", 4)) { /* append interface name to list */ len += snprintf(&names[len], *size - len, "%s ", name); continue; } /* others: proceed only when rules are met */ for (i = 1; i <= DEV_NUMIFS; i ++) { /* ignore i/f that is not ethernet */ ifr.ifr_ifindex = i; if (ioctl(s, SIOCGIFNAME, &ifr)) continue; if (ioctl(s, SIOCGIFHWADDR, &ifr)) continue; if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) continue; if (!strncmp(ifr.ifr_name, "vlan", 4)) continue; /* wl: use unit # to identify wl */ if (!strncmp(name, "wl", 2)) { if (wl_probe(ifr.ifr_name) || wl_ioctl(ifr.ifr_name, WLC_GET_INSTANCE, &unit, sizeof(unit)) || unit != atoi(&name[2])) continue; } /* et/il: use mac addr to identify et/il */ else if (!strncmp(name, "et", 2) || !strncmp(name, "il", 2)) { snprintf(var, sizeof(var), "%smacaddr", name); if (!(mac = nvram_get(var)) || !ether_atoe(mac, ea) || memcmp(ea, ifr.ifr_hwaddr.sa_data, ETHER_ADDR_LEN)) continue; // add by Chen-I to filter out wl interface here if (!wl_probe(ifr.ifr_name)) continue; } /* mac address: compare value */ else if (ether_atoe(name, ea) && !memcmp(ea, ifr.ifr_hwaddr.sa_data, ETHER_ADDR_LEN)) ; /* others: ignore */ else continue; /* append interface name to list */ len += snprintf(&names[len], *size - len, "%s ", ifr.ifr_name); } } close(s); *size = len; return 0; }