b9fbf64ec8bafe051ce91d1340f3162f8523c7f2
[project/luci.git] / protocols / 6x4 / luasrc / model / network / proto_6x4.lua
1 --[[
2 LuCI - Network model - 6to4 & 6in4 protocol extension
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"}) 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")
32 end
33 end
34
35 function proto.ifname(self)
36 return p .. "-" .. self.sid
37 end
38
39 function proto.opkg_package(self)
40 return p
41 end
42
43 function proto.is_installed(self)
44 return nixio.fs.access("/lib/network/" .. p .. ".sh") or
45 nixio.fs.access("/lib/netifd/proto/" .. p .. ".sh")
46 end
47
48 function proto.is_floating(self)
49 return true
50 end
51
52 function proto.is_virtual(self)
53 return true
54 end
55
56 function proto.get_interfaces(self)
57 return nil
58 end
59
60 function proto.contains_interface(self, ifname)
61 return (netmod:ifnameof(ifc) == self:ifname())
62 end
63
64 netmod:register_pattern_virtual("^%s-%%w" % p)
65 end