Merge pull request #798 from thoto/feature_lstat
[project/luci.git] / protocols / luci-proto-qmi / luasrc / model / network / proto_qmi.lua
1 -- Copyright 2016 David Thornley <david.thornley@touchstargroup.com>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local netmod = luci.model.network
5 local interface = luci.model.network.interface
6 local proto = netmod:register_protocol("qmi")
7
8 function proto.get_i18n(self)
9         return luci.i18n.translate("QMI Cellular")
10 end
11
12 function proto.ifname(self)
13         local base = netmod._M.protocol
14         local ifname = base.ifname(self) -- call base class "protocol.ifname(self)"
15
16                 -- Note: ifname might be nil if the adapter could not be determined through ubus (default name to qmi-wan in this case)
17         if ifname == nil then
18                 ifname = "qmi-" .. self.sid
19         end
20         return ifname
21 end
22
23 function proto.get_interface(self)
24         return interface(self:ifname(), self)
25 end
26
27 function proto.opkg_package(self)
28         return "uqmi"
29 end
30
31 function proto.is_installed(self)
32         return nixio.fs.access("/lib/netifd/proto/qmi.sh")
33 end
34
35 function proto.is_floating(self)
36         return true
37 end
38
39 function proto.is_virtual(self)
40         return true
41 end
42
43 function proto.get_interfaces(self)
44         return nil
45 end
46
47 function proto.contains_interface(self, ifc)
48          return (netmod:ifnameof(ifc) == self:ifname())
49 end
50
51 netmod:register_pattern_virtual("^qmi-%w")