summaryrefslogtreecommitdiff
path: root/src/common/util.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/util.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/util.c')
-rw-r--r--src/common/util.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/common/util.c b/src/common/util.c
index a1e0448bc5..40aafb8c2f 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -2108,8 +2108,8 @@ int
is_internal_IP(uint32_t ip, int for_listening)
{
tor_addr_t myaddr;
- myaddr.sa.sin_family = AF_INET;
- myaddr.sa.sin_addr.s_addr = htonl(ip);
+ myaddr.family = AF_INET;
+ myaddr.addr.in_addr.s_addr = htonl(ip);
return tor_addr_is_internal(&myaddr, for_listening);
}
@@ -2519,12 +2519,12 @@ tor_addr_parse_mask_ports(const char *s, tor_addr_t *addr_out,
memset(addr_out, 0, sizeof(tor_addr_t));
if (!strcmp(address, "*")) {
- addr_out->sa.sin_family = AF_INET; /* AF_UNSPEC ???? XXXXX020 */
+ addr_out->family = AF_INET; /* AF_UNSPEC ???? XXXXX020 */
any_flag = 1;
- } else if (tor_inet_pton(AF_INET6, address, &addr_out->sa6.sin6_addr) > 0) {
- addr_out->sa6.sin6_family = AF_INET6;
- } else if (tor_inet_pton(AF_INET, address, &addr_out->sa.sin_addr) > 0) {
- addr_out->sa.sin_family = AF_INET;
+ } else if (tor_inet_pton(AF_INET6, address, &addr_out->addr.in6_addr) > 0) {
+ addr_out->family = AF_INET6;
+ } else if (tor_inet_pton(AF_INET, address, &addr_out->addr.in_addr) > 0) {
+ addr_out->family = AF_INET;
} else {
log_warn(LD_GENERAL, "Malformed IP %s in address pattern; rejecting.",
escaped(address));
@@ -2708,8 +2708,8 @@ tor_addr_from_ipv4(tor_addr_t *dest, uint32_t v4addr)
{
tor_assert(dest);
memset(dest, 0, sizeof(dest));
- dest->sa.sin_family = AF_INET;
- dest->sa.sin_addr.s_addr = htonl(v4addr);
+ dest->family = AF_INET;
+ dest->addr.in_addr.s_addr = htonl(v4addr);
}
/** Copy a tor_addr_t from <b>src</b> to <b>dest</b>.