Use build-time configured ares_socklen_t instead of socklen_t
This commit is contained in:
parent
6ac739630f
commit
80186aa7f4
@ -1,5 +1,8 @@
|
|||||||
Changelog for the c-ares project
|
Changelog for the c-ares project
|
||||||
|
|
||||||
|
* May 2 2009 (Yang Tse)
|
||||||
|
- Use a build-time configured ares_socklen_t data type instead of socklen_t.
|
||||||
|
|
||||||
* April 21 2009 (Yang Tse)
|
* April 21 2009 (Yang Tse)
|
||||||
- Moved potential inclusion of system's malloc.h and memory.h header files to
|
- Moved potential inclusion of system's malloc.h and memory.h header files to
|
||||||
setup_once.h. Inclusion of each header file is based on the definition of
|
setup_once.h. Inclusion of each header file is based on the definition of
|
||||||
|
@ -23,7 +23,7 @@ CFLAGS += -DWATT32 -DHAVE_AF_INET6 -DHAVE_PF_INET6 -DHAVE_IOCTLSOCKET \
|
|||||||
-DRECV_TYPE_ARG1='int' -DRECV_TYPE_ARG2='void*' \
|
-DRECV_TYPE_ARG1='int' -DRECV_TYPE_ARG2='void*' \
|
||||||
-DRECV_TYPE_ARG3='int' -DRECV_TYPE_ARG4='int' \
|
-DRECV_TYPE_ARG3='int' -DRECV_TYPE_ARG4='int' \
|
||||||
-DRECV_TYPE_RETV='int' -DHAVE_STRUCT_TIMEVAL \
|
-DRECV_TYPE_RETV='int' -DHAVE_STRUCT_TIMEVAL \
|
||||||
-Dselect=select_s -Dsocklen_t=int -UHAVE_CONFIG_H \
|
-Dselect=select_s -UHAVE_CONFIG_H \
|
||||||
-DRECVFROM_TYPE_ARG1='int' -DRECVFROM_TYPE_ARG2='void' \
|
-DRECVFROM_TYPE_ARG1='int' -DRECVFROM_TYPE_ARG2='void' \
|
||||||
-DRECVFROM_TYPE_ARG3='int' -DRECVFROM_TYPE_ARG4='int' \
|
-DRECVFROM_TYPE_ARG3='int' -DRECVFROM_TYPE_ARG4='int' \
|
||||||
-DRECVFROM_TYPE_ARG6='int' -DRECVFROM_TYPE_RETV='int' \
|
-DRECVFROM_TYPE_ARG6='int' -DRECVFROM_TYPE_RETV='int' \
|
||||||
|
@ -303,7 +303,6 @@ ifeq ($(LIBARCH),CLIB)
|
|||||||
@echo $(DL)#define SEND_TYPE_ARG3 int$(DL) >> $@
|
@echo $(DL)#define SEND_TYPE_ARG3 int$(DL) >> $@
|
||||||
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
|
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
|
||||||
@echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@
|
@echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@
|
||||||
@echo $(DL)#define socklen_t int$(DL) >> $@
|
|
||||||
else
|
else
|
||||||
@echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@
|
@echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_DLFCN_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_DLFCN_H 1$(DL) >> $@
|
||||||
@ -407,9 +406,6 @@ endif
|
|||||||
@echo $(DL)#else$(DL) >> $@
|
@echo $(DL)#else$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_VARIADIC_MACROS_C99 1$(DL) >> $@
|
@echo $(DL)#define HAVE_VARIADIC_MACROS_C99 1$(DL) >> $@
|
||||||
@echo $(DL)#endif$(DL) >> $@
|
@echo $(DL)#endif$(DL) >> $@
|
||||||
ifdef OLD_NOVELLSDK
|
|
||||||
@echo $(DL)#define socklen_t int$(DL) >> $@
|
|
||||||
endif
|
|
||||||
|
|
||||||
FORCE: ;
|
FORCE: ;
|
||||||
|
|
||||||
|
@ -4,8 +4,9 @@ Changed:
|
|||||||
|
|
||||||
o in6_addr is not used in ares.h anymore, but a private ares_in6_addr is
|
o in6_addr is not used in ares.h anymore, but a private ares_in6_addr is
|
||||||
instead declared and used
|
instead declared and used
|
||||||
p ares_gethostbyname() now supports 'AF_UNSPEC' as a family for resolving
|
o ares_gethostbyname() now supports 'AF_UNSPEC' as a family for resolving
|
||||||
either AF_INET6 or AF_INET
|
either AF_INET6 or AF_INET
|
||||||
|
o a build-time configured ares_socklen_t is now used instead of socklen_t
|
||||||
|
|
||||||
Fixed:
|
Fixed:
|
||||||
|
|
||||||
|
@ -450,94 +450,6 @@ AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
dnl CURL_CHECK_TYPE_SOCKLEN_T
|
|
||||||
dnl -------------------------------------------------
|
|
||||||
dnl Check for existing socklen_t type, and provide
|
|
||||||
dnl an equivalent type if socklen_t not available
|
|
||||||
|
|
||||||
AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
|
|
||||||
AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
|
|
||||||
AC_CHECK_TYPE([socklen_t], ,[
|
|
||||||
dnl socklen_t not available
|
|
||||||
AC_CACHE_CHECK([for socklen_t equivalent],
|
|
||||||
[curl_cv_socklen_t_equiv], [
|
|
||||||
curl_cv_socklen_t_equiv="unknown"
|
|
||||||
for arg1 in 'int' 'SOCKET'; do
|
|
||||||
for arg2 in "struct sockaddr" void; do
|
|
||||||
for t in int size_t unsigned long "unsigned long"; do
|
|
||||||
if test "$curl_cv_socklen_t_equiv" = "unknown"; then
|
|
||||||
AC_COMPILE_IFELSE([
|
|
||||||
AC_LANG_PROGRAM([[
|
|
||||||
#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>
|
|
||||||
#else
|
|
||||||
#ifdef HAVE_WINSOCK_H
|
|
||||||
#include <winsock.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#define GETPEERNCALLCONV PASCAL
|
|
||||||
#else
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
|
||||||
#include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#define GETPEERNCALLCONV
|
|
||||||
#endif
|
|
||||||
extern int GETPEERNCALLCONV getpeername($arg1, $arg2 *, $t *);
|
|
||||||
]],[[
|
|
||||||
$t len=0;
|
|
||||||
getpeername(0,0,&len);
|
|
||||||
]])
|
|
||||||
],[
|
|
||||||
curl_cv_socklen_t_equiv="$t"
|
|
||||||
])
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
done
|
|
||||||
])
|
|
||||||
case "$curl_cv_socklen_t_equiv" in
|
|
||||||
unknown)
|
|
||||||
AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
|
|
||||||
[Type to use in place of socklen_t when system does not provide it.])
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
],[
|
|
||||||
#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>
|
|
||||||
#ifdef HAVE_WS2TCPIP_H
|
|
||||||
#include <ws2tcpip.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
|
||||||
#include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
])
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
dnl CURL_CHECK_FUNC_GETNAMEINFO
|
dnl CURL_CHECK_FUNC_GETNAMEINFO
|
||||||
dnl -------------------------------------------------
|
dnl -------------------------------------------------
|
||||||
dnl Test if the getnameinfo function is available,
|
dnl Test if the getnameinfo function is available,
|
||||||
@ -551,7 +463,6 @@ dnl argument in GETNAMEINFO_QUAL_ARG1.
|
|||||||
|
|
||||||
AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
|
AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
|
||||||
AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
|
AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
|
||||||
AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
|
|
||||||
AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
|
AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
|
||||||
#
|
#
|
||||||
AC_MSG_CHECKING([for getnameinfo])
|
AC_MSG_CHECKING([for getnameinfo])
|
||||||
|
@ -260,7 +260,7 @@ int ares_gethostbyname_file(ares_channel channel, const char *name,
|
|||||||
void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
|
void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
|
||||||
int family, ares_host_callback callback, void *arg);
|
int family, ares_host_callback callback, void *arg);
|
||||||
void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
|
void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
|
||||||
socklen_t salen, int flags,
|
ares_socklen_t salen, int flags,
|
||||||
ares_nameinfo_callback callback,
|
ares_nameinfo_callback callback,
|
||||||
void *arg);
|
void *arg);
|
||||||
int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
|
int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
.\" this software for any purpose. It is provided "as is"
|
.\" this software for any purpose. It is provided "as is"
|
||||||
.\" without express or implied warranty.
|
.\" without express or implied warranty.
|
||||||
.\"
|
.\"
|
||||||
.TH ARES_GETNAMEINFO 3 "16 May 2005"
|
.TH ARES_GETNAMEINFO 3 "1 May 2009"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
ares_getnameinfo \- Address-to-nodename translation in protocol-independent manner
|
ares_getnameinfo \- Address-to-nodename translation in protocol-independent manner
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@ -25,7 +25,7 @@ ares_getnameinfo \- Address-to-nodename translation in protocol-independent mann
|
|||||||
.B int \fItimeouts\fP, char *\fInode\fP, char *\fIservice\fP)
|
.B int \fItimeouts\fP, char *\fInode\fP, char *\fIservice\fP)
|
||||||
.PP
|
.PP
|
||||||
.B void ares_getnameinfo(ares_channel \fIchannel\fP, const struct sockaddr *\fIsa\fP,
|
.B void ares_getnameinfo(ares_channel \fIchannel\fP, const struct sockaddr *\fIsa\fP,
|
||||||
.B socklen_t \fIsalen\fP, int \fIflags\fP, ares_nameinfo_callback \fIcallback\fP,
|
.B ares_socklen_t \fIsalen\fP, int \fIflags\fP, ares_nameinfo_callback \fIcallback\fP,
|
||||||
.B void *\fIarg\fP)
|
.B void *\fIarg\fP)
|
||||||
.fi
|
.fi
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
@ -92,7 +92,8 @@ static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int scopeid,
|
|||||||
#endif
|
#endif
|
||||||
static char *ares_striendstr(const char *s1, const char *s2);
|
static char *ares_striendstr(const char *s1, const char *s2);
|
||||||
|
|
||||||
void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa, socklen_t salen,
|
void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
|
||||||
|
ares_socklen_t salen,
|
||||||
int flags, ares_nameinfo_callback callback, void *arg)
|
int flags, ares_nameinfo_callback callback, void *arg)
|
||||||
{
|
{
|
||||||
struct sockaddr_in *addr = NULL;
|
struct sockaddr_in *addr = NULL;
|
||||||
|
@ -49,7 +49,7 @@ struct addrinfo
|
|||||||
int ai_family;
|
int ai_family;
|
||||||
int ai_socktype;
|
int ai_socktype;
|
||||||
int ai_protocol;
|
int ai_protocol;
|
||||||
socklen_t ai_addrlen; /* Follow rfc3493 struct addrinfo */
|
ares_socklen_t ai_addrlen; /* Follow rfc3493 struct addrinfo */
|
||||||
char *ai_canonname;
|
char *ai_canonname;
|
||||||
struct sockaddr *ai_addr;
|
struct sockaddr *ai_addr;
|
||||||
struct addrinfo *ai_next;
|
struct addrinfo *ai_next;
|
||||||
|
@ -429,7 +429,7 @@ static void read_udp_packets(ares_channel channel, fd_set *read_fds,
|
|||||||
unsigned char buf[PACKETSZ + 1];
|
unsigned char buf[PACKETSZ + 1];
|
||||||
#ifdef HAVE_RECVFROM
|
#ifdef HAVE_RECVFROM
|
||||||
struct sockaddr_in from;
|
struct sockaddr_in from;
|
||||||
socklen_t fromlen;
|
ares_socklen_t fromlen;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(!read_fds && (read_fd == ARES_SOCKET_BAD))
|
if(!read_fds && (read_fd == ARES_SOCKET_BAD))
|
||||||
|
@ -551,9 +551,6 @@ AC_CHECK_TYPE([bool],[
|
|||||||
|
|
||||||
CARES_CONFIGURE_ARES_SOCKLEN_T
|
CARES_CONFIGURE_ARES_SOCKLEN_T
|
||||||
|
|
||||||
# Check for socklen_t or equivalent
|
|
||||||
CURL_CHECK_TYPE_SOCKLEN_T
|
|
||||||
|
|
||||||
TYPE_IN_ADDR_T
|
TYPE_IN_ADDR_T
|
||||||
|
|
||||||
TYPE_SOCKADDR_STORAGE
|
TYPE_SOCKADDR_STORAGE
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/* Copyright (C) 2004 - 2008 by Daniel Stenberg et al
|
/* Copyright (C) 2004 - 2009 by Daniel Stenberg et al
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software and its
|
* Permission to use, copy, modify, and distribute this software and its
|
||||||
* documentation for any purpose and without fee is hereby granted, provided
|
* documentation for any purpose and without fee is hereby granted, provided
|
||||||
@ -99,23 +99,6 @@ struct timeval {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Windows build targets have socklen_t definition in
|
|
||||||
* ws2tcpip.h but some versions of ws2tcpip.h do not
|
|
||||||
* have the definition. It seems that when the socklen_t
|
|
||||||
* definition is missing from ws2tcpip.h the definition
|
|
||||||
* for INET_ADDRSTRLEN is also missing, and that when one
|
|
||||||
* definition is present the other one also is available.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(HAVE_CONFIG_H)
|
|
||||||
# if ( defined(_MSC_VER) && !defined(INET_ADDRSTRLEN) ) || \
|
|
||||||
(!defined(_MSC_VER) && !defined(HAVE_WS2TCPIP_H) )
|
|
||||||
# define socklen_t int
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__minix)
|
#if defined(__minix)
|
||||||
/* Minix doesn't support recv on TCP sockets */
|
/* Minix doesn't support recv on TCP sockets */
|
||||||
#define sread(x,y,z) (ssize_t)read((RECV_TYPE_ARG1)(x), \
|
#define sread(x,y,z) (ssize_t)read((RECV_TYPE_ARG1)(x), \
|
||||||
@ -444,88 +427,5 @@ typedef int sig_atomic_t;
|
|||||||
#define ZERO_NULL 0
|
#define ZERO_NULL 0
|
||||||
|
|
||||||
|
|
||||||
#if defined (__LP64__) && defined(__hpux) && !defined(_XOPEN_SOURCE_EXTENDED)
|
|
||||||
#include <sys/socket.h>
|
|
||||||
/* HP-UX has this oddity where it features a few functions that don't work
|
|
||||||
with socklen_t so we need to convert to ints
|
|
||||||
|
|
||||||
This is due to socklen_t being a 64bit int under 64bit ABI, but the
|
|
||||||
pre-xopen (default) interfaces require an int, which is 32bits.
|
|
||||||
|
|
||||||
Therefore, Anytime socklen_t is passed by pointer, the libc function
|
|
||||||
truncates the 64bit socklen_t value by treating it as a 32bit value.
|
|
||||||
|
|
||||||
|
|
||||||
Note that some socket calls are allowed to have a NULL pointer for
|
|
||||||
the socklen arg.
|
|
||||||
*/
|
|
||||||
|
|
||||||
inline static int Curl_hp_getsockname(int s, struct sockaddr *name,
|
|
||||||
socklen_t *namelen)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
if(namelen) {
|
|
||||||
int len = *namelen;
|
|
||||||
rc = getsockname(s, name, &len);
|
|
||||||
*namelen = len;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
rc = getsockname(s, name, 0);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline static int Curl_hp_getsockopt(int s, int level, int optname,
|
|
||||||
void *optval, socklen_t *optlen)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
if(optlen) {
|
|
||||||
int len = *optlen;
|
|
||||||
rc = getsockopt(s, level, optname, optval, &len);
|
|
||||||
*optlen = len;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
rc = getsockopt(s, level, optname, optval, 0);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline static int Curl_hp_accept(int sockfd, struct sockaddr *addr,
|
|
||||||
socklen_t *addrlen)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
if(addrlen) {
|
|
||||||
int len = *addrlen;
|
|
||||||
rc = accept(sockfd, addr, &len);
|
|
||||||
*addrlen = len;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
rc = accept(sockfd, addr, 0);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline static ssize_t Curl_hp_recvfrom(int s, void *buf, size_t len, int flags,
|
|
||||||
struct sockaddr *from,
|
|
||||||
socklen_t *fromlen)
|
|
||||||
{
|
|
||||||
ssize_t rc;
|
|
||||||
if(fromlen) {
|
|
||||||
int fromlen32 = *fromlen;
|
|
||||||
rc = recvfrom(s, buf, len, flags, from, &fromlen32);
|
|
||||||
*fromlen = fromlen32;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
rc = recvfrom(s, buf, len, flags, from, 0);
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define getsockname(a,b,c) Curl_hp_getsockname((a),(b),(c))
|
|
||||||
#define getsockopt(a,b,c,d,e) Curl_hp_getsockopt((a),(b),(c),(d),(e))
|
|
||||||
#define accept(a,b,c) Curl_hp_accept((a),(b),(c))
|
|
||||||
#define recvfrom(a,b,c,d,e,f) Curl_hp_recvfrom((a),(b),(c),(d),(e),(f))
|
|
||||||
|
|
||||||
#endif /* HPUX work-around */
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __SETUP_ONCE_H */
|
#endif /* __SETUP_ONCE_H */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user