2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
16 require("luci.tools.webadmin")
18 m = Map("olsrd", translate("OLSR Daemon"),
19 translate("The OLSR daemon is an implementation of the Optimized Link State Routing protocol. "..
20 "As such it allows mesh routing for any network equipment. "..
21 "It runs on any wifi card that supports ad-hoc mode and of course on any ethernet device. "..
22 "Visit <a href='http://www.olsr.org'>olsrd.org</a> for help and documentation."))
25 local has_defaults = false
27 m.uci:foreach("olsrd", "InterfaceDefaults",
33 if not has_defaults then
34 m.uci:section("olsrd", "InterfaceDefaults")
38 s = m:section(TypedSection, "olsrd", translate("General settings"))
42 s:tab("general", translate("General Settings"))
43 s:tab("lquality", translate("Link Quality Settings"))
44 s:tab("advanced", translate("Advanced Settings"))
47 ipv = s:taboption("general", ListValue, "IpVersion", translate("Internet protocol"),
48 translate("IP-version to use. If 6and4 is selected then one olsrd instance is started for each protocol."))
49 ipv:value("4", "IPv4")
50 ipv:value("6", "IPv6")
51 ipv:value("6and4", "6and4")
54 poll = s:taboption("advanced", Value, "Pollrate", translate("Pollrate"),
55 translate("Polling rate for OLSR sockets in seconds. Default is 0.05."))
57 poll.datatype = "ufloat"
58 poll.placeholder = "0.05"
60 nicc = s:taboption("advanced", Value, "NicChgsPollInt", translate("Nic changes poll interval"),
61 translate("Interval to poll network interfaces for configuration changes (in seconds). Default is \"2.5\"."))
63 nicc.datatype = "ufloat"
64 nicc.placeholder = "2.5"
66 tos = s:taboption("advanced", Value, "TosValue", translate("TOS value"),
67 translate("Type of service value for the IP header of control traffic. Default is \"16\"."))
69 tos.datatype = "uinteger"
70 tos.placeholder = "16"
72 fib = s:taboption("general", ListValue, "FIBMetric", translate("FIB metric"),
73 translate ("FIBMetric controls the metric value of the host-routes OLSRd sets. "..
74 "\"flat\" means that the metric value is always 2. This is the preferred value "..
75 "because it helps the linux kernel routing to clean up older routes. "..
76 "\"correct\" uses the hopcount as the metric value. "..
77 "\"approx\" use the hopcount as the metric value too, but does only update the hopcount if the nexthop changes too. "..
78 "Default is \"flat\"."))
83 lql = s:taboption("lquality", ListValue, "LinkQualityLevel", translate("LQ level"),
84 translate("Link quality level switch between hopcount and cost-based (mostly ETX) routing.<br />"..
85 "<b>0</b> = do not use link quality<br />"..
86 "<b>2</b> = use link quality for MPR selection and routing<br />"..
91 lqage = s:taboption("lquality", Value, "LinkQualityAging", translate("LQ aging"),
92 translate("Link quality aging factor (only for lq level 2). Tuning parameter for etx_float and etx_fpm, smaller values "..
93 "mean slower changes of ETX value. (allowed values are between 0.01 and 1.0)"))
95 lqage:depends("LinkQualityLevel", "2")
97 lqa = s:taboption("lquality", ListValue, "LinkQualityAlgorithm", translate("LQ algorithm"),
98 translate("Link quality algorithm (only for lq level 2).<br />"..
99 "<b>etx_float</b>: floating point ETX with exponential aging<br />"..
100 "<b>etx_fpm</b> : same as ext_float, but with integer arithmetic<br />"..
101 "<b>etx_ff</b> : ETX freifunk, an etx variant which use all OLSR traffic (instead of only hellos) for ETX calculation<br />"..
102 "<b>etx_ffeth</b>: incompatible variant of etx_ff that allows ethernet links with ETX 0.1.<br />"..
103 "Defaults to \"etx_ff\""))
107 lqa:value("etx_float")
108 lqa:value("etx_ffeth")
109 lqa:depends("LinkQualityLevel", "2")
112 lqfish = s:taboption("lquality", Flag, "LinkQualityFishEye", translate("LQ fisheye"),
113 translate("Fisheye mechanism for TCs (checked means on). Default is \"on\""))
115 lqfish.optional = true
117 hyst = s:taboption("lquality", Flag, "UseHysteresis", translate("Use hysteresis"),
118 translate("Hysteresis for link sensing (only for hopcount metric). Hysteresis adds more robustness to the link sensing "..
119 "but delays neighbor registration. Defaults is \"yes\""))
123 hyst:depends("LinkQualityLevel", "0")
126 port = s:taboption("general", Value, "OlsrPort", translate("Port"),
127 translate("The port OLSR uses. This should usually stay at the IANA assigned port 698. It can have a value between 1 and 65535."))
132 mainip = s:taboption("general", Value, "MainIp", translate("Main IP"),
133 translate("Sets the main IP (originator ip) of the router. This IP will NEVER change during the uptime of olsrd. "..
134 "Default is 0.0.0.0, which triggers usage of the IP of the first interface."))
135 mainip.optional = true
136 mainip.rmempty = true
137 mainip.datatype = "ipaddr"
138 mainip.placeholder = "0.0.0.0"
140 willingness = s:taboption("advanced", ListValue, "Willingness", translate("Willingness"),
141 translate("The fixed willingness to use. If not set willingness will be calculated dynamically based on battery/power status. Default is \"3\"."))
145 willingness.optional = true
146 willingness.default = "3"
148 natthr = s:taboption("advanced", Value, "NatThreshold", translate("NAT threshold"),
149 translate("If the route to the current gateway is to be changed, the ETX value of this gateway is "..
150 "multiplied with this value before it is compared to the new one. "..
151 "The parameter can be a value between 0.1 and 1.0, but should be close to 1.0 if changed.<br />"..
152 "<b>WARNING:</b> This parameter should not be used together with the etx_ffeth metric!<br />"..
153 "Defaults to \"1.0\"."))
157 natthr:depends("LinkQualityAlgorithm", "etx_ff")
158 natthr:depends("LinkQualityAlgorithm", "etx_float")
159 natthr:depends("LinkQualityAlgorithm", "etx_fpm")
161 natthr.optional = true
164 i = m:section(TypedSection, "InterfaceDefaults", translate("Interfaces Defaults"))
168 i:tab("general", translate("General Settings"))
169 i:tab("addrs", translate("IP Addresses"))
170 i:tab("timing", translate("Timing and Validity"))
172 mode = i:taboption("general", ListValue, "Mode", translate("Mode"),
173 translate("Interface Mode is used to prevent unnecessary packet forwarding on switched ethernet interfaces. "..
174 "valid Modes are \"mesh\" and \"ether\". Default is \"mesh\"."))
181 weight = i:taboption("general", Value, "Weight", translate("Weight"),
182 translate("When multiple links exist between hosts the weight of interface is used to determine the link to use. "..
183 "Normally the weight is automatically calculated by olsrd based on the characteristics of the interface, "..
184 "but here you can specify a fixed value. Olsrd will choose links with the lowest value.<br />"..
185 "<b>Note:</b> Interface weight is used only when LinkQualityLevel is set to 0. "..
186 "For any other value of LinkQualityLevel, the interface ETX value is used instead."))
187 weight.optional = true
188 weight.datatype = "uinteger"
189 weight.placeholder = "0"
191 lqmult = i:taboption("general", DynamicList, "LinkQualityMult", translate("LinkQuality Multiplicator"),
192 translate("Multiply routes with the factor given here. Allowed values are between 0.01 and 1. "..
193 "It is only used when LQ-Level is greater than 0. Examples:<br />"..
194 "reduce LQ to 192.168.0.1 by half: 192.168.0.1 0.5<br />"..
195 "reduce LQ to all nodes on this interface by 20%: default 0.8"))
196 lqmult.optional = true
197 lqmult.rmempty = true
198 lqmult.cast = "table"
199 lqmult.placeholder = "default 1.0"
202 ip4b = i:taboption("addrs", Value, "Ip4Broadcast", translate("IPv4 broadcast"),
203 translate("IPv4 broadcast address for outgoing OLSR packets. One useful example would be 255.255.255.255. "..
204 "Default is \"0.0.0.0\", which triggers the usage of the interface broadcast IP."))
206 ip4b.datatype = "ip4addr"
207 ip4b.placeholder = "0.0.0.0"
209 ip6m = i:taboption("addrs", Value, "IPv6Multicast", translate("IPv6 multicast"),
210 translate("IPv6 multicast address. Default is \"FF02::6D\", the manet-router linklocal multicast."))
212 ip6m.datatype = "ip6addr"
213 ip6m.placeholder = "FF02::6D"
215 ip4s = i:taboption("addrs", Value, "IPv4Src", translate("IPv4 source"),
216 translate("IPv4 src address for outgoing OLSR packages. Default is \"0.0.0.0\", which triggers usage of the interface IP."))
218 ip4s.datatype = "ip4addr"
219 ip4s.placeholder = "0.0.0.0"
221 ip6s = i:taboption("addrs", Value, "IPv6Src", translate("IPv6 source"),
222 translate("IPv6 src prefix. OLSRd will choose one of the interface IPs which matches the prefix of this parameter. "..
223 "Default is \"0::/0\", which triggers the usage of a not-linklocal interface IP."))
225 ip6s.datatype = "ip6addr"
226 ip6s.placeholder = "0::/0"
229 hi = i:taboption("timing", Value, "HelloInterval", translate("Hello interval"))
231 hi.datatype = "ufloat"
232 hi.placeholder = "5.0"
234 hv = i:taboption("timing", Value, "HelloValidityTime", translate("Hello validity time"))
236 hv.datatype = "ufloat"
237 hv.placeholder = "40.0"
239 ti = i:taboption("timing", Value, "TcInterval", translate("TC interval"))
241 ti.datatype = "ufloat"
242 ti.placeholder = "2.0"
244 tv = i:taboption("timing", Value, "TcValidityTime", translate("TC validity time"))
246 tv.datatype = "ufloat"
247 tv.placeholder = "256.0"
249 mi = i:taboption("timing", Value, "MidInterval", translate("MID interval"))
251 mi.datatype = "ufloat"
252 mi.placeholder = "18.0"
254 mv = i:taboption("timing", Value, "MidValidityTime", translate("MID validity time"))
256 mv.datatype = "ufloat"
257 mv.placeholder = "324.0"
259 ai = i:taboption("timing", Value, "HnaInterval", translate("HNA interval"))
261 ai.datatype = "ufloat"
262 ai.placeholder = "18.0"
264 av = i:taboption("timing", Value, "HnaValidityTime", translate("HNA validity time"))
266 av.datatype = "ufloat"
267 av.placeholder = "108.0"
270 ifs = m:section(TypedSection, "Interface", translate("Interfaces"))
273 ifs.extedit = luci.dispatcher.build_url("admin/services/olsrd/iface/%s")
274 ifs.template = "cbi/tblsection"
276 function ifs.create(...)
277 local sid = TypedSection.create(...)
278 luci.http.redirect(ifs.extedit % sid)
281 ign = ifs:option(Flag, "ignore", translate("Enable"))
285 function ign.cfgvalue(self, section)
286 return Flag.cfgvalue(self, section) or "0"
289 network = ifs:option(DummyValue, "interface", translate("Network"))
290 network.template = "cbi/network_netinfo"
292 mode = ifs:option(DummyValue, "Mode", translate("Mode"))
293 function mode.cfgvalue(...)
294 return Value.cfgvalue(...) or "mesh"
297 hello = ifs:option(DummyValue, "_hello", translate("Hello"))
298 function hello.cfgvalue(self, section)
299 local i = tonumber(m.uci:get("olsrd", section, "HelloInterval")) or 5
300 local v = tonumber(m.uci:get("olsrd", section, "HelloValidityTime")) or 40
301 return "%.01fs / %.01fs" %{ i, v }
304 tc = ifs:option(DummyValue, "_tc", translate("TC"))
305 function tc.cfgvalue(self, section)
306 local i = tonumber(m.uci:get("olsrd", section, "TcInterval")) or 2
307 local v = tonumber(m.uci:get("olsrd", section, "TcValidityTime")) or 256
308 return "%.01fs / %.01fs" %{ i, v }
311 mid = ifs:option(DummyValue, "_mid", translate("MID"))
312 function mid.cfgvalue(self, section)
313 local i = tonumber(m.uci:get("olsrd", section, "MidInterval")) or 18
314 local v = tonumber(m.uci:get("olsrd", section, "MidValidityTime")) or 324
315 return "%.01fs / %.01fs" %{ i, v }
318 hna = ifs:option(DummyValue, "_hna", translate("HNA"))
319 function hna.cfgvalue(self, section)
320 local i = tonumber(m.uci:get("olsrd", section, "HnaInterval")) or 18
321 local v = tonumber(m.uci:get("olsrd", section, "HnaValidityTime")) or 108
322 return "%.01fs / %.01fs" %{ i, v }