diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-10-15 17:08:18 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-10-15 17:08:18 -0400 |
commit | a7cf788740f9cb8befc8c46d175dbc23a4aaa6ea (patch) | |
tree | 6736644858d343a292db3beffe84fbf157a0eb8a /src/common | |
parent | d6bd2e55a67a9260f0fa2d4c91eb3ee9368c9f8a (diff) | |
parent | b97da61b5a26e67dca11a81d28b5e26e3a3f5a59 (diff) | |
download | tor-a7cf788740f9cb8befc8c46d175dbc23a4aaa6ea.tar.gz tor-a7cf788740f9cb8befc8c46d175dbc23a4aaa6ea.zip |
Merge branch 'bug1992_part1'
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/address.c | 12 | ||||
-rw-r--r-- | src/common/address.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/common/address.c b/src/common/address.c index c7e8109fa5..323e0eeac3 100644 --- a/src/common/address.c +++ b/src/common/address.c @@ -925,6 +925,18 @@ fmt_addr(const tor_addr_t *addr) return buf; } +/** Like fmt_addr(), but for IPv4 addresses. Also not thread-safe, also + * clobbers its return buffer on repeated calls. */ +const char * +fmt_addr32(uint32_t addr) +{ + static char buf[INET_NTOA_BUF_LEN]; + struct in_addr in; + in.s_addr = htonl(addr); + tor_inet_ntoa(&in, buf, sizeof(buf)); + return buf; +} + /** Convert the string in <b>src</b> to a tor_addr_t <b>addr</b>. The string * may be an IPv4 address, an IPv6 address, or an IPv6 address surrounded by * square brackets. diff --git a/src/common/address.h b/src/common/address.h index c7a08698f5..e004ffb13f 100644 --- a/src/common/address.h +++ b/src/common/address.h @@ -108,6 +108,7 @@ tor_addr_eq_ipv4h(const tor_addr_t *a, uint32_t u) int tor_addr_lookup(const char *name, uint16_t family, tor_addr_t *addr_out); char *tor_dup_addr(const tor_addr_t *addr) ATTR_MALLOC; const char *fmt_addr(const tor_addr_t *addr); +const char * fmt_addr32(uint32_t addr); int get_interface_address6(int severity, sa_family_t family, tor_addr_t *addr); /** Flag to specify how to do a comparison between addresses. In an "exact" |