diff --git a/configure.ac b/configure.ac
index dff1c40517dc8d20caa5b4c77925f3125f6287af..ee3c8b8d9ba691625329abec49abff9676e8ed6f 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 e660a8967966adbf19e2fcc5e27d98428c09cccb..db132e59d77c1aba039002f1913c680ae5c3b327 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 348301084413f3d3d8683f75e50249cd0528d111..88f6a03336b755ae9cb2728e1e9ff52c5ae8c3d6 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>