static void check_and_set_comm_if(void) { #ifndef RTCONFIG_RALINK const char *ipaddr; char buf_ip[32]; ipaddr = getifaddr("vlan2", AF_INET, GIF_PREFIXLEN); //_dprintf("%s: %s\n", __func__, ipaddr); if(!ipaddr || (ipaddr && strncmp("169.254", ipaddr, 7))) { pick_a_random_ipv4(buf_ip); ifconfig("vlan2", IFUP, buf_ip, "255.255.0.0"); } if(!check_if_route_exist("vlan2", "169.254.0.1", "255.255.255.255")) route_add("vlan2", 0, "169.254.0.1", "0.0.0.0", "255.255.255.255"); #endif }
void start_dsl() { // todo: is it necessary? init_dsl_before_start_wan(); char *argv_tp_init[] = {"tp_init", NULL}; int pid; // if setting cfg file is from annex a, annex b will has invalid values if(nvram_match("productid", "DSL-N55U-B")) { if (nvram_get_int("dslx_annex") != 0) { nvram_set_int("dslx_annex", 0); //Paul add 2012/8/22, for Annex B model should always be 0 nvram_set_int("dslx_config_num", 0); } } eval("mkdir", "/tmp/adsl"); /* Paul comment 2012/7/25, the "never overcommit" policy would cause Ralink WiFi driver kernel panic when configure DUT through external registrar. * * So let this value be the default which is 0, the kernel will estimate the amount of free memory left when userspace requests more memory. */ //system("echo 2 > /proc/sys/vm/overcommit_memory"); #ifdef RTCONFIG_DUALWAN if (get_dualwan_secondary()==WANS_DUALWAN_IF_NONE) { if (get_dualwan_primary()!=WANS_DUALWAN_IF_DSL) { // it does not need to start dsl driver when using other modes // but it still need to run tp_init to have firmware version info printf("get modem info\n"); eval("tp_init", "eth_wan_mode_only"); return; } } #endif int config_num = nvram_get_int("dslx_config_num"); _eval(argv_tp_init, NULL, 0, &pid); // IPTV if (nvram_match("x_Setting", "1") && config_num > 1) { int x; char wan_if[9]; char wan_num[2]; char buf_ip[32]; eval("brctl", "addbr", "br1"); for(x=2; x<=config_num; x++) { sprintf(wan_if, "eth2.1.%d", x); sprintf(wan_num, "%d", x); eval("vconfig", "add", "eth2.1", wan_num); eval("ifconfig", wan_if, "up"); eval("brctl", "addif", "br1", wan_if); } eval("brctl", "addif", "br1", "eth2.3"); // it needs assign a IPv4 address to enable packet forwarding pick_a_random_ipv4(buf_ip); eval("ifconfig", "br1", "up"); eval("ifconfig", "br1", buf_ip); } // auto detection if (nvram_match("x_Setting", "0") && config_num == 0) { int x; char wan_if[9]; char wan_num[2]; char country_value[8]; char cmd_buf[64]; char *argv_auto_det[] = {"auto_det", country_value, NULL}; int pid; for(x=2; x<=8; x++) { sprintf(wan_if, "eth2.1.%d", x); sprintf(wan_num, "%d", x); eval("vconfig", "add", "eth2.1", wan_num); eval("ifconfig", wan_if, "up"); } // nvram_set("dsltmp_autodet_state", "Detecting"); // call auto detection with country code get_country_code_from_rc(country_value); _eval(argv_auto_det, NULL, 0, &pid); } }
void start_dsl() { #ifdef RTCONFIG_RALINK // todo: is it necessary? init_dsl_before_start_wan(); #endif char *argv_tp_init[] = {"tp_init", NULL}; int pid; char buf_ip[32]; mkdir("/tmp/adsl", S_IRUSR | S_IWUSR | S_IXUSR); /* Paul comment 2012/7/25, the "never overcommit" policy would cause Ralink WiFi driver kernel panic when configure DUT through external registrar. * * So let this value be the default which is 0, the kernel will estimate the amount of free memory left when userspace requests more memory. */ //f_write_string("/proc/sys/vm/overcommit_memory", "2", 0, 0); #ifdef RTCONFIG_DSL_TCLINUX check_and_set_comm_if(); #endif #ifndef RTCONFIG_DSL_TCLINUX #ifdef RTCONFIG_DUALWAN if (get_dualwan_secondary()==WANS_DUALWAN_IF_NONE) { if (get_dualwan_primary()!=WANS_DUALWAN_IF_DSL) { // it does not need to start dsl driver when using other modes // but it still need to run tp_init to have firmware version info printf("get modem info\n"); xstart("tp_init", "eth_wan_mode_only"); return; } } #endif #endif _eval(argv_tp_init, NULL, 0, &pid); int config_num = nvram_get_int("dslx_config_num"); // IPTV if (nvram_match("x_Setting", "1") && config_num > 1) { int x; char wan_if[9]; char wan_num[2]; eval("brctl", "addbr", "br1"); for(x=2; x<=config_num; x++) { sprintf(wan_num, "%d", x); #ifdef RTCONFIG_RALINK sprintf(wan_if, "eth2.1.%d", x); eval("vconfig", "add", "eth2.1", wan_num); #else /* create IPTV PVC interface and begin from eth0.3881 */ sprintf(wan_num, "%d", (DSL_WAN_VID + x -1)); sprintf(wan_if, "vlan%s", wan_num); eval("vconfig", "set_name_type", "VLAN_PLUS_VID_NO_PAD"); eval("vconfig", "add", "eth0", wan_num); //Set switch sprintf(wan_num, "0x%04x", (DSL_WAN_VID + x -1)); eval("et", "robowr", "0x05", "0x83", "0x0021"); eval("et", "robowr", "0x05", "0x81", wan_num); eval("et", "robowr", "0x05", "0x80", "0x0000"); eval("et", "robowr", "0x05", "0x80", "0x0080"); #endif eval("ifconfig", wan_if, "up"); eval("brctl", "addif", "br1", wan_if); } #ifdef RTCONFIG_RALINK eval("brctl", "addif", "br1", "eth2.3"); #else eval("brctl", "addif", "br1", "vlan3"); #endif // it needs assign a IPv4 address to enable packet forwarding pick_a_random_ipv4(buf_ip); eval("ifconfig", "br1", "up"); eval("ifconfig", "br1", buf_ip); } #ifndef RTCONFIG_DSL_TCLINUX // auto detection if (nvram_match("x_Setting", "0") && config_num == 0) { int x; char wan_if[9]; char wan_num[2]; char country_value[8]; char cmd_buf[64]; char *argv_auto_det[] = {"auto_det", country_value, NULL}; int pid; for(x=2; x<=8; x++) { sprintf(wan_num, "%d", x); sprintf(wan_if, "eth2.1.%d", x); eval("vconfig", "add", "eth2.1", wan_num); eval("ifconfig", wan_if, "up"); } // nvram_set("dsltmp_autodet_state", "Detecting"); // call auto detection with country code get_country_code_from_rc(country_value); _eval(argv_auto_det, NULL, 0, &pid); } #endif //nRTCONFIG_DSL_TCLINUX #ifdef RTCONFIG_DSL_TCLINUX if(nvram_match("dslx_diag_enable", "1") && nvram_match("dslx_diag_state", "1")) start_dsl_diag(); #endif }
void start_dsl() { // todo: is it necessary? init_dsl_before_start_wan(); char *argv_tp_init[] = {"tp_init", NULL}; int pid; // if setting cfg file is from annex a, annex b will has invalid values if(nvram_match("productid", "DSL-N55U-B")) { if (nvram_get_int("dslx_annex") != 0) { nvram_set_int("dslx_config_num", 0); } } eval("mkdir", "/tmp/adsl"); // disable out-of-memory process killer // this command could not use eval because redirection system("echo 2 > /proc/sys/vm/overcommit_memory"); #ifdef RTCONFIG_DUALWAN if (get_dualwan_secondary()==WANS_DUALWAN_IF_NONE) { if (get_dualwan_primary()!=WANS_DUALWAN_IF_DSL) { // it does not need to start dsl driver when using other modes // but it still need to run tp_init to have firmware version info printf("get modem info\n"); eval("tp_init", "eth_wan_mode_only"); return; } } #endif int config_num = nvram_get_int("dslx_config_num"); _eval(argv_tp_init, NULL, 0, &pid); // IPTV if (nvram_match("x_Setting", "1") && config_num > 1) { int x; char wan_if[9]; char wan_num[2]; char buf_ip[32]; eval("brctl", "addbr", "br1"); for(x=2; x<=config_num; x++) { sprintf(wan_if, "eth2.1.%d", x); sprintf(wan_num, "%d", x); eval("vconfig", "add", "eth2.1", wan_num); eval("ifconfig", wan_if, "up"); eval("brctl", "addif", "br1", wan_if); } eval("brctl", "addif", "br1", "eth2.3"); // it needs assign a IPv4 address to enable packet forwarding pick_a_random_ipv4(buf_ip); eval("ifconfig", "br1", "up"); eval("ifconfig", "br1", buf_ip); } // auto detection if (nvram_match("x_Setting", "0") && config_num == 0) { int x; char wan_if[9]; char wan_num[2]; char country_value[8]; char cmd_buf[64]; char *argv_auto_det[] = {"auto_det", country_value, NULL}; int pid; for(x=2; x<=8; x++) { sprintf(wan_if, "eth2.1.%d", x); sprintf(wan_num, "%d", x); eval("vconfig", "add", "eth2.1", wan_num); eval("ifconfig", wan_if, "up"); } // nvram_set("dsltmp_autodet_state", "Detecting"); // call auto detection with country code get_country_code_from_rc(country_value); _eval(argv_auto_det, NULL, 0, &pid); } }