applications/siitwizard: also setup v4 routes and firewall
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 21 Dec 2008 19:17:12 +0000 (19:17 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 21 Dec 2008 19:17:12 +0000 (19:17 +0000)
applications/luci-siitwizard/luasrc/model/cbi/siitwizard.lua

index a6b4050..ca6ed20 100644 (file)
@@ -21,8 +21,8 @@ f = SimpleForm("siitwizward", "4over6-Assistent",
  "Dieser Assistent unterstüzt bei der Einrichtung von IPv4-over-IPv6 Translation.")
 
 mode = f:field(ListValue, "mode", "Betriebsmodus")
  "Dieser Assistent unterstüzt bei der Einrichtung von IPv4-over-IPv6 Translation.")
 
 mode = f:field(ListValue, "mode", "Betriebsmodus")
-mode:value("gateway", "Gateway")
 mode:value("client", "Client")
 mode:value("client", "Client")
+mode:value("gateway", "Gateway")
 
 dev = f:field(ListValue, "device", "WLAN-Gerät")
 uci:foreach("wireless", "wifi-device",
 
 dev = f:field(ListValue, "device", "WLAN-Gerät")
 uci:foreach("wireless", "wifi-device",
@@ -168,8 +168,57 @@ function mode.write(self, section, value)
                        siit_prefix .. "/" .. (96 + lan_net:prefix())
                ):add(lan_net[2])
 
                        siit_prefix .. "/" .. (96 + lan_net:prefix())
                ):add(lan_net[2])
 
+               -- ipv4 <-> siit route
+               uci:delete_all("network", "route",
+                       function(s) return s.interface == "siit0" end)
+
+               uci:section("network", "route", nil, {
+                       interface = "siit0",
+                       target    = "0.0.0.0",
+                       netmask   = "0.0.0.0"
+               })
        end
 
        end
 
+       -- setup the firewall
+       uci:delete_all("firewall", "zone",
+               function(s) return (
+                       s['.name'] == "siit0" or s.name == "siit0" or
+                       s.network == "siit0" or s['.name'] == wifi_device or
+                       s.name == wifi_device or s.network == wifi_device
+               ) end)
+
+       uci:delete_all("firewall", "forwarding",
+               function(s) return (
+                       s.src == wifi_device and s.dest == "siit0" or
+                       s.dest == wifi_device and s.src == "siit0"
+               ) end)
+
+       uci:section("firewall", "zone", "siit0", {
+               name    = "siit0",
+               network = "siit0",
+               input   = "ACCEPT",
+               output  = "ACCEPT",
+               forward = "ACCEPT"
+       })
+
+       uci:section("firewall", "zone", wifi_device, {
+               name    = wifi_device,
+               network = wifi_device,
+               input   = "ACCEPT",
+               output  = "ACCEPT",
+               forward = "ACCEPT"
+       })
+
+       uci:section("firewall", "forwarding", nil, {
+               src  = wifi_device,
+               dest = "siit0"
+       })
+
+       uci:section("firewall", "forwarding", nil, {
+               src  = "siit0",
+               dest = wifi_device
+       })
+
        -- siit0 interface
        uci:delete_all("network", "interface",
                function(s) return ( s.ifname == "siit0" ) end)
        -- siit0 interface
        uci:delete_all("network", "interface",
                function(s) return ( s.ifname == "siit0" ) end)
@@ -225,6 +274,7 @@ function mode.write(self, section, value)
        })
 
        uci:save("wireless")
        })
 
        uci:save("wireless")
+       uci:save("firewall")
        uci:save("network")
        uci:save("olsrd")
 end
        uci:save("network")
        uci:save("olsrd")
 end