Added luci configuration for openconnect protocol
[project/luci.git] / protocols / openconnect / luasrc / model / network / proto_openconnect.lua
1 --[[
2 LuCI - Network model - openconnect protocol extension
3
4 Copyright 2012 David Woodhouse
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 local interface = luci.model.network.interface
22 local proto = netmod:register_protocol("openconnect")
23
24 function proto.get_i18n(self)
25         return luci.i18n.translate("OpenConnect (CISCO AnyConnect)")
26 end
27
28 function proto.ifname(self)
29         return "vpn-" .. self.sid
30 end
31
32 function proto.get_interface(self)
33         return interface(self:ifname(), self)
34 end
35
36 function proto.opkg_package(self)
37         return "openconnect"
38 end
39
40 function proto.is_installed(self)
41         return nixio.fs.access("/lib/netifd/proto/openconnect.sh")
42 end
43
44 function proto.is_floating(self)
45         return true
46 end
47
48 function proto.is_virtual(self)
49         return true
50 end
51
52 function proto.get_interfaces(self)
53         return nil
54 end
55
56 function proto.contains_interface(self, ifc)
57          return (netmod:ifnameof(ifc) == self:ifname())
58
59 end
60
61 netmod:register_pattern_virtual("^vpn-%w")