summaryrefslogtreecommitdiffstats
path: root/src/send.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/send.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/send.c')
-rw-r--r--src/send.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/send.c b/src/send.c
index 8707e31..3a990d2 100644
--- a/src/send.c
+++ b/src/send.c
@@ -70,6 +70,7 @@ static void send_type(fastd_context_t *ctx, const fastd_socket_t *sock, const fa
struct msghdr msg = {};
char cbuf[1024] = {};
+ fastd_peer_address_t remote_addr6;
switch (remote_addr->sa.sa_family) {
case AF_INET:
@@ -86,6 +87,14 @@ static void send_type(fastd_context_t *ctx, const fastd_socket_t *sock, const fa
exit_bug(ctx, "unsupported address family");
}
+ if (sock->bound_addr->sa.sa_family == AF_INET6) {
+ remote_addr6 = *remote_addr;
+ fastd_peer_address_widen(&remote_addr6);
+
+ msg.msg_name = (void*)&remote_addr6.in6;
+ msg.msg_namelen = sizeof(struct sockaddr_in6);
+ }
+
struct iovec iov[2] = {
{ .iov_base = &packet_type, .iov_len = 1 },
{ .iov_base = buffer.data, .iov_len = buffer.len }