aboutsummaryrefslogtreecommitdiff
path: root/src/lib/net/address.c
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2020-04-30 21:51:45 +1000
committerteor <teor@torproject.org>2020-04-30 23:27:13 +1000
commit2a0e48385d01ddb2c8a332faed1445110131d723 (patch)
tree662b6a41439f3be21aabc60a157ddc9b790ed552 /src/lib/net/address.c
parent01d940e71b02fd133eda56e0bc9bee113854af7c (diff)
downloadtor-2a0e48385d01ddb2c8a332faed1445110131d723.tar.gz
tor-2a0e48385d01ddb2c8a332faed1445110131d723.zip
relay: Launch IPv4 and IPv6 ORPort self-test circuits
When launching relay ORPort reachability self-tests, launch tests to the IPv4 and IPv6 ORPorts (if available). Part of 33222.
Diffstat (limited to 'src/lib/net/address.c')
-rw-r--r--src/lib/net/address.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/lib/net/address.c b/src/lib/net/address.c
index 4193053ee1..e112da9479 100644
--- a/src/lib/net/address.c
+++ b/src/lib/net/address.c
@@ -1207,20 +1207,17 @@ fmt_addr32(uint32_t addr)
return buf;
}
-/** Return a string representing the family of <b>addr</b>.
+/** Return a string representing <b>family</b>.
*
* This string is a string constant, and must not be freed.
* This function is thread-safe.
*/
const char *
-fmt_addr_family(const tor_addr_t *addr)
+fmt_af_family(sa_family_t family)
{
static int default_bug_once = 0;
- IF_BUG_ONCE(!addr)
- return "NULL pointer";
-
- switch (tor_addr_family(addr)) {
+ switch (family) {
case AF_INET6:
return "IPv6";
case AF_INET:
@@ -1232,7 +1229,7 @@ fmt_addr_family(const tor_addr_t *addr)
default:
if (!default_bug_once) {
log_warn(LD_BUG, "Called with unknown address family %d",
- (int)tor_addr_family(addr));
+ (int)family);
default_bug_once = 1;
}
return "unknown";
@@ -1240,6 +1237,20 @@ fmt_addr_family(const tor_addr_t *addr)
//return "(unreachable code)";
}
+/** Return a string representing the family of <b>addr</b>.
+ *
+ * This string is a string constant, and must not be freed.
+ * This function is thread-safe.
+ */
+const char *
+fmt_addr_family(const tor_addr_t *addr)
+{
+ IF_BUG_ONCE(!addr)
+ return "NULL pointer";
+
+ return fmt_af_family(tor_addr_family(addr));
+}
+
/** Convert the string in <b>src</b> to a tor_addr_t <b>addr</b>. The string
* may be an IPv4 address, or an IPv6 address surrounded by square brackets.
*