end
end
+function write_float(self, section, value)
+ local n = tonumber(value)
+ if n ~= nil then
+ return Value.write(self, section, "%.1f" % n)
+ end
+end
+
s = m:section(TypedSection, "olsrd", translate("General settings"))
---s.dynamic = true
s.anonymous = true
s:tab("general", translate("General Settings"))
hyst.disabled = "no"
hyst:depends("LinkQualityLevel", "0")
hyst.optional = true
+hyst.rmempty = true
port = s:taboption("general", Value, "OlsrPort", translate("Port"),
translate("The port OLSR uses. This should usually stay at the IANA assigned port 698. It can have a value between 1 and 65535."))
natthr:depends("LinkQualityAlgorithm", "etx_ff")
natthr:depends("LinkQualityAlgorithm", "etx_float")
natthr:depends("LinkQualityAlgorithm", "etx_fpm")
-natthr.default = 1
+natthr.default = "1.0"
natthr.optional = true
+natthr.write = write_float
i = m:section(TypedSection, "InterfaceDefaults", translate("Interfaces Defaults"))
hi.optional = true
hi.datatype = "ufloat"
hi.placeholder = "5.0"
+hi.write = write_float
hv = i:taboption("timing", Value, "HelloValidityTime", translate("Hello validity time"))
hv.optional = true
hv.datatype = "ufloat"
hv.placeholder = "40.0"
+hv.write = write_float
ti = i:taboption("timing", Value, "TcInterval", translate("TC interval"))
ti.optional = true
ti.datatype = "ufloat"
ti.placeholder = "2.0"
+ti.write = write_float
tv = i:taboption("timing", Value, "TcValidityTime", translate("TC validity time"))
tv.optional = true
tv.datatype = "ufloat"
tv.placeholder = "256.0"
+tv.write = write_float
mi = i:taboption("timing", Value, "MidInterval", translate("MID interval"))
mi.optional = true
mi.datatype = "ufloat"
mi.placeholder = "18.0"
+mi.write = write_float
mv = i:taboption("timing", Value, "MidValidityTime", translate("MID validity time"))
mv.optional = true
mv.datatype = "ufloat"
mv.placeholder = "324.0"
+mv.write = write_float
ai = i:taboption("timing", Value, "HnaInterval", translate("HNA interval"))
ai.optional = true
ai.datatype = "ufloat"
ai.placeholder = "18.0"
+ai.write = write_float
av = i:taboption("timing", Value, "HnaValidityTime", translate("HNA validity time"))
av.optional = true
av.datatype = "ufloat"
av.placeholder = "108.0"
+av.write = write_float
ifs = m:section(TypedSection, "Interface", translate("Interfaces"))
mode = ifs:option(DummyValue, "Mode", translate("Mode"))
function mode.cfgvalue(...)
- return Value.cfgvalue(...) or "mesh"
+ return Value.cfgvalue(...) or m.uci:get_first("olsrd", "InterfaceDefaults", "Mode", "mesh")
end
hello = ifs:option(DummyValue, "_hello", translate("Hello"))
function hello.cfgvalue(self, section)
- local i = tonumber(m.uci:get("olsrd", section, "HelloInterval")) or 5
- local v = tonumber(m.uci:get("olsrd", section, "HelloValidityTime")) or 40
+ local i = tonumber(m.uci:get("olsrd", section, "HelloInterval")) or tonumber(m.uci:get_first("olsrd", "InterfaceDefaults", "HelloInterval", 5))
+ local v = tonumber(m.uci:get("olsrd", section, "HelloValidityTime")) or tonumber(m.uci:get_first("olsrd", "InterfaceDefaults", "HelloValidityTime", 40))
return "%.01fs / %.01fs" %{ i, v }
end
tc = ifs:option(DummyValue, "_tc", translate("TC"))
function tc.cfgvalue(self, section)
- local i = tonumber(m.uci:get("olsrd", section, "TcInterval")) or 2
- local v = tonumber(m.uci:get("olsrd", section, "TcValidityTime")) or 256
+ local i = tonumber(m.uci:get("olsrd", section, "TcInterval")) or tonumber(m.uci:get_first("olsrd", "InterfaceDefaults", "TcInterval", 2))
+ local v = tonumber(m.uci:get("olsrd", section, "TcValidityTime")) or tonumber(m.uci:get_first("olsrd", "InterfaceDefaults", "TcValidityTime", 256))
return "%.01fs / %.01fs" %{ i, v }
end
mid = ifs:option(DummyValue, "_mid", translate("MID"))
function mid.cfgvalue(self, section)
- local i = tonumber(m.uci:get("olsrd", section, "MidInterval")) or 18
- local v = tonumber(m.uci:get("olsrd", section, "MidValidityTime")) or 324
+ local i = tonumber(m.uci:get("olsrd", section, "MidInterval")) or tonumber(m.uci:get_first("olsrd", "InterfaceDefaults", "MidInterval", 18))
+ local v = tonumber(m.uci:get("olsrd", section, "MidValidityTime")) or tonumber(m.uci:get_first("olsrd", "InterfaceDefaults", "MidValidityTime", 324))
return "%.01fs / %.01fs" %{ i, v }
end
hna = ifs:option(DummyValue, "_hna", translate("HNA"))
function hna.cfgvalue(self, section)
- local i = tonumber(m.uci:get("olsrd", section, "HnaInterval")) or 18
- local v = tonumber(m.uci:get("olsrd", section, "HnaValidityTime")) or 108
+ local i = tonumber(m.uci:get("olsrd", section, "HnaInterval")) or tonumber(m.uci:get_first("olsrd", "InterfaceDefaults", "HnaInterval", 18))
+ local v = tonumber(m.uci:get("olsrd", section, "HnaValidityTime")) or tonumber(m.uci:get_first("olsrd", "InterfaceDefaults", "HnaValidityTime", 108))
return "%.01fs / %.01fs" %{ i, v }
end