aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorteor <teor@riseup.net>2020-05-07 20:59:10 +1000
committerteor <teor@riseup.net>2020-05-07 20:59:10 +1000
commit504b16fb757d14f58e20294f7aca338dc6826140 (patch)
treeadd7e18a4ebe1aa8055a224301d4b47ce46fd790 /src/lib
parente887887cd32f9e78e3b6e9c47661eaf750b4c0fb (diff)
downloadtor-504b16fb757d14f58e20294f7aca338dc6826140.tar.gz
tor-504b16fb757d14f58e20294f7aca338dc6826140.zip
relay: Rewrite inform_testing_reachability()
Rewrite inform_testing_reachability() to use separate buffers for IPv4 ORPort, IPv6 ORPort, and IPv4 DirPort. And use consistent APIs to fill those buffers. Part of 33222.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/net/address.c11
-rw-r--r--src/lib/net/address.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/net/address.c b/src/lib/net/address.c
index 7f63593875..76c7aadd22 100644
--- a/src/lib/net/address.c
+++ b/src/lib/net/address.c
@@ -1206,6 +1206,17 @@ fmt_addr32(uint32_t addr)
return buf;
}
+/** Like fmt_addrport(), but takes <b>addr</b> as a host-order IPv4
+ * addresses. Also not thread-safe, also clobbers its return buffer on
+ * repeated calls. */
+const char *
+fmt_addr32_port(uint32_t addr, uint16_t port)
+{
+ static char buf[INET_NTOA_BUF_LEN + 6];
+ snprintf(buf, sizeof(buf), "%s:%u", fmt_addr32(addr), port);
+ return buf;
+}
+
/** Return a string representing <b>family</b>.
*
* This string is a string constant, and must not be freed.
diff --git a/src/lib/net/address.h b/src/lib/net/address.h
index eca5ddab75..5ab654ef1d 100644
--- a/src/lib/net/address.h
+++ b/src/lib/net/address.h
@@ -236,6 +236,7 @@ const char *fmt_addr_impl(const tor_addr_t *addr, int decorate);
const char *fmt_addrport(const tor_addr_t *addr, uint16_t port);
#define fmt_addrport_ap(ap) fmt_addrport(&(ap)->addr, (ap)->port)
const char *fmt_addr32(uint32_t addr);
+const char *fmt_addr32_port(uint32_t addr, uint16_t port);
const char *fmt_af_family(sa_family_t family);
const char *fmt_addr_family(const tor_addr_t *addr);