applications/meshwizard: Add ipv6 config options

This commit is contained in:
Manuel Munz 2012-08-20 11:12:39 +00:00
parent adedd765d4
commit 1f1aaf1a66

View file

@ -6,19 +6,22 @@ local util = require "luci.util"
local ip = require "luci.ip" local ip = require "luci.ip"
local community = "profile_" .. (uci:get("freifunk", "community", "name") or "Freifunk") local community = "profile_" .. (uci:get("freifunk", "community", "name") or "Freifunk")
mesh_network = ip.IPv4(uci:get_first(community, "community", "mesh_network") or "10.0.0.0/8") local mesh_network = ip.IPv4(uci:get_first(community, "community", "mesh_network") or "10.0.0.0/8")
local community_ipv6 = uci:get_first(community, "community", "ipv6") or 0
local community_ipv6mode = uci:get_first(community, "community", "ipv6_config") or "static"
local meshkit_ipv6 = uci:get("meshwizard", "ipv6", "enabled") or 0
m = Map("meshwizard", translate("Wizard"), translate("This wizard will assist you in setting up your router for Freifunk " .. m = Map("meshwizard", translate("Wizard"), translate("This wizard will assist you in setting up your router for Freifunk " ..
"or another similar wireless community network.")) "or another similar wireless community network."))
--m:chain("meshwizard")
n = m:section(TypedSection, "netconfig", translate("Interfaces")) n = m:section(NamedSection, "netconfig", nil, translate("Interfaces"))
n.anonymous = true n.anonymous = true
-- common functions -- common functions
function cbi_configure(device) function cbi_configure(device)
local configure = n:taboption(device, Flag, device .. "_config", translate("Configure this interface")) local configure = n:taboption(device, Flag, device .. "_config", translate("Configure this interface"),
translate("Note: this will setup this interface for mesh operation, i.e. add to zone 'freifunk' and enable olsr."))
end end
function cbi_ip4addr(device) function cbi_ip4addr(device)
@ -37,6 +40,14 @@ function cbi_ip4addr(device)
end end
end end
function cbi_ip6addr(device)
local ip6addr = n:taboption(device, Value, device .. "_ip6addr", translate("Mesh IPv6 address"),
translate("This is a unique IPv6 address in CIDR notation (e.g. 2001:1:2:3::1/64) and has to be registered at your local community."))
ip6addr:depends(device .. "_config", 1)
ip6addr.datatype = "ip6addr"
end
function cbi_dhcp(device) function cbi_dhcp(device)
local dhcp = n:taboption(device, Flag, device .. "_dhcp", translate("Enable DHCP"), local dhcp = n:taboption(device, Flag, device .. "_dhcp", translate("Enable DHCP"),
translate("DHCP will automatically assign ip addresses to clients")) translate("DHCP will automatically assign ip addresses to clients"))
@ -44,6 +55,13 @@ function cbi_dhcp(device)
dhcp.rmempty = true dhcp.rmempty = true
end end
function cbi_ra(device)
local ra = n:taboption(device, Flag, device .. "_ipv6ra", translate("Enable RA"),
translate("Send router advertisements on this device."))
ra:depends(device .. "_config", 1)
ra.rmempty = true
end
function cbi_dhcprange(device) function cbi_dhcprange(device)
local dhcprange = n:taboption(device, Value, device .. "_dhcprange", translate("DHCP IP range"), local dhcprange = n:taboption(device, Value, device .. "_dhcprange", translate("DHCP IP range"),
translate("The IP range from which clients are assigned ip addresses (e.g. 10.1.2.1/28). " .. translate("The IP range from which clients are assigned ip addresses (e.g. 10.1.2.1/28). " ..
@ -63,7 +81,7 @@ end)
local wired_nets = {} local wired_nets = {}
uci:foreach("network", "interface", function(section) uci:foreach("network", "interface", function(section)
local device = section[".name"] local device = section[".name"]
if not util.contains(nets, device) and device ~= "loopback" then if not util.contains(nets, device) and device ~= "loopback" and not device:find("wireless") then
table.insert(nets, device) table.insert(nets, device)
table.insert(wired_nets, device) table.insert(wired_nets, device)
end end
@ -115,6 +133,14 @@ uci:foreach("wireless", "wifi-device", function(section)
-- DHCP range -- DHCP range
cbi_dhcprange(device) cbi_dhcprange(device)
-- IPv6 addr and RA
if community_ipv6 == "1" then
if community_ipv6mode == "static" then
cbi_ip6addr(device)
end
cbi_ra(device)
end
-- Enable VAP -- Enable VAP
if hwtype == "atheros" then if hwtype == "atheros" then
local vap = n:taboption(device, Flag, device .. "_vap", translate("Virtual Access Point (VAP)"), local vap = n:taboption(device, Flag, device .. "_vap", translate("Virtual Access Point (VAP)"),
@ -129,8 +155,16 @@ for _, device in pairs(wired_nets) do
cbi_ip4addr(device) cbi_ip4addr(device)
cbi_dhcp(device) cbi_dhcp(device)
cbi_dhcprange(device) cbi_dhcprange(device)
-- IPv6 addr and RA
if community_ipv6 == "1" then
if community_ipv6mode == "static" then
cbi_ip6addr(device)
end
cbi_ra(device)
end
end end
-- General settings
g = m:section(TypedSection, "general", translate("General Settings")) g = m:section(TypedSection, "general", translate("General Settings"))
g.anonymous = true g.anonymous = true
@ -145,8 +179,13 @@ local share = g:option(Flag, "sharenet", translate("Share your internet connecti
translate("Select this to allow others to use your connection to access the internet.")) translate("Select this to allow others to use your connection to access the internet."))
share.rmempty = true share.rmempty = true
--function m.on_after_commit (self) -- IPv6 config
-- sys.call("/usr/bin/mesh-wizard/wizard.sh >/dev/null") if community_ipv6 == "1" then
--end v6 = m:section(NamedSection, "ipv6", nil, translate("IPv6 Settings"))
local enabled = v6:option(Flag, "enabled", translate("Enabled"),
translate("Activate or deactivate IPv6 config globally."))
enabled.default = meshkit_ipv6
enabled.rmempty = false
end
return m return m