示例#1
0
static void wpsfix_check(int sig)
{
	int unit;
	time_t now = uptime();

	if (nvram_match("wps_band", "0"))
		unit = 0;
	else
		unit = 1;

	if (((now - up) >= 600) && !wl_WscConfigured(unit))
	{
		stop_wsc();

		nvram_set("wps_sta_pin", "00000000");
		nvram_set("wps_enable", "0");
		nvram_set("wl_wps_mode", "disabled");
		nvram_set("wl0_wps_mode", "disabled");
		nvram_set("wl1_wps_mode", "disabled");

		wpsfix_exit(sig);
	}
	else
		alarmtimer(60, 0);
}
示例#2
0
int 
stop_wps_method(void)
{
	if(getpid()!=1) {
		notify_rc("stop_wps_method");
		return 0;
	}

#ifdef RTCONFIG_WPS_ENROLLEE
	if (nvram_match("wps_enrollee", "1")) {
		stop_wsc_enrollee();
	}
	else
#endif
		stop_wsc();

	return 0;
}
示例#3
0
int asus_ate_command(const char *command, const char *value, const char *value2){
	_dprintf("===[ATE %s %s]===\n", command, value);
	if(!strcmp(command, "Set_StartATEMode")) {
                nvram_set("asus_mfg", "1");
                if(nvram_match("asus_mfg", "1")) {
			puts("1");
#ifdef RTCONFIG_FANCTRL
			stop_phy_tempsense();
#endif
#ifdef TODO
	                stop_wsc();
#endif
        	        stop_lltd();    
                	stop_wanduck();
	                stop_logger();
        	        stop_wanduck();
#ifdef RTCONFIG_DNSMASQ
                	stop_dnsmasq();
#else
	                stop_dns();
	                stop_dhcpd();
#endif
        	        stop_ots();
                	stop_networkmap();
#ifdef RTCONFIG_USB
	                stop_usbled();
#endif
		}
		else
			puts("ATE_ERROR");
                return 0;
        }
        else if (!strcmp(command, "Set_AllLedOn")) {
                return setAllLedOn();
        }
        else if (!strcmp(command, "Set_AllLedOff")) {
                return setAllLedOff();
        }
        else if (!strcmp(command, "Set_AllLedOn_Half")) {
                puts("Not support"); //Need to implement for EA-N66U
                return 0;
        }
        else if (!strcmp(command, "Set_MacAddr_2G")) {
                if( !setMAC_2G(value) )
			puts("ATE_ERROR_INCORRECT_PARAMETER");
		return 0;
        }
        else if (!strcmp(command, "Set_MacAddr_5G")) {
                if( !setMAC_5G(value))
                        puts("ATE_ERROR_INCORRECT_PARAMETER");
                return 0;
        }
        else if (!strcmp(command, "Set_RegulationDomain_2G")) {
                if ( !setCountryCode_2G(value))
			puts("ATE_ERROR_INCORRECT_PARAMETER");
                return 0;
        }
#ifdef CONFIG_BCMWL5
        else if (!strcmp(command, "Set_RegulationDomain_5G")) {
                if ( !setCountryCode_5G(value))
                        puts("ATE_ERROR_INCORRECT_PARAMETER");
                return 0;
        }
        else if (!strcmp(command, "Set_Regrev_2G")) {
                if( !setRegrev_2G(value) )
                        puts("ATE_ERROR_INCORRECT_PARAMETER");
                return 0;
        }
        else if (!strcmp(command, "Set_Regrev_5G")) {
                if( !setRegrev_5G(value))
                        puts("ATE_ERROR_INCORRECT_PARAMETER");
                return 0;
        }
#endif
        else if (!strcmp(command, "Set_PINCode")) {
                if (!setPIN(value))
			puts("ATE_ERROR_INCORRECT_PARAMETER");
                return 0;
        }
        else if (!strcmp(command, "Set_40M_Channel_2G")) {
                if(!set40M_Channel_2G(value))
			puts("ATE_ERROR_INCORRECT_PARAMETER");
                return 0;
        }
        else if (!strcmp(command, "Set_40M_Channel_5G")) {
                if(!set40M_Channel_5G(value))
			puts("ATE_ERROR_INCORRECT_PARAMETER");
                return 0;
        }
#ifdef RTCONFIG_FANCTRL
        else if (!strcmp(command, "Set_FanOn")) {
                setFanOn();
                return 0;
        }
        else if (!strcmp(command, "Set_FanOff")) {
                setFanOff();
                return 0;
        }
#endif
	else if (!strcmp(command, "Set_RestoreDefault")) {
		ResetDefault();
                return 0;
        }
#ifdef CONFIG_BCMWL5
        else if (!strcmp(command, "Set_Commit")) {
                setCommit();
                return 0;
        }
#endif
        else if (!strcmp(command, "Get_FWVersion")) {
	        char fwver[12];
        	sprintf(fwver, "%s.%s", nvram_safe_get("firmver"), nvram_safe_get("buildno"));
	        puts(fwver);
                return 0;
        }
        else if (!strcmp(command, "Get_BootLoaderVersion")) {
                getBootVer();
                return 0;
        }
        else if (!strcmp(command, "Get_ResetButtonStatus")) {
                puts(nvram_safe_get("btn_rst"));
                return 0;
        }
        else if (!strcmp(command, "Get_WpsButtonStatus")) {
                puts(nvram_safe_get("btn_ez"));
                return 0;
        }
        else if (!strcmp(command, "Get_SWMode")) {
                puts(nvram_safe_get("sw_mode"));
                return 0;
        }
        else if (!strcmp(command, "Get_MacAddr_2G")) {
                getMAC_2G();
                return 0;
        }
        else if (!strcmp(command, "Get_MacAddr_5G")) {
                getMAC_5G();
                return 0;
        }
        else if (!strcmp(command, "Get_Usb2p0_Port1_Infor")) {
		Get_USB_Port_Info(1);
                return 0;
        }
        else if (!strcmp(command, "Get_Usb2p0_Port1_Folder")) {
                Get_USB_Port_Folder(1);
                return 0;
        }
        else if (!strcmp(command, "Get_Usb2p0_Port2_Infor")) {
                Get_USB_Port_Info(2);
                return 0;
        }
        else if (!strcmp(command, "Get_Usb2p0_Port2_Folder")) {
                Get_USB_Port_Folder(2);
                return 0;
        }
        else if (!strcmp(command, "Get_Usb3p0_Port1_Infor")) {
                puts("Not support"); //Need to implement
                return 0;
        }
        else if (!strcmp(command, "Get_Usb3p0_Port2_Infor")) {
                puts("Not support"); //Need to implement
                return 0;
        }
        else if (!strcmp(command, "Get_Usb3p0_Port3_Infor")) {
                puts("Not support"); //Need to implement
                return 0;
        }
        else if (!strcmp(command, "Get_SD_Infor")) {
		Get_SD_Card_Info();
                return 0;
        }
        else if (!strcmp(command, "Get_SD_Folder")) {
                Get_SD_Card_Folder();
                return 0;
        }
        else if (!strcmp(command, "Get_RegulationDomain_2G")) {
		getCountryCode_2G();
                return 0;
        }
#ifdef CONFIG_BCMWL5
        else if (!strcmp(command, "Get_RegulationDomain_5G")) {
           	getCountryCode_5G();
                return 0;
        }
	else if (!strcmp(command, "Get_Regrev_2G")) {
		getRegrev_2G();
		return 0;
	}
        else if (!strcmp(command, "Get_Regrev_5G")) {
		getRegrev_5G();
                return 0;
        }
#endif
        else if (!strcmp(command, "Get_PINCode")) {
                getPIN();
                return 0;
        }
        else if (!strcmp(command, "Get_WanLanStatus")) {
                if( !GetPhyStatus())
			puts("ATE_ERROR");
		return 0;
        }
        else if (!strcmp(command, "Get_FwReadyStatus")) {
                puts(nvram_safe_get("success_start_service"));
                return 0;
        }
	else if (!strcmp(command, "Get_Build_Info")) {
		puts(nvram_safe_get("buildinfo"));
		return 0;
	}
#ifdef RTCONFIG_RALINK
        else if (!strcmp(command, "Get_RSSI_2G")) {
                getrssi(0);
                return 0;
        }
        else if (!strcmp(command, "Get_RSSI_5G")) {
                getrssi(1);
                return 0;
        }
#endif
        else if (!strcmp(command, "Get_ChannelList_2G")) {
                puts("Not support"); //Need to implement
                return 0;
        }
        else if (!strcmp(command, "Get_ChannelList_5G")) {
                puts("Not support"); //Need to implement
                return 0;
        }
        else if (!strcmp(command, "Get_Usb3p0_Port1_Folder")) {
                puts("Not support"); //Need to implement
                return 0;
        }
        else if (!strcmp(command, "Get_Usb3p0_Port2_Folder")) {
                puts("Not support"); //Need to implement
                return 0;
        }
        else if (!strcmp(command, "Get_Usb3p0_Port3_Folder")) {
                puts("Not support"); //Need to implement
                return 0;
        }
        else if (!strcmp(command, "Get_Usb3p0_Port1_DataRate")) {
                puts("Not support"); //Need to implement
                return 0;
        }
        else if (!strcmp(command, "Get_Usb3p0_Port2_DataRate")) {
                puts("Not support"); //Need to implement
                return 0;
        }
        else if (!strcmp(command, "Get_Usb3p0_Port3_DataRate")) {
                puts("Not support"); //Need to implement
                return 0;
        }
#ifdef RTCONFIG_RALINK
	else if (!strcmp(command, "Ra_FWRITE")) {
		return FWRITE(value, value2);
	}
        else if (!strcmp(command, "Ra_Asuscfe_2G")) {
                return asuscfe(value, WIF_2G);
        }
        else if (!strcmp(command, "Ra_Asuscfe_5G")) {
		return asuscfe(value, WIF_5G);
        }

#endif
        else 
	{
		puts("ATE_ERROR");
                return EINVAL;
	}
}
示例#4
0
void btn_check(void)
{
#ifdef BTN_SETUP
	if (btn_pressed_setup == BTNSETUP_NONE)
	{
#endif

#ifdef SR3
	if (!ralink_gpio_read_bit(BTN_RESET))	// reset button is on low phase
#else
	if (0)
#endif
	{
	/*--------------- Add BTN_RST MFG test ------------------------*/
		if (!nvram_match("asus_mfg", "0"))
		{
			nvram_set("btn_rst", "1");
		}
		else
		{
			if (!btn_pressed)
			{
				btn_pressed = 1;
				btn_count = 0;
				alarmtimer(0, URGENT_PERIOD);
			}
			else
			{	/* Whenever it is pushed steady */
				if (++btn_count > RESET_WAIT_COUNT)
				{
					dbg("You can release RESET button now!\n");

					btn_pressed = 2;
				}
				if (btn_pressed == 2)
				{
				/* 0123456789 */
				/* 0011100111 */
					if ((btn_count % 10) < 1 || ((btn_count % 10) > 4 && (btn_count % 10) < 7))
						LED_CONTROL(LED_POWER, LED_OFF);
					else
						LED_CONTROL(LED_POWER, LED_ON);
				}
			}
		} // end BTN_RST MFG test
	}
	else
	{
		if (btn_pressed == 1)
		{
			btn_count = 0;
			btn_pressed = 0;
			LED_CONTROL(LED_POWER, LED_ON);
			alarmtimer(NORMAL_PERIOD, 0);
		}
		else if (btn_pressed == 2)
		{
			LED_CONTROL(LED_POWER, LED_OFF);
			alarmtimer(0, 0);
			system("erase /dev/mtd1");
//			kill(1, SIGTERM);
			sys_exit();
		}
	}

#ifdef BTN_SETUP
	}
	if (btn_pressed != 0) return;

	if (btn_pressed_setup < BTNSETUP_START)
	{
		if (!ralink_gpio_read_bit(BTN_WPS) && !no_need_to_start_wps(0))
		{
			/* Add BTN_EZ MFG test */
			if (!nvram_match("asus_mfg", "0"))
			{
				nvram_set("btn_ez", "1");
			}
			else
			{
				if (btn_pressed_setup == BTNSETUP_NONE)
				{
					btn_pressed_setup = BTNSETUP_DETECT;
					btn_count_setup = 0;
					alarmtimer(0, RUSHURGENT_PERIOD);
				}
				else
				{	/* Whenever it is pushed steady */
					if (++btn_count_setup > SETUP_WAIT_COUNT)
					{
						if (!nvram_match("sw_mode_ex", "3"))
						{
							stop_wsc();
							stop_wsc_2g();
							nvram_set("wps_enable", "0");

#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
							nvram_set("wps_triggered", "1");	// psp fix
#endif

							btn_pressed_setup = BTNSETUP_START;
							btn_count_setup = 0;
							btn_count_setup_second = 0;
#if defined (W7_LOGO) || defined (WIFI_LOGO)
							if (nvram_match("wps_band", "0"))
								start_wsc_pbc();
							else
								start_wsc_pbc_2g();
#else
#if 0
							start_wsc_pbc_both();
#else
							nvram_set("wps_band", "1");
							start_wsc_pbc_2g();
#endif
#endif
							WscStatus_old = -1;
							WscStatus_old_2g = -1;
							wsc_timeout = 120*20;
						}
					}
				}
			} // end BTN_EZ MFG test
		} 
		else if (btn_pressed_setup == BTNSETUP_DETECT)
		{
			btn_pressed_setup = BTNSETUP_NONE;
			btn_count_setup = 0;
			LED_CONTROL(LED_POWER, LED_ON);
			alarmtimer(NORMAL_PERIOD, 0);
		}
	}
	else 
	{
		if (!ralink_gpio_read_bit(BTN_WPS) && !no_need_to_start_wps(0))
		{
			/* Whenever it is pushed steady, again... */
			if (++btn_count_setup_second > SETUP_WAIT_COUNT)
			{
				if (!nvram_match("sw_mode_ex", "3"))
				{
					stop_wsc();
					stop_wsc_2g();
					nvram_set("wps_enable", "0");

#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
					nvram_set("wps_triggered", "1");	// psp fix
#endif
					dbg("pushed again...\n");
					btn_pressed_setup = BTNSETUP_START;
					btn_count_setup_second = 0;
#if defined (W7_LOGO) || defined (WIFI_LOGO)
					if (nvram_match("wps_band", "0"))
						start_wsc_pbc();
					else
						start_wsc_pbc_2g();
#else
#if 0
					start_wsc_pbc_both();
#else
					nvram_set("wps_band", "1");
					start_wsc_pbc_2g();
#endif
#endif
					WscStatus_old = -1;
					WscStatus_old_2g = -1;
					wsc_timeout = 120*20;
				}
#if 0
				else
				{
					dbg("pushed again... do nothing...\n");
/*
					btn_pressed_setup = BTNSETUP_START;
					btn_count_setup_second = 0;
					sta_wps_pbc();
					wsc_timeout = 120*20;
*/
				}
#endif
			}
		}

		struct _WSC_CONFIGURED_VALUE wsc_value;
		int int_stop_wps_led = 0;
		int WscStatus = -1;
		int WscStatus_2g = -1;

		if (nvram_match("wps_mode", "1"))	// PIN
		{
			if (nvram_match("wps_band", "0"))
				WscStatus = getWscStatus();
			else
				WscStatus = getWscStatus_2g();
		}
		else					// PBC
		{
			WscStatus = getWscStatus();
			WscStatus_2g = getWscStatus_2g();
		}
		
		if (WscStatus_old != WscStatus)
		{
			WscStatus_old = WscStatus;
			dbg("WscStatus: %d\n", WscStatus);
		}

		if (nvram_match("wps_mode", "2") && WscStatus_old_2g != WscStatus_2g)
		{
			WscStatus_old_2g = WscStatus_2g;
			dbg("WscStatus_2g: %d\n", WscStatus_2g);
		}

		if (WscStatus == 2 || WscStatus_2g == 2)// Wsc Process failed
		{
			if (g_isEnrollee)
				;			// go on monitoring
			else
			{
				int_stop_wps_led = 1;
				dbg("%s", "Error occured. Is the PIN correct?\n");
			}
		}

		// Driver 1.9 supports AP PBC Session Overlapping Detection.
		if (WscStatus == 0x109 /* PBC_SESSION_OVERLAP */ || WscStatus_2g == 0x109)
		{
			dbg("PBC_SESSION_OVERLAP\n");
			int_stop_wps_led = 1;
		}

		if (nvram_match("wps_mode", "1"))	// PIN
		{
			if (WscStatus == 34 /* Configured*/)
			{
/*
				dbg("getWscProfile()\n");
				getWscProfile(WIF, &wsc_value, sizeof(WSC_CONFIGURED_VALUE));
*/
				if (!g_wsc_configured)
					g_wsc_configured = 1;

				int_stop_wps_led = 1;
				g_isEnrollee = 0;
			}
		}
		else					// PBC
		{
			if (WscStatus == 34 /* Configured*/ || WscStatus_2g == 34)
			{
				if (!g_wsc_configured)
					g_wsc_configured = 1;

				int_stop_wps_led = 1;
				g_isEnrollee = 0;
			}
		}

		if (int_stop_wps_led || --wsc_timeout == 0)
		{
			if(!nvram_match("sw_mode_ex", "3"))	// not AP mode
			{
#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
				nvram_set("wps_triggered", "1");// psp fix
#endif
				wsc_timeout = 0;

				btn_pressed_setup = BTNSETUP_NONE;
				btn_count_setup = 0;
				LED_CONTROL(LED_POWER, LED_ON);
				alarmtimer(NORMAL_PERIOD, 0);
#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
//				if (nvram_match("wps_band", "0"))
					stop_wsc();		// psp fix
//				else
					stop_wsc_2g();		// psp fix
				nvram_set("wps_enable", "0");	// psp fix
#endif
			}
			return;
		}

		++btn_count_setup;
		btn_count_setup = (btn_count_setup % 20);

		/* 0123456789 */
		/* 1010101010 */
		if ((btn_count_setup % 2) == 0 && (btn_count_setup > 10))
			LED_CONTROL(LED_POWER, LED_ON);
		else
			LED_CONTROL(LED_POWER, LED_OFF);
	}
#endif
}
示例#5
0
/* wathchdog is runned in NORMAL_PERIOD, 1 seconds
 * check in each NORMAL_PERIOD
 *	1. button
 *
 * check in each NORAML_PERIOD*10
 *
 *      1. ntptime 
 *      2. time-dependent service
 *      3. http-process
 *      4. usb hotplug status
 */
