interface.lua 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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 - Interface %q", "?"),
  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) ~= "interface" then
  11. luci.http.redirect(m.redirect)
  12. return
  13. end
  14. m.uci:foreach("radvd", "interface",
  15. function(s)
  16. if s['.name'] == sid and s.interface then
  17. m.title = translatef("Radvd - Interface %q", s.interface)
  18. return false
  19. end
  20. end)
  21. s = m:section(NamedSection, sid, "interface", translate("Interface Configuration"))
  22. s.addremove = false
  23. s:tab("general", translate("General"))
  24. s:tab("timing", translate("Timing"))
  25. s:tab("mobile", translate("Mobile IPv6"))
  26. --
  27. -- General
  28. --
  29. o = s:taboption("general", Flag, "ignore", translate("Enable"))
  30. o.rmempty = false
  31. function o.cfgvalue(...)
  32. local v = Flag.cfgvalue(...)
  33. return v == "1" and "0" or "1"
  34. end
  35. function o.write(self, section, value)
  36. Flag.write(self, section, value == "1" and "0" or "1")
  37. end
  38. o = s:taboption("general", Value, "interface", translate("Interface"),
  39. translate("Specifies the logical interface name this section belongs to"))
  40. o.template = "cbi/network_netlist"
  41. o.nocreate = true
  42. o.optional = false
  43. function o.formvalue(...)
  44. return Value.formvalue(...) or "-"
  45. end
  46. function o.validate(self, value)
  47. if value == "-" then
  48. return nil, translate("Interface required")
  49. end
  50. return value
  51. end
  52. function o.write(self, section, value)
  53. m.uci:set("radvd", section, "ignore", 0)
  54. m.uci:set("radvd", section, "interface", value)
  55. end
  56. o = s:taboption("general", DynamicList, "client", translate("Clients"),
  57. translate("Restrict communication to specified clients, leave empty to use multicast"))
  58. o.rmempty = true
  59. o.datatype = "ip6addr"
  60. o.placeholder = "any"
  61. function o.cfgvalue(...)
  62. local v = Value.cfgvalue(...)
  63. local l = { }
  64. for v in utl.imatch(v) do
  65. l[#l+1] = v
  66. end
  67. return l
  68. end
  69. o = s:taboption("general", Flag, "AdvSendAdvert", translate("Enable advertisements"),
  70. translate("Enables router advertisements and solicitations"))
  71. o.rmempty = false
  72. function o.write(self, section, value)
  73. if value == "1" then
  74. m.uci:set("radvd", section, "ignore", 0)
  75. m.uci:set("radvd", section, "IgnoreIfMissing", 1)
  76. end
  77. m.uci:set("radvd", section, "AdvSendAdvert", value)
  78. end
  79. o = s:taboption("general", Flag, "UnicastOnly", translate("Unicast only"),
  80. translate("Indicates that the underlying link is not broadcast capable, prevents unsolicited advertisements from being sent"))
  81. o:depends("AdvSendAdvert", "1")
  82. o = s:taboption("general", Flag, "AdvManagedFlag", translate("Managed flag"),
  83. translate("Enables the additional stateful administered autoconfiguration protocol (RFC2462)"))
  84. o:depends("AdvSendAdvert", "1")
  85. o = s:taboption("general", Flag, "AdvOtherConfigFlag", translate("Configuration flag"),
  86. translate("Enables the autoconfiguration of additional, non address information (RFC2462)"))
  87. o:depends("AdvSendAdvert", "1")
  88. o = s:taboption("general", Flag, "AdvSourceLLAddress", translate("Source link-layer address"),
  89. translate("Includes the link-layer address of the outgoing interface in the RA"))
  90. o.rmempty = false
  91. o.default = "1"
  92. o:depends("AdvSendAdvert", "1")
  93. o = s:taboption("general", Value, "AdvLinkMTU", translate("Link MTU"),
  94. translate("Advertises the given link MTU in the RA if specified. 0 disables MTU advertisements"))
  95. o.datatype = "uinteger"
  96. o.placeholder = 0
  97. o:depends("AdvSendAdvert", "1")
  98. o = s:taboption("general", Value, "AdvCurHopLimit", translate("Current hop limit"),
  99. translate("Advertises the default Hop Count value for outgoing unicast packets in the RA. 0 disables hopcount advertisements"))
  100. o.datatype = "uinteger"
  101. o.optional = false
  102. o.placeholder = 64
  103. o:depends("AdvSendAdvert", "1")
  104. o = s:taboption("general", ListValue, "AdvDefaultPreference", translate("Default preference"),
  105. translate("Advertises the default router preference"))
  106. o.optional = false
  107. o.default = "medium"
  108. o:value("low", translate("low"))
  109. o:value("medium", translate("medium"))
  110. o:value("high", translate("high"))
  111. o:depends("AdvSendAdvert", "1")
  112. --
  113. -- Timing
  114. --
  115. o = s:taboption("timing", Value, "MinRtrAdvInterval", translate("Minimum advertisement interval"),
  116. translate("The minimum time allowed between sending unsolicited multicast router advertisements from the interface, in seconds"))
  117. o.datatype = "uinteger"
  118. o.optional = false
  119. o.placeholder = 198
  120. o:depends("AdvSendAdvert", "1")
  121. o = s:taboption("timing", Value, "MaxRtrAdvInterval", translate("Maximum advertisement interval"),
  122. translate("The maximum time allowed between sending unsolicited multicast router advertisements from the interface, in seconds"))
  123. o.datatype = "uinteger"
  124. o.optional = false
  125. o.placeholder = 600
  126. o:depends("AdvSendAdvert", "1")
  127. o = s:taboption("timing", Value, "MinDelayBetweenRAs", translate("Minimum advertisement delay"),
  128. translate("The minimum time allowed between sending multicast router advertisements from the interface, in seconds"))
  129. o.datatype = "uinteger"
  130. o.optional = false
  131. o.placeholder = 3
  132. o:depends("AdvSendAdvert", "1")
  133. o = s:taboption("timing", Value, "AdvReachableTime", translate("Reachable time"),
  134. translate("Advertises assumed reachability time in milliseconds of neighbours in the RA if specified. 0 disables reachability advertisements"))
  135. o.datatype = "uinteger"
  136. o.optional = false
  137. o.placeholder = 0
  138. o:depends("AdvSendAdvert", "1")
  139. o = s:taboption("timing", Value, "AdvRetransTimer", translate("Retransmit timer"),
  140. translate("Advertises wait time in milliseconds between Neighbor Solicitation messages in the RA if specified. 0 disables retransmit advertisements"))
  141. o.datatype = "uinteger"
  142. o.optional = false
  143. o.placeholder = 0
  144. o:depends("AdvSendAdvert", "1")
  145. o = s:taboption("timing", Value, "AdvDefaultLifetime", translate("Default lifetime"),
  146. translate("Advertises the lifetime of the default router in seconds. 0 indicates that the node is no default router"))
  147. o.datatype = "uinteger"
  148. o.optional = false
  149. o.placeholder = 1800
  150. o:depends("AdvSendAdvert", "1")
  151. --
  152. -- Mobile
  153. --
  154. o = s:taboption("mobile", Flag, "AdvHomeAgentFlag", translate("Advertise Home Agent flag"),
  155. translate("Advertises Mobile IPv6 Home Agent capability (RFC3775)"))
  156. o:depends("AdvSendAdvert", "1")
  157. o = s:taboption("mobile", Flag, "AdvIntervalOpt", translate("Mobile IPv6 interval option"),
  158. translate("Include Mobile IPv6 Advertisement Interval option to RA"))
  159. o:depends({AdvHomeAgentFlag = "1", AdvSendAdvert = "1"})
  160. o = s:taboption("mobile", Flag, "AdvHomeAgentInfo", translate("Home Agent information"),
  161. translate("Include Home Agent Information in the RA"))
  162. o:depends({AdvHomeAgentFlag = "1", AdvSendAdvert = "1"})
  163. o = s:taboption("mobile", Flag, "AdvMobRtrSupportFlag", translate("Mobile IPv6 router registration"),
  164. translate("Advertises Mobile Router registration capability (NEMO Basic)"))
  165. o:depends({AdvHomeAgentInfo = "1", AdvSendAdvert = "1"})
  166. o = s:taboption("mobile", Value, "HomeAgentLifetime", translate("Home Agent lifetime"),
  167. translate("Advertises the time in seconds the router is offering Mobile IPv6 Home Agent services"))
  168. o.datatype = "uinteger"
  169. o.optional = false
  170. o.placeholder = 1800
  171. o:depends({AdvHomeAgentInfo = "1", AdvSendAdvert = "1"})
  172. o = s:taboption("mobile", Value, "HomeAgentPreference", translate("Home Agent preference"),
  173. translate("The preference for the Home Agent sending this RA"))
  174. o.datatype = "uinteger"
  175. o.optional = false
  176. o.placeholder = 0
  177. o:depends({AdvHomeAgentInfo = "1", AdvSendAdvert = "1"})
  178. return m