From c690c99dd434934a09f38b57d7598c8ecd1231eb Mon Sep 17 00:00:00 2001 From: Patrik Nyblom Date: Wed, 1 Dec 2010 12:08:43 +0100 Subject: Make windows inet_gethost work for ipv6 --- erts/configure.in | 100 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 85 insertions(+), 15 deletions(-) (limited to 'erts/configure.in') diff --git a/erts/configure.in b/erts/configure.in index 8d629c25ae..544ff9790a 100644 --- a/erts/configure.in +++ b/erts/configure.in @@ -1679,18 +1679,66 @@ LIBS="$LIBS $EMU_THR_X_LIBS" dnl Check if we have these, in which case we'll try to build dnl inet_gethost with ipv6 support. -AC_CHECK_FUNC(getaddrinfo, have_getaddrinfo=yes, have_getaddrinfo=no) +AC_CHECK_HEADERS(windows.h) +AC_CHECK_HEADERS(winsock2.h) +AC_CHECK_HEADERS(ws2tcpip.h,[],[],[ +#ifdef HAVE_WINSOCK2_H +#include +#endif +#ifdef HAVE_WINDOWS_H +#include +#endif +]) +dnl AC_CHECK_FUNC(getaddrinfo, have_getaddrinfo=yes, have_getaddrinfo=no) +AC_MSG_CHECKING(for getaddrinfo) +AC_TRY_LINK([ +#include +#include +#ifdef HAVE_WINSOCK2_H +#include +#endif +#ifdef HAVE_WINDOWS_H +#include +#endif +#ifdef HAVE_WS2TCPIP_H +#include +#endif +#ifndef __WIN32__ +#include +#include +#endif +], +[ +getaddrinfo("","",NULL,NULL); +],have_getaddrinfo=yes, have_getaddrinfo=no) if test $have_getaddrinfo = yes; then + AC_MSG_RESULT([yes]) AC_MSG_CHECKING([whether getaddrinfo accepts enough flags]) - AC_TRY_RUN([ + AC_TRY_COMPILE([ #include #include +#ifdef HAVE_WINSOCK2_H +#include +#endif +#ifdef HAVE_WINDOWS_H +#include +#endif +#ifdef HAVE_WS2TCPIP_H +#include +#endif +#ifndef __WIN32__ #include #include -int main(int argc, char **argv) { +#endif +], +[ struct addrinfo hints, *ai; memset(&hints, 0, sizeof(hints)); +#ifndef __WIN32__ hints.ai_flags = (AI_CANONNAME|AI_V4MAPPED|AI_ADDRCONFIG); +#else + hints.ai_flags = AI_CANONNAME; +#endif hints.ai_socktype = SOCK_STREAM; hints.ai_family = AF_INET6; if (getaddrinfo("::", NULL, &hints, &ai) == 0) { @@ -1699,26 +1747,48 @@ int main(int argc, char **argv) { } else { exit(1); } -} - ],, have_getaddrinfo=no, - [ - case X$erl_xcomp_getaddrinfo in - X) have_getaddrinfo=cross;; - Xyes|Xno) have_getaddrinfo=$erl_xcomp_getaddrinfo;; - *) AC_MSG_ERROR([Bad erl_xcomp_getaddrinfo value: $erl_xcomp_getaddrinfo]);; - esac - ]) +],, have_getaddrinfo=no) AC_MSG_RESULT($have_getaddrinfo) case $have_getaddrinfo in yes) AC_DEFINE(HAVE_GETADDRINFO, [1], [Define to 1 if you have a good `getaddrinfo' function.]);; - cross) - AC_MSG_WARN([result no guessed because of cross compilation]);; *) ;; esac +else + AC_MSG_RESULT([no]) fi -AC_CHECK_FUNCS([getnameinfo getipnodebyname getipnodebyaddr gethostbyname2]) +AC_MSG_CHECKING(for getnameinfo) +AC_TRY_LINK([ +#include +#include +#ifdef HAVE_WINSOCK2_H +#include +#endif +#ifdef HAVE_WINDOWS_H +#include +#endif +#ifdef HAVE_WS2TCPIP_H +#include +#endif +#ifndef __WIN32__ +#include +#include +#endif +], +[ +getnameinfo(NULL,0,NULL,0,NULL,0,0); +],have_getnameinfo=yes, have_getnameinfo=no) +if test $have_getnameinfo = yes; then + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_GETNAMEINFO, [1], + [Define to 1 if you have a good `getnameinfo' function.]) +else + AC_MSG_RESULT([no]) +fi + + +AC_CHECK_FUNCS([getipnodebyname getipnodebyaddr gethostbyname2]) AC_CHECK_FUNCS([ieee_handler fpsetmask finite isnan isinf res_gethostbyname dlopen \ pread pwrite writev memmove strerror strerror_r strncasecmp \ -- cgit v1.2.3 From 0d79832e450c49e51f5fd7149f5f72930ef1f966 Mon Sep 17 00:00:00 2001 From: Raimo Niskanen Date: Thu, 2 Dec 2010 16:49:19 +0100 Subject: Stop using uncertain flags for getaddrinfo() The AI_V4MAPPED flag is falling out of grace in modern IPv6 stacks, for security reasons, e.g. FreeBSD do not document it any longer. The AI_ADDRCONFIG flag have got unclear semantics on the same OS. --- erts/configure.in | 4 ---- 1 file changed, 4 deletions(-) (limited to 'erts/configure.in') diff --git a/erts/configure.in b/erts/configure.in index 544ff9790a..f99a86a899 100644 --- a/erts/configure.in +++ b/erts/configure.in @@ -1734,11 +1734,7 @@ if test $have_getaddrinfo = yes; then [ struct addrinfo hints, *ai; memset(&hints, 0, sizeof(hints)); -#ifndef __WIN32__ - hints.ai_flags = (AI_CANONNAME|AI_V4MAPPED|AI_ADDRCONFIG); -#else hints.ai_flags = AI_CANONNAME; -#endif hints.ai_socktype = SOCK_STREAM; hints.ai_family = AF_INET6; if (getaddrinfo("::", NULL, &hints, &ai) == 0) { -- cgit v1.2.3