modules/admin-full: expose switch title on vlan page
[project/luci.git] / modules / admin-full / 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
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("cdma", "CDMA")
38 service:value("evdo", "EV-DO")
39
40
41 apn = section:taboption("general", Value, "apn", translate("APN"))
42
43
44 pincode = section:taboption("general", Value, "pincode", translate("PIN"))
45 pincode.datatype = "range(0,9999)"
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
55 if luci.model.network:has_ipv6() then
56
57         ipv6 = section:taboption("advanced", Flag, "ipv6",
58                 translate("Enable IPv6 negotiation on the PPP link"))
59
60         ipv6.default = ipv6.disabled
61
62 end
63
64
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"))
68
69 maxwait.placeholder = "20"
70 maxwait.datatype    = "min(1)"
71
72
73 defaultroute = section:taboption("advanced", Flag, "defaultroute",
74         translate("Use default gateway"),
75         translate("If unchecked, no default route is configured"))
76
77 defaultroute.default = defaultroute.enabled
78
79
80 metric = section:taboption("advanced", Value, "metric",
81         translate("Use gateway metric"))
82
83 metric.placeholder = "0"
84 metric.datatype    = "uinteger"
85 metric:depends("defaultroute", defaultroute.enabled)
86
87
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"))
91
92 peerdns.default = peerdns.enabled
93
94
95 dns = section:taboption("advanced", DynamicList, "dns",
96         translate("Use custom DNS servers"))
97
98 dns:depends("peerdns", "")
99 dns.datatype = "ipaddr"
100
101
102 keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure",
103         translate("LCP echo failure threshold"),
104         translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures"))
105
106 function keepalive_failure.cfgvalue(self, section)
107         local v = m:get(section, "keepalive")
108         if v and #v > 0 then
109                 return tonumber(v:match("^(%d+)[ ,]+%d+") or v)
110         end
111 end
112
113 function keepalive_failure.write() end
114 function keepalive_failure.remove() end
115
116 keepalive_failure.placeholder = "0"
117 keepalive_failure.datatype    = "uinteger"
118
119
120 keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval",
121         translate("LCP echo interval"),
122         translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold"))
123
124 function keepalive_interval.cfgvalue(self, section)
125         local v = m:get(section, "keepalive")
126         if v and #v > 0 then
127                 return tonumber(v:match("^%d+[ ,]+(%d+)"))
128         end
129 end
130
131 function keepalive_interval.write(self, section, value)
132         local f = tonumber(keepalive_failure:formvalue(section)) or 0
133         local i = tonumber(value) or 5
134         if i < 1 then i = 1 end
135         if f > 0 then
136                 m:set(section, "keepalive", "%d %d" %{ f, i })
137         else
138                 m:del(section, "keepalive")
139         end
140 end
141
142 keepalive_interval.remove      = keepalive_interval.write
143 keepalive_interval.placeholder = "5"
144 keepalive_interval.datatype    = "min(1)"
145
146
147 demand = section:taboption("advanced", Value, "demand",
148         translate("Inactivity timeout"),
149         translate("Close inactive connection after the given amount of seconds, use 0 to persist connection"))
150
151 demand.placeholder = "0"
152 demand.datatype    = "uinteger"