1 -- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
4 local netmod = luci.model.network
7 for _, p in ipairs({"ppp", "pptp", "pppoe", "pppoa", "l2tp"}) do
9 local proto = netmod:register_protocol(p)
11 function proto.get_i18n(self)
13 return luci.i18n.translate("PPP")
14 elseif p == "pptp" then
15 return luci.i18n.translate("PPtP")
16 elseif p == "pppoe" then
17 return luci.i18n.translate("PPPoE")
18 elseif p == "pppoa" then
19 return luci.i18n.translate("PPPoATM")
20 elseif p == "l2tp" then
21 return luci.i18n.translate("L2TP")
25 function proto.ifname(self)
26 return p .. "-" .. self.sid
29 function proto.opkg_package(self)
32 elseif p == "pptp" then
34 elseif p == "pppoe" then
35 return "ppp-mod-pppoe"
36 elseif p == "pppoa" then
37 return "ppp-mod-pppoa"
38 elseif p == "l2tp" then
43 function proto.is_installed(self)
45 return (nixio.fs.glob("/usr/lib/pppd/*/pppoatm.so")() ~= nil)
46 elseif p == "pppoe" then
47 return (nixio.fs.glob("/usr/lib/pppd/*/rp-pppoe.so")() ~= nil)
48 elseif p == "pptp" then
49 return (nixio.fs.glob("/usr/lib/pppd/*/pptp.so")() ~= nil)
50 elseif p == "l2tp" then
51 return nixio.fs.access("/lib/netifd/proto/l2tp.sh")
53 return nixio.fs.access("/lib/netifd/proto/ppp.sh")
57 function proto.is_floating(self)
61 function proto.is_virtual(self)
65 function proto.get_interfaces(self)
66 if self:is_floating() then
69 return netmod.protocol.get_interfaces(self)
73 function proto.contains_interface(self, ifc)
74 if self:is_floating() then
75 return (netmod:ifnameof(ifc) == self:ifname())
77 return netmod.protocol.contains_interface(self, ifc)
81 netmod:register_pattern_virtual("^%s%%-%%w" % p)