diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-08-17 20:44:54 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-08-17 20:44:54 +0000 |
commit | f8b3927e076465808bd31e0e06712fb155ccf125 (patch) | |
tree | 31242e84582a8814a5276d12e9dcbcddb88c73cf /src/common/compat.h | |
parent | cb7f4504e4dfcf04767f73c7014dea065d731655 (diff) | |
download | tor-f8b3927e076465808bd31e0e06712fb155ccf125.tar.gz tor-f8b3927e076465808bd31e0e06712fb155ccf125.zip |
r14634@catbus: nickm | 2007-08-17 16:43:49 -0400
Try to fix bug 482: do not rely on s6_addr16 or s6_addr32 on MSVC. How ugly.
svn:r11155
Diffstat (limited to 'src/common/compat.h')
-rw-r--r-- | src/common/compat.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/common/compat.h b/src/common/compat.h index 9e3069d1fb..647e64c4b7 100644 --- a/src/common/compat.h +++ b/src/common/compat.h @@ -298,6 +298,16 @@ struct in6_addr typedef uint16_t sa_family_t; #endif +#ifndef _MSC_VER +/* Apparently, MSVC doesn't define s6_addr16 or s6_addr32. How dumb. */ +/* XXXX020 detect with autoconf. */ +#define S6_ADDR16(x) ((x).s6_addr16) +#define S6_ADDR32(x) ((x).s6_addr32) +#else +#define S6_ADDR16(x) ((uint16_t*)((char*)&(x).s6_addr)) +#define S6_ADDR32(x) ((uint32_t*)((char*)&(x).s6_addr)) +#endif + /* XXXX020 detect sockaddr_in6 correctly on ms_windows; this is also a hack. */ #if !defined(HAVE_STRUCT_SOCKADDR_IN6) && !defined(MS_WINDOWS) struct sockaddr_in6 { @@ -367,6 +377,9 @@ 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 */ |