summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriele Svelto <gabriele.svelto@gmail.com>2012-03-11 10:21:12 +0100
committerMartin Sustrik <sustrik@250bpm.com>2012-03-13 10:29:10 +0100
commit224b7c7a816010fc0f781372051ec7c578af42a0 (patch)
tree1f125fc580616b437ce1b601bfaf0a7f0690f243
parent1c4afc25e2fb9e081013edbaadcacb361c998bec (diff)
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 <gabriele.svelto@gmail.com>
-rw-r--r--src/tcp_address.cpp8
1 files 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.