1 -- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
4 local map, section, net = ...
6 local device, apn, service, pincode, username, password, dialnumber
7 local ipv6, maxwait, defaultroute, metric, peerdns, dns,
8 keepalive_failure, keepalive_interval, demand
11 device = section:taboption("general", Value, "device", translate("Modem device"))
12 device.rmempty = false
14 local device_suggestions = nixio.fs.glob("/dev/tty[A-Z]*")
15 or nixio.fs.glob("/dev/tts/*")
17 if device_suggestions then
19 for node in device_suggestions do
25 service = section:taboption("general", Value, "service", translate("Service Type"))
26 service:value("", translate("-- Please choose --"))
27 service:value("umts", "UMTS/GPRS")
28 service:value("umts_only", translate("UMTS only"))
29 service:value("gprs_only", translate("GPRS only"))
30 service:value("evdo", "CDMA/EV-DO")
33 apn = section:taboption("general", Value, "apn", translate("APN"))
36 pincode = section:taboption("general", Value, "pincode", translate("PIN"))
39 username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
42 password = section:taboption("general", Value, "password", translate("PAP/CHAP password"))
43 password.password = true
45 dialnumber = section:taboption("general", Value, "dialnumber", translate("Dial number"))
46 dialnumber.placeholder = "*99***1#"
48 if luci.model.network:has_ipv6() then
50 ipv6 = section:taboption("advanced", ListValue, "ipv6",
51 translate("Obtain IPv6-Address"))
53 ipv6:value("auto", translate("Automatic"))
54 ipv6:value("0", translate("Disabled"))
55 ipv6:value("1", translate("Manual"))
61 maxwait = section:taboption("advanced", Value, "maxwait",
62 translate("Modem init timeout"),
63 translate("Maximum amount of seconds to wait for the modem to become ready"))
65 maxwait.placeholder = "20"
66 maxwait.datatype = "min(1)"
69 defaultroute = section:taboption("advanced", Flag, "defaultroute",
70 translate("Use default gateway"),
71 translate("If unchecked, no default route is configured"))
73 defaultroute.default = defaultroute.enabled
76 metric = section:taboption("advanced", Value, "metric",
77 translate("Use gateway metric"))
79 metric.placeholder = "0"
80 metric.datatype = "uinteger"
81 metric:depends("defaultroute", defaultroute.enabled)
84 peerdns = section:taboption("advanced", Flag, "peerdns",
85 translate("Use DNS servers advertised by peer"),
86 translate("If unchecked, the advertised DNS server addresses are ignored"))
88 peerdns.default = peerdns.enabled
91 dns = section:taboption("advanced", DynamicList, "dns",
92 translate("Use custom DNS servers"))
94 dns:depends("peerdns", "")
95 dns.datatype = "ipaddr"
99 keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure",
100 translate("LCP echo failure threshold"),
101 translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures"))
103 function keepalive_failure.cfgvalue(self, section)
104 local v = m:get(section, "keepalive")
106 return tonumber(v:match("^(%d+)[ ,]+%d+") or v)
110 function keepalive_failure.write() end
111 function keepalive_failure.remove() end
113 keepalive_failure.placeholder = "0"
114 keepalive_failure.datatype = "uinteger"
117 keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval",
118 translate("LCP echo interval"),
119 translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold"))
121 function keepalive_interval.cfgvalue(self, section)
122 local v = m:get(section, "keepalive")
124 return tonumber(v:match("^%d+[ ,]+(%d+)"))
128 function keepalive_interval.write(self, section, value)
129 local f = tonumber(keepalive_failure:formvalue(section)) or 0
130 local i = tonumber(value) or 5
131 if i < 1 then i = 1 end
133 m:set(section, "keepalive", "%d %d" %{ f, i })
135 m:del(section, "keepalive")
139 keepalive_interval.remove = keepalive_interval.write
140 keepalive_interval.placeholder = "5"
141 keepalive_interval.datatype = "min(1)"
144 demand = section:taboption("advanced", Value, "demand",
145 translate("Inactivity timeout"),
146 translate("Close inactive connection after the given amount of seconds, use 0 to persist connection"))
148 demand.placeholder = "0"
149 demand.datatype = "uinteger"