| 747 |
|
|
| 748 |
|
/* |
| 749 |
|
* remove_ipv6_mapping() - Removes IPv4-In-IPv6 mapping from an address |
| 750 |
< |
* This function should really inspect the struct itself rather than relying |
| 751 |
< |
* on inet_pton and inet_ntop. OSes with IPv6 mapping listening on both |
| 750 |
> |
* OSes with IPv6 mapping listening on both |
| 751 |
|
* AF_INET and AF_INET6 map AF_INET connections inside AF_INET6 structures |
| 752 |
|
* |
| 753 |
|
*/ |
| 757 |
|
{ |
| 758 |
|
if (addr->ss.ss_family == AF_INET6) |
| 759 |
|
{ |
| 760 |
< |
struct sockaddr_in6 *v6; |
| 762 |
< |
|
| 763 |
< |
v6 = (struct sockaddr_in6*)addr; |
| 764 |
< |
if (IN6_IS_ADDR_V4MAPPED(&v6->sin6_addr)) |
| 760 |
> |
if (IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)addr)->sin6_addr)) |
| 761 |
|
{ |
| 762 |
< |
char v4ip[HOSTIPLEN]; |
| 763 |
< |
struct sockaddr_in *v4 = (struct sockaddr_in*)addr; |
| 764 |
< |
inetntop(AF_INET6, &v6->sin6_addr, v4ip, HOSTIPLEN); |
| 765 |
< |
inet_pton(AF_INET, v4ip, &v4->sin_addr); |
| 762 |
> |
struct sockaddr_in6 v6; |
| 763 |
> |
struct sockaddr_in *v4 = (struct sockaddr_in *)addr; |
| 764 |
> |
|
| 765 |
> |
memcpy(&v6, addr, sizeof(v6)); |
| 766 |
> |
memset(v4, 0, sizeof(struct sockaddr_in)); |
| 767 |
> |
memcpy(&v4->sin_addr, &v6.sin6_addr.s6_addr[12], sizeof(v4->sin_addr)); |
| 768 |
> |
|
| 769 |
|
addr->ss.ss_family = AF_INET; |
| 770 |
|
addr->ss_len = sizeof(struct sockaddr_in); |
| 771 |
|
} |