summaryrefslogtreecommitdiff
path: root/src/lib/net/address.c
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2020-04-14 15:08:42 +1000
committerteor <teor@torproject.org>2020-04-29 22:43:09 +1000
commitbd6ab90ad4b40a64c604c1a4b6b37da6991fad9e (patch)
tree832476a193af3ecb73d6858ed532f9127eb858c5 /src/lib/net/address.c
parent3253c357eeae3434da62bf720a451aa19f0ddd32 (diff)
downloadtor-bd6ab90ad4b40a64c604c1a4b6b37da6991fad9e.tar.gz
tor-bd6ab90ad4b40a64c604c1a4b6b37da6991fad9e.zip
core/or: Support IPv6 EXTEND2 cells
Allow clients and relays to send dual-stack and IPv6-only EXTEND2 cells. Parse dual-stack and IPv6-only EXTEND2 cells on relays. Relays do not make connections or extend circuits via IPv6: that's the next step. Closes ticket 33901.
Diffstat (limited to 'src/lib/net/address.c')
-rw-r--r--src/lib/net/address.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lib/net/address.c b/src/lib/net/address.c
index 5dbef6a79d..5fe9abca1b 100644
--- a/src/lib/net/address.c
+++ b/src/lib/net/address.c
@@ -903,6 +903,20 @@ tor_addr_from_in6(tor_addr_t *dest, const struct in6_addr *in6)
tor_addr_from_ipv6_bytes(dest, (const char*)in6->s6_addr);
}
+/** Set the 16 bytes at <b>dest</b> to equal the IPv6 address <b>src</b>.
+ * <b>src</b> must be an IPv6 address, if it is not, log a warning, and clear
+ * <b>dest</b>. */
+void
+tor_addr_get_ipv6_bytes(char *dest, const tor_addr_t *src)
+{
+ tor_assert(dest);
+ tor_assert(src);
+ memset(dest, 0, 16);
+ IF_BUG_ONCE(src->family != AF_INET6)
+ return;
+ memcpy(dest, src->addr.in6_addr.s6_addr, 16);
+}
+
/** Copy a tor_addr_t from <b>src</b> to <b>dest</b>.
*/
void