Commit 27507991 authored by Ondřej Surý's avatar Ondřej Surý

Assume socklen_t is always available on all supported platforms (except on...

Assume socklen_t is always available on all supported platforms (except on Windows where it is typedefed to int32_t)
parent 7e25330b
...@@ -17,9 +17,6 @@ ...@@ -17,9 +17,6 @@
***/ ***/
@TOP@ @TOP@
/* Define to the length type used by the socket API (socklen_t, size_t, int). */
#undef ISC_SOCKADDR_LEN_T
/* Define if threads need PTHREAD_SCOPE_SYSTEM */ /* Define if threads need PTHREAD_SCOPE_SYSTEM */
#undef NEED_PTHREAD_SCOPE_SYSTEM #undef NEED_PTHREAD_SCOPE_SYSTEM
......
...@@ -175,7 +175,7 @@ main(int argc, char **argv) { ...@@ -175,7 +175,7 @@ main(int argc, char **argv) {
int s; int s;
int n = -1; int n = -1;
int v6only = -1; int v6only = -1;
ISC_SOCKADDR_LEN_T len = sizeof(v6only); socklen_t len = sizeof(v6only);
s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
if (s >= 0) { if (s >= 0) {
......
...@@ -17,9 +17,6 @@ ...@@ -17,9 +17,6 @@
*** it does not get installed. *** it does not get installed.
***/ ***/
/* Define to the length type used by the socket API (socklen_t, size_t, int). */
#undef ISC_SOCKADDR_LEN_T
/* Define if threads need PTHREAD_SCOPE_SYSTEM */ /* Define if threads need PTHREAD_SCOPE_SYSTEM */
#undef NEED_PTHREAD_SCOPE_SYSTEM #undef NEED_PTHREAD_SCOPE_SYSTEM
......
...@@ -759,7 +759,6 @@ GEOIPLINKOBJS ...@@ -759,7 +759,6 @@ GEOIPLINKOBJS
GEOIPLINKSRCS GEOIPLINKSRCS
ISC_PLATFORM_NORETURN_POST ISC_PLATFORM_NORETURN_POST
ISC_PLATFORM_NORETURN_PRE ISC_PLATFORM_NORETURN_PRE
ISC_SOCKADDR_LEN_T
expanded_sysconfdir expanded_sysconfdir
PYTHON_INSTALL_LIB PYTHON_INSTALL_LIB
PYTHON_INSTALL_DIR PYTHON_INSTALL_DIR
...@@ -13732,43 +13731,6 @@ fi ...@@ -13732,43 +13731,6 @@ fi
ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "
#include <sys/types.h>
#include <sys/socket.h>
"
if test "x$ac_cv_type_socklen_t" = xyes; then :
$as_echo "#define ISC_SOCKADDR_LEN_T socklen_t" >>confdefs.h
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/types.h>
#include <sys/socket.h>
int getsockname(int, struct sockaddr *, size_t *);
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
$as_echo "#define ISC_SOCKADDR_LEN_T size_t" >>confdefs.h
else
$as_echo "#define ISC_SOCKADDR_LEN_T int" >>confdefs.h
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5
$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; }
if ${ac_cv_header_time+:} false; then : if ${ac_cv_header_time+:} false; then :
......
...@@ -477,23 +477,6 @@ AC_TYPE_SIZE_T ...@@ -477,23 +477,6 @@ AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T AC_TYPE_SSIZE_T
AC_TYPE_UINTPTR_T AC_TYPE_UINTPTR_T
AC_CHECK_TYPE(socklen_t,
[AC_DEFINE(ISC_SOCKADDR_LEN_T, socklen_t)],
[
AC_TRY_COMPILE(
[
#include <sys/types.h>
#include <sys/socket.h>
int getsockname(int, struct sockaddr *, size_t *);
],[],
[AC_DEFINE(ISC_SOCKADDR_LEN_T, size_t)],
[AC_DEFINE(ISC_SOCKADDR_LEN_T, int)])
],
[
#include <sys/types.h>
#include <sys/socket.h>
])
AC_SUBST(ISC_SOCKADDR_LEN_T)
AC_HEADER_TIME AC_HEADER_TIME
# #
......
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
#include <isc/string.h> #include <isc/string.h>
#include <isc/util.h> #include <isc/util.h>
#ifndef ISC_SOCKADDR_LEN_T #ifndef socklen_t
#define ISC_SOCKADDR_LEN_T unsigned int #define socklen_t unsigned int
#endif #endif
/*% /*%
...@@ -366,24 +366,24 @@ isc_net_probe_ipv6pktinfo(void) { ...@@ -366,24 +366,24 @@ isc_net_probe_ipv6pktinfo(void) {
#if ISC_CMSG_IP_TOS || defined(IPV6_TCLASS) #if ISC_CMSG_IP_TOS || defined(IPV6_TCLASS)
static inline ISC_SOCKADDR_LEN_T static inline socklen_t
cmsg_len(ISC_SOCKADDR_LEN_T len) { cmsg_len(socklen_t len) {
#ifdef CMSG_LEN #ifdef CMSG_LEN
return (CMSG_LEN(len)); return (CMSG_LEN(len));
#else #else
ISC_SOCKADDR_LEN_T hdrlen; socklen_t hdrlen;
/* /*
* Cast NULL so that any pointer arithmetic performed by CMSG_DATA * Cast NULL so that any pointer arithmetic performed by CMSG_DATA
* is correct. * is correct.
*/ */
hdrlen = (ISC_SOCKADDR_LEN_T)CMSG_DATA(((struct cmsghdr *)NULL)); hdrlen = (socklen_t)CMSG_DATA(((struct cmsghdr *)NULL));
return (hdrlen + len); return (hdrlen + len);
#endif #endif
} }
static inline ISC_SOCKADDR_LEN_T static inline socklen_t
cmsg_space(ISC_SOCKADDR_LEN_T len) { cmsg_space(socklen_t len) {
#ifdef CMSG_SPACE #ifdef CMSG_SPACE
return (CMSG_SPACE(len)); return (CMSG_SPACE(len));
#else #else
...@@ -448,7 +448,7 @@ static bool ...@@ -448,7 +448,7 @@ static bool
cmsgsend(int s, int level, int type, struct addrinfo *res) { cmsgsend(int s, int level, int type, struct addrinfo *res) {
char strbuf[ISC_STRERRORSIZE]; char strbuf[ISC_STRERRORSIZE];
struct sockaddr_storage ss; struct sockaddr_storage ss;
ISC_SOCKADDR_LEN_T len = sizeof(ss); socklen_t len = sizeof(ss);
struct msghdr msg; struct msghdr msg;
union { union {
struct cmsghdr h; struct cmsghdr h;
......
...@@ -207,8 +207,8 @@ typedef enum { poll_idle, poll_active, poll_checking } pollstate_t; ...@@ -207,8 +207,8 @@ typedef enum { poll_idle, poll_active, poll_checking } pollstate_t;
* Some systems define the socket length argument as an int, some as size_t, * Some systems define the socket length argument as an int, some as size_t,
* some as socklen_t. This is here so it can be easily changed if needed. * some as socklen_t. This is here so it can be easily changed if needed.
*/ */
#ifndef ISC_SOCKADDR_LEN_T #ifndef socklen_t
#define ISC_SOCKADDR_LEN_T unsigned int #define socklen_t unsigned int
#endif #endif
/*% /*%
...@@ -1195,24 +1195,24 @@ make_nonblock(int fd) { ...@@ -1195,24 +1195,24 @@ make_nonblock(int fd) {
* Note that cmsg_space() could run slow on OSes that do not have * Note that cmsg_space() could run slow on OSes that do not have
* CMSG_SPACE. * CMSG_SPACE.
*/ */
static inline ISC_SOCKADDR_LEN_T static inline socklen_t
cmsg_len(ISC_SOCKADDR_LEN_T len) { cmsg_len(socklen_t len) {
#ifdef CMSG_LEN #ifdef CMSG_LEN
return (CMSG_LEN(len)); return (CMSG_LEN(len));
#else #else
ISC_SOCKADDR_LEN_T hdrlen; socklen_t hdrlen;
/* /*
* Cast NULL so that any pointer arithmetic performed by CMSG_DATA * Cast NULL so that any pointer arithmetic performed by CMSG_DATA
* is correct. * is correct.
*/ */
hdrlen = (ISC_SOCKADDR_LEN_T)CMSG_DATA(((struct cmsghdr *)NULL)); hdrlen = (socklen_t)CMSG_DATA(((struct cmsghdr *)NULL));
return (hdrlen + len); return (hdrlen + len);
#endif #endif
} }
static inline ISC_SOCKADDR_LEN_T static inline socklen_t
cmsg_space(ISC_SOCKADDR_LEN_T len) { cmsg_space(socklen_t len) {
#ifdef CMSG_SPACE #ifdef CMSG_SPACE
return (CMSG_SPACE(len)); return (CMSG_SPACE(len));
#else #else
...@@ -2274,7 +2274,7 @@ static void ...@@ -2274,7 +2274,7 @@ static void
set_rcvbuf(void) { set_rcvbuf(void) {
int fd; int fd;
int max = rcvbuf, min; int max = rcvbuf, min;
ISC_SOCKADDR_LEN_T len; socklen_t len;
fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (fd == -1) { if (fd == -1) {
...@@ -2328,7 +2328,7 @@ static void ...@@ -2328,7 +2328,7 @@ static void
set_sndbuf(void) { set_sndbuf(void) {
int fd; int fd;
int max = sndbuf, min; int max = sndbuf, min;
ISC_SOCKADDR_LEN_T len; socklen_t len;
fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
#if defined(ISC_PLATFORM_HAVEIPV6) #if defined(ISC_PLATFORM_HAVEIPV6)
...@@ -2463,7 +2463,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, ...@@ -2463,7 +2463,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
int on = 1; int on = 1;
#endif #endif
#if defined(SO_RCVBUF) || defined(SO_SNDBUF) #if defined(SO_RCVBUF) || defined(SO_SNDBUF)
ISC_SOCKADDR_LEN_T optlen; socklen_t optlen;
int size = 0; int size = 0;
#endif #endif
...@@ -3412,7 +3412,7 @@ internal_accept(isc_task_t *me, isc_event_t *ev) { ...@@ -3412,7 +3412,7 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
isc__socketmgr_t *manager; isc__socketmgr_t *manager;
isc_socket_newconnev_t *dev; isc_socket_newconnev_t *dev;
isc_task_t *task; isc_task_t *task;
ISC_SOCKADDR_LEN_T addrlen; socklen_t addrlen;
int fd; int fd;
isc_result_t result = ISC_R_SUCCESS; isc_result_t result = ISC_R_SUCCESS;
char strbuf[ISC_STRERRORSIZE]; char strbuf[ISC_STRERRORSIZE];
...@@ -5812,7 +5812,7 @@ internal_connect(isc_task_t *me, isc_event_t *ev) { ...@@ -5812,7 +5812,7 @@ internal_connect(isc_task_t *me, isc_event_t *ev) {
isc_socket_connev_t *dev; isc_socket_connev_t *dev;
int cc; int cc;
isc_result_t result; isc_result_t result;
ISC_SOCKADDR_LEN_T optlen; socklen_t optlen;
char strbuf[ISC_STRERRORSIZE]; char strbuf[ISC_STRERRORSIZE];
char peerbuf[ISC_SOCKADDR_FORMATSIZE]; char peerbuf[ISC_SOCKADDR_FORMATSIZE];
...@@ -5948,7 +5948,7 @@ isc__socket_getpeername(isc_socket_t *sock0, isc_sockaddr_t *addressp) { ...@@ -5948,7 +5948,7 @@ isc__socket_getpeername(isc_socket_t *sock0, isc_sockaddr_t *addressp) {
isc_result_t isc_result_t
isc__socket_getsockname(isc_socket_t *sock0, isc_sockaddr_t *addressp) { isc__socket_getsockname(isc_socket_t *sock0, isc_sockaddr_t *addressp) {
isc__socket_t *sock = (isc__socket_t *)sock0; isc__socket_t *sock = (isc__socket_t *)sock0;
ISC_SOCKADDR_LEN_T len; socklen_t len;
isc_result_t result; isc_result_t result;
char strbuf[ISC_STRERRORSIZE]; char strbuf[ISC_STRERRORSIZE];
...@@ -6304,7 +6304,7 @@ isc_socketmgr_renderxml(isc_socketmgr_t *mgr0, xmlTextWriterPtr writer) { ...@@ -6304,7 +6304,7 @@ isc_socketmgr_renderxml(isc_socketmgr_t *mgr0, xmlTextWriterPtr writer) {
isc__socket_t *sock = NULL; isc__socket_t *sock = NULL;
char peerbuf[ISC_SOCKADDR_FORMATSIZE]; char peerbuf[ISC_SOCKADDR_FORMATSIZE];
isc_sockaddr_t addr; isc_sockaddr_t addr;
ISC_SOCKADDR_LEN_T len; socklen_t len;
int xmlrc; int xmlrc;
LOCK(&mgr->lock); LOCK(&mgr->lock);
...@@ -6416,7 +6416,7 @@ isc_socketmgr_renderjson(isc_socketmgr_t *mgr0, json_object *stats) { ...@@ -6416,7 +6416,7 @@ isc_socketmgr_renderjson(isc_socketmgr_t *mgr0, json_object *stats) {
isc__socket_t *sock = NULL; isc__socket_t *sock = NULL;
char peerbuf[ISC_SOCKADDR_FORMATSIZE]; char peerbuf[ISC_SOCKADDR_FORMATSIZE];
isc_sockaddr_t addr; isc_sockaddr_t addr;
ISC_SOCKADDR_LEN_T len; socklen_t len;
json_object *obj, *array = json_object_new_array(); json_object *obj, *array = json_object_new_array();
CHECKMEM(array); CHECKMEM(array);
......
...@@ -34,6 +34,10 @@ ...@@ -34,6 +34,10 @@
#ifndef strtoull #ifndef strtoull
#define strtoull _strtoui64 #define strtoull _strtoui64
#endif #endif
#include <stdint.h>
typedef uint32_t socklen_t;
#endif #endif
/*** /***
......
...@@ -112,14 +112,6 @@ static void consistent(isc_socket_t *sock); ...@@ -112,14 +112,6 @@ static void consistent(isc_socket_t *sock);
#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12) #define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12)
#endif #endif
/*
* Some systems define the socket length argument as an int, some as size_t,
* some as socklen_t. This is here so it can be easily changed if needed.
*/
#ifndef ISC_SOCKADDR_LEN_T
#define ISC_SOCKADDR_LEN_T unsigned int
#endif
/* /*
* Define what the possible "soft" errors can be. These are non-fatal returns * Define what the possible "soft" errors can be. These are non-fatal returns
* of various network related functions, like recv() and so on. * of various network related functions, like recv() and so on.
...@@ -1649,7 +1641,7 @@ socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, ...@@ -1649,7 +1641,7 @@ socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
int on = 1; int on = 1;
#endif #endif
#if defined(SO_RCVBUF) #if defined(SO_RCVBUF)
ISC_SOCKADDR_LEN_T optlen; socklen_t optlen;
int size; int size;
#endif #endif
int socket_errno; int socket_errno;
...@@ -3655,7 +3647,7 @@ isc__socket_getpeername(isc_socket_t *sock, isc_sockaddr_t *addressp) { ...@@ -3655,7 +3647,7 @@ isc__socket_getpeername(isc_socket_t *sock, isc_sockaddr_t *addressp) {
isc_result_t isc_result_t
isc__socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp) { isc__socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp) {
ISC_SOCKADDR_LEN_T len; socklen_t len;
isc_result_t result; isc_result_t result;
char strbuf[ISC_STRERRORSIZE]; char strbuf[ISC_STRERRORSIZE];
...@@ -4007,7 +3999,7 @@ isc_socketmgr_renderxml(isc_socketmgr_t *mgr, xmlTextWriterPtr writer) ...@@ -4007,7 +3999,7 @@ isc_socketmgr_renderxml(isc_socketmgr_t *mgr, xmlTextWriterPtr writer)
isc_socket_t *sock = NULL; isc_socket_t *sock = NULL;
char peerbuf[ISC_SOCKADDR_FORMATSIZE]; char peerbuf[ISC_SOCKADDR_FORMATSIZE];
isc_sockaddr_t addr; isc_sockaddr_t addr;
ISC_SOCKADDR_LEN_T len; socklen_t len;
int xmlrc; int xmlrc;
LOCK(&mgr->lock); LOCK(&mgr->lock);
...@@ -4118,7 +4110,7 @@ isc_socketmgr_renderjson(isc_socketmgr_t *mgr, json_object *stats) { ...@@ -4118,7 +4110,7 @@ isc_socketmgr_renderjson(isc_socketmgr_t *mgr, json_object *stats) {
isc_socket_t *sock = NULL; isc_socket_t *sock = NULL;
char peerbuf[ISC_SOCKADDR_FORMATSIZE]; char peerbuf[ISC_SOCKADDR_FORMATSIZE];
isc_sockaddr_t addr; isc_sockaddr_t addr;
ISC_SOCKADDR_LEN_T len; socklen_t len;
json_object *obj, *array = json_object_new_array(); json_object *obj, *array = json_object_new_array();
CHECKMEM(array); CHECKMEM(array);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment