You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.7 KiB

  1. From 5a566e3d01273de38490527fbd378c9a2f671b2c Mon Sep 17 00:00:00 2001
  2. From: Thierry FOURNIER <thierry.fournier@ozon.io>
  3. Date: Fri, 23 Dec 2016 17:03:25 +0100
  4. Subject: [PATCH 19/19] BUILD: lua: build failed on FreeBSD.
  5. s6_addr* fields are not available in the userland on
  6. BSD systems in general.
  7. bug reported by David Carlier
  8. needs backport to 1.7.x
  9. (cherry picked from commit de6925eccfaba85f1402c5e5cf700c420792802a)
  10. ---
  11. src/hlua_fcn.c | 18 ++++++++++--------
  12. 1 file changed, 10 insertions(+), 8 deletions(-)
  13. diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c
  14. index 5ac533a..58905d7 100644
  15. --- a/src/hlua_fcn.c
  16. +++ b/src/hlua_fcn.c
  17. @@ -1016,14 +1016,16 @@ int hlua_match_addr(lua_State *L)
  18. return 1;
  19. }
  20. } else {
  21. - if (((addr1->addr.v6.ip.s6_addr32[0] & addr2->addr.v6.mask.s6_addr32[0]) ==
  22. - (addr2->addr.v6.ip.s6_addr32[0] & addr1->addr.v6.mask.s6_addr32[0])) &&
  23. - ((addr1->addr.v6.ip.s6_addr32[1] & addr2->addr.v6.mask.s6_addr32[1]) ==
  24. - (addr2->addr.v6.ip.s6_addr32[1] & addr1->addr.v6.mask.s6_addr32[1])) &&
  25. - ((addr1->addr.v6.ip.s6_addr32[2] & addr2->addr.v6.mask.s6_addr32[2]) ==
  26. - (addr2->addr.v6.ip.s6_addr32[2] & addr1->addr.v6.mask.s6_addr32[2])) &&
  27. - ((addr1->addr.v6.ip.s6_addr32[3] & addr2->addr.v6.mask.s6_addr32[3]) ==
  28. - (addr2->addr.v6.ip.s6_addr32[3] & addr1->addr.v6.mask.s6_addr32[3]))) {
  29. + int i;
  30. +
  31. + for (i = 0; i < 16; i += 4) {
  32. + if ((*(uint32_t *)&addr1->addr.v6.ip.s6_addr[i] &
  33. + *(uint32_t *)&addr2->addr.v6.mask.s6_addr[i]) !=
  34. + (*(uint32_t *)&addr2->addr.v6.ip.s6_addr[i] &
  35. + *(uint32_t *)&addr1->addr.v6.mask.s6_addr[i]))
  36. + break;
  37. + }
  38. + if (i == 16) {
  39. lua_pushboolean(L, 1);
  40. return 1;
  41. }
  42. --
  43. 2.10.2