static void nvram_convert_misc_values(void) { char buff[64]; int sw_mode; /* check router mode */ sw_mode = nvram_get_int("sw_mode"); if (sw_mode == 1) { /* Internet gateway mode */ nvram_set_int("wan_nat_x", 1); nvram_set("wan_route_x", "IP_Routed"); } else if (sw_mode == 4) { /* Pure router mode */ nvram_set_int("wan_nat_x", 0); nvram_set("wan_route_x", "IP_Routed"); } else if (sw_mode == 3) { /* AP mode (Ethernet convertor) */ nvram_set_int("wan_nat_x", 0); nvram_set("wan_route_x", "IP_Bridged"); } else { nvram_set_int("sw_mode", 1); nvram_set_int("wan_nat_x", 1); nvram_set("wan_route_x", "IP_Routed"); } if (strlen(nvram_wlan_get("wl", "ssid")) < 1) nvram_wlan_set("wl", "ssid", DEF_WLAN_5G_SSID); if (strlen(nvram_wlan_get("rt", "ssid")) < 1) nvram_wlan_set("rt", "ssid", DEF_WLAN_5G_SSID); memset(buff, 0, sizeof(buff)); char_to_ascii(buff, nvram_wlan_get("wl", "ssid")); nvram_wlan_set("wl", "ssid2", buff); memset(buff, 0, sizeof(buff)); char_to_ascii(buff, nvram_wlan_get("rt", "ssid")); nvram_wlan_set("rt", "ssid2", buff); if (strlen(nvram_safe_get("wl_wpa_mode")) < 1) nvram_set_int("wl_wpa_mode", 0); if (strlen(nvram_safe_get("wl_gmode")) < 1) nvram_set_int("wl_gmode", 2); // a/n Mixed if (strlen(nvram_safe_get("rt_gmode")) < 1) nvram_set_int("rt_gmode", 2); // b/g/n Mixed if (nvram_get_int("wl_HT_BW") > 1) nvram_set_int("wl_HT_BW", 1); if (nvram_get_int("rt_HT_BW") > 1) nvram_set_int("rt_HT_BW", 1); if (nvram_get_int("wl_stream_tx") > BOARD_NUM_ANT_5G_TX) nvram_set_int("wl_stream_tx", BOARD_NUM_ANT_5G_TX); if (nvram_get_int("wl_stream_rx") > BOARD_NUM_ANT_5G_RX) nvram_set_int("wl_stream_rx", BOARD_NUM_ANT_5G_RX); if (nvram_get_int("rt_stream_tx") > BOARD_NUM_ANT_2G_TX) nvram_set_int("rt_stream_tx", BOARD_NUM_ANT_2G_TX); if (nvram_get_int("rt_stream_rx") > BOARD_NUM_ANT_2G_RX) nvram_set_int("rt_stream_rx", BOARD_NUM_ANT_2G_RX); nvram_set_temp("ntpc_counter", "0000000000"); nvram_set_temp("login_timestamp", "0000000000"); nvram_set_int_temp("networkmap_fullscan", 0); nvram_set_int_temp("link_internet", 2); nvram_set_int_temp("link_wan", 0); nvram_set_int_temp("reload_svc_wl", 0); nvram_set_int_temp("reload_svc_rt", 0); nvram_set_int_temp("usb_hotplug_ms", 0); nvram_set_int_temp("usb_hotplug_lp", 0); nvram_set_int_temp("usb_hotplug_md", 0); nvram_set_int_temp("usb_unplug_lp", 0); nvram_set_int_temp("usb_unplug_md", 0); nvram_set_int_temp("usb_opt_start", 0); nvram_set_int_temp("l2tp_wan_t", 0); nvram_set_int_temp("l2tp_cli_t", 0); nvram_set_int_temp("l2tp_srv_t", 0); nvram_set_int_temp("vpnc_state_t", 0); nvram_set_temp("deferred_wanup_t", "0000000000"); nvram_set_temp("vpnc_dns_t", ""); nvram_set_temp("viptv_ifname", ""); /* setup wan0 variables */ set_wan0_vars(); set_wan_unit_value(0, "uptime", "0000000000"); set_wan_unit_value(0, "dltime", "0000000000"); set_wan_unit_value(0, "bytes_rx", "00000000000000000000"); set_wan_unit_value(0, "bytes_tx", "00000000000000000000"); set_wan_unit_value(0, "ifname_t", ""); set_usb_modem_dev_wan(0, 0); reset_wan_vars(); /* setup lan variables */ reset_lan_vars(); reset_lan_temp(); time_zone_x_mapping(); }
static void nvram_convert_misc_values(void) { char buff[64]; int sw_mode; #if defined (BOARD_GPIO_BTN_ROUTER) int i_router_switch = BTN_PRESSED; if (cpu_gpio_get_pin(BOARD_GPIO_BTN_ROUTER, &i_router_switch) >= 0) { if (i_router_switch != BTN_PRESSED) nvram_set_int("sw_mode", 3); } #endif /* check router mode */ sw_mode = nvram_get_int("sw_mode"); if (sw_mode == 1) { /* Internet gateway mode */ nvram_set_int("wan_nat_x", 1); nvram_set("wan_route_x", "IP_Routed"); } else if (sw_mode == 4) { /* Pure router mode */ nvram_set_int("wan_nat_x", 0); nvram_set("wan_route_x", "IP_Routed"); } else if (sw_mode == 3) { /* AP mode (Ethernet convertor) */ nvram_set_int("wan_nat_x", 0); nvram_set("wan_route_x", "IP_Bridged"); } else { sw_mode = 1; nvram_set_int("sw_mode", 1); nvram_set_int("wan_nat_x", 1); nvram_set("wan_route_x", "IP_Routed"); } #if defined (BOARD_GPIO_LED_ROUTER) if (sw_mode != 3) LED_CONTROL(BOARD_GPIO_LED_ROUTER, LED_ON); #endif #if BOARD_HAS_5G_RADIO if (strlen(nvram_wlan_get(1, "ssid")) < 1) nvram_wlan_set(1, "ssid", DEF_WLAN_5G_SSID); memset(buff, 0, sizeof(buff)); char_to_ascii(buff, nvram_wlan_get(1, "ssid")); nvram_wlan_set(1, "ssid2", buff); if (strlen(nvram_wlan_get(1, "wpa_mode")) < 1) nvram_wlan_set_int(1, "wpa_mode", 0); #if BOARD_HAS_5G_11AC if (strlen(nvram_wlan_get(1, "gmode")) < 1) nvram_wlan_set_int(1, "gmode", 4); // a/n/ac Mixed if (nvram_wlan_get_int(1, "HT_BW") > 2) nvram_wlan_set_int(1, "HT_BW", 2); #else if (strlen(nvram_wlan_get(1, "gmode")) < 1) nvram_wlan_set_int(1, "gmode", 2); // a/n Mixed if (nvram_wlan_get_int(1, "HT_BW") > 1) nvram_wlan_set_int(1, "HT_BW", 1); #endif if (nvram_wlan_get_int(1, "stream_tx") > BOARD_NUM_ANT_5G_TX) nvram_wlan_set_int(1, "stream_tx", BOARD_NUM_ANT_5G_TX); if (nvram_wlan_get_int(1, "stream_rx") > BOARD_NUM_ANT_5G_RX) nvram_wlan_set_int(1, "stream_rx", BOARD_NUM_ANT_5G_RX); #endif if (strlen(nvram_wlan_get(0, "ssid")) < 1) nvram_wlan_set(0, "ssid", DEF_WLAN_2G_SSID); memset(buff, 0, sizeof(buff)); char_to_ascii(buff, nvram_wlan_get(0, "ssid")); nvram_wlan_set(0, "ssid2", buff); if (strlen(nvram_wlan_get(0, "gmode")) < 1) nvram_wlan_set_int(0, "gmode", 2); // b/g/n Mixed if (nvram_wlan_get_int(0, "HT_BW") > 1) nvram_wlan_set_int(0, "HT_BW", 1); if (nvram_wlan_get_int(0, "stream_tx") > BOARD_NUM_ANT_2G_TX) nvram_wlan_set_int(0, "stream_tx", BOARD_NUM_ANT_2G_TX); if (nvram_wlan_get_int(0, "stream_rx") > BOARD_NUM_ANT_2G_RX) nvram_wlan_set_int(0, "stream_rx", BOARD_NUM_ANT_2G_RX); nvram_set_temp("ntpc_counter", "0000000000"); nvram_set_temp("login_timestamp", "0000000000"); nvram_set_int_temp("networkmap_fullscan", 0); nvram_set_int_temp("link_internet", 2); nvram_set_int_temp("link_wan", 0); nvram_set_int_temp("reload_svc_wl", 0); nvram_set_int_temp("reload_svc_rt", 0); nvram_set_int_temp("usb_hotplug_ms", 0); nvram_set_int_temp("usb_hotplug_lp", 0); nvram_set_int_temp("usb_hotplug_md", 0); nvram_set_int_temp("usb_unplug_lp", 0); nvram_set_int_temp("usb_unplug_md", 0); nvram_set_int_temp("usb_opt_start", 0); nvram_set_int_temp("l2tp_wan_t", 0); nvram_set_int_temp("l2tp_cli_t", 0); nvram_set_int_temp("l2tp_srv_t", 0); nvram_set_int_temp("vpnc_state_t", 0); nvram_set_temp("deferred_wanup_t", "0000000000"); nvram_set_temp("vpnc_dns_t", ""); nvram_set_temp("vpnc_dom_t", ""); nvram_set_temp("viptv_ifname", ""); nvram_set_temp(RSTATS_NVKEY_24, (sw_mode != 3) ? IFDESC_WAN : IFDESC_LAN); nvram_set_temp(RSTATS_NVKEY_DM, IFDESC_WAN); /* setup wan0 variables */ set_wan0_vars(); set_wan_unit_value(0, "uptime", "0000000000"); set_wan_unit_value(0, "dltime", "0000000000"); set_wan_unit_value(0, "bytes_rx", "00000000000000000000"); set_wan_unit_value(0, "bytes_tx", "00000000000000000000"); set_wan_unit_value(0, "ifname_t", ""); set_usb_modem_dev_wan(0, 0); reset_wan_vars(); /* setup lan variables */ reset_lan_vars(); reset_lan_temp(); time_zone_x_mapping(); }