aboutsummaryrefslogtreecommitdiff
path: root/src/common/address.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-07-29 00:34:50 +0000
committerNick Mathewson <nickm@torproject.org>2008-07-29 00:34:50 +0000
commit507b01357affd0b58ac0721a7b5001d38a600c6a (patch)
tree8fe707000aaff36b8c0023eeff193bf2d9c7e1f6 /src/common/address.h
parent056d97da0c6c69aa2da9855675b6726f471b5f5a (diff)
downloadtor-507b01357affd0b58ac0721a7b5001d38a600c6a.tar.gz
tor-507b01357affd0b58ac0721a7b5001d38a600c6a.zip
r17426@tombo: nickm | 2008-07-28 20:34:03 -0400
More test coverage for tor_addr_t; fix a couple of bugs. svn:r16234
Diffstat (limited to 'src/common/address.h')
-rw-r--r--src/common/address.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/common/address.h b/src/common/address.h
index fd4b7879e8..b079f69451 100644
--- a/src/common/address.h
+++ b/src/common/address.h
@@ -37,8 +37,9 @@ static INLINE uint32_t tor_addr_to_mapped_ipv4h(const tor_addr_t *a);
static INLINE sa_family_t tor_addr_family(const tor_addr_t *a);
static INLINE const struct in_addr *tor_addr_to_in(const tor_addr_t *a);
static INLINE const struct in6_addr *tor_addr_to_in6(const tor_addr_t *a);
+static INLINE int tor_addr_eq_ipv4h(const tor_addr_t *a, uint32_t u);
socklen_t tor_addr_to_sockaddr(const tor_addr_t *a, uint16_t port,
- struct sockaddr *sa_out);
+ struct sockaddr *sa_out, socklen_t len);
void tor_addr_from_sockaddr(tor_addr_t *a, const struct sockaddr *sa);
static INLINE const struct in6_addr *
@@ -47,6 +48,7 @@ tor_addr_to_in6(const tor_addr_t *a)
return a->family == AF_INET6 ? &a->addr.in6_addr : NULL;
}
+#define tor_addr_to_in6_addr8(x) tor_addr_to_in6(x)->s6_addr
#define tor_addr_to_in6_addr16(x) S6_ADDR16(*tor_addr_to_in6(x))
#define tor_addr_to_in6_addr32(x) S6_ADDR32(*tor_addr_to_in6(x))
@@ -75,6 +77,11 @@ tor_addr_to_in(const tor_addr_t *a)
{
return a->family == AF_INET ? &a->addr.in_addr : NULL;
}
+static INLINE int
+tor_addr_eq_ipv4h(const tor_addr_t *a, uint32_t u)
+{
+ return a->family == AF_INET ? (tor_addr_to_ipv4h(a) == u) : 0;
+}
#define TOR_ADDR_BUF_LEN 48 /* [ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255]
*/