summaryrefslogtreecommitdiff
path: root/src/common/compat.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-12-04 05:19:56 +0000
committerNick Mathewson <nickm@torproject.org>2007-12-04 05:19:56 +0000
commit593ab7e808155fb187a6d99d9a607639502ee5b3 (patch)
treed7917a9b345a197a5d818f6adf614d5d1d55a4e6 /src/common/compat.c
parentce2cf88ebf9fdc96dad1ba552c1c2904937fc1b4 (diff)
downloadtor-593ab7e808155fb187a6d99d9a607639502ee5b3.tar.gz
tor-593ab7e808155fb187a6d99d9a607639502ee5b3.zip
r15106@tombo: nickm | 2007-12-04 00:08:35 -0500
Change tor_addr_t to be a tagged union of in_addr and in6_addr, not of sockaddr_in and sockaddr_in6. It's hardly used in the main code as it is, but let's get it right before it gets popular. svn:r12660
Diffstat (limited to 'src/common/compat.c')
-rw-r--r--src/common/compat.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index 6a5d2abba6..d02049836a 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -1093,12 +1093,12 @@ tor_addr_lookup(const char *name, uint16_t family, tor_addr_t *addr)
return -1;
} else if (tor_inet_pton(AF_INET, name, &iaddr)) {
/* It's an IPv4 IP. */
- addr->sa.sin_family = AF_INET;
- memcpy(&addr->sa.sin_addr, &iaddr, sizeof(struct in_addr));
+ addr->family = AF_INET;
+ memcpy(&addr->addr.in_addr, &iaddr, sizeof(struct in_addr));
return 0;
} else if (tor_inet_pton(AF_INET6, name, &iaddr6)) {
- addr->sa6.sin6_family = AF_INET6;
- memcpy(&addr->sa6.sin6_addr, &iaddr6, sizeof(struct in6_addr));
+ addr->family = AF_INET6;
+ memcpy(&addr->addr.in6_addr, &iaddr6, sizeof(struct in6_addr));
return 0;
} else {
#ifdef HAVE_GETADDRINFO
@@ -1129,14 +1129,14 @@ tor_addr_lookup(const char *name, uint16_t family, tor_addr_t *addr)
if (!best)
best = res;
if (best->ai_family == AF_INET) {
- addr->sa.sin_family = AF_INET;
- memcpy(&addr->sa.sin_addr,
+ addr->family = AF_INET;
+ memcpy(&addr->addr.in_addr,
&((struct sockaddr_in*)best->ai_addr)->sin_addr,
sizeof(struct in_addr));
result = 0;
} else if (best->ai_family == AF_INET6) {
- addr->sa6.sin6_family = AF_INET6;
- memcpy(&addr->sa6.sin6_addr,
+ addr->family = AF_INET6;
+ memcpy(&addr->addr.in6_addr,
&((struct sockaddr_in6*)best->ai_addr)->sin6_addr,
sizeof(struct in6_addr));
result = 0;
@@ -1172,11 +1172,11 @@ tor_addr_lookup(const char *name, uint16_t family, tor_addr_t *addr)
#endif
#endif /* endif HAVE_GETHOSTBYNAME_R_6_ARG. */
if (ent) {
- addr->sa.sin_family = ent->h_addrtype;
+ addr->family = ent->h_addrtype;
if (ent->h_addrtype == AF_INET) {
- memcpy(&addr->sa.sin_addr, ent->h_addr, sizeof(struct in_addr));
+ memcpy(&addr->addr.in_addr, ent->h_addr, sizeof(struct in_addr));
} else if (ent->h_addrtype == AF_INET6) {
- memcpy(&addr->sa6.sin6_addr, ent->h_addr, sizeof(struct in6_addr));
+ memcpy(&addr->addr.in6_addr, ent->h_addr, sizeof(struct in6_addr));
} else {
tor_assert(0); /* gethostbyname() returned a bizarre addrtype */
}