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
39 ipv6 = section:taboption("advanced", ListValue, "ipv6",
40 translate("Obtain IPv6-Address"),
41 translate("Enable IPv6 negotiation on the PPP link"))
42 ipv6:value("auto", translate("Automatic"))
43 ipv6:value("0", translate("Disabled"))
44 ipv6:value("1", translate("Manual"))
49 defaultroute = section:taboption("advanced", Flag, "defaultroute",
50 translate("Use default gateway"),
51 translate("If unchecked, no default route is configured"))
53 defaultroute.default = defaultroute.enabled
56 metric = section:taboption("advanced", Value, "metric",
57 translate("Use gateway metric"))
59 metric.placeholder = "0"
60 metric.datatype = "uinteger"
61 metric:depends("defaultroute", defaultroute.enabled)
64 peerdns = section:taboption("advanced", Flag, "peerdns",
65 translate("Use DNS servers advertised by peer"),
66 translate("If unchecked, the advertised DNS server addresses are ignored"))
68 peerdns.default = peerdns.enabled
71 dns = section:taboption("advanced", DynamicList, "dns",
72 translate("Use custom DNS servers"))
74 dns:depends("peerdns", "")
75 dns.datatype = "ipaddr"
79 keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure",
80 translate("LCP echo failure threshold"),
81 translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures"))
83 function keepalive_failure.cfgvalue(self, section)
84 local v = m:get(section, "keepalive")
86 return tonumber(v:match("^(%d+)[ ,]+%d+") or v)
90 keepalive_failure.placeholder = "0"
91 keepalive_failure.datatype = "uinteger"
94 keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval",
95 translate("LCP echo interval"),
96 translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold"))
98 function keepalive_interval.cfgvalue(self, section)
99 local v = m:get(section, "keepalive")
101 return tonumber(v:match("^%d+[ ,]+(%d+)"))
105 function keepalive_interval.write(self, section, value)
106 local f = tonumber(keepalive_failure:formvalue(section)) or 0
107 local i = tonumber(value) or 5
108 if i < 1 then i = 1 end
110 m:set(section, "keepalive", "%d %d" %{ f, i })
112 m:del(section, "keepalive")
116 keepalive_interval.remove = keepalive_interval.write
117 keepalive_failure.write = keepalive_interval.write
118 keepalive_failure.remove = keepalive_interval.write
119 keepalive_interval.placeholder = "5"
120 keepalive_interval.datatype = "min(1)"
123 demand = section:taboption("advanced", Value, "demand",
124 translate("Inactivity timeout"),
125 translate("Close inactive connection after the given amount of seconds, use 0 to persist connection"))
127 demand.placeholder = "0"
128 demand.datatype = "uinteger"
131 mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"))
132 mtu.placeholder = "1500"
133 mtu.datatype = "max(9200)"