1 -- Copyright 2011 Jo-Philipp Wich <xm@subsignal.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", "3g", "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")
17 return luci.i18n.translate("UMTS/GPRS/EV-DO")
18 elseif p == "pppoe" then
19 return luci.i18n.translate("PPPoE")
20 elseif p == "pppoa" then
21 return luci.i18n.translate("PPPoATM")
22 elseif p == "l2tp" then
23 return luci.i18n.translate("L2TP")
27 function proto.ifname(self)
28 return p .. "-" .. self.sid
31 function proto.opkg_package(self)
36 elseif p == "pptp" then
38 elseif p == "pppoe" then
39 return "ppp-mod-pppoe"
40 elseif p == "pppoa" then
41 return "ppp-mod-pppoa"
42 elseif p == "l2tp" then
47 function proto.is_installed(self)
49 return (nixio.fs.glob("/usr/lib/pppd/*/pppoatm.so")() ~= nil)
50 elseif p == "pppoe" then
51 return (nixio.fs.glob("/usr/lib/pppd/*/rp-pppoe.so")() ~= nil)
52 elseif p == "pptp" then
53 return (nixio.fs.glob("/usr/lib/pppd/*/pptp.so")() ~= nil)
55 return nixio.fs.access("/lib/netifd/proto/3g.sh")
56 elseif p == "l2tp" then
57 return nixio.fs.access("/lib/netifd/proto/l2tp.sh")
59 return nixio.fs.access("/lib/netifd/proto/ppp.sh")
63 function proto.is_floating(self)
67 function proto.is_virtual(self)
71 function proto.get_interfaces(self)
72 if self:is_floating() then
75 return netmod.protocol.get_interfaces(self)
79 function proto.contains_interface(self, ifc)
80 if self:is_floating() then
81 return (netmod:ifnameof(ifc) == self:ifname())
83 return netmod.protocol.contains_interface(self, ifc)
87 netmod:register_pattern_virtual("^%s-%%w" % p)