Example #1
0
void load_sysparam(void)
{
	char macstr[32];
#if defined(RTCONFIG_WIRELESSREPEATER) || defined(RTCONFIG_PROXYSTA)
	char tmp[100], prefix[] = "wlXXXXXXXXXXXXXX";
#endif
#ifdef RTCONFIG_WIRELESSREPEATER
	if (nvram_get_int("sw_mode") == SW_MODE_REPEATER)
	{
		snprintf(prefix, sizeof(prefix), "wl%d.1_", nvram_get_int("wlc_band"));
		strncpy(ssid_g, nvram_safe_get(strcat_r(prefix, "ssid", tmp)), sizeof(ssid_g));
	}
	else
#endif
#ifdef RTCONFIG_BCMWL6
#ifdef RTCONFIG_PROXYSTA
	if (is_psta(0) || is_psta(1))
	{
		snprintf(prefix, sizeof(prefix), "wl%d_", 1 - nvram_get_int("wlc_band"));
		strncpy(ssid_g, nvram_safe_get(strcat_r(prefix, "ssid", tmp)), 32);
	}
	else
#endif
#endif
	strncpy(ssid_g, nvram_safe_get("wl0_ssid"), sizeof(ssid_g));
	strncpy(netmask_g, nvram_safe_get("lan_netmask"), sizeof(netmask_g));
	strncpy(productid_g, get_productid(), sizeof(productid_g));

	snprintf(firmver_g, sizeof(firmver_g), "%s.%s", nvram_safe_get("firmver"), nvram_safe_get("buildno"));

	strcpy(macstr, nvram_safe_get("lan_hwaddr"));
//	printf("mac: %d\n", strlen(macstr));
	if (strlen(macstr)!=0) ether_atoe(macstr, mac);
}
Example #2
0
int 
psta_monitor_main(int argc, char *argv[])
{
	FILE *fp;
	sigset_t sigs_to_catch;
	if (!is_psta(0) && !is_psta(1))
		return 0;
#ifdef RTCONFIG_QTN
	if (nvram_get_int("wlc_band") == 1)
		return 0;
#endif
	/* write pid */
	if ((fp = fopen("/var/run/psta_monitor.pid", "w")) != NULL)
	{
		fprintf(fp, "%d", getpid());
		fclose(fp);
	}

	if (nvram_match("psta_debug", "1"))
		psta_debug = 1;

	/* set the signal handler */
	sigemptyset(&sigs_to_catch);
	sigaddset(&sigs_to_catch, SIGALRM);
	sigaddset(&sigs_to_catch, SIGTERM);
	sigprocmask(SIG_UNBLOCK, &sigs_to_catch, NULL);

	signal(SIGALRM, psta_monitor);
	signal(SIGTERM, psta_monitor_exit);

	alarm(NORMAL_PERIOD);

	/* Most of time it goes to sleep */
	while (1)
	{
		pause();
	}

	return 0;
}