+2005-06-30 Hrvoje Niksic <hniksic@xemacs.org>
+
+ * host.c (pretty_print_address): Handle error result from
+ inet_ntop.
+
+2005-06-30 Gisle Vanem <giva@bgnett.no>
+
+ * mswindows.c (inet_ntop): New function. Print IPv6 addresses
+ using WSAAddressToString.
+
2005-06-27 Hrvoje Niksic <hniksic@xemacs.org>
* progress.c (dot_update): Remove unused variable row_qty.
#ifdef ENABLE_IPV6
case IPV6_ADDRESS:
{
- static char buf[128];
- inet_ntop (AF_INET6, &ADDRESS_IPV6_IN6_ADDR (addr), buf, sizeof (buf));
-#if 0
-#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID
- {
- /* append "%SCOPE_ID" for all ?non-global? addresses */
- char *p = buf + strlen (buf);
- *p++ = '%';
- number_to_string (p, ADDRESS_IPV6_SCOPE (addr));
- }
-#endif
-#endif
+ static char buf[64];
+ if (!inet_ntop (AF_INET6, &ADDRESS_IPV6_IN6_ADDR (addr),
+ buf, sizeof (buf)))
+ snprintf (buf, sizeof buf, "[error: %s]", strerror (errno));
buf[sizeof (buf) - 1] = '\0';
return buf;
}
return buf;
}
}
+\f
+#ifdef ENABLE_IPV6
+/* An IPv6-only inet_ntop that prints with WSAAddressToString. (Wget
+ uses inet_ntoa for IPv4 addresses -- see pretty_print_address.)
+ Prototype complies with POSIX 1003.1-2004. */
+
+const char *
+inet_ntop (int af, const void *src, char *dst, socklen_t cnt)
+{
+ struct sockaddr_in6 sin6;
+ DWORD dstlen = cnt;
+
+ assert (af == AF_INET6);
+ xzero (sin6);
+ sin6.sin6_family = AF_INET6;
+ sin6.sin6_addr = *(struct in6_addr *) src;
+ if (WSAAddressToString ((struct sockaddr *) &sin6, sizeof (sin6),
+ NULL, dst, &dstlen) != 0)
+ {
+ errno = WSAGetLastError();
+ return NULL;
+ }
+ return (const char *) dst;
+}
+#endif
/* Additional declarations needed for IPv6: */
#ifdef ENABLE_IPV6
-/* Missing declaration? */
-extern const char *inet_ntop (int, const void *, char *, size_t);
+const char *inet_ntop (int, const void *, char *, socklen_t);
/* MinGW 3.7 (or older) prototypes gai_strerror(), but is missing
from all import libraries. */
# ifdef __MINGW32__