diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-12-13 14:13:51 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-12-13 14:13:51 +0100 |
commit | da4d1d1586f36f1a4b69e19d39638676da3315d2 (patch) | |
tree | 3e2c017b65dd751da8ef3635a304e0c582401bb4 /src | |
parent | b3b4397734e2845d9fa0f994550dc960ad1900d1 (diff) | |
download | fastd-da4d1d1586f36f1a4b69e19d39638676da3315d2.tar fastd-da4d1d1586f36f1a4b69e19d39638676da3315d2.zip |
Reduce v4-mapped IPv6 addresses to IPv4 addresses
We need this for "any" binds to work correctly again.
Diffstat (limited to 'src')
-rw-r--r-- | src/fastd.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/fastd.c b/src/fastd.c index af9ba6e..d751a59 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -748,6 +748,15 @@ static void handle_socket(fastd_context *ctx, fastd_socket *sock) { packet_type = buffer.data; buffer.len = len; + if (recvaddr.sa.sa_family == AF_INET6 && IN6_IS_ADDR_V4MAPPED(&recvaddr.in6.sin6_addr)) { + struct sockaddr_in6 mapped = recvaddr.in6; + + memset(&recvaddr, 0, sizeof(recvaddr)); + recvaddr.in.sin_family = AF_INET; + recvaddr.in.sin_port = mapped.sin6_port; + memcpy(&recvaddr.in.sin_addr.s_addr, &mapped.sin6_addr.s6_addr[12], 4); + } + fastd_buffer_push_head(&buffer, 1); fastd_peer *peer = NULL; |