proto_4x6.lua 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 == "ipip6" then
  12. return luci.i18n.translate("IPv4 over IPv6 (RFC2473-IPIPv6)")
  13. elseif p == "map" then
  14. return luci.i18n.translate("MAP / LW4over6")
  15. elseif p == "464xlat" then
  16. return luci.i18n.translate("464XLAT (CLAT)")
  17. end
  18. end
  19. function proto.ifname(self)
  20. return p .. "-" .. self.sid
  21. end
  22. function proto.opkg_package(self)
  23. if p == "dslite" or p == "ipip6" then
  24. return "ds-lite"
  25. elseif p == "map" then
  26. return "map-t"
  27. elseif p == "464xlat" then
  28. return "464xlat"
  29. end
  30. end
  31. function proto.is_installed(self)
  32. return nixio.fs.access("/lib/netifd/proto/" .. p .. ".sh")
  33. end
  34. function proto.is_floating(self)
  35. return true
  36. end
  37. function proto.is_virtual(self)
  38. return true
  39. end
  40. function proto.get_interfaces(self)
  41. return nil
  42. end
  43. function proto.contains_interface(self, ifc)
  44. return (netmod:ifnameof(ifc) == self:ifname())
  45. end
  46. end
  47. netmod:register_pattern_virtual("^464%-%w")
  48. netmod:register_pattern_virtual("^ds%-%w")
  49. netmod:register_pattern_virtual("^ipip6%-%w")
  50. netmod:register_pattern_virtual("^map%-%w")
  51. netmod:register_error_code("AFTR_DNS_FAIL", luci.i18n.translate("Unable to resolve AFTR host name"))
  52. netmod:register_error_code("INVALID_MAP_RULE", luci.i18n.translate("MAP rule is invalid"))
  53. netmod:register_error_code("NO_MATCHING_PD", luci.i18n.translate("No matching prefix delegation"))
  54. netmod:register_error_code("UNSUPPORTED_TYPE", luci.i18n.translate("Unsupported MAP type"))