modules/admin-full: expose switch title on vlan page
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / proto_pppoa.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 encaps, atmdev, vci, vpi, username, password
16 local ipv6, defaultroute, metric, peerdns, dns,
17       keepalive_failure, keepalive_interval, demand
18
19
20 encaps = section:taboption("general", ListValue, "encaps", translate("PPPoA Encapsulation"))
21 encaps:value("vc", "VC-Mux")
22 encaps:value("llc", "LLC")
23
24
25 atmdev = section:taboption("general", Value, "atmdev", translate("ATM device number"))
26 atmdev.default  = "0"
27 atmdev.datatype = "uinteger"
28
29
30 vci = section:taboption("general", Value, "vci", translate("ATM Virtual Channel Identifier (VCI)"))
31 vci.default  = "35"
32 vci.datatype = "uinteger"
33
34
35 vpi = section:taboption("general", Value, "vpi", translate("ATM Virtual Path Identifier (VPI)"))
36 vpi.default  = "8"
37 vpi.datatype = "uinteger"
38
39
40 username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
41
42
43 password = section:taboption("general", Value, "password", translate("PAP/CHAP password"))
44 password.password = true
45
46
47 if luci.model.network:has_ipv6() then
48
49         ipv6 = section:taboption("advanced", Flag, "ipv6",
50                 translate("Enable IPv6 negotiation on the PPP link"))
51
52         ipv6.default = ipv6.disabled
53
54 end
55
56
57 defaultroute = section:taboption("advanced", Flag, "defaultroute",
58         translate("Use default gateway"),
59         translate("If unchecked, no default route is configured"))
60
61 defaultroute.default = defaultroute.enabled
62
63
64 metric = section:taboption("advanced", Value, "metric",
65         translate("Use gateway metric"))
66
67 metric.placeholder = "0"
68 metric.datatype    = "uinteger"
69 metric:depends("defaultroute", defaultroute.enabled)
70
71
72 peerdns = section:taboption("advanced", Flag, "peerdns",
73         translate("Use DNS servers advertised by peer"),
74         translate("If unchecked, the advertised DNS server addresses are ignored"))
75
76 peerdns.default = peerdns.enabled
77
78
79 dns = section:taboption("advanced", DynamicList, "dns",
80         translate("Use custom DNS servers"))
81
82 dns:depends("peerdns", "")
83 dns.datatype = "ipaddr"
84
85
86 keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure",
87         translate("LCP echo failure threshold"),
88         translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures"))
89
90 function keepalive_failure.cfgvalue(self, section)
91         local v = m:get(section, "keepalive")
92         if v and #v > 0 then
93                 return tonumber(v:match("^(%d+)[ ,]+%d+") or v)
94         end
95 end
96
97 function keepalive_failure.write() end
98 function keepalive_failure.remove() end
99
100 keepalive_failure.placeholder = "0"
101 keepalive_failure.datatype    = "uinteger"
102
103
104 keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval",
105         translate("LCP echo interval"),
106         translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold"))
107
108 function keepalive_interval.cfgvalue(self, section)
109         local v = m:get(section, "keepalive")
110         if v and #v > 0 then
111                 return tonumber(v:match("^%d+[ ,]+(%d+)"))
112         end
113 end
114
115 function keepalive_interval.write(self, section, value)
116         local f = tonumber(keepalive_failure:formvalue(section)) or 0
117         local i = tonumber(value) or 5
118         if i < 1 then i = 1 end
119         if f > 0 then
120                 m:set(section, "keepalive", "%d %d" %{ f, i })
121         else
122                 m:del(section, "keepalive")
123         end
124 end
125
126 keepalive_interval.remove      = keepalive_interval.write
127 keepalive_interval.placeholder = "5"
128 keepalive_interval.datatype    = "min(1)"
129
130
131 demand = section:taboption("advanced", Value, "demand",
132         translate("Inactivity timeout"),
133         translate("Close inactive connection after the given amount of seconds, use 0 to persist connection"))
134
135 demand.placeholder = "0"
136 demand.datatype    = "uinteger"