From 5da80263a511f7f9d03e553a1b97e55de86966d6 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Thu, 30 Jan 2014 13:59:10 -0500 Subject: Convert IPv4 in IPv6 to IPv6 address in recieve packet. --- toxcore/network.c | 6 +++++- toxcore/network.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'toxcore') diff --git a/toxcore/network.c b/toxcore/network.c index 08fb71c7..1186a468 100644 --- a/toxcore/network.c +++ b/toxcore/network.c @@ -258,10 +258,14 @@ static int receivepacket(sock_t sock, IP_Port *ip_port, uint8_t *data, uint32_t ip_port->port = addr_in->sin_port; } else if (addr.ss_family == AF_INET6) { struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6 *)&addr; - ip_port->ip.family = addr_in6->sin6_family; ip_port->ip.ip6.in6_addr = addr_in6->sin6_addr; ip_port->port = addr_in6->sin6_port; + + if (IN6_IS_ADDR_V4MAPPED(&ip_port->ip.ip6.in6_addr)) { + ip_port->ip.family = AF_INET; + ip_port->ip.ip4.uint32 = ip_port->ip.ip6.uint32[3]; + } } else return -1; diff --git a/toxcore/network.h b/toxcore/network.h index 2ba2b005..4c7f1a83 100644 --- a/toxcore/network.h +++ b/toxcore/network.h @@ -81,7 +81,7 @@ typedef int sock_t; #endif #if defined(__AIX__) -# define _XOPEN_SOURCE 1 +# define _XOPEN_SOURCE 1 #endif #if defined(__sun__) -- cgit v1.2.3