Globally reduce copyright headers
[project/luci.git] / protocols / luci-proto-ppp / luasrc / model / cbi / admin_network / proto_ppp.lua
1 -- Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local map, section, net = ...
5
6 local device, username, password
7 local ipv6, defaultroute, metric, peerdns, dns,
8 keepalive_failure, keepalive_interval, demand, mtu
9
10
11 device = section:taboption("general", Value, "device", translate("Modem device"))
12 device.rmempty = false
13
14 local device_suggestions = nixio.fs.glob("/dev/tty*S*")
15 or nixio.fs.glob("/dev/tts/*")
16
17 if device_suggestions then
18 local node
19 for node in device_suggestions do
20 device:value(node)
21 end
22 end
23
24
25 username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
26
27
28 password = section:taboption("general", Value, "password", translate("PAP/CHAP password"))
29 password.password = true
30
31
32 if luci.model.network:has_ipv6() then
33
34 ipv6 = section:taboption("advanced", Flag, "ipv6",
35 translate("Enable IPv6 negotiation on the PPP link"))
36
37 ipv6.default = ipv6.disabled
38
39 end
40
41
42 defaultroute = section:taboption("advanced", Flag, "defaultroute",
43 translate("Use default gateway"),
44 translate("If unchecked, no default route is configured"))
45
46 defaultroute.default = defaultroute.enabled
47
48
49 metric = section:taboption("advanced", Value, "metric",
50 translate("Use gateway metric"))
51
52 metric.placeholder = "0"
53 metric.datatype = "uinteger"
54 metric:depends("defaultroute", defaultroute.enabled)
55
56
57 peerdns = section:taboption("advanced", Flag, "peerdns",
58 translate("Use DNS servers advertised by peer"),
59 translate("If unchecked, the advertised DNS server addresses are ignored"))
60
61 peerdns.default = peerdns.enabled
62
63
64 dns = section:taboption("advanced", DynamicList, "dns",
65 translate("Use custom DNS servers"))
66
67 dns:depends("peerdns", "")
68 dns.datatype = "ipaddr"
69 dns.cast = "string"
70
71
72 keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure",
73 translate("LCP echo failure threshold"),
74 translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures"))
75
76 function keepalive_failure.cfgvalue(self, section)
77 local v = m:get(section, "keepalive")
78 if v and #v > 0 then
79 return tonumber(v:match("^(%d+)[ ,]+%d+") or v)
80 end
81 end
82
83 keepalive_failure.placeholder = "0"
84 keepalive_failure.datatype = "uinteger"
85
86
87 keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval",
88 translate("LCP echo interval"),
89 translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold"))
90
91 function keepalive_interval.cfgvalue(self, section)
92 local v = m:get(section, "keepalive")
93 if v and #v > 0 then
94 return tonumber(v:match("^%d+[ ,]+(%d+)"))
95 end
96 end
97
98 function keepalive_interval.write(self, section, value)
99 local f = tonumber(keepalive_failure:formvalue(section)) or 0
100 local i = tonumber(value) or 5
101 if i < 1 then i = 1 end
102 if f > 0 then
103 m:set(section, "keepalive", "%d %d" %{ f, i })
104 else
105 m:del(section, "keepalive")
106 end
107 end
108
109 keepalive_interval.remove = keepalive_interval.write
110 keepalive_failure.write = keepalive_interval.write
111 keepalive_failure.remove = keepalive_interval.write
112 keepalive_interval.placeholder = "5"
113 keepalive_interval.datatype = "min(1)"
114
115
116 demand = section:taboption("advanced", Value, "demand",
117 translate("Inactivity timeout"),
118 translate("Close inactive connection after the given amount of seconds, use 0 to persist connection"))
119
120 demand.placeholder = "0"
121 demand.datatype = "uinteger"
122
123
124 mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"))
125 mtu.placeholder = "1500"
126 mtu.datatype = "max(9200)"