From a2eefbab4d1ba7bc2aa1779fa8f83616c3c9a209 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 21 Nov 2010 03:03:55 +0000 Subject: [PATCH] applications: add radvd frontend --- applications/luci-radvd/Makefile | 4 + applications/luci-radvd/ipkg/postinst | 7 + .../luci-radvd/luasrc/controller/radvd.lua | 27 ++ .../luci-radvd/luasrc/model/cbi/radvd.lua | 253 ++++++++++++++++++ .../luasrc/model/cbi/radvd/interface.lua | 246 +++++++++++++++++ .../luasrc/model/cbi/radvd/prefix.lua | 150 +++++++++++ .../luasrc/model/cbi/radvd/rdnss.lua | 98 +++++++ .../luasrc/model/cbi/radvd/route.lua | 102 +++++++ .../root/etc/uci-defaults/luci-radvd | 8 + 9 files changed, 895 insertions(+) create mode 100644 applications/luci-radvd/Makefile create mode 100644 applications/luci-radvd/ipkg/postinst create mode 100644 applications/luci-radvd/luasrc/controller/radvd.lua create mode 100644 applications/luci-radvd/luasrc/model/cbi/radvd.lua create mode 100644 applications/luci-radvd/luasrc/model/cbi/radvd/interface.lua create mode 100644 applications/luci-radvd/luasrc/model/cbi/radvd/prefix.lua create mode 100644 applications/luci-radvd/luasrc/model/cbi/radvd/rdnss.lua create mode 100644 applications/luci-radvd/luasrc/model/cbi/radvd/route.lua create mode 100644 applications/luci-radvd/root/etc/uci-defaults/luci-radvd diff --git a/applications/luci-radvd/Makefile b/applications/luci-radvd/Makefile new file mode 100644 index 000000000..68c6b99c4 --- /dev/null +++ b/applications/luci-radvd/Makefile @@ -0,0 +1,4 @@ +PO = radvd + +include ../../build/config.mk +include ../../build/module.mk diff --git a/applications/luci-radvd/ipkg/postinst b/applications/luci-radvd/ipkg/postinst new file mode 100644 index 000000000..88aaf8330 --- /dev/null +++ b/applications/luci-radvd/ipkg/postinst @@ -0,0 +1,7 @@ +#!/bin/sh + +[ -n "${IPKG_INSTROOT}" ] || { + ( . /etc/uci-defaults/luci-radvd ) && rm -f /etc/uci-defaults/luci-radvd + /etc/init.d/radvd enabled || /etc/init.d/radvd enable + exit 0 +} diff --git a/applications/luci-radvd/luasrc/controller/radvd.lua b/applications/luci-radvd/luasrc/controller/radvd.lua new file mode 100644 index 000000000..1b403a8f9 --- /dev/null +++ b/applications/luci-radvd/luasrc/controller/radvd.lua @@ -0,0 +1,27 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2010 Jo-Philipp Wich + +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).i18n = "radvd" + 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 +end diff --git a/applications/luci-radvd/luasrc/model/cbi/radvd.lua b/applications/luci-radvd/luasrc/model/cbi/radvd.lua new file mode 100644 index 000000000..67ef26a2f --- /dev/null +++ b/applications/luci-radvd/luasrc/model/cbi/radvd.lua @@ -0,0 +1,253 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2010 Jo-Philipp Wich + +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) + + +-- +-- 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) + 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 + + return TypedSection.remove(self, section) +end + + +o = s:option(DummyValue, "interface", translate("Interface")) +o.template = "cbi/network_netinfo" + +o = s:option(DummyValue, "UnicastOnly", translate("Multicast")) +function o.cfgvalue(...) + local v = Value.cfgvalue(...) + return v == "1" 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(DummyValue, "interface", translate("Interface")) +o.template = "cbi/network_netinfo" + +o = s2:option(DummyValue, "prefix", translate("Prefix")) +function o.cfgvalue(self, section) + local v = Value.cfgvalue(self, section) + if not v 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 + local lla = luci.ip.IPv6("fe80::/10") + for _, adr in ipairs(ifc:ip6addrs()) do + if not lla:contains(adr) then + v = adr:string() + break + end + end + end + end + else + v = luci.ip.IPv6(v) + v = v and v:string() + end + + return v or "?" +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(DummyValue, "interface", translate("Interface")) +o.template = "cbi/network_netinfo" + +o = s3:option(DummyValue, "prefix", translate("Prefix")) +function o.cfgvalue(self, section) + local v = Value.cfgvalue(self, section) + if v then + v = luci.ip.IPv6(v) + v = v and v:string() + end + return v or "?" +end + +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 s.create(...) + local id = TypedSection.create(...) + luci.http.redirect(s4.extedit % id) +end + + +o = s4:option(DummyValue, "interface", translate("Interface")) +o.template = "cbi/network_netinfo" + +o = s4:option(DummyValue, "addr", translate("Address")) +function o.cfgvalue(self, section) + local v = Value.cfgvalue(self, section) + if not v 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 + local lla = luci.ip.IPv6("fe80::/10") + for _, adr in ipairs(ifc:ip6addrs()) do + if not lla:contains(adr) then + v = adr:network(128):string() + break + end + end + end + end + else + v = luci.ip.IPv6(v) + v = v and v:network(128):string() + end + + return v or "?" +end + +o = s4:option(DummyValue, "AdvRDNSSOpen", translate("Open")) +function o.cfgvalue(self, section) + local v = Value.cfgvalue(self, section) + return v == "1" and translate("yes") or translate("no") +end + +o = s4:option(DummyValue, "AdvRDNSSLifetime", 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-radvd/luasrc/model/cbi/radvd/interface.lua b/applications/luci-radvd/luasrc/model/cbi/radvd/interface.lua new file mode 100644 index 000000000..ca510cd76 --- /dev/null +++ b/applications/luci-radvd/luasrc/model/cbi/radvd/interface.lua @@ -0,0 +1,246 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2010 Jo-Philipp Wich + +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] + +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", 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", 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-radvd/luasrc/model/cbi/radvd/prefix.lua b/applications/luci-radvd/luasrc/model/cbi/radvd/prefix.lua new file mode 100644 index 000000000..460a244d0 --- /dev/null +++ b/applications/luci-radvd/luasrc/model/cbi/radvd/prefix.lua @@ -0,0 +1,150 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2010 Jo-Philipp Wich + +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] + +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", 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", Value, "prefix", translate("Prefix"), + translate("Advertised IPv6 prefix. If empty, the current interface prefix is used")) + +o.optional = true +o.datatype = "ip6addr" + + +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. Use 0 to specify an infinite lifetime")) + +o.datatype = "uinteger" +o.placeholder = 86400 + +function o.cfgvalue(self, section) + local v = Value.cfgvalue(self, section) + if v == "infinity" then + return 0 + else + return v + end +end + +function o.write(self, section, value) + if value == "0" then + Value.write(self, section, "infinity") + else + Value.write(self, section, value) + end +end + + +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. Use 0 to specify an infinite lifetime")) + +o.datatype = "uinteger" +o.placeholder = 14400 + +function o.cfgvalue(self, section) + local v = Value.cfgvalue(self, section) + if v == "infinity" then + return 0 + else + return v + end +end + +function o.write(self, section, value) + if value == "0" then + Value.write(self, section, "infinity") + else + Value.write(self, section, value) + end +end + + +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-radvd/luasrc/model/cbi/radvd/rdnss.lua b/applications/luci-radvd/luasrc/model/cbi/radvd/rdnss.lua new file mode 100644 index 000000000..31450b8f3 --- /dev/null +++ b/applications/luci-radvd/luasrc/model/cbi/radvd/rdnss.lua @@ -0,0 +1,98 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2010 Jo-Philipp Wich + +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] + +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(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(Value, "addr", translate("Address"), + 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 = s:option(Flag, "AdvRDNSSOpen", translate("Open"), + translate("Indicates whether that RDNSS continues to be available to hosts even if they moved to a different subnet ")) + + +o = s:option(Value, "AdvRDNSSLifetime", translate("Lifetime"), + translate("Specifies the maximum duration how long the RDNSS entries are used for name resolution. Use 0 to specify an infinite lifetime")) + +o.datatype = "uinteger" +o.placeholder = 1200 + +function o.cfgvalue(self, section) + local v = Value.cfgvalue(self, section) + if v == "infinity" then + return 0 + else + return v + end +end + +function o.write(self, section, value) + if value == "0" then + Value.write(self, section, "infinity") + else + Value.write(self, section, value) + end +end + + +return m diff --git a/applications/luci-radvd/luasrc/model/cbi/radvd/route.lua b/applications/luci-radvd/luasrc/model/cbi/radvd/route.lua new file mode 100644 index 000000000..31b6900e5 --- /dev/null +++ b/applications/luci-radvd/luasrc/model/cbi/radvd/route.lua @@ -0,0 +1,102 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2010 Jo-Philipp Wich + +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] + +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(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(Value, "prefix", translate("Prefix"), + translate("Advertised IPv6 prefix")) + +o.rmempty = false +o.datatype = "ip6addr" + + +o = s:option(Value, "AdvRouteLifetime", translate("Lifetime"), + translate("Specifies the lifetime associated with the route in seconds. Use 0 to specify an infinite lifetime")) + +o.datatype = "uinteger" +o.placeholder = 1800 + +function o.cfgvalue(self, section) + local v = Value.cfgvalue(self, section) + if v == "infinity" then + return 0 + else + return v + end +end + +function o.write(self, section, value) + if value == "0" then + Value.write(self, section, "infinity") + else + Value.write(self, section, value) + end +end + + +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 diff --git a/applications/luci-radvd/root/etc/uci-defaults/luci-radvd b/applications/luci-radvd/root/etc/uci-defaults/luci-radvd new file mode 100644 index 000000000..ba4822141 --- /dev/null +++ b/applications/luci-radvd/root/etc/uci-defaults/luci-radvd @@ -0,0 +1,8 @@ +#!/bin/sh + +uci batch <<-EOF + delete ucitrack.@radvd[-1] + add ucitrack radvd + set ucitrack.@radvd[-1].init=radvd + commit ucitrack +EOF -- 2.25.1