diff options
Diffstat (limited to 'applications/luci-app-radvd/luasrc')
7 files changed, 1085 insertions, 0 deletions
diff --git a/applications/luci-app-radvd/luasrc/controller/radvd.lua b/applications/luci-app-radvd/luasrc/controller/radvd.lua new file mode 100644 index 0000000000..58dcbb2eac --- /dev/null +++ b/applications/luci-app-radvd/luasrc/controller/radvd.lua @@ -0,0 +1,28 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- + +module("luci.controller.radvd", package.seeall) + +function index() + if not nixio.fs.access("/etc/config/radvd") then + return + end + + entry({"admin", "network", "radvd"}, cbi("radvd"), _("Radvd"), 61) + entry({"admin", "network", "radvd", "interface"}, cbi("radvd/interface"), nil).leaf = true + entry({"admin", "network", "radvd", "prefix"}, cbi("radvd/prefix"), nil).leaf = true + entry({"admin", "network", "radvd", "route"}, cbi("radvd/route"), nil).leaf = true + entry({"admin", "network", "radvd", "rdnss"}, cbi("radvd/rdnss"), nil).leaf = true + entry({"admin", "network", "radvd", "dnssl"}, cbi("radvd/dnssl"), nil).leaf = true +end diff --git a/applications/luci-app-radvd/luasrc/model/cbi/radvd.lua b/applications/luci-app-radvd/luasrc/model/cbi/radvd.lua new file mode 100644 index 0000000000..a43e8d9548 --- /dev/null +++ b/applications/luci-app-radvd/luasrc/model/cbi/radvd.lua @@ -0,0 +1,335 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- + +m = Map("radvd", translate("Radvd"), + translate("Radvd is a router advertisement daemon for IPv6. " .. + "It listens to router solicitations and sends router advertisements " .. + "as described in RFC 4861.")) + +local nm = require "luci.model.network".init(m.uci) +local ut = require "luci.util" + + +-- +-- Interfaces +-- + +s = m:section(TypedSection, "interface", translate("Interfaces")) +s.template = "cbi/tblsection" +s.extedit = luci.dispatcher.build_url("admin/network/radvd/interface/%s") +s.anonymous = true +s.addremove = true + +function s.create(...) + local id = TypedSection.create(...) + luci.http.redirect(s.extedit % id) +end + +function s.remove(self, section) + if m.uci:get("radvd", section) == "interface" then + local iface = m.uci:get("radvd", section, "interface") + if iface then + m.uci:delete_all("radvd", "prefix", + function(s) return s.interface == iface end) + + m.uci:delete_all("radvd", "route", + function(s) return s.interface == iface end) + + m.uci:delete_all("radvd", "rdnss", + function(s) return s.interface == iface end) + end + end + + return TypedSection.remove(self, section) +end + +o = s:option(Flag, "ignore", translate("Enable")) +o.rmempty = false +o.width = "30px" +function o.cfgvalue(...) + local v = Flag.cfgvalue(...) + return v == "1" and "0" or "1" +end +function o.write(self, section, value) + Flag.write(self, section, value == "1" and "0" or "1") +end + +o = s:option(DummyValue, "interface", translate("Interface")) +o.template = "cbi/network_netinfo" +o.width = "10%" + +o = s:option(DummyValue, "UnicastOnly", translate("Multicast")) +function o.cfgvalue(self, section) + local v = Value.cfgvalue(self, section) + local v2 = m.uci:get("radvd", section, "client") + return (v == "1" or (v2 and #v2 > 0)) and translate("no") or translate("yes") +end + +o = s:option(DummyValue, "AdvSendAdvert", translate("Advertising")) +function o.cfgvalue(...) + local v = Value.cfgvalue(...) + return v == "1" and translate("yes") or translate("no") +end + +o = s:option(DummyValue, "MaxRtrAdvInterval", translate("Max. interval")) +function o.cfgvalue(...) + local v = Value.cfgvalue(...) or "600" + return v .. "s" +end + +o = s:option(DummyValue, "AdvHomeAgentFlag", translate("Mobile IPv6")) +function o.cfgvalue(...) + local v = Value.cfgvalue(...) + return v == "1" and translate("yes") or translate("no") +end + +o = s:option(DummyValue, "AdvDefaultPreference", translate("Preference")) +function o.cfgvalue(...) + local v = Value.cfgvalue(...) or "medium" + return translate(v) +end + + +-- +-- Prefixes +-- + +s2 = m:section(TypedSection, "prefix", translate("Prefixes")) +s2.template = "cbi/tblsection" +s2.extedit = luci.dispatcher.build_url("admin/network/radvd/prefix/%s") +s2.addremove = true +s2.anonymous = true + +function s2.create(...) + local id = TypedSection.create(...) + luci.http.redirect(s2.extedit % id) +end + + +o = s2:option(Flag, "ignore", translate("Enable")) +o.rmempty = false +o.width = "30px" +function o.cfgvalue(...) + local v = Flag.cfgvalue(...) + return v == "1" and "0" or "1" +end +function o.write(self, section, value) + Flag.write(self, section, value == "1" and "0" or "1") +end + +o = s2:option(DummyValue, "interface", translate("Interface")) +o.template = "cbi/network_netinfo" +o.width = "10%" + +pfx = s2:option(DummyValue, "prefix", translate("Prefix")) +pfx.width = "60%" +function pfx.cfgvalue(self, section) + local v = m.uci:get_list("radvd", section, self.option) + local l = { } + + if not v or #v == 0 or (#v == 1 and #v[1] == 0) then + local net = nm:get_network(m.uci:get("radvd", section, "interface")) + if net then + local ifc = nm:get_interface(net:ifname()) + if ifc then + local adr + for _, adr in ipairs(ifc:ip6addrs()) do + if not adr:is6linklocal() then + v = adr:string() + break + end + end + end + end + end + + for v in ut.imatch(v) do + v = luci.ip.IPv6(v) + if v then + l[#l+1] = v:string() + end + end + + if #l == 0 then + l[1] = "?" + end + + return table.concat(l, ", ") +end + +o = s2:option(DummyValue, "AdvAutonomous", translate("Autonomous")) +function o.cfgvalue(...) + local v = Value.cfgvalue(...) + return v == "1" and translate("yes") or translate("no") +end + +o = s2:option(DummyValue, "AdvOnLink", translate("On-link")) +function o.cfgvalue(...) + local v = Value.cfgvalue(...) + return v == "1" and translate("yes") or translate("no") +end + +o = s2:option(DummyValue, "AdvValidLifetime", translate("Validity time")) +function o.cfgvalue(...) + local v = Value.cfgvalue(...) or "86400" + return translate(v) +end + + +-- +-- Routes +-- + +s3 = m:section(TypedSection, "route", translate("Routes")) +s3.template = "cbi/tblsection" +s3.extedit = luci.dispatcher.build_url("admin/network/radvd/route/%s") +s3.addremove = true +s3.anonymous = true + +function s3.create(...) + local id = TypedSection.create(...) + luci.http.redirect(s3.extedit % id) +end + + +o = s3:option(Flag, "ignore", translate("Enable")) +o.rmempty = false +o.width = "30px" +function o.cfgvalue(...) + local v = Flag.cfgvalue(...) + return v == "1" and "0" or "1" +end +function o.write(self, section, value) + Flag.write(self, section, value == "1" and "0" or "1") +end + +o = s3:option(DummyValue, "interface", translate("Interface")) +o.template = "cbi/network_netinfo" +o.width = "10%" + +o = s3:option(DummyValue, "prefix", translate("Prefix")) +o.width = "60%" +o.cfgvalue = pfx.cfgvalue + +o = s3:option(DummyValue, "AdvRouteLifetime", translate("Lifetime")) +function o.cfgvalue(self, section) + local v = Value.cfgvalue(self, section) or "1800" + return translate(v) +end + +o = s3:option(DummyValue, "AdvRoutePreference", translate("Preference")) +function o.cfgvalue(self, section) + local v = Value.cfgvalue(self, section) or "medium" + return translate(v) +end + + +-- +-- RDNSS +-- + +s4 = m:section(TypedSection, "rdnss", translate("RDNSS")) +s4.template = "cbi/tblsection" +s4.extedit = luci.dispatcher.build_url("admin/network/radvd/rdnss/%s") +s4.addremove = true +s4.anonymous = true + +function s4.create(...) + local id = TypedSection.create(...) + luci.http.redirect(s4.extedit % id) +end + + +o = s4:option(Flag, "ignore", translate("Enable")) +o.rmempty = false +o.width = "30px" +function o.cfgvalue(...) + local v = Flag.cfgvalue(...) + return v == "1" and "0" or "1" +end +function o.write(self, section, value) + Flag.write(self, section, value == "1" and "0" or "1") +end + +o = s4:option(DummyValue, "interface", translate("Interface")) +o.template = "cbi/network_netinfo" +o.width = "10%" + +o = s4:option(DummyValue, "addr", translate("Address")) +o.width = "60%" +o.cfgvalue = pfx.cfgvalue + +o = s4:option(DummyValue, "AdvRDNSSLifetime", translate("Lifetime")) +function o.cfgvalue(self, section) + local v = Value.cfgvalue(self, section) or "1200" + return translate(v) +end + + +-- +-- DNSSL +-- + +s5 = m:section(TypedSection, "dnssl", translate("DNSSL")) +s5.template = "cbi/tblsection" +s5.extedit = luci.dispatcher.build_url("admin/network/radvd/dnssl/%s") +s5.addremove = true +s5.anonymous = true + +function s5.create(...) + local id = TypedSection.create(...) + luci.http.redirect(s5.extedit % id) +end + + +o = s5:option(Flag, "ignore", translate("Enable")) +o.rmempty = false +o.width = "30px" +function o.cfgvalue(...) + local v = Flag.cfgvalue(...) + return v == "1" and "0" or "1" +end +function o.write(self, section, value) + Flag.write(self, section, value == "1" and "0" or "1") +end + +o = s5:option(DummyValue, "interface", translate("Interface")) +o.template = "cbi/network_netinfo" +o.width = "10%" + +o = s5:option(DummyValue, "suffix", translate("Suffix")) +o.width = "60%" +function o.cfgvalue(self, section) + local v = m.uci:get_list("radvd", section, "suffix") + local l = { } + + for v in ut.imatch(v) do + l[#l+1] = v + end + + if #l == 0 then + l[1] = "?" + end + + return table.concat(l, ", ") +end + +o = s5:option(DummyValue, "AdvDNSSLLifetime", translate("Lifetime")) +function o.cfgvalue(self, section) + local v = Value.cfgvalue(self, section) or "1200" + return translate(v) +end + + +return m diff --git a/applications/luci-app-radvd/luasrc/model/cbi/radvd/dnssl.lua b/applications/luci-app-radvd/luasrc/model/cbi/radvd/dnssl.lua new file mode 100644 index 0000000000..ec67f308ae --- /dev/null +++ b/applications/luci-app-radvd/luasrc/model/cbi/radvd/dnssl.lua @@ -0,0 +1,99 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id: rdnss.lua 6715 2011-01-13 20:03:40Z jow $ +]]-- + +local sid = arg[1] +local utl = require "luci.util" + +m = Map("radvd", translatef("Radvd - DNSSL"), + translate("Radvd is a router advertisement daemon for IPv6. " .. + "It listens to router solicitations and sends router advertisements " .. + "as described in RFC 4861.")) + +m.redirect = luci.dispatcher.build_url("admin/network/radvd") + +if m.uci:get("radvd", sid) ~= "dnssl" then + luci.http.redirect(m.redirect) + return +end + + +s = m:section(NamedSection, sid, "interface", translate("DNSSL Configuration")) +s.addremove = false + + +-- +-- General +-- + +o = s:option(Flag, "ignore", translate("Enable")) +o.rmempty = false + +function o.cfgvalue(...) + local v = Flag.cfgvalue(...) + return v == "1" and "0" or "1" +end + +function o.write(self, section, value) + Flag.write(self, section, value == "1" and "0" or "1") +end + + +o = s:option(Value, "interface", translate("Interface"), + translate("Specifies the logical interface name this section belongs to")) + +o.template = "cbi/network_netlist" +o.nocreate = true +o.optional = false + +function o.formvalue(...) + return Value.formvalue(...) or "-" +end + +function o.validate(self, value) + if value == "-" then + return nil, translate("Interface required") + end + return value +end + +function o.write(self, section, value) + m.uci:set("radvd", section, "ignore", 0) + m.uci:set("radvd", section, "interface", value) +end + + +o = s:option(DynamicList, "suffix", translate("Suffix"), + translate("Advertised Domain Suffixes")) + +o.optional = false +o.rmempty = false +o.datatype = "hostname" +function o.cfgvalue(self, section) + local l = { } + local v = m.uci:get_list("radvd", section, "suffix") + for v in utl.imatch(v) do + l[#l+1] = v + end + return l +end + + +o = s:option(Value, "AdvDNSSLLifetime", translate("Lifetime"), + translate("Specifies the maximum duration how long the DNSSL entries are used for name resolution.")) + +o.datatype = 'or(uinteger,"infinity")' +o.placeholder = 1200 + + +return m diff --git a/applications/luci-app-radvd/luasrc/model/cbi/radvd/interface.lua b/applications/luci-app-radvd/luasrc/model/cbi/radvd/interface.lua new file mode 100644 index 0000000000..519664cdc2 --- /dev/null +++ b/applications/luci-app-radvd/luasrc/model/cbi/radvd/interface.lua @@ -0,0 +1,276 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- + +local sid = arg[1] +local utl = require "luci.util" + +m = Map("radvd", translatef("Radvd - Interface %q", "?"), + translate("Radvd is a router advertisement daemon for IPv6. " .. + "It listens to router solicitations and sends router advertisements " .. + "as described in RFC 4861.")) + +m.redirect = luci.dispatcher.build_url("admin/network/radvd") + +if m.uci:get("radvd", sid) ~= "interface" then + luci.http.redirect(m.redirect) + return +end + +m.uci:foreach("radvd", "interface", + function(s) + if s['.name'] == sid and s.interface then + m.title = translatef("Radvd - Interface %q", s.interface) + return false + end + end) + + +s = m:section(NamedSection, sid, "interface", translate("Interface Configuration")) +s.addremove = false + +s:tab("general", translate("General")) +s:tab("timing", translate("Timing")) +s:tab("mobile", translate("Mobile IPv6")) + + +-- +-- General +-- + +o = s:taboption("general", Flag, "ignore", translate("Enable")) +o.rmempty = false + +function o.cfgvalue(...) + local v = Flag.cfgvalue(...) + return v == "1" and "0" or "1" +end + +function o.write(self, section, value) + Flag.write(self, section, value == "1" and "0" or "1") +end + + +o = s:taboption("general", Value, "interface", translate("Interface"), + translate("Specifies the logical interface name this section belongs to")) + +o.template = "cbi/network_netlist" +o.nocreate = true +o.optional = false + +function o.formvalue(...) + return Value.formvalue(...) or "-" +end + +function o.validate(self, value) + if value == "-" then + return nil, translate("Interface required") + end + return value +end + +function o.write(self, section, value) + m.uci:set("radvd", section, "ignore", 0) + m.uci:set("radvd", section, "interface", value) +end + + +o = s:taboption("general", DynamicList, "client", translate("Clients"), + translate("Restrict communication to specified clients, leave empty to use multicast")) + +o.rmempty = true +o.datatype = "ip6addr" +o.placeholder = "any" +function o.cfgvalue(...) + local v = Value.cfgvalue(...) + local l = { } + for v in utl.imatch(v) do + l[#l+1] = v + end + return l +end + + +o = s:taboption("general", Flag, "AdvSendAdvert", translate("Enable advertisements"), + translate("Enables router advertisements and solicitations")) + +o.rmempty = false +function o.write(self, section, value) + if value == "1" then + m.uci:set("radvd", section, "ignore", 0) + m.uci:set("radvd", section, "IgnoreIfMissing", 1) + end + + m.uci:set("radvd", section, "AdvSendAdvert", value) +end + + +o = s:taboption("general", Flag, "UnicastOnly", translate("Unicast only"), + translate("Indicates that the underlying link is not broadcast capable, prevents unsolicited advertisements from being sent")) + +o:depends("AdvSendAdvert", "1") + + +o = s:taboption("general", Flag, "AdvManagedFlag", translate("Managed flag"), + translate("Enables the additional stateful administered autoconfiguration protocol (RFC2462)")) + +o:depends("AdvSendAdvert", "1") + + +o = s:taboption("general", Flag, "AdvOtherConfigFlag", translate("Configuration flag"), + translate("Enables the autoconfiguration of additional, non address information (RFC2462)")) + +o:depends("AdvSendAdvert", "1") + + +o = s:taboption("general", Flag, "AdvSourceLLAddress", translate("Source link-layer address"), + translate("Includes the link-layer address of the outgoing interface in the RA")) + +o.rmempty = false +o.default = "1" +o:depends("AdvSendAdvert", "1") + + +o = s:taboption("general", Value, "AdvLinkMTU", translate("Link MTU"), + translate("Advertises the given link MTU in the RA if specified. 0 disables MTU advertisements")) + +o.datatype = "uinteger" +o.placeholder = 0 +o:depends("AdvSendAdvert", "1") + + +o = s:taboption("general", Value, "AdvCurHopLimit", translate("Current hop limit"), + translate("Advertises the default Hop Count value for outgoing unicast packets in the RA. 0 disables hopcount advertisements")) + +o.datatype = "uinteger" +o.optional = false +o.placeholder = 64 +o:depends("AdvSendAdvert", "1") + + +o = s:taboption("general", ListValue, "AdvDefaultPreference", translate("Default preference"), + translate("Advertises the default router preference")) + +o.optional = false +o.default = "medium" +o:value("low", translate("low")) +o:value("medium", translate("medium")) +o:value("high", translate("high")) +o:depends("AdvSendAdvert", "1") + + +-- +-- Timing +-- + +o = s:taboption("timing", Value, "MinRtrAdvInterval", translate("Minimum advertisement interval"), + translate("The minimum time allowed between sending unsolicited multicast router advertisements from the interface, in seconds")) + +o.datatype = "uinteger" +o.optional = false +o.placeholder = 198 +o:depends("AdvSendAdvert", "1") + + +o = s:taboption("timing", Value, "MaxRtrAdvInterval", translate("Maximum advertisement interval"), + translate("The maximum time allowed between sending unsolicited multicast router advertisements from the interface, in seconds")) + +o.datatype = "uinteger" +o.optional = false +o.placeholder = 600 +o:depends("AdvSendAdvert", "1") + + +o = s:taboption("timing", Value, "MinDelayBetweenRAs", translate("Minimum advertisement delay"), + translate("The minimum time allowed between sending multicast router advertisements from the interface, in seconds")) + +o.datatype = "uinteger" +o.optional = false +o.placeholder = 3 +o:depends("AdvSendAdvert", "1") + + +o = s:taboption("timing", Value, "AdvReachableTime", translate("Reachable time"), + translate("Advertises assumed reachability time in milliseconds of neighbours in the RA if specified. 0 disables reachability advertisements")) + +o.datatype = "uinteger" +o.optional = false +o.placeholder = 0 +o:depends("AdvSendAdvert", "1") + + +o = s:taboption("timing", Value, "AdvRetransTimer", translate("Retransmit timer"), + translate("Advertises wait time in milliseconds between Neighbor Solicitation messages in the RA if specified. 0 disables retransmit advertisements")) + +o.datatype = "uinteger" +o.optional = false +o.placeholder = 0 +o:depends("AdvSendAdvert", "1") + + +o = s:taboption("timing", Value, "AdvDefaultLifetime", translate("Default lifetime"), + translate("Advertises the lifetime of the default router in seconds. 0 indicates that the node is no default router")) + +o.datatype = "uinteger" +o.optional = false +o.placeholder = 1800 +o:depends("AdvSendAdvert", "1") + + +-- +-- Mobile +-- + +o = s:taboption("mobile", Flag, "AdvHomeAgentFlag", translate("Advertise Home Agent flag"), + translate("Advertises Mobile IPv6 Home Agent capability (RFC3775)")) + +o:depends("AdvSendAdvert", "1") + + +o = s:taboption("mobile", Flag, "AdvIntervalOpt", translate("Mobile IPv6 interval option"), + translate("Include Mobile IPv6 Advertisement Interval option to RA")) + +o:depends({AdvHomeAgentFlag = "1", AdvSendAdvert = "1"}) + + +o = s:taboption("mobile", Flag, "AdvHomeAgentInfo", translate("Home Agent information"), + translate("Include Home Agent Information in the RA")) + +o:depends({AdvHomeAgentFlag = "1", AdvSendAdvert = "1"}) + + +o = s:taboption("mobile", Flag, "AdvMobRtrSupportFlag", translate("Mobile IPv6 router registration"), + translate("Advertises Mobile Router registration capability (NEMO Basic)")) + +o:depends({AdvHomeAgentInfo = "1", AdvSendAdvert = "1"}) + + +o = s:taboption("mobile", Value, "HomeAgentLifetime", translate("Home Agent lifetime"), + translate("Advertises the time in seconds the router is offering Mobile IPv6 Home Agent services")) + +o.datatype = "uinteger" +o.optional = false +o.placeholder = 1800 +o:depends({AdvHomeAgentInfo = "1", AdvSendAdvert = "1"}) + + +o = s:taboption("mobile", Value, "HomeAgentPreference", translate("Home Agent preference"), + translate("The preference for the Home Agent sending this RA")) + +o.datatype = "uinteger" +o.optional = false +o.placeholder = 0 +o:depends({AdvHomeAgentInfo = "1", AdvSendAdvert = "1"}) + + +return m diff --git a/applications/luci-app-radvd/luasrc/model/cbi/radvd/prefix.lua b/applications/luci-app-radvd/luasrc/model/cbi/radvd/prefix.lua new file mode 100644 index 0000000000..6032986510 --- /dev/null +++ b/applications/luci-app-radvd/luasrc/model/cbi/radvd/prefix.lua @@ -0,0 +1,139 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- + +local sid = arg[1] +local utl = require "luci.util" + +m = Map("radvd", translatef("Radvd - Prefix"), + translate("Radvd is a router advertisement daemon for IPv6. " .. + "It listens to router solicitations and sends router advertisements " .. + "as described in RFC 4861.")) + +m.redirect = luci.dispatcher.build_url("admin/network/radvd") + +if m.uci:get("radvd", sid) ~= "prefix" then + luci.http.redirect(m.redirect) + return +end + + +s = m:section(NamedSection, sid, "interface", translate("Prefix Configuration")) +s.addremove = false + +s:tab("general", translate("General")) +s:tab("advanced", translate("Advanced")) + + +-- +-- General +-- + +o = s:taboption("general", Flag, "ignore", translate("Enable")) +o.rmempty = false + +function o.cfgvalue(...) + local v = Flag.cfgvalue(...) + return v == "1" and "0" or "1" +end + +function o.write(self, section, value) + Flag.write(self, section, value == "1" and "0" or "1") +end + + +o = s:taboption("general", Value, "interface", translate("Interface"), + translate("Specifies the logical interface name this section belongs to")) + +o.template = "cbi/network_netlist" +o.nocreate = true +o.optional = false + +function o.formvalue(...) + return Value.formvalue(...) or "-" +end + +function o.validate(self, value) + if value == "-" then + return nil, translate("Interface required") + end + return value +end + +function o.write(self, section, value) + m.uci:set("radvd", section, "ignore", 0) + m.uci:set("radvd", section, "interface", value) +end + + +o = s:taboption("general", DynamicList, "prefix", translate("Prefixes"), + translate("Advertised IPv6 prefixes. If empty, the current interface prefix is used")) + +o.optional = true +o.datatype = "ip6addr" +o.placeholder = translate("default") +function o.cfgvalue(self, section) + local l = { } + local v = m.uci:get_list("radvd", section, "prefix") + for v in utl.imatch(v) do + l[#l+1] = v + end + return l +end + + +o = s:taboption("general", Flag, "AdvOnLink", translate("On-link determination"), + translate("Indicates that this prefix can be used for on-link determination (RFC4861)")) + +o.rmempty = false +o.default = "1" + + +o = s:taboption("general", Flag, "AdvAutonomous", translate("Autonomous"), + translate("Indicates that this prefix can be used for autonomous address configuration (RFC4862)")) + +o.rmempty = false +o.default = "1" + + +-- +-- Advanced +-- + +o = s:taboption("advanced", Flag, "AdvRouterAddr", translate("Advertise router address"), + translate("Indicates that the address of interface is sent instead of network prefix, as is required by Mobile IPv6")) + + +o = s:taboption("advanced", Value, "AdvValidLifetime", translate("Valid lifetime"), + translate("Advertises the length of time in seconds that the prefix is valid for the purpose of on-link determination.")) + +o.datatype = 'or(uinteger,"infinity")' +o.placeholder = 86400 + + +o = s:taboption("advanced", Value, "AdvPreferredLifetime", translate("Preferred lifetime"), + translate("Advertises the length of time in seconds that addresses generated from the prefix via stateless address autoconfiguration remain preferred.")) + +o.datatype = 'or(uinteger,"infinity")' +o.placeholder = 14400 + + +o = s:taboption("advanced", Value, "Base6to4Interface", translate("6to4 interface"), + translate("Specifies a logical interface name to derive a 6to4 prefix from. The interfaces public IPv4 address is combined with 2002::/3 and the value of the prefix option")) + +o.template = "cbi/network_netlist" +o.nocreate = true +o.unspecified = true + + +return m diff --git a/applications/luci-app-radvd/luasrc/model/cbi/radvd/rdnss.lua b/applications/luci-app-radvd/luasrc/model/cbi/radvd/rdnss.lua new file mode 100644 index 0000000000..ea65263996 --- /dev/null +++ b/applications/luci-app-radvd/luasrc/model/cbi/radvd/rdnss.lua @@ -0,0 +1,100 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- + +local sid = arg[1] +local utl = require "luci.util" + +m = Map("radvd", translatef("Radvd - RDNSS"), + translate("Radvd is a router advertisement daemon for IPv6. " .. + "It listens to router solicitations and sends router advertisements " .. + "as described in RFC 4861.")) + +m.redirect = luci.dispatcher.build_url("admin/network/radvd") + +if m.uci:get("radvd", sid) ~= "rdnss" then + luci.http.redirect(m.redirect) + return +end + + +s = m:section(NamedSection, sid, "interface", translate("RDNSS Configuration")) +s.addremove = false + + +-- +-- General +-- + +o = s:option(Flag, "ignore", translate("Enable")) +o.rmempty = false + +function o.cfgvalue(...) + local v = Flag.cfgvalue(...) + return v == "1" and "0" or "1" +end + +function o.write(self, section, value) + Flag.write(self, section, value == "1" and "0" or "1") +end + + +o = s:option(Value, "interface", translate("Interface"), + translate("Specifies the logical interface name this section belongs to")) + +o.template = "cbi/network_netlist" +o.nocreate = true +o.optional = false + +function o.formvalue(...) + return Value.formvalue(...) or "-" +end + +function o.validate(self, value) + if value == "-" then + return nil, translate("Interface required") + end + return value +end + +function o.write(self, section, value) + m.uci:set("radvd", section, "ignore", 0) + m.uci:set("radvd", section, "interface", value) +end + + +o = s:option(DynamicList, "addr", translate("Addresses"), + translate("Advertised IPv6 RDNSS. If empty, the current IPv6 address of the interface is used")) + +o.optional = false +o.rmempty = true +o.datatype = "ip6addr" +o.placeholder = translate("default") +function o.cfgvalue(self, section) + local l = { } + local v = m.uci:get_list("radvd", section, "addr") + for v in utl.imatch(v) do + l[#l+1] = v + end + return l +end + + +o = s:option(Value, "AdvRDNSSLifetime", translate("Lifetime"), + translate("Specifies the maximum duration how long the RDNSS entries are used for name resolution.")) + +o.datatype = 'or(uinteger,"infinity")' +o.placeholder = 1200 + + +return m diff --git a/applications/luci-app-radvd/luasrc/model/cbi/radvd/route.lua b/applications/luci-app-radvd/luasrc/model/cbi/radvd/route.lua new file mode 100644 index 0000000000..97c72a4ec3 --- /dev/null +++ b/applications/luci-app-radvd/luasrc/model/cbi/radvd/route.lua @@ -0,0 +1,108 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- + +local sid = arg[1] +local utl = require "luci.util" + +m = Map("radvd", translatef("Radvd - Route"), + translate("Radvd is a router advertisement daemon for IPv6. " .. + "It listens to router solicitations and sends router advertisements " .. + "as described in RFC 4861.")) + +m.redirect = luci.dispatcher.build_url("admin/network/radvd") + +if m.uci:get("radvd", sid) ~= "route" then + luci.http.redirect(m.redirect) + return +end + + +s = m:section(NamedSection, sid, "interface", translate("Route Configuration")) +s.addremove = false + + +-- +-- General +-- + +o = s:option(Flag, "ignore", translate("Enable")) +o.rmempty = false + +function o.cfgvalue(...) + local v = Flag.cfgvalue(...) + return v == "1" and "0" or "1" +end + +function o.write(self, section, value) + Flag.write(self, section, value == "1" and "0" or "1") +end + + +o = s:option(Value, "interface", translate("Interface"), + translate("Specifies the logical interface name this section belongs to")) + +o.template = "cbi/network_netlist" +o.nocreate = true +o.optional = false + +function o.formvalue(...) + return Value.formvalue(...) or "-" +end + +function o.validate(self, value) + if value == "-" then + return nil, translate("Interface required") + end + return value +end + +function o.write(self, section, value) + m.uci:set("radvd", section, "ignore", 0) + m.uci:set("radvd", section, "interface", value) +end + + +o = s:option(DynamicList, "prefix", translate("Prefixes"), + translate("Advertised IPv6 prefixes")) + +o.rmempty = false +o.datatype = "ip6addr" +o.placeholder = translate("default") +function o.cfgvalue(self, section) + local l = { } + local v = m.uci:get_list("radvd", section, "prefix") + for v in utl.imatch(v) do + l[#l+1] = v + end + return l +end + + +o = s:option(Value, "AdvRouteLifetime", translate("Lifetime"), + translate("Specifies the lifetime associated with the route in seconds.")) + +o.datatype = 'or(uinteger,"infinity")' +o.placeholder = 1800 + + +o = s:option(ListValue, "AdvRoutePreference", translate("Preference"), + translate("Specifies the preference associated with the default router")) + +o.default = "medium" +o:value("low", translate("low")) +o:value("medium", translate("medium")) +o:value("high", translate("high")) + + +return m |