2 LuCI - Lua Configuration Interface
4 Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
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
10 http://www.apache.org/licenses/LICENSE-2.0
13 local map, section, net = ...
15 local device, apn, service, pincode, username, password
16 local ipv6, maxwait, defaultroute, metric, peerdns, dns,
17 keepalive_failure, keepalive_interval, demand
20 device = section:taboption("general", Value, "device", translate("Modem device"))
21 device.rmempty = false
23 local device_suggestions = nixio.fs.glob("/dev/tty[A-Z]*")
24 or nixio.fs.glob("/dev/tts/*")
26 if device_suggestions then
28 for node in device_suggestions do
34 service = section:taboption("general", Value, "service", translate("Service Type"))
35 service:value("", translate("-- Please choose --"))
36 service:value("umts", "UMTS/GPRS")
37 service:value("umts_only", translate("UMTS only"))
38 service:value("gprs_only", translate("GPRS only"))
39 service:value("evdo", "CDMA/EV-DO")
42 apn = section:taboption("general", Value, "apn", translate("APN"))
45 pincode = section:taboption("general", Value, "pincode", translate("PIN"))
48 username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
51 password = section:taboption("general", Value, "password", translate("PAP/CHAP password"))
52 password.password = true
55 if luci.model.network:has_ipv6() then
57 ipv6 = section:taboption("advanced", Flag, "ipv6",
58 translate("Enable IPv6 negotiation on the PPP link"))
60 ipv6.default = ipv6.disabled
65 maxwait = section:taboption("advanced", Value, "maxwait",
66 translate("Modem init timeout"),
67 translate("Maximum amount of seconds to wait for the modem to become ready"))
69 maxwait.placeholder = "20"
70 maxwait.datatype = "min(1)"
73 defaultroute = section:taboption("advanced", Flag, "defaultroute",
74 translate("Use default gateway"),
75 translate("If unchecked, no default route is configured"))
77 defaultroute.default = defaultroute.enabled
80 metric = section:taboption("advanced", Value, "metric",
81 translate("Use gateway metric"))
83 metric.placeholder = "0"
84 metric.datatype = "uinteger"
85 metric:depends("defaultroute", defaultroute.enabled)
88 peerdns = section:taboption("advanced", Flag, "peerdns",
89 translate("Use DNS servers advertised by peer"),
90 translate("If unchecked, the advertised DNS server addresses are ignored"))
92 peerdns.default = peerdns.enabled
95 dns = section:taboption("advanced", DynamicList, "dns",
96 translate("Use custom DNS servers"))
98 dns:depends("peerdns", "")
99 dns.datatype = "ipaddr"
103 keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure",
104 translate("LCP echo failure threshold"),
105 translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures"))
107 function keepalive_failure.cfgvalue(self, section)
108 local v = m:get(section, "keepalive")
110 return tonumber(v:match("^(%d+)[ ,]+%d+") or v)
114 function keepalive_failure.write() end
115 function keepalive_failure.remove() end
117 keepalive_failure.placeholder = "0"
118 keepalive_failure.datatype = "uinteger"
121 keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval",
122 translate("LCP echo interval"),
123 translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold"))
125 function keepalive_interval.cfgvalue(self, section)
126 local v = m:get(section, "keepalive")
128 return tonumber(v:match("^%d+[ ,]+(%d+)"))
132 function keepalive_interval.write(self, section, value)
133 local f = tonumber(keepalive_failure:formvalue(section)) or 0
134 local i = tonumber(value) or 5
135 if i < 1 then i = 1 end
137 m:set(section, "keepalive", "%d %d" %{ f, i })
139 m:del(section, "keepalive")
143 keepalive_interval.remove = keepalive_interval.write
144 keepalive_interval.placeholder = "5"
145 keepalive_interval.datatype = "min(1)"
148 demand = section:taboption("advanced", Value, "demand",
149 translate("Inactivity timeout"),
150 translate("Close inactive connection after the given amount of seconds, use 0 to persist connection"))
152 demand.placeholder = "0"
153 demand.datatype = "uinteger"