Beispiel #1
0
void start_radius(char *prefix)
{

	// wrt-radauth $IFNAME $server $port $share $override $mackey $maxun &

	if (nvram_nmatch("1", "%s_radauth", prefix)
	    && nvram_nmatch("ap", "%s_mode", prefix)) {
		char *server = nvram_nget("%s_radius_ipaddr", prefix);
		char *port = nvram_nget("%s_radius_port", prefix);
		char *share = nvram_nget("%s_radius_key", prefix);
		char *ifname = nvram_nget("%s_ifname", prefix);
		char type[32];

		sprintf(type, "%s_radmactype", prefix);
		char *pragma = "";

		if (nvram_default_match(type, "0", "0"))
			pragma = "-n1 ";
		if (nvram_match(type, "1"))
			pragma = "-n2 ";
		if (nvram_match(type, "2"))
			pragma = "-n3 ";
		if (nvram_match(type, "3"))
			pragma = "";
		sleep(1);	// some delay is usefull
		sysprintf("wrt-radauth %s %s %s %s %s %s %s %s &", pragma,
			  ifname, server, port, share, nvram_nget("%s_radius_override", prefix), nvram_nget("%s_radmacpassword", prefix), nvram_nget("%s_max_unauth_users", prefix));
	}

}
Beispiel #2
0
static void convert_wds(int instance)
{
	char wds_mac[254];
	char buf[254];

	if (nvram_nmatch("", "wl%d_wds", instance))	// For Router, accept 
		// all WDS link
		strcpy(wds_mac, "*");
	else			// For AP, assign remote WDS MAC
		strcpy(wds_mac, nvram_nget("wl%d_wds", instance));

	/*
	 * For WPA-PSK mode, we want to convert wl_wds_mac to wl0_wds0 ...
	 * wl0_wds255 
	 */
	if (nvram_nmatch("psk", "wl%d_security_mode", instance)
	    || nvram_nmatch("psk2", "wl%d_security_mode", instance)) {
		int i = 0;
		int j;
		char mac[254];
		char *next;

		foreach(mac, wds_mac, next) {
			snprintf(buf, sizeof(buf), "%s,auto,%s,%s,%s,%s",
				 mac, nvram_nget("wl%d_crypto", instance), nvram_nget("wl%d_security_mode", instance), nvram_nget("wl%d_ssid", instance), nvram_nget("wl%d_wpa_psk", instance));
			nvram_nset(buf, "wl%d_wds%d", instance, i);
			i++;
		}
Beispiel #3
0
void start_igmp_proxy(void)
{
	int ret = 0;
	pid_t pid;
	char name[80], *next, *svbuf;
	char *argv[] = { "igmprt", "/tmp/igmpproxy.conf", NULL };

	int ifcount = 0;

	FILE *fp = fopen("/tmp/igmpproxy.conf", "wb");

	if (nvram_match("dtag_vlan8", "1") && nvram_match("wan_vdsl", "1")) {
		fprintf(fp, "quickleave\nphyint %s upstream  ratelimit 0  threshold 1\n", nvram_safe_get("tvnicfrom"));
		fprintf(fp, "phyint %s disabled\n", get_wan_face());
	} else {
		fprintf(fp, "quickleave\nphyint %s upstream  ratelimit 0  threshold 1\n", get_wan_face());
	}
	if (nvram_match("block_multicast", "0")) {
		fprintf(fp, "phyint %s downstream  ratelimit 0  threshold 1\n", nvram_safe_get("lan_ifname"));
		ifcount++;
	} else {
		fprintf(fp, "phyint %s disabled\n" "phyint %s:0 disabled\n", nvram_safe_get("lan_ifname"), nvram_safe_get("lan_ifname"));
	}
	char ifnames[256];

	getIfLists(ifnames, 256);
	foreach(name, ifnames, next) {
		if (strcmp(get_wan_face(), name)
		    && strcmp(nvram_safe_get("lan_ifname"), name)
		    && strcmp(nvram_safe_get("tvnicfrom"), name)) {
			if (nvram_nmatch("0", "%s_bridged", name)
			    && nvram_nmatch("1", "%s_multicast", name)) {
				fprintf(fp, "phyint %s downstream  ratelimit 0  threshold 1\n", name);
				ifcount++;
			} else
				fprintf(fp, "phyint %s disabled\n", name);
		}
	}
	fprintf(fp, "phyint lo disabled\n");
	fclose(fp);
	if (nvram_match("wan_proto", "disabled"))	// todo: add upstream 
		// config
	{
		// ret = _evalpid (igmp_proxybr_argv, NULL, 0, &pid);
		return;
	} else {
		if (ifcount) {
			if (pidof("igmprt") < 1)
				ret = _evalpid(argv, NULL, 0, &pid);
			dd_syslog(LOG_INFO, "igmprt : multicast daemon successfully started\n");
		}
	}

	cprintf("done\n");
	return;
}
Beispiel #4
0
static int client_bridged_enabled(void)
{
	// enumerate all possible interfaces
	char iflist[256];
	iflist[0] = 0;		// workaround for bug in getIfList()
	getIfList(iflist, NULL);

	static char word[256];
	char *next;
	int bridged_clients = 0;

	// any interface in client_bridged mode?
	foreach(word, iflist, next)
	    if (nvram_nmatch("wet", "%s_mode", word))
		bridged_clients++;

	return bridged_clients;
}
Beispiel #5
0
void readWL(wiviz_cfg * cfg)
{
	int ap, i;
	wiviz_host *host, *sta;
	uchar mac[6];
	wlc_ssid_t ssid;
	channel_info_t channel;
	maclist_t *macs;
	sta_rssi_t starssi;
	char buf[32];

	get_mac(wl_dev, mac);
	printf("AP mac: ");
#ifdef NEED_PRINTF
	print_mac(mac, "\n");
#endif
	if (!nonzeromac(mac))
		return;
#ifdef HAVE_RT2880
	if (nvram_match("ap", "wl0_oldmode"))
		ap = 1;
#else
	if (nvram_nmatch("ap", "%s_mode", wl_dev))
		ap = 1;
	if (nvram_nmatch("wdsap", "%s_mode", wl_dev))
		ap = 1;
#endif
//      wl_ioctl(wl_dev, WLC_GET_AP, &ap, 4);
	if (ap) {
		host = gotHost(cfg, mac, typeAP);
		host->isSelf = 1;
#if defined(HAVE_MADWIFI) || defined(HAVE_RT2880)
#ifdef HAVE_RT2880
		strcpy(host->apInfo->ssid, nvram_safe_get("wl0_ssid"));
		host->apInfo->ssidlen = strlen(host->apInfo->ssid);
		ether_atoe(nvram_safe_get("wl0_hwaddr"), buf);
		memcpy(host->apInfo->bssid, buf, 6);
#else
		strcpy(host->apInfo->ssid, nvram_nget("%s_ssid", wl_dev));
		host->apInfo->ssidlen = strlen(host->apInfo->ssid);
		ether_atoe(nvram_nget("%s_hwaddr", wl_dev), buf);
		memcpy(host->apInfo->bssid, buf, 6);
#endif
#else
		wl_ioctl(wl_dev, WLC_GET_BSSID, host->apInfo->bssid, 6);
		wl_ioctl(wl_dev, WLC_GET_SSID, &ssid, sizeof(wlc_ssid_t));
		memcpy(host->apInfo->ssid, ssid.SSID, 32);
		host->apInfo->ssidlen = ssid.SSID_len;
#endif
		host->RSSI = 0;
#ifdef HAVE_MADWIFI
		host->apInfo->channel = wifi_getchannel(wl_dev);
#elif HAVE_RT2880
		host->apInfo->channel = atoi(nvram_safe_get("wl0_channel"));
#else
		wl_ioctl(wl_dev, WLC_GET_CHANNEL, &channel, sizeof(channel_info_t));
		host->apInfo->channel = channel.hw_channel;
#endif

		macs = (maclist_t *) malloc(4 + MAX_STA_COUNT * sizeof(ether_addr_t));
		macs->count = MAX_STA_COUNT;
		int code = getassoclist(wl_dev, macs);
		printf("code :%d\n", code);
		if (code > 0) {
			for (i = 0; i < macs->count; i++) {
				sta = gotHost(cfg, (char *)&macs->ea[i], typeSta);
#ifdef HAVE_MADWIFI
				sta->RSSI = -getRssi(wl_dev, macs->ea) * 100;
#elif HAVE_RT2880
				sta->RSSI = -getRssi(wl_dev, macs->ea) * 100;	// needs to be solved                            
#else
				memcpy(starssi.mac, &macs->ea[i], 6);
				starssi.RSSI = 3000;
				starssi.zero_ex_forty_one = 0x41;
				if (wl_ioctl(wl_dev, WLC_GET_RSSI, &starssi, 12) < 0)
					printf("rssifail\n");
				sta->RSSI = -starssi.RSSI * 100;
#endif
				sta->staInfo->state = ssAssociated;
				memcpy(sta->staInfo->connectedBSSID, host->apInfo->bssid, 6);
			}
		}
	} else {
		host = gotHost(cfg, mac, typeSta);
		host->isSelf = 1;
		host->RSSI = 0;
#if defined(HAVE_MADWIFI) || defined(HAVE_RT2880)
		if (getassoclist(wl_dev, macs) > -1) {
			if (macs->count > 0) {
				host->staInfo->state = ssUnassociated;
			} else {
				host->staInfo->state = ssAssociated;
			}
		} else {
			host->staInfo->state = ssUnassociated;

		}

#else
		if (wl_ioctl(wl_dev, WLC_GET_BSSID, &host->staInfo->connectedBSSID, 6) < 0) {
			host->staInfo->state = ssUnassociated;
		} else {
			host->staInfo->state = ssAssociated;
		}
#endif
	}
#if defined(HAVE_MADWIFI) || defined(HAVE_RT2880)
	cfg->curChannel = wifi_getchannel(wl_dev);

#else
	if (wl_ioctl(wl_dev, WLC_GET_CHANNEL, &channel, sizeof(channel_info_t)) >= 0) {
		cfg->curChannel = channel.hw_channel;
		printf("Current channel is %i\n", cfg->curChannel);
	}
#endif
}