Exemplo n.º 1
0
void config_switch_dsl()
{
    int stbport;
    dbG("config ethernet switch IC\n");

    if (is_routing_enabled())
    {
        stbport = atoi(nvram_safe_get("switch_stb_x"));
        if (stbport < 0 || stbport > 6) stbport = 0;
        dbG("STB port: %d\n", stbport);

#ifdef RTCONFIG_DUALWAN
        if (stbport == 0)
        {
            if (get_dualwan_secondary()==WANS_DUALWAN_IF_LAN)
            {
                config_switch_dsl_set_lan();
            }
            else
            {
                if (get_dualwan_primary()==WANS_DUALWAN_IF_LAN)
                {
                    config_switch_dsl_set_lan();
                }
                else
                {
                    config_switch_dsl_set_dsl();
                }
            }
        }
        else
        {
            if (get_dualwan_secondary()==WANS_DUALWAN_IF_LAN)
            {
                config_switch_dsl_set_lan_iptv(stbport);
            }
            else
            {
                if (get_dualwan_primary()==WANS_DUALWAN_IF_LAN)
                {
                    config_switch_dsl_set_lan_iptv(stbport);
                }
                else
                {
                    config_switch_dsl_set_dsl();
                }
            }
        }
#else
        if (stbport == 0)
        {
            config_switch_dsl_set_dsl();
        }
        else
        {
            config_switch_dsl_set_iptv(stbport);
        }
#endif
    }
}
Exemplo n.º 2
0
int get_dualwan_values_once(void)
{
	if (m_dualwan_ifname_values_loaded) return;
	m_dualwan_ifname_values_loaded = 1;
	m_primary_if = get_dualwan_primary();
	m_secondary_if = get_dualwan_secondary();	
}
Exemplo n.º 3
0
void convert_dsl_wan()
{
	int conv_dsl_to_wan0 = 0;
	int conv_dsl_to_wan1 = 0;

#ifdef RTCONFIG_DUALWAN
	if (get_dualwan_primary()==WANS_DUALWAN_IF_DSL)
	{
		conv_dsl_to_wan0 = 1;
	}

	if (get_dualwan_secondary()==WANS_DUALWAN_IF_DSL)
	{
		conv_dsl_to_wan1 = 1;
	}	
#else
	conv_dsl_to_wan0 = 1;
#endif

	if (conv_dsl_to_wan0)
	{
		nvram_set("wan_nat_x",nvram_safe_get("dslx_nat"));
		nvram_set("wan_upnp_enable",nvram_safe_get("dslx_upnp_enable"));	
		nvram_set("wan_enable",nvram_safe_get("dslx_link_enable")); 
		nvram_set("wan_dhcpenable_x",nvram_safe_get("dslx_DHCPClient"));	
		nvram_set("wan_ipaddr_x",nvram_safe_get("dslx_ipaddr"));	
		nvram_set("wan_upnp_enable",nvram_safe_get("dslx_upnp_enable"));		
		nvram_set("wan_netmask_x",nvram_safe_get("dslx_netmask"));		
		nvram_set("wan_gateway_x",nvram_safe_get("dslx_gateway"));		
		nvram_set("wan_dnsenable_x",nvram_safe_get("dslx_dnsenable"));		
		nvram_set("wan_dns1_x",nvram_safe_get("dslx_dns1"));			
		nvram_set("wan_dns2_x",nvram_safe_get("dslx_dns2"));			
		nvram_set("wan_pppoe_username",nvram_safe_get("dslx_pppoe_username"));			
		nvram_set("wan_pppoe_passwd",nvram_safe_get("dslx_pppoe_passwd"));				
		nvram_set("wan_pppoe_idletime",nvram_safe_get("dslx_pppoe_idletime"));			
		nvram_set("wan_pppoe_mtu",nvram_safe_get("dslx_pppoe_mtu"));				
		nvram_set("wan_pppoe_mru",nvram_safe_get("dslx_pppoe_mtu"));			
		nvram_set("wan_pppoe_service",nvram_safe_get("dslx_pppoe_service"));				
		nvram_set("wan_pppoe_ac",nvram_safe_get("dslx_pppoe_ac"));				
		nvram_set("wan_pppoe_options_x",nvram_safe_get("dslx_pppoe_options"));			
//		nvram_set("wan_pppoe_relay",nvram_safe_get("dslx_pppoe_relay"));				
		nvram_set("wan_dns1_x",nvram_safe_get("dslx_dns1"));			
		nvram_set("wan_dns1_x",nvram_safe_get("dslx_dns1"));				
	}

	if (conv_dsl_to_wan0)
	{
		nvram_set("wan0_nat_x",nvram_safe_get("dslx_nat"));
		nvram_set("wan0_upnp_enable",nvram_safe_get("dslx_upnp_enable"));	
		nvram_set("wan0_enable",nvram_safe_get("dslx_link_enable"));	
		nvram_set("wan0_dhcpenable_x",nvram_safe_get("dslx_DHCPClient"));	
		nvram_set("wan0_ipaddr_x",nvram_safe_get("dslx_ipaddr"));	
		nvram_set("wan0_upnp_enable",nvram_safe_get("dslx_upnp_enable"));		
		nvram_set("wan0_netmask_x",nvram_safe_get("dslx_netmask")); 	
		nvram_set("wan0_gateway_x",nvram_safe_get("dslx_gateway")); 	
		nvram_set("wan0_dnsenable_x",nvram_safe_get("dslx_dnsenable")); 	
		nvram_set("wan0_dns1_x",nvram_safe_get("dslx_dns1"));			
		nvram_set("wan0_dns2_x",nvram_safe_get("dslx_dns2"));			
		nvram_set("wan0_pppoe_username",nvram_safe_get("dslx_pppoe_username")); 		
		nvram_set("wan0_pppoe_passwd",nvram_safe_get("dslx_pppoe_passwd")); 			
		nvram_set("wan0_pppoe_idletime",nvram_safe_get("dslx_pppoe_idletime")); 		
		nvram_set("wan0_pppoe_mtu",nvram_safe_get("dslx_pppoe_mtu"));				
		nvram_set("wan0_pppoe_mru",nvram_safe_get("dslx_pppoe_mtu"));			
		nvram_set("wan0_pppoe_service",nvram_safe_get("dslx_pppoe_service"));				
		nvram_set("wan0_pppoe_ac",nvram_safe_get("dslx_pppoe_ac")); 			
		nvram_set("wan0_pppoe_options_x",nvram_safe_get("dslx_pppoe_options")); 		
//		nvram_set("wan0_pppoe_relay",nvram_safe_get("dslx_pppoe_relay"));				
		nvram_set("wan0_dns1_x",nvram_safe_get("dslx_dns1"));			
		nvram_set("wan0_dns1_x",nvram_safe_get("dslx_dns1"));				
		nvram_set("wan0_hwaddr_x",nvram_safe_get("dslx_hwaddr"));					
	}

	if (conv_dsl_to_wan1)
	{
		nvram_set("wan1_nat_x",nvram_safe_get("dslx_nat"));
		nvram_set("wan1_upnp_enable",nvram_safe_get("dslx_upnp_enable"));	
		nvram_set("wan1_enable",nvram_safe_get("dslx_link_enable"));	
		nvram_set("wan1_dhcpenable_x",nvram_safe_get("dslx_DHCPClient"));	
		nvram_set("wan1_ipaddr_x",nvram_safe_get("dslx_ipaddr"));	
		nvram_set("wan1_upnp_enable",nvram_safe_get("dslx_upnp_enable"));		
		nvram_set("wan1_netmask_x",nvram_safe_get("dslx_netmask")); 	
		nvram_set("wan1_gateway_x",nvram_safe_get("dslx_gateway")); 	
		nvram_set("wan1_dnsenable_x",nvram_safe_get("dslx_dnsenable")); 	
		nvram_set("wan1_dns1_x",nvram_safe_get("dslx_dns1"));			
		nvram_set("wan1_dns2_x",nvram_safe_get("dslx_dns2"));			
		nvram_set("wan1_pppoe_username",nvram_safe_get("dslx_pppoe_username")); 		
		nvram_set("wan1_pppoe_passwd",nvram_safe_get("dslx_pppoe_passwd")); 			
		nvram_set("wan1_pppoe_idletime",nvram_safe_get("dslx_pppoe_idletime")); 		
		nvram_set("wan1_pppoe_mtu",nvram_safe_get("dslx_pppoe_mtu"));				
		nvram_set("wan1_pppoe_mru",nvram_safe_get("dslx_pppoe_mtu"));			
		nvram_set("wan1_pppoe_service",nvram_safe_get("dslx_pppoe_service"));				
		nvram_set("wan1_pppoe_ac",nvram_safe_get("dslx_pppoe_ac")); 			
		nvram_set("wan1_pppoe_options_x",nvram_safe_get("dslx_pppoe_options")); 		
//		nvram_set("wan1_pppoe_relay",nvram_safe_get("dslx_pppoe_relay"));				
		nvram_set("wan1_dns1_x",nvram_safe_get("dslx_dns1"));			
		nvram_set("wan1_dns1_x",nvram_safe_get("dslx_dns1"));				
		nvram_set("wan1_hwaddr_x",nvram_safe_get("dslx_hwaddr"));					
	}
	

	if (conv_dsl_to_wan0)
	{
		if (nvram_match("dsl0_proto","pppoe") || nvram_match("dsl0_proto","pppoa")) {
			nvram_set("wan0_proto","pppoe");
			/* Turn off DHCP on MAN interface */
			nvram_set_int("wan0_dhcpenable_x", 2);
		}
		else if (nvram_match("dsl0_proto","ipoa")) {
			nvram_set("wan0_proto","static");
		}
		else if (nvram_match("dsl0_proto","bridge")) {
			// disable nat
			nvram_set("wan0_nat_x","0");

			/* Paul add 2012/7/13, for Bridge connection type wan0_proto set to dhcp, and dsl_proto set as bridge */
			nvram_set("wan0_proto","dhcp");
			nvram_set("dsl_proto","bridge");
		}
		else if (nvram_match("dsl0_proto","mer")) {
			if (nvram_match("dslx_DHCPClient","1")) {
				nvram_set("wan0_proto","dhcp");
			}
			else {
				nvram_set("wan0_proto","static");		
			}
		}
	}

	if (conv_dsl_to_wan1)
	{
		if (nvram_match("dsl0_proto","pppoe") || nvram_match("dsl0_proto","pppoa")) {
			nvram_set("wan1_proto","pppoe");
			/* Turn off DHCP on MAN interface */
			nvram_set_int("wan1_dhcpenable_x", 2);
		}
		else if (nvram_match("dsl0_proto","ipoa")) {
			nvram_set("wan1_proto","static");
		}
		else if (nvram_match("dsl0_proto","bridge")) {
			// disable nat
			nvram_set("wan1_nat_x","0");		

			/* Paul add 2012/7/13, for Bridge connection type wan0_proto set to dhcp, and dsl_proto set as bridge */
			nvram_set("wan1_proto","dhcp");
			nvram_set("dsl_proto","bridge");
		}
		else if (nvram_match("dsl0_proto","mer")) {
			if (nvram_match("dslx_DHCPClient","1")) {
				nvram_set("wan1_proto","dhcp");
			}
			else {
				nvram_set("wan1_proto","static");		
			}
		}
	}
	

	if (conv_dsl_to_wan0)
	{
		nvram_set("wan_proto",nvram_safe_get("wan0_proto"));
	}	

}
Exemplo n.º 4
0
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);
	}
}
Exemplo n.º 5
0
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
}
Exemplo n.º 6
0
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);
	}
}
Exemplo n.º 7
0
void init_switch_dsl()
{
	// vlan1 => LAN PORT
	// vlan2 => WAN to modem , send packet to modem , used on modem driver
	// vlan3 => IPTV port
	// vlan4 => WAN to Ethernet this is ethernet WAN ifname
	int stbport;
	int enable_dsl_wan_dsl_if = 0;
	int enable_dsl_wan_eth_if = 0;
	int enable_dsl_wan_iptv_if = 0;

#ifdef RTCONFIG_DUALWAN
	if (get_dualwan_secondary()==WANS_DUALWAN_IF_NONE)
	{
		if (get_dualwan_primary()==WANS_DUALWAN_IF_DSL)
		{
			enable_dsl_wan_dsl_if = 1;
		}
		else if (get_dualwan_primary()==WANS_DUALWAN_IF_LAN)
		{
			enable_dsl_wan_eth_if = 1;
		}
	}
	else
	{
		if (get_dualwan_primary()==WANS_DUALWAN_IF_DSL)
		{
			enable_dsl_wan_dsl_if = 1;
		}
		else if (get_dualwan_primary()==WANS_DUALWAN_IF_LAN)
		{
			enable_dsl_wan_eth_if = 1;
		}

		if (get_dualwan_secondary()==WANS_DUALWAN_IF_DSL)
		{
			enable_dsl_wan_dsl_if = 1;
		}
		else if (get_dualwan_secondary()==WANS_DUALWAN_IF_LAN)
		{
			enable_dsl_wan_eth_if = 1;
		}
	}
#else
	enable_dsl_wan_dsl_if = 1;
#endif

	if (is_routing_enabled())
	{
		stbport = atoi(nvram_safe_get("switch_stb_x"));
		if (stbport < 0 || stbport > 6) stbport = 0;
		dbG("STB port: %d\n", stbport);

		if (stbport > 0)
		{
			enable_dsl_wan_iptv_if = 1;
		}
	}

	eval("ifconfig", "eth0", "up");
	// vlan2 = WAN
	eval("vconfig", "set_name_type", "VLAN_PLUS_VID_NO_PAD");
	eval("vconfig", "add", "eth0", "2");
	eval("ifconfig", "vlan2", "up");

	if (enable_dsl_wan_dsl_if)
	{
		// DSL WAN MODE
		eval("vconfig", "set_name_type", "VLAN_PLUS_VID_NO_PAD");
		eval("vconfig", "add", "eth0", "100");
		eval("ifconfig", "vlan100", "up");
		eval("ifconfig", "vlan100", "hw", "ether", nvram_safe_get("et0macaddr"));
	}

	if (enable_dsl_wan_eth_if)
	{
		// vlan4 = ethenet WAN
		eval("vconfig", "set_name_type", "VLAN_PLUS_VID_NO_PAD");
		eval("vconfig", "add", "eth0", "4");
		eval("ifconfig", "vlan4", "up");
		// ethernet WAN , it needs to use another MAC address
		eval("ifconfig", "vlan4", "hw", "ether", nvram_safe_get("et1macaddr"));
	}

	if (enable_dsl_wan_iptv_if)
	{
		// vlan3 = IPTV
		eval("vconfig", "set_name_type", "VLAN_PLUS_VID_NO_PAD");
		eval("vconfig", "add", "eth0", "3");
		eval("ifconfig", "vlan3", "up");
		// bypass , no need to have another MAC address
	}

}
Exemplo n.º 8
0
void init_switch_dsl()
{
    // DSLTODO

    // Eth2 => SoC RGMII 0 => Because we use VLAN, we do not use this interface directly
    // Eth2.1 => WAN to modem , send packet to modem , used on modem driver
    // Eth2.2 => LAN PORT
    // Eth 2.1.50 => for stats, ethernet driver modify modem packets to this VLAN ID
    // Eth 2.1.51 => bridge for Ethernet and modem, ethernet driver modify modem packet to VLAN ID (51)
    // and then bridge eth2.2 and eth2.1.51. thus, PC could control modem from LAN port
    // Eth2.3 => IPTV port
    // Eth2.4 => WAN to Ethernet this is ethernet WAN ifname
    int stbport;
    int enable_dsl_wan_dsl_if = 0;
    int enable_dsl_wan_eth_if = 0;
    int enable_dsl_wan_iptv_if = 0;


    eval("ifconfig", "eth2", "up");
    // eth2.1 = WAN
    eval("vconfig", "add", "eth2", "1");
    eval("ifconfig", "eth2.1", "up");
    // eth2.2 = LAN
    eval("vconfig", "add", "eth2", "2");
    eval("ifconfig", "eth2.2", "up");
    // eth2.3 = IPTV

#ifdef RTCONFIG_DUALWAN
    if (get_dualwan_secondary()==WANS_DUALWAN_IF_NONE)
    {
        if (get_dualwan_primary()==WANS_DUALWAN_IF_DSL)
        {
            enable_dsl_wan_dsl_if = 1;
        }
        else if (get_dualwan_primary()==WANS_DUALWAN_IF_LAN)
        {
            enable_dsl_wan_eth_if = 1;
        }
    }
    else
    {
        if (get_dualwan_primary()==WANS_DUALWAN_IF_DSL)
        {
            enable_dsl_wan_dsl_if = 1;
        }
        else if (get_dualwan_primary()==WANS_DUALWAN_IF_LAN)
        {
            enable_dsl_wan_eth_if = 1;
        }

        if (get_dualwan_secondary()==WANS_DUALWAN_IF_DSL)
        {
            enable_dsl_wan_dsl_if = 1;
        }
        else if (get_dualwan_secondary()==WANS_DUALWAN_IF_LAN)
        {
            enable_dsl_wan_eth_if = 1;
        }
    }
#else
    enable_dsl_wan_dsl_if = 1;
#endif

    if (is_routing_enabled())
    {
        stbport = atoi(nvram_safe_get("switch_stb_x"));
        if (stbport < 0 || stbport > 6) stbport = 0;
        dbG("STB port: %d\n", stbport);

        if (stbport > 0)
        {
            enable_dsl_wan_iptv_if = 1;
        }
    }


    if (enable_dsl_wan_dsl_if)
    {
        // DSL WAN MODE
        eval("vconfig", "add", "eth2.1", "1");
        eval("ifconfig", "eth2.1.1", "up");
        eval("ifconfig", "eth2.1", "hw", "ether", nvram_safe_get("et0macaddr"));
    }

    if (enable_dsl_wan_eth_if)
    {
        // eth2.4 = ethenet WAN
        eval("vconfig", "add", "eth2", "4");
        eval("ifconfig", "eth2.4", "up");
        // ethernet WAN , it needs to use another MAC address
        eval("ifconfig", "eth2.4", "hw", "ether", nvram_safe_get("et1macaddr"));
    }

    if (enable_dsl_wan_iptv_if)
    {
        // eth2.3 = IPTV
        eval("vconfig", "add", "eth2", "3");
        eval("ifconfig", "eth2.3", "up");
        // bypass , no need to have another MAC address
    }

    // for a dummy interface from trendchip
    // this is only for stats viewing , non-necessary
    // do not power up dummay interface. If so, it will send packet out
    eval("vconfig", "add", "eth2.1", "50");
    eval("vconfig", "add", "eth2.1", "51");

}