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>
46 #define IFUP (IFF_UP | IFF_RUNNING | IFF_BROADCAST | IFF_MULTICAST)
47 #define sin_addr(s) (((struct sockaddr_in *)(s))->sin_addr)
50 static void make_secrets(void)
56 user
= nvram_safe_get("ppp_username");
57 pass
= nvram_safe_get("ppp_passwd");
58 if ((f
= fopen("/tmp/ppp/pap-secrets", "w")) != NULL
) {
59 fprintf(f
, "\"%s\" * \"%s\" *\n", user
, pass
);
62 chmod("/tmp/ppp/pap-secrets", 0600);
64 if ((f
= fopen("/tmp/ppp/chap-secrets", "w")) != NULL
) {
65 fprintf(f
, "\"%s\" * \"%s\" *\n", user
, pass
);
68 chmod("/tmp/ppp/chap-secrets", 0600);
72 // -----------------------------------------------------------------------------
74 int start_pptp(int mode
)
76 _dprintf("%s: begin\n", __FUNCTION__
);
85 strlcpy(username
, nvram_safe_get("ppp_username"), sizeof(username
));
86 strlcpy(passwd
, nvram_safe_get("ppp_passwd"), sizeof(passwd
));
89 mkdir("/tmp/ppp", 0777);
90 symlink("/sbin/rc", "/tmp/ppp/ip-up");
91 symlink("/sbin/rc", "/tmp/ppp/ip-down");
92 symlink("/dev/null", "/tmp/ppp/connect-errors");
94 // Generate options file
95 if ((fp
= fopen("/tmp/ppp/options", "w")) == NULL
) {
96 perror("/tmp/ppp/options");
100 fprintf(fp
, "defaultroute\n"); // Add a default route to the system routing tables, using the peer as the gateway
101 fprintf(fp
, "usepeerdns\n"); // Ask the peer for up to 2 DNS server addresses
102 fprintf(fp
, "pty 'pptp %s --nolaunchpppd'\n", nvram_safe_get("pptp_server_ip"));
103 fprintf(fp
, "user '%s'\n", username
);
104 //fprintf(fp, "persist\n"); // Do not exit after a connection is terminated.
106 fprintf(fp
, "mtu %s\n",nvram_safe_get("wan_mtu"));
108 if (nvram_match("ppp_demand", "1")) {
110 fprintf(fp
, "idle %d\n", nvram_get_int("ppp_idletime") * 60);
111 fprintf(fp
, "demand\n"); // Dial on demand
112 fprintf(fp
, "persist\n"); // Do not exit after a connection is terminated.
113 //43011: fprintf(fp, "%s:%s\n", PPP_PSEUDO_IP, PPP_PSEUDO_GW); // <local IP>:<remote IP>
114 fprintf(fp
, "ipcp-accept-remote\n");
115 fprintf(fp
, "ipcp-accept-local\n");
116 fprintf(fp
, "connect true\n");
117 fprintf(fp
, "noipdefault\n"); // Disables the default behaviour when no local IP address is specified
118 fprintf(fp
, "ktune\n"); // Set /proc/sys/net/ipv4/ip_dynaddr to 1 in demand mode if the local address changes
125 fprintf(fp
, "default-asyncmap\n"); // Disable asyncmap negotiation
126 fprintf(fp
, "nopcomp\n"); // Disable protocol field compression
127 fprintf(fp
, "noaccomp\n"); // Disable Address/Control compression
128 fprintf(fp
, "noccp\n"); // Disable CCP (Compression Control Protocol)
129 fprintf(fp
, "novj\n"); // Disable Van Jacobson style TCP/IP header compression
130 fprintf(fp
, "nobsdcomp\n"); // Disables BSD-Compress compression
131 fprintf(fp
, "nodeflate\n"); // Disables Deflate compression
132 fprintf(fp
, "lcp-echo-interval 0\n"); // Don't send an LCP echo-request frame to the peer
133 fprintf(fp
, "lock\n");
134 fprintf(fp
, "noauth\n");
136 if (nvram_match("debug_pppd", "1")) {
137 fprintf(fp
, "debug\n");
145 // Bring up WAN interface
146 ifconfig(nvram_safe_get("wan_ifname"), IFUP
,
147 nvram_safe_get("wan_ipaddr"), nvram_safe_get("wan_netmask"));
151 if (nvram_match("ppp_demand", "1")) {
152 #if 1 // 43011: added by crazy 20070720
154 Fixed issue id 7887(or 7787):
155 When DUT is PPTP Connect on Demand mode, it couldn't be trigger from LAN.
162 // Trigger Connect On Demand if user ping pptp server
163 eval("listen", nvram_safe_get("lan_ifname"));
166 _dprintf("%s: end\n", __FUNCTION__
);
172 _dprintf("%s: begin\n", __FUNCTION__
);
174 unlink("/tmp/ppp/link");
176 while ((killall("pppd", SIGKILL
) == 0) || (killall("pptp", SIGKILL
) == 0) || (killall("listen", SIGKILL
) == 0)) {
180 _dprintf("%s: end\n", __FUNCTION__
);
185 // -----------------------------------------------------------------------------
188 // Get the IP, Subnetmask, Geteway from WAN interface and set nvram
189 static void start_tmp_ppp(int num
)
196 _dprintf("%s: num=%d\n", __FUNCTION__
, num
);
198 if (num
!= 0) return;
200 // Wait for ppp0 to be created
202 while ((ifconfig(ifname
= nvram_safe_get("pppoe_ifname0"), IFUP
, NULL
, NULL
) != 0) && (timeout
-- > 0)) {
204 _dprintf("[%d] waiting for %s %d...\n", __LINE__
, ifname
, timeout
);
207 if ((s
= socket(AF_INET
, SOCK_RAW
, IPPROTO_RAW
)) < 0) return;
208 strlcpy(ifr
.ifr_name
, ifname
, IFNAMSIZ
);
210 // Set temporary IP address
212 while (ioctl(s
, SIOCGIFADDR
, &ifr
) && timeout
--){
213 _dprintf("[%d] waiting for %s...\n", __LINE__
, ifname
);
216 nvram_set("wan_ipaddr", inet_ntoa(sin_addr(&(ifr
.ifr_addr
))));
217 nvram_set("wan_netmask", "255.255.255.255");
219 // Set temporary P-t-P address
221 while (ioctl(s
, SIOCGIFDSTADDR
, &ifr
) && timeout
--){
222 _dprintf("[%d] waiting for %s...\n", __LINE__
, ifname
);
225 nvram_set("wan_gateway", inet_ntoa(sin_addr(&(ifr
.ifr_dstaddr
))));
229 start_wan_done(ifname
);
233 void start_pppoe(int num
)
238 char lcp_echo_interval
[16];
239 char lcp_echo_fails
[16];
244 _dprintf("%s pppoe_num=%d\n", __FUNCTION__
, num
);
246 if (num
!= 0) return;
250 nvram_set("pppoe_ifname0", "");
252 dod
= nvram_match("ppp_demand", "1");
255 sprintf(idle
, "%d", dod
? (nvram_get_int("ppp_idletime") * 60) : 0);
258 sprintf(retry
, "%d", (nvram_get_int("ppp_redialperiod") / 5) - 1);
261 mtu
= nvram_safe_get("wan_mtu");
263 // [-I n] Interval between LCP echo-requests
264 sprintf(lcp_echo_interval
, "%d", ((n
= nvram_get_int("pppoe_lei")) > 0) ? n
: 30);
266 // [-T n] Tolerance to unanswered echo-requests
267 sprintf(lcp_echo_fails
, "%d", ((n
= nvram_get_int("pppoe_lef")) > 0) ? n
: 5);
269 char *pppoe_argv
[] = {
271 nvram_safe_get("wan_ifname"),
272 "-u", nvram_safe_get("ppp_username"),
273 "-p", nvram_safe_get("ppp_passwd"),
276 "-i", idle
, // >0 == dial on demand
277 "-I", lcp_echo_interval
, // Send an LCP echo-request frame to the server every X seconds
278 "-N", retry
, // To avoid kill pppd when pppd has been connecting.
279 "-T", lcp_echo_fails
, // pppd will presume the server to be dead if 3 LCP echo-requests are sent without receiving a valid LCP echo-reply
280 "-P", "0", // PPPOE session number.
281 "-C", "pppoe_down", // by tallest 0407
282 "-R", // set default route
284 NULL
, NULL
, // pppoe_service
285 NULL
, NULL
, // pppoe_ac
286 NULL
, NULL
, // static IP
287 NULL
, // pppoe_keepalive
288 NULL
, // -x extended logging
294 for (arg
= pppoe_argv
; *arg
; arg
++) {
298 if (nvram_match("debug_pppoe", "1")) {
299 *arg
++ = "-d"; // debug mode; compile ppp w/ -DDEBUG !
302 if (((p
= nvram_get("ppp_service")) != NULL
) && (*p
!= 0)) {
308 if (((p
= nvram_get("ppp_ac")) != NULL
) && (*p
!= 0)) {
313 if (nvram_match("ppp_static", "1")) {
315 *arg
++ = nvram_safe_get("ppp_static_ip");
319 //if (nvram_match("pppoe_demand", "1") || nvram_match("pppoe_keepalive", "1"))
322 if (nvram_contains_word("log_events", "pppoe")) *arg
++ = "-x";
324 mkdir("/tmp/ppp", 0777);
327 symlink("/sbin/rc", "/tmp/ppp/ip-up");
328 symlink("/sbin/rc", "/tmp/ppp/ip-down");
329 symlink("/sbin/rc", "/tmp/ppp/set-pppoepid"); // tallest 1219
331 rename("/tmp/ppp/log", "/tmp/ppp/log.~");
333 _eval(pppoe_argv
, NULL
, 0, &pid
);
340 void stop_pppoe(void)
342 _dprintf("%s\n", __FUNCTION__
);
344 unlink("/tmp/ppp/link");
345 nvram_unset("pppoe_ifname0");
346 killall_tk("pppoecd");
348 killall_tk("ip-down");
351 void stop_singe_pppoe(int num
)
353 _dprintf("%s pppoe_num=%d\n", __FUNCTION__
, num
);
357 if (num
!= 0) return;
359 i
= nvram_get_int("pppoe_pid0");
360 if ((i
> 1) && (kill(i
, SIGTERM
) == 0)) {
363 } while (kill(i
, SIGKILL
) == 0);
366 unlink("/tmp/ppp/link");
367 nvram_unset("pppoe_ifname0");
369 nvram_set("wan_get_dns", "");
373 // -----------------------------------------------------------------------------
376 void start_l2tp(void)
378 _dprintf("%s: begin\n", __FUNCTION__
);
382 char *l2tp_argv
[] = { "l2tpd", NULL
};
390 snprintf(username
, sizeof(username
), "%s", nvram_safe_get("ppp_username"));
391 snprintf(passwd
, sizeof(passwd
), "%s", nvram_safe_get("ppp_passwd"));
393 mkdir("/tmp/ppp", 0777);
394 symlink("/sbin/rc", "/tmp/ppp/ip-up");
395 symlink("/sbin/rc", "/tmp/ppp/ip-down");
396 symlink("/dev/null", "/tmp/ppp/connect-errors");
398 /* Generate L2TP configuration file */
399 if ((fp
= fopen("/tmp/l2tp.conf", "w")) == NULL
) {
402 fprintf(fp
, "global\n"); // Global section
403 fprintf(fp
, "load-handler \"sync-pppd.so\"\n"); // Load handlers
404 fprintf(fp
, "load-handler \"cmd.so\"\n");
405 fprintf(fp
, "listen-port 1701\n"); // Bind address
406 fprintf(fp
, "section sync-pppd\n"); // Configure the sync-pppd handler
407 fprintf(fp
, "section peer\n"); // Peer section
408 fprintf(fp
, "peer %s\n", nvram_safe_get("l2tp_server_ip"));
409 fprintf(fp
, "port 1701\n");
410 fprintf(fp
, "lac-handler sync-pppd\n");
411 fprintf(fp
, "section cmd\n"); // Configure the cmd handler
414 /* Generate options file */
415 if ((fp
= fopen("/tmp/ppp/options", "w")) == NULL
) {
418 fprintf(fp
, "defaultroute\n"); // Add a default route to the system routing tables, using the peer as the gateway
419 fprintf(fp
, "usepeerdns\n"); // Ask the peer for up to 2 DNS server addresses
420 //fprintf(fp, "pty 'pptp %s --nolaunchpppd'\n",nvram_safe_get("pptp_server_ip"));
421 fprintf(fp
, "user '%s'\n", username
);
422 //fprintf(fp, "persist\n"); // Do not exit after a connection is terminated.
424 fprintf(fp
, "mtu %s\n",nvram_safe_get("wan_mtu"));
426 if (nvram_match("ppp_demand", "1")){ // demand mode
427 fprintf(fp
, "idle %d\n", nvram_get_int("ppp_idletime") * 60);
428 //fprintf(fp, "demand\n"); // Dial on demand
429 //fprintf(fp, "persist\n"); // Do not exit after a connection is terminated.
430 //fprintf(fp, "%s:%s\n",PPP_PSEUDO_IP,PPP_PSEUDO_GW); // <local IP>:<remote IP>
431 fprintf(fp
, "ipcp-accept-remote\n");
432 fprintf(fp
, "ipcp-accept-local\n");
433 fprintf(fp
, "connect true\n");
434 fprintf(fp
, "noipdefault\n"); // Disables the default behaviour when no local IP address is specified
435 fprintf(fp
, "ktune\n"); // Set /proc/sys/net/ipv4/ip_dynaddr to 1 in demand mode if the local address changes
437 else{ // keepalive mode
438 if (nvram_match("l2tp_test", "1")) {
439 fprintf(fp
, "idle %d\n", 0);
440 fprintf(fp
, "ipcp-accept-remote\n");
441 fprintf(fp
, "ipcp-accept-local\n");
442 fprintf(fp
, "connect true\n");
443 fprintf(fp
, "noipdefault\n"); // Disables the default behaviour when no local IP address is specified
447 fprintf(fp
, "default-asyncmap\n"); // Disable asyncmap negotiation
448 fprintf(fp
, "nopcomp\n"); // Disable protocol field compression
449 fprintf(fp
, "noaccomp\n"); // Disable Address/Control compression
450 fprintf(fp
, "noccp\n"); // Disable CCP (Compression Control Protocol)
451 fprintf(fp
, "novj\n"); // Disable Van Jacobson style TCP/IP header compression
452 fprintf(fp
, "nobsdcomp\n"); // Disable BSD-Compress compression
453 fprintf(fp
, "nodeflate\n"); // Disable Deflate compression
454 fprintf(fp
, "lcp-echo-interval 0\n"); // Don't send an LCP echo-request frame to the peer
455 fprintf(fp
, "lock\n");
456 fprintf(fp
, "noauth");
458 if (nvram_match("debug_pppd", "1")) {
459 fprintf(fp
, "debug\n");
466 /* Bring up WAN interface */
467 //ifconfig(nvram_safe_get("wan_ifname"), IFUP,
468 // nvram_safe_get("wan_ipaddr"), nvram_safe_get("wan_netmask"));
470 ret
= _eval(l2tp_argv
, NULL
, 0, NULL
);
473 if (nvram_match("ppp_demand", "1")) {
474 eval("listen", nvram_safe_get("lan_ifname"));
477 snprintf(l2tpctrl
, sizeof(l2tpctrl
), "l2tp-control \"start-session %s\"", nvram_safe_get("l2tp_server_ip"));
479 _dprintf("%s\n", l2tpctrl
);
484 _dprintf("%s: end\n", __FUNCTION__
);
489 _dprintf("%s: begin\n", __FUNCTION__
);
491 unlink("/tmp/ppp/link");
492 while ((killall("pppd", SIGKILL
) == 0) || (killall("l2tpd", SIGKILL
) == 0) || (killall("listen", SIGKILL
) == 0)) {
495 _dprintf("%s: end\n", __FUNCTION__
);
498 // -----------------------------------------------------------------------------
500 // trigger connect on demand
501 void force_to_dial(void)
505 _dprintf("%s: begin\n", __FUNCTION__
);
508 switch (get_wan_proto()) {
510 snprintf(s
, sizeof(s
), "/usr/sbin/l2tp-control \"start-session %s\"", nvram_safe_get("l2tp_server_ip"));
515 eval("ping", "-c", "2", "10.112.112.112");
521 eval("ping", "-c", "2", nvram_safe_get("wan_gateway"));
525 _dprintf("%s: end\n", __FUNCTION__
);
528 // -----------------------------------------------------------------------------
530 const char wan_connecting
[] = "/var/lib/misc/wan.connecting";
532 void start_wan(int mode
)
543 f_write(wan_connecting
, NULL
, 0, 0, 0);
547 if (nvram_match("wl_mode", "sta")) {
548 p
= nvram_safe_get("wl_ifname");
551 p
= nvram_safe_get("wan_ifnameX");
552 set_mac(p
, "mac_wan", 1);
554 nvram_set("wan_ifname", p
);
555 nvram_set("wan_ifnames", p
);
559 wan_ifname
= nvram_safe_get("wan_ifname");
560 if (wan_ifname
[0] == 0) {
562 nvram_set("wan_ifname", wan_ifname
);
565 if (strcmp(wan_ifname
, "none") == 0) {
566 nvram_set("wan_proto", "disabled");
567 syslog(LOG_INFO
, "No WAN");
572 wan_proto
= get_wan_proto();
574 if (wan_proto
== WP_DISABLED
) {
575 start_wan_done(wan_ifname
);
579 if ((sd
= socket(AF_INET
, SOCK_RAW
, IPPROTO_RAW
)) < 0) {
598 if (nvram_match("mtu_enable", "0")) {
602 mtu
= nvram_get_int("wan_mtu");
603 if (mtu
> max
) mtu
= max
;
604 else if (mtu
< 576) mtu
= 576;
606 sprintf(buf
, "%d", mtu
);
607 nvram_set("wan_mtu", buf
);
608 nvram_set("wan_run_mtu", buf
);
610 // 43011: zhijian 2006-12-25 for CD-Router v3.4 mtu bug of PPTP connection mode
611 /* if (wan_proto == WP_PPTP) {
613 } */ // commented out; checkme -- zzz
616 strcpy(ifr
.ifr_name
, wan_ifname
);
617 ioctl(sd
, SIOCSIFMTU
, &ifr
);
621 ifconfig(wan_ifname
, IFUP
, NULL
, NULL
);
623 set_host_domain_name();
628 if (nvram_invmatch("ppp_demand", "1")) {
629 if (mode
!= REDIAL
) start_redial();
641 nvram_set("wan_iface", wan_ifname
);
642 ifconfig(wan_ifname
, IFUP
, nvram_safe_get("wan_ipaddr"), nvram_safe_get("wan_netmask"));
645 while ((!check_wanup()) && (r
-- > 0)) {
649 start_wan_done(wan_ifname
);
653 // Get current WAN hardware address
654 strlcpy(ifr
.ifr_name
, wan_ifname
, IFNAMSIZ
);
655 if (ioctl(sd
, SIOCGIFHWADDR
, &ifr
) == 0) {
656 nvram_set("wan_hwaddr", ether_etoa(ifr
.ifr_hwaddr
.sa_data
, buf
));
659 /* Set initial QoS mode again now that WAN port is ready. */
666 led(LED_DIAG
, 0); // for 4712, 5325E (?)
667 led(LED_DMZ
, nvram_match("dmz_enable", "1"));
669 _dprintf("%s: end\n", __FUNCTION__
);
673 // ppp_demand: 0=keep alive, 1=connect on demand (run 'listen')
675 // wan_iface: ppp# (PPPOE, PPTP, L2TP), vlan1 (DHCP, HB, Static)
678 void start_wan_done(char *wan_ifname
)
687 TRACE_PT("begin wan_ifname=%s\n", wan_ifname
);
690 f_write("/var/lib/misc/wantime", &si
.uptime
, sizeof(si
.uptime
), 0, 0);
692 proto
= get_wan_proto();
693 dod
= nvram_match("ppp_demand", "1");
695 if (proto
== WP_L2TP
) {
696 while (route_del(nvram_safe_get("wan_ifname"), 0, NULL
, NULL
, NULL
) == 0) {
701 // delete all default routes
702 while (route_del(wan_ifname
, 0, NULL
, NULL
, NULL
) == 0) {
706 if (proto
!= WP_DISABLED
) {
707 // set default route to gateway if specified
708 gw
= (proto
== WP_PPTP
) ? nvram_safe_get("pptp_get_ip") : nvram_safe_get("wan_gateway");
709 if ((*gw
!= 0) && (strcmp(gw
, "0.0.0.0") != 0)) {
711 while ((route_add(wan_ifname
, 0, "0.0.0.0", gw
, "0.0.0.0") == 1) && (n
--)) {
714 _dprintf("set default gateway=%s n=%d\n", gw
, n
);
717 #ifdef THREE_ARP_GRATUATOUS_SUPPORT // from 43011; checkme; commented-out -- zzz
719 // 43011: Alpha add to send Gratuitous ARP when wan_proto is Static IP 2007-04-09
720 if(nvram_match("wan_proto", "static"))
724 unsigned char wan_mac[6];
726 if (read_iface(nvram_safe_get("wan_iface"), &ifindex, &wan_ip, wan_mac) >= 0)
727 arpping(wan_ip, wan_ip, wan_mac, nvram_safe_get("wan_iface"));
733 if (proto
== WP_PPTP
) {
734 // For PPTP protocol, we must use pptp_get_ip as gateway, not pptp_server_ip
735 route_del(nvram_safe_get("wan_iface"), 0, nvram_safe_get("wan_gateway"), NULL
, "255.255.255.255");
736 route_del(nvram_safe_get("wan_iface"), 0, nvram_safe_get("pptp_server_ip"), NULL
, "255.255.255.255");
737 route_add(nvram_safe_get("wan_iface"), 0, nvram_safe_get("pptp_get_ip"), NULL
, "255.255.255.255");
739 else if (proto
== WP_L2TP
) {
740 route_del(nvram_safe_get("wan_iface"), 0, nvram_safe_get("wan_gateway"), NULL
, "255.255.255.255");
741 route_add(nvram_safe_get("wan_iface"), 0, nvram_safe_get("l2tp_get_ip"), NULL
, "255.255.255.255");
743 #if 1 // 43011: add by crazy 20070803
746 1. DUT can't response a L2TP ZLB Control message to L2TP server.
747 2. Configure DUT to be L2TP with Connect on demand in 5 minutes,
748 but DUT will disconnect L2TP before 5 minutes.
749 3. It also causes DUT could often disconnect from L2TP server in
750 L2TP Keep Alive mode.
752 struct in_addr l2tp_server_ip
, wan_ipaddr_old
, wan_netmask
;
754 if (inet_aton(nvram_safe_get("l2tp_server_ip"), &l2tp_server_ip
) &&
755 inet_aton(nvram_safe_get("wan_netmask"), &wan_netmask
) &&
756 inet_aton(nvram_safe_get("wan_ipaddr"), &wan_ipaddr_old
)) {
757 if ((l2tp_server_ip
.s_addr
& wan_netmask
.s_addr
) != (wan_ipaddr_old
.s_addr
& wan_netmask
.s_addr
)) {
758 // If DUT WAN IP and L2TP server IP are in different subnets, it could need this route.
759 route_add(nvram_safe_get("wan_ifname"), 0, nvram_safe_get("l2tp_server_ip"), nvram_safe_get("wan_gateway_buf"), "255.255.255.255"); // fixed routing problem in Israel by kanki
763 // Fail to change IP from char to struct, still add this route.
764 route_add(nvram_safe_get("wan_ifname"), 0, nvram_safe_get("l2tp_server_ip"), nvram_safe_get("wan_gateway_buf"), "255.255.255.255"); // fixed routing problem in Israel by kanki
767 route_add(nvram_safe_get("wan_ifname"), 0, nvram_safe_get("l2tp_server_ip"), nvram_safe_get("wan_gateway_buf"), "255.255.255.255"); // fixed routing problem in Israel by kanki
789 wanup
= check_wanup();
791 if ((wanup
) || (time(0) < Y2K
)) {
796 if ((wanup
) || (proto
== WP_DISABLED
)) {
803 notice_set("wan", "");
805 run_nvscript("script_wanup", NULL
, 0);
809 // We don't need STP after wireless led is lighted // no idea why... toggling it if necessary -- zzz
810 if (check_hw_type() == HW_BCM4702
) {
811 eval("brctl", "stp", nvram_safe_get("lan_ifname"), "0");
812 if (nvram_match("lan_stp", "1")) eval("brctl", "stp", nvram_safe_get("lan_ifname"), "1");
819 unlink(wan_connecting
);
829 _dprintf("%s: begin\n", __FUNCTION__
);
832 stop_upnp(); //!!TB - moved from stop_services()
837 /* Kill any WAN client daemons or callbacks */
838 stop_singe_pppoe(PPPOE0
);
844 nvram_set("wan_get_dns", "");
846 /* Bring down WAN interfaces */
847 foreach(name
, nvram_safe_get("wan_ifnames"), next
)
848 ifconfig(name
, 0, "0.0.0.0", NULL
);
851 notice_set("wan", "");
852 unlink(wan_connecting
);
854 _dprintf("%s: end\n", __FUNCTION__
);