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