diff options
author | Roger Dingledine <arma@torproject.org> | 2008-12-25 15:37:47 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2008-12-25 15:37:47 +0000 |
commit | a12c3f2c86d967bce7253e78f4c42929b03cc87d (patch) | |
tree | 3d17dfd8fca4ff9556ddeed3a23b281632d69a2e /src/common | |
parent | 4a1fd99899b654081465d42f4df8a9d119f906c8 (diff) | |
download | tor-a12c3f2c86d967bce7253e78f4c42929b03cc87d.tar.gz tor-a12c3f2c86d967bce7253e78f4c42929b03cc87d.zip |
some fixes i found in my sandbox
svn:r17771
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/address.c | 2 | ||||
-rw-r--r-- | src/common/address.h | 34 |
2 files changed, 18 insertions, 18 deletions
diff --git a/src/common/address.c b/src/common/address.c index 67eb07f3a1..d65d16036f 100644 --- a/src/common/address.c +++ b/src/common/address.c @@ -1013,7 +1013,7 @@ tor_addr_from_str(tor_addr_t *addr, const char *src) /** Parse an address or address-port combination from <b>s</b>, and put the result in <b>addr_out</b> and (optionally) <b>port_out</b>. Return 0 on - success, negative on failure.*/ + success, negative on failure. */ int tor_addr_port_parse(const char *s, tor_addr_t *addr_out, uint16_t *port_out) { diff --git a/src/common/address.h b/src/common/address.h index 603ffae2ae..0bc7674913 100644 --- a/src/common/address.h +++ b/src/common/address.h @@ -33,28 +33,12 @@ typedef struct tor_addr_t } addr; } tor_addr_t; -/** Return an IPv4 address in network order for <b>a</b>, or 0 if - * <b>a</b> is not an IPv4 address. */ +static INLINE const struct in6_addr *tor_addr_to_in6(const tor_addr_t *a); static INLINE uint32_t tor_addr_to_ipv4n(const tor_addr_t *a); -/** Return an IPv4 address in host order for <b>a</b>, or 0 if - * <b>a</b> is not an IPv4 address. */ static INLINE uint32_t tor_addr_to_ipv4h(const tor_addr_t *a); -/* Given an IPv6 address, return its mapped IPv4 address in host order, or - * 0 if <b>a</b> is not an IPv6 address. - * - * (Does not check whether the address is really a mapped address */ static INLINE uint32_t tor_addr_to_mapped_ipv4h(const tor_addr_t *a); -/** Return the address family of <b>a</b>. Possible values are: - * AF_INET6, AF_INET, AF_UNSPEC. */ static INLINE sa_family_t tor_addr_family(const tor_addr_t *a); -/** Return an in_addr* equivalent to <b>a</b>, or NULL if <b>a</b> is not - * an IPv4 address. */ static INLINE const struct in_addr *tor_addr_to_in(const tor_addr_t *a); -/** Return an in6_addr* equivalent to <b>a</b>, or NULL if <b>a</b> is not - * an IPv6 address. */ -static INLINE const struct in6_addr *tor_addr_to_in6(const tor_addr_t *a); -/** Return true iff <b>a</b> is an IPv4 address equal to the host-ordered - * address in <b>u</b>. */ 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, @@ -63,6 +47,8 @@ int tor_addr_from_sockaddr(tor_addr_t *a, const struct sockaddr *sa, uint16_t *port_out); void tor_addr_make_unspec(tor_addr_t *a); +/** Return an in6_addr* equivalent to <b>a</b>, or NULL if <b>a</b> is not + * an IPv6 address. */ static INLINE const struct in6_addr * tor_addr_to_in6(const tor_addr_t *a) { @@ -73,31 +59,45 @@ tor_addr_to_in6(const tor_addr_t *a) #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)) +/** Return an IPv4 address in network order for <b>a</b>, or 0 if + * <b>a</b> is not an IPv4 address. */ static INLINE uint32_t tor_addr_to_ipv4n(const tor_addr_t *a) { return a->family == AF_INET ? a->addr.in_addr.s_addr : 0; } +/** Return an IPv4 address in host order for <b>a</b>, or 0 if + * <b>a</b> is not an IPv4 address. */ static INLINE uint32_t tor_addr_to_ipv4h(const tor_addr_t *a) { return ntohl(tor_addr_to_ipv4n(a)); } +/* Given an IPv6 address, return its mapped IPv4 address in host order, or + * 0 if <b>a</b> is not an IPv6 address. + * + * (Does not check whether the address is really a mapped address */ static INLINE uint32_t tor_addr_to_mapped_ipv4h(const tor_addr_t *a) { return a->family == AF_INET6 ? ntohl(tor_addr_to_in6_addr32(a)[3]) : 0; } +/** Return the address family of <b>a</b>. Possible values are: + * AF_INET6, AF_INET, AF_UNSPEC. */ static INLINE sa_family_t tor_addr_family(const tor_addr_t *a) { return a->family; } +/** Return an in_addr* equivalent to <b>a</b>, or NULL if <b>a</b> is not + * an IPv4 address. */ static INLINE const struct in_addr * tor_addr_to_in(const tor_addr_t *a) { return a->family == AF_INET ? &a->addr.in_addr : NULL; } +/** Return true iff <b>a</b> is an IPv4 address equal to the host-ordered + * address in <b>u</b>. */ static INLINE int tor_addr_eq_ipv4h(const tor_addr_t *a, uint32_t u) { |