2 LuCI - Network model - 3G, PPP, PPtP, PPPoE and PPPoA protocol extension
4 Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
20 local netmod = luci.model.network
23 for _, p in ipairs({"ppp", "pptp", "pppoe", "pppoa", "3g", "l2tp"}) do
25 local proto = netmod:register_protocol(p)
27 function proto.get_i18n(self)
29 return luci.i18n.translate("PPP")
30 elseif p == "pptp" then
31 return luci.i18n.translate("PPtP")
33 return luci.i18n.translate("UMTS/GPRS/EV-DO")
34 elseif p == "pppoe" then
35 return luci.i18n.translate("PPPoE")
36 elseif p == "pppoa" then
37 return luci.i18n.translate("PPPoATM")
38 elseif p == "l2tp" then
39 return luci.i18n.translate("L2TP")
43 function proto.ifname(self)
44 return p .. "-" .. self.sid
47 function proto.opkg_package(self)
52 elseif p == "pptp" then
54 elseif p == "pppoe" then
55 return "ppp-mod-pppoe"
56 elseif p == "pppoa" then
57 return "ppp-mod-pppoa"
58 elseif p == "l2tp" then
63 function proto.is_installed(self)
65 return (nixio.fs.glob("/usr/lib/pppd/*/pppoatm.so")() ~= nil)
66 elseif p == "pppoe" then
67 return (nixio.fs.glob("/usr/lib/pppd/*/rp-pppoe.so")() ~= nil)
68 elseif p == "pptp" then
69 return (nixio.fs.glob("/usr/lib/pppd/*/pptp.so")() ~= nil)
71 return nixio.fs.access("/lib/netifd/proto/3g.sh")
72 elseif p == "l2tp" then
73 return nixio.fs.access("/lib/netifd/proto/l2tp.sh")
75 return nixio.fs.access("/lib/netifd/proto/ppp.sh")
79 function proto.is_floating(self)
83 function proto.is_virtual(self)
87 function proto.get_interfaces(self)
88 if self:is_floating() then
91 return netmod.protocol.get_interfaces(self)
95 function proto.contains_interface(self, ifc)
96 if self:is_floating() then
97 return (netmod:ifnameof(ifc) == self:ifname())
99 return netmod.protocol.contains_interface(self, ifc)
103 netmod:register_pattern_virtual("^%s-%%w" % p)