summaryrefslogtreecommitdiffstats
path: root/src/peer.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-08-20 16:16:55 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-08-20 16:16:55 +0200
commitd52f208d9fb6381f3c3656c5916866a4b779fa82 (patch)
tree05b08cf037283f1c7a9e10001c962f42422a9aac /src/peer.c
parentf6640a80f4be19e988fd7426c3f897f4d3f614e4 (diff)
downloadfastd-d52f208d9fb6381f3c3656c5916866a4b779fa82.tar
fastd-d52f208d9fb6381f3c3656c5916866a4b779fa82.zip
Use v4-mapped addresses for IPv4 peers on IPv6 sockets
This is needed at least on FreeBSD
Diffstat (limited to 'src/peer.c')
-rw-r--r--src/peer.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/peer.c b/src/peer.c
index dae8141..fc22a50 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -324,6 +324,19 @@ void fastd_peer_address_simplify(fastd_peer_address_t *addr) {
}
}
+void fastd_peer_address_widen(fastd_peer_address_t *addr) {
+ if (addr->sa.sa_family == AF_INET) {
+ struct sockaddr_in addr4 = addr->in;
+
+ memset(addr, 0, sizeof(fastd_peer_address_t));
+ addr->in6.sin6_family = AF_INET6;
+ addr->in6.sin6_port = addr4.sin_port;
+ addr->in6.sin6_addr.s6_addr[10] = 0xff;
+ addr->in6.sin6_addr.s6_addr[11] = 0xff;
+ memcpy(&addr->in6.sin6_addr.s6_addr[12], &addr4.sin_addr.s_addr, 4);
+ }
+}
+
static inline void reset_peer_address(fastd_context_t *ctx, fastd_peer_t *peer) {
if (fastd_peer_is_established(peer))