diff options
Diffstat (limited to 'ext/sockets')
-rw-r--r-- | ext/sockets/config.m4 | 21 | ||||
-rw-r--r-- | ext/sockets/sockaddr_conv.c | 4 |
2 files changed, 21 insertions, 4 deletions
diff --git a/ext/sockets/config.m4 b/ext/sockets/config.m4 index 9c75249646..a5a63dfb61 100644 --- a/ext/sockets/config.m4 +++ b/ext/sockets/config.m4 @@ -16,10 +16,10 @@ if test "$PHP_SOCKETS" != "no"; then if test "$ac_cv_cmsghdr" = yes; then AC_DEFINE(HAVE_CMSGHDR,1,[Whether you have struct cmsghdr]) - fi + fi AC_CHECK_FUNCS([hstrerror socketpair if_nametoindex if_indextoname]) - AC_CHECK_HEADERS([netdb.h netinet/tcp.h sys/un.h sys/sockio.h errno.h]) + AC_CHECK_HEADERS([netdb.h netinet/tcp.h sys/un.h sys/sockio.h errno.h]) AC_TRY_COMPILE([ #include <sys/types.h> #include <sys/socket.h> @@ -27,7 +27,7 @@ if test "$PHP_SOCKETS" != "no"; then [AC_DEFINE(MISSING_MSGHDR_MSGFLAGS, 1, [ ])] ) AC_DEFINE([HAVE_SOCKETS], 1, [ ]) - + dnl Check for fied ss_family in sockaddr_storage (missing in AIX until 5.3) AC_CACHE_CHECK([for field ss_family in struct sockaddr_storage], ac_cv_ss_family, [ @@ -38,11 +38,24 @@ if test "$PHP_SOCKETS" != "no"; then ], [struct sockaddr_storage sa_store; sa_store.ss_family = AF_INET6;], ac_cv_ss_family=yes, ac_cv_ss_family=no) ]) - + if test "$ac_cv_ss_family" = yes; then AC_DEFINE(HAVE_SA_SS_FAMILY,1,[Whether you have sockaddr_storage.ss_family]) fi + dnl Check for AI_V4MAPPED flag + AC_CACHE_CHECK([if getaddrinfo supports AI_V4MAPPED],[ac_cv_gai_ai_v4mapped], + [ + AC_TRY_COMPILE([ +#include <netdb.h> + ], [int flag = AI_V4MAPPED;], + ac_cv_gai_ai_v4mapped=yes, ac_cv_gai_ai_v4mapped=no) + ]) + + if test "$ac_cv_gai_ai_v4mapped" = yes; then + AC_DEFINE(HAVE_AI_V4MAPPED,1,[Whether you have AI_V4MAPPED]) + fi + PHP_NEW_EXTENSION([sockets], [sockets.c multicast.c conversions.c sockaddr_conv.c sendrecvmsg.c], [$ext_shared]) PHP_INSTALL_HEADERS([ext/sockets/], [php_sockets.h]) fi diff --git a/ext/sockets/sockaddr_conv.c b/ext/sockets/sockaddr_conv.c index 64523c3191..bc1131a734 100644 --- a/ext/sockets/sockaddr_conv.c +++ b/ext/sockets/sockaddr_conv.c @@ -27,7 +27,11 @@ int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_ memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_INET6; +#if HAVE_AI_V4MAPPED hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG; +#else + hints.ai_flags = AI_ADDRCONFIG; +#endif getaddrinfo(string, NULL, &hints, &addrinfo); if (!addrinfo) { #ifdef PHP_WIN32 |