changeset 63:fa4983c5f7ea

Fix floating remote mode on NetBSD
author Ivo Smits <Ivo@UFO-Net.nl>
date Sat, 07 Jan 2017 16:01:01 +0100
parents 5b9e742bb704
children fa53d1c54886
files src/common.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/common.c	Sat Jan 07 15:47:19 2017 +0100
+++ b/src/common.c	Sat Jan 07 16:01:01 2017 +0100
@@ -301,7 +301,10 @@
 	if (session->remote_float == 0) {
 		len = write(session->fd_socket, msg, len);
 	} else if (session->remote_float == 2) {
-		len = sendto(session->fd_socket, msg, len, 0, (struct sockaddr*)&session->remote_addr, sizeof(sockaddr_any));
+		int sa_size = sizeof(sockaddr_any);
+		if (session->remote_addr.any.sa_family == AF_INET) sa_size = sizeof(struct sockaddr_in);
+		else if (session->remote_addr.any.sa_family == AF_INET6) sa_size = sizeof(struct sockaddr_in6);
+		len = sendto(session->fd_socket, msg, len, 0, (struct sockaddr*)&session->remote_addr, sa_size);
 	}
 }