diff options
author | Roger Dingledine <arma@torproject.org> | 2010-10-01 21:31:09 -0400 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2010-10-01 21:31:09 -0400 |
commit | 22f723e4a3fc32983480c7403af9d7e77a3200ea (patch) | |
tree | b33e4fec4ffa0e350e5c4193e050cb3441e2958e /src/common/address.c | |
parent | 165aaf560a7249a388e916659d55ec6fa1d2fd24 (diff) | |
download | tor-22f723e4a3fc32983480c7403af9d7e77a3200ea.tar tor-22f723e4a3fc32983480c7403af9d7e77a3200ea.tar.gz |
refactor all these tor_inet_ntoa idioms
but don't refactor the ones that look messy
Diffstat (limited to 'src/common/address.c')
-rw-r--r-- | src/common/address.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/common/address.c b/src/common/address.c index c35f04c18..dfe8f518e 100644 --- a/src/common/address.c +++ b/src/common/address.c @@ -927,6 +927,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. |