Move the helper scripts to setup IPv6 connectivity fo the 6scripts package
authorFlorian Fainelli <florian@openwrt.org>
Fri, 18 Jul 2008 14:04:47 +0000 (14:04 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Fri, 18 Jul 2008 14:04:47 +0000 (14:04 +0000)
SVN-Revision: 11859

ipv6/6scripts/Makefile [new file with mode: 0644]
ipv6/6scripts/files/6bridge.conf [new file with mode: 0644]
ipv6/6scripts/files/6bridge.init [new file with mode: 0644]
ipv6/6scripts/files/6tunnel.conf [new file with mode: 0644]
ipv6/6scripts/files/6tunnel.init [new file with mode: 0644]

diff --git a/ipv6/6scripts/Makefile b/ipv6/6scripts/Makefile
new file mode 100644 (file)
index 0000000..5600ff0
--- /dev/null
@@ -0,0 +1,48 @@
+#
+# Copyright (C) 2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# $Id: Makefile 9802 2007-12-19 08:30:28Z florian $
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=6scripts
+PKG_VERSION:=0.1
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/6scripts
+  SECTION:=ipv6
+  CATEGORY:=IPv6
+  TITLE:=IPv6 scripts
+endef
+
+define Package/6tunnel/description
+IPv6 scripts to setup ipv6 connectivy using 6to4 tunnels
+or bridged ipv6 connectivity.
+endef
+
+define Package/6scripts/conffiles
+/etc/config/6tunnel
+/etc/config/6bridge
+endef
+
+define Build/Compile
+endef
+
+define Build/Configure
+endef
+
+define Package/6scripts/install
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_DATA) ./files/6tunnel.conf $(1)/etc/config/6tunnel
+       $(INSTALL_DATA) ./files/6bridge.conf $(1)/etc/config/6bridge
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/6tunnel.init $(1)/etc/init.d/6tunnel
+       $(INSTALL_BIN) ./files/6bridge.init $(1)/etc/init.d/6bridge
+endef
+
+$(eval $(call BuildPackage,6scripts))
diff --git a/ipv6/6scripts/files/6bridge.conf b/ipv6/6scripts/files/6bridge.conf
new file mode 100644 (file)
index 0000000..e2980ad
--- /dev/null
@@ -0,0 +1,2 @@
+config 6bridge
+       option bridge   'bripv6'        
diff --git a/ipv6/6scripts/files/6bridge.init b/ipv6/6scripts/files/6bridge.init
new file mode 100644 (file)
index 0000000..ba98d66
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/sh /etc/rc.common
+START=46
+STOP=46
+
+start_service() {
+       local section="$1"
+       
+       include /lib/network
+       scan_interfaces
+       config_load /var/state/network
+
+       config_get LAN lan ifname
+       config_get WAN wan ifname
+       config_get bridge "$section" bridge
+
+       brctl addbr $bridge
+       brctl addif $bridge $LAN
+       brctl addif $bridge $WAN
+       brctl setfd $bridge 0
+        ebtables -t broute -A BROUTING -i $WAN -p ! ipv6 -j DROP
+        ifconfig $bridge up
+}
+
+stop_service() {
+        local section="$1"
+
+        include /lib/network
+        scan_interfaces
+        config_load /var/state/network
+
+        config_get LAN lan ifname
+        config_get WAN wan ifname
+        config_get bridge "$section" bridge
+
+        ifconfig $bridge down
+        ebtables -t broute -F
+        brctl delif $bridge $WAN
+        brctl delif $bridge $LAN
+        brctl delbr $bridge
+}
+start() {
+        if ! [ -f /proc/net/if_inet6 ]; then
+                echo "IPv6 not enabled, install kmod-ipv6";
+                exit 1;
+        fi
+        config_load "6bridge"
+        config_foreach start_service 6bridge
+}
+
+stop () {
+        config_load "6bridge"
+        config_foreach stop_service 6bridge
+}
diff --git a/ipv6/6scripts/files/6tunnel.conf b/ipv6/6scripts/files/6tunnel.conf
new file mode 100644 (file)
index 0000000..efd8f81
--- /dev/null
@@ -0,0 +1,6 @@
+config 6tunnel
+        option tnlifname     'sixbone'
+        option remoteip4       ''
+       option localip4         ''
+       option localip6         ''
+       option prefix           '/64'
diff --git a/ipv6/6scripts/files/6tunnel.init b/ipv6/6scripts/files/6tunnel.init
new file mode 100644 (file)
index 0000000..cd4e1fc
--- /dev/null
@@ -0,0 +1,64 @@
+#!/bin/sh /etc/rc.common
+START=46
+STOP=46
+
+start_service() {
+       local section="$1"
+       
+       include /lib/network
+       scan_interfaces
+       config_load /var/state/network
+
+       config_get LAN lan ifname
+        config_get tnlifname "$section" tnlifname
+       config_get remoteip4 "$section" remoteip4
+       config_get localip4 "$section" localip4
+       config_get localip6 "$section" localip6
+       config_get prefix "$section" prefix
+
+       ip tunnel add $tnlifname mode sit remote $remoteip4 local $localip4 ttl 255
+       ifconfig $tnlifname up
+       ip addr add $localip6 dev $tnlifname
+       ip route add ::/0 dev $tnlifname
+       ip route add 2000::/3 dev $tnlifname
+       ip -6 addr add $prefix dev $LAN
+}
+
+stop_service() {
+       local section="$1"
+       
+       include /lib/network
+       scan_interfaces
+       config_load /var/state/network
+
+       config_get LAN lan ifname
+        config_get tnlifname "$section" tnlifname
+       config_get remoteip4 "$section" remoteip4
+       config_get localip4 "$section" localip4
+       config_get localip6 "$section" localip6
+       config_get prefix "$section" prefix
+
+       ip -6 addr del $prefix dev $LAN
+       ip -6 ro del 2000::/3 dev $tnlifname
+       ip -6 ro del ::/0 dev $tnlifname
+       ip addr del $localip6 dev $tnlifname
+       ifconfig $tnlifname down
+       ip tunnel del $tnlifname
+}
+start() {
+       if ! [ -f /proc/net/if_inet6 ]; then
+               echo "IPv6 not enabled, install kmod-ipv6";
+               exit 1;
+       fi
+       if ! [ -x /sbin/ip ]; then
+               echo "ip is required to setup the tunnel";
+               exit 1;
+       fi
+       config_load "6tunnel"
+       config_foreach start_service 6tunnel
+}
+
+stop () {
+       config_load "6tunnel"
+       config_foreach stop_service 6tunnel
+}