Merge pull request #582 from h2o/kazuho/no-tcpip-in-headers

avoid dependency: picotls.h -> TCP/IP
diff --git a/include/picotls.h b/include/picotls.h
index 916c1f5..fef405e 100644
--- a/include/picotls.h
+++ b/include/picotls.h
@@ -34,10 +34,6 @@
 #include <inttypes.h>
 #include <string.h>
 #include <sys/types.h>
-#ifndef _WINDOWS
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#endif
 
 #if __GNUC__ >= 3
 #define PTLS_LIKELY(x) __builtin_expect(!!(x), 1)
@@ -1531,9 +1527,9 @@
      */
     float random_;
     /**
-     * represents peer address; ipv4 addresses are stored using the mapped form (::ffff:192.0.2.1)
+     * represents the peer address using ipv6; ipv4 addresses are stored using the mapped form (::ffff:192.0.2.1)
      */
-    struct in6_addr address;
+    uint8_t address[16];
     struct st_ptls_log_state_t state;
 } ptls_log_conn_state_t;
 
@@ -1954,9 +1950,9 @@
  */
 char *ptls_jsonescape(char *buf, const char *s, size_t len);
 /**
- * builds a v4-mapped address (i.e., ::ffff:192.0.2.1)
+ * Builds a v4-mapped address (i.e., ::ffff:192.0.2.1). The v4 address must be in big-endian.
  */
-void ptls_build_v4_mapped_v6_address(struct in6_addr *v6, const struct in_addr *v4);
+void ptls_build_v4_mapped_v6_address(void *v6, const void *v4);
 
 /**
  * the default get_time callback
diff --git a/lib/picotls.c b/lib/picotls.c
index 87c37ea..36899d4 100644
--- a/lib/picotls.c
+++ b/lib/picotls.c
@@ -6773,10 +6773,11 @@
     return dst;
 }
 
-void ptls_build_v4_mapped_v6_address(struct in6_addr *v6, const struct in_addr *v4)
+void ptls_build_v4_mapped_v6_address(void *v6, const void *v4)
 {
-    *v6 = (struct in6_addr){.s6_addr[10] = 0xff, .s6_addr[11] = 0xff};
-    memcpy(&v6->s6_addr[12], &v4->s_addr, 4);
+    memset(v6, 0, 10);
+    memset((uint8_t *)v6 + 10, 0xff, 2);
+    memcpy((uint8_t *)v6 + 12, v4, 4);
 }
 
 struct st_ptls_log_t ptls_log = {
@@ -6939,7 +6940,8 @@
         const char *sni = get_sni != NULL ? get_sni(get_sni_arg) : NULL;
         for (size_t slot = 0; slot < PTLS_ELEMENTSOF(logctx.conns); ++slot) {
             if (logctx.conns[slot].points != NULL && conn->random_ < logctx.conns[slot].sample_ratio &&
-                is_in_stringlist(logctx.conns[slot].snis, sni) && is_in_addresslist(logctx.conns[slot].addresses, &conn->address)) {
+                is_in_stringlist(logctx.conns[slot].snis, sni) &&
+                is_in_addresslist(logctx.conns[slot].addresses, (struct in6_addr *)&conn->address)) {
                 new_active |= (uint32_t)1 << slot;
             }
         }
@@ -7154,7 +7156,7 @@
 
     *state = (ptls_log_conn_state_t){
         .random_ = (float)r / ((uint64_t)UINT32_MAX + 1), /* [0..1), so that any(r) < sample_ratio where sample_ratio is [0..1] */
-        .address = in6addr_any,
+        .address = {0}, /* inaddr6_any */
     };
 }