[package] configure the IPv6 from /etc/config/network and remove 6scripts's prefix...
[openwrt/svn-archive/archive.git] / ipv6 / 6scripts / files / 6tunnel.init
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 remoteip6 "$section" remoteip6
18 config_get ttl "$section" ttl
19 config_get mtu "$section" mtu
20
21 ip tunnel add $tnlifname mode sit remote $remoteip4 local $localip4 ttl 255
22 ifconfig $tnlifname up
23 ip link set mtu $mtu dev $tnlifname
24 ip tunnel change $tnlifname ttl $ttl
25 ip addr add $localip6 dev $tnlifname
26 ip -6 route add 2000::/3 via $remoteip6
27 }
28
29 stop_service() {
30 local section="$1"
31
32 include /lib/network
33 scan_interfaces
34 config_load /var/state/network
35
36 config_get LAN lan ifname
37 config_get tnlifname "$section" tnlifname
38 config_get remoteip4 "$section" remoteip4
39 config_get localip4 "$section" localip4
40 config_get localip6 "$section" localip6
41 config_get remoteip6 "$section" remoteip6
42 config_get ttl "$section" ttl
43 config_get mtu "$section" mtu
44
45 ip -6 ro del 2000::/3 via $remoteip6
46 ip -6 ro del ::/0 dev $tnlifname
47 ip addr del $localip6 dev $tnlifname
48 ifconfig $tnlifname down
49 ip tunnel del $tnlifname
50 }
51 start() {
52 if ! [ -x /usr/sbin/ip ]; then
53 echo "ip is required to setup the tunnel";
54 exit 1;
55 fi
56 config_load "6tunnel"
57 config_foreach start_service 6tunnel
58 }
59
60 stop () {
61 config_load "6tunnel"
62 config_foreach stop_service 6tunnel
63 }