Linux vs. BSD sockaddr_storage fix
[umurmur.git] / src / client.c
index 1c83de0018f6c6e36cf3dd738e96b7b0b8153998..d79fa78206bb2591f716aee2b97f30658d030db3 100644 (file)
@@ -1046,11 +1046,11 @@ static int Client_send_udp(client_t *client, uint8_t *data, int len)
 
                CryptState_encrypt(&client->cryptState, data, buf, len);
 
-               // Maybe an OS X loopback quirk
-               if (client->remote_udp.ss_family == AF_INET)
-                       sendto(udpsock, buf, len + 4, 0, (struct sockaddr *)&client->remote_udp, sizeof(struct sockaddr_in));
-               else
-                       sendto(udpsock, buf, len + 4, 0, (struct sockaddr *)&client->remote_udp, sizeof(struct sockaddr_in6));
+#if defined(NETBSD) || defined(FREEBSD) || defined(OPENBSD) || defined(__APPLE__)
+                       sendto(udpsock, buf, len + 4, 0, (struct sockaddr *)&client->remote_udp, client->remote_tcp.ss_len);
+#else
+                       sendto(udpsock, buf, len + 4, 0, (struct sockaddr *)&client->remote_udp, sizeof(struct sockaddr_storage));
+#endif
 
                free(mbuf);
        } else {