ahcp.lua 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. -- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
  2. -- Licensed to the public under the Apache License 2.0.
  3. m = Map("ahcpd", translate("AHCP Server"), translate("AHCP is an autoconfiguration protocol " ..
  4. "for IPv6 and dual-stack IPv6/IPv4 networks designed to be used in place of router " ..
  5. "discovery or DHCP on networks where it is difficult or impossible to configure a " ..
  6. "server within every link-layer broadcast domain, for example mobile ad-hoc networks."))
  7. m:section(SimpleSection).template = "ahcp_status"
  8. s = m:section(TypedSection, "ahcpd")
  9. s:tab("general", translate("General Setup"))
  10. s:tab("advanced", translate("Advanced Settings"))
  11. s.addremove = false
  12. s.anonymous = true
  13. mode = s:taboption("general", ListValue, "mode", translate("Operation mode"))
  14. mode:value("server", translate("Server"))
  15. mode:value("forwarder", translate("Forwarder"))
  16. net = s:taboption("general", Value, "interface", translate("Served interfaces"))
  17. net.template = "cbi/network_netlist"
  18. net.widget = "checkbox"
  19. net.nocreate = true
  20. function net.cfgvalue(self, section)
  21. return m.uci:get("ahcpd", section, "interface")
  22. end
  23. pfx = s:taboption("general", DynamicList, "prefix", translate("Announced prefixes"),
  24. translate("Specifies the announced IPv4 and IPv6 network prefixes in CIDR notation"))
  25. pfx.optional = true
  26. pfx.datatype = "ipaddr"
  27. pfx:depends("mode", "server")
  28. nss = s:taboption("general", DynamicList, "name_server", translate("Announced DNS servers"),
  29. translate("Specifies the announced IPv4 and IPv6 name servers"))
  30. nss.optional = true
  31. nss.datatype = "ipaddr"
  32. nss:depends("mode", "server")
  33. ntp = s:taboption("general", DynamicList, "ntp_server", translate("Announced NTP servers"),
  34. translate("Specifies the announced IPv4 and IPv6 NTP servers"))
  35. ntp.optional = true
  36. ntp.datatype = "ipaddr"
  37. ntp:depends("mode", "server")
  38. mca = s:taboption("general", Value, "multicast_address", translate("Multicast address"))
  39. mca.optional = true
  40. mca.placeholder = "ff02::cca6:c0f9:e182:5359"
  41. mca.datatype = "ip6addr"
  42. port = s:taboption("general", Value, "port", translate("Port"))
  43. port.optional = true
  44. port.placeholder = 5359
  45. port.datatype = "port"
  46. fam = s:taboption("general", ListValue, "_family", translate("Protocol family"))
  47. fam:value("", translate("IPv4 and IPv6"))
  48. fam:value("ipv4", translate("IPv4 only"))
  49. fam:value("ipv6", translate("IPv6 only"))
  50. function fam.cfgvalue(self, section)
  51. local v4 = m.uci:get_bool("ahcpd", section, "ipv4_only")
  52. local v6 = m.uci:get_bool("ahcpd", section, "ipv6_only")
  53. if v4 then
  54. return "ipv4"
  55. elseif v6 then
  56. return "ipv6"
  57. end
  58. return ""
  59. end
  60. function fam.write(self, section, value)
  61. if value == "ipv4" then
  62. m.uci:set("ahcpd", section, "ipv4_only", "true")
  63. m.uci:delete("ahcpd", section, "ipv6_only")
  64. elseif value == "ipv6" then
  65. m.uci:set("ahcpd", section, "ipv6_only", "true")
  66. m.uci:delete("ahcpd", section, "ipv4_only")
  67. end
  68. end
  69. function fam.remove(self, section)
  70. m.uci:delete("ahcpd", section, "ipv4_only")
  71. m.uci:delete("ahcpd", section, "ipv6_only")
  72. end
  73. ltime = s:taboption("general", Value, "lease_time", translate("Lease validity time"))
  74. ltime.optional = true
  75. ltime.placeholder = 3666
  76. ltime.datatype = "uinteger"
  77. ld = s:taboption("advanced", Value, "lease_dir", translate("Lease directory"))
  78. ld.datatype = "directory"
  79. ld.placeholder = "/var/lib/leases"
  80. id = s:taboption("advanced", Value, "id_file", translate("Unique ID file"))
  81. --id.datatype = "file"
  82. id.placeholder = "/var/lib/ahcpd-unique-id"
  83. log = s:taboption("advanced", Value, "log_file", translate("Log file"))
  84. --log.datatype = "file"
  85. log.placeholder = "/var/log/ahcpd.log"
  86. return m