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 username, password, ac, service
7 local ipv6, defaultroute, metric, peerdns, dns,
8 keepalive_failure, keepalive_interval, demand, mtu
11 username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
14 password = section:taboption("general", Value, "password", translate("PAP/CHAP password"))
15 password.password = true
18 ac = section:taboption("general", Value, "ac",
19 translate("Access Concentrator"),
20 translate("Leave empty to autodetect"))
22 ac.placeholder = translate("auto")
25 service = section:taboption("general", Value, "service",
26 translate("Service Name"),
27 translate("Leave empty to autodetect"))
29 service.placeholder = translate("auto")
32 if luci.model.network:has_ipv6() then
33 ipv6 = section:taboption("advanced", ListValue, "ipv6",
34 translate("Obtain IPv6-Address"),
35 translate("Enable IPv6 negotiation on the PPP link"))
36 ipv6:value("auto", translate("Automatic"))
37 ipv6:value("0", translate("Disabled"))
38 ipv6:value("1", translate("Manual"))
43 defaultroute = section:taboption("advanced", Flag, "defaultroute",
44 translate("Use default gateway"),
45 translate("If unchecked, no default route is configured"))
47 defaultroute.default = defaultroute.enabled
50 metric = section:taboption("advanced", Value, "metric",
51 translate("Use gateway metric"))
53 metric.placeholder = "0"
54 metric.datatype = "uinteger"
55 metric:depends("defaultroute", defaultroute.enabled)
58 peerdns = section:taboption("advanced", Flag, "peerdns",
59 translate("Use DNS servers advertised by peer"),
60 translate("If unchecked, the advertised DNS server addresses are ignored"))
62 peerdns.default = peerdns.enabled
65 dns = section:taboption("advanced", DynamicList, "dns",
66 translate("Use custom DNS servers"))
68 dns:depends("peerdns", "")
69 dns.datatype = "ipaddr"
73 keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure",
74 translate("LCP echo failure threshold"),
75 translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures"))
77 function keepalive_failure.cfgvalue(self, section)
78 local v = m:get(section, "keepalive")
80 return tonumber(v:match("^(%d+)[ ,]+%d+") or v)
84 keepalive_failure.placeholder = "0"
85 keepalive_failure.datatype = "uinteger"
88 keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval",
89 translate("LCP echo interval"),
90 translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold"))
92 function keepalive_interval.cfgvalue(self, section)
93 local v = m:get(section, "keepalive")
95 return tonumber(v:match("^%d+[ ,]+(%d+)"))
99 function keepalive_interval.write(self, section, value)
100 local f = tonumber(keepalive_failure:formvalue(section)) or 0
101 local i = tonumber(value) or 5
102 if i < 1 then i = 1 end
104 m:set(section, "keepalive", "%d %d" %{ f, i })
106 m:set(section, "keepalive", "0")
110 keepalive_interval.remove = keepalive_interval.write
111 keepalive_failure.write = keepalive_interval.write
112 keepalive_failure.remove = keepalive_interval.write
113 keepalive_interval.placeholder = "5"
114 keepalive_interval.datatype = "min(1)"
117 host_uniq = section:taboption("advanced", Value, "host_uniq",
118 translate("Host-Uniq tag content"),
119 translate("Raw hex-encoded bytes. Leave empty unless your ISP require this"))
121 host_uniq.placeholder = translate("auto")
122 host_uniq.datatype = "hexstring"
125 demand = section:taboption("advanced", Value, "demand",
126 translate("Inactivity timeout"),
127 translate("Close inactive connection after the given amount of seconds, use 0 to persist connection"))
129 demand.placeholder = "0"
130 demand.datatype = "uinteger"
133 mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"))
134 mtu.placeholder = "1500"
135 mtu.datatype = "max(9200)"