b800b0b540ce6c3138c64545bf99bd18be783246
[project/luci.git] / protocols / luci-proto-ipv6 / luasrc / model / network / proto_6x4.lua
1 --[[
2 LuCI - Network model - 6to4, 6in4 & 6rd protocol extensions
3
4 Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
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 _, p
23 for _, p in ipairs({"6in4", "6to4", "6rd"}) do
24
25 local proto = netmod:register_protocol(p)
26
27 function proto.get_i18n(self)
28 if p == "6in4" then
29 return luci.i18n.translate("IPv6-in-IPv4 (RFC4213)")
30 elseif p == "6to4" then
31 return luci.i18n.translate("IPv6-over-IPv4 (6to4)")
32 elseif p == "6rd" then
33 return luci.i18n.translate("IPv6-over-IPv4 (6rd)")
34 end
35 end
36
37 function proto.ifname(self)
38 return p .. "-" .. self.sid
39 end
40
41 function proto.opkg_package(self)
42 return p
43 end
44
45 function proto.is_installed(self)
46 return nixio.fs.access("/lib/netifd/proto/" .. p .. ".sh")
47 end
48
49 function proto.is_floating(self)
50 return true
51 end
52
53 function proto.is_virtual(self)
54 return true
55 end
56
57 function proto.get_interfaces(self)
58 return nil
59 end
60
61 function proto.contains_interface(self, ifname)
62 return (netmod:ifnameof(ifc) == self:ifname())
63 end
64
65 netmod:register_pattern_virtual("^%s-%%w" % p)
66 end