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", "3g", "l2tp", "pppossh"}) 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")
24 elseif p == "pppossh" then
25 return luci.i18n.translate("PPPoSSH")
29 function proto.ifname(self)
30 return p .. "-" .. self.sid
33 function proto.opkg_package(self)
38 elseif p == "pptp" then
40 elseif p == "pppoe" then
41 return "ppp-mod-pppoe"
42 elseif p == "pppoa" then
43 return "ppp-mod-pppoa"
44 elseif p == "l2tp" then
46 elseif p == "pppossh" then
51 function proto.is_installed(self)
53 return (nixio.fs.glob("/usr/lib/pppd/*/pppoatm.so")() ~= nil)
54 elseif p == "pppoe" then
55 return (nixio.fs.glob("/usr/lib/pppd/*/rp-pppoe.so")() ~= nil)
56 elseif p == "pptp" then
57 return (nixio.fs.glob("/usr/lib/pppd/*/pptp.so")() ~= nil)
59 return nixio.fs.access("/lib/netifd/proto/3g.sh")
60 elseif p == "l2tp" then
61 return nixio.fs.access("/lib/netifd/proto/l2tp.sh")
62 elseif p == "pppossh" then
63 return nixio.fs.access("/lib/netifd/proto/pppossh.sh")
65 return nixio.fs.access("/lib/netifd/proto/ppp.sh")
69 function proto.is_floating(self)
73 function proto.is_virtual(self)
77 function proto.get_interfaces(self)
78 if self:is_floating() then
81 return netmod.protocol.get_interfaces(self)
85 function proto.contains_interface(self, ifc)
86 if self:is_floating() then
87 return (netmod:ifnameof(ifc) == self:ifname())
89 return netmod.protocol.contains_interface(self, ifc)
93 netmod:register_pattern_virtual("^%s-%%w" % p)