applications/luci-olsr: Prepare for the switch to olsrd-0.6.x
[project/luci.git] / applications / luci-olsr / luasrc / model / cbi / olsr / olsrd.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14
15 require("luci.tools.webadmin")
16
17 m = Map("olsrd", translate("OLSR Daemon"),
18         translate("The OLSR daemon is an implementation of the Optimized Link State Routing protocol. "..
19         "As such it allows mesh routing for any network equipment. "..
20         "It runs on any wifi card that supports ad-hoc mode and of course on any ethernet device. "..
21         "Visit <a href='http://www.olsr.org'>olsrd.org</a> for help and documentation."))
22
23 s = m:section(TypedSection, "olsrd", translate("General settings"))
24 s.dynamic = true
25 s.anonymous = true
26
27 ipv = s:option(ListValue, "IpVersion", translate("Internet protocol"),
28         translate("IP-version to use. If 6and4 is selected then one olsrd instance is started for each protocol."))
29 ipv:value("4", "IPv4")
30 ipv:value("6", "IPv6")
31 ipv:value("6and4", "6and4")
32
33 debug = s:option(ListValue, "DebugLevel", translate("Debugmode"), translate("Debug level to use. This should usually stay at 0."))
34 for i=0, 9 do
35         debug:value(i)
36 end
37 debug.optional = true
38
39 clrscr = s:option(Flag, "ClearScreen", translate ("Clear screen"),
40         translate("Clear the screen each time the internal state changes. Default is \"yes\"."))
41 clrscr.default = "yes"
42 clrscr.enabled = "yes"
43 clrscr.disabled = "no"
44 clrscr.optional = true
45
46 noint = s:option(Flag, "AllowNoInt", translate("Start without network"),
47         translate("If this is set to \"yes\" then olsrd also starts when no network devices are found."))
48 noint.default = "yes"
49 noint.enabled = "yes"
50 noint.disabled = "no"
51 noint.optional = true
52
53 s:option(Value, "Pollrate", translate("Pollrate"),
54         translate("Polling rate for OLSR sockets in seconds. Default is 0.05.")).optional = true
55
56 s:option(Value, "NicChgsPollInt", translate("Nic changes poll interval"),
57         translate("Interval to poll network interfaces for configuration changes (in seconds). Default is \"2.5\".")).optional = true
58
59 s:option(Value, "TosValue", translate("TOS value"),
60         translate("Type of service value for the IP header of control traffic. Default is \"16\".")).optional = true
61
62 fib = s:option(ListValue, "FIBMetric", translate("FIB metric"),
63         translate ("FIBMetric controls the metric value of the host-routes OLSRd sets. "..
64         "\"flat\" means that the metric value is always 2. This is the preferred value "..
65         "because it helps the linux kernel routing to clean up older routes. "..
66         "\"correct\" uses the hopcount as the metric value. "..
67         "\"approx\" use the hopcount as the metric value too, but does only update the hopcount if the nexthop changes too. "..
68         "Default is \"flat\"."))
69 fib.optional = true
70 fib:value("flat")
71 fib:value("correct")
72 fib:value("approx")
73 fib.optional = true
74
75 lql = s:option(ListValue, "LinkQualityLevel", translate("LQ level"),
76         translate("Link quality level switch between hopcount and cost-based (mostly ETX) routing.<br />"..
77         "<b>0</b> = do not use link quality<br />"..
78         "<b>2</b> = use link quality for MPR selection and routing<br />"..
79         "Default is \"2\""))
80 lql:value("2")
81 lql:value("0")
82 lql.optional = true
83
84 lqage = s:option(Value, "LinkQualityAging", translate("LQ aging"),
85         translate("Link quality aging factor (only for lq level 2). Tuning parameter for etx_float and etx_fpm, smaller values "..
86         "mean slower changes of ETX value. (allowed values are between 0.01 and 1.0)"))
87 lqage.optional = true
88 lqage:depends("LinkQualityLevel", "2")
89
90 lqa = s:option(ListValue, "LinkQualityAlgorithm", translate("LQ algorithm"),
91         translate("Link quality algorithm (only for lq level 2).<br />"..
92         "<b>etx_float</b>: floating point ETX with exponential aging<br />"..
93         "<b>etx_fpm</b>  : same as ext_float, but with integer arithmetic<br />"..
94         "<b>etx_ff</b>   : ETX freifunk, an etx variant which use all OLSR traffic (instead of only hellos) for ETX calculation<br />"..
95         "<b>etx_ffeth</b>: incompatible variant of etx_ff that allows ethernet links with ETX 0.1.<br />"..
96         "Defaults to \"etx_ff\""))
97 lqa.optional = true
98 lqa:value("etx_ff") 
99 lqa:value("etx_fpm")
100 lqa:value("etx_float")
101 lqa:value("etx_ffeth")
102 lqa:depends("LinkQualityLevel", "2")
103 lqa.optional = true
104
105 lqfish = s:option(Flag, "LinkQualityFishEye", translate("LQ fisheye"),
106         translate("Fisheye mechanism for TCs (checked means on). Default is \"on\""))
107 lqfish.default = "1"
108 lqfish.optional = true
109
110 hyst = s:option(Flag, "UseHysteresis", translate("Use hysteresis"),
111         translate("Hysteresis for link sensing (only for hopcount metric). Hysteresis adds more robustness to the link sensing "..
112         "but delays neighbor registration. Defaults is \"yes\""))
113 hyst.default = "yes"
114 hyst.enabled = "yes"
115 hyst.disabled = "no"
116 hyst:depends("LinkQualityLevel", "0")
117 hyst.optional = true
118
119 port = s:option(Value, "OlsrPort", translate("Port"),
120         translate("The port OLSR uses. This should usually stay at the IANA assigned port 698. It can have a value between 1 and 65535."))
121 port.optional = true
122 port.default = "698"
123 port.rmempty = true
124
125 mainip = s:option(Value, "MainIp", translate("Main IP"),
126         translate("Sets the main IP (originator ip) of the router. This IP will NEVER change during the uptime of olsrd. "..
127         "Default is 0.0.0.0, which triggers usage of the IP of the first interface."))
128 mainip.optional = true
129 mainip.rmempty = true
130
131 willingness = s:option(ListValue, "Willingness", translate("Willingness"),
132                 translate("The fixed willingness to use. If not set willingness will be calculated dynamically based on battery/power status. Default is \"3\"."))
133 for i=0,7 do
134         willingness:value(i)
135 end
136 willingness.optional = true
137
138 natthr = s:option(Value, "NatThreshold", translate("NAT threshold"),
139         translate("If the route to the current gateway is to be changed, the ETX value of this gateway is ".. 
140         "multiplied with this value before it is compared to the new one. "..
141         "The parameter can be a value between 0.1 and 1.0, but should be close to 1.0 if changed.<br />"..
142         "<b>WARNING:</b> This parameter should not be used together with the etx_ffeth metric!<br />"..
143         "Defaults to \"1.0\"."))
144 for i=1,0.1,-0.1 do
145         natthr:value(i)
146 end
147 natthr:depends("LinkQualityAlgorithm", "etx_ff")
148 natthr:depends("LinkQualityAlgorithm", "etx_float")
149 natthr:depends("LinkQualityAlgorithm", "etx_fpm")
150 natthr.default = 1
151 natthr.optional = true
152
153 i = m:section(TypedSection, "Interface", translate("Interfaces"))
154 i.anonymous = true
155 i.addremove = true
156 i.dynamic = true
157
158 ign = i:option(Flag, "ignore", translate("Enable"),
159         translate("Enable this interface."))
160 ign.enabled  = "0"
161 ign.disabled = "1"
162 ign.rmempty = false
163 function ign.cfgvalue(self, section)
164         return Flag.cfgvalue(self, section) or "0"
165 end
166
167 network = i:option(ListValue, "interface", translate("Network"),
168         translate("The interface where OLSRd should run. If \"Default\" is selected then the settings made "..
169         "here are used for all other interfaces unless overwritten."))
170 luci.tools.webadmin.cbi_add_networks(network)
171 network:value("Default")
172
173 mode = i:option(ListValue, "Mode", translate("Mode"),
174         translate("Interface Mode is used to prevent unnecessary packet forwarding on switched ethernet interfaces. "..
175         "valid Modes are \"mesh\" and \"ether\". Default is \"mesh\"."))
176 mode:value("mesh")  
177 mode:value("ether")
178 mode.optional = true
179 mode.rmempty = true
180
181 i:option(Value, "Ip4Broadcast", translate("IPv4 broadcast"),
182         translate("IPv4 broadcast address for outgoing OLSR packets. One useful example would be 255.255.255.255. "..
183         "Default is \"0.0.0.0\", which triggers the usage of the interface broadcast IP.")).optional = true
184
185 i:option(Value, "IPv6Multicast", translate("IPv6 multicast"),
186         translate("IPv6 multicast address. Default is \"FF02::6D\", the manet-router linklocal multicast.")).optional = true
187
188 i:option(Value, "IPv4Src", translate("IPv4 source"),
189         translate("IPv4 src address for outgoing OLSR packages. Default is \"0.0.0.0\", which triggers usage of the interface IP.")).optional = true
190
191 i:option(Value, "IPv6Src", translate("IPv6 source"),
192         translate("IPv6 src prefix. OLSRd will choose one of the interface IPs which matches the prefix of this parameter. "..
193         "Default is \"0::/0\", which triggers the usage of a not-linklocal interface IP.")).optional = true
194
195 i:option(Value, "HelloInterval", translate("Hello interval")).optional = true
196 i:option(Value, "HelloValidityTime", translate("Hello validity time")).optional = true
197 i:option(Value, "TcInterval", translate("TC interval")).optional = true
198 i:option(Value, "TcValidityTime", translate("TC validity time")).optional = true
199 i:option(Value, "MidInterval", translate("MID interval")).optional = true
200 i:option(Value, "MidValidityTime", translate("MID validity time")).optional = true
201 i:option(Value, "HnaInterval", translate("HNA interval")).optional = true
202 i:option(Value, "HnaValidityTime", translate("HNA validity time")).optional = true
203
204 i:option(Value, "Weight", translate("Weight"),
205         translate("When multiple links exist between hosts the weight of interface is used to determine the link to use. "..
206         "Normally the weight is automatically calculated by olsrd based on the characteristics of the interface, "..
207         "but here you can specify a fixed value. Olsrd will choose links with the lowest value.<br />"..
208         "<b>Note:</b> Interface weight is used only when LinkQualityLevel is set to 0. "..
209         "For any other value of LinkQualityLevel, the interface ETX value is used instead.")).optional = true
210
211 lqmult = i:option(DynamicList, "LinkQualityMult", translate("LinkQuality Multiplicator"),
212         translate("Multiply routes with the factor given here. Allowed values are between 0.01 and 1. "..
213         "It is only used when LQ-Level is greater than 0. Examples:<br />"..
214         "reduce LQ to 192.168.0.1 by half: 192.168.0.1 0.5<br />"..
215         "reduce LQ to all nodes on this interface by 20%: default 0.8"))
216 lqmult.optional = true
217 lqmult.rmempty = true
218 lqmult.cast = "table"
219
220 return m