Convert IPv4 in IPv6 to IPv6 address in recieve packet.

This commit is contained in:
irungentoo 2014-01-30 13:59:10 -05:00
parent f1e0e16b67
commit 5da80263a5
2 changed files with 6 additions and 2 deletions

View File

@ -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;

View File

@ -81,7 +81,7 @@ typedef int sock_t;
#endif
#if defined(__AIX__)
# define _XOPEN_SOURCE 1
# define _XOPEN_SOURCE 1
#endif
#if defined(__sun__)