From 224b7c7a816010fc0f781372051ec7c578af42a0 Mon Sep 17 00:00:00 2001 From: Gabriele Svelto Date: Sun, 11 Mar 2012 10:21:12 +0100 Subject: Check for AI_V4MAPPED and don't use it on FreeBSD Check if the constant is defined before using it. While the constant may be defined on FreeBSD, there's no support for the functionality and specifying the flag may cause errors. Signed-off-by: Gabriele Svelto --- src/tcp_address.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/tcp_address.cpp b/src/tcp_address.cpp index 38737c4..a82298d 100644 --- a/src/tcp_address.cpp +++ b/src/tcp_address.cpp @@ -274,7 +274,8 @@ int xs::tcp_address_t::resolve_interface (char const *interface_, // service-name irregularity due to indeterminate socktype. req.ai_flags = AI_PASSIVE | AI_NUMERICHOST; -#ifndef XS_HAVE_WINDOWS +#if defined AI_V4MAPPED && !defined XS_HAVE_WINDOWS && !defined XS_HAVE_FREEBSD + // On FreeBSD, AI_V4MAPPED isn't supported. // Windows by default maps IPv4 addresses into IPv6. In this API we only // require IPv4-mapped addresses when no native IPv6 interfaces are // available (~AI_ALL). This saves an additional DNS roundtrip for IPv4 @@ -319,8 +320,9 @@ int xs::tcp_address_t::resolve_hostname (const char *hostname_, bool ipv4only_) // Need to choose one to avoid duplicate results from getaddrinfo() - this // doesn't really matter, since it's not included in the addr-output. req.ai_socktype = SOCK_STREAM; - -#ifndef XS_HAVE_WINDOWS + +#if defined AI_V4MAPPED && !defined XS_HAVE_WINDOWS && !defined XS_HAVE_FREEBSD + // On FreeBSD, AI_V4MAPPED isn't supported. // Windows by default maps IPv4 addresses into IPv6. In this API we only // require IPv4-mapped addresses when no native IPv6 interfaces are // available. This saves an additional DNS roundtrip for IPv4 addresses. -- cgit v1.2.3