olsrdiface6.lua 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. -- Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local util = require "luci.util"
  4. local ip = require "luci.ip"
  5. function write_float(self, section, value)
  6. local n = tonumber(value)
  7. if n ~= nil then
  8. return Value.write(self, section, "%.1f" % n)
  9. end
  10. end
  11. m = Map("olsrd6", translate("OLSR Daemon - Interface"),
  12. translate("The OLSR daemon is an implementation of the Optimized Link State Routing protocol. "..
  13. "As such it allows mesh routing for any network equipment. "..
  14. "It runs on any wifi card that supports ad-hoc mode and of course on any ethernet device. "..
  15. "Visit <a href='http://www.olsr.org'>olsrd.org</a> for help and documentation."))
  16. m.redirect = luci.dispatcher.build_url("admin/services/olsrd6")
  17. if not arg[1] or m.uci:get("olsrd6", arg[1]) ~= "Interface" then
  18. luci.http.redirect(m.redirect)
  19. return
  20. end
  21. i = m:section(NamedSection, arg[1], "Interface", translate("Interface"))
  22. i.anonymous = true
  23. i.addremove = false
  24. i:tab("general", translate("General Settings"))
  25. i:tab("addrs", translate("IP Addresses"))
  26. i:tab("timing", translate("Timing and Validity"))
  27. ign = i:taboption("general", Flag, "ignore", translate("Enable"),
  28. translate("Enable this interface."))
  29. ign.enabled = "0"
  30. ign.disabled = "1"
  31. ign.rmempty = false
  32. function ign.cfgvalue(self, section)
  33. return Flag.cfgvalue(self, section) or "0"
  34. end
  35. network = i:taboption("general", Value, "interface", translate("Network"),
  36. translate("The interface OLSRd should serve."))
  37. network.template = "cbi/network_netlist"
  38. network.widget = "radio"
  39. network.nocreate = true
  40. mode = i:taboption("general", ListValue, "Mode", translate("Mode"),
  41. translate("Interface Mode is used to prevent unnecessary packet forwarding on switched ethernet interfaces. "..
  42. "valid Modes are \"mesh\" and \"ether\". Default is \"mesh\"."))
  43. mode:value("mesh")
  44. mode:value("ether")
  45. mode.optional = true
  46. mode.rmempty = true
  47. weight = i:taboption("general", Value, "Weight", translate("Weight"),
  48. translate("When multiple links exist between hosts the weight of interface is used to determine the link to use. "..
  49. "Normally the weight is automatically calculated by olsrd based on the characteristics of the interface, "..
  50. "but here you can specify a fixed value. Olsrd will choose links with the lowest value.<br />"..
  51. "<b>Note:</b> Interface weight is used only when LinkQualityLevel is set to 0. "..
  52. "For any other value of LinkQualityLevel, the interface ETX value is used instead."))
  53. weight.optional = true
  54. weight.datatype = "uinteger"
  55. weight.placeholder = "0"
  56. lqmult = i:taboption("general", DynamicList, "LinkQualityMult", translate("LinkQuality Multiplicator"),
  57. translate("Multiply routes with the factor given here. Allowed values are between 0.01 and 1.0. "..
  58. "It is only used when LQ-Level is greater than 0. Examples:<br />"..
  59. "reduce LQ to fd91:662e:3c58::1 by half: fd91:662e:3c58::1 0.5<br />"..
  60. "reduce LQ to all nodes on this interface by 20%: default 0.8"))
  61. lqmult.optional = true
  62. lqmult.rmempty = true
  63. lqmult.cast = "table"
  64. lqmult.placeholder = "default 1.0"
  65. function lqmult.validate(self, value)
  66. for _, v in pairs(value) do
  67. if v ~= "" then
  68. local val = util.split(v, " ")
  69. local host = val[1]
  70. local mult = val[2]
  71. if not host or not mult then
  72. return nil, translate("LQMult requires two values (IP address or 'default' and multiplicator) seperated by space.")
  73. end
  74. if not (host == "default" or ip.IPv6(host)) then
  75. return nil, translate("Can only be a valid IPv6 address or 'default'")
  76. end
  77. if not tonumber(mult) or tonumber(mult) > 1 or tonumber(mult) < 0.01 then
  78. return nil, translate("Invalid Value for LQMult-Value. Must be between 0.01 and 1.0.")
  79. end
  80. if not mult:match("[0-1]%.[0-9]+") then
  81. return nil, translate("Invalid Value for LQMult-Value. You must use a decimal number between 0.01 and 1.0 here.")
  82. end
  83. end
  84. end
  85. return value
  86. end
  87. ip6m = i:taboption("addrs", Value, "IPv6Multicast", translate("IPv6 multicast"),
  88. translate("IPv6 multicast address. Default is \"FF02::6D\", the manet-router linklocal multicast."))
  89. ip6m.optional = true
  90. ip6m.datatype = "ip6addr"
  91. ip6m.placeholder = "FF02::6D"
  92. ip6s = i:taboption("addrs", Value, "IPv6Src", translate("IPv6 source"),
  93. translate("IPv6 src prefix. OLSRd will choose one of the interface IPs which matches the prefix of this parameter. "..
  94. "Default is \"0::/0\", which triggers the usage of a not-linklocal interface IP."))
  95. ip6s.optional = true
  96. ip6s.datatype = "ip6addr"
  97. ip6s.placeholder = "0::/0"
  98. hi = i:taboption("timing", Value, "HelloInterval", translate("Hello interval"))
  99. hi.optional = true
  100. hi.datatype = "ufloat"
  101. hi.placeholder = "5.0"
  102. hi.write = write_float
  103. hv = i:taboption("timing", Value, "HelloValidityTime", translate("Hello validity time"))
  104. hv.optional = true
  105. hv.datatype = "ufloat"
  106. hv.placeholder = "40.0"
  107. hv.write = write_float
  108. ti = i:taboption("timing", Value, "TcInterval", translate("TC interval"))
  109. ti.optional = true
  110. ti.datatype = "ufloat"
  111. ti.placeholder = "2.0"
  112. ti.write = write_float
  113. tv = i:taboption("timing", Value, "TcValidityTime", translate("TC validity time"))
  114. tv.optional = true
  115. tv.datatype = "ufloat"
  116. tv.placeholder = "256.0"
  117. tv.write = write_float
  118. mi = i:taboption("timing", Value, "MidInterval", translate("MID interval"))
  119. mi.optional = true
  120. mi.datatype = "ufloat"
  121. mi.placeholder = "18.0"
  122. mi.write = write_float
  123. mv = i:taboption("timing", Value, "MidValidityTime", translate("MID validity time"))
  124. mv.optional = true
  125. mv.datatype = "ufloat"
  126. mv.placeholder = "324.0"
  127. mv.write = write_float
  128. ai = i:taboption("timing", Value, "HnaInterval", translate("HNA interval"))
  129. ai.optional = true
  130. ai.datatype = "ufloat"
  131. ai.placeholder = "18.0"
  132. ai.write = write_float
  133. av = i:taboption("timing", Value, "HnaValidityTime", translate("HNA validity time"))
  134. av.optional = true
  135. av.datatype = "ufloat"
  136. av.placeholder = "108.0"
  137. av.write = write_float
  138. return m