1 -- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
4 local map, section, net = ...
6 local encaps, atmdev, vci, vpi, username, password
7 local ipv6, defaultroute, metric, peerdns, dns,
8 keepalive_failure, keepalive_interval, demand, mtu
11 encaps = section:taboption("general", ListValue, "encaps", translate("PPPoA Encapsulation"))
12 encaps:value("vc", "VC-Mux")
13 encaps:value("llc", "LLC")
16 atmdev = section:taboption("general", Value, "atmdev", translate("ATM device number"))
18 atmdev.datatype = "uinteger"
21 vci = section:taboption("general", Value, "vci", translate("ATM Virtual Channel Identifier (VCI)"))
23 vci.datatype = "uinteger"
26 vpi = section:taboption("general", Value, "vpi", translate("ATM Virtual Path Identifier (VPI)"))
28 vpi.datatype = "uinteger"
31 username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
34 password = section:taboption("general", Value, "password", translate("PAP/CHAP password"))
35 password.password = true
38 if luci.model.network:has_ipv6() then
40 ipv6 = section:taboption("advanced", Flag, "ipv6",
41 translate("Enable IPv6 negotiation on the PPP link"))
43 ipv6.default = ipv6.disabled
48 defaultroute = section:taboption("advanced", Flag, "defaultroute",
49 translate("Use default gateway"),
50 translate("If unchecked, no default route is configured"))
52 defaultroute.default = defaultroute.enabled
55 metric = section:taboption("advanced", Value, "metric",
56 translate("Use gateway metric"))
58 metric.placeholder = "0"
59 metric.datatype = "uinteger"
60 metric:depends("defaultroute", defaultroute.enabled)
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"))
67 peerdns.default = peerdns.enabled
70 dns = section:taboption("advanced", DynamicList, "dns",
71 translate("Use custom DNS servers"))
73 dns:depends("peerdns", "")
74 dns.datatype = "ipaddr"
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"))
82 function keepalive_failure.cfgvalue(self, section)
83 local v = m:get(section, "keepalive")
85 return tonumber(v:match("^(%d+)[ ,]+%d+") or v)
89 keepalive_failure.placeholder = "0"
90 keepalive_failure.datatype = "uinteger"
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"))
97 function keepalive_interval.cfgvalue(self, section)
98 local v = m:get(section, "keepalive")
100 return tonumber(v:match("^%d+[ ,]+(%d+)"))
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
109 m:set(section, "keepalive", "%d %d" %{ f, i })
111 m:del(section, "keepalive")
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)"
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"))
126 demand.placeholder = "0"
127 demand.datatype = "uinteger"
130 mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"))
131 mtu.placeholder = "1500"
132 mtu.datatype = "max(9200)"