mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Convert IPv4 in IPv6 to IPv6 address in recieve packet.
This commit is contained in:
parent
f1e0e16b67
commit
5da80263a5
|
@ -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;
|
ip_port->port = addr_in->sin_port;
|
||||||
} else if (addr.ss_family == AF_INET6) {
|
} else if (addr.ss_family == AF_INET6) {
|
||||||
struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6 *)&addr;
|
struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6 *)&addr;
|
||||||
|
|
||||||
ip_port->ip.family = addr_in6->sin6_family;
|
ip_port->ip.family = addr_in6->sin6_family;
|
||||||
ip_port->ip.ip6.in6_addr = addr_in6->sin6_addr;
|
ip_port->ip.ip6.in6_addr = addr_in6->sin6_addr;
|
||||||
ip_port->port = addr_in6->sin6_port;
|
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
|
} else
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user