Merge pull request #1735 from sumpfralle/olsr-jsoninfo-parser-handle-empty-result
[project/luci.git] / protocols / luci-proto-ipv6 / luasrc / model / network / proto_6x4.lua
1 -- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local netmod = luci.model.network
5
6 local _, p
7 for _, p in ipairs({"6in4", "6to4", "6rd"}) do
8
9 local proto = netmod:register_protocol(p)
10
11 function proto.get_i18n(self)
12 if p == "6in4" then
13 return luci.i18n.translate("IPv6-in-IPv4 (RFC4213)")
14 elseif p == "6to4" then
15 return luci.i18n.translate("IPv6-over-IPv4 (6to4)")
16 elseif p == "6rd" then
17 return luci.i18n.translate("IPv6-over-IPv4 (6rd)")
18 end
19 end
20
21 function proto.ifname(self)
22 return p .. "-" .. self.sid
23 end
24
25 function proto.opkg_package(self)
26 return p
27 end
28
29 function proto.is_installed(self)
30 return nixio.fs.access("/lib/netifd/proto/" .. p .. ".sh")
31 end
32
33 function proto.is_floating(self)
34 return true
35 end
36
37 function proto.is_virtual(self)
38 return true
39 end
40
41 function proto.get_interfaces(self)
42 return nil
43 end
44
45 function proto.contains_interface(self, ifc)
46 return (netmod:ifnameof(ifc) == self:ifname())
47 end
48
49 netmod:register_pattern_virtual("^%s%%-%%w" % p)
50 end