3 Copyright 2003, CyberTAN Inc. All Rights Reserved
5 This is UNPUBLISHED PROPRIETARY SOURCE CODE of CyberTAN Inc.
6 the contents of this file may not be disclosed to third parties,
7 copied or duplicated in any form without the prior written
8 permission of CyberTAN Inc.
10 This software should be used as a reference only, and it not
11 intended for production use!
13 THIS SOFTWARE IS OFFERED "AS IS", AND CYBERTAN GRANTS NO WARRANTIES OF ANY
14 KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. CYBERTAN
15 SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
16 FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE
21 Copyright 2005, Broadcom Corporation
24 THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
25 KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
26 SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
27 FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
32 Modified for Tomato Firmware
33 Portions, Copyright (C) 2006-2009 Jonathan Zarate
39 #include <sys/ioctl.h>
40 #include <arpa/inet.h>
41 #include <sys/sysinfo.h>
45 static const char ppp_linkfile
[] = "/tmp/ppp/link";
46 static const char ppp_optfile
[] = "/tmp/ppp/wanoptions";
49 static const char ppp3g_chatfile
[] = "/tmp/ppp/connect.chat";
53 static void make_secrets(void)
59 user
= nvram_safe_get("ppp_username");
60 pass
= nvram_safe_get("ppp_passwd");
61 if ((f
= fopen("/tmp/ppp/pap-secrets", "w")) != NULL
) {
62 fprintf(f
, "\"%s\" * \"%s\" *\n", user
, pass
);
65 chmod("/tmp/ppp/pap-secrets", 0600);
67 if ((f
= fopen("/tmp/ppp/chap-secrets", "w")) != NULL
) {
68 fprintf(f
, "\"%s\" * \"%s\" *\n", user
, pass
);
71 chmod("/tmp/ppp/chap-secrets", 0600);
74 // -----------------------------------------------------------------------------
76 static int config_pppd(int wan_proto
, int num
)
85 mkdir("/tmp/ppp", 0777);
86 symlink("/sbin/rc", "/tmp/ppp/ip-up");
87 symlink("/sbin/rc", "/tmp/ppp/ip-down");
89 symlink("/sbin/rc", "/tmp/ppp/ipv6-up");
90 symlink("/sbin/rc", "/tmp/ppp/ipv6-down");
92 symlink("/dev/null", "/tmp/ppp/connect-errors");
94 demand
= nvram_get_int("ppp_demand");
96 // Generate options file
97 if ((fp
= fopen(ppp_optfile
, "w")) == NULL
) {
104 if (nvram_match("wan_proto", "ppp3g") ) {
108 "connect \"/usr/sbin/chat -V -t 60 -f %s\"\n"
113 "ipcp-accept-local\n",
114 nvram_safe_get("modem_dev"),
117 if (strlen(nvram_get("ppp_username")) >0 )
118 fprintf(fp
, "user '%s'\n", nvram_get("ppp_username"));
125 "lcp-echo-adaptive\n", // Suppress LCP echo-requests if traffic was received
127 nvram_safe_get("ppp_username"));
135 "defaultroute\n" // Add a default route to the system routing tables, using the peer as the gateway
136 "usepeerdns\n" // Ask the peer for up to 2 DNS server addresses
137 "default-asyncmap\n" // Disable asyncmap negotiation
138 "novj\n" // Disable Van Jacobson style TCP/IP header compression
139 "nobsdcomp\n" // Disable BSD-Compress compression
140 "nodeflate\n" // Disable Deflate compression
141 "noauth\n" // Do not authenticate peer
142 "refuse-eap\n" // Do not use eap
143 "maxfail 0\n" // Never give up
144 "lcp-echo-interval %d\n"// Interval between LCP echo-requests
145 "lcp-echo-failure %d\n" // Tolerance to unanswered echo-requests
147 nvram_get_int("pppoe_lei") ? : 10,
148 nvram_get_int("pppoe_lef") ? : 5,
149 nvram_get_int("debug_ppp") ? "debug\n" : "");
153 if (nvram_match("wan_proto", "ppp3g") && nvram_match("modem_dev", "ttyACM0") ) {
154 //don`t write nopcomp and noaccomp options
159 "nopcomp\n" // Disable protocol field compression
160 "noaccomp\n" // Disable Address/Control compression
169 if (wan_proto
!= WP_L2TP
) {
173 demand
? 30 : (nvram_get_int("ppp_redialperiod") ? : 30));
183 nvram_safe_get("pptp_server_ip"),
184 nvram_get_int("mtu_enable") ? nvram_get_int("wan_mtu") : 1400);
189 "plugin rp-pppoe.so\n"
193 nvram_safe_get("ppp_passwd"),
194 nvram_safe_get("wan_ifname"),
195 nvram_get_int("wan_mtu"), nvram_get_int("wan_mtu"));
196 if (((p
= nvram_get("ppp_service")) != NULL
) && (*p
)) {
197 fprintf(fp
, "rp_pppoe_service '%s'\n", p
);
199 if (((p
= nvram_get("ppp_ac")) != NULL
) && (*p
)) {
200 fprintf(fp
, "rp_pppoe_ac '%s'\n", p
);
202 if (nvram_match("ppp_mlppp", "1")) {
210 if ((cfp
= fopen(ppp3g_chatfile
, "w")) == NULL
) {
211 perror(ppp3g_chatfile
);
215 "ABORT \"NO CARRIER\"\n"
216 "ABORT \"NO DIALTONE\"\n"
217 "ABORT \"NO ERROR\"\n"
218 "ABORT \"NO ANSWER\"\n"
222 /* moved to switch3g script
223 if (strlen(nvram_get("modem_pin")) >0 ) {
226 "OK \"AT+CPIN=%s\"\n"
228 nvram_get("modem_pin"));
232 "OK \"AT&FE0V1X1&D2&C1S0=0\"\n"
236 "OK \"AT&FE0V1X1&D2&C1S0=0\"\n"
238 "OK 'AT+CGDCONT=1,\"IP\",\"%s\"'\n"
241 nvram_safe_get("modem_apn"),
242 nvram_safe_get("modem_init")
247 if (nvram_match("usb_3g", "1")) {
249 if (strlen(nvram_get("wan_gateway")) >0 ) {
250 nvram_set("wan_gateway", "");
260 fprintf(fp
, "nomppe nomppc\n");
261 if (nvram_get_int("mtu_enable"))
262 fprintf(fp
, "mtu %d\n", nvram_get_int("wan_mtu"));
269 "demand\n" // Dial on demand
271 "ipcp-accept-remote\n"
272 "ipcp-accept-local\n"
273 "noipdefault\n" // Disables the default behaviour when no local IP address is specified
274 "ktune\n", // Set /proc/sys/net/ipv4/ip_dynaddr to 1 in demand mode if the local address changes
275 nvram_get_int("ppp_idletime") * 60);
279 switch (get_ipv6_service()) {
281 case IPV6_NATIVE_DHCP
:
282 fprintf(fp
, "+ipv6\n");
286 // User specific options
287 fprintf(fp
, "%s\n", nvram_safe_get("ppp_custom"));
296 static void stop_ppp(void)
300 unlink(ppp_linkfile
);
303 killall_tk("ip-down");
305 killall_tk("ipv6-up");
306 killall_tk("ipv6-down");
308 killall_tk("xl2tpd");
310 killall_tk("listen");
315 static void run_pppd(void)
317 eval("pppd", "file", ppp_optfile
);
319 if (nvram_get_int("ppp_demand")) {
322 Fixed issue id 7887(or 7787):
323 When DUT is PPTP Connect on Demand mode, it couldn't be trigger from LAN.
329 // Trigger Connect On Demand if user ping pptp server
330 eval("listen", nvram_safe_get("lan_ifname"));
338 // -----------------------------------------------------------------------------
340 inline void stop_pptp(void)
345 void start_pptp(int mode
)
349 if (!using_dhcpc()) stop_dhcpc();
352 if (config_pppd(WP_PPTP
, 0) != 0)
360 // -----------------------------------------------------------------------------
362 void preset_wan(char *ifname
, char *gw
, char *netmask
)
366 /* Delete all default routes */
367 route_del(ifname
, 0, NULL
, NULL
, NULL
);
369 /* try adding a route to gateway first */
370 route_add(ifname
, 0, gw
, NULL
, "255.255.255.255");
372 /* Set default route to gateway if specified */
374 while ((route_add(ifname
, 1, "0.0.0.0", gw
, "0.0.0.0") == 1) && (i
--)) {
377 _dprintf("set default gateway=%s n=%d\n", gw
, i
);
379 /* Add routes to dns servers as well for demand ppp to work */
380 char word
[100], *next
;
381 in_addr_t mask
= inet_addr(netmask
);
382 foreach(word
, nvram_safe_get("wan_get_dns"), next
) {
383 if ((inet_addr(word
) & mask
) != (inet_addr(nvram_safe_get("wan_ipaddr")) & mask
))
384 route_add(ifname
, 0, word
, gw
, "255.255.255.255");
393 // -----------------------------------------------------------------------------
396 // Get the IP, Subnetmask, Geteway from WAN interface and set nvram
397 static void start_tmp_ppp(int num
, char *ifname
)
403 TRACE_PT("begin: num=%d\n", num
);
405 if (num
!= 0) return;
407 // Wait for ppp0 to be created
409 while ((ifconfig(ifname
, IFUP
, NULL
, NULL
) != 0) && (timeout
-- > 0)) {
411 _dprintf("[%d] waiting for %s %d...\n", __LINE__
, ifname
, timeout
);
414 if ((s
= socket(AF_INET
, SOCK_RAW
, IPPROTO_RAW
)) < 0) return;
415 strlcpy(ifr
.ifr_name
, ifname
, IFNAMSIZ
);
417 // Set temporary IP address
419 while (ioctl(s
, SIOCGIFADDR
, &ifr
) && timeout
--){
420 _dprintf("[%d] waiting for %s...\n", __LINE__
, ifname
);
423 nvram_set("wan_ipaddr", inet_ntoa(sin_addr(&(ifr
.ifr_addr
))));
424 nvram_set("wan_netmask", "255.255.255.255");
426 // Set temporary P-t-P address
428 while (ioctl(s
, SIOCGIFDSTADDR
, &ifr
) && timeout
--){
429 _dprintf("[%d] waiting for %s...\n", __LINE__
, ifname
);
432 nvram_set("wan_gateway", inet_ntoa(sin_addr(&(ifr
.ifr_dstaddr
))));
436 start_wan_done(ifname
);
440 void start_pppoe(int num
)
444 TRACE_PT("begin pppoe_num=%d\n", num
);
446 if (num
!= 0) return;
450 snprintf(ifname
, sizeof(ifname
), "ppp%d", num
);
454 if (nvram_match( "wan_proto", "ppp3g") ) {
455 if (config_pppd(WP_PPP3G
, num
) != 0)
460 if (config_pppd(WP_PPPOE
, num
) != 0)
469 if (nvram_get_int("ppp_demand"))
470 start_tmp_ppp(num
, ifname
);
472 ifconfig(ifname
, IFUP
, NULL
, NULL
);
477 void stop_pppoe(void)
485 void stop_singe_pppoe(int num
)
487 _dprintf("%s pppoe_num=%d\n", __FUNCTION__
, num
);
491 if (num
!= 0) return;
493 i
= nvram_get_int("pppoe_pid0");
494 if ((i
> 1) && (kill(i
, SIGTERM
) == 0)) {
497 } while (kill(i
, SIGKILL
) == 0);
500 unlink(ppp_linkfile
);
501 nvram_unset("pppoe_ifname0");
503 nvram_set("wan_get_dns", "");
508 // -----------------------------------------------------------------------------
510 inline void stop_l2tp(void)
515 void start_l2tp(void)
524 if (config_pppd(WP_L2TP
, 0) != 0)
527 demand
= nvram_get_int("ppp_demand");
529 /* Generate XL2TPD configuration file */
530 if ((fp
= fopen("/etc/xl2tpd.conf", "w")) == NULL
)
534 "access control = no\n"
538 "tx bps = 100000000\n"
541 "max redials = 32767\n"
542 "redial timeout = %d\n"
544 nvram_safe_get("l2tp_server_ip"),
546 demand
? 30 : (nvram_get_int("ppp_redialperiod") ? : 30),
547 nvram_get_int("debug_ppp") ? "yes" : "no");
555 eval("listen", nvram_safe_get("lan_ifname"));
565 // -----------------------------------------------------------------------------
567 char *wan_gateway(void)
569 char *gw
= nvram_safe_get("wan_gateway_get");
570 if ((*gw
== 0) || (strcmp(gw
, "0.0.0.0") == 0))
571 gw
= nvram_safe_get("wan_gateway");
575 // -----------------------------------------------------------------------------
577 // trigger connect on demand
578 void force_to_dial(void)
583 switch (get_wan_proto()) {
585 f_write_string("/var/run/l2tp-control", "c l2tp", 0, 0);
588 eval("ping", "-c", "2", "10.112.112.112");
594 eval("ping", "-c", "2", wan_gateway());
601 // -----------------------------------------------------------------------------
603 static void _do_wan_routes(char *ifname
, char *nvname
, int metric
, int add
)
610 // IP[/MASK] ROUTER IP2[/MASK2] ROUTER2 ...
611 tmp
= routes
= strdup(nvram_safe_get(nvname
));
612 while (tmp
&& *tmp
) {
613 char *ipaddr
, *gateway
, *nmask
;
615 ipaddr
= nmask
= strsep(&tmp
, " ");
616 strcpy(netmask
, "255.255.255.255");
619 ipaddr
= strsep(&nmask
, "/");
620 if (nmask
&& *nmask
) {
621 bits
= strtol(nmask
, &nmask
, 10);
622 if (bits
>= 1 && bits
<= 32) {
623 mask
.s_addr
= htonl(0xffffffff << (32 - bits
));
624 strcpy(netmask
, inet_ntoa(mask
));
628 gateway
= strsep(&tmp
, " ");
630 if (gateway
&& *gateway
) {
632 route_add(ifname
, metric
, ipaddr
, gateway
, netmask
);
634 route_del(ifname
, metric
, ipaddr
, gateway
, netmask
);
640 void do_wan_routes(char *ifname
, int metric
, int add
)
642 if (nvram_get_int("dhcp_routes")) {
643 // Static Routes: IP ROUTER IP2 ROUTER2 ...
644 // Classless Static Routes: IP/MASK ROUTER IP2/MASK2 ROUTER2 ...
645 _do_wan_routes(ifname
, "wan_routes1", metric
, add
);
646 _do_wan_routes(ifname
, "wan_routes2", metric
, add
);
650 // -----------------------------------------------------------------------------
652 const char wan_connecting
[] = "/var/lib/misc/wan.connecting";
654 static int is_sta(int idx
, int unit
, int subunit
, void *param
)
658 if (nvram_match(wl_nvname("mode", unit
, subunit
), "sta")) {
659 *p
= nvram_safe_get(wl_nvname("ifname", unit
, subunit
));
665 void start_wan(int mode
)
681 f_write(wan_connecting
, NULL
, 0, 0, 0);
685 if (!foreach_wif(1, &p
, is_sta
)) {
686 p
= nvram_safe_get("wan_ifnameX");
687 /* vlan ID mapping */
688 if (sscanf(p
, "vlan%d", &vid
) == 1) {
689 vlan0tag
= nvram_get_int("vlan0tag");
690 snprintf(buf
, sizeof(buf
), "vlan%dvid", vid
);
691 vid_map
= nvram_get_int(buf
);
692 if ((vid_map
< 1) || (vid_map
> 4094)) vid_map
= vlan0tag
| vid
;
693 snprintf(buf
, sizeof(buf
), "vlan%d", vid_map
);
696 set_mac(p
, "mac_wan", 1);
698 nvram_set("wan_ifname", p
);
699 nvram_set("wan_ifnames", p
);
703 wan_ifname
= nvram_safe_get("wan_ifname");
704 if (wan_ifname
[0] == 0) {
706 nvram_set("wan_ifname", wan_ifname
);
709 if (strcmp(wan_ifname
, "none") == 0) {
710 nvram_set("wan_proto", "disabled");
711 syslog(LOG_INFO
, "No WAN");
716 wan_proto
= get_wan_proto();
718 // set the default gateway for WAN interface
719 nvram_set("wan_gateway_get", nvram_safe_get("wan_gateway"));
721 if (wan_proto
== WP_DISABLED
) {
722 start_wan_done(wan_ifname
);
726 if ((sd
= socket(AF_INET
, SOCK_RAW
, IPPROTO_RAW
)) < 0) {
746 if (nvram_match("mtu_enable", "0")) {
750 mtu
= nvram_get_int("wan_mtu");
751 if (mtu
> max
) mtu
= max
;
752 else if (mtu
< 576) mtu
= 576;
754 sprintf(buf
, "%d", mtu
);
755 nvram_set("wan_mtu", buf
);
756 nvram_set("wan_run_mtu", buf
);
758 // 43011: zhijian 2006-12-25 for CD-Router v3.4 mtu bug of PPTP connection mode
759 /* if (wan_proto == WP_PPTP) {
761 } */ // commented out; checkme -- zzz
763 if (wan_proto
!= WP_PPTP
&& wan_proto
!= WP_L2TP
&& wan_proto
!= WP_PPPOE
) {
764 // Don't set the MTU on the port for PPP connections, it will be set on the link instead
766 strcpy(ifr
.ifr_name
, wan_ifname
);
767 ioctl(sd
, SIOCSIFMTU
, &ifr
);
772 ifconfig(wan_ifname
, IFUP
, NULL
, NULL
);
776 set_host_domain_name();
790 else if (wan_proto
!= WP_DHCP
) {
791 ifconfig(wan_ifname
, IFUP
, "0.0.0.0", NULL
);
792 ifconfig(wan_ifname
, IFUP
, nvram_safe_get("wan_ipaddr"), nvram_safe_get("wan_netmask"));
794 p
= nvram_safe_get("wan_gateway");
795 if ((*p
!= 0) && (strcmp(p
, "0.0.0.0") != 0))
796 preset_wan(wan_ifname
, p
, nvram_safe_get("wan_netmask"));
809 nvram_set("wan_iface", wan_ifname
);
810 ifconfig(wan_ifname
, IFUP
, nvram_safe_get("wan_ipaddr"), nvram_safe_get("wan_netmask"));
813 while ((!check_wanup()) && (r
-- > 0)) {
817 start_wan_done(wan_ifname
);
821 // Get current WAN hardware address
822 strlcpy(ifr
.ifr_name
, wan_ifname
, IFNAMSIZ
);
823 if (ioctl(sd
, SIOCGIFHWADDR
, &ifr
) == 0) {
824 nvram_set("wan_hwaddr", ether_etoa(ifr
.ifr_hwaddr
.sa_data
, buf
));
827 /* Set initial QoS mode again now that WAN port is ready. */
834 led(LED_DIAG
, 0); // for 4712, 5325E (?)
835 led(LED_DMZ
, nvram_match("dmz_enable", "1"));
841 void start_wan6_done(const char *wan_ifname
)
843 struct in_addr addr4
;
844 struct in6_addr addr
;
845 static char addr6
[INET6_ADDRSTRLEN
];
847 int service
= get_ipv6_service();
849 if (service
!= IPV6_DISABLED
) {
850 if ((nvram_get_int("ipv6_accept_ra") & 1) != 0)
851 accept_ra(wan_ifname
);
856 eval("ip", "route", "add", "::/0", "dev", (char *)wan_ifname
, "metric", "2048");
858 case IPV6_NATIVE_DHCP
:
859 eval("ip", "route", "add", "::/0", "dev", (char *)wan_ifname
);
863 case IPV6_ANYCAST_6TO4
:
866 if (service
== IPV6_ANYCAST_6TO4
) {
868 memset(&addr
, 0, sizeof(addr
));
869 inet_aton(get_wanip(), &addr4
);
870 addr
.s6_addr16
[0] = htons(0x2002);
871 ipv6_mapaddr4(&addr
, 16, &addr4
, 0);
872 addr
.s6_addr16
[3] = htons(0x0001);
873 inet_ntop(AF_INET6
, &addr
, addr6
, sizeof(addr6
));
874 nvram_set("ipv6_prefix", addr6
);
877 // FIXME: give it a few seconds for DAD completion
884 // FIXME2?: give it a few seconds for DAD completion
891 // ppp_demand: 0=keep alive, 1=connect on demand (run 'listen')
893 // wan_iface: ppp# (PPPOE, PPP3G, PPTP, L2TP), vlan1 (DHCP, HB, Static)
895 void start_wan_done(char *wan_ifname
)
903 TRACE_PT("begin wan_ifname=%s\n", wan_ifname
);
906 f_write("/var/lib/misc/wantime", &si
.uptime
, sizeof(si
.uptime
), 0, 0);
908 proto
= get_wan_proto();
910 // delete all default routes
911 route_del(wan_ifname
, 0, NULL
, NULL
, NULL
);
913 if (proto
!= WP_DISABLED
) {
914 // set default route to gateway if specified
917 if (proto
== WP_PPTP
&& !using_dhcpc()) {
918 // For PPTP protocol, we must use ppp_get_ip as gateway, not pptp_server_ip (why ??)
919 if (*gw
== 0 || strcmp(gw
, "0.0.0.0") == 0) gw
= nvram_safe_get("ppp_get_ip");
922 if ((*gw
!= 0) && (strcmp(gw
, "0.0.0.0") != 0)) {
923 if (proto
== WP_DHCP
|| proto
== WP_STATIC
) {
924 // possibly gateway is over the bridge, try adding a route to gateway first
925 route_add(wan_ifname
, 0, gw
, NULL
, "255.255.255.255");
929 while ((route_add(wan_ifname
, 0, "0.0.0.0", gw
, "0.0.0.0") == 1) && (n
--)) {
932 _dprintf("set default gateway=%s n=%d\n", gw
, n
);
934 // hack: avoid routing cycles, when both peer and server have the same IP
935 if (proto
== WP_PPTP
|| proto
== WP_L2TP
) {
936 // delete gateway route as it's no longer needed
937 route_del(wan_ifname
, 0, gw
, "0.0.0.0", "255.255.255.255");
941 #ifdef THREE_ARP_GRATUATOUS_SUPPORT // from 43011; checkme; commented-out -- zzz
943 // 43011: Alpha add to send Gratuitous ARP when wan_proto is Static IP 2007-04-09
944 if (proto == WP_STATIC)
948 unsigned char wan_mac[6];
950 if (read_iface(nvram_safe_get("wan_iface"), &ifindex, &wan_ip, wan_mac) >= 0)
951 arpping(wan_ip, wan_ip, wan_mac, nvram_safe_get("wan_iface"));
956 if (proto
== WP_PPTP
|| proto
== WP_L2TP
) {
957 route_del(nvram_safe_get("wan_iface"), 0, nvram_safe_get("wan_gateway_get"), NULL
, "255.255.255.255");
958 route_add(nvram_safe_get("wan_iface"), 0, nvram_safe_get("ppp_get_ip"), NULL
, "255.255.255.255");
960 if (proto
== WP_L2TP
) {
961 route_add(nvram_safe_get("wan_ifname"), 0, nvram_safe_get("l2tp_server_ip"), nvram_safe_get("wan_gateway"), "255.255.255.255"); // fixed routing problem in Israel by kanki
972 // and routes supplied via DHCP
973 do_wan_routes(using_dhcpc() ? nvram_safe_get("wan_ifname") : wan_ifname
, 0, 1);
978 wanup
= check_wanup();
980 if ((wanup
) || (time(0) < Y2K
)) {
985 if ((wanup
) || (proto
== WP_DISABLED
)) {
995 start_wan6_done(get_wan6face());
1006 notice_set("wan", "");
1008 run_nvscript("script_wanup", NULL
, 0);
1011 // We don't need STP after wireless led is lighted // no idea why... toggling it if necessary -- zzz
1012 if (check_hw_type() == HW_BCM4702
) {
1013 eval("brctl", "stp", nvram_safe_get("lan_ifname"), "0");
1014 if (nvram_match("lan_stp", "1"))
1015 eval("brctl", "stp", nvram_safe_get("lan_ifname"), "1");
1016 if(strcmp(nvram_safe_get("lan1_ifname"),"")!=0) {
1017 eval("brctl", "stp", nvram_safe_get("lan1_ifname"), "0");
1018 if (nvram_match("lan1_stp", "1"))
1019 eval("brctl", "stp", nvram_safe_get("lan1_ifname"), "1");
1021 if(strcmp(nvram_safe_get("lan2_ifname"),"")!=0) {
1022 eval("brctl", "stp", nvram_safe_get("lan2_ifname"), "0");
1023 if (nvram_match("lan2_stp", "1"))
1024 eval("brctl", "stp", nvram_safe_get("lan2_ifname"), "1");
1026 if(strcmp(nvram_safe_get("lan3_ifname"),"")!=0) {
1027 eval("brctl", "stp", nvram_safe_get("lan3_ifname"), "0");
1028 if (nvram_match("lan3_stp", "1"))
1029 eval("brctl", "stp", nvram_safe_get("lan3_ifname"), "1");
1036 #ifdef TCONFIG_PPTPD
1037 if (wanup
&& nvram_get_int("pptp_client_enable"))
1038 start_pptp_client();
1041 unlink(wan_connecting
);
1043 new_qoslimit_start(); //!! RAF
1053 TRACE_PT("begin\n");
1055 #ifdef TCONFIG_PPTPD
1062 new_qoslimit_stop(); //!! RAF
1065 stop_upnp(); //!!TB - moved from stop_services()
1074 nvram_set("ipv6_get_dns", "");
1077 /* Kill any WAN client daemons or callbacks */
1083 #ifdef TCONFIG_PPTPD
1084 if (nvram_get_int("pptp_client_enable"))
1088 nvram_set("wan_get_dns", "");
1090 /* Bring down WAN interfaces */
1091 foreach(name
, nvram_safe_get("wan_ifnames"), next
)
1092 ifconfig(name
, 0, "0.0.0.0", NULL
);
1094 SET_LED(RELEASE_IP
);
1095 //notice_set("wan", "");
1096 unlink("/var/notice/wan");
1097 unlink(wan_connecting
);