瀏覽代碼

r14651@catbus: nickm | 2007-08-17 21:37:03 -0400
Another attempt to confirm to msvc for bug 482.


svn:r11162

Nick Mathewson 17 年之前
父節點
當前提交
a237f25f9a
共有 1 個文件被更改,包括 10 次插入9 次删除
  1. 10 9
      src/common/compat.h

+ 10 - 9
src/common/compat.h

@@ -338,6 +338,15 @@ static INLINE const struct in_addr *IN4_ADDRESS(const tor_addr_t *a);
 static INLINE const struct in6_addr *IN6_ADDRESS(const tor_addr_t *a);
 static INLINE uint16_t IN_PORT(const tor_addr_t *a);
 
+static INLINE const struct in6_addr *
+IN6_ADDRESS(const tor_addr_t *a)
+{
+  return &a->sa6.sin6_addr;
+}
+
+#define IN6_ADDRESS16(x) S6_ADDR16(*IN6_ADDRESS(x))
+#define IN6_ADDRESS32(x) S6_ADDR32(*IN6_ADDRESS(x))
+
 static INLINE uint32_t
 IPV4IP(const tor_addr_t *a)
 {
@@ -351,7 +360,7 @@ static INLINE uint32_t IPV4IPh(const tor_addr_t *a)
 static INLINE uint32_t
 IPV4MAPh(const tor_addr_t *a)
 {
-  return ntohl(a->sa6.sin6_addr.s6_addr32[3]);
+  return ntohl(IN6_ADDRESS32(a)[3]);
 }
 static INLINE uint16_t
 IN_FAMILY(const tor_addr_t *a)
@@ -363,11 +372,6 @@ IN4_ADDRESS(const tor_addr_t *a)
 {
   return &a->sa.sin_addr;
 }
-static INLINE const struct in6_addr *
-IN6_ADDRESS(const tor_addr_t *a)
-{
-  return &a->sa6.sin6_addr;
-}
 static INLINE uint16_t
 IN_PORT(const tor_addr_t *a)
 {
@@ -377,9 +381,6 @@ IN_PORT(const tor_addr_t *a)
     return a->sa6.sin6_port;
 }
 
-#define IN6_ADDRESS16(x) S6_ADDR16(*IN6_ADDRESS(x))
-#define IN6_ADDRESS32(x) S6_ADDR32(*IN6_ADDRESS(x))
-
 #define INET_NTOA_BUF_LEN 16 /* 255.255.255.255 */
 #define TOR_ADDR_BUF_LEN 46 /* ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255 */