1
0

proto_4x6.lua 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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, ifc)
  42. return (netmod:ifnameof(ifc) == self:ifname())
  43. end
  44. end
  45. netmod:register_pattern_virtual("^464%-%w")
  46. netmod:register_pattern_virtual("^ds%-%w")
  47. netmod:register_pattern_virtual("^map%-%w")
  48. netmod:register_error_code("AFTR_DNS_FAIL", luci.i18n.translate("Unable to resolve AFTR host name"))
  49. netmod:register_error_code("INVALID_MAP_RULE", luci.i18n.translate("MAP rule is invalid"))
  50. netmod:register_error_code("NO_MATCHING_PD", luci.i18n.translate("No matching prefix delegation"))
  51. netmod:register_error_code("UNSUPPORTED_TYPE", luci.i18n.translate("Unsupported MAP type"))