Merge pull request #1818 from dibdot/lxc_fix
[project/luci.git] / protocols / luci-proto-ppp / luasrc / model / cbi / admin_network / proto_pppoe.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 username, password, ac, service
7 local ipv6, defaultroute, metric, peerdns, dns,
8       keepalive_failure, keepalive_interval, demand, mtu
9
10
11 username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
12
13
14 password = section:taboption("general", Value, "password", translate("PAP/CHAP password"))
15 password.password = true
16
17
18 ac = section:taboption("general", Value, "ac",
19         translate("Access Concentrator"),
20         translate("Leave empty to autodetect"))
21
22 ac.placeholder = translate("auto")
23
24
25 service = section:taboption("general", Value, "service",
26         translate("Service Name"),
27         translate("Leave empty to autodetect"))
28
29 service.placeholder = translate("auto")
30
31
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"))
39         ipv6.default = "auto"
40 end
41
42
43 defaultroute = section:taboption("advanced", Flag, "defaultroute",
44         translate("Use default gateway"),
45         translate("If unchecked, no default route is configured"))
46
47 defaultroute.default = defaultroute.enabled
48
49
50 metric = section:taboption("advanced", Value, "metric",
51         translate("Use gateway metric"))
52
53 metric.placeholder = "0"
54 metric.datatype    = "uinteger"
55 metric:depends("defaultroute", defaultroute.enabled)
56
57
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"))
61
62 peerdns.default = peerdns.enabled
63
64
65 dns = section:taboption("advanced", DynamicList, "dns",
66         translate("Use custom DNS servers"))
67
68 dns:depends("peerdns", "")
69 dns.datatype = "ipaddr"
70 dns.cast     = "string"
71
72
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"))
76
77 function keepalive_failure.cfgvalue(self, section)
78         local v = m:get(section, "keepalive")
79         if v and #v > 0 then
80                 return tonumber(v:match("^(%d+)[ ,]+%d+") or v)
81         end
82 end
83
84 keepalive_failure.placeholder = "0"
85 keepalive_failure.datatype    = "uinteger"
86
87
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"))
91
92 function keepalive_interval.cfgvalue(self, section)
93         local v = m:get(section, "keepalive")
94         if v and #v > 0 then
95                 return tonumber(v:match("^%d+[ ,]+(%d+)"))
96         end
97 end
98
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
103         if f > 0 then
104                 m:set(section, "keepalive", "%d %d" %{ f, i })
105         else
106                 m:del(section, "keepalive")
107         end
108 end
109
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)"
115
116
117 demand = section:taboption("advanced", Value, "demand",
118         translate("Inactivity timeout"),
119         translate("Close inactive connection after the given amount of seconds, use 0 to persist connection"))
120
121 demand.placeholder = "0"
122 demand.datatype    = "uinteger"
123
124
125 mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"))
126 mtu.placeholder = "1500"
127 mtu.datatype    = "max(9200)"