From 194b6a25192581bbc8ec731e32e8989042b202a4 Mon Sep 17 00:00:00 2001 From: Michael Graff Date: Sat, 28 Aug 1999 05:34:41 +0000 Subject: [PATCH] make sendmsg() and recvmsg() work on solaris and hpux through nasty methods --- acconfig.h | 10 +++++- config.h.in | 10 +++++- configure | 74 +++++++++++++++++++++++++------------------ configure.in | 12 +++++-- lib/isc/unix/socket.c | 32 ++++++++++--------- 5 files changed, 87 insertions(+), 51 deletions(-) diff --git a/acconfig.h b/acconfig.h index 489b4203c2..431499d748 100644 --- a/acconfig.h +++ b/acconfig.h @@ -33,5 +33,13 @@ /* define if catgets() is available */ #undef HAVE_CATGETS -/* Define if you have the NET_RT_IFLIST sysctl variable. */ +/* define if you have the NET_RT_IFLIST sysctl variable. */ #undef HAVE_IFLIST_SYSCTL + +/* define if you need to #define _XPG4_2 before including sys/socket.h */ +#undef NEED_XPG4_2_BEFORE_SOCKET_H + +/* define if you need to #define _XOPEN_SOURCE_ENTENDED before including + * sys/socket.h + */ +#undef NEED_XSE_BEFORE_SOCKET_H diff --git a/config.h.in b/config.h.in index b820f10dfd..d630720f20 100644 --- a/config.h.in +++ b/config.h.in @@ -33,9 +33,17 @@ /* define if catgets() is available */ #undef HAVE_CATGETS -/* Define if you have the NET_RT_IFLIST sysctl variable. */ +/* define if you have the NET_RT_IFLIST sysctl variable. */ #undef HAVE_IFLIST_SYSCTL +/* define if you need to #define _XPG4_2 before including sys/socket.h */ +#undef NEED_XPG4_2_BEFORE_SOCKET_H + +/* define if you need to #define _XOPEN_SOURCE_ENTENDED before including + * sys/socket.h + */ +#undef NEED_XSE_BEFORE_SOCKET_H + /* Define if you have the header file. */ #undef HAVE_FCNTL_H diff --git a/configure b/configure index 97e67058a4..bb163da927 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh -# From configure.in Revision: 1.49 +# From configure.in Revision: 1.50 @@ -2056,8 +2056,20 @@ fi case "$host" in *-dec-osf*) - cat >> confdefs.h <<\EOF + cat >> confdefs.h <<\EOF #define _SOCKADDR_LEN 1 +EOF + + ;; + *-sun-solaris*) + cat >> confdefs.h <<\EOF +#define NEED_XPG4_2_BEFORE_SOCKET_H 1 +EOF + + ;; + *-hp-hpux*) + cat >> confdefs.h <<\EOF +#define NEED_XSE_BEFORE_SOCKET_H 1 EOF ;; @@ -2065,9 +2077,9 @@ esac echo $ac_n "checking for sa_len in struct sockaddr""... $ac_c" 1>&6 -echo "configure:2069: checking for sa_len in struct sockaddr" >&5 +echo "configure:2081: checking for sa_len in struct sockaddr" >&5 cat > conftest.$ac_ext < @@ -2076,7 +2088,7 @@ int main() { struct sockaddr sa; sa.sa_len = 0; return (0); ; return 0; } EOF -if { (eval echo configure:2080: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2092: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 ISC_NET_HAVESALEN="#define ISC_NET_HAVESALEN 1" @@ -2092,9 +2104,9 @@ rm -f conftest* echo $ac_n "checking for interface list sysctl""... $ac_c" 1>&6 -echo "configure:2096: checking for interface list sysctl" >&5 +echo "configure:2108: checking for interface list sysctl" >&5 cat > conftest.$ac_ext < @@ -2201,7 +2213,7 @@ else fi echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:2205: checking build system type" >&5 +echo "configure:2217: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -2230,7 +2242,7 @@ ac_prog=ld if test "$ac_cv_prog_gcc" = yes; then # Check if gcc -print-prog-name=ld gives a path. echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6 -echo "configure:2234: checking for ld used by GCC" >&5 +echo "configure:2246: checking for ld used by GCC" >&5 ac_prog=`($CC -print-prog-name=ld) 2>&5` case "$ac_prog" in # Accept absolute paths. @@ -2254,10 +2266,10 @@ echo "configure:2234: checking for ld used by GCC" >&5 esac elif test "$with_gnu_ld" = yes; then echo $ac_n "checking for GNU ld""... $ac_c" 1>&6 -echo "configure:2258: checking for GNU ld" >&5 +echo "configure:2270: checking for GNU ld" >&5 else echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 -echo "configure:2261: checking for non-GNU ld" >&5 +echo "configure:2273: checking for non-GNU ld" >&5 fi if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2293,7 +2305,7 @@ fi test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; } echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6 -echo "configure:2297: checking if the linker ($LD) is GNU ld" >&5 +echo "configure:2309: checking if the linker ($LD) is GNU ld" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gnu_ld'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2309,7 +2321,7 @@ echo "$ac_t""$ac_cv_prog_gnu_ld" 1>&6 echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6 -echo "configure:2313: checking for BSD-compatible nm" >&5 +echo "configure:2325: checking for BSD-compatible nm" >&5 if eval "test \"`echo '$''{'ac_cv_path_NM'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2346,7 +2358,7 @@ echo "$ac_t""$NM" 1>&6 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:2350: checking whether ln -s works" >&5 +echo "configure:2362: checking whether ln -s works" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2390,8 +2402,8 @@ test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" case "$host" in *-*-irix6*) # Find out which ABI we are using. - echo '#line 2394 "configure"' > conftest.$ac_ext - if { (eval echo configure:2395: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + echo '#line 2406 "configure"' > conftest.$ac_ext + if { (eval echo configure:2407: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then case "`/usr/bin/file conftest.o`" in *32-bit*) LD="${LD-ld} -32" @@ -2412,19 +2424,19 @@ case "$host" in SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6 -echo "configure:2416: checking whether the C compiler needs -belf" >&5 +echo "configure:2428: checking whether the C compiler needs -belf" >&5 if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2440: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* lt_cv_cc_needs_belf=yes else @@ -2539,9 +2551,9 @@ esac echo $ac_n "checking for IPv6 structures""... $ac_c" 1>&6 -echo "configure:2543: checking for IPv6 structures" >&5 +echo "configure:2555: checking for IPv6 structures" >&5 cat > conftest.$ac_ext < @@ -2551,7 +2563,7 @@ int main() { struct sockaddr_in6 sin6; return (0); ; return 0; } EOF -if { (eval echo configure:2555: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2567: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 ISC_NET_HAVEIPV6="#define ISC_NET_HAVEIPV6 1" @@ -2574,12 +2586,12 @@ rm -f conftest* echo $ac_n "checking for inet_ntop""... $ac_c" 1>&6 -echo "configure:2578: checking for inet_ntop" >&5 +echo "configure:2590: checking for inet_ntop" >&5 if eval "test \"`echo '$''{'ac_cv_func_inet_ntop'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2618: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_inet_ntop=yes" else @@ -2626,12 +2638,12 @@ ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_ntop.$O" fi echo $ac_n "checking for inet_pton""... $ac_c" 1>&6 -echo "configure:2630: checking for inet_pton" >&5 +echo "configure:2642: checking for inet_pton" >&5 if eval "test \"`echo '$''{'ac_cv_func_inet_pton'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2670: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_inet_pton=yes" else @@ -2678,12 +2690,12 @@ ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_pton.$O" fi echo $ac_n "checking for inet_aton""... $ac_c" 1>&6 -echo "configure:2682: checking for inet_aton" >&5 +echo "configure:2694: checking for inet_aton" >&5 if eval "test \"`echo '$''{'ac_cv_func_inet_aton'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2722: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_inet_aton=yes" else diff --git a/configure.in b/configure.in index 404b43f74c..cf9a783e88 100644 --- a/configure.in +++ b/configure.in @@ -13,7 +13,7 @@ dnl PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS dnl ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS dnl SOFTWARE. -AC_REVISION($Revision: 1.50 $) +AC_REVISION($Revision: 1.51 $) AC_PREREQ(2.13) @@ -239,10 +239,16 @@ dnl case "$host" in *-dec-osf*) dnl Turn on 4.4BSD style sa_len support. - dnl (Disabled for now because it is incompatible - dnl with the use of send() and recv()). AC_DEFINE(_SOCKADDR_LEN) ;; + *-sun-solaris*) + dnl Solaris has yet another trick to get 4.4BSD behavior + AC_DEFINE(NEED_XPG4_2_BEFORE_SOCKET_H) + ;; + *-hp-hpux*) + dnl And HP has to be different, too. + AC_DEFINE(NEED_XSE_BEFORE_SOCKET_H) + ;; esac dnl diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 99560f27ce..0a21ddcd1d 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -19,6 +19,17 @@ #include #include +#if defined(NEED_XPG4_2_BEFORE_SOCKET_H) && !defined(_XPG4_2) +#define _XPG4_2 +#include +#undef _XPG4_2 +#elif defined(NEED_XSE_BEFORE_SOCKET_H) && !defined(_XOPEN_SOURCE_EXTENDED) +#define _XOPEN_SOURCE_EXTENDED +#include +#define _XOPEN_SOURCE_EXTENDED +#else +#include +#endif #include #include @@ -39,19 +50,10 @@ /* * 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 -#define ISC_SOCKADDR_LEN_T int -#endif - -/* - * As above, one system (solaris) wants the pointers passed into recv() and - * the other network functions to be char *. All the others seem to use - * void *. Cast everything to char * for now. - */ -#ifndef ISC_SOCKDATA_CAST -#define ISC_SOCKDATA_CAST(x) ((char *)(x)) +#define ISC_SOCKADDR_LEN_T unsigned int #endif /* @@ -496,7 +498,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, #ifdef SO_TIMESTAMP if (type == isc_sockettype_udp && setsockopt(sock->fd, SOL_SOCKET, SO_TIMESTAMP, - ISC_SOCKDATA_CAST(&on), sizeof on) < 0) { + (void *)&on, sizeof on) < 0) { UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d) failed", sock->fd); /* Press on... */ @@ -782,7 +784,7 @@ internal_accept(isc_task_t *me, isc_event_t *ev) * again. */ addrlen = sizeof dev->newsocket->address.type; - fd = accept(sock->fd, &dev->newsocket->address.type.sa, &addrlen); + fd = accept(sock->fd, &dev->newsocket->address.type.sa, (void *)&addrlen); dev->newsocket->address.length = addrlen; if (fd < 0) { if (SOFT_ERROR(errno)) { @@ -1303,7 +1305,7 @@ watcher(void *uap) * Process reads on internal, control fd. */ if (FD_ISSET(ctlfd, &readfds)) { - while (1) { + for (;;) { msg = select_readmsg(manager); XTRACE(TRACE_WATCHER, @@ -1980,7 +1982,7 @@ isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr) LOCK(&sock->lock); if (setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, - ISC_SOCKDATA_CAST(&on), sizeof on) < 0) { + (void *)&on, sizeof on) < 0) { UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d) failed", sock->fd); /* Press on... */ -- GitLab