"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("gateway", "Gateway")
dev = f:field(ListValue, "device", "WLAN-Gerät")
uci:foreach("wireless", "wifi-device",
end)
lanip = f:field(Value, "ipaddr", "LAN IP Adresse")
-lanip.value = "127.23.1.1"
+lanip.value = "172.23.1.1"
+
+lanmsk = f:field(Value, "lanmask", "Lokale LAN Netzmaske")
+lanmsk.value = "255.255.255.0"
-lanmsk = f:field(Value, "netmask", "LAN Netzmaske")
-lanmsk.value = "255.255.0.0"
+gv4msk = f:field(Value, "gv4mask", "Globale LAN Netzmaske")
+gv4msk.value = "255.255.0.0"
-------------------- Control --------------------
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
--
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:network():string(),
+ netmask = gv4_net:mask():string()
+ })
+
--
-- Client mode
--
-- * 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(),
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)
+
+ -- 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",
+ netmask = "0.0.0.0"
+ })
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" or
+ s.src == "lan" and s.dest == "siit0" or
+ s.dest == "lan" 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
+ })
+
+ 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)
prefix = siit_route:prefix()
})
+ -- txtinfo v6
+ uci:foreach("olsrd", "LoadPlugin",
+ function(s)
+ if s.library == "olsrd_txtinfo.so.0.1" then
+ uci:set("olsrd", s['.name'], "accept", "::1")
+ end
+ end)
+
uci:save("wireless")
+ uci:save("firewall")
uci:save("network")
uci:save("olsrd")
end