void watchdog(void)
{
	/* handle button */
	btn_check();

	/* if timer is set to less than 1 sec, then bypass the following */
	if (itv.it_value.tv_sec == 0) return;

	if (nvram_match("asus_mfg", "1"))
	{
		system("rmmod hw_nat");
		if (pids("ntp"))
			system("killall -SIGTERM ntp");
		if (pids("ntpclient"))
			system("killall ntpclient");
		if (pids("udhcpc"))
			system("killall -SIGTERM udhcpc");
#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
		if (pids("ots"))
			system("killall ots");
#endif
		stop_wanduck();
		stop_logger();
		stop_upnp();	// it may cause upnp cannot run
		stop_dhcpd();
		stop_dns();
#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
		stop_pspfix();
#endif
		stop_wsc();
		stop_wsc_2g();
		stop_lltd();
		stop_networkmap();
		stop_httpd();
		stop_lpd();
		stop_u2ec();
		kill_pidfile_s("/var/run/linkstatus_monitor.pid", SIGTERM);
		if (pids("detectWan"))
			system("killall detectWan");
#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
		stop_rstats();
		kill_pidfile_s("/var/run/detect_internet.pid", SIGTERM);
#endif
		if (pids("tcpcheck"))
			system("killall -SIGTERM tcpcheck");
#ifdef HTTPD_CHECK
		if (pids("httpdcheck"))
			system("killall -SIGTERM httpdcheck");
#endif
		if (pids("traceroute"))
			system("killall traceroute");
		if (pids("usbled"))
			system("killall -SIGTERM usbled");

		nvram_set("asus_mfg", "2");
	}

#if 0
	// reboot signal checking
	if (nvram_match("reboot", "1"))
	{
		printf("[watchdog] nvram match reboot\n");

		reboot_count++;
		if (reboot_count >= 2) 
		{
//			kill(1, SIGTERM);
			sys_exit();
		}

		return;
	}
#else
	if (nvram_match("reboot", "1")) return;
#endif

	if (stop_service_type_99) return;

	if (!nvram_match("asus_mfg", "0")) return;

	watchdog_period = (watchdog_period + 1) % 10;

	if (watchdog_period) return;

#ifdef BTN_SETUP
	if (btn_pressed_setup >= BTNSETUP_START) return;
#endif

#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
	if (count_to_stop_wps > 0)
	{
		count_to_stop_wps--;

		if (!count_to_stop_wps)
		{
//			if (nvram_match("wl_radio_x", "1"))
			stop_wsc();			// psp fix
//			if (nvram_match("rt_radio_x", "1"))
			stop_wsc_2g();			// psp fix
			nvram_set("wps_enable", "0");	// psp fix
		}
	}
#endif

	ddns_timer = (ddns_timer + 1) % 4320;

	if (nvram_match("asus_debug", "1"))
		mem_timer = (mem_timer + 1) % 60;

	if (!watchdog_count)
		watchdog_count++;
	else if (watchdog_count++ == 1)
	{
#if 0
		if (!strcmp(nvram_safe_get("rc_service"), "restart_upnp"))
			service_handle();
		else
#endif
		if (	nvram_match("router_disable", "0") &&
			nvram_match("upnp_enable", "1") &&
			nvram_match("upnp_started", "0")	)
		{
//			if (has_wan_ip())
			{
				dbg("[watchdog] starting upnp...\n");
				stop_upnp();
				start_upnp();
			}
		}
	}

	/* check for time-dependent services */
	svc_timecheck();

	/* http server check */
	httpd_processcheck();

	u2ec_processcheck();

	media_processcheck();
#if 0
	samba_processcheck();
#endif
	pppd_processcheck();

	if (nvram_match("wan_route_x", "IP_Routed"))
		nm_processcheck();

	cpu_usage_minotor();

	dm_block_chk();

	if (nvram_match("asus_debug", "1") && !mem_timer)
	{
		print_num_of_connections();
		dbg("Hardware NAT: %s\n", is_hwnat_loaded() ? "Enabled": "Disabled");
		dbg("Software QoS: %s\n", nvram_match("qos_enable", "1") ? "Enabled": "Disabled");
		dbg("pppd running: %s\n", pids("pppd") ? "Yes": "No");
#if 0
		dbg("CPU usage: %d%%\n", get_cpu_usage());
#else
		dbg("CPU usage: %d%%\n", cpu_main(0, NULL, 0));
#endif
		system("free");
		system("date");
		print_uptime();
	}

#ifdef CDMA
	/* CDMA_DOWN = 99, none
	 * CDMA_DOWN = 1, currently down
	 * CDMA_DOWN = 2, currently up
	 * CDMA_DOWN = 0, currently trying to connect
	 */
	if (nvram_match("cdma_down", "1"))
	{
		logmessage("CDMA client", "cdma is down(%d)!", cdma_down);

		cdma_down++;
		cdma_connec t = 0;

		if (cdma_down == 2)
		{
			printf("[watchdog] stop wan\n");
			stop_wan();
			start_wan();
		}
		else if (cdma_down >= 12) /* 2 minutes timeout for retry */
		{
			cdma_down = 0;
		}
	}
	else if (nvram_match("cdma_down", "0"))
	{
		logmessage("CDMA client", "cdma try connect(%d)!", cdma_connect);
		cdma_down = 0;
		cdma_connect++;

		if (cdma_connect > 12) /* 2 minitues timeout for connecting */
		{
			nvram_set("cdma_down", "1");
		}
	}
	else
	{
		cdma_down = 0;
		cdma_connect = 0;
	}
#endif

	if (nvram_match("wan_route_x", "IP_Routed"))
	{
		if (!is_phyconnected() || !has_wan_ip())
			return;

		/* sync time to ntp server if necessary */
		if (!nvram_match("wan_dns_t", "") && !nvram_match("wan_gateway_t", ""))
		{
			ntp_timesync();
		}

		if (	nvram_match("ddns_enable_x", "1") && 
			(!nvram_match("ddns_updated", "1") || !ddns_timer)
		)
		{
			logmessage("RT-N56U", "[start ddns] watchdog");
			start_ddns();
		}

		if (!ddns_timer)
		{
			stop_networkmap();
			start_networkmap();
		}
	}
	else
	{
		if (/*!nvram_match("lan_dns_t", "") && */!nvram_match("lan_gateway_t", ""))
			ntp_timesync();
	}
}
示例#6
0
static void catch_sig(int sig)
{
	if (sig == SIGUSR1)
	{
		dbg("[watchdog] Catch SIGUSR1 for rc_service\n");
		if (nvram_get("rc_service"))
			service_handle();
	}
	else if (sig == SIGUSR2)
	{
//		dbg("[watchdog] Catch Reset to Default Signal 2\n");
	}
	else if (sig == SIGTSTP && !nvram_match("sw_mode_ex", "3"))
	{
		if (nvram_match("wps_oob_flag", "1"))
		{
#if defined (W7_LOGO) || defined (WIFI_LOGO)
			if (nvram_match("wps_band", "0"))
				if (nvram_match("wl_radio_x", "0"))
					return;
			else
				if (nvram_match("rt_radio_x", "0"))
					return;
#else
#if 0
			if (nvram_match("wl_radio_x", "0") || nvram_match("rt_radio_x", "0"))
#else
			if (nvram_match("wl_radio_x", "0") && nvram_match("rt_radio_x", "0"))
#endif
				return;
#endif
#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
			nvram_set("wps_triggered", "1");	// psp fix
			count_to_stop_wps = 0;
#endif
			nvram_set("wps_oob_flag", "0");
			wsc_timeout = 0;
			btn_pressed_setup = BTNSETUP_NONE;
			btn_count_setup = 0;
			LED_CONTROL(LED_POWER, LED_ON);
			alarmtimer(NORMAL_PERIOD, 0);

#if defined (W7_LOGO) || defined (WIFI_LOGO)
			if (nvram_match("wps_band", "0"))
				wps_oob();
			else
				wps_oob_2g();
#else
			wps_oob_both();
#endif
			WscStatus_old = -1;
			WscStatus_old_2g = -1;
		}
		else if (nvram_match("wps_start_flag", "3") || nvram_match("wps_start_flag", "4"))	// let the SW push button be the same as the HW push button
		{
#if defined (W7_LOGO) || defined (WIFI_LOGO)
			if (nvram_match("wps_band", "0"))
				if (nvram_match("wl_radio_x", "0"))
					return;
			else
				if (nvram_match("rt_radio_x", "0"))
					return;
#else
#if 0
			if (nvram_match("wl_radio_x", "0") || nvram_match("rt_radio_x", "0"))
#else
			if (nvram_match("wl_radio_x", "0") && nvram_match("rt_radio_x", "0"))
#endif
				return;
#endif
//			if (nvram_match("wl_radio_x", "1"))
			stop_wsc();
//			if (nvram_match("rt_radio_x", "1"))
			stop_wsc_2g();
			nvram_set("wps_enable", "0");
#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
			nvram_set("wps_triggered", "1");	// psp fix
			count_to_stop_wps = 0;
			if (nvram_match("wps_start_flag", "3"))
                                nvram_set("wps_band", "1");
                        else
				nvram_set("wps_band", "0");
#endif
			nvram_set("wps_start_flag", "0");
			alarmtimer(NORMAL_PERIOD, 0);
			btn_pressed_setup = BTNSETUP_START;
			btn_count_setup = 0;
			btn_count_setup_second = 0;
#if defined (W7_LOGO) || defined (WIFI_LOGO)
			if (nvram_match("wps_band", "0"))
				start_wsc_pbc();
			else
				start_wsc_pbc_2g();
#else
#if 0
			start_wsc_pbc_both();
#else
			if (nvram_match("wps_band", "1"))
				start_wsc_pbc_2g();
			else
				start_wsc_pbc();
#endif
#endif
			WscStatus_old = -1;
			WscStatus_old_2g = -1;
			wsc_timeout = 120*20;
			alarmtimer(0, RUSHURGENT_PERIOD);
		}
		else if (nvram_match("wps_enable", "0"))
		{
#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
			nvram_set("wps_triggered", "1");	// psp fix
			count_to_stop_wps = 0;
#endif
			wsc_timeout = 1;
			btn_pressed_setup = BTNSETUP_NONE;
			btn_count_setup = 0;
			LED_CONTROL(LED_POWER, LED_ON);
			alarmtimer(NORMAL_PERIOD, 0);
//			if (nvram_match("wps_band", "0"))
//				if (nvram_match("wl_radio_x", "1"))
					stop_wsc();
//			else
//				if (nvram_match("rt_radio_x", "1"))
					stop_wsc_2g();
		}
		else if (nvram_match("wps_start_flag", "1"))
		{
			if (nvram_match("wps_band", "0"))
				if (nvram_match("wl_radio_x", "0"))
					return;
			else
				if (nvram_match("rt_radio_x", "0"))
					return;

#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
			nvram_set("wps_triggered", "1");	// psp fix
			count_to_stop_wps = 15;
#endif
			nvram_set("wps_start_flag", "0");

			wsc_timeout = 1;
			btn_pressed_setup = BTNSETUP_NONE;
			btn_count_setup = 0;
			LED_CONTROL(LED_POWER, LED_ON);
			alarmtimer(NORMAL_PERIOD, 0);

			WscStatus_old = -1;
			WscStatus_old_2g = -1;
			if (nvram_match("wps_band", "0"))
				start_wsc();
			else
				start_wsc_2g();
		}
		else if (nvram_match("wps_start_flag", "2"))
		{
			if (nvram_match("wps_mode", "1"))
			{
				if (nvram_match("wps_band", "0"))
					if (nvram_match("wl_radio_x", "0"))
						return;
				else
					if (nvram_match("rt_radio_x", "0"))
						return;
			}
			else
			{
#if defined (W7_LOGO) || defined (WIFI_LOGO)
				if (nvram_match("wps_band", "0"))
					if (nvram_match("wl_radio_x", "0"))
						return;
				else
					if (nvram_match("rt_radio_x", "0"))
						return;
#else
#if 0
				if (nvram_match("wl_radio_x", "0") || nvram_match("rt_radio_x", "0"))
#else
				if (nvram_match("wl_radio_x", "0") && nvram_match("rt_radio_x", "0"))
#endif
					return;
#endif
			}

#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
			nvram_set("wps_triggered", "1");	// psp fix
			count_to_stop_wps = 0;
#endif
			nvram_set("wps_start_flag", "0");
			alarmtimer(NORMAL_PERIOD, 0);
			btn_pressed_setup = BTNSETUP_START;
			btn_count_setup = 0;

			if (nvram_match("wps_mode", "1"))
			{
				if (nvram_match("wps_pin_web", ""))
				{
					if (nvram_match("wps_band", "0"))
						wps_pin("0");
					else
						wps_pin_2g("0");
				}
				else
				{
					if (nvram_match("wps_band", "0"))
						wps_pin(nvram_safe_get("wps_pin_web"));
					else
						wps_pin_2g(nvram_safe_get("wps_pin_web"));
				}
			}
			else
			{
#if defined (W7_LOGO) || defined (WIFI_LOGO)
				if (nvram_match("wps_band", "0"))
					wps_pbc();
				else
					wps_pbc_2g();
#else
#if 0
				wps_pbc_both();
#else
				nvram_set("wps_band", "1");
				wps_pbc_2g();
#endif
#endif
			}

			WscStatus_old = -1;
			WscStatus_old_2g = -1;
			wsc_timeout = 120*20;
			alarmtimer(0, RUSHURGENT_PERIOD);
		}
	}
	else if (sig == SIGTTIN)
	{
		wsc_user_commit();
	}
}