mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
243 lines
8.1 KiB
Plaintext
243 lines
8.1 KiB
Plaintext
|
|
Nmap currently includes a modified version of the tcpdump.org release
|
|
of libpcap version 0.8.3 (released March 30, 2004). My
|
|
(fyodor@insecure.org) modifications are as follows:
|
|
|
|
o Included this file, renamed directory from libpcap-0.8.3 to
|
|
libpcap-possiblymodified.
|
|
|
|
o Renamed configure.in to configure.ac, which is the name now
|
|
recommended by the autoconf project.
|
|
|
|
o Removed the .cvsignore file, all 'CVS' directories, the 'packaging' directory, and the install-sh script.
|
|
|
|
o Added the gcc debugging flag (-g) to aclocal.m4 if gcc is being used:
|
|
--- libpcap-0.8.3/aclocal.m4 2003-11-16 01:45:51.000000000 -0800
|
|
+++ libpcap-possiblymodified/aclocal.m4 2004-07-31 22:34:47.000000000 -0700
|
|
@@ -1,4 +1,4 @@
|
|
-dnl @(#) $Header$ (LBL)
|
|
+dnl @(#) $Header$ (LBL)
|
|
dnl
|
|
dnl Copyright (c) 1995, 1996, 1997, 1998
|
|
dnl The Regents of the University of California. All rights reserved.
|
|
@@ -76,7 +76,7 @@
|
|
if test "$GCC" = yes ; then
|
|
if test "$SHLICC2" = yes ; then
|
|
ac_cv_lbl_gcc_vers=2
|
|
- $1="-O2"
|
|
+ $1="-g -O2"
|
|
else
|
|
AC_MSG_CHECKING(gcc version)
|
|
AC_CACHE_VAL(ac_cv_lbl_gcc_vers,
|
|
@@ -87,7 +87,7 @@
|
|
-e 's/\..*//'`)
|
|
AC_MSG_RESULT($ac_cv_lbl_gcc_vers)
|
|
if test $ac_cv_lbl_gcc_vers -gt 1 ; then
|
|
- $1="-O2"
|
|
+ $1="-g -O2"
|
|
fi
|
|
fi
|
|
else
|
|
|
|
o The config.sub and config.guess have been upgraded (in the distribution
|
|
file they are just symlinks to the corresponding files in the nmap dir
|
|
|
|
o Changed pcap-linux.c by adding a select() call guarding recvfrom()
|
|
to insure that it returns after the timeout period specified in
|
|
pcap_open_live() rather than blocking forever.
|
|
--- libpcap-0.8.3/pcap-linux.c 2003-11-21 02:20:46.000000000 -0800
|
|
+++ libpcap-possiblymodified/pcap-linux.c 2004-07-31 22:34:47.000000000 -0700
|
|
@@ -27,7 +27,7 @@
|
|
|
|
#ifndef lint
|
|
static const char rcsid[] _U_ =
|
|
- "@(#) $Header$ (LBL)";
|
|
+ "@(#) $Header$ (LBL)";
|
|
#endif
|
|
|
|
/*
|
|
@@ -96,6 +96,7 @@
|
|
#include <netinet/in.h>
|
|
#include <linux/if_ether.h>
|
|
#include <net/if_arp.h>
|
|
+#include <assert.h>
|
|
|
|
/*
|
|
* If PF_PACKET is defined, we can use {SOCK_RAW,SOCK_DGRAM}/PF_PACKET
|
|
@@ -483,6 +484,32 @@
|
|
return -2;
|
|
}
|
|
fromlen = sizeof(from);
|
|
+ /* If the user specified a timeout in pcap_open_live(),
|
|
+ we will honor the timeout and return even if no packets
|
|
+ have arrived */
|
|
+ if (handle->md.timeout > 0) {
|
|
+ fd_set readfs;
|
|
+ struct timeval tv;
|
|
+ int res;
|
|
+
|
|
+ FD_ZERO(&readfs);
|
|
+ FD_SET(handle->fd, &readfs);
|
|
+ bzero((void *) &tv, sizeof(tv));
|
|
+ tv.tv_sec = handle->md.timeout / 1000;
|
|
+ tv.tv_usec = (handle->md.timeout % 1000 ) * 1000;
|
|
+ do {
|
|
+ /* since this is in pcap-linux.c, we can assume
|
|
+ Linux select() behavior WRT decrementing tv */
|
|
+ res = select(handle->fd + 1, &readfs, NULL, NULL, &tv);
|
|
+ if (res == 1) break;
|
|
+ if (res == 0) return 0;
|
|
+ assert(res == -1);
|
|
+ if (errno == EINTR) continue;
|
|
+ snprintf(handle->errbuf, sizeof(handle->errbuf), "select: %s", pcap_strerror(errno));
|
|
+ return -1;
|
|
+ } while (1);
|
|
+ }
|
|
+
|
|
packet_len = recvfrom(
|
|
handle->fd, bp + offset,
|
|
handle->bufsize - offset, MSG_TRUNC,
|
|
|
|
o Eliminated Lex/Yacc requirement (I now ship the generated .c files).
|
|
This involved:
|
|
|
|
o Changes to Makefile.in
|
|
--- libpcap-0.8.3/Makefile.in 2003-12-14 17:42:23.000000000 -0800
|
|
+++ libpcap-possiblymodified/Makefile.in 2004-07-31 22:34:47.000000000 -0700
|
|
@@ -17,7 +17,7 @@
|
|
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
|
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
#
|
|
-# @(#) $Header$ (LBL)
|
|
+# @(#) $Header$ (LBL)
|
|
|
|
#
|
|
# Various configurable paths (remember to edit Makefile.in, not Makefile)
|
|
@@ -60,8 +60,8 @@
|
|
# used by the generated parser. This allows programs to use lex/yacc
|
|
# and link against libpcap. If you don't have flex or bison, get them.
|
|
#
|
|
-LEX = @V_LEX@
|
|
-YACC = @V_YACC@
|
|
+LEX = flex
|
|
+YACC = yacc
|
|
|
|
# Explicitly define compilation rule since SunOS 4's make doesn't like gcc.
|
|
# Also, gcc does not remove the .o before forking 'as', which can be a
|
|
@@ -94,7 +94,7 @@
|
|
TAGFILES = \
|
|
$(SRC) $(HDR) $(TAGHDR)
|
|
|
|
-CLEANFILES = $(OBJ) libpcap.a $(GENSRC) $(GENHDR) lex.yy.c
|
|
+CLEANFILES = $(OBJ) libpcap.a version.c lex.yy.c
|
|
|
|
all: libpcap.a
|
|
|
|
o Ripped LEX/YACC detection code from configure.in:
|
|
--- libpcap-0.8.3/configure.in 2004-03-28 13:43:34.000000000 -0800
|
|
+++ libpcap-possiblymodified/configure.ac 2004-07-31 22:34:47.000000000 -0700
|
|
@@ -1,4 +1,4 @@
|
|
-dnl @(#) $Header$ (LBL)
|
|
+dnl @(#) $Header$ (LBL)
|
|
dnl
|
|
dnl Copyright (c) 1994, 1995, 1996, 1997
|
|
dnl The Regents of the University of California. All rights reserved.
|
|
@@ -6,7 +6,7 @@
|
|
dnl Process this file with autoconf to produce a configure script.
|
|
dnl
|
|
|
|
-AC_REVISION($Revision$)
|
|
+AC_REVISION($Revision$)
|
|
AC_PREREQ(2.50)
|
|
AC_INIT(pcap.c)
|
|
|
|
@@ -341,25 +341,6 @@
|
|
AC_MSG_ERROR(Specifying the capture type as 'dag' requires the DAG API to be present; use --with-dag=DIR)
|
|
fi
|
|
|
|
-
|
|
-AC_LBL_LEX_AND_YACC(V_LEX, V_YACC, pcap_)
|
|
-if test "$V_LEX" = lex ; then
|
|
-# Some versions of lex can't handle the definitions section of scanner.l .
|
|
-# Try lexing it and complain if it can't deal.
|
|
- AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
|
|
- if lex -t scanner.l > /dev/null 2>&1; then
|
|
- tcpdump_cv_capable_lex=yes
|
|
- else
|
|
- tcpdump_cv_capable_lex=insufficient
|
|
- fi)
|
|
- if test $tcpdump_cv_capable_lex = insufficient ; then
|
|
- AC_MSG_ERROR([Your operating system's lex is insufficient to compile
|
|
- libpcap. flex is a lex replacement that has many advantages, including
|
|
- being able to compile libpcap. For more information, see
|
|
- http://www.gnu.org/software/flex/flex.html .])
|
|
- fi
|
|
-fi
|
|
-
|
|
case "$host_os" in
|
|
|
|
aix*)
|
|
@@ -420,11 +401,9 @@
|
|
AC_SUBST(V_DEFS)
|
|
AC_SUBST(V_INCLS)
|
|
AC_SUBST(V_LIBS)
|
|
-AC_SUBST(V_LEX)
|
|
AC_SUBST(V_PCAP)
|
|
AC_SUBST(V_FINDALLDEVS)
|
|
AC_SUBST(V_RANLIB)
|
|
-AC_SUBST(V_YACC)
|
|
AC_SUBST(SSRC)
|
|
|
|
AC_PROG_INSTALL
|
|
|
|
o An OpenBSD portability fix to make loopback work:
|
|
diff -w -u -r1.1 pcap-bpf.h
|
|
--- pcap-bpf.h 1 Aug 2004 05:34:47 -0000 1.1
|
|
+++ pcap-bpf.h 29 Jan 2005 20:32:24 -0000
|
|
@@ -235,12 +235,14 @@
|
|
* OpenBSD DLT_LOOP, for loopback devices; it's like DLT_NULL, except
|
|
* that the AF_ type in the link-layer header is in network byte order.
|
|
*
|
|
- * OpenBSD defines it as 12, but that collides with DLT_RAW, so we
|
|
- * define it as 108 here. If OpenBSD picks up this file, it should
|
|
- * define DLT_LOOP as 12 in its version, as per the comment above -
|
|
- * and should not use 108 as a DLT_ value.
|
|
+ * OpenBSD defines it as 12, but that collides with DLT_RAW, so 108 is
|
|
+ * used for other platforms.
|
|
*/
|
|
+#ifdef __OpenBSD__
|
|
+#define DLT_LOOP 12
|
|
+#else
|
|
#define DLT_LOOP 108
|
|
+#endif
|
|
|
|
/*
|
|
* Encapsulated packets for IPsec; DLT_ENC is 13 in OpenBSD, but that's
|
|
|
|
|
|
The following patch removes some code that apparently causes libpcap on
|
|
Solaris to wait for 64K chunks before returning in some cases, regardless of
|
|
the timeout values. Problem report and patch came from
|
|
Ben Harris (bjh21(a)cam.ac.uk)
|
|
|
|
--- pcap-dlpi.c 1 Aug 2004 05:34:47 -0000 1.4
|
|
+++ pcap-dlpi.c 1 Feb 2005 20:29:29 -0000
|
|
@@ -675,16 +675,6 @@
|
|
}
|
|
}
|
|
|
|
- /*
|
|
- ** Set the chunk length.
|
|
- */
|
|
- chunksize = CHUNKSIZE;
|
|
- if (strioctl(p->fd, SBIOCSCHUNK, sizeof(chunksize), (char *)&chunksize)
|
|
- != 0) {
|
|
- snprintf(ebuf, PCAP_ERRBUF_SIZE, "SBIOCSCHUNKP: %s",
|
|
- pcap_strerror(errno));
|
|
- goto bad;
|
|
- }
|
|
#endif
|
|
|
|
/*
|
|
|