mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Handle IPv4 addresses in inet_ntop.
This commit is contained in:
parent
4f8da08d67
commit
dd8eafb6c9
@ -1,3 +1,8 @@
|
|||||||
|
2005-08-09 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
|
* mswindows.c (inet_ntop): Also handle IPv4 addresses for
|
||||||
|
completeness.
|
||||||
|
|
||||||
2005-08-09 Hrvoje Niksic <hniksic@xemacs.org>
|
2005-08-09 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
* http.c (gethttp): Don't read more than the amount of data
|
* http.c (gethttp): Don't read more than the amount of data
|
||||||
|
@ -799,22 +799,39 @@ windows_strerror (int err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
/* An IPv6-only inet_ntop that prints with WSAAddressToString. (Wget
|
/* An inet_ntop implementation that uses WSAAddressToString.
|
||||||
uses inet_ntoa for IPv4 addresses -- see print_address.) Prototype
|
Prototype complies with POSIX 1003.1-2004. This is only used under
|
||||||
complies with POSIX 1003.1-2004. */
|
IPv6 because Wget prints IPv4 addresses using inet_ntoa. */
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
inet_ntop (int af, const void *src, char *dst, socklen_t cnt)
|
inet_ntop (int af, const void *src, char *dst, socklen_t cnt)
|
||||||
{
|
{
|
||||||
|
/* struct sockaddr can't accomodate struct sockaddr_in6. */
|
||||||
|
union {
|
||||||
struct sockaddr_in6 sin6;
|
struct sockaddr_in6 sin6;
|
||||||
|
struct sockaddr_in sin;
|
||||||
|
} sa;
|
||||||
DWORD dstlen = cnt;
|
DWORD dstlen = cnt;
|
||||||
|
size_t srcsize;
|
||||||
|
|
||||||
assert (af == AF_INET6);
|
xzero (sa);
|
||||||
xzero (sin6);
|
switch (af)
|
||||||
sin6.sin6_family = AF_INET6;
|
{
|
||||||
sin6.sin6_addr = *(struct in6_addr *) src;
|
case AF_INET:
|
||||||
if (WSAAddressToString ((struct sockaddr *) &sin6, sizeof (sin6),
|
sa.sin.sin_family = AF_INET;
|
||||||
NULL, dst, &dstlen) != 0)
|
sa.sin.sin_addr = *(struct in_addr *) src;
|
||||||
|
srcsize = sizeof (sa.sin);
|
||||||
|
break;
|
||||||
|
case AF_INET6:
|
||||||
|
sa.sin6.sin6_family = AF_INET6;
|
||||||
|
sa.sin6.sin6_addr = *(struct in6_addr *) src;
|
||||||
|
srcsize = sizeof (sa.sin6);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WSAAddressToString ((struct sockaddr *) &sa, srcsize, NULL, dst, &dstlen) != 0)
|
||||||
{
|
{
|
||||||
errno = WSAGetLastError();
|
errno = WSAGetLastError();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user