luci-proto-3g: add dialnumber option
[project/luci.git] / protocols / luci-proto-3g / luasrc / model / cbi / admin_network / proto_3g.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2011 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
13 local map, section, net = ...
14
15 local device, apn, service, pincode, username, password, dialnumber
16 local ipv6, maxwait, defaultroute, metric, peerdns, dns,
17       keepalive_failure, keepalive_interval, demand
18
19
20 device = section:taboption("general", Value, "device", translate("Modem device"))
21 device.rmempty = false
22
23 local device_suggestions = nixio.fs.glob("/dev/tty[A-Z]*")
24         or nixio.fs.glob("/dev/tts/*")
25
26 if device_suggestions then
27         local node
28         for node in device_suggestions do
29                 device:value(node)
30         end
31 end
32
33
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")
40
41
42 apn = section:taboption("general", Value, "apn", translate("APN"))
43
44
45 pincode = section:taboption("general", Value, "pincode", translate("PIN"))
46
47
48 username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
49
50
51 password = section:taboption("general", Value, "password", translate("PAP/CHAP password"))
52 password.password = true
53
54 dialnumber = section:taboption("general", Value, "dialnumber", translate("Dial number"))
55 dialnumber.placeholder = "*99***1#"
56
57 if luci.model.network:has_ipv6() then
58
59         ipv6 = section:taboption("advanced", Flag, "ipv6",
60                 translate("Enable IPv6 negotiation on the PPP link"))
61
62         ipv6.default = ipv6.disabled
63
64 end
65
66
67 maxwait = section:taboption("advanced", Value, "maxwait",
68         translate("Modem init timeout"),
69         translate("Maximum amount of seconds to wait for the modem to become ready"))
70
71 maxwait.placeholder = "20"
72 maxwait.datatype    = "min(1)"
73
74
75 defaultroute = section:taboption("advanced", Flag, "defaultroute",
76         translate("Use default gateway"),
77         translate("If unchecked, no default route is configured"))
78
79 defaultroute.default = defaultroute.enabled
80
81
82 metric = section:taboption("advanced", Value, "metric",
83         translate("Use gateway metric"))
84
85 metric.placeholder = "0"
86 metric.datatype    = "uinteger"
87 metric:depends("defaultroute", defaultroute.enabled)
88
89
90 peerdns = section:taboption("advanced", Flag, "peerdns",
91         translate("Use DNS servers advertised by peer"),
92         translate("If unchecked, the advertised DNS server addresses are ignored"))
93
94 peerdns.default = peerdns.enabled
95
96
97 dns = section:taboption("advanced", DynamicList, "dns",
98         translate("Use custom DNS servers"))
99
100 dns:depends("peerdns", "")
101 dns.datatype = "ipaddr"
102 dns.cast     = "string"
103
104
105 keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure",
106         translate("LCP echo failure threshold"),
107         translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures"))
108
109 function keepalive_failure.cfgvalue(self, section)
110         local v = m:get(section, "keepalive")
111         if v and #v > 0 then
112                 return tonumber(v:match("^(%d+)[ ,]+%d+") or v)
113         end
114 end
115
116 function keepalive_failure.write() end
117 function keepalive_failure.remove() end
118
119 keepalive_failure.placeholder = "0"
120 keepalive_failure.datatype    = "uinteger"
121
122
123 keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval",
124         translate("LCP echo interval"),
125         translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold"))
126
127 function keepalive_interval.cfgvalue(self, section)
128         local v = m:get(section, "keepalive")
129         if v and #v > 0 then
130                 return tonumber(v:match("^%d+[ ,]+(%d+)"))
131         end
132 end
133
134 function keepalive_interval.write(self, section, value)
135         local f = tonumber(keepalive_failure:formvalue(section)) or 0
136         local i = tonumber(value) or 5
137         if i < 1 then i = 1 end
138         if f > 0 then
139                 m:set(section, "keepalive", "%d %d" %{ f, i })
140         else
141                 m:del(section, "keepalive")
142         end
143 end
144
145 keepalive_interval.remove      = keepalive_interval.write
146 keepalive_interval.placeholder = "5"
147 keepalive_interval.datatype    = "min(1)"
148
149
150 demand = section:taboption("advanced", Value, "demand",
151         translate("Inactivity timeout"),
152         translate("Close inactive connection after the given amount of seconds, use 0 to persist connection"))
153
154 demand.placeholder = "0"
155 demand.datatype    = "uinteger"