root/luci/trunk/protocols/ppp/luasrc/model/cbi/admin_network/proto_pppoa.lua @ 8869

Revision 8869, 4.0 KB (checked in by jow, 11 months ago)

protocols/ppp: add mtu options to all ppp protocols, add lcp options to pptp

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