Add 6tunnel configuration for tunnel brokers based configuration (not SiXXS), disable...
[openwrt-10.03/.git] / package / base-files / files / etc / init.d / 6tunnel
1 #!/bin/sh /etc/rc.common
2 START=46
3 STOP=46
4
5 start_service() {
6         local section="$1"
7         
8         include /lib/network
9         scan_interfaces
10         config_load /var/state/network
11
12         config_get LAN lan ifname
13         config_get tnlifname "$section" tnlifname
14         config_get remoteip4 "$section" remoteip4
15         config_get localip4 "$section" localip4
16         config_get localip6 "$section" localip6
17         config_get prefix "$section" prefix
18
19         ip tunnel add $tnlifname mode sit remote $remoteip4 local $localip4 ttl 255
20         ifconfig $tnlifname up
21         ip addr add $localip6 dev $tnlifname
22         ip route add ::/0 dev $tnlifname
23         ip route add 2000::/3 dev $tnlifname
24         ip -6 addr add $prefix dev $LAN
25 }
26
27 stop_service() {
28         local section="$1"
29         
30         include /lib/network
31         scan_interfaces
32         config_load /var/state/network
33
34         config_get LAN lan ifname
35         config_get tnlifname "$section" tnlifname
36         config_get remoteip4 "$section" remoteip4
37         config_get localip4 "$section" localip4
38         config_get localip6 "$section" localip6
39         config_get prefix "$section" prefix
40
41         ip -6 addr del $prefix dev $LAN
42         ip -6 ro del 2000::/3 dev $tnlifname
43         ip -6 ro del ::/0 dev $tnlifname
44         ip addr del $localip6 dev $tnlifname
45         ifconfig $tnlifname down
46         ip tunnel del $tnlifname
47 }
48 start() {
49         if ! [ -f /proc/net/if_inet6 ]; then
50                 echo "IPv6 not enabled, install kmod-ipv6";
51                 exit 1;
52         fi
53         if ! [ -x /sbin/ip ]; then
54                 echo "ip is required to setup the tunnel";
55                 exit 1;
56         fi
57         config_load "6tunnel"
58         config_foreach start_service 6tunnel
59 }
60
61 stop () {
62         config_load "6tunnel"
63         config_foreach stop_service 6tunnel
64 }