Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
/*
 * Get LAN or WAN ifname by wl mac
 * NOTE: We pass ifname in case of same mac in vifs (like URE TR mode)
 */
char *
get_ifname_by_wlmac(unsigned char *mac, char *name)
{
    char nv_name[16], os_name[16], if_name[16];
    char tmptr[] = "lanXX_ifnames";
    char *ifnames, *ifname;
    int i;

    /*
      * In case of URE mode, wl0.1 and wl0 have same mac,
      * we need extra identity (name).
      */
    if (name && !strncmp(name, "wl", 2))
        snprintf(nv_name, sizeof(nv_name), "%s", name);
    else if (get_wlname_by_mac(mac, nv_name))
        return 0;

    if (nvifname_to_osifname(nv_name, os_name, sizeof(os_name)) < 0)
        return 0;

    if (osifname_to_nvifname(os_name, nv_name, sizeof(nv_name)) < 0)
        return 0;

    /* find for lan */
    for (i = 0; i < WLIFU_MAX_NO_BRIDGE; i++) {
        if (i == 0) {
            ifnames = nvram_get("lan_ifnames");
            ifname = nvram_get("lan_ifname");
            if (ifname) {
                /* the name in ifnames may nvifname or osifname */
                if (find_in_list(ifnames, nv_name) ||
                        find_in_list(ifnames, os_name))
                    return ifname;
            }
        }
        else {
            sprintf(if_name, "lan%d_ifnames", i);
            sprintf(tmptr, "lan%d_ifname", i);
            ifnames = nvram_get(if_name);
            ifname = nvram_get(tmptr);
            if (ifname) {
                /* the name in ifnames may nvifname or osifname */
                if (find_in_list(ifnames, nv_name) ||
                        find_in_list(ifnames, os_name))
                    return ifname;
            }
        }
    }

    /* find for wan  */
    ifnames = nvram_get("wan_ifnames");
    ifname = nvram_get("wan0_ifname");
    /* the name in ifnames may nvifname or osifname */
    if (find_in_list(ifnames, nv_name) ||
            find_in_list(ifnames, os_name))
        return ifname;

    return 0;
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
int
get_spoof_ifname(char *mac, char *osifname, int osifnamelen)
{
    int idx, unit, subunit;
    char nvifname[16];
    wlif_name_desc_t *wlif_name;

    if (osifname == NULL ||
            mac == NULL)
        return -1;

    if (mac[0] != 0 || mac[1] != 0 ||
            mac[2] != 0)
        return -1; /* is a real mac, fast check */

    idx = mac[3];
    idx --; /* map to wlif_name_array index */
    unit = mac[4];
    subunit = mac[5];
    if (idx < 0 || idx >= ARRAYSIZE(wlif_name_array))
        return -1;

    /* get nvname format */
    wlif_name = &wlif_name_array[idx];
    if (wlif_name->subunit)
        snprintf(nvifname, sizeof(nvifname), "%s%d.%d", (wlif_name->wds) ? "wds" : "wl",
                 unit, subunit);
    else
        snprintf(nvifname, sizeof(nvifname), "wl%d", unit);

    /* translate to osifname */
    if (nvifname_to_osifname(nvifname, osifname, osifnamelen) < 0)
        return -1;

    return 0;
}