mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Merge commit 43acbb77a8e0b3346b574b3e28793de2d6985e69 from libpcap
upstream (git://bpf.tcpdump.org/libpcap). This is a workaround for the BIOCSRTIMEOUT bug in 10.6, 10.6.1, and 10.6.3 that doesn't work for non-integer timeouts. A symptom of being affected by the bug is Nmap haning forever at the first call to pcap_next. 10.6.2 was somehow not affected. This alone still doesn't solve the problem; I still have to make the default --with-libpcap=included for 64-bit OS X. The source comment is informative: /* * XXX - Mac OS X 10.6 mishandles BIOCSRTIMEOUT in 64-bit userland - it * takes, as an argument, a "struct BPF_TIMEVAL", which has 32-bit * tv_sec and tv_usec, rather than a "struct timeval". * * If this platform defines "struct BPF_TIMEVAL", we check whether the * structure size in BIOCSRTIMEOUT is that of a "struct timeval" and, if * not, we use a "struct BPF_TIMEVAL" rather than a "struct timeval". * (That way, if the bug is fixed in a future release, we will still do * the right thing.) */ commit 43acbb77a8e0b3346b574b3e28793de2d6985e69 Author: Guy Harris <guy@alum.mit.edu> Date: Sun Oct 11 11:05:46 2009 -0700 Work around an annoying Snow Leopard BPF bug that causes sub-second timeouts not to work in 64-bit userland code (Snow Leopard's GCC builds 64-bit by default on 64-bit machines).
This commit is contained in:
@@ -128,6 +128,9 @@
|
||||
/* Define to 1 if you have the `strlcpy' function. */
|
||||
#undef HAVE_STRLCPY
|
||||
|
||||
/* Define to 1 if the system has the type `struct BPF_TIMEVAL'. */
|
||||
#undef HAVE_STRUCT_BPF_TIMEVAL
|
||||
|
||||
/* Define to 1 if the system has the type `struct ether_addr'. */
|
||||
#undef HAVE_STRUCT_ETHER_ADDR
|
||||
|
||||
|
||||
123
libpcap/configure
vendored
123
libpcap/configure
vendored
@@ -7240,6 +7240,129 @@ $as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
|
||||
#
|
||||
# Check whether we have struct BPF_TIMEVAL.
|
||||
#
|
||||
{ $as_echo "$as_me:$LINENO: checking for struct BPF_TIMEVAL" >&5
|
||||
$as_echo_n "checking for struct BPF_TIMEVAL... " >&6; }
|
||||
if test "${ac_cv_type_struct_BPF_TIMEVAL+set}" = set; then
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
ac_cv_type_struct_BPF_TIMEVAL=no
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#ifdef HAVE_SYS_IOCCOM_H
|
||||
#include <sys/ioccom.h>
|
||||
#endif
|
||||
#include <net/bpf.h>
|
||||
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
if (sizeof (struct BPF_TIMEVAL))
|
||||
return 0;
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext
|
||||
if { (ac_try="$ac_compile"
|
||||
case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
|
||||
$as_echo "$ac_try_echo") >&5
|
||||
(eval "$ac_compile") 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } && {
|
||||
test -z "$ac_c_werror_flag" ||
|
||||
test ! -s conftest.err
|
||||
} && test -s conftest.$ac_objext; then
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#ifdef HAVE_SYS_IOCCOM_H
|
||||
#include <sys/ioccom.h>
|
||||
#endif
|
||||
#include <net/bpf.h>
|
||||
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
if (sizeof ((struct BPF_TIMEVAL)))
|
||||
return 0;
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext
|
||||
if { (ac_try="$ac_compile"
|
||||
case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
|
||||
$as_echo "$ac_try_echo") >&5
|
||||
(eval "$ac_compile") 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } && {
|
||||
test -z "$ac_c_werror_flag" ||
|
||||
test ! -s conftest.err
|
||||
} && test -s conftest.$ac_objext; then
|
||||
:
|
||||
else
|
||||
$as_echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_cv_type_struct_BPF_TIMEVAL=yes
|
||||
fi
|
||||
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
else
|
||||
$as_echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
|
||||
fi
|
||||
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
fi
|
||||
{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_struct_BPF_TIMEVAL" >&5
|
||||
$as_echo "$ac_cv_type_struct_BPF_TIMEVAL" >&6; }
|
||||
if test "x$ac_cv_type_struct_BPF_TIMEVAL" = x""yes; then
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_STRUCT_BPF_TIMEVAL 1
|
||||
_ACEOF
|
||||
|
||||
|
||||
fi
|
||||
|
||||
;;
|
||||
|
||||
dag)
|
||||
|
||||
@@ -381,6 +381,19 @@ bpf)
|
||||
[define if the system supports zerocopy BPF])
|
||||
],
|
||||
AC_MSG_RESULT(no))
|
||||
|
||||
#
|
||||
# Check whether we have struct BPF_TIMEVAL.
|
||||
#
|
||||
AC_CHECK_TYPES(struct BPF_TIMEVAL,,,
|
||||
[
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#ifdef HAVE_SYS_IOCCOM_H
|
||||
#include <sys/ioccom.h>
|
||||
#endif
|
||||
#include <net/bpf.h>
|
||||
])
|
||||
;;
|
||||
|
||||
dag)
|
||||
|
||||
@@ -1859,16 +1859,45 @@ pcap_activate_bpf(pcap_t *p)
|
||||
* XXX - is this seconds/nanoseconds in AIX?
|
||||
* (Treating it as such doesn't fix the timeout
|
||||
* problem described below.)
|
||||
*
|
||||
* XXX - Mac OS X 10.6 mishandles BIOCSRTIMEOUT in
|
||||
* 64-bit userland - it takes, as an argument, a
|
||||
* "struct BPF_TIMEVAL", which has 32-bit tv_sec
|
||||
* and tv_usec, rather than a "struct timeval".
|
||||
*
|
||||
* If this platform defines "struct BPF_TIMEVAL",
|
||||
* we check whether the structure size in BIOCSRTIMEOUT
|
||||
* is that of a "struct timeval" and, if not, we use
|
||||
* a "struct BPF_TIMEVAL" rather than a "struct timeval".
|
||||
* (That way, if the bug is fixed in a future release,
|
||||
* we will still do the right thing.)
|
||||
*/
|
||||
struct timeval to;
|
||||
to.tv_sec = p->md.timeout / 1000;
|
||||
to.tv_usec = (p->md.timeout * 1000) % 1000000;
|
||||
if (ioctl(p->fd, BIOCSRTIMEOUT, (caddr_t)&to) < 0) {
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSRTIMEOUT: %s",
|
||||
pcap_strerror(errno));
|
||||
status = PCAP_ERROR;
|
||||
goto bad;
|
||||
#ifdef HAVE_STRUCT_BPF_TIMEVAL
|
||||
struct BPF_TIMEVAL bpf_to;
|
||||
|
||||
if (IOCPARM_LEN(BIOCSRTIMEOUT) != sizeof(struct timeval)) {
|
||||
bpf_to.tv_sec = p->md.timeout / 1000;
|
||||
bpf_to.tv_usec = (p->md.timeout * 1000) % 1000000;
|
||||
if (ioctl(p->fd, BIOCSRTIMEOUT, (caddr_t)&bpf_to) < 0) {
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"BIOCSRTIMEOUT: %s", pcap_strerror(errno));
|
||||
status = PCAP_ERROR;
|
||||
goto bad;
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
to.tv_sec = p->md.timeout / 1000;
|
||||
to.tv_usec = (p->md.timeout * 1000) % 1000000;
|
||||
if (ioctl(p->fd, BIOCSRTIMEOUT, (caddr_t)&to) < 0) {
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"BIOCSRTIMEOUT: %s", pcap_strerror(errno));
|
||||
status = PCAP_ERROR;
|
||||
goto bad;
|
||||
}
|
||||
#ifdef HAVE_STRUCT_BPF_TIMEVAL
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _AIX
|
||||
|
||||
Reference in New Issue
Block a user