25692fd14698dc3d3bddb0f24174d2b70120ad6a
[project/luci.git] / applications / luci-olsr / luasrc / model / cbi / olsr / olsrdiface.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2010 Jo-Philipp Wich <xm@subsignal.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
16 function write_float(self, section, value)
17     local n = tonumber(value)
18     if n ~= nil then
19         return Value.write(self, section, "%.1f" % n)
20     end
21 end
22
23 m = Map("olsrd", translate("OLSR Daemon - Interface"),
24         translate("The OLSR daemon is an implementation of the Optimized Link State Routing protocol. "..
25         "As such it allows mesh routing for any network equipment. "..
26         "It runs on any wifi card that supports ad-hoc mode and of course on any ethernet device. "..
27         "Visit <a href='http://www.olsr.org'>olsrd.org</a> for help and documentation."))
28
29 m.redirect = luci.dispatcher.build_url("admin/services/olsrd")
30
31 if not arg[1] or m.uci:get("olsrd", arg[1]) ~= "Interface" then
32         luci.http.redirect(m.redirect)
33         return
34 end
35
36 i = m:section(NamedSection, arg[1], "Interface", translate("Interface"))
37 i.anonymous = true
38 i.addremove = false
39
40 i:tab("general", translate("General Settings"))
41 i:tab("addrs",   translate("IP Addresses"))
42 i:tab("timing",  translate("Timing and Validity"))
43
44 ign = i:taboption("general", Flag, "ignore", translate("Enable"),
45         translate("Enable this interface."))
46 ign.enabled  = "0"
47 ign.disabled = "1"
48 ign.rmempty = false
49 function ign.cfgvalue(self, section)
50         return Flag.cfgvalue(self, section) or "0"
51 end
52
53 network = i:taboption("general", Value, "interface", translate("Network"),
54         translate("The interface OLSRd should serve."))
55
56 network.template = "cbi/network_netlist"
57 network.widget   = "radio"
58 network.nocreate = true
59
60 mode = i:taboption("general", ListValue, "Mode", translate("Mode"),
61         translate("Interface Mode is used to prevent unnecessary packet forwarding on switched ethernet interfaces. "..
62         "valid Modes are \"mesh\" and \"ether\". Default is \"mesh\"."))
63 mode:value("mesh")
64 mode:value("ether")
65 mode.optional = true
66 mode.rmempty = true
67
68
69 weight = i:taboption("general", Value, "Weight", translate("Weight"),
70         translate("When multiple links exist between hosts the weight of interface is used to determine the link to use. "..
71         "Normally the weight is automatically calculated by olsrd based on the characteristics of the interface, "..
72         "but here you can specify a fixed value. Olsrd will choose links with the lowest value.<br />"..
73         "<b>Note:</b> Interface weight is used only when LinkQualityLevel is set to 0. "..
74         "For any other value of LinkQualityLevel, the interface ETX value is used instead."))
75 weight.optional = true
76 weight.datatype = "uinteger"
77 weight.placeholder = "0"
78
79 lqmult = i:taboption("general", DynamicList, "LinkQualityMult", translate("LinkQuality Multiplicator"),
80         translate("Multiply routes with the factor given here. Allowed values are between 0.01 and 1. "..
81         "It is only used when LQ-Level is greater than 0. Examples:<br />"..
82         "reduce LQ to 192.168.0.1 by half: 192.168.0.1 0.5<br />"..
83         "reduce LQ to all nodes on this interface by 20%: default 0.8"))
84 lqmult.optional = true
85 lqmult.rmempty = true
86 lqmult.cast = "table"
87 lqmult.placeholder = "default 1.0"
88
89
90 ip4b = i:taboption("addrs", Value, "Ip4Broadcast", translate("IPv4 broadcast"),
91         translate("IPv4 broadcast address for outgoing OLSR packets. One useful example would be 255.255.255.255. "..
92         "Default is \"0.0.0.0\", which triggers the usage of the interface broadcast IP."))
93 ip4b.optional = true
94 ip4b.datatype = "ip4addr"
95 ip4b.placeholder = "0.0.0.0"
96
97 ip6m = i:taboption("addrs", Value, "IPv6Multicast", translate("IPv6 multicast"),
98         translate("IPv6 multicast address. Default is \"FF02::6D\", the manet-router linklocal multicast."))
99 ip6m.optional = true
100 ip6m.datatype = "ip6addr"
101 ip6m.placeholder = "FF02::6D"
102
103 ip4s = i:taboption("addrs", Value, "IPv4Src", translate("IPv4 source"),
104         translate("IPv4 src address for outgoing OLSR packages. Default is \"0.0.0.0\", which triggers usage of the interface IP."))
105 ip4s.optional = true
106 ip4s.datatype = "ip4addr"
107 ip4s.placeholder = "0.0.0.0"
108
109 ip6s = i:taboption("addrs", Value, "IPv6Src", translate("IPv6 source"),
110         translate("IPv6 src prefix. OLSRd will choose one of the interface IPs which matches the prefix of this parameter. "..
111         "Default is \"0::/0\", which triggers the usage of a not-linklocal interface IP."))
112 ip6s.optional = true
113 ip6s.datatype = "ip6addr"
114 ip6s.placeholder = "0::/0"
115
116 hi = i:taboption("timing", Value, "HelloInterval", translate("Hello interval"))
117 hi.optional = true
118 hi.datatype = "ufloat"
119 hi.placeholder = "5.0"
120 hi.write = write_float
121
122 hv = i:taboption("timing", Value, "HelloValidityTime", translate("Hello validity time"))
123 hv.optional = true
124 hv.datatype = "ufloat"
125 hv.placeholder = "40.0"
126 hv.write = write_float
127
128 ti = i:taboption("timing", Value, "TcInterval", translate("TC interval"))
129 ti.optional = true
130 ti.datatype = "ufloat"
131 ti.placeholder = "2.0"
132 ti.write = write_float
133
134 tv = i:taboption("timing", Value, "TcValidityTime", translate("TC validity time"))
135 tv.optional = true
136 tv.datatype = "ufloat"
137 tv.placeholder = "256.0"
138 tv.write = write_float
139
140 mi = i:taboption("timing", Value, "MidInterval", translate("MID interval"))
141 mi.optional = true
142 mi.datatype = "ufloat"
143 mi.placeholder = "18.0"
144 mi.write = write_float
145
146 mv = i:taboption("timing", Value, "MidValidityTime", translate("MID validity time"))
147 mv.optional = true
148 mv.datatype = "ufloat"
149 mv.placeholder = "324.0"
150 mv.write = write_float
151
152 ai = i:taboption("timing", Value, "HnaInterval", translate("HNA interval"))
153 ai.optional = true
154 ai.datatype = "ufloat"
155 ai.placeholder = "18.0"
156 ai.write = write_float
157
158 av = i:taboption("timing", Value, "HnaValidityTime", translate("HNA validity time"))
159 av.optional = true
160 av.datatype = "ufloat"
161 av.placeholder = "108.0"
162 av.write = write_float
163
164 return m