3611a218019ec1ef4aa8a0970f53ab33c2d417ec
[project/luci.git] / libs / core / 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 local proto  = luci.util.class(netmod.proto.generic)
22
23 netmod.IFACE_PATTERNS_VIRTUAL[#netmod.IFACE_PATTERNS_VIRTUAL+1] = "^6to4-%w"
24 netmod.IFACE_PATTERNS_VIRTUAL[#netmod.IFACE_PATTERNS_VIRTUAL+1] = "^6in4-%w"
25
26 function proto.__init__(self, name)
27         self.sid = name
28 end
29
30 function proto.ifname(self)
31         return self:proto() .. "-" .. self.sid
32 end
33
34 function proto.is_floating(self)
35         return true
36 end
37
38 function proto.is_virtual(self)
39         return true
40 end
41
42 function proto.get_interfaces(self)
43         return nil
44 end
45
46 function proto.contains_interface(self, ifname)
47         return (netmod:ifnameof(ifc) == self:ifname())
48 end
49
50
51 netmod.proto["6to4"] = proto
52 netmod.proto["6in4"] = proto