From 6b23763ad7e4ba8b88a1944fb50a585b283699b4 Mon Sep 17 00:00:00 2001
From: Ken-ichi ICHINO <ichino@coreappli.jp>
Date: Thu, 28 Feb 2019 16:51:57 +0900
Subject: [PATCH] modify for FreeBSD. For using in6_addr structure in IPv6
 protocl stack  KAME project add netinet/in.h header in util.cc . And for
 privent for conflict with bswap64 which defined in OS header, add #ifndef.

---
 configure.ac       | 1 +
 examples/crypto.cc | 2 ++
 examples/util.cc   | 3 +++
 3 files changed, 6 insertions(+)

diff --git a/configure.ac b/configure.ac
index dff1c405..ee3c8b8d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -145,6 +145,7 @@ LIBS=$save_LIBS
 # Checks for header files.
 AC_CHECK_HEADERS([ \
   arpa/inet.h \
+  netinet/in.h \
   stddef.h \
   stdint.h \
   stdlib.h \
diff --git a/examples/crypto.cc b/examples/crypto.cc
index e660a896..db132e59 100644
--- a/examples/crypto.cc
+++ b/examples/crypto.cc
@@ -36,12 +36,14 @@ namespace ngtcp2 {
 
 namespace crypto {
 
+#ifndef bswap64
 #ifdef WORDS_BIGENDIAN
 #  define bswap64(N) (N)
 #else /* !WORDS_BIGENDIAN */
 #  define bswap64(N)                                                           \
     ((uint64_t)(ntohl((uint32_t)(N))) << 32 | ntohl((uint32_t)((N) >> 32)))
 #endif /* !WORDS_BIGENDIAN */
+#endif
 
 int derive_initial_secret(uint8_t *dest, size_t destlen,
                           const ngtcp2_cid *secret, const uint8_t *salt,
diff --git a/examples/util.cc b/examples/util.cc
index 34830108..88f6a033 100644
--- a/examples/util.cc
+++ b/examples/util.cc
@@ -28,6 +28,9 @@
 #ifdef HAVE_ARPA_INET_H
 #  include <arpa/inet.h>
 #endif // HAVE_ARPA_INET_H
+#ifdef HAVE_NETINET_IN_H
+#  include <netinet/in.h>
+#endif
 #include <netdb.h>
 
 #include <cassert>
-- 
GitLab