proto_4x6.lua 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. local netmod = luci.model.network
  5. local _, p
  6. for _, p in ipairs({"dslite", "map", "464xlat"}) do
  7. local proto = netmod:register_protocol(p)
  8. function proto.get_i18n(self)
  9. if p == "dslite" then
  10. return luci.i18n.translate("Dual-Stack Lite (RFC6333)")
  11. elseif p == "map" then
  12. return luci.i18n.translate("MAP / LW4over6")
  13. elseif p == "464xlat" then
  14. return luci.i18n.translate("464XLAT (CLAT)")
  15. end
  16. end
  17. function proto.ifname(self)
  18. return p .. "-" .. self.sid
  19. end
  20. function proto.opkg_package(self)
  21. if p == "dslite" then
  22. return "ds-lite"
  23. elseif p == "map" then
  24. return "map-t"
  25. elseif p == "464xlat" then
  26. return "464xlat"
  27. end
  28. end
  29. function proto.is_installed(self)
  30. return nixio.fs.access("/lib/netifd/proto/" .. p .. ".sh")
  31. end
  32. function proto.is_floating(self)
  33. return true
  34. end
  35. function proto.is_virtual(self)
  36. return true
  37. end
  38. function proto.get_interfaces(self)
  39. return nil
  40. end
  41. function proto.contains_interface(self, ifname)
  42. return (netmod:ifnameof(ifc) == self:ifname())
  43. end
  44. if p == "dslite" then
  45. netmod:register_pattern_virtual("^ds-%w")
  46. elseif p == "map" then
  47. netmod:register_pattern_virtual("^map-%w")
  48. elseif p == "464xlat" then
  49. netmod:register_pattern_virtual("^464-%w")
  50. end
  51. end