rdnss.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. -- Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local sid = arg[1]
  4. local utl = require "luci.util"
  5. m = Map("radvd", translatef("Radvd - RDNSS"),
  6. translate("Radvd is a router advertisement daemon for IPv6. " ..
  7. "It listens to router solicitations and sends router advertisements " ..
  8. "as described in RFC 4861."))
  9. m.redirect = luci.dispatcher.build_url("admin/network/radvd")
  10. if m.uci:get("radvd", sid) ~= "rdnss" then
  11. luci.http.redirect(m.redirect)
  12. return
  13. end
  14. s = m:section(NamedSection, sid, "interface", translate("RDNSS Configuration"))
  15. s.addremove = false
  16. --
  17. -- General
  18. --
  19. o = s:option(Flag, "ignore", translate("Enable"))
  20. o.rmempty = false
  21. function o.cfgvalue(...)
  22. local v = Flag.cfgvalue(...)
  23. return v == "1" and "0" or "1"
  24. end
  25. function o.write(self, section, value)
  26. Flag.write(self, section, value == "1" and "0" or "1")
  27. end
  28. o = s:option(Value, "interface", translate("Interface"),
  29. translate("Specifies the logical interface name this section belongs to"))
  30. o.template = "cbi/network_netlist"
  31. o.nocreate = true
  32. o.optional = false
  33. function o.formvalue(...)
  34. return Value.formvalue(...) or "-"
  35. end
  36. function o.validate(self, value)
  37. if value == "-" then
  38. return nil, translate("Interface required")
  39. end
  40. return value
  41. end
  42. function o.write(self, section, value)
  43. m.uci:set("radvd", section, "ignore", 0)
  44. m.uci:set("radvd", section, "interface", value)
  45. end
  46. o = s:option(DynamicList, "addr", translate("Addresses"),
  47. translate("Advertised IPv6 RDNSS. If empty, the current IPv6 address of the interface is used"))
  48. o.optional = false
  49. o.rmempty = true
  50. o.datatype = "ip6addr"
  51. o.placeholder = translate("default")
  52. function o.cfgvalue(self, section)
  53. local l = { }
  54. local v = m.uci:get_list("radvd", section, "addr")
  55. for v in utl.imatch(v) do
  56. l[#l+1] = v
  57. end
  58. return l
  59. end
  60. o = s:option(Value, "AdvRDNSSLifetime", translate("Lifetime"),
  61. translate("Specifies the maximum duration how long the RDNSS entries are used for name resolution."))
  62. o.datatype = 'or(uinteger,"infinity")'
  63. o.placeholder = 1200
  64. return m