X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=applications%2Fluci-olsr%2Fluasrc%2Fmodel%2Fcbi%2Folsr%2Folsrd.lua;h=f7b173cd6f26f813de4a54566e99c89f0be43ba8;hp=09d18350741d431cd1d160fd2c909ead52259c46;hb=725c424a759ca55017a50947fa871b44c7a8b8ef;hpb=82f08a4a1d1f7d54ccc82326c02f40f11a028409 diff --git a/applications/luci-olsr/luasrc/model/cbi/olsr/olsrd.lua b/applications/luci-olsr/luasrc/model/cbi/olsr/olsrd.lua index 09d183507..f7b173cd6 100644 --- a/applications/luci-olsr/luasrc/model/cbi/olsr/olsrd.lua +++ b/applications/luci-olsr/luasrc/model/cbi/olsr/olsrd.lua @@ -2,6 +2,7 @@ LuCI - Lua Configuration Interface Copyright 2008 Steven Barth +Copyright 2010 Jo-Philipp Wich Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,132 +15,327 @@ $Id$ require("luci.tools.webadmin") -m = Map("olsrd", translate("olsrd", "OLSR Daemon")) +m = Map("olsrd", translate("OLSR Daemon"), + translate("The OLSR daemon is an implementation of the Optimized Link State Routing protocol. ".. + "As such it allows mesh routing for any network equipment. ".. + "It runs on any wifi card that supports ad-hoc mode and of course on any ethernet device. ".. + "Visit olsrd.org for help and documentation.")) -s = m:section(TypedSection, "olsrd", translate("olsrd_general")) -s.dynamic = true -s.anonymous = true - -debug = s:option(ListValue, "DebugLevel") -for i=0, 9 do - debug:value(i) -end -debug.optional = true +function m.on_parse() + local has_defaults = false -ipv = s:option(ListValue, "IpVersion") -ipv:value("4", "IPv4") -ipv:value("6", "IPv6") + m.uci:foreach("olsrd", "InterfaceDefaults", + function(s) + has_defaults = true + return false + end) -noint = s:option(Flag, "AllowNoInt") -noint.enabled = "yes" -noint.disabled = "no" -noint.optional = true + if not has_defaults then + m.uci:section("olsrd", "InterfaceDefaults") + end +end -s:option(Value, "Pollrate").optional = true +function write_float(self, section, value) + local n = tonumber(value) + if n ~= nil then + return Value.write(self, section, "%.1f" % n) + end +end -tcr = s:option(ListValue, "TcRedundancy") -tcr:value("0", translate("olsrd_olsrd_tcredundancy_0")) -tcr:value("1", translate("olsrd_olsrd_tcredundancy_1")) -tcr:value("2", translate("olsrd_olsrd_tcredundancy_2")) -tcr.optional = true +s = m:section(TypedSection, "olsrd", translate("General settings")) +s.anonymous = true -s:option(Value, "MprCoverage").optional = true +s:tab("general", translate("General Settings")) +s:tab("lquality", translate("Link Quality Settings")) +s:tab("advanced", translate("Advanced Settings")) -lql = s:option(ListValue, "LinkQualityLevel") -lql:value("0", translate("disable")) -lql:value("1", translate("olsrd_olsrd_linkqualitylevel_1")) -lql:value("2", translate("olsrd_olsrd_linkqualitylevel_2")) -lql.optional = true -s:option(Value, "LinkQualityAging").optional = true +ipv = s:taboption("general", ListValue, "IpVersion", translate("Internet protocol"), + translate("IP-version to use. If 6and4 is selected then one olsrd instance is started for each protocol.")) +ipv:value("4", "IPv4") +ipv:value("6", "IPv6") +ipv:value("6and4", "6and4") + + +poll = s:taboption("advanced", Value, "Pollrate", translate("Pollrate"), + translate("Polling rate for OLSR sockets in seconds. Default is 0.05.")) +poll.optional = true +poll.datatype = "ufloat" +poll.placeholder = "0.05" + +nicc = s:taboption("advanced", Value, "NicChgsPollInt", translate("Nic changes poll interval"), + translate("Interval to poll network interfaces for configuration changes (in seconds). Default is \"2.5\".")) +nicc.optional = true +nicc.datatype = "ufloat" +nicc.placeholder = "2.5" + +tos = s:taboption("advanced", Value, "TosValue", translate("TOS value"), + translate("Type of service value for the IP header of control traffic. Default is \"16\".")) +tos.optional = true +tos.datatype = "uinteger" +tos.placeholder = "16" + +fib = s:taboption("general", ListValue, "FIBMetric", translate("FIB metric"), + translate ("FIBMetric controls the metric value of the host-routes OLSRd sets. ".. + "\"flat\" means that the metric value is always 2. This is the preferred value ".. + "because it helps the linux kernel routing to clean up older routes. ".. + "\"correct\" uses the hopcount as the metric value. ".. + "\"approx\" use the hopcount as the metric value too, but does only update the hopcount if the nexthop changes too. ".. + "Default is \"flat\".")) +fib:value("flat") +fib:value("correct") +fib:value("approx") -lqa = s:option(ListValue, "LinkQualityAlgorithm") +lql = s:taboption("lquality", ListValue, "LinkQualityLevel", translate("LQ level"), + translate("Link quality level switch between hopcount and cost-based (mostly ETX) routing.
".. + "0 = do not use link quality
".. + "2 = use link quality for MPR selection and routing
".. + "Default is \"2\"")) +lql:value("2") +lql:value("0") + +lqage = s:taboption("lquality", Value, "LinkQualityAging", translate("LQ aging"), + translate("Link quality aging factor (only for lq level 2). Tuning parameter for etx_float and etx_fpm, smaller values ".. + "mean slower changes of ETX value. (allowed values are between 0.01 and 1.0)")) +lqage.optional = true +lqage:depends("LinkQualityLevel", "2") + +lqa = s:taboption("lquality", ListValue, "LinkQualityAlgorithm", translate("LQ algorithm"), + translate("Link quality algorithm (only for lq level 2).
".. + "etx_float: floating point ETX with exponential aging
".. + "etx_fpm : same as ext_float, but with integer arithmetic
".. + "etx_ff : ETX freifunk, an etx variant which use all OLSR traffic (instead of only hellos) for ETX calculation
".. + "etx_ffeth: incompatible variant of etx_ff that allows ethernet links with ETX 0.1.
".. + "Defaults to \"etx_ff\"")) lqa.optional = true -lqa:value("etx_fpm", translate("olsrd_etx_fpm")) -lqa:value("etx_float", translate("olsrd_etx_float")) -lqa:value("etx_ff", translate("olsrd_etx_ff")) +lqa:value("etx_ff") +lqa:value("etx_fpm") +lqa:value("etx_float") +lqa:value("etx_ffeth") +lqa:depends("LinkQualityLevel", "2") lqa.optional = true -lqfish = s:option(Flag, "LinkQualityFishEye") +lqfish = s:taboption("lquality", Flag, "LinkQualityFishEye", translate("LQ fisheye"), + translate("Fisheye mechanism for TCs (checked means on). Default is \"on\"")) +lqfish.default = "1" lqfish.optional = true -s:option(Value, "LinkQualityWinSize").optional = true - -s:option(Value, "LinkQualityDijkstraLimit").optional = true - -hyst = s:option(Flag, "UseHysteresis") +hyst = s:taboption("lquality", Flag, "UseHysteresis", translate("Use hysteresis"), + translate("Hysteresis for link sensing (only for hopcount metric). Hysteresis adds more robustness to the link sensing ".. + "but delays neighbor registration. Defaults is \"yes\"")) +hyst.default = "yes" hyst.enabled = "yes" hyst.disabled = "no" +hyst:depends("LinkQualityLevel", "0") hyst.optional = true - -fib = s:option(ListValue, "FIBMetric") -fib.optional = true -fib:value("flat") -fib:value("correct") -fib:value("approx") -fib.optional = true - -clrscr = s:option(Flag, "ClearScreen") -clrscr.enabled = "yes" -clrscr.disabled = "no" -clrscr.optional = true - -willingness = s:option(ListValue, "Willingness") +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.")) +port.optional = true +port.default = "698" +port.rmempty = true + +mainip = s:taboption("general", Value, "MainIp", translate("Main IP"), + translate("Sets the main IP (originator ip) of the router. This IP will NEVER change during the uptime of olsrd. ".. + "Default is 0.0.0.0, which triggers usage of the IP of the first interface.")) +mainip.optional = true +mainip.rmempty = true +mainip.datatype = "ipaddr" +mainip.placeholder = "0.0.0.0" + +willingness = s:taboption("advanced", ListValue, "Willingness", translate("Willingness"), + translate("The fixed willingness to use. If not set willingness will be calculated dynamically based on battery/power status. Default is \"3\".")) for i=0,7 do willingness:value(i) end willingness.optional = true +willingness.default = "3" + +natthr = s:taboption("advanced", Value, "NatThreshold", translate("NAT threshold"), + translate("If the route to the current gateway is to be changed, the ETX value of this gateway is ".. + "multiplied with this value before it is compared to the new one. ".. + "The parameter can be a value between 0.1 and 1.0, but should be close to 1.0 if changed.
".. + "WARNING: This parameter should not be used together with the etx_ffeth metric!
".. + "Defaults to \"1.0\".")) +for i=1,0.1,-0.1 do + natthr:value(i) +end +natthr:depends("LinkQualityAlgorithm", "etx_ff") +natthr:depends("LinkQualityAlgorithm", "etx_float") +natthr:depends("LinkQualityAlgorithm", "etx_fpm") +natthr.default = "1.0" +natthr.optional = true +natthr.write = write_float - -i = m:section(TypedSection, "Interface", translate("interfaces")) +i = m:section(TypedSection, "InterfaceDefaults", translate("Interfaces Defaults")) i.anonymous = true -i.addremove = true -i.dynamic = true +i.addremove = false + +i:tab("general", translate("General Settings")) +i:tab("addrs", translate("IP Addresses")) +i:tab("timing", translate("Timing and Validity")) + +mode = i:taboption("general", ListValue, "Mode", translate("Mode"), + translate("Interface Mode is used to prevent unnecessary packet forwarding on switched ethernet interfaces. ".. + "valid Modes are \"mesh\" and \"ether\". Default is \"mesh\".")) +mode:value("mesh") +mode:value("ether") +mode.optional = true +mode.rmempty = true + + +weight = i:taboption("general", Value, "Weight", translate("Weight"), + translate("When multiple links exist between hosts the weight of interface is used to determine the link to use. ".. + "Normally the weight is automatically calculated by olsrd based on the characteristics of the interface, ".. + "but here you can specify a fixed value. Olsrd will choose links with the lowest value.
".. + "Note: Interface weight is used only when LinkQualityLevel is set to 0. ".. + "For any other value of LinkQualityLevel, the interface ETX value is used instead.")) +weight.optional = true +weight.datatype = "uinteger" +weight.placeholder = "0" + +lqmult = i:taboption("general", DynamicList, "LinkQualityMult", translate("LinkQuality Multiplicator"), + translate("Multiply routes with the factor given here. Allowed values are between 0.01 and 1. ".. + "It is only used when LQ-Level is greater than 0. Examples:
".. + "reduce LQ to 192.168.0.1 by half: 192.168.0.1 0.5
".. + "reduce LQ to all nodes on this interface by 20%: default 0.8")) +lqmult.optional = true +lqmult.rmempty = true +lqmult.cast = "table" +lqmult.placeholder = "default 1.0" + + +ip4b = i:taboption("addrs", Value, "Ip4Broadcast", translate("IPv4 broadcast"), + translate("IPv4 broadcast address for outgoing OLSR packets. One useful example would be 255.255.255.255. ".. + "Default is \"0.0.0.0\", which triggers the usage of the interface broadcast IP.")) +ip4b.optional = true +ip4b.datatype = "ip4addr" +ip4b.placeholder = "0.0.0.0" + +ip6m = i:taboption("addrs", Value, "IPv6Multicast", translate("IPv6 multicast"), + translate("IPv6 multicast address. Default is \"FF02::6D\", the manet-router linklocal multicast.")) +ip6m.optional = true +ip6m.datatype = "ip6addr" +ip6m.placeholder = "FF02::6D" + +ip4s = i:taboption("addrs", Value, "IPv4Src", translate("IPv4 source"), + translate("IPv4 src address for outgoing OLSR packages. Default is \"0.0.0.0\", which triggers usage of the interface IP.")) +ip4s.optional = true +ip4s.datatype = "ip4addr" +ip4s.placeholder = "0.0.0.0" + +ip6s = i:taboption("addrs", Value, "IPv6Src", translate("IPv6 source"), + translate("IPv6 src prefix. OLSRd will choose one of the interface IPs which matches the prefix of this parameter. ".. + "Default is \"0::/0\", which triggers the usage of a not-linklocal interface IP.")) +ip6s.optional = true +ip6s.datatype = "ip6addr" +ip6s.placeholder = "0::/0" + + +hi = i:taboption("timing", Value, "HelloInterval", translate("Hello interval")) +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")) +ifs.addremove = true +ifs.anonymous = true +ifs.extedit = luci.dispatcher.build_url("admin/services/olsrd/iface/%s") +ifs.template = "cbi/tblsection" + +function ifs.create(...) + local sid = TypedSection.create(...) + luci.http.redirect(ifs.extedit % sid) +end -ign = i:option(Flag, "ignore", "Enable") +ign = ifs:option(Flag, "ignore", translate("Enable")) ign.enabled = "0" ign.disabled = "1" +ign.rmempty = false +function ign.cfgvalue(self, section) + return Flag.cfgvalue(self, section) or "0" +end -network = i:option(ListValue, "interface", translate("network")) -luci.tools.webadmin.cbi_add_networks(network) - -i:option(Value, "Ip4Broadcast").optional = true - -ip6t = i:option(ListValue, "Ip6AddrType") -ip6t:value("", translate("cbi_select")) -ip6t:value("auto") -ip6t:value("site-local") -ip6t:value("unique-local") -ip6t:value("global") -ip6t.optional = true - -i:option(Value, "HelloInterval").optional = true -i:option(Value, "HelloValidityTime").optional = true -i:option(Value, "TcInterval").optional = true -i:option(Value, "TcValidityTime").optional = true -i:option(Value, "MidInterval").optional = true -i:option(Value, "MidValidityTime").optional = true -i:option(Value, "HnaInterval").optional = true -i:option(Value, "HnaValidityTime").optional = true - -adc = i:option(Flag, "AutoDetectChanges") -adc.enabled = "yes" -adc.disabled = "no" -adc.optional = true - +network = ifs:option(DummyValue, "interface", translate("Network")) +network.template = "cbi/network_netinfo" -ipc = m:section(TypedSection, "IpcConnect") -ipc.anonymous = true +mode = ifs:option(DummyValue, "Mode", translate("Mode")) +function mode.cfgvalue(...) + return Value.cfgvalue(...) or m.uci:get_first("olsrd", "InterfaceDefaults", "Mode", "mesh") +end -conns = ipc:option(Value, "MaxConnections") -conns.isInteger = true +hello = ifs:option(DummyValue, "_hello", translate("Hello")) +function hello.cfgvalue(self, section) + 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 -nets = ipc:option(Value, "Net") -nets.optional = true +tc = ifs:option(DummyValue, "_tc", translate("TC")) +function tc.cfgvalue(self, section) + 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 -hosts = ipc:option(Value, "Host") -hosts.optional = true +mid = ifs:option(DummyValue, "_mid", translate("MID")) +function mid.cfgvalue(self, section) + 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 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 return m