protocols: vpnc: Add vpnc as a network protocol
[project/luci.git] / protocols / luci-proto-vpnc / luasrc / model / network / proto_vpnc.lua
1 -- Copyright 2015 Daniel Dickinson <openwrt@daniel.thecshore.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("vpnc")
7
8 function proto.get_i18n(self)
9         return luci.i18n.translate("VPNC (CISCO 3000 (and others) VPN)")
10 end
11
12 function proto.ifname(self)
13         return "vpn-" .. self.sid
14 end
15
16 function proto.get_interface(self)
17         return interface(self:ifname(), self)
18 end
19
20 function proto.opkg_package(self)
21         return "vpnc"
22 end
23
24 function proto.is_installed(self)
25         return nixio.fs.access("/lib/netifd/proto/vpnc.sh")
26 end
27
28 function proto.is_floating(self)
29         return true
30 end
31
32 function proto.is_virtual(self)
33         return true
34 end
35
36 function proto.get_interfaces(self)
37         return nil
38 end
39
40 function proto.contains_interface(self, ifc)
41          return (netmod:ifnameof(ifc) == self:ifname())
42
43 end
44
45 netmod:register_pattern_virtual("^vpn-%w")
46