Provide an IPv6 bridging script
authorFlorian Fainelli <florian@openwrt.org>
Wed, 19 Dec 2007 08:30:28 +0000 (08:30 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Wed, 19 Dec 2007 08:30:28 +0000 (08:30 +0000)
SVN-Revision: 9802

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

index 3150751..64afbff 100644 (file)
@@ -53,8 +53,10 @@ define Package/6tunnel/install
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/6tunnel $(1)/usr/sbin/
        $(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,6tunnel))
diff --git a/ipv6/6tunnel/files/6bridge.conf b/ipv6/6tunnel/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/6tunnel/files/6bridge.init b/ipv6/6tunnel/files/6bridge.init
new file mode 100755 (executable)
index 0000000..2f6ad4a
--- /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
+}