protocols: fix various interface patterns
[project/luci.git] / protocols / luci-proto-ncm / luasrc / model / network / proto_ncm.lua
1 --[[
2 LuCI - Network model - NCM protocol extension
3
4 Copyright 2015 Cezary Jackiewicz <cezary.jackiewicz@gmail.com>
5
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
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
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.
17
18 ]]--
19
20 local netmod = luci.model.network
21
22 local proto = netmod:register_protocol("ncm")
23 local interface = luci.model.network.interface
24
25 function proto.get_i18n(self)
26         return luci.i18n.translate("NCM")
27 end
28
29 function proto.opkg_package(self)
30         return "comgt-ncm"
31 end
32
33 function proto.is_installed(self)
34         return nixio.fs.access("/lib/netifd/proto/ncm.sh")
35 end
36
37 function proto.is_floating(self)
38         return true
39 end
40
41 function proto.is_virtual(self)
42         return true
43 end
44
45 function proto.get_interface(self)
46         local _ifname=netmod.protocol.ifname(self)
47         if not _ifname then
48                 _ifname = "wan"
49         end
50         return interface(_ifname, self)
51 end
52
53 function proto.get_interfaces(self)
54         return nil
55 end
56
57 function proto.contains_interface(self, ifc)
58         return (netmod:ifnameof(ifc) == self:ifname())
59 end
60
61 netmod:register_pattern_virtual("^ncm%-%w")