diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/common/compat.h | 8 | ||||
-rw-r--r-- | src/common/util.c | 42 | ||||
-rw-r--r-- | src/or/test.c | 8 |
4 files changed, 32 insertions, 30 deletions
@@ -1,4 +1,8 @@ Changes in version 0.2.0.4-alpha - 2007-??-?? + o Major bugfixes (compilation): + - Fix win32 compilation: apparently IN_ADDR and IN6_ADDR are already + defined there. + o Minor features (performance): - Be even more aggressive about releasing RAM from small empty buffers. Thanks to our free-list code, this shouldn't be too diff --git a/src/common/compat.h b/src/common/compat.h index 9b23467e73..1923e3504b 100644 --- a/src/common/compat.h +++ b/src/common/compat.h @@ -319,8 +319,8 @@ static INLINE uint32_t IPV4IP(const tor_addr_t *a); static INLINE uint32_t IPV4IPh(const tor_addr_t *a); static INLINE uint32_t IPV4MAPh(const tor_addr_t *a); static INLINE uint16_t IN_FAMILY(const tor_addr_t *a); -static INLINE const struct in_addr *IN4_ADDR(const tor_addr_t *a); -static INLINE const struct in6_addr *IN6_ADDR(const tor_addr_t *a); +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 uint32_t @@ -344,12 +344,12 @@ IN_FAMILY(const tor_addr_t *a) return a->sa.sin_family; } static INLINE const struct in_addr * -IN4_ADDR(const tor_addr_t *a) +IN4_ADDRESS(const tor_addr_t *a) { return &a->sa.sin_addr; } static INLINE const struct in6_addr * -IN6_ADDR(const tor_addr_t *a) +IN6_ADDRESS(const tor_addr_t *a) { return &a->sa6.sin6_addr; } diff --git a/src/common/util.c b/src/common/util.c index 1be630e1d9..1e25e294a2 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -1872,15 +1872,15 @@ tor_addr_is_internal(const tor_addr_t *addr, int for_listening) } else if (v_family == AF_INET6) { if (tor_addr_is_v4(addr)) { /* v4-mapped */ v_family = AF_INET; - iph4 = ntohl(IN6_ADDR(addr)->s6_addr32[3]); + iph4 = ntohl(IN6_ADDRESS(addr)->s6_addr32[3]); } } if (v_family == AF_INET6) { - iph6[0] = ntohl(IN6_ADDR(addr)->s6_addr32[0]); - iph6[1] = ntohl(IN6_ADDR(addr)->s6_addr32[1]); - iph6[2] = ntohl(IN6_ADDR(addr)->s6_addr32[2]); - iph6[3] = ntohl(IN6_ADDR(addr)->s6_addr32[3]); + iph6[0] = ntohl(IN6_ADDRESS(addr)->s6_addr32[0]); + iph6[1] = ntohl(IN6_ADDRESS(addr)->s6_addr32[1]); + iph6[2] = ntohl(IN6_ADDRESS(addr)->s6_addr32[2]); + iph6[3] = ntohl(IN6_ADDRESS(addr)->s6_addr32[3]); if (for_listening && !iph6[0] && !iph6[1] && !iph6[2] && !iph6[3]) /* :: */ return 0; @@ -2278,14 +2278,14 @@ tor_addr_parse_mask_ports(const char *s, tor_addr_t *addr_out, #ifdef ALWAYS_V6_MAP if (v_family == AF_INET) { v_family = AF_INET6; - IN_ADDR6(addr_out).s6_addr32[3] = IN6_ADDR(addr_out).s_addr; - memset(&IN6_ADDR(addr_out), 0, 10); + IN_ADDR6(addr_out).s6_addr32[3] = IN6_ADDRESS(addr_out).s_addr; + memset(&IN6_ADDRESS(addr_out), 0, 10); IN_ADDR6(addr_out).s6_addr16[5] = 0xffff; } #else if (v_family == AF_INET6 && v4map) { v_family = AF_INET; - IN4_ADDR(addr_out).s_addr = IN6_ADDR(addr_out).s6_addr32[3]; + IN4_ADDRESS((addr_out).s_addr = IN6_ADDRESS(addr_out).s6_addr32[3]; } #endif */ @@ -2392,9 +2392,9 @@ tor_addr_is_v4(const tor_addr_t *addr) return 1; if (IN_FAMILY(addr) == AF_INET6) { /* First two don't need to be ordered */ - if ((IN6_ADDR(addr)->s6_addr32[0] == 0) && - (IN6_ADDR(addr)->s6_addr32[1] == 0) && - (ntohl(IN6_ADDR(addr)->s6_addr32[2]) == 0x0000ffffu)) + if ((IN6_ADDRESS(addr)->s6_addr32[0] == 0) && + (IN6_ADDRESS(addr)->s6_addr32[1] == 0) && + (ntohl(IN6_ADDRESS(addr)->s6_addr32[2]) == 0x0000ffffu)) return 1; } @@ -2411,14 +2411,12 @@ tor_addr_is_null(const tor_addr_t *addr) switch (IN_FAMILY(addr)) { case AF_INET6: - if (!IN6_ADDR(addr)->s6_addr32[0] && !IN6_ADDR(addr)->s6_addr32[1] && - !IN6_ADDR(addr)->s6_addr32[2] && !IN6_ADDR(addr)->s6_addr32[3]) - return 1; - return 0; + return (!IN6_ADDRESS(addr)->s6_addr32[0] && + !IN6_ADDRESS(addr)->s6_addr32[1] && + !IN6_ADDRESS(addr)->s6_addr32[2] && + !IN6_ADDRESS(addr)->s6_addr32[3]); case AF_INET: - if (!IN4_ADDR(addr)->s_addr) - return 1; - return 0; + return (!IN4_ADDRESS(addr)->s_addr); default: return 1; } @@ -2538,8 +2536,8 @@ tor_addr_compare_masked(const tor_addr_t *addr1, const tor_addr_t *addr2, return 1; return 0; } else if (v_family[0] == AF_INET6) { /* Real IPv6 */ - const uint32_t *a1 = IN6_ADDR(addr1)->s6_addr32; - const uint32_t *a2 = IN6_ADDR(addr2)->s6_addr32; + const uint32_t *a1 = IN6_ADDRESS(addr1)->s6_addr32; + const uint32_t *a2 = IN6_ADDRESS(addr2)->s6_addr32; for (idx = 0; idx < 4; ++idx) { uint32_t masked_a = ntohl(a1[idx]); uint32_t masked_b = ntohl(a2[idx]); @@ -2590,9 +2588,9 @@ tor_addr_to_str(char *dest, const tor_addr_t *addr, int len) tor_assert(addr && dest); if (IN_FAMILY(addr) == AF_INET) { - return tor_inet_ntop(AF_INET, IN4_ADDR(addr), dest, len); + return tor_inet_ntop(AF_INET, IN4_ADDRESS(addr), dest, len); } else if (IN_FAMILY(addr) == AF_INET6) { - return tor_inet_ntop(AF_INET6, IN6_ADDR(addr), dest, len); + return tor_inet_ntop(AF_INET6, IN6_ADDRESS(addr), dest, len); } else { return NULL; } diff --git a/src/or/test.c b/src/or/test.c index 85c7869419..d731fb24f0 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -1069,10 +1069,10 @@ _test_eq_ip6(struct in6_addr *a, struct in6_addr *b, const char *e1, * conventions of the other test macros. */ #define test_addr_parse_check(ip1, ip2, ip3, ip4, mm, pt1, pt2) STMT_BEGIN \ test_assert(r>=0); \ - test_eq(htonl(ip1), IN6_ADDR(&t1)->s6_addr32[0]); \ - test_eq(htonl(ip2), IN6_ADDR(&t1)->s6_addr32[1]); \ - test_eq(htonl(ip3), IN6_ADDR(&t1)->s6_addr32[2]); \ - test_eq(htonl(ip4), IN6_ADDR(&t1)->s6_addr32[3]); \ + test_eq(htonl(ip1), IN6_ADDRESS(&t1)->s6_addr32[0]); \ + test_eq(htonl(ip2), IN6_ADDRESS(&t1)->s6_addr32[1]); \ + test_eq(htonl(ip3), IN6_ADDRESS(&t1)->s6_addr32[2]); \ + test_eq(htonl(ip4), IN6_ADDRESS(&t1)->s6_addr32[3]); \ test_eq(mask, mm); \ test_eq(port1, pt1); \ test_eq(port2, pt2); \ |