2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-03 08:05:21 +00:00

Do the bsd4.3/bsd4.4 msghdr test right.

This commit is contained in:
Michael Graff
1999-08-31 20:57:46 +00:00
parent 0fe778098d
commit 4c5faa6bcf
4 changed files with 114 additions and 82 deletions

102
configure vendored
View File

@@ -1,6 +1,6 @@
#! /bin/sh
# From configure.in Revision: 1.50
# From configure.in Revision: 1.51
@@ -2058,18 +2058,6 @@ case "$host" in
*-dec-osf*)
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
;;
@@ -2077,9 +2065,9 @@ esac
echo $ac_n "checking for sa_len in struct sockaddr""... $ac_c" 1>&6
echo "configure:2081: checking for sa_len in struct sockaddr" >&5
echo "configure:2069: checking for sa_len in struct sockaddr" >&5
cat > conftest.$ac_ext <<EOF
#line 2083 "configure"
#line 2071 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -2088,7 +2076,7 @@ int main() {
struct sockaddr sa; sa.sa_len = 0; return (0);
; return 0; }
EOF
if { (eval echo configure:2092: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2080: \"$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"
@@ -2103,10 +2091,37 @@ rm -f conftest*
echo $ac_n "checking for interface list sysctl""... $ac_c" 1>&6
echo "configure:2108: checking for interface list sysctl" >&5
echo $ac_n "checking for struct msghdr flavor""... $ac_c" 1>&6
echo "configure:2096: checking for struct msghdr flavor" >&5
cat > conftest.$ac_ext <<EOF
#line 2110 "configure"
#line 2098 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/socket.h>
int main() {
struct msghdr msg; msg.msg_flags = 0; return (0);
; return 0; }
EOF
if { (eval echo configure:2107: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo "$ac_t""4.4BSD" 1>&6
ISC_NET_MSGHDRFLAVOR="#define ISC_NET_BSD44MSGHDR 1"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
echo "$ac_t""4.3BSD" 1>&6
ISC_NET_MSGHDRFLAVOR="#define ISC_NET_BSD43MSGHDR 1"
fi
rm -f conftest*
echo $ac_n "checking for interface list sysctl""... $ac_c" 1>&6
echo "configure:2123: checking for interface list sysctl" >&5
cat > conftest.$ac_ext <<EOF
#line 2125 "configure"
#include "confdefs.h"
#include <sys/param.h>
@@ -2213,7 +2228,7 @@ else
fi
echo $ac_n "checking build system type""... $ac_c" 1>&6
echo "configure:2217: checking build system type" >&5
echo "configure:2232: checking build system type" >&5
build_alias=$build
case "$build_alias" in
@@ -2242,7 +2257,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:2246: checking for ld used by GCC" >&5
echo "configure:2261: checking for ld used by GCC" >&5
ac_prog=`($CC -print-prog-name=ld) 2>&5`
case "$ac_prog" in
# Accept absolute paths.
@@ -2266,10 +2281,10 @@ echo "configure:2246: 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:2270: checking for GNU ld" >&5
echo "configure:2285: checking for GNU ld" >&5
else
echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
echo "configure:2273: checking for non-GNU ld" >&5
echo "configure:2288: 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
@@ -2305,7 +2320,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:2309: checking if the linker ($LD) is GNU ld" >&5
echo "configure:2324: 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
@@ -2321,7 +2336,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:2325: checking for BSD-compatible nm" >&5
echo "configure:2340: 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
@@ -2358,7 +2373,7 @@ echo "$ac_t""$NM" 1>&6
echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
echo "configure:2362: checking whether ln -s works" >&5
echo "configure:2377: 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
@@ -2402,8 +2417,8 @@ test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
case "$host" in
*-*-irix6*)
# Find out which ABI we are using.
echo '#line 2406 "configure"' > conftest.$ac_ext
if { (eval echo configure:2407: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
echo '#line 2421 "configure"' > conftest.$ac_ext
if { (eval echo configure:2422: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
case "`/usr/bin/file conftest.o`" in
*32-bit*)
LD="${LD-ld} -32"
@@ -2424,19 +2439,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:2428: checking whether the C compiler needs -belf" >&5
echo "configure:2443: 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 <<EOF
#line 2433 "configure"
#line 2448 "configure"
#include "confdefs.h"
int main() {
; return 0; }
EOF
if { (eval echo configure:2440: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2455: \"$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
@@ -2551,9 +2566,9 @@ esac
echo $ac_n "checking for IPv6 structures""... $ac_c" 1>&6
echo "configure:2555: checking for IPv6 structures" >&5
echo "configure:2570: checking for IPv6 structures" >&5
cat > conftest.$ac_ext <<EOF
#line 2557 "configure"
#line 2572 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -2563,7 +2578,7 @@ int main() {
struct sockaddr_in6 sin6; return (0);
; return 0; }
EOF
if { (eval echo configure:2567: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2582: \"$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"
@@ -2586,12 +2601,12 @@ rm -f conftest*
echo $ac_n "checking for inet_ntop""... $ac_c" 1>&6
echo "configure:2590: checking for inet_ntop" >&5
echo "configure:2605: 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 <<EOF
#line 2595 "configure"
#line 2610 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char inet_ntop(); below. */
@@ -2614,7 +2629,7 @@ inet_ntop();
; return 0; }
EOF
if { (eval echo configure:2618: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2633: \"$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
@@ -2638,12 +2653,12 @@ ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_ntop.$O"
fi
echo $ac_n "checking for inet_pton""... $ac_c" 1>&6
echo "configure:2642: checking for inet_pton" >&5
echo "configure:2657: 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 <<EOF
#line 2647 "configure"
#line 2662 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char inet_pton(); below. */
@@ -2666,7 +2681,7 @@ inet_pton();
; return 0; }
EOF
if { (eval echo configure:2670: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2685: \"$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
@@ -2690,12 +2705,12 @@ ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_pton.$O"
fi
echo $ac_n "checking for inet_aton""... $ac_c" 1>&6
echo "configure:2694: checking for inet_aton" >&5
echo "configure:2709: 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 <<EOF
#line 2699 "configure"
#line 2714 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char inet_aton(); below. */
@@ -2718,7 +2733,7 @@ inet_aton();
; return 0; }
EOF
if { (eval echo configure:2722: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2737: \"$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
@@ -2956,6 +2971,7 @@ s%@MKDEPCC@%$MKDEPCC%g
s%@MKDEPCFLAGS@%$MKDEPCFLAGS%g
s%@MKDEPPROG@%$MKDEPPROG%g
s%@ISC_NET_HAVESALEN@%$ISC_NET_HAVESALEN%g
s%@ISC_NET_MSGHDRFLAVOR@%$ISC_NET_MSGHDRFLAVOR%g
s%@build@%$build%g
s%@build_alias@%$build_alias%g
s%@build_cpu@%$build_cpu%g

View File

@@ -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.51 $)
AC_REVISION($Revision: 1.52 $)
AC_PREREQ(2.13)
@@ -241,14 +241,6 @@ case "$host" in
dnl Turn on 4.4BSD style sa_len support.
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
@@ -266,6 +258,21 @@ AC_TRY_COMPILE([
ISC_NET_HAVESALEN="#undef ISC_NET_HAVESALEN"])
AC_SUBST(ISC_NET_HAVESALEN)
dnl
dnl Look for a 4.4BSD or 4.3BSD struct msghdr
dnl
AC_MSG_CHECKING(for struct msghdr flavor)
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>],
[struct msghdr msg; msg.msg_flags = 0; return (0);],
[AC_MSG_RESULT(4.4BSD)
ISC_NET_MSGHDRFLAVOR="#define ISC_NET_BSD44MSGHDR 1"],
[AC_MSG_RESULT(4.3BSD)
ISC_NET_MSGHDRFLAVOR="#define ISC_NET_BSD43MSGHDR 1"])
AC_SUBST(ISC_NET_MSGHDRFLAVOR)
dnl
dnl Look for a sysctl call to get the list of network interfaces.
dnl

View File

@@ -115,6 +115,11 @@
#include <isc/ipv6.h>
#endif
/*
* Define either ISC_NET_BSD44MSGHDR or ISC_NET_BSD43MSGHDR
*/
@ISC_NET_MSGHDRFLAVOR@
/***
*** Functions.
***/

View File

@@ -19,17 +19,6 @@
#include <sys/types.h>
#include <sys/uio.h>
#if defined(NEED_XPG4_2_BEFORE_SOCKET_H) && !defined(_XPG4_2)
#define _XPG4_2
#include <sys/socket.h>
#undef _XPG4_2
#elif defined(NEED_XSE_BEFORE_SOCKET_H) && !defined(_XOPEN_SOURCE_EXTENDED)
#define _XOPEN_SOURCE_EXTENDED
#include <sys/socket.h>
#undef _XOPEN_SOURCE_EXTENDED
#else
#include <sys/socket.h>
#endif
#include <errno.h>
#include <stddef.h>
@@ -42,6 +31,7 @@
#include <isc/error.h>
#include <isc/thread.h>
#include <isc/mutex.h>
#include <isc/net.h>
#include <isc/condition.h>
#include <isc/socket.h>
#include <isc/list.h>
@@ -277,8 +267,10 @@ make_nonblock(int fd)
static void
process_cmsg(isc_socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev)
{
struct cmsghdr *cm;
(void)sock;
#ifdef ISC_NET_BSD44MSGHDR
#ifdef MSG_TRUNC
if ((msg->msg_flags & MSG_TRUNC) == MSG_TRUNC)
dev->attributes |= ISC_SOCKEVENTATTR_TRUNC;
@@ -291,10 +283,7 @@ process_cmsg(isc_socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev)
if (msg->msg_controllen == 0 || msg->msg_control == NULL)
return;
/*
* Pull off the options
*/
#endif /* ISC_NET_BSD44MSGHDR */
}
@@ -455,7 +444,6 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
{
isc_socket_t *sock = NULL;
isc_result_t ret;
int on = 1;
REQUIRE(VALID_MANAGER(manager));
REQUIRE(socketp != NULL && *socketp == NULL);
@@ -499,6 +487,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
return (ISC_R_UNEXPECTED);
}
#if 0
#ifdef SO_TIMESTAMP
if (type == isc_sockettype_udp
&& setsockopt(sock->fd, SOL_SOCKET, SO_TIMESTAMP,
@@ -507,6 +496,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
sock->fd);
/* Press on... */
}
#endif
#endif
sock->references = 1;
@@ -945,14 +935,15 @@ internal_recv(isc_task_t *me, isc_event_t *ev)
}
msghdr.msg_iov = &iov;
msghdr.msg_iovlen = 1;
#ifdef notyet
msghdr.msg_control = (void *)sock->cmsg;
msghdr.msg_controllen = sizeof (sock->cmsg);
#else
#ifdef ISC_NET_BSD44MSGHDR
msghdr.msg_control = NULL;
msghdr.msg_controllen = 0;
#endif
msghdr.msg_flags = 0;
#else
msghdr.msg_accrights = NULL;
msghdr.msg_accrightslen = 0;
#endif
cc = recvmsg(sock->fd, &msghdr, 0);
@@ -1141,9 +1132,15 @@ internal_send(isc_task_t *me, isc_event_t *ev)
msghdr.msg_iov = &iov;
msghdr.msg_iovlen = 1;
#ifdef ISC_NET_BSD44MSGHDR
msghdr.msg_control = NULL;
msghdr.msg_controllen = 0;
msghdr.msg_flags = 0;
#else
msghdr.msg_accrights = NULL;
msghdr.msg_accrightslen = 0;
#endif
cc = sendmsg(sock->fd, &msghdr, 0);
@@ -1693,14 +1690,15 @@ isc_socket_recv(isc_socket_t *sock, isc_region_t *region, unsigned int minimum,
}
msghdr.msg_iov = &iov;
msghdr.msg_iovlen = 1;
#ifdef notyet
msghdr.msg_control = (void *)sock->cmsg;
msghdr.msg_controllen = sizeof (sock->cmsg);
#else
#ifdef ISC_NET_BSD44MSGHDR
msghdr.msg_control = NULL;
msghdr.msg_controllen = 0;
#endif
msghdr.msg_flags = 0;
#else
msghdr.msg_accrights = NULL;
msghdr.msg_accrightslen = 0;
#endif
cc = recvmsg(sock->fd, &msghdr, 0);
if (sock->type == isc_sockettype_udp)
@@ -1892,9 +1890,15 @@ isc_socket_sendto(isc_socket_t *sock, isc_region_t *region,
msghdr.msg_iov = &iov;
msghdr.msg_iovlen = 1;
#ifdef ISC_NET_BSD44MSGHDR
msghdr.msg_control = NULL;
msghdr.msg_controllen = 0;
msghdr.msg_flags = 0;
#else
msghdr.msg_accrights = NULL;
msghdr.msg_accrightslen = 0;
#endif
cc = sendmsg(sock->fd, &msghdr, 0);
@@ -2247,7 +2251,7 @@ internal_connect(isc_task_t *me, isc_event_t *ev)
ISC_SOCKADDR_LEN_T optlen;
(void)me;
INSIST(ev->type = ISC_SOCKEVENT_INTW);
INSIST(ev->type == ISC_SOCKEVENT_INTW);
sock = ev->sender;
INSIST(VALID_SOCKET(sock));
@@ -2285,7 +2289,7 @@ internal_connect(isc_task_t *me, isc_event_t *ev)
*/
optlen = sizeof(cc);
if (getsockopt(sock->fd, SOL_SOCKET, SO_ERROR,
(char *)&cc, &optlen) < 0)
(void *)&cc, (void *)&optlen) < 0)
cc = errno;
else
errno = cc;
@@ -2361,7 +2365,7 @@ isc_socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp)
LOCK(&sock->lock);
len = sizeof addressp->type;
if (getsockname(sock->fd, &addressp->type.sa, &len) < 0) {
if (getsockname(sock->fd, &addressp->type.sa, (void *)&len) < 0) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"getsockname: %s", strerror(errno));
UNLOCK(&sock->lock);