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 {
struct sockaddr_storage* v4address = calloc(1, sizeof(struct sockaddr_storage));
v4address->ss_family = AF_INET;
- v4address->ss_len = sizeof(struct sockaddr_storage);
struct sockaddr_storage* v6address = calloc(1, sizeof(struct sockaddr_storage));
v6address->ss_family = AF_INET6;
+
+#if defined(NETBSD) || defined(FREEBSD) || defined(OPENBSD) || defined(__APPLE__)
+ v4address->ss_len = sizeof(struct sockaddr_storage);
v6address->ss_len = sizeof(struct sockaddr_storage);
+#endif
int error = 0;