Exemplo n.º 1
0
int madwifi_get_scanlist(const char *ifname, char *buf, int *len)
{
	int ret;
	char *res;
	DIR *proc;
	struct dirent *e;

	ret = -1;

	/* We got a wifiX device passed, try to lookup a vap on it */
	if( madwifi_iswifi(ifname) )
	{
		if( (proc = opendir("/proc/sys/net/")) != NULL )
		{
			while( (e = readdir(proc)) != NULL )
			{
				if( !!madwifi_isvap(e->d_name, ifname) )
				{
					if( iwinfo_ifup(e->d_name) )
					{
						ret = wext_get_scanlist(e->d_name, buf, len);
						break;
					}
				}
			}

			closedir(proc);
		}

		/* Still nothing found, try to create a vap */
		if( ret == -1 )
		{
			if( (res = madwifi_ifadd(ifname)) != NULL )
			{
				if( iwinfo_ifup(res) )
				{
					wext_get_scanlist(res, buf, len);
					sleep(1);

					wext_get_scanlist(res, buf, len);
					sleep(1);

					ret = wext_get_scanlist(res, buf, len);
				}

				iwinfo_ifdown(res);
				madwifi_ifdel(res);
			}
		}
	}

	/* Got athX device? */
	else if( !!madwifi_isvap(ifname, NULL) )
	{
		ret = wext_get_scanlist(ifname, buf, len);
	}

	return ret;
}
Exemplo n.º 2
0
int wl_get_scanlist(const char *ifname, char *buf, int *len)
{
	return wext_get_scanlist(ifname, buf, len);
}