Use CURL_CHECK_FUNC_GETNAMEINFO results in CURL_CHECK_NI_WITHSCOPEID
This commit is contained in:
Родитель
4c08eb4b11
Коммит
bec1977137
117
acinclude.m4
117
acinclude.m4
|
@ -422,45 +422,106 @@ AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
|
|||
]) # AC_DEFUN
|
||||
|
||||
|
||||
dnl TYPE_SOCKADDR_STORAGE
|
||||
dnl -------------------------------------------------
|
||||
dnl Check for struct sockaddr_storage. Most IPv6-enabled
|
||||
dnl hosts have it, but AIX 4.3 is one known exception.
|
||||
|
||||
AC_DEFUN([TYPE_SOCKADDR_STORAGE],
|
||||
[
|
||||
AC_CHECK_TYPE([struct sockaddr_storage],
|
||||
AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
|
||||
[if struct sockaddr_storage is defined]), ,
|
||||
[
|
||||
#undef inline
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
#else
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#endif
|
||||
])
|
||||
])
|
||||
|
||||
|
||||
dnl CURL_CHECK_NI_WITHSCOPEID
|
||||
dnl -------------------------------------------------
|
||||
dnl Check for working NI_WITHSCOPEID in getnameinfo()
|
||||
|
||||
AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
|
||||
AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
|
||||
AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
|
||||
AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
|
||||
netdb.h netinet/in.h arpa/inet.h)
|
||||
#
|
||||
AC_CACHE_CHECK([for working NI_WITHSCOPEID],
|
||||
[ac_cv_working_ni_withscopeid], [
|
||||
AC_RUN_IFELSE([
|
||||
AC_LANG_PROGRAM([
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETDB_H
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
],[
|
||||
#ifdef NI_WITHSCOPEID
|
||||
struct sockaddr_storage ss;
|
||||
int sslen = sizeof(ss);
|
||||
#if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
|
||||
#ifdef HAVE_STRUCT_SOCKADDR_STORAGE
|
||||
struct sockaddr_storage sa;
|
||||
#else
|
||||
unsigned char sa[256];
|
||||
#endif
|
||||
char hostbuf[NI_MAXHOST];
|
||||
int rc;
|
||||
char hbuf[NI_MAXHOST];
|
||||
GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
|
||||
GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
|
||||
GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
|
||||
int fd = socket(AF_INET6, SOCK_STREAM, 0);
|
||||
if(fd < 0) {
|
||||
perror("socket()");
|
||||
return 1; /* Error creating socket */
|
||||
}
|
||||
rc = getsockname(fd, (struct sockaddr *)&ss, &sslen);
|
||||
rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
|
||||
if(rc) {
|
||||
perror("getsockname()");
|
||||
return 2; /* Error retrieving socket name */
|
||||
}
|
||||
rc = getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf),
|
||||
NULL, 0,
|
||||
NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID);
|
||||
rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
|
||||
if(rc) {
|
||||
printf("rc = %s\n", gai_strerror(rc));
|
||||
return 3; /* Error translating socket address */
|
||||
}
|
||||
return 0; /* Ok, NI_WITHSCOPEID works */
|
||||
#else
|
||||
return 4; /* Error, NI_WITHSCOPEID not defined */
|
||||
return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
|
||||
#endif
|
||||
]) # AC_LANG_PROGRAM
|
||||
],[
|
||||
|
@ -474,7 +535,6 @@ AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
|
|||
# NI_WITHSCOPEID will work if we are able to compile it.
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_PROGRAM([
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
|
@ -637,43 +697,6 @@ dnl end of non-blocking try-compile test
|
|||
])
|
||||
|
||||
|
||||
dnl TYPE_SOCKADDR_STORAGE
|
||||
dnl -------------------------------------------------
|
||||
dnl Check for struct sockaddr_storage. Most IPv6-enabled hosts have it, but
|
||||
dnl AIX 4.3 is one known exception.
|
||||
AC_DEFUN([TYPE_SOCKADDR_STORAGE],
|
||||
[
|
||||
AC_CHECK_TYPE([struct sockaddr_storage],
|
||||
AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
|
||||
[if struct sockaddr_storage is defined]), ,
|
||||
[
|
||||
#undef inline
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
#else
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#endif
|
||||
])
|
||||
])
|
||||
|
||||
|
||||
dnl TYPE_IN_ADDR_T
|
||||
dnl -------------------------------------------------
|
||||
dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
|
||||
|
|
|
@ -401,45 +401,106 @@ AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
|
|||
]) # AC_DEFUN
|
||||
|
||||
|
||||
dnl TYPE_SOCKADDR_STORAGE
|
||||
dnl -------------------------------------------------
|
||||
dnl Check for struct sockaddr_storage. Most IPv6-enabled
|
||||
dnl hosts have it, but AIX 4.3 is one known exception.
|
||||
|
||||
AC_DEFUN([TYPE_SOCKADDR_STORAGE],
|
||||
[
|
||||
AC_CHECK_TYPE([struct sockaddr_storage],
|
||||
AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
|
||||
[if struct sockaddr_storage is defined]), ,
|
||||
[
|
||||
#undef inline
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
#else
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#endif
|
||||
])
|
||||
])
|
||||
|
||||
|
||||
dnl CURL_CHECK_NI_WITHSCOPEID
|
||||
dnl -------------------------------------------------
|
||||
dnl Check for working NI_WITHSCOPEID in getnameinfo()
|
||||
|
||||
AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
|
||||
AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
|
||||
AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
|
||||
AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
|
||||
netdb.h netinet/in.h arpa/inet.h)
|
||||
#
|
||||
AC_CACHE_CHECK([for working NI_WITHSCOPEID],
|
||||
[ac_cv_working_ni_withscopeid], [
|
||||
AC_RUN_IFELSE([
|
||||
AC_LANG_PROGRAM([
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETDB_H
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
],[
|
||||
#ifdef NI_WITHSCOPEID
|
||||
struct sockaddr_storage ss;
|
||||
int sslen = sizeof(ss);
|
||||
#if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
|
||||
#ifdef HAVE_STRUCT_SOCKADDR_STORAGE
|
||||
struct sockaddr_storage sa;
|
||||
#else
|
||||
unsigned char sa[256];
|
||||
#endif
|
||||
char hostbuf[NI_MAXHOST];
|
||||
int rc;
|
||||
char hbuf[NI_MAXHOST];
|
||||
GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
|
||||
GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
|
||||
GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
|
||||
int fd = socket(AF_INET6, SOCK_STREAM, 0);
|
||||
if(fd < 0) {
|
||||
perror("socket()");
|
||||
return 1; /* Error creating socket */
|
||||
}
|
||||
rc = getsockname(fd, (struct sockaddr *)&ss, &sslen);
|
||||
rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
|
||||
if(rc) {
|
||||
perror("getsockname()");
|
||||
return 2; /* Error retrieving socket name */
|
||||
}
|
||||
rc = getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf),
|
||||
NULL, 0,
|
||||
NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID);
|
||||
rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
|
||||
if(rc) {
|
||||
printf("rc = %s\n", gai_strerror(rc));
|
||||
return 3; /* Error translating socket address */
|
||||
}
|
||||
return 0; /* Ok, NI_WITHSCOPEID works */
|
||||
#else
|
||||
return 4; /* Error, NI_WITHSCOPEID not defined */
|
||||
return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
|
||||
#endif
|
||||
]) # AC_LANG_PROGRAM
|
||||
],[
|
||||
|
@ -453,7 +514,6 @@ AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
|
|||
# NI_WITHSCOPEID will work if we are able to compile it.
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_PROGRAM([
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
|
|
|
@ -537,10 +537,6 @@ main()
|
|||
|
||||
if test "$ipv6" = "yes"; then
|
||||
curl_ipv6_msg="enabled"
|
||||
|
||||
CURL_CHECK_WORKING_GETADDRINFO
|
||||
|
||||
CURL_CHECK_NI_WITHSCOPEID
|
||||
fi
|
||||
|
||||
dnl **********************************************************************
|
||||
|
@ -1689,6 +1685,11 @@ dnl Check if the getnameinfo function is available
|
|||
dnl and get the types of five of its arguments.
|
||||
CURL_CHECK_FUNC_GETNAMEINFO
|
||||
|
||||
if test "$ipv6" = "yes"; then
|
||||
CURL_CHECK_WORKING_GETADDRINFO
|
||||
CURL_CHECK_NI_WITHSCOPEID
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([if we are Mac OS X (to disable poll)])
|
||||
disable_poll=no
|
||||
case $host in
|
||||
|
|
Загрузка…
Ссылка в новой задаче