diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2008-12-21 19:38:49 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2008-12-21 19:38:49 +0000 |
commit | 81424e456f4fc28797c484bc9a4a2f9f8b4ca1ea (patch) | |
tree | d44612d3303ae6e463f1c4b4fb4b22394209cab2 /applications | |
parent | e1bd71a8250c20df1833cf35874cc496ca842bf2 (diff) |
applications/siitwizard: install v4 routes and tweak firewall forwardings
Diffstat (limited to 'applications')
-rw-r--r-- | applications/luci-siitwizard/luasrc/controller/siitwizard.lua | 2 | ||||
-rw-r--r-- | applications/luci-siitwizard/luasrc/model/cbi/siitwizard.lua | 61 |
2 files changed, 52 insertions, 11 deletions
diff --git a/applications/luci-siitwizard/luasrc/controller/siitwizard.lua b/applications/luci-siitwizard/luasrc/controller/siitwizard.lua index dabbcaf43..71b8b300f 100644 --- a/applications/luci-siitwizard/luasrc/controller/siitwizard.lua +++ b/applications/luci-siitwizard/luasrc/controller/siitwizard.lua @@ -17,5 +17,5 @@ $Id$ module "luci.controller.siitwizard" function index() - entry({"admin", "freifunk", "siitwizard"}, form("siitwizard"), "SIIT 4over6 assistent", 50) + entry({"admin", "network", "siitwizard"}, form("siitwizard"), "SIIT 4over6 assistent", 50) end diff --git a/applications/luci-siitwizard/luasrc/model/cbi/siitwizard.lua b/applications/luci-siitwizard/luasrc/model/cbi/siitwizard.lua index ca6ed20f8..ec503ae0d 100644 --- a/applications/luci-siitwizard/luasrc/model/cbi/siitwizard.lua +++ b/applications/luci-siitwizard/luasrc/model/cbi/siitwizard.lua @@ -32,11 +32,12 @@ uci:foreach("wireless", "wifi-device", lanip = f:field(Value, "ipaddr", "LAN IP Adresse") lanip.value = "172.23.1.1" -lanip:depends("mode", "client") -lanmsk = f:field(Value, "netmask", "LAN Netzmaske") -lanmsk.value = "255.255.0.0" -lanmsk:depends("mode", "client") +lanmsk = f:field(Value, "netmask", "Lokale LAN Netzmaske") +lanmsk.value = "255.255.255.0" + +gv4msk = f:field(Value, "netmask", "Globale LAN Netzmaske") +gv4msk.value = "255.255.0.0" -------------------- Control -------------------- @@ -68,6 +69,17 @@ end function mode.write(self, section, value) + -- lan interface + local lan_net = luci.ip.IPv4( + lanip:formvalue(section) or "192.168.1.1", + lanmsk:formvalue(section) or "255.255.255.0" + ) + + local gv4_net = luci.ip.IPv4( + lanip:formvalue(section) or "192.168.1.1", + gv4msk:formvalue(section) or "255.255.0.0" + ) + -- -- Configure wifi device -- @@ -137,11 +149,30 @@ function mode.write(self, section, value) if value == "gateway" then + + -- wan mtu uci:set("network", "wan", "mtu", 1400) + -- lan settings + uci:tset("network", "lan", { + mtu = 1400, + ipaddr = lan_net:host():string(), + netmask = lan_net:mask():string() + }) + -- use full siit subnet siit_route = luci.ip.IPv6(siit_prefix .. "/96") + -- v4 <-> siit route + uci:delete_all("network", "route", + function(s) return s.interface == "siit0" end) + + uci:section("network", "route", nil, { + interface = "siit0", + target = gv4_net:host():string(), + netmask = gv4_net:mask():string() + }) + -- -- Client mode -- @@ -151,12 +182,8 @@ function mode.write(self, section, value) -- * Also, MTU on LAN reduced to 1400. else - -- lan interface - local lan_net = luci.ip.IPv4( - lanip:formvalue(section) or "192.168.1.1", - lanmsk:formvalue(section) or "255.255.255.0" - ) + -- lan settings uci:tset("network", "lan", { mtu = 1400, ipaddr = lan_net:host():string(), @@ -172,6 +199,8 @@ function mode.write(self, section, value) uci:delete_all("network", "route", function(s) return s.interface == "siit0" end) + -- XXX: kind of a catch all, gv4_net would be better + -- but does not cover non-local v4 space uci:section("network", "route", nil, { interface = "siit0", target = "0.0.0.0", @@ -190,7 +219,9 @@ function mode.write(self, section, value) 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" + s.dest == wifi_device and s.src == "siit0" or + s.src == "lan" and s.dest == "siit0" or + s.dest == "lan" and s.src == "siit0" ) end) uci:section("firewall", "zone", "siit0", { @@ -219,6 +250,16 @@ function mode.write(self, section, value) dest = wifi_device }) + uci:section("firewall", "forwarding", nil, { + src = "lan", + dest = "siit0" + }) + + uci:section("firewall", "forwarding", nil, { + src = "siit0", + dest = "lan" + }) + -- siit0 interface uci:delete_all("network", "interface", function(s) return ( s.ifname == "siit0" ) end) |