aboutsummaryrefslogtreecommitdiff
path: root/src/common/address.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2010-10-01 21:31:09 -0400
committerRoger Dingledine <arma@torproject.org>2010-10-01 21:31:09 -0400
commit22f723e4a3fc32983480c7403af9d7e77a3200ea (patch)
treeb33e4fec4ffa0e350e5c4193e050cb3441e2958e /src/common/address.c
parent165aaf560a7249a388e916659d55ec6fa1d2fd24 (diff)
downloadtor-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.c12
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.