static void flash_firmware(void) { char* svcs[] = { "l2tpd", "xl2tpd", "pppd", "wpa_cli", "wpa_supplicant", NULL }; stop_misc(); stop_services(0); // don't stop httpd/telnetd/sshd/vpn #if (BOARD_NUM_USB_PORTS > 0) stop_usb_printer_spoolers(); safe_remove_usb_device(0, NULL, 0); #endif stop_igmpproxy(NULL); kill_services(svcs, 6, 1); /* save storage (if changed) */ storage_save_time(60); write_storage_to_mtd(); sync(); sleep(1); if (eval("/tmp/mtd_write", "-r", "write", FW_IMG_NAME, FW_MTD_NAME) != 0) { start_watchdog(); } }
static void watchdog_on_timer(void) { int is_ap_mode; /* if timer is set to less than 1 sec, then check buttons only */ if (wd_itv.it_value.tv_sec == 0) { int i_ret = 0; /* handle buttons */ #if defined (BOARD_GPIO_BTN_RESET) i_ret |= btn_check_reset(); #endif #if defined (BOARD_GPIO_BTN_WPS) i_ret |= btn_check_wps(); #endif #if defined (BOARD_GPIO_BTN_WLTOG) i_ret |= btn_check_wlt(); #endif if (i_ret) { if (wd_itv.it_value.tv_usec != WD_URGENT_PERIOD) wd_alarmtimer(0, WD_URGENT_PERIOD); } else { wd_alarmtimer(WD_NORMAL_PERIOD, 0); } return; } is_ap_mode = get_ap_mode(); /* check for time-dependent services */ svc_timecheck(); /* http server check */ httpd_process_check(); /* DNS/DHCP server check */ if (!is_ap_mode) dnsmasq_process_check(); inet_handler(is_ap_mode); /* update kernel timezone daylight */ setkernel_tz(); storage_save_time(10); }
void shutdown_router(int use_reboot) { int is_ap_mode = get_ap_mode(); stop_misc(); stop_services(1); #if (BOARD_NUM_USB_PORTS > 0) stop_usb_printer_spoolers(); safe_remove_usb_device(0, NULL, !use_reboot); #endif #if defined (BOARD_GPIO_LED_USB) LED_CONTROL(BOARD_GPIO_LED_USB, LED_OFF); #endif stop_wan(); stop_services_lan_wan(); set_ipv4_forward(0); #if defined (BOARD_GPIO_LED_WAN) LED_CONTROL(BOARD_GPIO_LED_WAN, LED_OFF); #endif storage_save_time(10); write_storage_to_mtd(); stop_8021x_all(); stop_wifi_all_wl(); stop_wifi_all_rt(); stop_logger(); stop_lan(is_ap_mode); umount_rwfs_partition(); #if defined (BOARD_GPIO_LED_LAN) LED_CONTROL(BOARD_GPIO_LED_LAN, LED_OFF); #endif #if defined (BOARD_GPIO_LED_POWER) LED_CONTROL(BOARD_GPIO_LED_POWER, LED_OFF); #endif if (!use_reboot) module_smart_unload("rt_timer_wdg", 0); }