socket_util: check if IN6_IS_ADDR_V4MAPPED is defined

On some systems, the macro IN6_IS_ADDR_V4MAPPED() is not available.
Don't try to convert IPv6 to their IPV4 equivalents in this case.
This commit is contained in:
Max Kellermann 2009-03-06 10:09:10 +01:00
parent 38ead091f9
commit 4c3ce9ef1c
1 changed files with 2 additions and 2 deletions

View File

@ -33,14 +33,14 @@
char * char *
sockaddr_to_string(const struct sockaddr *sa, size_t length, GError **error) sockaddr_to_string(const struct sockaddr *sa, size_t length, GError **error)
{ {
#ifdef HAVE_IPV6 #if defined(HAVE_IPV6) && defined(IN6_IS_ADDR_V4MAPPED)
const struct sockaddr_in6 *a6 = (const struct sockaddr_in6 *)sa; const struct sockaddr_in6 *a6 = (const struct sockaddr_in6 *)sa;
struct sockaddr_in a4; struct sockaddr_in a4;
#endif #endif
int ret; int ret;
char host[NI_MAXHOST], serv[NI_MAXSERV]; char host[NI_MAXHOST], serv[NI_MAXSERV];
#ifdef HAVE_IPV6 #if defined(HAVE_IPV6) && defined(IN6_IS_ADDR_V4MAPPED)
if (sa->sa_family == AF_INET6 && if (sa->sa_family == AF_INET6 &&
IN6_IS_ADDR_V4MAPPED(&a6->sin6_addr)) { IN6_IS_ADDR_V4MAPPED(&a6->sin6_addr)) {
/* convert "::ffff:127.0.0.1" to "127.0.0.1" */ /* convert "::ffff:127.0.0.1" to "127.0.0.1" */