diff --git a/src/socket_util.c b/src/socket_util.c index 0fea281f0..0b38a1468 100644 --- a/src/socket_util.c +++ b/src/socket_util.c @@ -33,14 +33,14 @@ char * 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; struct sockaddr_in a4; #endif int ret; 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 && IN6_IS_ADDR_V4MAPPED(&a6->sin6_addr)) { /* convert "::ffff:127.0.0.1" to "127.0.0.1" */