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(); } }
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); }