proto_6x4.lua 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. -- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local netmod = luci.model.network
  4. local _, p
  5. for _, p in ipairs({"6in4", "6to4", "6rd"}) do
  6. local proto = netmod:register_protocol(p)
  7. function proto.get_i18n(self)
  8. if p == "6in4" then
  9. return luci.i18n.translate("IPv6-in-IPv4 (RFC4213)")
  10. elseif p == "6to4" then
  11. return luci.i18n.translate("IPv6-over-IPv4 (6to4)")
  12. elseif p == "6rd" then
  13. return luci.i18n.translate("IPv6-over-IPv4 (6rd)")
  14. end
  15. end
  16. function proto.ifname(self)
  17. return p .. "-" .. self.sid
  18. end
  19. function proto.opkg_package(self)
  20. return p
  21. end
  22. function proto.is_installed(self)
  23. return nixio.fs.access("/lib/netifd/proto/" .. p .. ".sh")
  24. end
  25. function proto.is_floating(self)
  26. return true
  27. end
  28. function proto.is_virtual(self)
  29. return true
  30. end
  31. function proto.get_interfaces(self)
  32. return nil
  33. end
  34. function proto.contains_interface(self, ifname)
  35. return (netmod:ifnameof(ifc) == self:ifname())
  36. end
  37. netmod:register_pattern_virtual("^%s-%%w" % p)
  38. end