IPv6 updates
[project/luci.git] / protocols / luci-proto-ipv6 / luasrc / model / network / proto_4x6.lua
1 -- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
2 -- Copyright 2013 Steven Barth <steven@midlink.org>
3 -- Licensed to the public under the Apache License 2.0.
4
5 local netmod = luci.model.network
6
7 local _, p
8 for _, p in ipairs({"dslite", "map", "464xlat"}) do
9
10         local proto = netmod:register_protocol(p)
11
12         function proto.get_i18n(self)
13                 if p == "dslite" then
14                         return luci.i18n.translate("Dual-Stack Lite (RFC6333)")
15                 elseif p == "map" then
16                         return luci.i18n.translate("MAP / LW4over6")
17                 elseif p == "464xlat" then
18                         return luci.i18n.translate("464XLAT (CLAT)")
19                 end
20         end
21
22         function proto.ifname(self)
23                 return p .. "-" .. self.sid
24         end
25
26         function proto.opkg_package(self)
27                 if p == "dslite" then
28                         return "ds-lite"
29                 elseif p == "map" then
30                         return "map-t"
31                 elseif p == "464xlat" then
32                         return "464xlat"
33                 end
34         end
35
36         function proto.is_installed(self)
37                 return nixio.fs.access("/lib/netifd/proto/" .. p .. ".sh")
38         end
39
40         function proto.is_floating(self)
41                 return true
42         end
43
44         function proto.is_virtual(self)
45                 return true
46         end
47
48         function proto.get_interfaces(self)
49                 return nil
50         end
51
52         function proto.contains_interface(self, ifname)
53                 return (netmod:ifnameof(ifc) == self:ifname())
54         end
55
56         if p == "dslite" then
57                 netmod:register_pattern_virtual("^ds-%w")
58         elseif p == "map" then
59                 netmod:register_pattern_virtual("^map-%w")
60         elseif p == "464xlat" then
61                 netmod:register_pattern_virtual("^464-%w")
62         end
63 end