1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00
Files
nmap/libpcap/NMAP_MODIFICATIONS/0002-Add-the-disable-packet-ring-configure-option.patch

90 lines
3.0 KiB
Diff

From 3807934db1b073534a01d9a8546cddcec9be501f Mon Sep 17 00:00:00 2001
From: David Fifield <david@bamsoftware.com>
Date: Mon, 9 Apr 2012 17:02:40 -0700
Subject: [PATCH 2/2] Add the --disable-packet-ring configure option.
This allows the creation of 32-bit binaries that are compatible with
64-bit Linux kernels before version 2.6.27.
---
configure.in | 18 ++++++++++++++++++
pcap-linux.c | 18 ++++++++++--------
config.h.in | 3 +++
3 files changed, 31 insertions(+), 8 deletions(-)
diff --git configure.in configure.in
index 24097b2..5eca6ab 100644
--- configure.in
+++ configure.in
@@ -1404,6 +1404,24 @@ linux*)
;;
esac
+dnl The packet ring capture facility of Linux, described in
+dnl Documentation/networking/packet_mmap.txt, is not 32/64-bit compatible before
+dnl version 2.6.27. A 32-bit kernel requires a 32-bit userland, and likewise for
+dnl 64-bit. The effect of this is that a 32-bit libpcap binary will not run
+dnl correctly on a 64-bit kernel (the binary will use the wrong offsets into a
+dnl kernel struct). This problem was solved in Linux 2.6.27. Use
+dnl --disable-packet-ring whenever a 32-bit application must run on a 64-bit
+dnl target host, and either the build host or the target host run Linux 2.6.26
+dnl or earlier.
+AC_ARG_ENABLE([packet-ring],
+[AC_HELP_STRING([--enable-packet-ring],[enable Linux packet ring support @<:@default=yes@:>@])],
+,enable_packet_ring=yes)
+
+if test "x$enable_packet_ring" != "xno" ; then
+ AC_DEFINE(PCAP_SUPPORT_PACKET_RING, 1, [use Linux packet ring capture if available])
+ AC_SUBST(PCAP_SUPPORT_PACKET_RING)
+fi
+
AC_PROG_INSTALL
AC_CONFIG_HEADER(config.h)
diff --git pcap-linux.c pcap-linux.c
index 17bd0f5..bd2457d 100644
--- pcap-linux.c
+++ pcap-linux.c
@@ -196,17 +196,19 @@ static const char rcsid[] _U_ =
/* check for memory mapped access avaibility. We assume every needed
* struct is defined if the macro TPACKET_HDRLEN is defined, because it
* uses many ring related structs and macros */
-# ifdef TPACKET_HDRLEN
-# define HAVE_PACKET_RING
-# ifdef TPACKET3_HDRLEN
-# define HAVE_TPACKET3
-# endif /* TPACKET3_HDRLEN */
-# ifdef TPACKET2_HDRLEN
-# define HAVE_TPACKET2
-# else /* TPACKET2_HDRLEN */
-# define TPACKET_V1 0 /* Old kernel with only V1, so no TPACKET_Vn defined */
-# endif /* TPACKET2_HDRLEN */
-# endif /* TPACKET_HDRLEN */
+# ifdef PCAP_SUPPORT_PACKET_RING
+# ifdef TPACKET_HDRLEN
+# define HAVE_PACKET_RING
+# ifdef TPACKET3_HDRLEN
+# define HAVE_TPACKET3
+# endif /* TPACKET3_HDRLEN */
+# ifdef TPACKET2_HDRLEN
+# define HAVE_TPACKET2
+# else /* TPACKET2_HDRLEN */
+# define TPACKET_V1 0 /* Old kernel with only V1, so no TPACKET_Vn defined */
+# endif /* TPACKET2_HDRLEN */
+# endif /* TPACKET_HDRLEN */
+# endif /* PCAP_SUPPORT_PACKET_RING */
#endif /* PF_PACKET */
#ifdef SO_ATTACH_FILTER
--- config.h.in
+++ config.h.in
@@ -271,6 +271,9 @@
/* target host supports USB sniffing */
#undef PCAP_SUPPORT_USB
+/* target host supports packet ring capture */
+#undef PCAP_SUPPORT_PACKET_RING
+
/* include ACN support */
#undef SITA