aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2017-02-12 07:04:44 +0000
committerXin LI <delphij@FreeBSD.org>2017-02-12 07:04:44 +0000
commitc8c6d70e300aa9261c4766502c179fc4cd2b22a0 (patch)
tree14c068bb8b49db9f9ae540e8e2be80a9035e403a
parent50224b10fa4e157f09ee1cd03c790c9e61e76c5e (diff)
downloadsrc-c8c6d70e300aa9261c4766502c179fc4cd2b22a0.tar.gz
src-c8c6d70e300aa9261c4766502c179fc4cd2b22a0.zip
Vendor import of libpcap 1.8.1.vendor/libpcap/1.8.1
Notes
Notes: svn path=/vendor/libpcap/dist/; revision=313676 svn path=/vendor/libpcap/1.8.1/; revision=313677; tag=vendor/libpcap/1.8.1
-rw-r--r--CHANGES83
-rw-r--r--CMakeLists.txt520
-rw-r--r--CREDITS7
-rw-r--r--GenVersion.bat23
-rw-r--r--INSTALL.txt68
-rw-r--r--LICENSE6
-rw-r--r--Makefile-devel-adds4
-rw-r--r--Makefile.in182
-rw-r--r--README10
-rw-r--r--README.Win3242
-rw-r--r--README.aix4
-rw-r--r--README.hpux40
-rw-r--r--README.linux6
-rw-r--r--README.septel2
-rw-r--r--README.sita2
-rw-r--r--README.tru642
-rw-r--r--TODO10
-rw-r--r--VERSION2
-rw-r--r--Win32/Include/Gnuc.h36
-rw-r--r--Win32/Include/addrinfo.h144
-rw-r--r--Win32/Include/arpa/nameser.h349
-rw-r--r--Win32/Include/bittypes.h89
-rw-r--r--Win32/Include/cdecl_ext.h37
-rw-r--r--Win32/Include/inetprivate.h67
-rw-r--r--Win32/Include/ip6_misc.h161
-rw-r--r--Win32/Include/net/if.h2
-rw-r--r--Win32/Include/net/netdb.h164
-rw-r--r--Win32/Include/net/paths.h105
-rw-r--r--Win32/Include/sockstorage.h38
-rw-r--r--Win32/Prj/libpcap.dsp168
-rw-r--r--Win32/Prj/libpcap.dsw29
-rw-r--r--Win32/Prj/wpcap.sln28
-rw-r--r--Win32/Prj/wpcap.vcxproj234
-rw-r--r--Win32/Prj/wpcap.vcxproj.filters107
-rw-r--r--Win32/Src/gai_strerror.c83
-rw-r--r--Win32/Src/getaddrinfo.c1124
-rw-r--r--Win32/Src/getnetbynm.c44
-rw-r--r--Win32/Src/getnetent.c119
-rw-r--r--Win32/Src/getservent.c125
-rw-r--r--Win32/Src/inet_aton.c54
-rw-r--r--Win32/Src/inet_net.c101
-rw-r--r--Win32/Src/inet_pton.c64
-rw-r--r--aclocal.m4118
-rw-r--r--bpf/net/bpf_filter.c120
-rw-r--r--bpf_dump.c5
-rw-r--r--bpf_image.c12
-rw-r--r--cmake/preconfigure.cmake55
-rw-r--r--cmakeconfig.h.in345
-rwxr-xr-xconfig.guess373
-rw-r--r--config.h.in43
-rwxr-xr-xconfig.sub128
-rw-r--r--config/have_siocglifconf.c6
-rwxr-xr-xconfigure1558
-rw-r--r--[-rwxr-xr-x]configure.ac (renamed from configure.in)849
-rw-r--r--dlpisubs.c31
-rw-r--r--etherent.c6
-rw-r--r--ethertype.h3
-rw-r--r--extract.h221
-rw-r--r--fad-getad.c76
-rw-r--r--fad-gifc.c49
-rw-r--r--fad-glifc.c60
-rw-r--r--fad-helpers.c884
-rw-r--r--fad-sita.c59
-rw-r--r--fad-win32.c248
-rwxr-xr-xgen_version_c.sh11
-rwxr-xr-xgen_version_header.sh19
-rw-r--r--gencode.c5537
-rw-r--r--gencode.h158
-rw-r--r--grammar.y249
-rw-r--r--inet.c883
-rwxr-xr-xinstall-sh14
-rw-r--r--lbl/os-aix7.h23
-rw-r--r--lbl/os-osf4.h6
-rw-r--r--lbl/os-osf5.h8
-rw-r--r--lbl/os-solaris2.h2
-rw-r--r--lbl/os-sunos4.h4
-rw-r--r--lbl/os-ultrix4.h1
-rw-r--r--missing/getopt.c (renamed from Win32/Src/getopt.c)15
-rw-r--r--missing/getopt.h7
-rw-r--r--missing/snprintf.c20
-rw-r--r--missing/strtok_r.c87
-rw-r--r--missing/win_snprintf.c31
-rwxr-xr-xmkdep3
-rw-r--r--msdos/bin2c.c4
-rw-r--r--msdos/common.dj17
-rw-r--r--msdos/makefile2
-rw-r--r--msdos/makefile.dj128
-rw-r--r--msdos/makefile.wc33
-rw-r--r--msdos/ndis2.c10
-rw-r--r--msdos/ndis2.h2
-rw-r--r--msdos/ndis_0.asm376
-rw-r--r--msdos/pkt_rx0.asm394
-rw-r--r--msdos/pkt_rx1.s2
-rw-r--r--msdos/pktdrvr.c6
-rw-r--r--msdos/pktdrvr.h2
-rw-r--r--msdos/readme.dos60
-rw-r--r--nametoaddr.c73
-rw-r--r--nametoaddr.h (renamed from fad-null.c)34
-rw-r--r--optimize.c861
-rw-r--r--packaging/pcap.spec.in77
-rw-r--r--pcap-bpf.c631
-rw-r--r--pcap-bpf.h2
-rw-r--r--pcap-bt-linux.c106
-rw-r--r--pcap-bt-linux.h4
-rw-r--r--pcap-bt-monitor-linux.c51
-rw-r--r--pcap-can-linux.c319
-rw-r--r--pcap-can-linux.h36
-rw-r--r--pcap-canusb-linux.c472
-rw-r--r--pcap-common.c192
-rw-r--r--pcap-config.12
-rw-r--r--pcap-dag.c366
-rw-r--r--pcap-dag.h94
-rw-r--r--pcap-dbus.c38
-rw-r--r--pcap-dlpi.c370
-rw-r--r--pcap-dos.c136
-rw-r--r--pcap-dos.h2
-rw-r--r--pcap-filter.manmisc.in31
-rw-r--r--pcap-int.h132
-rw-r--r--pcap-libdlpi.c39
-rw-r--r--pcap-linktype.manmisc.in2
-rw-r--r--pcap-linux.c1571
-rw-r--r--pcap-netfilter-linux.c108
-rw-r--r--pcap-netfilter-linux.h4
-rw-r--r--pcap-new.c1265
-rw-r--r--pcap-nit.c43
-rw-r--r--pcap-null.c6
-rw-r--r--pcap-pf.c59
-rw-r--r--pcap-rpcap.c2127
-rw-r--r--pcap-rpcap.h465
-rw-r--r--pcap-savefile.manfile.in4
-rw-r--r--pcap-septel.c40
-rw-r--r--pcap-sita.c88
-rw-r--r--pcap-snf.c246
-rw-r--r--pcap-snit.c53
-rw-r--r--pcap-snoop.c93
-rw-r--r--pcap-stdinc.h95
-rw-r--r--pcap-tc.c1284
-rw-r--r--pcap-tc.h (renamed from pcap-canusb-linux.h)31
-rw-r--r--pcap-tstamp.manmisc.in51
-rw-r--r--pcap-usb-linux.c194
-rw-r--r--pcap-usb-linux.h4
-rw-r--r--pcap-win32.c1023
-rw-r--r--pcap.3pcap.in44
-rw-r--r--pcap.c977
-rw-r--r--pcap/bluetooth.h10
-rw-r--r--pcap/bpf.h1257
-rw-r--r--pcap/can_socketcan.h (renamed from Win32/Src/ffs.c)40
-rw-r--r--pcap/dlt.h1340
-rw-r--r--pcap/export-defs.h108
-rw-r--r--pcap/namedb.h32
-rw-r--r--pcap/nflog.h4
-rw-r--r--pcap/pcap.h302
-rw-r--r--pcap/sll.h2
-rw-r--r--pcap/usb.h12
-rw-r--r--pcap_activate.3pcap73
-rw-r--r--pcap_breakloop.3pcap4
-rw-r--r--pcap_can_set_rfmon.3pcap34
-rw-r--r--pcap_close.3pcap2
-rw-r--r--pcap_compile.3pcap.in2
-rw-r--r--pcap_create.3pcap2
-rw-r--r--pcap_datalink.3pcap.in2
-rw-r--r--pcap_datalink_name_to_val.3pcap5
-rw-r--r--pcap_datalink_val_to_name.3pcap16
-rw-r--r--pcap_dump.3pcap6
-rw-r--r--pcap_dump_close.3pcap2
-rw-r--r--pcap_dump_file.3pcap2
-rw-r--r--pcap_dump_flush.3pcap2
-rw-r--r--pcap_dump_ftell.3pcap2
-rw-r--r--pcap_dump_open.3pcap.in15
-rw-r--r--pcap_file.3pcap2
-rw-r--r--pcap_fileno.3pcap2
-rw-r--r--pcap_findalldevs.3pcap2
-rw-r--r--pcap_freecode.3pcap2
-rw-r--r--pcap_get_selectable_fd.3pcap14
-rw-r--r--pcap_get_tstamp_precision.3pcap.in2
-rw-r--r--pcap_geterr.3pcap4
-rw-r--r--pcap_inject.3pcap2
-rw-r--r--pcap_is_swapped.3pcap2
-rw-r--r--pcap_lib_version.3pcap2
-rw-r--r--pcap_list_datalinks.3pcap.in4
-rw-r--r--pcap_list_tstamp_types.3pcap.in2
-rw-r--r--pcap_lookupdev.3pcap2
-rw-r--r--pcap_lookupnet.3pcap2
-rw-r--r--pcap_loop.3pcap9
-rw-r--r--pcap_major_version.3pcap2
-rw-r--r--pcap_next_ex.3pcap2
-rw-r--r--pcap_offline_filter.3pcap2
-rw-r--r--pcap_open_dead.3pcap.in2
-rw-r--r--pcap_open_live.3pcap2
-rw-r--r--pcap_open_offline.3pcap.in2
-rw-r--r--pcap_set_buffer_size.3pcap2
-rw-r--r--pcap_set_datalink.3pcap2
-rw-r--r--pcap_set_immediate_mode.3pcap2
-rw-r--r--pcap_set_promisc.3pcap2
-rw-r--r--pcap_set_rfmon.3pcap2
-rw-r--r--pcap_set_snaplen.3pcap2
-rw-r--r--pcap_set_timeout.3pcap9
-rw-r--r--pcap_set_tstamp_precision.3pcap.in4
-rw-r--r--pcap_set_tstamp_type.3pcap.in4
-rw-r--r--pcap_setdirection.3pcap4
-rw-r--r--pcap_setfilter.3pcap2
-rw-r--r--pcap_setnonblock.3pcap10
-rw-r--r--pcap_snapshot.3pcap2
-rw-r--r--pcap_stats.3pcap2
-rw-r--r--pcap_statustostr.3pcap2
-rw-r--r--pcap_strerror.3pcap2
-rw-r--r--pcap_tstamp_type_name_to_val.3pcap4
-rw-r--r--pcap_tstamp_type_val_to_name.3pcap2
-rw-r--r--pcap_version.h.in13
-rw-r--r--portability.h216
-rw-r--r--remote-ext.h467
-rwxr-xr-xrunlex.sh233
-rw-r--r--savefile.c179
-rw-r--r--scanner.l248
-rw-r--r--sf-pcap-ng.c405
-rw-r--r--sf-pcap.c328
-rw-r--r--sockutils.c1230
-rw-r--r--sockutils.h241
-rw-r--r--tests/CMakeLists.txt42
-rw-r--r--tests/can_set_rfmon_test.c92
-rw-r--r--tests/capturetest.c67
-rw-r--r--tests/filtertest.c115
-rw-r--r--tests/findalldevstest.c56
-rw-r--r--tests/opentest.c77
-rw-r--r--tests/reactivatetest.c2
-rw-r--r--tests/selpolltest.c73
-rw-r--r--tests/valgrindtest.c90
227 files changed, 24711 insertions, 14656 deletions
diff --git a/CHANGES b/CHANGES
index eb73e28d77f0..178409659305 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,80 @@
+Tuesday, Oct. 25, 2016 mcr@sandelman.ca
+ Summary for 1.8.1 libpcap release
+ Add a target in Makefile.in for Exuberant Ctags use: 'extags'.
+ Rename configure.in to configure.ac: autoconf 2.59
+ Clean up the name-to-DLT mapping table.
+ Add some newer DLT_ values: IPMI_HPM_2,ZWAVE_R1_R2,ZWAVE_R3,WATTSTOPPER_DLM,ISO_14443,RDS
+ Clarify what the return values are for both success and failure.
+ Many changes to build on windows
+ Check for the "break the loop" condition in the inner loop for TPACKET_V3.
+ Fix handling of packet count in the TPACKET_V3 inner loop: GitHub issue #493.
+ Filter out duplicate looped back CAN frames.
+ Fix the handling of loopback filters for IPv6 packets.
+ Add a link-layer header type for RDS (IEC 62106) groups.
+ Use different intermediate folders for x86 and x64 builds on Windows.
+ On Linux, handle all CAN captures with pcap-linux.c, in cooked mode.
+ Removes the need for the "host-endian" link-layer header type.
+ Compile with '-Wused-but-marked-unused' in devel mode if supported
+ Have separate DLTs for big-endian and host-endian SocketCAN headers.
+ Reflect version.h being renamed to pcap_version.h.
+ Require that version.h be generated: all build procedures we support generate version.h (autoconf, CMake, MSVC)!
+ Properly check for sock_recv() errors.
+ Re-impose some of Winsock's limitations on sock_recv().
+ Replace sprintf() with pcap_snprintf().
+ Fix signature of pcap_stats_ex_remote().
+ Initial cmake support for remote packet capture.
+ Have rpcap_remoteact_getsock() return a SOCKET and supply an "is active" flag.
+ Clean up {DAG, Septel, Myricom SNF}-only builds.
+ Do UTF-16-to-ASCII conversion into the right place.
+ pcap_create_interface() needs the interface name on Linux.
+ Clean up hardware time stamp support: the "any" device does not support any time stamp types.
+ Add support for capturing on FreeBSD usbusN interfaces.
+ Add a LINKTYPE/DLT_ value for FreeBSD USB.
+ Go back to using PCAP_API on Windows.
+ CMake support
+ Add TurboCap support from WinPcap.
+ Recognize 802.1ad nested VLAN tag in vlan filter.
+
+Thursday Sep. 3, 2015 guy@alum.mit.edu
+ Summary for 1.7.5 libpcap release
+ Man page cleanups.
+ Add some allocation failure checks.
+ Fix a number of Linux/ucLinux configure/build issues.
+ Fix some memory leaks.
+ Recognize 802.1ad nested VLAN tag in vlan filter.
+ Fix building Bluetooth Linux Monitor support with BlueZ 5.1+
+
+Saturday Jun. 27, 2015 mcr@sandelman.ca
+ Summary for 1.7.4 libpcap release
+ Include fix for GitHub issue #424 -- out of tree builds.
+
+Friday Apr. 10, 2015 guy@alum.mit.edu
+ Summary for 1.7.3 libpcap release
+ Work around a Linux bonding driver bug.
+
+Thursday Feb. 12, 2015 guy@alum.mit.edu/mcr@sandelman.ca
+ Summary for 1.7.2 libpcap release
+ Support for filtering Geneve encapsulated packets.
+ Generalize encapsulation handling, fixing some bugs.
+ Don't add null addresses to address lists.
+ Add pcap_dump_open_append() to open for appending.
+ Fix the swapping of isochronous descriptors in Linux USB.
+ Attempt to handle TPACKET_V1 with 32-bit userland and 64-bit kernel.
+
+Wednesday Nov. 12, 2014 guy@alum.mit.edu/mcr@sandelman.ca
+ Summary for 1.7.0 libpcap release
+ Fix handling of zones for BPF on Solaris
+ new DLT for ZWAVE
+ clarifications for read timeouts.
+ Use BPF extensions in compiled filters, fixing VLAN filters
+ some fixes to compilation without stdint.h
+ EBUSY can now be returned by SNFv3 code.
+ Fix the range checks in BPF loads
+ Various DAG fixes.
+ Various Linux fixes.
+
Monday Aug. 12, 2014 guy@alum.mit.edu
- Summary for 1.6.2 tcpdump release
+ Summary for 1.6.2 libpcap release
Don't crash on filters testing a non-existent link-layer type
field.
Fix sending in non-blocking mode on Linux with memory-mapped
@@ -8,12 +83,12 @@ Monday Aug. 12, 2014 guy@alum.mit.edu
machines.
Saturday Jul. 19, 2014 mcr@sandelman.ca
- Summary for 1.6.1 tcpdump release
+ Summary for 1.6.1 libpcap release
some fixes for the any device
- changes for how --enable-XXX works
+ changes for how --enable-XXX (--enable-sniffing, --enable-can) works
Wednesday Jul. 2, 2014 mcr@sandelman.ca
- Summary for 1.6.0 tcpdump release
+ Summary for 1.6.0 libpcap release
Don't support D-Bus sniffing on OS X
fixes for byte order issues with NFLOG captures
Handle using cooked mode for DLT_NETLINK in activate_new().
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 000000000000..0ed8b61291a6
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,520 @@
+cmake_minimum_required( VERSION 2.8.8 )
+
+project( pcap )
+#
+# Call the library "wpcap" on Windows, for backwards compatibility.
+#
+if( WIN32 )
+ set( LIBRARY_NAME wpcap )
+else()
+ set( LIBRARY_NAME pcap )
+endif()
+
+###################################################################
+# Parameters
+###################################################################
+
+option (INET6 "Enable IPv6" ON)
+if( MSVC )
+ option (USE_STATIC_RT "Use static Runtime" ON)
+endif( MSVC )
+option (BUILD_SHARED_LIBS "Build shared libraries" ON)
+if( WIN32 )
+ set(PACKET_DLL_DIR "" CACHE PATH "Path to directory with include and lib subdirectories for packet.dll")
+endif( WIN32 )
+
+#
+# XXX - this should be an option, defaulting to "yes" for Windows and to
+# "no", for now, on UN*X.
+#
+if( WIN32 )
+ set( HAVE_REMOTE 1 )
+endif( WIN32 )
+
+######################################
+# Project settings
+######################################
+
+add_definitions( -DHAVE_CONFIG_H )
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${pcap_SOURCE_DIR}
+)
+
+if( WIN32 )
+ if( NOT "${PACKET_DLL_DIR}" STREQUAL "" )
+ include_directories("${PACKET_DLL_DIR}/Include")
+ if( CMAKE_CL_64 )
+ link_directories("${PACKET_DLL_DIR}/Lib/x64")
+ else( CMAKE_CL_64 )
+ link_directories("${PACKET_DLL_DIR}/Lib")
+ endif( CMAKE_CL_64 )
+ endif()
+ include_directories(
+ ../Common/
+ Win32/Include
+ )
+endif( WIN32)
+
+add_definitions( -DBUILDING_PCAP )
+
+if( MSVC )
+ add_definitions( -D__STDC__ )
+ add_definitions( -D_CRT_SECURE_NO_WARNINGS )
+ add_definitions( "-D_U_=" )
+elseif( CMAKE_COMPILER_IS_GNUCXX )
+ add_definitions( "-D_U_=__attribute__((unused))" )
+else(MSVC)
+ add_definitions( "-D_U_=" )
+endif( MSVC )
+
+if( MSVC )
+ if (USE_STATIC_RT)
+ MESSAGE( STATUS "Use STATIC runtime" )
+ set(NAME_RT MT)
+ set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT")
+ set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
+ set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
+ set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
+
+ set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
+ set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT")
+ set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
+ set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
+ else (USE_STATIC_RT)
+ MESSAGE( STATUS "Use DYNAMIC runtime" )
+ set(NAME_RT MD)
+ set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MD")
+ set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD")
+ set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
+ set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
+
+ set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MD")
+ set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MD")
+ set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MD")
+ set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MDd")
+ endif (USE_STATIC_RT)
+endif( MSVC )
+
+###################################################################
+# Detect available platform features
+###################################################################
+
+include(CheckIncludeFile)
+include(CheckFunctionExists)
+include(CheckStructHasMember)
+include(CheckTypeSize)
+
+#
+# Header files.
+#
+check_include_file( inttypes.h HAVE_INTTYPES_H )
+check_include_file( stdint.h HAVE_STDINT_H )
+check_include_file( unistd.h HAVE_UNISTD_H )
+if( NOT HAVE_UNISTD_H )
+ add_definitions( -DYY_NO_UNISTD_H )
+endif( NOT HAVE_UNISTD_H )
+check_include_file( bitypes.h HAVE_SYS_BITYPES_H )
+check_include_file( limits.h HAVE_LIMITS_H )
+
+#
+# Functions.
+#
+check_function_exists( strerror HAVE_STRERROR )
+check_function_exists( strlcpy HAVE_STRLCPY )
+check_function_exists( snprintf HAVE_SNPRINTF )
+check_function_exists( vsnprintf HAVE_VSNPRINTF )
+check_function_exists( strtok_r HAVE_STRTOK_R )
+
+if (WIN32)
+ #
+ # Check for Windows-only functions, such as packet.dll functions.
+ #
+ check_function_exists( PacketIsLoopbackAdapter HAVE_PACKET_IS_LOOPBACK_ADAPTER )
+endif()
+
+#
+# Data types.
+#
+# XXX - there's no check_struct() macro that's like check_struct_has_member()
+# except that it only checks for the existence of the structure type,
+# so we use check_struct_has_member() and look for ss_family.
+#
+check_struct_has_member("struct sockaddr_storage" ss_family sys/socket.h HAVE_SOCKADDR_STORAGE)
+set(CMAKE_EXTRA_INCLUDE_FILES unistd.h sys/socket.h)
+check_type_size("socklen_t" SOCKLEN_T)
+set(CMAKE_EXTRA_INCLUDE_FILES unistd.h)
+
+#
+# Structure fields.
+#
+check_struct_has_member("struct sockaddr" sa_len sys/socket.h HAVE_SOCKADDR_SA_LEN )
+
+if( INET6 )
+ MESSAGE( STATUS "Use IPv6" )
+endif( INET6 )
+
+if( WIN32 )
+ add_definitions( -DHAVE_ADDRINFO )
+endif( WIN32 )
+
+######################################
+# External dependencies
+######################################
+
+######################################
+# Input files
+######################################
+
+set(PROJECT_SOURCE_LIST_C
+ bpf_dump.c
+ bpf_image.c
+ etherent.c
+ fad-helpers.c
+ gencode.c
+ inet.c
+ nametoaddr.c
+ optimize.c
+ pcap-common.c
+ pcap.c
+ savefile.c
+ sf-pcap-ng.c
+ sf-pcap.c
+ bpf/net/bpf_filter.c
+)
+
+if( WIN32 )
+ set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/win_snprintf.c )
+else()
+ if( NOT HAVE_SNPRINTF )
+ set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/snprintf.c )
+ endif( NOT HAVE_SNPRINTF )
+ if( NOT HAVE_STRTOK_R )
+ set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/strtok_r.c )
+ endif( NOT HAVE_STRTOK_R )
+endif( WIN32 )
+
+if( HAVE_REMOTE )
+ set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C}
+ pcap-new.c pcap-rpcap.c sockutils.c)
+endif( HAVE_REMOTE )
+
+#
+# Determine the main pcap-XXX.c file to use.
+#
+if( WIN32 )
+ #
+ # WinPcap.
+ #
+ set( PCAP_TYPE win32 )
+else()
+ #
+ # UN*X - figure out what type of packet capture mechanism we
+ # have.
+ #
+ if( EXISTS /dev/bpf )
+ #
+ # Cloning BPF device.
+ #
+ set( PCAP_TYPE bpf )
+ AC_DEFINE(HAVE_CLONING_BPF,1,[define if you have a cloning BPF device])
+ elseif( EXISTS /dev/bpf0 )
+ set( PCAP_TYPE bpf )
+
+ #
+ # XXX - many more BPF checks.
+ #
+ elseif( EXISTS /usr/include/net/pfilt.h )
+ #
+ # DEC OSF/1, Digital UNIX, Tru64 UNIX
+ #
+ set( PCAP_TYPE pf )
+ elseif( EXISTS /dev/enet )
+ set( PCAP_TYPE enet )
+ elseif( EXISTS /dev/nit )
+ set( PCAP_TYPE snit )
+ elseif( EXISTS /usr/include/sys/net/nit.h )
+ set( PCAP_TYPE nit )
+ elseif( EXISTS /usr/include/linux/socket.h )
+ set( PCAP_TYPE linux )
+
+ #
+ # Do we have the wireless extensions?
+ #
+ check_include_file( linux/wireless.h HAVE_LINUX_WIRELESS_H )
+
+ #
+ # XXX - many more Linux checks.
+ #
+ elseif( EXISTS /usr/include/net/raw.h )
+ set( PCAP_TYPE snoop )
+ elseif( EXISTS /usr/include/odmi.h )
+ #
+ # On AIX, the BPF devices might not yet be present - they're
+ # created the first time libpcap runs after booting.
+ # We check for odmi.h instead.
+ #
+ set( PCAP_TYPE bpf )
+ elseif( /usr/include/sys/dlpi.h )
+ set( PCAP_TYPE dlpi )
+
+ #
+ # XXX - many more DLPI checks.
+ #
+ else()
+ set( PCAP_TYPE null )
+ endif()
+endif( WIN32 )
+message(STATUS "Packet capture mechanism type: ${PCAP_TYPE}")
+set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-${PCAP_TYPE}.c)
+
+#
+# Now figure out how we get a list of interfaces and addresses,
+# if we support capturing. Don't bother if we don't support
+# capturing.
+#
+if( NOT WIN32 )
+ #
+ # UN*X - figure out what type of interface list mechanism we
+ # have.
+ #
+ if( ${PCAP_TYPE} STREQUAL "null" )
+ #
+ # We can't capture, so we can't open any capture
+ # devices, so we won't return any interfaces.
+ #
+ set( FINDALLDEVS_TYPE null )
+ else()
+ check_function_exists( getifaddrs HAVE_GETIFADDRS )
+ if( ${HAVE_GETIFADDRS} )
+ #
+ # We have "getifaddrs()"; make sure we have <ifaddrs.h>
+ # as well, just in case some platform is really weird.
+ #
+ check_include_file( ifaddrs.h HAVE_IFADDRS_H )
+ if( ${HAVE_IFADDRS_H} )
+ #
+ # We have the header, so we use "getifaddrs()" to
+ # get the list of interfaces.
+ #
+ set( FINDALLDEVS_TYPE getad )
+ else()
+ #
+ # We don't have the header - give up.
+ # XXX - we could also fall back on some other
+ # mechanism, but, for now, this'll catch this
+ # problem so that we can at least try to figure
+ # out something to do on systems with "getifaddrs()"
+ # but without "ifaddrs.h", if there is something
+ # we can do on those systems.
+ #
+ message(FATAL_ERROR "Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>." )
+ endif()
+ else()
+ #
+ # Well, we don't have "getifaddrs()", so we have to use
+ # some other mechanism; determine what that mechanism is.
+ #
+ # The first thing we use is the type of capture mechanism,
+ # which is somewhat of a proxy for the OS we're using.
+ #
+ if( ${PCAP_TYPE} STREQUAL "dlpi" OR ${PCAP_TYPE} STREQUAL "libdlpi" )
+ #
+ # This might be Solaris 8 or later, with
+ # SIOCGLIFCONF, or it might be some other OS
+ # or some older version of Solaris, with
+ # just SIOCGIFCONF.
+ #
+ try_compile( HAVE_SIOCGLIFCONF ${CMAKE_CURRENT_BINARY_DIR} "${pcap_SOURCE_DIR}/config/have_siocglifconf.c" )
+ message( STATUS "HAVE_SIOCGLIFCONF = ${HAVE_SIOCGLIFCONF}" )
+ if( HAVE_SIOCGLIFCONF )
+ set( FINDALLDEVS_TYPE glifc )
+ else()
+ set( FINDALLDEVS_TYPE gifc )
+ endif()
+ else()
+ #
+ # Assume we just have SIOCGIFCONF.
+ # (XXX - on at least later Linux kernels, there's
+ # another mechanism, and we should be using that
+ # instead.)
+ #
+ set( FINDALLDEVS_TYPE gifc )
+ endif()
+ endif()
+ endif()
+ message(STATUS "Find-interfaces mechanism type: ${FINDALLDEVS_TYPE}")
+ set( PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} fad-${FINDALLDEVS_TYPE}.c )
+endif()
+
+file(GLOB PROJECT_SOURCE_LIST_CORE_H
+ *.h
+ pcap/*.h
+)
+set( PROJECT_SOURCE_LIST_H ${PROJECT_SOURCE_LIST_H} ${PROJECT_SOURCE_LIST_CORE_H} )
+
+if( WIN32 )
+ file(GLOB PROJECT_SOURCE_LIST_WIN32_H
+ Win32/Include/*.h
+ )
+ set( PROJECT_SOURCE_LIST_H ${PROJECT_SOURCE_LIST_H} ${PROJECT_SOURCE_LIST_WIN32_H} )
+endif( WIN32 )
+
+#
+# {Flex} and YACC/Berkeley YACC/Bison.
+# From a mail message to the CMake mailing list by Andy Cedilnik of
+# Kitware.
+#
+
+#
+# Try to find Flex, a Windows version of Flex, or Lex.
+#
+find_program(LEX_EXECUTABLE NAMES flex win_flex lex)
+if( ${LEX_EXECUTABLE} STREQUAL "LEX_EXECUTABLE-NOTFOUND" )
+ message(FATAL_ERROR "Neither flex nor win_flex nor lex was found." )
+endif()
+message(STATUS "Lexical analyzer generator: ${LEX_EXECUTABLE}")
+
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/scanner.c ${CMAKE_CURRENT_BINARY_DIR}/scanner.h
+ SOURCE ${pcap_SOURCE_DIR}/scanner.l
+ COMMAND ${LEX_EXECUTABLE} -P pcap_ --header-file=scanner.h --nounput -o${CMAKE_CURRENT_BINARY_DIR}/scanner.c ${pcap_SOURCE_DIR}/scanner.l
+ DEPENDS ${pcap_SOURCE_DIR}/scanner.l
+)
+
+#
+# Since scanner.c does not exist yet when cmake is run, mark
+# it as generated.
+#
+# Since scanner.c includes grammar.h, mark that as a dependency.
+#
+set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/scanner.c PROPERTIES
+ GENERATED TRUE
+ OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scanner.h
+)
+
+#
+# Add scanner.c to the list of sources.
+#
+#set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/scanner.c)
+
+#
+# Try to find YACC or Bison.
+#
+find_program(YACC_EXECUTABLE NAMES bison win_bison byacc yacc)
+if( ${YACC_EXECUTABLE} STREQUAL "YACC_EXECUTABLE-NOTFOUND" )
+ message(FATAL_ERROR "Neither bison nor win_bison nor byacc nor yacc was found." )
+endif()
+message(STATUS "Parser generator: ${YACC_EXECUTABLE}")
+
+#
+# Create custom command for the scanner.
+# Find out whether it's Bison or notby looking at the last component
+# of the path (without a .exe extension, if this is Windows).
+#
+get_filename_component(YACC_NAME ${YACC_EXECUTABLE} NAME_WE)
+if( "${YACC_NAME}" STREQUAL "bison" OR "${YACC_NAME}" STREQUAL "win_bison" )
+ set( YACC_COMPATIBILITY_FLAG "-y" )
+endif()
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/grammar.c ${CMAKE_CURRENT_BINARY_DIR}/grammar.h
+ SOURCE ${pcap_SOURCE_DIR}/grammar.y
+ COMMAND ${YACC_EXECUTABLE} ${YACC_COMPATIBILITY_FLAG} -p pcap_ -o ${CMAKE_CURRENT_BINARY_DIR}/grammar.c -d ${pcap_SOURCE_DIR}/grammar.y
+ DEPENDS ${pcap_SOURCE_DIR}/grammar.y
+)
+
+#
+# Since grammar.c does not exists yet when cmake is run, mark
+# it as generated.
+#
+set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/grammar.c PROPERTIES
+ GENERATED TRUE
+)
+
+#
+# Add grammar.c to the list of sources.
+#
+#set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/grammar.c)
+
+if( WIN32 )
+ #
+ # CMake does not love Windows.
+ #
+ file(TO_NATIVE_PATH "${pcap_SOURCE_DIR}/GenVersion.bat" GenVersion_path)
+ file(TO_NATIVE_PATH "${pcap_SOURCE_DIR}/VERSION" VERSION_path)
+ file(TO_NATIVE_PATH "${pcap_SOURCE_DIR}/pcap_version.h.in" version_h_in_path)
+ file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h" version_h_path)
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h
+ SOURCE ${pcap_SOURCE_DIR}/VERSION ${pcap_SOURCE_DIR}/pcap_version.h.in
+ COMMAND ${GenVersion_path} ${VERSION_path} ${version_h_in_path} ${version_h_path}
+ DEPENDS ${pcap_SOURCE_DIR}/VERSION ${pcap_SOURCE_DIR}/pcap_version.h.in
+ )
+else( WIN32 )
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.c
+ SOURCE ${pcap_SOURCE_DIR}/VERSION
+ COMMAND ${pcap_SOURCE_DIR}/gen_version_c.sh ${pcap_SOURCE_DIR}/VERSION ${CMAKE_CURRENT_BINARY_DIR}/version.c
+ DEPENDS ${pcap_SOURCE_DIR}/VERSION
+ )
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h
+ SOURCE ${pcap_SOURCE_DIR}/VERSION
+ COMMAND ${pcap_SOURCE_DIR}/gen_version_header.sh ${pcap_SOURCE_DIR}/VERSION ${pcap_SOURCE_DIR}/pcap_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h
+ DEPENDS ${pcap_SOURCE_DIR}/VERSION
+ )
+
+ #
+ # Since version.c does not exists yet when cmake is run, mark
+ # it as generated.
+ #
+ set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/version.c PROPERTIES
+ GENERATED TRUE
+ )
+
+ #
+ # Add version.c to the list of sources.
+ #
+ set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/version.c)
+endif( WIN32 )
+
+#
+# Since pcap_version.h does not exists yet when cmake is run, mark
+# it as generated.
+#
+set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h PROPERTIES
+ GENERATED TRUE
+)
+
+#
+# Add pcap_version.h to the list of headers.
+#
+set(PROJECT_SOURCE_LIST_H ${PROJECT_SOURCE_LIST_H} ${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h)
+
+source_group("Source Files" FILES ${PROJECT_SOURCE_LIST_C})
+source_group("Header Files" FILES ${PROJECT_SOURCE_LIST_H})
+
+######################################
+# Register targets
+######################################
+
+add_library(${LIBRARY_NAME}
+ ${PROJECT_SOURCE_LIST_C}
+ ${CMAKE_CURRENT_BINARY_DIR}/grammar.c
+ ${CMAKE_CURRENT_BINARY_DIR}/scanner.c
+ ${PROJECT_SOURCE_LIST_H}
+)
+
+if( WIN32 )
+ target_link_libraries ( ${LIBRARY_NAME}
+ packet
+ ws2_32
+ )
+endif( WIN32 )
+
+######################################
+# Write out the config.h file
+######################################
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
diff --git a/CREDITS b/CREDITS
index dfc4e411036d..b40152f5e54b 100644
--- a/CREDITS
+++ b/CREDITS
@@ -2,11 +2,12 @@ This file lists people who have contributed to libpcap:
The current maintainers:
Bill Fenner <fenner at research dot att dot com>
- Denis Ovsienko <infrastation at yandex dot ru>
+ Denis Ovsienko <denis at ovsienko dot info>
Fulvio Risso <risso at polito dot it>
Guy Harris <guy at alum dot mit dot edu>
Hannes Gredler <hannes at juniper dot net>
Michael Richardson <mcr at sandelman dot ottawa dot on dot ca>
+ Francois-Xavier Le Bail <fx dot lebail at yahoo dot com>
Additional people who have contributed patches:
@@ -45,7 +46,7 @@ Additional people who have contributed patches:
David Young <dyoung at ojctech dot com>
Dean Gaudet <dean at arctic dot org>
dhruv <rsrivat at sourceforge dot net>
- Don Ebright <Don dot Ebright at compuware dot com>
+ Don Ebright <Don dot Ebright at compuware dot com>
Dug Song <dugsong at monkey dot org>
Dustin Spicuzza <dustin at virtualroadside dot com>
dzejarczech <dzejarczech at sourceforge dot net>
@@ -83,6 +84,7 @@ Additional people who have contributed patches:
Jefferson Ogata <jogata at nodc dot noaa dot gov>
Jesper Dangaard Brouer <hawk at comx dot dk>
Jesper Peterson <jesper at endace dot com>
+ Jesse Gross <jesse at nicira dot com>
Jiri Slaby <jirislaby at gmail dot com>
Joerg Mayer <jmayer at loplof dot de>
John Bankier <jbankier at rainfinity dot com>
@@ -105,6 +107,7 @@ Additional people who have contributed patches:
Mansour Behabadi <mansour at oxplot dot com>
Marcus Felipe Pereira <marcus at task dot com dot br>
Mark C. Brown <mbrown at hp dot com>
+ Mark Johnston <markjdb at gmail dot com>
Mark Pizzolato <List-tcpdump-workers at subscriptions dot pizzolato dot net>
Markus Mayer <markus_mayer at sourceforge dot net>
Martin Husemann <martin at netbsd dot org>
diff --git a/GenVersion.bat b/GenVersion.bat
new file mode 100644
index 000000000000..babf3737efa5
--- /dev/null
+++ b/GenVersion.bat
@@ -0,0 +1,23 @@
+REM
+REM Automatically generate pcap_version.h based on pcap_version.h.in
+REM for Windows
+REM The version string comes from VERSION
+REM @echo off
+REM
+
+setlocal enableextensions disabledelayedexpansion
+
+set "search=%%%%LIBPCAP_VERSION%%%%"
+set /p replace=<%1
+
+if exist %3 del %3 2>nul
+
+for /f "delims=" %%i in ('type %2' ) do (
+ set "line=%%i"
+ setlocal enabledelayedexpansion
+ set "line=!line:%search%=%replace%!"
+ >>%3 echo(!line!
+ endlocal
+)
+
+echo pcap_version.h generated
diff --git a/INSTALL.txt b/INSTALL.txt
index 7bbbf0cb8e1c..f305aa2b7929 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -16,7 +16,7 @@ does support packet capture but libpcap does not support that
particular type. (If you have HP-UX, see below.) If your system uses a
packet capture not supported by libpcap, please send us patches; don't
forget to include an autoconf fragment suitable for use in
-configure.in.
+configure.ac.
It is possible to override the default packet capture type, although
the circumstance where this works are limited. For example if you have
@@ -31,40 +31,22 @@ You will need an ANSI C compiler to build libpcap. The configure script
will abort if your compiler is not ANSI compliant. If this happens, use
the generally available GNU C compiler (GCC).
-If you use flex, you must use version 2.4.6 or higher. The configure
-script automatically detects the version of flex and will not use it
-unless it is new enough. You can use "flex -V" to see what version you
-have (unless it's really old). The current version of flex is available
-at flex.sourceforge.net and often comes packaged by means of the OS.
-As of this writing, the current version is 2.5.37.
+You will need either Flex 2.5.31 or later, or a version of Lex
+compatible with it (if any exist), to build libpcap. The configure
+script will abort if there isn't any such program. If you have an older
+version of Flex, or don't have a compatible version of Lex, the current
+version of flex is available at flex.sourceforge.net.
-If you use bison, you must use flex (and visa versa). The configure
-script automatically falls back to lex and yacc if both flex and bison
-are not found.
+You will need either Bison, Berkeley YACC, or a version of YACC
+compatible with them (if any exist), to build libpcap. The configure
+script will abort if there isn't any such program. If you don't have
+any such program, the current version of Bison can be found at
+http://ftp.gnu.org/gnu/bison/ and the current version of Berkeley YACC
+can be found at http://invisible-island.net/byacc/.
-Sometimes the stock C compiler does not interact well with flex and
-bison. The list of problems includes undefined references for alloca.
-You can get around this by installing gcc or manually disabling flex
-and bison with:
-
- ./configure --without-flex --without-bison
-
-If your system only has AT&T lex, this is okay unless your libpcap
-program uses other lex/yacc generated code. (Although it's possible to
-map the yy* identifiers with a script, we use flex and bison so we
-don't feel this is necessary.)
-
-Some systems support the Berkeley Packet Filter natively; for example
-out of the box OSF and BSD/OS have bpf. If your system does not support
-bpf, you will need to pick up:
-
- ftp://ftp.ee.lbl.gov/bpf-*.tar.Z
-
-Note well: you MUST have kernel source for your operating system in
-order to install bpf. An exception is SunOS 4; the bpf distribution
-includes replacement kernel objects for some of the standard SunOS 4
-network device drivers. See the bpf INSTALL document for more
-information.
+Sometimes the stock C compiler does not interact well with Flex and
+Bison. The list of problems includes undefined references for alloca.
+You can get around this by installing GCC.
If you use Solaris, there is a bug with bufmod(7) that is fixed in
Solaris 2.3.2 (aka SunOS 5.3.2). Setting a snapshot length with the
@@ -178,14 +160,14 @@ packet timestamps aren't very good. This appears to be due to haphazard
handling of the timestamp in the kernel.
Note well: there is rumoured to be a version of tcpdump floating around
-called 3.0.3 that includes libpcap and is supposed to support Linux.
+called 3.0.3 that includes libpcap and is supposed to support Linux.
You should be advised that neither the Network Research Group at LBNL
-nor the Tcpdump Group ever generated a release with this version number.
+nor the Tcpdump Group ever generated a release with this version number.
The LBNL Network Research Group notes with interest that a standard
cracker trick to get people to install trojans is to distribute bogus
-packages that have a version number higher than the current release.
+packages that have a version number higher than the current release.
They also noted with annoyance that 90% of the Linux related bug reports
-they got are due to changes made to unofficial versions of their page.
+they got are due to changes made to unofficial versions of their page.
If you are having trouble but aren't using a version that came from
tcpdump.org, please try that before submitting a bug report!
@@ -239,11 +221,11 @@ the libpcap 0.6.2 source release, so this release of libpcap might also
build without changes on UnixWare 7.
If linking tcpdump fails with "Undefined: _alloca" when using bison on
-a Sun4, your version of bison is broken. In any case version 1.16 or
+a Sun4, your version of Bison is broken. In any case version 1.16 or
higher is recommended (1.14 is known to cause problems 1.16 is known to
work). Either pick up a current version from:
- ftp://ftp.gnu.org/pub/gnu/bison
+ http://ftp.gnu.org/gnu/bison/
or hack around it by inserting the lines:
@@ -289,6 +271,7 @@ FILES
CHANGES - description of differences between releases
ChmodBPF/* - Mac OS X startup item to set ownership and permissions
on /dev/bpf*
+CMakeLists.txt - CMake file
CREDITS - people that have helped libpcap along
INSTALL.txt - this file
LICENSE - the license under which tcpdump is distributed
@@ -317,7 +300,7 @@ config.guess - autoconf support
config.h.in - autoconf input
config.sub - autoconf support
configure - configure script (run this first)
-configure.in - configure script source
+configure.ac - configure script source
dlpisubs.c - DLPI-related functions for pcap-dlpi.c and pcap-libdlpi.c
dlpisubs.h - DLPI-related function declarations
etherent.c - /etc/ethers support routines
@@ -325,9 +308,6 @@ ethertype.h - Ethernet protocol types and names definitions
fad-getad.c - pcap_findalldevs() for systems with getifaddrs()
fad-gifc.c - pcap_findalldevs() for systems with only SIOCGIFLIST
fad-glifc.c - pcap_findalldevs() for systems with SIOCGLIFCONF
-fad-null.c - pcap_findalldevs() for systems without capture support
-fad-sita.c - pcap_findalldevs() for systems with SITA support
-fad-win32.c - pcap_findalldevs() for WinPcap
filtertest.c - test program for BPF compiler
findalldevstest.c - test program for pcap_findalldevs()
gencode.c - BPF code generation routines
@@ -345,7 +325,6 @@ nametoaddr.c - hostname to address routines
nlpid.h - OSI network layer protocol identifier definitions
net - symlink to bpf/net
optimize.c - BPF optimization routines
-packaging - packaging information for building libpcap RPMs
pcap/bluetooth.h - public definition of DLT_BLUETOOTH_HCI_H4_WITH_PHDR header
pcap/bpf.h - BPF definitions
pcap/namedb.h - public libpcap name database definitions
@@ -389,7 +368,6 @@ pcap_*.3pcap - manual entries for library functions
pcap-filter.4 - manual entry for filter syntax
pcap-linktype.4 - manual entry for link-layer header types
ppp.h - Point to Point Protocol definitions
-runlex.sh - wrapper for Lex/Flex
savefile.c - offline support
scanner.l - filter string scanner
sunatmpos.h - definitions for SunATM capturing
diff --git a/LICENSE b/LICENSE
index dea5f7d54d6b..a10474d54aeb 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,9 +1,9 @@
License: BSD
-
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
-
+
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
@@ -13,7 +13,7 @@ are met:
3. The names of the authors may not be used to endorse or promote
products derived from this software without specific prior
written permission.
-
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/Makefile-devel-adds b/Makefile-devel-adds
index 7bf6420c1c82..fea63bbce3a7 100644
--- a/Makefile-devel-adds
+++ b/Makefile-devel-adds
@@ -2,12 +2,12 @@
# Auto-regenerate configure script or Makefile when things change.
# From autoconf.info . Works best with GNU Make.
#
-${srcdir}/configure: configure.in aclocal.m4
+${srcdir}/configure: configure.ac aclocal.m4
cd ${srcdir} && autoconf
# autoheader might not change config.h.in, so touch a stamp file.
${srcdir}/config.h.in: ${srcdir}/stamp-h.in
-${srcdir}/stamp-h.in: configure.in aclocal.m4
+${srcdir}/stamp-h.in: configure.ac aclocal.m4
cd ${srcdir} && autoheader
echo timestamp > ${srcdir}/stamp-h.in
diff --git a/Makefile.in b/Makefile.in
index 1c2d7459943f..e71d973ca448 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -49,12 +49,13 @@ LN_S = @LN_S@
MKDEP = @MKDEP@
CCOPT = @V_CCOPT@
INCLS = -I. @V_INCLS@
-DEFS = @DEFS@ @V_DEFS@
+DEFS = -DBUILDING_PCAP @DEFS@ @V_DEFS@
ADDLOBJS = @ADDLOBJS@
ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@
LIBS = @LIBS@
-CFLAGS = @CFLAGS@
-LDFLAGS = @LDFLAGS@
+CROSSFLAGS=
+CFLAGS = @CFLAGS@ ${CROSSFLAGS}
+LDFLAGS = @LDFLAGS@ ${CROSSFLAGS}
DYEXT = @DYEXT@
V_RPATH_OPT = @V_RPATH_OPT@
DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@
@@ -68,13 +69,8 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
RANLIB = @RANLIB@
-#
-# Flex and bison allow you to specify the prefixes of the global symbols
-# 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 = @LEX@
+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
@@ -83,11 +79,11 @@ YACC = @V_YACC@
@rm -f $@
$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
-PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @CAN_SRC@ @NETFILTER_SRC@ @CANUSB_SRC@ @DBUS_SRC@
-FSRC = fad-@V_FINDALLDEVS@.c
+PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @NETFILTER_SRC@ @DBUS_SRC@
+FSRC = @V_FINDALLDEVS@
SSRC = @SSRC@
-CSRC = pcap.c inet.c gencode.c optimize.c nametoaddr.c etherent.c \
- savefile.c sf-pcap.c sf-pcap-ng.c pcap-common.c \
+CSRC = pcap.c inet.c fad-helpers.c gencode.c optimize.c nametoaddr.c \
+ etherent.c savefile.c sf-pcap.c sf-pcap-ng.c pcap-common.c \
bpf_image.c bpf_dump.c
GENSRC = scanner.c grammar.c bpf_filter.c version.c
LIBOBJS = @LIBOBJS@
@@ -103,6 +99,9 @@ PUBHDR = \
pcap-namedb.h \
pcap/bpf.h \
pcap/bluetooth.h \
+ pcap/can_socketcan.h \
+ pcap/dlt.h \
+ pcap/export-defs.h \
pcap/ipnet.h \
pcap/namedb.h \
pcap/nflog.h \
@@ -115,37 +114,43 @@ HDR = $(PUBHDR) \
arcnet.h \
atmuni31.h \
ethertype.h \
+ extract.h \
gencode.h \
ieee80211.h \
llc.h \
+ nametoaddr.h \
nlpid.h \
pcap-common.h \
pcap-int.h \
pcap-stdinc.h \
+ portability.h \
ppp.h \
sf-pcap.h \
sf-pcap-ng.h \
sunatmpos.h
TESTS = \
+ @VALGRINDTEST@ \
capturetest \
+ can_set_rfmon_test \
filtertest \
findalldevstest \
opentest \
- selpolltest \
- valgrindtest
+ reactivatetest \
+ selpolltest
TESTS_SRC = \
+ tests/valgrindtest.c \
tests/capturetest.c \
+ tests/can_set_rfmon_test.c \
tests/filtertest.c \
tests/findalldevstest.c \
tests/opentest.c \
tests/reactivatetest.c \
- tests/selpolltest.c \
- tests/valgrindtest.c
+ tests/selpolltest.c
GENHDR = \
- scanner.h tokdefs.h version.h
+ scanner.h grammar.h pcap_version.h
TAGFILES = \
$(SRC) $(HDR)
@@ -231,6 +236,8 @@ EXTRA_DIST = \
ChmodBPF/ChmodBPF \
ChmodBPF/StartupParameters.plist \
CREDITS \
+ CMakeLists.txt \
+ GenVersion.bat \
INSTALL.txt \
LICENSE \
Makefile.in \
@@ -253,29 +260,37 @@ EXTRA_DIST = \
aclocal.m4 \
bpf/net/bpf_filter.c \
chmod_bpf \
+ cmakeconfig.h.in \
+ cmake/preconfigure.cmake \
+ config/have_siocglifconf.c \
config.guess \
config.h.in \
config.sub \
configure \
- configure.in \
+ configure.ac \
dlpisubs.c \
dlpisubs.h \
fad-getad.c \
fad-gifc.c \
fad-glifc.c \
- fad-null.c \
- fad-sita.c \
- fad-win32.c \
+ fad-helpers.c \
+ gen_version_c.sh \
+ gen_version_header.sh \
grammar.y \
install-sh \
lbl/os-aix4.h \
+ lbl/os-aix7.h \
lbl/os-hpux11.h \
lbl/os-osf4.h \
lbl/os-osf5.h \
lbl/os-solaris2.h \
lbl/os-sunos4.h \
lbl/os-ultrix4.h \
+ missing/getopt.c \
+ missing/getopt.h \
missing/snprintf.c \
+ missing/strtok_r.c \
+ missing/win_snprintf.c \
mkdep \
msdos/bin2c.c \
msdos/common.dj \
@@ -291,16 +306,11 @@ EXTRA_DIST = \
msdos/pktdrvr.h \
msdos/readme.dos \
org.tcpdump.chmod_bpf.plist \
- packaging/pcap.spec.in \
pcap-bpf.c \
pcap-bt-linux.c \
pcap-bt-linux.h \
pcap-bt-monitor-linux.c \
pcap-bt-monitor-linux.h \
- pcap-can-linux.c \
- pcap-can-linux.h \
- pcap-canusb-linux.c \
- pcap-canusb-linux.h \
pcap-config.in \
pcap-dag.c \
pcap-dag.h \
@@ -314,11 +324,14 @@ EXTRA_DIST = \
pcap-libdlpi.c \
pcap-linux.c \
pcap-namedb.h \
+ pcap-new.c \
pcap-netfilter-linux.c \
pcap-netfilter-linux.h \
pcap-nit.c \
pcap-null.c \
pcap-pf.c \
+ pcap-rpcap.c \
+ pcap-rpcap.h \
pcap-septel.c \
pcap-septel.h \
pcap-sita.h \
@@ -328,34 +341,22 @@ EXTRA_DIST = \
pcap-snf.h \
pcap-snit.c \
pcap-snoop.c \
+ pcap-tc.c \
+ pcap-tc.h \
pcap-usb-linux.c \
pcap-usb-linux.h \
pcap-win32.c \
- runlex.sh \
+ remote-ext.h \
+ sockutils.c \
+ sockutils.h \
scanner.l \
+ tests/CMakeLists.txt \
+ pcap_version.h.in \
Win32/Include/Gnuc.h \
- Win32/Include/addrinfo.h \
- Win32/Include/bittypes.h \
- Win32/Include/cdecl_ext.h \
- Win32/Include/inetprivate.h \
- Win32/Include/ip6_misc.h \
- Win32/Include/sockstorage.h \
- Win32/Include/arpa/nameser.h \
Win32/Include/net/if.h \
- Win32/Include/net/netdb.h \
- Win32/Include/net/paths.h \
- Win32/Prj/libpcap.dsp \
- Win32/Prj/libpcap.dsw \
- Win32/Src/ffs.c \
- Win32/Src/gai_strerror.c \
- Win32/Src/getaddrinfo.c \
- Win32/Src/getnetbynm.c \
- Win32/Src/getnetent.c \
- Win32/Src/getopt.c \
- Win32/Src/getservent.c \
- Win32/Src/inet_aton.c \
- Win32/Src/inet_net.c \
- Win32/Src/inet_pton.c
+ Win32/Prj/wpcap.sln \
+ Win32/Prj/wpcap.vcxproj \
+ Win32/Prj/wpcap.vcxproj.filters
all: libpcap.a shared pcap-config
@@ -443,24 +444,33 @@ libpcap.shareda: $(OBJ)
libpcap.none:
scanner.c: $(srcdir)/scanner.l
- @rm -f $@
- $(srcdir)/runlex.sh $(LEX) -o$@ $<
-
-scanner.o: scanner.c tokdefs.h
+ $(LEX) -P pcap_ --header-file=scanner.h --nounput -o scanner.c $<
+scanner.h: scanner.c
+## Recover from the removal of $@
+ @if test -f $@; then :; else \
+ rm -f scanner.c; \
+ $(MAKE) $(MAKEFLAGS) scanner.c; \
+ fi
+
+scanner.o: scanner.c grammar.h
$(CC) $(FULL_CFLAGS) -c scanner.c
-pcap.o: version.h
+pcap.o: pcap_version.h
-tokdefs.h: grammar.c
grammar.c: $(srcdir)/grammar.y
- @rm -f grammar.c tokdefs.h
- $(YACC) -d $<
- mv y.tab.c grammar.c
- mv y.tab.h tokdefs.h
+ $(YACC) -p pcap_ -o grammar.c -d $<
+grammar.h: grammar.c
+## Recover from the removal of $@
+ @if test -f $@; then :; else \
+ rm -f grammar.c; \
+ $(MAKE) $(MAKEFLAGS) grammar.c; \
+ fi
grammar.o: grammar.c
- @rm -f $@
- $(CC) $(FULL_CFLAGS) -Dyylval=pcap_lval -c grammar.c
+ $(CC) $(FULL_CFLAGS) -c grammar.c
+
+gencode.o: $(srcdir)/gencode.c grammar.h scanner.h
+ $(CC) $(FULL_CFLAGS) -c $(srcdir)/gencode.c
version.o: version.c
$(CC) $(FULL_CFLAGS) -c version.c
@@ -468,32 +478,21 @@ version.o: version.c
snprintf.o: $(srcdir)/missing/snprintf.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
-version.c: $(srcdir)/VERSION
+strtok_r.o: $(srcdir)/missing/strtok_r.c
+ $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strtok_r.c
+
+version.c: $(srcdir)/VERSION $(srcdir)/gen_version_c.sh
+ #
+ # Older programs import this if they want to show the
+ # libpcap version number, rather than calling
+ # pcap_lib_version(), so we need to export it.
+ #
@rm -f $@
- if grep GIT ${srcdir}/VERSION >/dev/null; then \
- read ver <${srcdir}/VERSION; \
- echo $$ver | tr -d '\012'; \
- date +_%Y_%m_%d; \
- else \
- cat ${srcdir}/VERSION; \
- fi | sed -e 's/.*/char pcap_version[] = "&";/' > $@
+ $(srcdir)/gen_version_c.sh $(srcdir)/VERSION $@
-#
-# NOTE: this really is supposed to be static; importing a string
-# from a shared library does not work very well on many
-# versions of UNIX (Solaris, Linux, and the BSDs, for example),
-# so we make the version string static and return it from
-# a function, which does work.
-#
-version.h: $(srcdir)/VERSION
+pcap_version.h: $(srcdir)/VERSION $(srcdir)/pcap_version.h.in $(srcdir)/gen_version_header.sh
@rm -f $@
- if grep GIT ${srcdir}/VERSION >/dev/null; then \
- read ver <${srcdir}/VERSION; \
- echo $$ver | tr -d '\012'; \
- date +_%Y_%m_%d; \
- else \
- cat ${srcdir}/VERSION; \
- fi | sed -e 's/.*/static const char pcap_version_string[] = "libpcap version &";/' > $@
+ $(srcdir)/gen_version_header.sh $(srcdir)/VERSION $(srcdir)/pcap_version.h.in $@
bpf_filter.c: $(srcdir)/bpf/net/bpf_filter.c
rm -f bpf_filter.c
@@ -530,6 +529,9 @@ tests: $(TESTS)
capturetest: tests/capturetest.c libpcap.a
$(CC) $(FULL_CFLAGS) -I. -L. -o capturetest $(srcdir)/tests/capturetest.c libpcap.a $(LIBS)
+can_set_rfmon_test: tests/can_set_rfmon_test.c libpcap.a
+ $(CC) $(FULL_CFLAGS) -I. -L. -o can_set_rfmon_test $(srcdir)/tests/can_set_rfmon_test.c libpcap.a $(LIBS)
+
filtertest: tests/filtertest.c libpcap.a
$(CC) $(FULL_CFLAGS) -I. -L. -o filtertest $(srcdir)/tests/filtertest.c libpcap.a $(LIBS)
@@ -539,6 +541,9 @@ findalldevstest: tests/findalldevstest.c libpcap.a
opentest: tests/opentest.c libpcap.a
$(CC) $(FULL_CFLAGS) -I. -L. -o opentest $(srcdir)/tests/opentest.c libpcap.a $(LIBS)
+reactivatetest: tests/reactivatetest.c libpcap.a
+ $(CC) $(FULL_CFLAGS) -I. -L. -o reactivatetest $(srcdir)/tests/reactivatetest.c libpcap.a $(LIBS)
+
selpolltest: tests/selpolltest.c libpcap.a
$(CC) $(FULL_CFLAGS) -I. -L. -o selpolltest $(srcdir)/tests/selpolltest.c libpcap.a $(LIBS)
@@ -728,13 +733,12 @@ distclean: clean
rm -f $(MAN3PCAP_EXPAND:.in=) $(MANFILE:.in=) $(MANMISC:.in=)
rm -rf autom4te.cache
+extags: $(TAGFILES)
+ ctags $(TAGFILES)
+
tags: $(TAGFILES)
ctags -wtd $(TAGFILES)
-packaging/pcap.spec: packaging/pcap.spec.in VERSION
- RPMVERSION=`cat VERSION | sed s/-.*//g`; \
- sed -e s/@VERSION@/$$RPMVERSION/ -e s/@NAME@/libpcap-`cat VERSION`/ $< > $@
-
releasetar:
@cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \
mkdir $$name; \
diff --git a/README b/README
index 46fcc5689e70..9f65948d4ef2 100644
--- a/README
+++ b/README
@@ -76,15 +76,15 @@ information on configuring that option.
Note to Linux distributions and *BSD systems that include libpcap:
-There's now a rule to make a shared library, which should work on Linux
+There's now a rule to make a shared library, which should work on Linux
and *BSD, among other platforms.
-It sets the soname of the library to "libpcap.so.1"; this is what it
-should be, *NOT* libpcap.so.1.x or libpcap.so.1.x.y or something such as
+It sets the soname of the library to "libpcap.so.1"; this is what it
+should be, *NOT* libpcap.so.1.x or libpcap.so.1.x.y or something such as
that.
-We've been maintaining binary compatibility between libpcap releases for
-quite a while; there's no reason to tie a binary linked with libpcap to
+We've been maintaining binary compatibility between libpcap releases for
+quite a while; there's no reason to tie a binary linked with libpcap to
a particular release of libpcap.
Problems, bugs, questions, desirable enhancements, etc. should be sent
diff --git a/README.Win32 b/README.Win32
index 503836e341f1..0a42dab93d4b 100644
--- a/README.Win32
+++ b/README.Win32
@@ -1,9 +1,9 @@
-Under Win32, libpcap is integrated in the WinPcap packet capture system.
-WinPcap provides a framework that allows libpcap to capture the packets
-under Windows 95, Windows 98, Windows ME, Windows NT 4, Windows 2000
+Under Win32, libpcap is integrated in the WinPcap packet capture system.
+WinPcap provides a framework that allows libpcap to capture the packets
+under Windows 95, Windows 98, Windows ME, Windows NT 4, Windows 2000
and Windows XP.
-WinPcap binaries and source code can be found at http://winpcap.polito.it:
-they include also a developer's pack with all the necessary to compile
+WinPcap binaries and source code can be found at http://winpcap.polito.it:
+they include also a developer's pack with all the necessary to compile
libpcap-based applications under Windows.
How to compile libpcap with Visual Studio
@@ -12,35 +12,35 @@ How to compile libpcap with Visual Studio
In order to compile libpcap you will need:
- version 6 (or higher) of Microsoft Visual Studio
-- The November 2001 (or later) edition of Microsoft Platform
-Software Development Kit (SDK), that contains some necessary includes
+- The November 2001 (or later) edition of Microsoft Platform
+Software Development Kit (SDK), that contains some necessary includes
for IPv6 support. You can download it from http://www.microsoft.com/sdk
-- the latest WinPcap sources from http://winpcap.polito.it/install
+- the latest WinPcap sources from http://winpcap.polito.it/install
-The WinPcap source code already contains a recent (usually the latest
-stable) version of libpcap. If you need to compile a different one,
-simply download it from www.tcpdump.org and copy the sources in the
+The WinPcap source code already contains a recent (usually the latest
+stable) version of libpcap. If you need to compile a different one,
+simply download it from www.tcpdump.org and copy the sources in the
winpcap\wpcap\libpcap folder of the WinPcap distribution. If you want to
-compile a libpcap source retrieved from the tcpdump.org Git, you will
-have to create the scanner and the grammar by hand (with lex and yacc)
+compile a libpcap source retrieved from the tcpdump.org Git, you will
+have to create the scanner and the grammar by hand (with lex and yacc)
or with the cygnus makefile, since The Visual Studio project is not able
to build them.
-Open the project file winpcap\wpcap\prj\wpcap.dsw with Visual Studio and
-build wpcap.dll. wpcap.lib, the library file to link with the applications,
-will be generated in winpcap\wpcap\lib\. wpcap.dll will be generated in
-winpcap\wpcap\prj\release or winpcap\wpcap\prj\debug depending on the type
+Open the project file winpcap\wpcap\prj\wpcap.dsw with Visual Studio and
+build wpcap.dll. wpcap.lib, the library file to link with the applications,
+will be generated in winpcap\wpcap\lib\. wpcap.dll will be generated in
+winpcap\wpcap\prj\release or winpcap\wpcap\prj\debug depending on the type
of binary that is being created.
How to compile libpcap with Cygnus
----------------------------------
-To build wpcap.dll, cd to the directory WPCAP/PRJ of the WinPcap source code
-distribution and type "make". libwpcap.a, the library file to link with the
-applications, will be generated in winpcap\wpcap\lib\. wpcap.dll will be
+To build wpcap.dll, cd to the directory WPCAP/PRJ of the WinPcap source code
+distribution and type "make". libwpcap.a, the library file to link with the
+applications, will be generated in winpcap\wpcap\lib\. wpcap.dll will be
generated in winpcap\wpcap\prj.
-Remember, you CANNOT use the MSVC-generated .lib files with gcc, use
+Remember, you CANNOT use the MSVC-generated .lib files with gcc, use
libwpcap.a instead.
"make install" installs wpcap.dll in the Windows system folder.
diff --git a/README.aix b/README.aix
index f457df321702..92e513ff7413 100644
--- a/README.aix
+++ b/README.aix
@@ -76,8 +76,8 @@ If you use DLPI:
Then you need to type:
strload -f /etc/dlpi.conf
-
- Check again with strload -q -d dlpi that the dlpi driver is loaded.
+
+ Check again with strload -q -d dlpi that the dlpi driver is loaded.
Alternatively, you can uncomment the lines for DLPI in
/etc/pse.conf and reboot the machine; this way DLPI will always
diff --git a/README.hpux b/README.hpux
index 88c27f8a2581..65ecff97c249 100644
--- a/README.hpux
+++ b/README.hpux
@@ -5,14 +5,14 @@ HP-UX and cannot upgrade, please continue reading.
HP-UX patches to fix packet capture problems
Note that packet-capture programs such as tcpdump may, on HP-UX, not be
-able to see packets sent from the machine on which they're running.
+able to see packets sent from the machine on which they're running.
Some articles on groups.google.com discussing this are:
http://groups.google.com/groups?selm=82ld3v%2480i%241%40mamenchi.zrz.TU-Berlin.DE
which says:
- Newsgroups: comp.sys.hp.hpux
+ Newsgroups: comp.sys.hp.hpux
Subject: Re: Did someone made tcpdump working on 10.20 ?
Date: 12/08/1999
From: Lutz Jaenicke <jaenicke@emserv1.ee.TU-Berlin.DE>
@@ -27,14 +27,14 @@ which says:
>must me "patched" (poked) in order to see outbound data in promiscuous mode.
>Many things to do .... So the question is : did someone has already this
>"ready to use" PHNE_**** patch ?
-
+
Two things:
1. You do need a late "LAN products cumulative patch" (e.g. PHNE_18173
for s700/10.20).
2. You must use
echo 'lanc_outbound_promisc_flag/W1' | /usr/bin/adb -w /stand/vmunix /dev/kmem
You can insert this e.g. into /sbin/init.d/lan
-
+
Best regards,
Lutz
@@ -44,7 +44,7 @@ and
which says:
- Newsgroups: comp.sys.hp.hpux
+ Newsgroups: comp.sys.hp.hpux
Subject: Re: tcpdump only shows incoming packets
Date: 02/15/2000
From: Rick Jones <foo@bar.baz.invalid>
@@ -56,12 +56,12 @@ which says:
> outgoing. I have tried tcpflow-0.12 which also uses libpcap and the
> same thing happens. Could someone please give me a hint on how to
> get this right?
-
+
Search/Read the archives ?-)
-
+
What you are seeing is expected, un-patched, behaviour for an HP-UX
system. On 11.00, you need to install the latest lancommon/DLPI
- patches, and then the latest driver patch for the interface(s) in use.
+ patches, and then the latest driver patch for the interface(s) in use.
At that point, a miracle happens and you should start seeing outbound
traffic.
@@ -79,7 +79,7 @@ which says:
From: Harald Skotnes <harald@cc.uit.no>
Rick Jones wrote:
-
+
...
> What you are seeing is expected, un-patched, behaviour for an HP-UX
@@ -87,7 +87,7 @@ which says:
> patches, and then the latest driver patch for the interface(s) in
> use. At that point, a miracle happens and you should start seeing
> outbound traffic.
-
+
Thanks a lot. I have this problem on several machines running HPUX
10.20 and 11.00. The machines where patched up before y2k so did not
know what to think. Anyway I have now installed PHNE_19766,
@@ -101,7 +101,7 @@ And another message to tcpdump-workers@tcpdump.org, from Rick Jones:
Date: Mon, 29 Apr 2002 15:59:55 -0700
From: Rick Jones
- To: tcpdump-workers@tcpdump.org
+ To: tcpdump-workers@tcpdump.org
Subject: Re: [tcpdump-workers] I Can't Capture the Outbound Traffic
...
@@ -130,21 +130,21 @@ captures on HP-UX 9.x:
Dave Barr (barr@cis.ohio-state.edu) wrote:
: Has anyone ported tcpdump (or something similar) to HP/UX 9.x?
-
+
I'm reasonably confident that any port of tcpdump to 9.X would require
the (then optional) STREAMS product. This would bring DLPI, which is
what one uses to access interfaces in promiscuous mode.
-
+
I'm not sure that HP even sells the 9.X STREAMS product any longer,
since HP-UX 9.X is off the pricelist (well, maybe 9.10 for the old 68K
- devices).
-
+ devices).
+
Your best bet is to be up on 10.20 or better if that is at all
- possible. If your hardware is supported by it, I'd go with HP-UX 11.
+ possible. If your hardware is supported by it, I'd go with HP-UX 11.
If you want to see the system's own outbound traffic, you'll never get
that functionality on 9.X, but it might happen at some point for 10.20
- and 11.X.
-
+ and 11.X.
+
rick jones
(as per other messages cited here, the ability to see the system's own
@@ -178,12 +178,12 @@ An additional note, from Jost Martin, for HP-UX 10.20:
(thanks to hildeb@www.stahl.bau.tu-bs.de (Ralf Hildebrandt) who
posted the security-part some time ago)
- <<hack_ip_stack>>
+ <<hack_ip_stack>>
(Don't switch IP-forwarding off, if you need it !)
Install the hack as /sbin/init.d/hacl_ip_stack (adjust
permissions !) and make a sequencing-symlink
- /sbin/rc2.d/S350hack_ip_stack pointing to this script.
+ /sbin/rc2.d/S350hack_ip_stack pointing to this script.
Now all this is done on every reboot.
According to Rick Jones, the global promiscuous switch also has to be
diff --git a/README.linux b/README.linux
index f92cd22b9e91..ffcb9288ca13 100644
--- a/README.linux
+++ b/README.linux
@@ -19,13 +19,13 @@ the 2.0[.x] kernel:
The Packet protocol is used by applications which communicate
directly with network devices without an intermediate network
protocol implemented in the kernel, e.g. tcpdump. If you want them
- to work, choose Y.
+ to work, choose Y.
This driver is also available as a module called af_packet.o ( =
code which can be inserted in and removed from the running kernel
whenever you want). If you want to compile it as a module, say M
here and read Documentation/modules.txt; if you use modprobe or
- kmod, you may also want to add "alias net-pf-17 af_packet" to
+ kmod, you may also want to add "alias net-pf-17 af_packet" to
/etc/modules.conf.
and the note for the 2.2[.x] kernel says:
@@ -47,7 +47,7 @@ In addition, there is an option that, in 2.2 and later kernels, will
allow packet capture filters specified to programs such as tcpdump to be
executed in the kernel, so that packets that don't pass the filter won't
be copied from the kernel to the program, rather than having all packets
-copied to the program and libpcap doing the filtering in user mode.
+copied to the program and libpcap doing the filtering in user mode.
Copying packets from the kernel to the program consumes a significant
amount of CPU, so filtering in the kernel can reduce the overhead of
diff --git a/README.septel b/README.septel
index fbc88df38af4..483de6a7f969 100644
--- a/README.septel
+++ b/README.septel
@@ -14,7 +14,7 @@ where DIR is the root of the Septel software distribution, for example
/var/src/septel.
By default (if you write only ./configure --with-septel) it takes
-./../septel as argument for DIR.
+./../septel as argument for DIR.
If the Septel software is correctly detected 'configure' will
report:
diff --git a/README.sita b/README.sita
index ee7a426846f0..014d51d98d98 100644
--- a/README.sita
+++ b/README.sita
@@ -12,7 +12,7 @@ These additions/extensions have been made to PCAP to allow it to
capture packets from a SITA ACN device (and potentially others).
To enable its support you need to ensure that the distribution has
-a correct configure.in file; that can be created if neccessay by
+a correct configure.ac file; that can be created if neccessay by
using the normal autoconf procedure of:
aclocal
diff --git a/README.tru64 b/README.tru64
index 7fe1ef07b530..2420d9e12180 100644
--- a/README.tru64
+++ b/README.tru64
@@ -1,4 +1,4 @@
-The following instructions are applicable to Tru64 UNIX
+The following instructions are applicable to Tru64 UNIX
(formerly Digital UNIX (formerly DEC OSF/1)) version 4.0, and
probably to later versions as well; at least some options apply to
Digital UNIX 3.2 - perhaps all do.
diff --git a/TODO b/TODO
index 73325e1965dd..aae24c22d251 100644
--- a/TODO
+++ b/TODO
@@ -6,11 +6,11 @@ Important stuff (to be done before the next release)
General
-- configure should not be in Git. Most open source projects have an
- autogen.sh script to run autoconf etc. after checkout. I think we
- should stick to the standard.
+- configure should not be in Git. Most open source projects have an
+ autogen.sh script to run autoconf etc. after checkout. I think we
+ should stick to the standard.
-- The source files should be better documented. There is no official
+- The source files should be better documented. There is no official
design guideline for what is done where. There should be a common coding
style (okay, you can guess that by looking at the code) and a guide for
what needs to be documented.
@@ -18,7 +18,7 @@ General
Less urgent items
-----------------
-- Better documentation and cleanup of the interface. I am seeing a few
+- Better documentation and cleanup of the interface. I am seeing a few
problems at the first glance which needs fixing:
+ pcap_lookupnet makes little to no sense with protocols != IPv4
+ not very well suited for interactive programs (think ethereal). There
diff --git a/VERSION b/VERSION
index fdd3be6df54a..a8fdfda1c782 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.6.2
+1.8.1
diff --git a/Win32/Include/Gnuc.h b/Win32/Include/Gnuc.h
index aa4959873796..e1b5951d1cb3 100644
--- a/Win32/Include/Gnuc.h
+++ b/Win32/Include/Gnuc.h
@@ -1,13 +1,3 @@
-/* Define __P() macro, if necessary */
-
-#ifndef __P
-#if __STDC__
-#define __P(protos) protos
-#else
-#define __P(protos) ()
-#endif
-#endif
-
/* inline foo */
#ifndef __cplusplus
#ifdef __GNUC__
@@ -16,29 +6,3 @@
#define inline
#endif
#endif
-
-/*
- * Handle new and old "dead" routine prototypes
- *
- * For example:
- *
- * __dead void foo(void) __attribute__((volatile));
- *
- */
-#ifdef __GNUC__
-#ifndef __dead
-#define __dead volatile
-#endif
-#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-#ifndef __attribute__
-#define __attribute__(args)
-#endif
-#endif
-#else
-#ifndef __dead
-#define __dead
-#endif
-#ifndef __attribute__
-#define __attribute__(args)
-#endif
-#endif
diff --git a/Win32/Include/addrinfo.h b/Win32/Include/addrinfo.h
deleted file mode 100644
index 4db7384af205..000000000000
--- a/Win32/Include/addrinfo.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef HAVE_ADDRINFO
-
-/*
- * Error return codes from getaddrinfo()
- */
-#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
-#define EAI_AGAIN 2 /* temporary failure in name resolution */
-#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
-#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
-#define EAI_FAMILY 5 /* ai_family not supported */
-#define EAI_MEMORY 6 /* memory allocation failure */
-#define EAI_NODATA 7 /* no address associated with hostname */
-#define EAI_NONAME 8 /* hostname nor servname provided, or not known */
-#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
-#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
-#define EAI_SYSTEM 11 /* system error returned in errno */
-#define EAI_BADHINTS 12
-#define EAI_PROTOCOL 13
-#define EAI_MAX 14
-
-/* internal error */
-#define NETDB_INTERNAL -1 /* see errno */
-
-/*
- * Flag values for getaddrinfo()
- */
-#define AI_PASSIVE 0x00000001 /* get address to use bind() */
-#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
-#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
-/* valid flags for addrinfo */
-#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
-
-#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
-#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
-#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
-#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
-/* special recommended flags for getipnodebyname */
-#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
-
-struct addrinfo {
- int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
- int ai_family; /* PF_xxx */
- int ai_socktype; /* SOCK_xxx */
- int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
- size_t ai_addrlen; /* length of ai_addr */
- char *ai_canonname; /* canonical name for hostname */
- struct sockaddr *ai_addr; /* binary address */
- struct addrinfo *ai_next; /* next structure in linked list */
-};
-
-extern void freeaddrinfo (struct addrinfo *);
-extern void freehostent (struct hostent *);
-extern char *gai_strerror (int);
-extern int getaddrinfo (const char *, const char *,
- const struct addrinfo *, struct addrinfo **);
-extern int getnameinfo (const struct sockaddr *, size_t, char *,
- size_t, char *, size_t, int);
-extern struct hostent *getipnodebyaddr (const void *, size_t, int, int *);
-extern struct hostent *getipnodebyname (const char *, int, int, int *);
-extern int inet_pton (int, const char *, void *);
-extern const char *inet_ntop (int, const void *, char *, size_t);
-#else
-
-#ifndef EAI_BADHINTS
-#define EAI_BADHINTS 12
-#endif
-
-#ifndef EAI_PROTOCOL
-#define EAI_PROTOCOL 13
-#endif
-
-#ifndef EAI_MAX
-#define EAI_MAX 14
-#endif
-
-#ifndef NETDB_INTERNAL
-#define NETDB_INTERNAL -1 /* see errno */
-#endif
-
-#ifndef AI_MASK
-/* valid flags for addrinfo */
-#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
-#endif
-
-#endif /* HAVE_ADDRINFO */
-
-/*
- * Constants for getnameinfo()
- */
-#ifndef NI_MAXHOST
-#define NI_MAXHOST 1025
-#endif
-#ifndef NI_MAXSERV
-#define NI_MAXSERV 32
-#endif
-
-/*
- * Flag values for getnameinfo()
- */
-#ifndef NI_NOFQDN
-#define NI_NOFQDN 0x00000001
-#endif
-#ifndef NI_NUMERICHOST
-#define NI_NUMERICHOST 0x00000002
-#endif
-#ifndef NI_NAMEREQD
-#define NI_NAMEREQD 0x00000004
-#endif
-#ifndef NI_NUMERICSERV
-#define NI_NUMERICSERV 0x00000008
-#endif
-#ifndef NI_DGRAM
-#define NI_DGRAM 0x00000010
-#endif
-
diff --git a/Win32/Include/arpa/nameser.h b/Win32/Include/arpa/nameser.h
deleted file mode 100644
index 18f185cf5b34..000000000000
--- a/Win32/Include/arpa/nameser.h
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- * ++Copyright++ 1983, 1989, 1993
- * -
- * Copyright (c) 1983, 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * -
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- * -
- * --Copyright--
- */
-
-/*
- * @(#)nameser.h 8.1 (Berkeley) 6/2/93
- * nameser.h,v 1.2 1995/05/06 14:23:54 hjl Exp
- */
-
-#ifndef _NAMESER_H_
-#define _NAMESER_H_
-
-#ifndef WIN32
-#include <sys/param.h>
-#if (!defined(BSD)) || (BSD < 199306)
-# include <sys/bitypes.h>
-#else
-# include <sys/types.h>
-#endif
-#include <sys/cdefs.h>
-#else
-#include <pcap-stdinc.h>
-#define __LITTLE_ENDIAN 1
-#define __BYTE_ORDER __LITTLE_ENDIAN
-#endif
-
-/*
- * revision information. this is the release date in YYYYMMDD format.
- * it can change every day so the right thing to do with it is use it
- * in preprocessor commands such as "#if (__BIND > 19931104)". do not
- * compare for equality; rather, use it to determine whether your resolver
- * is new enough to contain a certain feature.
- */
-
-#define __BIND 19940417 /* interface version stamp */
-
-/*
- * Define constants based on rfc883
- */
-#define PACKETSZ 512 /* maximum packet size */
-#define MAXDNAME 256 /* maximum domain name */
-#define MAXCDNAME 255 /* maximum compressed domain name */
-#define MAXLABEL 63 /* maximum length of domain label */
-#define HFIXEDSZ 12 /* #/bytes of fixed data in header */
-#define QFIXEDSZ 4 /* #/bytes of fixed data in query */
-#define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
-#define INT32SZ 4 /* for systems without 32-bit ints */
-#define INT16SZ 2 /* for systems without 16-bit ints */
-#define INADDRSZ 4 /* for sizeof(struct inaddr) != 4 */
-
-/*
- * Internet nameserver port number
- */
-#define NAMESERVER_PORT 53
-
-/*
- * Currently defined opcodes
- */
-#define QUERY 0x0 /* standard query */
-#define IQUERY 0x1 /* inverse query */
-#define STATUS 0x2 /* nameserver status query */
-/*#define xxx 0x3 *//* 0x3 reserved */
-#define NS_NOTIFY_OP 0x4 /* notify secondary of SOA change */
-#ifdef ALLOW_UPDATES
- /* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */
-# define UPDATEA 0x9 /* add resource record */
-# define UPDATED 0xa /* delete a specific resource record */
-# define UPDATEDA 0xb /* delete all named resource record */
-# define UPDATEM 0xc /* modify a specific resource record */
-# define UPDATEMA 0xd /* modify all named resource record */
-# define ZONEINIT 0xe /* initial zone transfer */
-# define ZONEREF 0xf /* incremental zone referesh */
-#endif
-
-/*
- * Currently defined response codes
- */
-#ifdef HAVE_ADDRINFO
-#define NOERROR 0 /* no error */
-#endif /* HAVE_ADDRINFO */
-#define FORMERR 1 /* format error */
-#define SERVFAIL 2 /* server failure */
-#define NXDOMAIN 3 /* non existent domain */
-#define NOTIMP 4 /* not implemented */
-#define REFUSED 5 /* query refused */
-#ifdef ALLOW_UPDATES
- /* non standard */
-# define NOCHANGE 0xf /* update failed to change db */
-#endif
-
-/*
- * Type values for resources and queries
- */
-#define T_A 1 /* host address */
-#define T_NS 2 /* authoritative server */
-#define T_MD 3 /* mail destination */
-#define T_MF 4 /* mail forwarder */
-#define T_CNAME 5 /* canonical name */
-#define T_SOA 6 /* start of authority zone */
-#define T_MB 7 /* mailbox domain name */
-#define T_MG 8 /* mail group member */
-#define T_MR 9 /* mail rename name */
-#define T_NULL 10 /* null resource record */
-#define T_WKS 11 /* well known service */
-#define T_PTR 12 /* domain name pointer */
-#define T_HINFO 13 /* host information */
-#define T_MINFO 14 /* mailbox information */
-#define T_MX 15 /* mail routing information */
-#define T_TXT 16 /* text strings */
-#define T_RP 17 /* responsible person */
-#define T_AFSDB 18 /* AFS cell database */
-#define T_X25 19 /* X_25 calling address */
-#define T_ISDN 20 /* ISDN calling address */
-#define T_RT 21 /* router */
-#define T_NSAP 22 /* NSAP address */
-#define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
-#define T_SIG 24 /* security signature */
-#define T_KEY 25 /* security key */
-#define T_PX 26 /* X.400 mail mapping */
-#define T_GPOS 27 /* geographical position (withdrawn) */
-#define T_AAAA 28 /* IP6 Address */
-#define T_LOC 29 /* Location Information */
- /* non standard */
-#define T_UINFO 100 /* user (finger) information */
-#define T_UID 101 /* user ID */
-#define T_GID 102 /* group ID */
-#define T_UNSPEC 103 /* Unspecified format (binary data) */
- /* Query type values which do not appear in resource records */
-#define T_AXFR 252 /* transfer zone of authority */
-#define T_MAILB 253 /* transfer mailbox records */
-#define T_MAILA 254 /* transfer mail agent records */
-#define T_ANY 255 /* wildcard match */
-
-/*
- * Values for class field
- */
-
-#define C_IN 1 /* the arpa internet */
-#define C_CHAOS 3 /* for chaos net (MIT) */
-#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
- /* Query class values which do not appear in resource records */
-#define C_ANY 255 /* wildcard match */
-
-/*
- * Status return codes for T_UNSPEC conversion routines
- */
-#define CONV_SUCCESS 0
-#define CONV_OVERFLOW (-1)
-#define CONV_BADFMT (-2)
-#define CONV_BADCKSUM (-3)
-#define CONV_BADBUFLEN (-4)
-
-#ifndef __BYTE_ORDER
-#if (BSD >= 199103)
-# include <machine/endian.h>
-#else
-#ifdef linux
-# include <endian.h>
-#else
-#define __LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
-#define __BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
-#define __PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
-
-#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
- defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
- defined(__alpha__) || defined(__alpha)
-#define __BYTE_ORDER __LITTLE_ENDIAN
-#endif
-
-#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
- defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
- defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
- defined(apollo) || defined(__convex__) || defined(_CRAY) || \
- defined(__hppa) || defined(__hp9000) || \
- defined(__hp9000s300) || defined(__hp9000s700) || \
- defined (BIT_ZERO_ON_LEFT) || defined(m68k)
-#define __BYTE_ORDER __BIG_ENDIAN
-#endif
-#endif /* linux */
-#endif /* BSD */
-#endif /* __BYTE_ORDER */
-
-#if !defined(__BYTE_ORDER) || \
- (__BYTE_ORDER != __BIG_ENDIAN && __BYTE_ORDER != __LITTLE_ENDIAN && \
- __BYTE_ORDER != __PDP_ENDIAN)
- /* you must determine what the correct bit order is for
- * your compiler - the next line is an intentional error
- * which will force your compiles to bomb until you fix
- * the above macros.
- */
- error "Undefined or invalid __BYTE_ORDER";
-#endif
-
-/*
- * Structure for query header. The order of the fields is machine- and
- * compiler-dependent, depending on the byte/bit order and the layout
- * of bit fields. We use bit fields only in int variables, as this
- * is all ANSI requires. This requires a somewhat confusing rearrangement.
- */
-
-typedef struct {
- unsigned id :16; /* query identification number */
-#if __BYTE_ORDER == __BIG_ENDIAN
- /* fields in third byte */
- unsigned qr: 1; /* response flag */
- unsigned opcode: 4; /* purpose of message */
- unsigned aa: 1; /* authoritive answer */
- unsigned tc: 1; /* truncated message */
- unsigned rd: 1; /* recursion desired */
- /* fields in fourth byte */
- unsigned ra: 1; /* recursion available */
- unsigned pr: 1; /* primary server req'd (!standard) */
- unsigned unused :2; /* unused bits (MBZ as of 4.9.3a3) */
- unsigned rcode :4; /* response code */
-#endif
-#if __BYTE_ORDER == __LITTLE_ENDIAN || __BYTE_ORDER == __PDP_ENDIAN
- /* fields in third byte */
- unsigned rd :1; /* recursion desired */
- unsigned tc :1; /* truncated message */
- unsigned aa :1; /* authoritive answer */
- unsigned opcode :4; /* purpose of message */
- unsigned qr :1; /* response flag */
- /* fields in fourth byte */
- unsigned rcode :4; /* response code */
- unsigned unused :2; /* unused bits (MBZ as of 4.9.3a3) */
- unsigned pr :1; /* primary server req'd (!standard) */
- unsigned ra :1; /* recursion available */
-#endif
- /* remaining bytes */
- unsigned qdcount :16; /* number of question entries */
- unsigned ancount :16; /* number of answer entries */
- unsigned nscount :16; /* number of authority entries */
- unsigned arcount :16; /* number of resource entries */
-} HEADER;
-
-/*
- * Defines for handling compressed domain names
- */
-#define INDIR_MASK 0xc0
-
-/*
- * Structure for passing resource records around.
- */
-struct rrec {
- int16_t r_zone; /* zone number */
- int16_t r_class; /* class number */
- int16_t r_type; /* type number */
- u_int32_t r_ttl; /* time to live */
- int r_size; /* size of data area */
- char *r_data; /* pointer to data */
-};
-
-//extern u_int16_t _getshort __P((const u_char *));
-//extern u_int32_t _getlong __P((const u_char *));
-
-/*
- * Inline versions of get/put short/long. Pointer is advanced.
- *
- * These macros demonstrate the property of C whereby it can be
- * portable or it can be elegant but rarely both.
- */
-#define GETSHORT(s, cp) { \
- register u_char *t_cp = (u_char *)(cp); \
- (s) = ((u_int16_t)t_cp[0] << 8) \
- | ((u_int16_t)t_cp[1]) \
- ; \
- (cp) += INT16SZ; \
-}
-
-#define GETLONG(l, cp) { \
- register u_char *t_cp = (u_char *)(cp); \
- (l) = ((u_int32_t)t_cp[0] << 24) \
- | ((u_int32_t)t_cp[1] << 16) \
- | ((u_int32_t)t_cp[2] << 8) \
- | ((u_int32_t)t_cp[3]) \
- ; \
- (cp) += INT32SZ; \
-}
-
-#define PUTSHORT(s, cp) { \
- register u_int16_t t_s = (u_int16_t)(s); \
- register u_char *t_cp = (u_char *)(cp); \
- *t_cp++ = t_s >> 8; \
- *t_cp = t_s; \
- (cp) += INT16SZ; \
-}
-
-#define PUTLONG(l, cp) { \
- register u_int32_t t_l = (u_int32_t)(l); \
- register u_char *t_cp = (u_char *)(cp); \
- *t_cp++ = t_l >> 24; \
- *t_cp++ = t_l >> 16; \
- *t_cp++ = t_l >> 8; \
- *t_cp = t_l; \
- (cp) += INT32SZ; \
-}
-
-#endif /* !_NAMESER_H_ */
diff --git a/Win32/Include/bittypes.h b/Win32/Include/bittypes.h
deleted file mode 100644
index 7c0cbdeb5f3b..000000000000
--- a/Win32/Include/bittypes.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 1999 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#ifndef _BITTYPES_H
-#define _BITTYPES_H
-
-#ifndef HAVE_U_INT8_T
-typedef unsigned char u_int8_t;
-typedef signed char int8_t;
-#endif /* HAVE_U_INT8_T */
-
-#ifndef HAVE_U_INT16_T
-typedef unsigned short u_int16_t;
-typedef signed short int16_t;
-#endif /* HAVE_U_INT16_T */
-
-#ifndef HAVE_U_INT32_T
-typedef unsigned int u_int32_t;
-typedef signed int int32_t;
-#endif /* HAVE_U_INT32_T */
-
-#ifndef HAVE_U_INT64_T
-#ifdef _MSC_EXTENSIONS
-typedef unsigned _int64 u_int64_t;
-typedef _int64 int64_t;
-#else /* _MSC_EXTENSIONS */
-typedef unsigned long long u_int64_t;
-typedef long long int64_t;
-#endif /* _MSC_EXTENSIONS */
-#endif /* HAVE_U_INT64_T */
-
-#ifndef PRId64
-#ifdef _MSC_EXTENSIONS
-#define PRId64 "I64d"
-#else /* _MSC_EXTENSIONS */
-#define PRId64 "lld"
-#endif /* _MSC_EXTENSIONS */
-#endif /* PRId64 */
-
-#ifndef PRIo64
-#ifdef _MSC_EXTENSIONS
-#define PRIo64 "I64o"
-#else /* _MSC_EXTENSIONS */
-#define PRIo64 "llo"
-#endif /* _MSC_EXTENSIONS */
-#endif /* PRIo64 */
-
-#ifndef PRIx64
-#ifdef _MSC_EXTENSIONS
-#define PRIx64 "I64x"
-#else /* _MSC_EXTENSIONS */
-#define PRIx64 "llx"
-#endif /* _MSC_EXTENSIONS */
-#endif /* PRIx64 */
-
-#ifndef PRIu64
-#ifdef _MSC_EXTENSIONS
-#define PRIu64 "I64u"
-#else /* _MSC_EXTENSIONS */
-#define PRIu64 "llu"
-#endif /* _MSC_EXTENSIONS */
-#endif /* PRIu64 */
-
-#endif /* _BITTYPES_H */
diff --git a/Win32/Include/cdecl_ext.h b/Win32/Include/cdecl_ext.h
deleted file mode 100644
index 9591db264574..000000000000
--- a/Win32/Include/cdecl_ext.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 1999 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#ifndef HAVE_PORTABLE_PROTOTYPE
-
-#if defined(__STDC__) || defined(__cplusplus)
-#define __P(protos) protos /* full-blown ANSI C */
-#else
-#define __P(protos) () /* traditional C preprocessor */
-#endif
-
-#endif /* !HAVE_PORTABLE_PROTOTYPE */
diff --git a/Win32/Include/inetprivate.h b/Win32/Include/inetprivate.h
deleted file mode 100644
index e25ed3d6c9bc..000000000000
--- a/Win32/Include/inetprivate.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 1999 - 2003
- * NetGroup, Politecnico di Torino (Italy)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the Politecnico di Torino nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <sys/types.h>
-#include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <net/netdb.h>
-#include <stdio.h>
-#include <errno.h>
-#include <arpa/nameser.h>
-
-extern void _sethtent(int f);
-extern void _endhtent(void);
-extern struct hostent *_gethtent(void);
-extern struct hostent *_gethtbyname(const char *name);
-extern struct hostent *_gethtbyaddr(const char *addr, int len,
- int type);
-extern int _validuser(FILE *hostf, const char *rhost,
- const char *luser, const char *ruser, int baselen);
-extern int _checkhost(const char *rhost, const char *lhost, int len);
-#if 0
-extern void putlong(u_long l, u_char *msgp);
-extern void putshort(u_short l, u_char *msgp);
-extern u_int32_t _getlong(register const u_char *msgp);
-extern u_int16_t _getshort(register const u_char *msgp);
-extern void p_query(char *msg);
-extern void fp_query(char *msg, FILE *file);
-extern char *p_cdname(char *cp, char *msg, FILE *file);
-extern char *p_rr(char *cp, char *msg, FILE *file);
-extern char *p_type(int type);
-extern char * p_class(int class);
-extern char *p_time(u_long value);
-#endif
-extern char * hostalias(const char *name);
-extern void sethostfile(char *name);
-extern void _res_close (void);
-extern void ruserpass(const char *host, char **aname, char **apass);
diff --git a/Win32/Include/ip6_misc.h b/Win32/Include/ip6_misc.h
deleted file mode 100644
index 0b578c33c11d..000000000000
--- a/Win32/Include/ip6_misc.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (c) 1993, 1994, 1997
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*
- * This file contains a collage of declarations for IPv6 from FreeBSD not present in Windows
- */
-
-#include <winsock2.h>
-
-#include <ws2tcpip.h>
-
-#ifndef __MINGW32__
-#define IN_MULTICAST(a) IN_CLASSD(a)
-#endif
-
-#define IN_EXPERIMENTAL(a) ((((u_int32_t) (a)) & 0xf0000000) == 0xf0000000)
-
-#define IN_LOOPBACKNET 127
-
-#if defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF)
-/* IPv6 address */
-struct in6_addr
- {
- union
- {
- u_int8_t u6_addr8[16];
- u_int16_t u6_addr16[8];
- u_int32_t u6_addr32[4];
- } in6_u;
-#define s6_addr in6_u.u6_addr8
-#define s6_addr16 in6_u.u6_addr16
-#define s6_addr32 in6_u.u6_addr32
-#define s6_addr64 in6_u.u6_addr64
- };
-
-#define IN6ADDR_ANY_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
-#define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
-#endif /* __MINGW32__ */
-
-
-#if (defined _MSC_VER) || (defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF))
-typedef unsigned short sa_family_t;
-#endif
-
-
-#if defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF)
-
-#define __SOCKADDR_COMMON(sa_prefix) \
- sa_family_t sa_prefix##family
-
-/* Ditto, for IPv6. */
-struct sockaddr_in6
- {
- __SOCKADDR_COMMON (sin6_);
- u_int16_t sin6_port; /* Transport layer port # */
- u_int32_t sin6_flowinfo; /* IPv6 flow information */
- struct in6_addr sin6_addr; /* IPv6 address */
- };
-
-#define IN6_IS_ADDR_V4MAPPED(a) \
- ((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \
- (((u_int32_t *) (a))[2] == htonl (0xffff)))
-
-#define IN6_IS_ADDR_MULTICAST(a) (((u_int8_t *) (a))[0] == 0xff)
-
-#define IN6_IS_ADDR_LINKLOCAL(a) \
- ((((u_int32_t *) (a))[0] & htonl (0xffc00000)) == htonl (0xfe800000))
-
-#define IN6_IS_ADDR_LOOPBACK(a) \
- (((u_int32_t *) (a))[0] == 0 && ((u_int32_t *) (a))[1] == 0 && \
- ((u_int32_t *) (a))[2] == 0 && ((u_int32_t *) (a))[3] == htonl (1))
-#endif /* __MINGW32__ */
-
-#define ip6_vfc ip6_ctlun.ip6_un2_vfc
-#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
-#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
-#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
-#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
-#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
-
-#define nd_rd_type nd_rd_hdr.icmp6_type
-#define nd_rd_code nd_rd_hdr.icmp6_code
-#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
-#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
-
-/*
- * IPV6 extension headers
- */
-#define IPPROTO_HOPOPTS 0 /* IPv6 hop-by-hop options */
-#define IPPROTO_IPV6 41 /* IPv6 header. */
-#define IPPROTO_ROUTING 43 /* IPv6 routing header */
-#define IPPROTO_FRAGMENT 44 /* IPv6 fragmentation header */
-#define IPPROTO_ESP 50 /* encapsulating security payload */
-#define IPPROTO_AH 51 /* authentication header */
-#define IPPROTO_ICMPV6 58 /* ICMPv6 */
-#define IPPROTO_NONE 59 /* IPv6 no next header */
-#define IPPROTO_DSTOPTS 60 /* IPv6 destination options */
-#define IPPROTO_PIM 103 /* Protocol Independent Multicast. */
-
-#define IPV6_RTHDR_TYPE_0 0
-
-/* Option types and related macros */
-#define IP6OPT_PAD1 0x00 /* 00 0 00000 */
-#define IP6OPT_PADN 0x01 /* 00 0 00001 */
-#define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */
-#define IP6OPT_JUMBO_LEN 6
-#define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */
-
-#define IP6OPT_RTALERT_LEN 4
-#define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */
-#define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */
-#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */
-#define IP6OPT_MINLEN 2
-
-#define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */
-#define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */
-#define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */
-#define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */
-#define IP6OPT_EID 0x8a /* 10 0 01010 */
-
-#define IP6OPT_TYPE(o) ((o) & 0xC0)
-#define IP6OPT_TYPE_SKIP 0x00
-#define IP6OPT_TYPE_DISCARD 0x40
-#define IP6OPT_TYPE_FORCEICMP 0x80
-#define IP6OPT_TYPE_ICMP 0xC0
-
-#define IP6OPT_MUTABLE 0x20
-
-
-#if defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF)
-#ifndef EAI_ADDRFAMILY
-struct addrinfo {
- int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
- int ai_family; /* PF_xxx */
- int ai_socktype; /* SOCK_xxx */
- int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
- size_t ai_addrlen; /* length of ai_addr */
- char *ai_canonname; /* canonical name for hostname */
- struct sockaddr *ai_addr; /* binary address */
- struct addrinfo *ai_next; /* next structure in linked list */
-};
-#endif
-#endif /* __MINGW32__ */
diff --git a/Win32/Include/net/if.h b/Win32/Include/net/if.h
index 7f835fbf1b0b..619eb690179d 100644
--- a/Win32/Include/net/if.h
+++ b/Win32/Include/net/if.h
@@ -36,7 +36,7 @@
#ifndef _NET_IF_H_
#define _NET_IF_H_
-
+
/*
* <net/if.h> does not depend on <sys/time.h> on most other systems. This
* helps userland compatability. (struct timeval ifi_lastchange)
diff --git a/Win32/Include/net/netdb.h b/Win32/Include/net/netdb.h
deleted file mode 100644
index b9d45acf6d02..000000000000
--- a/Win32/Include/net/netdb.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/*-
- * Copyright (c) 1980, 1983, 1988, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)netdb.h 8.1 (Berkeley) 6/2/93
- * netdb.h,v 1.4 1995/08/14 04:05:04 hjl Exp
- * -
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- *
- * Permission to use, copy, modify and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- * -
- * --Copyright--
- */
-
-#ifndef _NETDB_H_
-#define _NETDB_H_
-
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(_REENTRANT)
-#include <stdio.h>
-#include <netinet/in.h>
-#endif
-
-#include <winsock2.h>
-#include <net/paths.h>
-
-#define _PATH_HEQUIV __PATH_ETC_INET"/hosts.equiv"
-#define _PATH_HOSTS __PATH_ETC_INET"/hosts"
-#define _PATH_NETWORKS __PATH_ETC_INET"/networks"
-#define _PATH_PROTOCOLS __PATH_ETC_INET"/protocols"
-#define _PATH_SERVICES __PATH_ETC_INET"/services"
-#define _PATH_RESCONF __PATH_ETC_INET"/resolv.conf"
-#define _PATH_RPC __PATH_ETC_INET"/rpc"
-
-struct rpcent {
- char *r_name; /* name of server for this rpc program */
- char **r_aliases; /* alias list */
- int r_number; /* rpc program number */
-};
-
-#ifndef WIN32
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(_REENTRANT)
-
-#define __NETDB_MAXALIASES 35
-#define __NETDB_MAXADDRS 35
-
-/*
- * Error return codes from gethostbyname() and gethostbyaddr()
- * (left in extern int h_errno).
- */
-#define h_errno (*__h_errno_location ())
-#else
-extern int h_errno;
-#endif
-#endif
-
-#define NETDB_INTERNAL -1 /* see errno */
-#define NETDB_SUCCESS 0 /* no problem */
-
-//#include <features.h>
-
-void endhostent (void);
-void endnetent (void);
-void endprotoent (void);
-void endservent (void);
-void endrpcent (void);
-struct hostent *gethostent (void);
-struct netent *getnetbyaddr (long, int); /* u_long? */
-struct netent *getnetbyname (const char *);
-struct netent *getnetent (void);
-struct protoent *getprotoent (void);
-struct servent *getservent (void);
-struct rpcent *getrpcent (void);
-struct rpcent *getrpcbyname (const char *);
-struct rpcent *getrpcbynumber (int);
-void herror (const char *);
-void sethostent (int);
-/* void sethostfile (const char *); */
-void setnetent (int);
-void setprotoent (int);
-void setservent (int);
-void setrpcent (int);
-
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(_REENTRANT)
-struct hostent *gethostbyaddr_r (const char *__addr,
- int __length, int __type,
- struct hostent *__result,
- char *__buffer, int __buflen, int *__h_errnop);
-struct hostent *gethostbyname_r (const char * __name,
- struct hostent *__result, char *__buffer,
- int __buflen, int *__h_errnop);
-struct hostent *gethostent_r (struct hostent *__result,
- char *__buffer, int __buflen, int *__h_errnop);
-struct netent *getnetbyaddr_r (long __net, int __type,
- struct netent *__result, char *__buffer,
- int __buflen);
-struct netent *getnetbyname_r (const char * __name,
- struct netent *__result, char *__buffer,
- int __buflen);
-struct netent *getnetent_r (struct netent *__result,
- char *__buffer, int __buflen);
-struct protoent *getprotobyname_r (const char * __name,
- struct protoent *__result, char *__buffer,
- int __buflen);
-struct protoent *getprotobynumber_r (int __proto,
- struct protoent *__result, char *__buffer,
- int __buflen);
-struct protoent *getprotoent_r (struct protoent *__result,
- char *__buffer, int __buflen);
-struct servent *getservbyname_r (const char * __name,
- const char *__proto, struct servent *__result,
- char *__buffer, int __buflen);
-struct servent *getservbyport_r (int __port,
- const char *__proto, struct servent *__result,
- char *__buffer, int __buflen);
-struct servent *getservent_r (struct servent *__result,
- char *__buffer, int __buflen);
-
-int *__h_errno_location (void);
-
-#endif
-
-#endif /* !_NETDB_H_ */
diff --git a/Win32/Include/net/paths.h b/Win32/Include/net/paths.h
deleted file mode 100644
index 987de4f0dcef..000000000000
--- a/Win32/Include/net/paths.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)paths.h 5.15 (Berkeley) 5/29/91
- */
-
-#ifndef _PATHS_H_
-#define _PATHS_H_
-
-#if 0
-#define __PATH_ETC_INET "/usr/etc/inet"
-#else
-#define __PATH_ETC_INET "/etc"
-#endif
-
-/* Default search path. */
-#define _PATH_DEFPATH "/usr/local/bin:/usr/bin:/bin:."
-#define _PATH_DEFPATH_ROOT "/sbin:/bin:/usr/sbin:/usr/bin"
-
-#define _PATH_BSHELL "/bin/sh"
-#define _PATH_CONSOLE "/dev/console"
-#define _PATH_CSHELL "/bin/csh"
-#define _PATH_DEVDB "/var/run/dev.db"
-#define _PATH_DEVNULL "/dev/null"
-#define _PATH_DRUM "/dev/drum"
-#define _PATH_HEQUIV __PATH_ETC_INET"/hosts.equiv"
-#define _PATH_KMEM "/dev/kmem"
-#define _PATH_MAILDIR "/var/spool/mail"
-#define _PATH_MAN "/usr/man"
-#define _PATH_MEM "/dev/mem"
-#define _PATH_LOGIN "/bin/login"
-#define _PATH_NOLOGIN "/etc/nologin"
-#define _PATH_SENDMAIL "/usr/sbin/sendmail"
-#define _PATH_SHELLS "/etc/shells"
-#define _PATH_TTY "/dev/tty"
-#define _PATH_UNIX "/vmlinux"
-#define _PATH_VI "/usr/bin/vi"
-
-/* Provide trailing slash, since mostly used for building pathnames. */
-#define _PATH_DEV "/dev/"
-#define _PATH_TMP "/tmp/"
-#define _PATH_VARRUN "/var/run/"
-#define _PATH_VARTMP "/var/tmp/"
-
-#define _PATH_KLOG "/proc/kmsg"
-#define _PATH_LOGCONF __PATH_ETC_INET"/syslog.conf"
-#if 0
-#define _PATH_LOGPID __PATH_ETC_INET"/syslog.pid"
-#else
-#define _PATH_LOGPID "/var/run/syslog.pid"
-#endif
-#define _PATH_LOG "/dev/log"
-#define _PATH_CONSOLE "/dev/console"
-
-#if 0
-#define _PATH_UTMP "/var/adm/utmp"
-#define _PATH_WTMP "/var/adm/wtmp"
-#define _PATH_LASTLOG "/var/adm/lastlog"
-#else
-#define _PATH_UTMP "/var/run/utmp"
-#define _PATH_WTMP "/var/log/wtmp"
-#define _PATH_LASTLOG "/var/log/lastlog"
-#endif
-
-#define _PATH_LOCALE "/usr/lib/locale"
-
-#define _PATH_RWHODIR "/var/spool/rwho"
-
-#if _MIT_POSIX_THREADS
-/* For the MIT pthreads */
-#define _PATH_PTY "/dev/"
-#define _PATH_TZDIR "/usr/lib/zoneinfo"
-#define _PATH_TZFILE "/usr/lib/zoneinfo/localtime"
-#endif
-
-#endif /* !_PATHS_H_ */
diff --git a/Win32/Include/sockstorage.h b/Win32/Include/sockstorage.h
deleted file mode 100644
index 557eb4df0aff..000000000000
--- a/Win32/Include/sockstorage.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 1999 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-struct sockaddr_storage {
-#ifdef HAVE_SOCKADDR_SA_LEN
- u_int8_t __ss_len;
- u_int8_t __ss_family;
- u_int8_t fill[126];
-#else
- u_int8_t __ss_family;
- u_int8_t fill[127];
-#endif /* HAVE_SOCKADDR_SA_LEN */
-};
diff --git a/Win32/Prj/libpcap.dsp b/Win32/Prj/libpcap.dsp
deleted file mode 100644
index 17e5a7037d41..000000000000
--- a/Win32/Prj/libpcap.dsp
+++ /dev/null
@@ -1,168 +0,0 @@
-# Microsoft Developer Studio Project File - Name="libpcap" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=libpcap - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "libpcap.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "libpcap.mak" CFG="libpcap - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "libpcap - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "libpcap - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "libpcap - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../" /I "../../lbl/" /I "../../bpf/" /I "../include/" /I "../../../../common" /I "../../../../dag/include" /I "../../../../dag/drv/windows" /D "NDEBUG" /D "YY_NEVER_INTERACTIVE" /D yylval=pcap_lval /D "_USRDLL" /D "LIBPCAP_EXPORTS" /D "HAVE_STRERROR" /D "__STDC__" /D "INET6" /D "_WINDOWS" /D "_MBCS" /D "HAVE_ADDRINFO" /D "WIN32" /D _U_= /D "HAVE_SNPRINTF" /D "HAVE_VSNPRINTF" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF "$(CFG)" == "libpcap - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../" /I "../../lbl/" /I "../../bpf/" /I "../include/" /I "../../../../common" /I "../../../../dag/include" /I "../../../../dag/drv/windows" /D "_DEBUG" /D "YY_NEVER_INTERACTIVE" /D yylval=pcap_lval /D "_USRDLL" /D "LIBPCAP_EXPORTS" /D "HAVE_STRERROR" /D "__STDC__" /D "INET6" /D "_WINDOWS" /D "_MBCS" /D "HAVE_ADDRINFO" /D "WIN32" /D _U_= /D "HAVE_SNPRINTF" /D "HAVE_VSNPRINTF" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ENDIF
-
-# Begin Target
-
-# Name "libpcap - Win32 Release"
-# Name "libpcap - Win32 Debug"
-# Begin Source File
-
-SOURCE=..\..\bpf_dump.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\bpf\net\bpf_filter.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\bpf_image.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\etherent.c
-# End Source File
-# Begin Source File
-
-SOURCE="..\..\fad-win32.c"
-# End Source File
-# Begin Source File
-
-SOURCE=..\Src\ffs.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\gencode.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\Src\getnetbynm.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\Src\getnetent.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\Src\getservent.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\grammar.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\inet.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\Src\inet_aton.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\Src\inet_net.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\Src\inet_pton.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\nametoaddr.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\optimize.c
-# End Source File
-# Begin Source File
-
-SOURCE="..\..\Pcap-win32.c"
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\pcap.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\savefile.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\scanner.c
-# End Source File
-# End Target
-# End Project
diff --git a/Win32/Prj/libpcap.dsw b/Win32/Prj/libpcap.dsw
deleted file mode 100644
index 8cdff2d02033..000000000000
--- a/Win32/Prj/libpcap.dsw
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "libpcap"=".\libpcap.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/Win32/Prj/wpcap.sln b/Win32/Prj/wpcap.sln
new file mode 100644
index 000000000000..5a9fce98ee35
--- /dev/null
+++ b/Win32/Prj/wpcap.sln
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.40629.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wpcap", "wpcap.vcxproj", "{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|Win32.Build.0 = Debug|Win32
+ {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|x64.ActiveCfg = Debug|x64
+ {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|x64.Build.0 = Debug|x64
+ {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|Win32.ActiveCfg = Release|Win32
+ {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|Win32.Build.0 = Release|Win32
+ {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|x64.ActiveCfg = Release|x64
+ {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Win32/Prj/wpcap.vcxproj b/Win32/Prj/wpcap.vcxproj
new file mode 100644
index 000000000000..c923357aa9a5
--- /dev/null
+++ b/Win32/Prj/wpcap.vcxproj
@@ -0,0 +1,234 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <SccProjectName />
+ <SccLocalPath />
+ <ProjectGuid>{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v120</PlatformToolset>
+ <UseOfMfc>false</UseOfMfc>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v120</PlatformToolset>
+ <UseOfMfc>false</UseOfMfc>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v120</PlatformToolset>
+ <UseOfMfc>false</UseOfMfc>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v120</PlatformToolset>
+ <UseOfMfc>false</UseOfMfc>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <OutDir>.\Release\</OutDir>
+ <IntDir>.\Release\</IntDir>
+ <LinkIncremental>false</LinkIncremental>
+ <IncludePath>../../../;$(IncludePath)</IncludePath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IncludePath>../../../;$(IncludePath)</IncludePath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <OutDir>.\Debug\</OutDir>
+ <IntDir>.\Debug\</IntDir>
+ <LinkIncremental>true</LinkIncremental>
+ <IncludePath>../../../;$(IncludePath)</IncludePath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IncludePath>../../../;$(IncludePath)</IncludePath>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <InlineFunctionExpansion>Default</InlineFunctionExpansion>
+ <StringPooling>true</StringPooling>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <Optimization>MaxSpeed</Optimization>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <WarningLevel>Level3</WarningLevel>
+ <AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x0409</Culture>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <PreBuildEvent>
+ <Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
+win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
+win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <InlineFunctionExpansion>Default</InlineFunctionExpansion>
+ <StringPooling>true</StringPooling>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <Optimization>MaxSpeed</Optimization>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <WarningLevel>Level3</WarningLevel>
+ <AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x0409</Culture>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\x64\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <PreBuildEvent>
+ <Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
+win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
+win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <InlineFunctionExpansion>Default</InlineFunctionExpansion>
+ <FunctionLevelLinking>false</FunctionLevelLinking>
+ <Optimization>Disabled</Optimization>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <WarningLevel>Level3</WarningLevel>
+ <MinimalRebuild>true</MinimalRebuild>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ <AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x0409</Culture>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <PreBuildEvent>
+ <Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
+win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
+win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <InlineFunctionExpansion>Default</InlineFunctionExpansion>
+ <FunctionLevelLinking>false</FunctionLevelLinking>
+ <Optimization>Disabled</Optimization>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x0409</Culture>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\x64\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <PreBuildEvent>
+ <Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
+win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
+win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\bpf\net\bpf_filter.c" />
+ <ClCompile Include="..\..\bpf_dump.c" />
+ <ClCompile Include="..\..\bpf_image.c" />
+ <ClCompile Include="..\..\etherent.c" />
+ <ClCompile Include="..\..\fad-helpers.c" />
+ <ClCompile Include="..\..\gencode.c" />
+ <ClCompile Include="..\..\grammar.c" />
+ <ClCompile Include="..\..\inet.c" />
+ <ClCompile Include="..\..\missing\win_snprintf.c" />
+ <ClCompile Include="..\..\nametoaddr.c" />
+ <ClCompile Include="..\..\optimize.c" />
+ <ClCompile Include="..\..\pcap-common.c" />
+ <ClCompile Include="..\..\pcap-new.c" />
+ <ClCompile Include="..\..\pcap-rpcap.c" />
+ <ClCompile Include="..\..\pcap-win32.c" />
+ <ClCompile Include="..\..\pcap.c" />
+ <ClCompile Include="..\..\savefile.c" />
+ <ClCompile Include="..\..\scanner.c" />
+ <ClCompile Include="..\..\sf-pcap-ng.c" />
+ <ClCompile Include="..\..\sf-pcap.c" />
+ <ClCompile Include="..\..\sockutils.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\pcap-common.h" />
+ <ClInclude Include="..\..\pcap-int.h" />
+ <ClInclude Include="..\..\pcap-rpcap.h" />
+ <ClInclude Include="..\..\pcap-stdinc.h" />
+ <ClInclude Include="..\..\pcap.h" />
+ <ClInclude Include="..\..\remote-ext.h" />
+ <ClInclude Include="..\..\sockutils.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="..\..\..\Win32-Extensions\version.rc" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Win32/Prj/wpcap.vcxproj.filters b/Win32/Prj/wpcap.vcxproj.filters
new file mode 100644
index 000000000000..72f1492c0222
--- /dev/null
+++ b/Win32/Prj/wpcap.vcxproj.filters
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="..\..\bpf_dump.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\bpf\net\bpf_filter.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\bpf_image.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\etherent.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\gencode.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\grammar.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\inet.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\nametoaddr.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\optimize.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\pcap.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\pcap-win32.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\savefile.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\scanner.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\sf-pcap.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\sf-pcap-ng.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\pcap-common.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\fad-helpers.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\missing\win_snprintf.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\pcap-new.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\pcap-rpcap.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\sockutils.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{c51dce5e-0da9-4e33-a235-d5c76c76485c}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{5ec9fd4b-10b5-4527-b249-56b53d844fb1}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{c90886f0-8973-436b-a7a1-b9e881544f9a}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\pcap-stdinc.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\pcap-common.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\pcap.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\pcap-int.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\pcap-rpcap.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\remote-ext.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\sockutils.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="..\..\..\Win32-Extensions\version.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project>
diff --git a/Win32/Src/gai_strerror.c b/Win32/Src/gai_strerror.c
deleted file mode 100644
index e90245ad2bd0..000000000000
--- a/Win32/Src/gai_strerror.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
-#include <sys/cdefs.h>
-
-__FBSDID("$FreeBSD$");
-
-*/
-
-#ifdef WIN32
-
-#include <ws2tcpip.h>
-
-#else
-
-#include <netdb.h>
-
-#endif
-
-/* Entries EAI_ADDRFAMILY (1) and EAI_NODATA (7) are obsoleted, but left */
-/* for backward compatibility with userland code prior to 2553bis-02 */
-static char *ai_errlist[] = {
- "Success", /* 0 */
- "Address family for hostname not supported", /* 1 */
- "Temporary failure in name resolution", /* EAI_AGAIN */
- "Invalid value for ai_flags", /* EAI_BADFLAGS */
- "Non-recoverable failure in name resolution", /* EAI_FAIL */
- "ai_family not supported", /* EAI_FAMILY */
- "Memory allocation failure", /* EAI_MEMORY */
- "No address associated with hostname", /* 7 */
- "hostname nor servname provided, or not known", /* EAI_NONAME */
- "servname not supported for ai_socktype", /* EAI_SERVICE */
- "ai_socktype not supported", /* EAI_SOCKTYPE */
- "System error returned in errno", /* EAI_SYSTEM */
- "Invalid value for hints", /* EAI_BADHINTS */
- "Resolved protocol is unknown" /* EAI_PROTOCOL */
-};
-
-#ifndef EAI_MAX
-#define EAI_MAX (sizeof(ai_errlist)/sizeof(ai_errlist[0]))
-#endif
-
-/* on MingW, gai_strerror is available.
- We need to compile gai_strerrorA only for Cygwin
- */
-#ifndef gai_strerror
-
-char *
-WSAAPI gai_strerrorA(int ecode)
-{
- if (ecode >= 0 && ecode < EAI_MAX)
- return ai_errlist[ecode];
- return "Unknown error";
-}
-
-#endif /* gai_strerror */ \ No newline at end of file
diff --git a/Win32/Src/getaddrinfo.c b/Win32/Src/getaddrinfo.c
deleted file mode 100644
index 19ffa68a8a8a..000000000000
--- a/Win32/Src/getaddrinfo.c
+++ /dev/null
@@ -1,1124 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * "#ifdef FAITH" part is local hack for supporting IPv4-v6 translator.
- *
- * Issues to be discussed:
- * - Thread safe-ness must be checked.
- * - Return values. There are nonstandard return values defined and used
- * in the source code. This is because RFC2553 is silent about which error
- * code must be returned for which situation.
- * Note:
- * - We use getipnodebyname() just for thread-safeness. There's no intent
- * to let it do PF_UNSPEC (actually we never pass PF_UNSPEC to
- * getipnodebyname().
- * - The code filters out AFs that are not supported by the kernel,
- * when globbing NULL hostname (to loopback, or wildcard). Is it the right
- * thing to do? What is the relationship with post-RFC2553 AI_ADDRCONFIG
- * in ai_flags?
- */
-
-/*
- * Mingw64 has its own implementation of getaddrinfo, mingw32 no
- */
-#ifndef __MINGW64__
-
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <pcap-stdinc.h>
-#if 0
-#include <sys/sysctl.h>
-#endif
-#ifndef __MINGW32__
-#include <arpa/nameser.h>
-#endif
-#include <string.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <errno.h>
-
-#ifndef HAVE_PORTABLE_PROTOTYPE
-#include "cdecl_ext.h"
-#endif
-
-#ifndef HAVE_U_INT32_T
-#include "bittypes.h"
-#endif
-
-#ifndef HAVE_SOCKADDR_STORAGE
-#ifndef __MINGW32__
-#include "sockstorage.h"
-#endif
-#endif
-
-#ifdef NEED_ADDRINFO_H
-#include "addrinfo.h"
-#ifdef WIN32
-#include "ip6_misc.h"
-#endif
-#endif
-
-
-#if defined(__KAME__) && defined(INET6)
-# define FAITH
-#endif
-
-#define SUCCESS 0
-#define ANY 0
-#define YES 1
-#define NO 0
-
-#ifdef FAITH
-static int translate = NO;
-static struct in6_addr faith_prefix = IN6ADDR_ANY_INIT;
-#endif
-
-static const char in_addrany[] = { 0, 0, 0, 0 };
-static const char in6_addrany[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-static const char in_loopback[] = { 127, 0, 0, 1 };
-static const char in6_loopback[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
-};
-
-struct sockinet {
- u_char si_len;
- u_char si_family;
- u_short si_port;
- u_int32_t si_scope_id;
-};
-
-static const struct afd {
- int a_af;
- int a_addrlen;
- int a_socklen;
- int a_off;
- const char *a_addrany;
- const char *a_loopback;
- int a_scoped;
-} afdl [] = {
-#ifdef INET6
- {PF_INET6, sizeof(struct in6_addr),
- sizeof(struct sockaddr_in6),
- offsetof(struct sockaddr_in6, sin6_addr),
- in6_addrany, in6_loopback, 1},
-#endif
- {PF_INET, sizeof(struct in_addr),
- sizeof(struct sockaddr_in),
- offsetof(struct sockaddr_in, sin_addr),
- in_addrany, in_loopback, 0},
- {0, 0, 0, 0, NULL, NULL, 0},
-};
-
-struct explore {
- int e_af;
- int e_socktype;
- int e_protocol;
- const char *e_protostr;
- int e_wild;
-#define WILD_AF(ex) ((ex)->e_wild & 0x01)
-#define WILD_SOCKTYPE(ex) ((ex)->e_wild & 0x02)
-#define WILD_PROTOCOL(ex) ((ex)->e_wild & 0x04)
-};
-
-static const struct explore explore[] = {
-#if 0
- { PF_LOCAL, 0, ANY, ANY, NULL, 0x01 },
-#endif
-#ifdef INET6
- { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
- { PF_INET6, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
- { PF_INET6, SOCK_RAW, ANY, NULL, 0x05 },
-#endif
- { PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
- { PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
- { PF_INET, SOCK_RAW, ANY, NULL, 0x05 },
- { -1, 0, 0, NULL, 0 },
-};
-
-#ifdef INET6
-#define PTON_MAX 16
-#else
-#define PTON_MAX 4
-#endif
-
-
-static int str_isnumber __P((const char *));
-static int explore_fqdn __P((const struct addrinfo *, const char *,
- const char *, struct addrinfo **));
-static int explore_null __P((const struct addrinfo *, const char *,
- const char *, struct addrinfo **));
-static int explore_numeric __P((const struct addrinfo *, const char *,
- const char *, struct addrinfo **));
-static int explore_numeric_scope __P((const struct addrinfo *, const char *,
- const char *, struct addrinfo **));
-static int get_name __P((const char *, const struct afd *, struct addrinfo **,
- char *, const struct addrinfo *, const char *));
-static int get_canonname __P((const struct addrinfo *,
- struct addrinfo *, const char *));
-static struct addrinfo *get_ai __P((const struct addrinfo *,
- const struct afd *, const char *));
-static int get_portmatch __P((const struct addrinfo *, const char *));
-static int get_port __P((struct addrinfo *, const char *, int));
-static const struct afd *find_afd __P((int));
-
-static char *ai_errlist[] = {
- "Success",
- "Address family for hostname not supported", /* EAI_ADDRFAMILY */
- "Temporary failure in name resolution", /* EAI_AGAIN */
- "Invalid value for ai_flags", /* EAI_BADFLAGS */
- "Non-recoverable failure in name resolution", /* EAI_FAIL */
- "ai_family not supported", /* EAI_FAMILY */
- "Memory allocation failure", /* EAI_MEMORY */
- "No address associated with hostname", /* EAI_NODATA */
- "hostname nor servname provided, or not known", /* EAI_NONAME */
- "servname not supported for ai_socktype", /* EAI_SERVICE */
- "ai_socktype not supported", /* EAI_SOCKTYPE */
- "System error returned in errno", /* EAI_SYSTEM */
- "Invalid value for hints", /* EAI_BADHINTS */
- "Resolved protocol is unknown", /* EAI_PROTOCOL */
- "Unknown error", /* EAI_MAX */
-};
-
-/* XXX macros that make external reference is BAD. */
-
-#define GET_AI(ai, afd, addr) \
-do { \
- /* external reference: pai, error, and label free */ \
- (ai) = get_ai(pai, (afd), (addr)); \
- if ((ai) == NULL) { \
- error = EAI_MEMORY; \
- goto free; \
- } \
-} while (0)
-
-#define GET_PORT(ai, serv) \
-do { \
- /* external reference: error and label free */ \
- error = get_port((ai), (serv), 0); \
- if (error != 0) \
- goto free; \
-} while (0)
-
-#define GET_CANONNAME(ai, str) \
-do { \
- /* external reference: pai, error and label free */ \
- error = get_canonname(pai, (ai), (str)); \
- if (error != 0) \
- goto free; \
-} while (0)
-
-#define ERR(err) \
-do { \
- /* external reference: error, and label bad */ \
- error = (err); \
- goto bad; \
-} while (0)
-
-#define MATCH_FAMILY(x, y, w) \
- ((x) == (y) || ((w) && ((x) == PF_UNSPEC || (y) == PF_UNSPEC)))
-#define MATCH(x, y, w) \
- ((x) == (y) || ((w) && ((x) == ANY || (y) == ANY)))
-
-#if defined(DEFINE_ADDITIONAL_IPV6_STUFF)
-char *
-gai_strerror(ecode)
- int ecode;
-{
- if (ecode < 0 || ecode > EAI_MAX)
- ecode = EAI_MAX;
- return ai_errlist[ecode];
-}
-#endif
-
-void
-freeaddrinfo(ai)
- struct addrinfo *ai;
-{
- struct addrinfo *next;
-
- do {
- next = ai->ai_next;
- if (ai->ai_canonname)
- free(ai->ai_canonname);
- /* no need to free(ai->ai_addr) */
- free(ai);
- } while ((ai = next) != NULL);
-}
-
-static int
-str_isnumber(p)
- const char *p;
-{
- char *q = (char *)p;
- while (*q) {
- if (! isdigit(*q))
- return NO;
- q++;
- }
- return YES;
-}
-
-int
-getaddrinfo(hostname, servname, hints, res)
- const char *hostname, *servname;
- const struct addrinfo *hints;
- struct addrinfo **res;
-{
- struct addrinfo sentinel;
- struct addrinfo *cur;
- int error = 0;
- struct addrinfo ai;
- struct addrinfo ai0;
- struct addrinfo *pai;
- const struct afd *afd;
- const struct explore *ex;
-
-#ifdef FAITH
- static int firsttime = 1;
-
- if (firsttime) {
- /* translator hack */
- char *q = getenv("GAI");
- if (q && inet_pton(AF_INET6, q, &faith_prefix) == 1)
- translate = YES;
- firsttime = 0;
- }
-#endif
-
- sentinel.ai_next = NULL;
- cur = &sentinel;
- pai = &ai;
- pai->ai_flags = 0;
- pai->ai_family = PF_UNSPEC;
- pai->ai_socktype = ANY;
- pai->ai_protocol = ANY;
- pai->ai_addrlen = 0;
- pai->ai_canonname = NULL;
- pai->ai_addr = NULL;
- pai->ai_next = NULL;
-
- if (hostname == NULL && servname == NULL)
- return EAI_NONAME;
- if (hints) {
- /* error check for hints */
- if (hints->ai_addrlen || hints->ai_canonname ||
- hints->ai_addr || hints->ai_next)
- ERR(EAI_BADHINTS); /* xxx */
- if (hints->ai_flags & ~AI_MASK)
- ERR(EAI_BADFLAGS);
- switch (hints->ai_family) {
- case PF_UNSPEC:
- case PF_INET:
-#ifdef INET6
- case PF_INET6:
-#endif
- break;
- default:
- ERR(EAI_FAMILY);
- }
- memcpy(pai, hints, sizeof(*pai));
-
- /*
- * if both socktype/protocol are specified, check if they
- * are meaningful combination.
- */
- if (pai->ai_socktype != ANY && pai->ai_protocol != ANY) {
- for (ex = explore; ex->e_af >= 0; ex++) {
- if (pai->ai_family != ex->e_af)
- continue;
- if (ex->e_socktype == ANY)
- continue;
- if (ex->e_protocol == ANY)
- continue;
- if (pai->ai_socktype == ex->e_socktype
- && pai->ai_protocol != ex->e_protocol) {
- ERR(EAI_BADHINTS);
- }
- }
- }
- }
-
- /*
- * check for special cases. (1) numeric servname is disallowed if
- * socktype/protocol are left unspecified. (2) servname is disallowed
- * for raw and other inet{,6} sockets.
- */
- if (MATCH_FAMILY(pai->ai_family, PF_INET, 1)
-#ifdef PF_INET6
- || MATCH_FAMILY(pai->ai_family, PF_INET6, 1)
-#endif
- ) {
- ai0 = *pai;
-
- if (pai->ai_family == PF_UNSPEC) {
-#ifdef PF_INET6
- pai->ai_family = PF_INET6;
-#else
- pai->ai_family = PF_INET;
-#endif
- }
- error = get_portmatch(pai, servname);
- if (error)
- ERR(error);
-
- *pai = ai0;
- }
-
- ai0 = *pai;
-
- /* NULL hostname, or numeric hostname */
- for (ex = explore; ex->e_af >= 0; ex++) {
- *pai = ai0;
-
- if (!MATCH_FAMILY(pai->ai_family, ex->e_af, WILD_AF(ex)))
- continue;
- if (!MATCH(pai->ai_socktype, ex->e_socktype, WILD_SOCKTYPE(ex)))
- continue;
- if (!MATCH(pai->ai_protocol, ex->e_protocol, WILD_PROTOCOL(ex)))
- continue;
-
- if (pai->ai_family == PF_UNSPEC)
- pai->ai_family = ex->e_af;
- if (pai->ai_socktype == ANY && ex->e_socktype != ANY)
- pai->ai_socktype = ex->e_socktype;
- if (pai->ai_protocol == ANY && ex->e_protocol != ANY)
- pai->ai_protocol = ex->e_protocol;
-
- if (hostname == NULL)
- error = explore_null(pai, hostname, servname, &cur->ai_next);
- else
- error = explore_numeric_scope(pai, hostname, servname, &cur->ai_next);
-
- if (error)
- goto free;
-
- while (cur && cur->ai_next)
- cur = cur->ai_next;
- }
-
- /*
- * XXX
- * If numreic representation of AF1 can be interpreted as FQDN
- * representation of AF2, we need to think again about the code below.
- */
- if (sentinel.ai_next)
- goto good;
-
- if (pai->ai_flags & AI_NUMERICHOST)
- ERR(EAI_NONAME);
- if (hostname == NULL)
- ERR(EAI_NONAME);
-
- /*
- * hostname as alphabetical name.
- * we would like to prefer AF_INET6 than AF_INET, so we'll make a
- * outer loop by AFs.
- */
- for (afd = afdl; afd->a_af; afd++) {
- *pai = ai0;
-
- if (!MATCH_FAMILY(pai->ai_family, afd->a_af, 1))
- continue;
-
- for (ex = explore; ex->e_af >= 0; ex++) {
- *pai = ai0;
-
- if (pai->ai_family == PF_UNSPEC)
- pai->ai_family = afd->a_af;
-
- if (!MATCH_FAMILY(pai->ai_family, ex->e_af, WILD_AF(ex)))
- continue;
- if (!MATCH(pai->ai_socktype, ex->e_socktype,
- WILD_SOCKTYPE(ex))) {
- continue;
- }
- if (!MATCH(pai->ai_protocol, ex->e_protocol,
- WILD_PROTOCOL(ex))) {
- continue;
- }
-
- if (pai->ai_family == PF_UNSPEC)
- pai->ai_family = ex->e_af;
- if (pai->ai_socktype == ANY && ex->e_socktype != ANY)
- pai->ai_socktype = ex->e_socktype;
- if (pai->ai_protocol == ANY && ex->e_protocol != ANY)
- pai->ai_protocol = ex->e_protocol;
-
- error = explore_fqdn(pai, hostname, servname,
- &cur->ai_next);
-
- while (cur && cur->ai_next)
- cur = cur->ai_next;
- }
- }
-
- /* XXX */
- if (sentinel.ai_next)
- error = 0;
-
- if (error)
- goto free;
- if (error == 0) {
- if (sentinel.ai_next) {
- good:
- *res = sentinel.ai_next;
- return SUCCESS;
- } else
- error = EAI_FAIL;
- }
- free:
- bad:
- if (sentinel.ai_next)
- freeaddrinfo(sentinel.ai_next);
- *res = NULL;
- return error;
-}
-
-/*
- * FQDN hostname, DNS lookup
- */
-static int
-explore_fqdn(pai, hostname, servname, res)
- const struct addrinfo *pai;
- const char *hostname;
- const char *servname;
- struct addrinfo **res;
-{
- struct hostent *hp;
- int h_error;
- int af;
- char **aplist = NULL, *apbuf = NULL;
- char *ap;
- struct addrinfo sentinel, *cur;
- int i;
-#ifndef USE_GETIPNODEBY
- int naddrs;
-#endif
- const struct afd *afd;
- int error;
-
- *res = NULL;
- sentinel.ai_next = NULL;
- cur = &sentinel;
-
- /*
- * Do not filter unsupported AFs here. We need to honor content of
- * databases (/etc/hosts, DNS and others). Otherwise we cannot
- * replace gethostbyname() by getaddrinfo().
- */
-
- /*
- * if the servname does not match socktype/protocol, ignore it.
- */
- if (get_portmatch(pai, servname) != 0)
- return 0;
-
- afd = find_afd(pai->ai_family);
-
- /*
- * post-RFC2553: should look at (pai->ai_flags & AI_ADDRCONFIG)
- * rather than hardcoding it. we may need to add AI_ADDRCONFIG
- * handling code by ourselves in case we don't have getipnodebyname().
- */
-#ifdef USE_GETIPNODEBY
- hp = getipnodebyname(hostname, pai->ai_family, AI_ADDRCONFIG, &h_error);
-#else
-#ifdef HAVE_GETHOSTBYNAME2
- hp = gethostbyname2(hostname, pai->ai_family);
-#else
- if (pai->ai_family != AF_INET)
- return 0;
- hp = gethostbyname(hostname);
-#ifdef HAVE_H_ERRNO
- h_error = h_errno;
-#else
- h_error = EINVAL;
-#endif
-#endif /*HAVE_GETHOSTBYNAME2*/
-#endif /*USE_GETIPNODEBY*/
-
- if (hp == NULL) {
- switch (h_error) {
- case HOST_NOT_FOUND:
- case NO_DATA:
- error = EAI_NODATA;
- break;
- case TRY_AGAIN:
- error = EAI_AGAIN;
- break;
- case NO_RECOVERY:
- case NETDB_INTERNAL:
- default:
- error = EAI_FAIL;
- break;
- }
- } else if ((hp->h_name == NULL) || (hp->h_name[0] == 0)
- || (hp->h_addr_list[0] == NULL)) {
-#ifdef USE_GETIPNODEBY
- freehostent(hp);
-#endif
- hp = NULL;
- error = EAI_FAIL;
- }
-
- if (hp == NULL)
- goto free;
-
-#ifdef USE_GETIPNODEBY
- aplist = hp->h_addr_list;
-#else
- /*
- * hp will be overwritten if we use gethostbyname2().
- * always deep copy for simplification.
- */
- for (naddrs = 0; hp->h_addr_list[naddrs] != NULL; naddrs++)
- ;
- naddrs++;
- aplist = (char **)malloc(sizeof(aplist[0]) * naddrs);
- apbuf = (char *)malloc(hp->h_length * naddrs);
- if (aplist == NULL || apbuf == NULL) {
- error = EAI_MEMORY;
- goto free;
- }
- memset(aplist, 0, sizeof(aplist[0]) * naddrs);
- for (i = 0; i < naddrs; i++) {
- if (hp->h_addr_list[i] == NULL) {
- aplist[i] = NULL;
- continue;
- }
- memcpy(&apbuf[i * hp->h_length], hp->h_addr_list[i],
- hp->h_length);
- aplist[i] = &apbuf[i * hp->h_length];
- }
-#endif
-
- for (i = 0; aplist[i] != NULL; i++) {
- af = hp->h_addrtype;
- ap = aplist[i];
-#ifdef AF_INET6
- if (af == AF_INET6
- && IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) {
- af = AF_INET;
- ap = ap + sizeof(struct in6_addr)
- - sizeof(struct in_addr);
- }
-#endif
-
- if (af != pai->ai_family)
- continue;
-
- if ((pai->ai_flags & AI_CANONNAME) == 0) {
- GET_AI(cur->ai_next, afd, ap);
- GET_PORT(cur->ai_next, servname);
- } else {
- /*
- * if AI_CANONNAME and if reverse lookup
- * fail, return ai anyway to pacify
- * calling application.
- *
- * XXX getaddrinfo() is a name->address
- * translation function, and it looks
- * strange that we do addr->name
- * translation here.
- */
- get_name(ap, afd, &cur->ai_next,
- ap, pai, servname);
- }
-
- while (cur && cur->ai_next)
- cur = cur->ai_next;
- }
-
- *res = sentinel.ai_next;
- return 0;
-
-free:
-#ifdef USE_GETIPNODEBY
- if (hp)
- freehostent(hp);
-#endif
- if (aplist)
- free(aplist);
- if (apbuf)
- free(apbuf);
- if (sentinel.ai_next)
- freeaddrinfo(sentinel.ai_next);
- return error;
-}
-
-/*
- * hostname == NULL.
- * passive socket -> anyaddr (0.0.0.0 or ::)
- * non-passive socket -> localhost (127.0.0.1 or ::1)
- */
-static int
-explore_null(pai, hostname, servname, res)
- const struct addrinfo *pai;
- const char *hostname;
- const char *servname;
- struct addrinfo **res;
-{
- int s;
- const struct afd *afd;
- struct addrinfo *cur;
- struct addrinfo sentinel;
- int error;
-
- *res = NULL;
- sentinel.ai_next = NULL;
- cur = &sentinel;
-
- /*
- * filter out AFs that are not supported by the kernel
- * XXX errno?
- */
- s = socket(pai->ai_family, SOCK_DGRAM, 0);
- if (s < 0) {
- if (errno != EMFILE)
- return 0;
- } else
- close(s);
-
- /*
- * if the servname does not match socktype/protocol, ignore it.
- */
- if (get_portmatch(pai, servname) != 0)
- return 0;
-
- afd = find_afd(pai->ai_family);
-
- if (pai->ai_flags & AI_PASSIVE) {
- GET_AI(cur->ai_next, afd, afd->a_addrany);
- /* xxx meaningless?
- * GET_CANONNAME(cur->ai_next, "anyaddr");
- */
- GET_PORT(cur->ai_next, servname);
- } else {
- GET_AI(cur->ai_next, afd, afd->a_loopback);
- /* xxx meaningless?
- * GET_CANONNAME(cur->ai_next, "localhost");
- */
- GET_PORT(cur->ai_next, servname);
- }
- cur = cur->ai_next;
-
- *res = sentinel.ai_next;
- return 0;
-
-free:
- if (sentinel.ai_next)
- freeaddrinfo(sentinel.ai_next);
- return error;
-}
-
-/*
- * numeric hostname
- */
-static int
-explore_numeric(pai, hostname, servname, res)
- const struct addrinfo *pai;
- const char *hostname;
- const char *servname;
- struct addrinfo **res;
-{
- const struct afd *afd;
- struct addrinfo *cur;
- struct addrinfo sentinel;
- int error;
- char pton[PTON_MAX];
- int flags;
-
- *res = NULL;
- sentinel.ai_next = NULL;
- cur = &sentinel;
-
- /*
- * if the servname does not match socktype/protocol, ignore it.
- */
- if (get_portmatch(pai, servname) != 0)
- return 0;
-
- afd = find_afd(pai->ai_family);
- flags = pai->ai_flags;
-
- if (inet_pton(afd->a_af, hostname, pton) == 1) {
- u_int32_t v4a;
-#ifdef INET6
- u_char pfx;
-#endif
-
- switch (afd->a_af) {
- case AF_INET:
- v4a = (u_int32_t)ntohl(((struct in_addr *)pton)->s_addr);
- if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
- flags &= ~AI_CANONNAME;
- v4a >>= IN_CLASSA_NSHIFT;
- if (v4a == 0 || v4a == IN_LOOPBACKNET)
- flags &= ~AI_CANONNAME;
- break;
-#ifdef INET6
- case AF_INET6:
- pfx = ((struct in6_addr *)pton)->s6_addr[0];
- if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
- flags &= ~AI_CANONNAME;
- break;
-#endif
- }
-
- if (pai->ai_family == afd->a_af ||
- pai->ai_family == PF_UNSPEC /*?*/) {
- if ((flags & AI_CANONNAME) == 0) {
- GET_AI(cur->ai_next, afd, pton);
- GET_PORT(cur->ai_next, servname);
- } else {
- /*
- * if AI_CANONNAME and if reverse lookup
- * fail, return ai anyway to pacify
- * calling application.
- *
- * XXX getaddrinfo() is a name->address
- * translation function, and it looks
- * strange that we do addr->name
- * translation here.
- */
- get_name(pton, afd, &cur->ai_next,
- pton, pai, servname);
- }
- while (cur && cur->ai_next)
- cur = cur->ai_next;
- } else
- ERR(EAI_FAMILY); /*xxx*/
- }
-
- *res = sentinel.ai_next;
- return 0;
-
-free:
-bad:
- if (sentinel.ai_next)
- freeaddrinfo(sentinel.ai_next);
- return error;
-}
-
-/*
- * numeric hostname with scope
- */
-static int
-explore_numeric_scope(pai, hostname, servname, res)
- const struct addrinfo *pai;
- const char *hostname;
- const char *servname;
- struct addrinfo **res;
-{
-#ifndef SCOPE_DELIMITER
- return explore_numeric(pai, hostname, servname, res);
-#else
- const struct afd *afd;
- struct addrinfo *cur;
- int error;
- char *cp, *hostname2 = NULL;
- int scope;
- struct sockaddr_in6 *sin6;
-
- /*
- * if the servname does not match socktype/protocol, ignore it.
- */
- if (get_portmatch(pai, servname) != 0)
- return 0;
-
- afd = find_afd(pai->ai_family);
- if (!afd->a_scoped)
- return explore_numeric(pai, hostname, servname, res);
-
- cp = strchr(hostname, SCOPE_DELIMITER);
- if (cp == NULL)
- return explore_numeric(pai, hostname, servname, res);
-
- /*
- * Handle special case of <scoped_address><delimiter><scope id>
- */
- hostname2 = strdup(hostname);
- if (hostname2 == NULL)
- return EAI_MEMORY;
- /* terminate at the delimiter */
- hostname2[cp - hostname] = '\0';
-
- cp++;
- switch (pai->ai_family) {
-#ifdef INET6
- case AF_INET6:
- scope = if_nametoindex(cp);
- if (scope == 0) {
- free(hostname2);
- return (EAI_NONAME);
- }
- break;
-#endif
- }
-
- error = explore_numeric(pai, hostname2, servname, res);
- if (error == 0) {
- for (cur = *res; cur; cur = cur->ai_next) {
- if (cur->ai_family != AF_INET6)
- continue;
- sin6 = (struct sockaddr_in6 *)cur->ai_addr;
- if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) ||
- IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr))
- sin6->sin6_scope_id = scope;
- }
- }
-
- free(hostname2);
-
- return error;
-#endif
-}
-
-static int
-get_name(addr, afd, res, numaddr, pai, servname)
- const char *addr;
- const struct afd *afd;
- struct addrinfo **res;
- char *numaddr;
- const struct addrinfo *pai;
- const char *servname;
-{
- struct hostent *hp = NULL;
- struct addrinfo *cur = NULL;
- int error = 0;
- char *ap = NULL, *cn = NULL;
-#ifdef USE_GETIPNODEBY
- int h_error;
-
- hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
-#else
- hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
-#endif
- if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
-#ifdef USE_GETIPNODEBY
- GET_AI(cur, afd, hp->h_addr_list[0]);
- GET_PORT(cur, servname);
- GET_CANONNAME(cur, hp->h_name);
-#else
- /* hp will be damaged if we use gethostbyaddr() */
- if ((ap = (char *)malloc(hp->h_length)) == NULL) {
- error = EAI_MEMORY;
- goto free;
- }
- memcpy(ap, hp->h_addr_list[0], hp->h_length);
- if ((cn = strdup(hp->h_name)) == NULL) {
- error = EAI_MEMORY;
- goto free;
- }
-
- GET_AI(cur, afd, ap);
- GET_PORT(cur, servname);
- GET_CANONNAME(cur, cn);
- free(ap); ap = NULL;
- free(cn); cn = NULL;
-#endif
- } else {
- GET_AI(cur, afd, numaddr);
- GET_PORT(cur, servname);
- }
-
-#ifdef USE_GETIPNODEBY
- if (hp)
- freehostent(hp);
-#endif
- *res = cur;
- return SUCCESS;
- free:
- if (cur)
- freeaddrinfo(cur);
- if (ap)
- free(ap);
- if (cn)
- free(cn);
-#ifdef USE_GETIPNODEBY
- if (hp)
- freehostent(hp);
-#endif
- *res = NULL;
- return error;
-}
-
-static int
-get_canonname(pai, ai, str)
- const struct addrinfo *pai;
- struct addrinfo *ai;
- const char *str;
-{
- if ((pai->ai_flags & AI_CANONNAME) != 0) {
- ai->ai_canonname = strdup(str);
- if (ai->ai_canonname == NULL)
- return EAI_MEMORY;
- }
- return 0;
-}
-
-static struct addrinfo *
-get_ai(pai, afd, addr)
- const struct addrinfo *pai;
- const struct afd *afd;
- const char *addr;
-{
- char *p;
- struct addrinfo *ai;
-
- ai = (struct addrinfo *)malloc(sizeof(struct addrinfo)
- + (afd->a_socklen));
- if (ai == NULL)
- return NULL;
-
- memcpy(ai, pai, sizeof(struct addrinfo));
- ai->ai_addr = (struct sockaddr *)(ai + 1);
- memset(ai->ai_addr, 0, afd->a_socklen);
-#ifdef HAVE_SOCKADDR_SA_LEN
- ai->ai_addr->sa_len = afd->a_socklen;
-#endif
- ai->ai_addrlen = afd->a_socklen;
- ai->ai_addr->sa_family = ai->ai_family = afd->a_af;
- p = (char *)(ai->ai_addr);
- memcpy(p + afd->a_off, addr, afd->a_addrlen);
- return ai;
-}
-
-static int
-get_portmatch(ai, servname)
- const struct addrinfo *ai;
- const char *servname;
-{
-
- /* get_port does not touch first argument. when matchonly == 1. */
- return get_port((struct addrinfo *)ai, servname, 1);
-}
-
-static int
-get_port(ai, servname, matchonly)
- struct addrinfo *ai;
- const char *servname;
- int matchonly;
-{
- const char *proto;
- struct servent *sp;
- int port;
- int allownumeric;
-
- if (servname == NULL)
- return 0;
- switch (ai->ai_family) {
- case AF_INET:
-#ifdef AF_INET6
- case AF_INET6:
-#endif
- break;
- default:
- return 0;
- }
-
- switch (ai->ai_socktype) {
- case SOCK_RAW:
- return EAI_SERVICE;
- case SOCK_DGRAM:
- case SOCK_STREAM:
- allownumeric = 1;
- break;
- case ANY:
- allownumeric = 0;
- break;
- default:
- return EAI_SOCKTYPE;
- }
-
- if (str_isnumber(servname)) {
- if (!allownumeric)
- return EAI_SERVICE;
- port = htons(atoi(servname));
- if (port < 0 || port > 65535)
- return EAI_SERVICE;
- } else {
- switch (ai->ai_socktype) {
- case SOCK_DGRAM:
- proto = "udp";
- break;
- case SOCK_STREAM:
- proto = "tcp";
- break;
- default:
- proto = NULL;
- break;
- }
-
- if ((sp = getservbyname(servname, proto)) == NULL)
- return EAI_SERVICE;
- port = sp->s_port;
- }
-
- if (!matchonly) {
- switch (ai->ai_family) {
- case AF_INET:
- ((struct sockaddr_in *)ai->ai_addr)->sin_port = port;
- break;
-#ifdef INET6
- case AF_INET6:
- ((struct sockaddr_in6 *)ai->ai_addr)->sin6_port = port;
- break;
-#endif
- }
- }
-
- return 0;
-}
-
-static const struct afd *
-find_afd(af)
- int af;
-{
- const struct afd *afd;
-
- if (af == PF_UNSPEC)
- return NULL;
- for (afd = afdl; afd->a_af; afd++) {
- if (afd->a_af == af)
- return afd;
- }
- return NULL;
-}
-
-
-#endif /*__MING64__*/
diff --git a/Win32/Src/getnetbynm.c b/Win32/Src/getnetbynm.c
deleted file mode 100644
index fa4d398e54eb..000000000000
--- a/Win32/Src/getnetbynm.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getnetbyname.c 5.5 (Berkeley) 6/27/88";
-#endif /* LIBC_SCCS and not lint */
-
-#include "inetprivate.h"
-
-extern int _net_stayopen;
-
-struct netent *
-getnetbyname(const char *name)
-{
- register struct netent *p;
- register char **cp;
-
- setnetent(_net_stayopen);
- while (p = getnetent()) {
- if (strcmp(p->n_name, name) == 0)
- break;
- for (cp = p->n_aliases; *cp != 0; cp++)
- if (strcmp(*cp, name) == 0)
- goto found;
- }
-found:
- if (!_net_stayopen)
- endnetent();
- return (p);
-}
diff --git a/Win32/Src/getnetent.c b/Win32/Src/getnetent.c
deleted file mode 100644
index d4cceb334380..000000000000
--- a/Win32/Src/getnetent.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getnetent.c 5.5 (Berkeley) 6/27/88";
-#endif /* LIBC_SCCS and not lint */
-
-#include "inetprivate.h"
-
-#define MAXALIASES 35
-
-static char NETDB[] = _PATH_NETWORKS;
-static FILE *netf = NULL;
-static char line[BUFSIZ+1];
-static struct netent net;
-static char *net_aliases[MAXALIASES];
-static char *any(char *, char *);
-
-int _net_stayopen;
-extern u_int32_t inet_network(const char *cp);
-
-void
-setnetent(f)
- int f;
-{
- if (netf == NULL)
- netf = fopen(NETDB, "r" );
- else
- rewind(netf);
- _net_stayopen |= f;
-}
-
-void
-endnetent()
-{
- if (netf) {
- fclose(netf);
- netf = NULL;
- }
- _net_stayopen = 0;
-}
-
-struct netent *
-getnetent()
-{
- char *p;
- register char *cp, **q;
-
- if (netf == NULL && (netf = fopen(NETDB, "r" )) == NULL)
- return (NULL);
-again:
- p = fgets(line, BUFSIZ, netf);
- if (p == NULL)
- return (NULL);
- if (*p == '#')
- goto again;
- cp = any(p, "#\n");
- if (cp == NULL)
- goto again;
- *cp = '\0';
- net.n_name = p;
- cp = any(p, " \t");
- if (cp == NULL)
- goto again;
- *cp++ = '\0';
- while (*cp == ' ' || *cp == '\t')
- cp++;
- p = any(cp, " \t");
- if (p != NULL)
- *p++ = '\0';
- net.n_net = inet_network(cp);
- net.n_addrtype = AF_INET;
- q = net.n_aliases = net_aliases;
- if (p != NULL)
- cp = p;
- while (cp && *cp) {
- if (*cp == ' ' || *cp == '\t') {
- cp++;
- continue;
- }
- if (q < &net_aliases[MAXALIASES - 1])
- *q++ = cp;
- cp = any(cp, " \t");
- if (cp != NULL)
- *cp++ = '\0';
- }
- *q = NULL;
- return (&net);
-}
-
-static char *
-any(cp, match)
- register char *cp;
- char *match;
-{
- register char *mp, c;
-
- while (c = *cp) {
- for (mp = match; *mp; mp++)
- if (*mp == c)
- return (cp);
- cp++;
- }
- return ((char *)0);
-}
diff --git a/Win32/Src/getservent.c b/Win32/Src/getservent.c
deleted file mode 100644
index 61b8cb04b7fe..000000000000
--- a/Win32/Src/getservent.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 1983, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getservent.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <string.h>
-
-#include <stdlib.h>
-#include <ctype.h>
-#include <net/netdb.h>
-#include <stdio.h>
-#include <errno.h>
-#include <arpa/nameser.h>
-
-#define MAXALIASES 35
-
-static char SERVDB[] = _PATH_SERVICES;
-static FILE *servf = NULL;
-static char line[BUFSIZ+1];
-static struct servent serv;
-static char *serv_aliases[MAXALIASES];
-int _serv_stayopen;
-
-void
-setservent(f)
- int f;
-{
- if (servf == NULL)
- servf = fopen(SERVDB, "r" );
- else
- rewind(servf);
- _serv_stayopen |= f;
-}
-
-void
-endservent()
-{
- if (servf) {
- fclose(servf);
- servf = NULL;
- }
- _serv_stayopen = 0;
-}
-
-struct servent *
-getservent()
-{
- char *p;
- register char *cp, **q;
-
- if (servf == NULL && (servf = fopen(SERVDB, "r" )) == NULL)
- return (NULL);
-again:
- if ((p = fgets(line, BUFSIZ, servf)) == NULL)
- return (NULL);
- if (*p == '#')
- goto again;
- cp = strpbrk(p, "#\n");
- if (cp == NULL)
- goto again;
- *cp = '\0';
- serv.s_name = p;
- p = strpbrk(p, " \t");
- if (p == NULL)
- goto again;
- *p++ = '\0';
- while (*p == ' ' || *p == '\t')
- p++;
- cp = strpbrk(p, ",/");
- if (cp == NULL)
- goto again;
- *cp++ = '\0';
- serv.s_port = htons((u_short)atoi(p));
- serv.s_proto = cp;
- q = serv.s_aliases = serv_aliases;
- cp = strpbrk(cp, " \t");
- if (cp != NULL)
- *cp++ = '\0';
- while (cp && *cp) {
- if (*cp == ' ' || *cp == '\t') {
- cp++;
- continue;
- }
- if (q < &serv_aliases[MAXALIASES - 1])
- *q++ = cp;
- cp = strpbrk(cp, " \t");
- if (cp != NULL)
- *cp++ = '\0';
- }
- *q = NULL;
- return (&serv);
-}
diff --git a/Win32/Src/inet_aton.c b/Win32/Src/inet_aton.c
deleted file mode 100644
index cbd43619164b..000000000000
--- a/Win32/Src/inet_aton.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Hgskolan
- * (Royal Institute of Technology, Stockholm, Sweden).
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the Kungliga Tekniska
- * Hgskolan and its contributors.
- *
- * 4. Neither the name of the Institute nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <pcap-stdinc.h>
-
-/* Minimal implementation of inet_aton.
- * Cannot distinguish between failure and a local broadcast address. */
-
-#ifndef INADDR_NONE
-#define INADDR_NONE 0xffffffff
-#endif
-
-int
-inet_aton(const char *cp, struct in_addr *addr)
-{
- addr->s_addr = inet_addr(cp);
- return (addr->s_addr == INADDR_NONE) ? 0 : 1;
-}
diff --git a/Win32/Src/inet_net.c b/Win32/Src/inet_net.c
deleted file mode 100644
index 5bbe3914ef9b..000000000000
--- a/Win32/Src/inet_net.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 1983, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)inet_network.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include "inetprivate.h"
-
-/*
- * Internet network address interpretation routine.
- * The library routines call this routine to interpret
- * network numbers.
- */
-u_int32_t
-inet_network(const char *cp)
-{
- register u_long val, base, n;
- register char c;
- u_long parts[4], *pp = parts;
- register int i;
-
-again:
- /*
- * Collect number up to ``.''.
- * Values are specified as for C:
- * 0x=hex, 0=octal, other=decimal.
- */
- val = 0; base = 10;
- /*
- * The 4.4BSD version of this file also accepts 'x__' as a hexa
- * number. I don't think this is correct. -- Uli
- */
- if (*cp == '0') {
- if (*++cp == 'x' || *cp == 'X')
- base = 16, cp++;
- else
- base = 8;
- }
- while ((c = *cp)) {
- if (isdigit(c)) {
- val = (val * base) + (c - '0');
- cp++;
- continue;
- }
- if (base == 16 && isxdigit(c)) {
- val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A'));
- cp++;
- continue;
- }
- break;
- }
- if (*cp == '.') {
- if (pp >= parts + 4)
- return (INADDR_NONE);
- *pp++ = val, cp++;
- goto again;
- }
- if (*cp && !isspace(*cp))
- return (INADDR_NONE);
- *pp++ = val;
- n = pp - parts;
- if (n > 4)
- return (INADDR_NONE);
- for (val = 0, i = 0; i < (int)n; i++) {
- val <<= 8;
- val |= parts[i] & 0xff;
- }
- return (val);
-}
diff --git a/Win32/Src/inet_pton.c b/Win32/Src/inet_pton.c
deleted file mode 100644
index fe89bb59f3c3..000000000000
--- a/Win32/Src/inet_pton.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 1999 Kungliga Tekniska Hgskolan
- * (Royal Institute of Technology, Stockholm, Sweden).
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the Kungliga Tekniska
- * Hgskolan and its contributors.
- *
- * 4. Neither the name of the Institute nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <errno.h>
-
-#ifdef WIN32
-#ifndef EAFNOSUPPORT
-#define EAFNOSUPPORT 97 /* not present in errno.h provided with VC */
-#endif
-#endif
-
-#ifdef __MINGW32__
-int* _errno();
-#define errno (*_errno())
-#endif /* __MINGW32__ */
-
-#include <pcap-stdinc.h>
-
-int inet_aton(const char *cp, struct in_addr *addr);
-
-int
-inet_pton(int af, const char *src, void *dst)
-{
- if (af != AF_INET) {
- errno = EAFNOSUPPORT;
- return -1;
- }
- return inet_aton (src, dst);
-}
diff --git a/aclocal.m4 b/aclocal.m4
index 31a18e10fc47..83f5761f0b13 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -102,6 +102,13 @@ AC_DEFUN(AC_LBL_C_INIT,
# -Werror forces warnings to be errors.
#
ac_lbl_cc_force_warning_errors=-Werror
+
+ #
+ # Try to have the compiler default to hiding symbols,
+ # so that only symbols explicitly exported with
+ # PCAP_API will be visible outside (shared) libraries.
+ #
+ AC_LBL_CHECK_COMPILER_OPT($1, -fvisibility=hidden)
else
$2="$$2 -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
@@ -114,6 +121,13 @@ AC_DEFUN(AC_LBL_C_INIT,
# of which use -Werror to force warnings to be errors.
#
ac_lbl_cc_force_warning_errors=-Werror
+
+ #
+ # Try to have the compiler default to hiding symbols,
+ # so that only symbols explicitly exported with
+ # PCAP_API will be visible outside (shared) libraries.
+ #
+ AC_LBL_CHECK_COMPILER_OPT($1, -fvisibility=hidden)
;;
hpux*)
@@ -188,6 +202,13 @@ AC_DEFUN(AC_LBL_C_INIT,
# warnings to be treated as errors.
#
ac_lbl_cc_force_warning_errors=-errwarn
+
+ #
+ # Try to have the compiler default to hiding symbols,
+ # so that only symbols explicitly exported with
+ # PCAP_API will be visible outside (shared) libraries.
+ #
+ AC_LBL_CHECK_COMPILER_OPT($1, -xldscope=hidden)
;;
ultrix*)
@@ -231,7 +252,7 @@ AC_DEFUN(AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR,
# We're assuming this is clang, where
# -Werror=unknown-warning-option is the appropriate
# option to force the compiler to fail.
- #
+ #
ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option"
],
[
@@ -249,7 +270,18 @@ AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
[
AC_MSG_CHECKING([whether the compiler supports the $2 option])
save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2"
+ if expr "x$2" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2"
+ elif expr "x$2" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror $2"
+ elif expr "x$2" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror $2"
+ else
+ CFLAGS="$CFLAGS $2"
+ fi
AC_TRY_COMPILE(
[],
[return 0],
@@ -630,82 +662,6 @@ AC_DEFUN(AC_LBL_FIXINCLUDES,
fi])
dnl
-dnl Check for flex, default to lex
-dnl Require flex 2.4 or higher
-dnl Check for bison, default to yacc
-dnl Default to lex/yacc if both flex and bison are not available
-dnl
-dnl If we're using flex and bison, pass -P to flex and -p to bison
-dnl to define a prefix string for the lexer and parser
-dnl
-dnl If we're not using flex and bison, don't pass those options
-dnl (as they might not work - although if "lex" is a wrapper for
-dnl Flex and "yacc" is a wrapper for Bison, they will work), and
-dnl define NEED_YYPARSE_WRAPPER (we *CANNOT* use YYBISON to check
-dnl whether the wrapper is needed, as some people apparently, for
-dnl some unknown reason, choose to use --without-flex and
-dnl --without-bison on systems that have Flex and Bison, which
-dnl means that the "yacc" they end up using is a wrapper that
-dnl runs "bison -y", and at least some versions of Bison define
-dnl YYBISON even if run with "-y", so we end up not compiling
-dnl the yyparse wrapper and end up with a libpcap that doesn't
-dnl define pcap_parse())
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
-dnl
-dnl results:
-dnl
-dnl $1 (lex set)
-dnl $2 (yacc appended)
-dnl $3 (optional flex and bison -P prefix)
-dnl
-AC_DEFUN(AC_LBL_LEX_AND_YACC,
- [AC_ARG_WITH(flex, [ --without-flex don't use flex])
- AC_ARG_WITH(bison, [ --without-bison don't use bison])
- if test "$with_flex" = no ; then
- $1=lex
- else
- AC_CHECK_PROGS($1, flex, lex)
- fi
- if test "$$1" = flex ; then
- # The -V flag was added in 2.4
- AC_MSG_CHECKING(for flex 2.4 or higher)
- AC_CACHE_VAL(ac_cv_lbl_flex_v24,
- if flex -V >/dev/null 2>&1; then
- ac_cv_lbl_flex_v24=yes
- else
- ac_cv_lbl_flex_v24=no
- fi)
- AC_MSG_RESULT($ac_cv_lbl_flex_v24)
- if test $ac_cv_lbl_flex_v24 = no ; then
- s="2.4 or higher required"
- AC_MSG_WARN(ignoring obsolete flex executable ($s))
- $1=lex
- fi
- fi
- if test "$with_bison" = no ; then
- $2=yacc
- else
- AC_CHECK_PROGS($2, bison, yacc)
- fi
- if test "$$2" = bison ; then
- $2="$$2 -y"
- fi
- if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then
- AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc)
- $1=lex
- $2=yacc
- fi
- if test "$$1" = flex -a -n "$3" ; then
- $1="$$1 -P$3"
- $2="$$2 -p $3"
- else
- AC_DEFINE(NEED_YYPARSE_WRAPPER,1,[if we need a pcap_parse wrapper around yyparse])
- fi])
-
-dnl
dnl Checks to see if union wait is used with WEXITSTATUS()
dnl
dnl usage:
@@ -970,8 +926,12 @@ AC_DEFUN(AC_LBL_DEVEL,
if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR()
AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
+ AC_LBL_CHECK_COMPILER_OPT($1, -Wsign-compare)
AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
+ AC_LBL_CHECK_COMPILER_OPT($1, -Wshadow)
+ AC_LBL_CHECK_COMPILER_OPT($1, -Wdeclaration-after-statement)
+ AC_LBL_CHECK_COMPILER_OPT($1, -Wused-but-marked-unused)
fi
AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
#
@@ -1274,7 +1234,7 @@ dnl
dnl AC_LBL_DL_PASSIVE_REQ_T
dnl
dnl results:
-dnl
+dnl
dnl HAVE_DLPI_PASSIVE (defined)
dnl
AC_DEFUN(AC_LBL_DL_PASSIVE_REQ_T,
diff --git a/bpf/net/bpf_filter.c b/bpf/net/bpf_filter.c
index ad689e16a912..01a1b64e7197 100644
--- a/bpf/net/bpf_filter.c
+++ b/bpf/net/bpf_filter.c
@@ -42,11 +42,11 @@
#include "config.h"
#endif
-#ifdef WIN32
+#ifdef _WIN32
#include <pcap-stdinc.h>
-#else /* WIN32 */
+#else /* _WIN32 */
#if HAVE_INTTYPES_H
#include <inttypes.h>
@@ -73,7 +73,7 @@
# define MLEN(m) ((m)->m_len)
#endif /* defined(__hpux) || SOLARIS */
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include <pcap/bpf.h>
@@ -99,7 +99,7 @@
#endif
#ifndef LBL_ALIGN
-#ifndef WIN32
+#ifndef _WIN32
#include <netinet/in.h>
#endif
@@ -195,23 +195,41 @@ m_xhalf(m, k, err)
}
#endif
+#ifdef __linux__
+#include <linux/types.h>
+#include <linux/if_packet.h>
+#include <linux/filter.h>
+#endif
+
+enum {
+ BPF_S_ANC_NONE,
+ BPF_S_ANC_VLAN_TAG,
+ BPF_S_ANC_VLAN_TAG_PRESENT,
+};
+
/*
* Execute the filter program starting at pc on the packet p
* wirelen is the length of the original packet
* buflen is the amount of data present
+ * aux_data is auxiliary data, currently used only when interpreting
+ * filters intended for the Linux kernel in cases where the kernel
+ * rejects the filter; it contains VLAN tag information
* For the kernel, p is assumed to be a pointer to an mbuf if buflen is 0,
* in all other cases, p is a pointer to a buffer and buflen is its size.
+ *
+ * Thanks to Ani Sinha <ani@arista.com> for providing initial implementation
*/
u_int
-bpf_filter(pc, p, wirelen, buflen)
+bpf_filter_with_aux_data(pc, p, wirelen, buflen, aux_data)
register const struct bpf_insn *pc;
register const u_char *p;
u_int wirelen;
register u_int buflen;
+ register const struct bpf_aux_data *aux_data;
{
register u_int32 A, X;
- register int k;
- int32 mem[BPF_MEMWORDS];
+ register bpf_u_int32 k;
+ u_int32 mem[BPF_MEMWORDS];
#if defined(KERNEL) || defined(_KERNEL)
struct mbuf *m, *n;
int merr, len;
@@ -250,7 +268,7 @@ bpf_filter(pc, p, wirelen, buflen)
case BPF_LD|BPF_W|BPF_ABS:
k = pc->k;
- if (k + sizeof(int32) > buflen) {
+ if (k > buflen || sizeof(int32_t) > buflen - k) {
#if defined(KERNEL) || defined(_KERNEL)
if (m == NULL)
return 0;
@@ -267,7 +285,7 @@ bpf_filter(pc, p, wirelen, buflen)
case BPF_LD|BPF_H|BPF_ABS:
k = pc->k;
- if (k + sizeof(short) > buflen) {
+ if (k > buflen || sizeof(int16_t) > buflen - k) {
#if defined(KERNEL) || defined(_KERNEL)
if (m == NULL)
return 0;
@@ -283,22 +301,50 @@ bpf_filter(pc, p, wirelen, buflen)
continue;
case BPF_LD|BPF_B|BPF_ABS:
- k = pc->k;
- if (k >= buflen) {
+ {
+#if defined(SKF_AD_VLAN_TAG) && defined(SKF_AD_VLAN_TAG_PRESENT)
+ int code = BPF_S_ANC_NONE;
+#define ANCILLARY(CODE) case SKF_AD_OFF + SKF_AD_##CODE: \
+ code = BPF_S_ANC_##CODE; \
+ if (!aux_data) \
+ return 0; \
+ break;
+
+ switch (pc->k) {
+ ANCILLARY(VLAN_TAG);
+ ANCILLARY(VLAN_TAG_PRESENT);
+ default :
+#endif
+ k = pc->k;
+ if (k >= buflen) {
#if defined(KERNEL) || defined(_KERNEL)
- if (m == NULL)
- return 0;
- n = m;
- MINDEX(len, n, k);
- A = mtod(n, u_char *)[k];
- continue;
+ if (m == NULL)
+ return 0;
+ n = m;
+ MINDEX(len, n, k);
+ A = mtod(n, u_char *)[k];
+ continue;
#else
- return 0;
+ return 0;
#endif
+ }
+ A = p[k];
+#if defined(SKF_AD_VLAN_TAG) && defined(SKF_AD_VLAN_TAG_PRESENT)
+ }
+ switch (code) {
+ case BPF_S_ANC_VLAN_TAG:
+ if (aux_data)
+ A = aux_data->vlan_tag;
+ break;
+
+ case BPF_S_ANC_VLAN_TAG_PRESENT:
+ if (aux_data)
+ A = aux_data->vlan_tag_present;
+ break;
+ }
+#endif
+ continue;
}
- A = p[k];
- continue;
-
case BPF_LD|BPF_W|BPF_LEN:
A = wirelen;
continue;
@@ -309,7 +355,8 @@ bpf_filter(pc, p, wirelen, buflen)
case BPF_LD|BPF_W|BPF_IND:
k = X + pc->k;
- if (k + sizeof(int32) > buflen) {
+ if (pc->k > buflen || X > buflen - pc->k ||
+ sizeof(int32_t) > buflen - k) {
#if defined(KERNEL) || defined(_KERNEL)
if (m == NULL)
return 0;
@@ -326,7 +373,8 @@ bpf_filter(pc, p, wirelen, buflen)
case BPF_LD|BPF_H|BPF_IND:
k = X + pc->k;
- if (k + sizeof(short) > buflen) {
+ if (X > buflen || pc->k > buflen - X ||
+ sizeof(int16_t) > buflen - k) {
#if defined(KERNEL) || defined(_KERNEL)
if (m == NULL)
return 0;
@@ -343,7 +391,7 @@ bpf_filter(pc, p, wirelen, buflen)
case BPF_LD|BPF_B|BPF_IND:
k = X + pc->k;
- if (k >= buflen) {
+ if (pc->k >= buflen || X >= buflen - pc->k) {
#if defined(KERNEL) || defined(_KERNEL)
if (m == NULL)
return 0;
@@ -531,7 +579,12 @@ bpf_filter(pc, p, wirelen, buflen)
continue;
case BPF_ALU|BPF_NEG:
- A = -A;
+ /*
+ * Most BPF arithmetic is unsigned, but negation
+ * can't be unsigned; throw some casts to
+ * specify what we're trying to do.
+ */
+ A = (u_int32)(-(int32)A);
continue;
case BPF_MISC|BPF_TAX:
@@ -545,6 +598,17 @@ bpf_filter(pc, p, wirelen, buflen)
}
}
+u_int
+bpf_filter(pc, p, wirelen, buflen)
+ register const struct bpf_insn *pc;
+ register const u_char *p;
+ u_int wirelen;
+ register u_int buflen;
+{
+ return bpf_filter_with_aux_data(pc, p, wirelen, buflen, NULL);
+}
+
+
/*
* Return true if the 'fcode' is a valid filter program.
* The constraints are that each jump be forward and to a valid
@@ -574,7 +638,7 @@ bpf_validate(f, len)
return 0;
#endif
- for (i = 0; i < len; ++i) {
+ for (i = 0; i < (u_int)len; ++i) {
p = &f[i];
switch (BPF_CLASS(p->code)) {
/*
@@ -675,7 +739,7 @@ bpf_validate(f, len)
#if defined(KERNEL) || defined(_KERNEL)
if (from + p->k < from || from + p->k >= len)
#else
- if (from + p->k >= len)
+ if (from + p->k >= (u_int)len)
#endif
return 0;
break;
@@ -683,7 +747,7 @@ bpf_validate(f, len)
case BPF_JGT:
case BPF_JGE:
case BPF_JSET:
- if (from + p->jt >= len || from + p->jf >= len)
+ if (from + p->jt >= (u_int)len || from + p->jf >= (u_int)len)
return 0;
break;
default:
diff --git a/bpf_dump.c b/bpf_dump.c
index 5eaadc08aad2..d5ab61e5e8ff 100644
--- a/bpf_dump.c
+++ b/bpf_dump.c
@@ -51,7 +51,10 @@ bpf_dump(const struct bpf_program *p, int option)
for (i = 0; i < n; ++insn, ++i) {
#ifdef BDEBUG
extern int bids[];
- printf(bids[i] > 0 ? "[%02d]" : " -- ", bids[i] - 1);
+ if (bids[i] > 0)
+ printf("[%02d]", bids[i] - 1);
+ else
+ printf(" -- ");
#endif
puts(bpf_image(insn, i));
}
diff --git a/bpf_image.c b/bpf_image.c
index 3e9a23f51b4c..01ec536dfd62 100644
--- a/bpf_image.c
+++ b/bpf_image.c
@@ -23,9 +23,9 @@
#include "config.h"
#endif
-#ifdef WIN32
+#ifdef _WIN32
#include <pcap-stdinc.h>
-#else /* WIN32 */
+#else /* _WIN32 */
#if HAVE_INTTYPES_H
#include <inttypes.h>
#elif HAVE_STDINT_H
@@ -35,7 +35,7 @@
#include <sys/bitypes.h>
#endif
#include <sys/types.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include <stdio.h>
#include <string.h>
@@ -306,13 +306,13 @@ bpf_image(p, n)
fmt = "";
break;
}
- (void)snprintf(operand, sizeof operand, fmt, v);
+ (void)pcap_snprintf(operand, sizeof operand, fmt, v);
if (BPF_CLASS(p->code) == BPF_JMP && BPF_OP(p->code) != BPF_JA) {
- (void)snprintf(image, sizeof image,
+ (void)pcap_snprintf(image, sizeof image,
"(%03d) %-8s %-16s jt %d\tjf %d",
n, op, operand, n + 1 + p->jt, n + 1 + p->jf);
} else {
- (void)snprintf(image, sizeof image,
+ (void)pcap_snprintf(image, sizeof image,
"(%03d) %-8s %s",
n, op, operand);
}
diff --git a/cmake/preconfigure.cmake b/cmake/preconfigure.cmake
new file mode 100644
index 000000000000..c8c92a48edd7
--- /dev/null
+++ b/cmake/preconfigure.cmake
@@ -0,0 +1,55 @@
+if( NOT LIBPCAP_PRECONFIGURED )
+ set( LIBPCAP_PRECONFIGURED TRUE )
+
+ ###################################################################
+ # Parameters
+ ###################################################################
+
+ option (USE_STATIC_RT "Use static Runtime" ON)
+
+ ######################################
+ # Project setings
+ ######################################
+
+ add_definitions( -DBUILDING_PCAP )
+
+ if( MSVC )
+ add_definitions( -D__STDC__ )
+ add_definitions( -D_CRT_SECURE_NO_WARNINGS )
+ add_definitions( "-D_U_=" )
+ elseif( CMAKE_COMPILER_IS_GNUCXX )
+ add_definitions( "-D_U_=__attribute__((unused))" )
+ else(MSVC)
+ add_definitions( "-D_U_=" )
+ endif( MSVC )
+
+ if (USE_STATIC_RT)
+ MESSAGE( STATUS "Use STATIC runtime" )
+
+ if( MSVC )
+ set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT")
+ set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
+ set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
+ set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
+
+ set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
+ set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT")
+ set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
+ set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
+ endif( MSVC )
+ else (USE_STATIC_RT)
+ MESSAGE( STATUS "Use DYNAMIC runtime" )
+
+ if( MSVC )
+ set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MD")
+ set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD")
+ set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
+ set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
+
+ set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MD")
+ set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MD")
+ set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MD")
+ set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MDd")
+ endif( MSVC )
+ endif (USE_STATIC_RT)
+endif( NOT LIBPCAP_PRECONFIGURED )
diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in
new file mode 100644
index 000000000000..94edb5f44c5a
--- /dev/null
+++ b/cmakeconfig.h.in
@@ -0,0 +1,345 @@
+/* cmakeconfig.h.in */
+
+/* Enable optimizer debugging */
+#cmakedefine BDEBUG 1
+
+/* define if you have a cloning BPF device */
+#cmakedefine HAVE_CLONING_BPF 1
+
+/* define if you have the DAG API */
+#cmakedefine HAVE_DAG_API 1
+
+/* define if you have dag_get_erf_types() */
+#cmakedefine HAVE_DAG_GET_ERF_TYPES 1
+
+/* define if you have dag_get_stream_erf_types() */
+#cmakedefine HAVE_DAG_GET_STREAM_ERF_TYPES 1
+
+/* define if you have streams capable DAG API */
+#cmakedefine HAVE_DAG_STREAMS_API 1
+
+/* define if you have vdag_set_device_info() */
+#cmakedefine HAVE_DAG_VDAG 1
+
+/* Define to 1 if you have the declaration of `ether_hostton', and to 0 if you
+ don't. */
+#cmakedefine HAVE_DECL_ETHER_HOSTTON 1
+
+/* define if you have a /dev/dlpi */
+#cmakedefine HAVE_DEV_DLPI 1
+
+/* if passive_req_t primitive exists */
+#cmakedefine HAVE_DLPI_PASSIVE 1
+
+/* Define to 1 if you have the `ether_hostton' function. */
+#cmakedefine HAVE_ETHER_HOSTTON 1
+
+/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
+#cmakedefine HAVE_FSEEKO 1
+
+/* on HP-UX 10.20 or later */
+#cmakedefine HAVE_HPUX10_20_OR_LATER 1
+
+/* on HP-UX 9.x */
+#cmakedefine HAVE_HPUX9 1
+
+/* if ppa_info_t_dl_module_id exists */
+#cmakedefine HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#cmakedefine HAVE_INTTYPES_H 1
+
+/* if libdlpi exists */
+#cmakedefine HAVE_LIBDLPI 1
+
+/* if libnl exists */
+#cmakedefine HAVE_LIBNL 1
+
+/* if libnl exists and is version 2.x */
+#cmakedefine HAVE_LIBNL_2_x 1
+
+/* if libnl exists and is version 3.x */
+#cmakedefine HAVE_LIBNL_3_x 1
+
+/* libnl has NLE_FAILURE */
+#cmakedefine HAVE_LIBNL_NLE 1
+
+/* libnl has new-style socket api */
+#cmakedefine HAVE_LIBNL_SOCKETS 1
+
+/* Define to 1 if you have the <limits.h> header file. */
+#cmakedefine HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the <linux/compiler.h> header file. */
+#cmakedefine HAVE_LINUX_COMPILER_H 1
+
+/* Define to 1 if you have the <linux/ethtool.h> header file. */
+#cmakedefine HAVE_LINUX_ETHTOOL_H 1
+
+/* Define to 1 if you have the <linux/if_bonding.h> header file. */
+#cmakedefine HAVE_LINUX_IF_BONDING_H 1
+
+/* Define to 1 if you have the <linux/if_packet.h> header file. */
+#cmakedefine HAVE_LINUX_IF_PACKET_H 1
+
+/* Define to 1 if you have the <linux/net_tstamp.h> header file. */
+#cmakedefine HAVE_LINUX_NET_TSTAMP_H 1
+
+/* Define to 1 if you have the <linux/sockios.h> header file. */
+#cmakedefine HAVE_LINUX_SOCKIOS_H 1
+
+/* if tp_vlan_tci exists */
+#cmakedefine HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI 1
+
+/* Define to 1 if you have the <linux/types.h> header file. */
+#cmakedefine HAVE_LINUX_TYPES_H 1
+
+/* Define to 1 if you have the <linux/usbdevice_fs.h> header file. */
+#cmakedefine HAVE_LINUX_USBDEVICE_FS_H 1
+
+/* Define to 1 if you have the <linux/wireless.h> header file. */
+#cmakedefine HAVE_LINUX_WIRELESS_H 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#cmakedefine HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the <netinet/ether.h> header file. */
+#cmakedefine HAVE_NETINET_ETHER_H 1
+
+/* Define to 1 if you have the <netinet/if_ether.h> header file. */
+#cmakedefine HAVE_NETINET_IF_ETHER_H 1
+
+/* Define to 1 if you have the <netpacket/if_packet.h> header file. */
+#cmakedefine HAVE_NETPACKET_IF_PACKET_H 1
+
+/* Define to 1 if you have the <netpacket/packet.h> header file. */
+#cmakedefine HAVE_NETPACKET_PACKET_H 1
+
+/* Define to 1 if you have the <net/if_media.h> header file. */
+#cmakedefine HAVE_NET_IF_MEDIA_H 1
+
+/* Define to 1 if you have the <net/pfvar.h> header file. */
+#cmakedefine HAVE_NET_PFVAR_H 1
+
+/* if there's an os_proto.h for this platform, to use additional prototypes */
+#cmakedefine HAVE_OS_PROTO_H 1
+
+/* Define to 1 if remote packet capture is to be supported */
+#cmakedefine HAVE_REMOTE 1
+
+/* Define to 1 if you have the <paths.h> header file. */
+#cmakedefine HAVE_PATHS_H 1
+
+/* define if net/pfvar.h defines PF_NAT through PF_NORDR */
+#cmakedefine HAVE_PF_NAT_THROUGH_PF_NORDR 1
+
+/* define if you have the Septel API */
+#cmakedefine HAVE_SEPTEL_API 1
+
+/* define if you have the Myricom SNF API */
+#cmakedefine HAVE_SNF_API 1
+
+/* Define to 1 if you have the `snprintf' function. */
+#cmakedefine HAVE_SNPRINTF 1
+
+/* if struct sockaddr has the sa_len member */
+#cmakedefine HAVE_SOCKADDR_SA_LEN 1
+
+/* if struct sockaddr_storage exists */
+#cmakedefine HAVE_SOCKADDR_STORAGE 1
+
+/* define if socklen_t is defined */
+#cmakedefine HAVE_SOCKLEN_T 1
+
+/* On solaris */
+#cmakedefine HAVE_SOLARIS 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#cmakedefine HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#cmakedefine HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strerror' function. */
+#cmakedefine HAVE_STRERROR 1
+
+/* Define to 1 if you have the `strlcpy' function. */
+#cmakedefine HAVE_STRLCPY 1
+
+/* Define to 1 if the system has the type `struct BPF_TIMEVAL'. */
+#cmakedefine HAVE_STRUCT_BPF_TIMEVAL 1
+
+/* Define to 1 if the system has the type `struct ether_addr'. */
+#cmakedefine HAVE_STRUCT_ETHER_ADDR 1
+
+/* Define to 1 if you have the <sys/bitypes.h> header file. */
+#cmakedefine HAVE_SYS_BITYPES_H 1
+
+/* Define to 1 if you have the <sys/bufmod.h> header file. */
+#cmakedefine HAVE_SYS_BUFMOD_H 1
+
+/* Define to 1 if you have the <sys/dlpi_ext.h> header file. */
+#cmakedefine HAVE_SYS_DLPI_EXT_H 1
+
+/* Define to 1 if you have the <sys/ioccom.h> header file. */
+#cmakedefine HAVE_SYS_IOCCOM_H 1
+
+/* Define to 1 if you have the <sys/sockio.h> header file. */
+#cmakedefine HAVE_SYS_SOCKIO_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#cmakedefine HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#cmakedefine HAVE_SYS_TYPES_H 1
+
+/* define if you have the TurboCap API */
+#cmakedefine HAVE_TC_API 1
+
+/* if if_packet.h has tpacket_stats defined */
+#cmakedefine HAVE_TPACKET_STATS 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#cmakedefine HAVE_UNISTD_H 1
+
+/* if struct usbdevfs_ctrltransfer has bRequestType */
+#cmakedefine HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE 1
+
+/* Define to 1 if you have the `vsnprintf' function. */
+#cmakedefine HAVE_VSNPRINTF 1
+
+/* Define to 1 if you have the `PacketIsLoopbackAdapter' function. */
+#cmakedefine HAVE_PACKET_IS_LOOPBACK_ADAPTER 1
+
+/* define if the system supports zerocopy BPF */
+#cmakedefine HAVE_ZEROCOPY_BPF 1
+
+/* define if your compiler has __attribute__ */
+#cmakedefine HAVE___ATTRIBUTE__ 1
+
+/* IPv6 */
+#cmakedefine INET6 1
+
+/* if unaligned access fails */
+#cmakedefine LBL_ALIGN 1
+
+/* path for device for USB sniffing */
+#cmakedefine LINUX_USB_MON_DEV 1
+
+/* if we need a pcap_parse wrapper around yyparse */
+#cmakedefine NEED_YYPARSE_WRAPPER 1
+
+/* Define to 1 if netinet/ether.h declares `ether_hostton' */
+#cmakedefine NETINET_ETHER_H_DECLARES_ETHER_HOSTTON 1
+
+/* Define to 1 if netinet/if_ether.h declares `ether_hostton' */
+#cmakedefine NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON 1
+
+/* do not use protochain */
+#cmakedefine NO_PROTOCHAIN 1
+
+/* Define to the address where bug reports for this package should be sent. */
+#cmakedefine PACKAGE_BUGREPORT 1
+
+/* Define to the full name of this package. */
+#cmakedefine PACKAGE_NAME 1
+
+/* Define to the full name and version of this package. */
+#cmakedefine PACKAGE_STRING 1
+
+/* Define to the one symbol short name of this package. */
+#cmakedefine PACKAGE_TARNAME 1
+
+/* Define to the home page for this package. */
+#cmakedefine PACKAGE_URL 1
+
+/* Define to the version of this package. */
+#cmakedefine PACKAGE_VERSION 1
+
+/* /dev/dlpi directory */
+#cmakedefine PCAP_DEV_PREFIX 1
+
+/* target host supports Bluetooth sniffing */
+#cmakedefine PCAP_SUPPORT_BT 1
+
+/* target host supports Bluetooth Monitor */
+#cmakedefine PCAP_SUPPORT_BT_MONITOR 1
+
+/* support D-Bus sniffing */
+#cmakedefine PCAP_SUPPORT_DBUS 1
+
+/* target host supports netfilter sniffing */
+#cmakedefine PCAP_SUPPORT_NETFILTER 1
+
+/* use Linux packet ring capture if available */
+#cmakedefine PCAP_SUPPORT_PACKET_RING 1
+
+/* target host supports USB sniffing */
+#cmakedefine PCAP_SUPPORT_USB 1
+
+/* include ACN support */
+#cmakedefine SITA 1
+
+/* if struct sockaddr_hci has hci_channel member */
+#cmakedefine SOCKADDR_HCI_HAS_HCI_CHANNEL 1
+
+/* Define to 1 if you have the ANSI C header files. */
+#cmakedefine STDC_HEADERS 1
+
+/* Enable parser debugging */
+#cmakedefine YYDEBUG 1
+
+/* Enable large inode numbers on Mac OS X 10.5. */
+#ifndef _DARWIN_USE_64_BIT_INODE
+# define _DARWIN_USE_64_BIT_INODE 1
+#endif
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#cmakedefine _FILE_OFFSET_BITS 1
+
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+#cmakedefine _LARGEFILE_SOURCE 1
+
+/* Define for large files, on AIX-style hosts. */
+#cmakedefine _LARGE_FILES 1
+
+/* define on AIX to get certain functions */
+#cmakedefine _SUN 1
+
+/* define if your compiler allows __attribute__((format)) without a warning */
+#cmakedefine __ATTRIBUTE___FORMAT_OK 1
+
+#if 0
+/* to handle Ultrix compilers that don't support const in prototypes */
+#cmakedefine const 1
+
+/* Define as token for inline if inlining supported */
+#cmakedefine inline 1
+
+/* Define to `short' if int16_t not defined. */
+#cmakedefine int16_t 1
+
+/* Define to `int' if int32_t not defined. */
+#cmakedefine int32_t 1
+
+/* Define to `long long' if int64_t not defined. */
+#cmakedefine int64_t 1
+
+/* Define to `signed char' if int8_t not defined. */
+#cmakedefine int8_t 1
+
+/* on sinix */
+#cmakedefine sinix 1
+
+/* Define to `unsigned short' if u_int16_t not defined. */
+#cmakedefine u_int16_t 1
+
+/* Define to `unsigned int' if u_int32_t not defined. */
+#cmakedefine u_int32_t 1
+
+/* Define to `unsigned long long' if u_int64_t not defined. */
+#cmakedefine u_int64_t 1
+
+/* Define to `unsigned char' if u_int8_t not defined. */
+#cmakedefine u_int8_t 1
+#endif
diff --git a/config.guess b/config.guess
index d622a44e551f..44290b838cd0 100755
--- a/config.guess
+++ b/config.guess
@@ -1,14 +1,12 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-# 2011, 2012 Free Software Foundation, Inc.
+# Copyright 1992-2015 Free Software Foundation, Inc.
-timestamp='2012-02-10'
+timestamp='2015-02-23'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
@@ -22,19 +20,17 @@ timestamp='2012-02-10'
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Originally written by Per Bothner. Please send patches (context
-# diff format) to <config-patches@gnu.org> and include a ChangeLog
-# entry.
+# the same distribution terms that you use for the rest of that
+# program. This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
#
-# This script attempts to guess a canonical system name similar to
-# config.sub. If it succeeds, it prints the system name on stdout, and
-# exits with 0. Otherwise, it exits with 1.
+# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
#
# You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+#
+# Please send patches to <config-patches@gnu.org>.
+
me=`echo "$0" | sed -e 's,.*/,,'`
@@ -54,9 +50,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-Free Software Foundation, Inc.
+Copyright 1992-2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -138,6 +132,27 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+case "${UNAME_SYSTEM}" in
+Linux|GNU|GNU/*)
+ # If the system lacks a compiler, then just pick glibc.
+ # We could probably try harder.
+ LIBC=gnu
+
+ eval $set_cc_for_build
+ cat <<-EOF > $dummy.c
+ #include <features.h>
+ #if defined(__UCLIBC__)
+ LIBC=uclibc
+ #elif defined(__dietlibc__)
+ LIBC=dietlibc
+ #else
+ LIBC=gnu
+ #endif
+ EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
+ ;;
+esac
+
# Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
@@ -153,20 +168,27 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# Note: NetBSD doesn't particularly care about the vendor
# portion of the name. We always set it to "unknown".
sysctl="sysctl -n hw.machine_arch"
- UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
- /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
+ /sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || \
+ echo unknown)`
case "${UNAME_MACHINE_ARCH}" in
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
sh5el) machine=sh5le-unknown ;;
+ earmv*)
+ arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
+ endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'`
+ machine=${arch}${endian}-unknown
+ ;;
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently, or will in the future.
case "${UNAME_MACHINE_ARCH}" in
- arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax)
eval $set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ELF__
@@ -182,6 +204,13 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
os=netbsd
;;
esac
+ # Determine ABI tags.
+ case "${UNAME_MACHINE_ARCH}" in
+ earm*)
+ expr='s/^earmv[0-9]/-eabi/;s/eb$//'
+ abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"`
+ ;;
+ esac
# The OS release
# Debian GNU/NetBSD machines have a different userland, and
# thus, need a distinct triplet. However, they do not need
@@ -198,7 +227,11 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
- echo "${machine}-${os}${release}"
+ echo "${machine}-${os}${release}${abi}"
+ exit ;;
+ *:Bitrig:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
exit ;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
@@ -302,7 +335,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit ;;
- arm:riscos:*:*|arm:RISCOS:*:*)
+ arm*:riscos:*:*|arm*:RISCOS:*:*)
echo arm-unknown-riscos
exit ;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
@@ -560,8 +593,9 @@ EOF
else
IBM_ARCH=powerpc
fi
- if [ -x /usr/bin/oslevel ] ; then
- IBM_REV=`/usr/bin/oslevel`
+ if [ -x /usr/bin/lslpp ] ; then
+ IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
+ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
else
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
@@ -801,10 +835,13 @@ EOF
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
exit ;;
+ *:MINGW64*:*)
+ echo ${UNAME_MACHINE}-pc-mingw64
+ exit ;;
*:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
exit ;;
- i*:MSYS*:*)
+ *:MSYS*:*)
echo ${UNAME_MACHINE}-pc-msys
exit ;;
i*:windows32*:*)
@@ -852,21 +889,21 @@ EOF
exit ;;
*:GNU:*:*)
# the GNU system
- echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
- echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
exit ;;
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit ;;
aarch64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
@@ -879,59 +916,54 @@ EOF
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
- if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
- echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ arc:Linux:*:* | arceb:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
arm*:Linux:*:*)
eval $set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
else
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
- echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
else
- echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
fi
fi
exit ;;
avr32*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
cris:Linux:*:*)
- echo ${UNAME_MACHINE}-axis-linux-gnu
+ echo ${UNAME_MACHINE}-axis-linux-${LIBC}
exit ;;
crisv32:Linux:*:*)
- echo ${UNAME_MACHINE}-axis-linux-gnu
+ echo ${UNAME_MACHINE}-axis-linux-${LIBC}
exit ;;
frv:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
hexagon:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
i*86:Linux:*:*)
- LIBC=gnu
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #ifdef __dietlibc__
- LIBC=dietlibc
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
- echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+ echo ${UNAME_MACHINE}-pc-linux-${LIBC}
exit ;;
ia64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
m32r*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
m68*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
mips:Linux:*:* | mips64:Linux:*:*)
eval $set_cc_for_build
@@ -950,54 +982,63 @@ EOF
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
;;
- or32:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ openrisc*:Linux:*:*)
+ echo or1k-unknown-linux-${LIBC}
+ exit ;;
+ or32:Linux:*:* | or1k*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
padre:Linux:*:*)
- echo sparc-unknown-linux-gnu
+ echo sparc-unknown-linux-${LIBC}
exit ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
- echo hppa64-unknown-linux-gnu
+ echo hppa64-unknown-linux-${LIBC}
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
- PA7*) echo hppa1.1-unknown-linux-gnu ;;
- PA8*) echo hppa2.0-unknown-linux-gnu ;;
- *) echo hppa-unknown-linux-gnu ;;
+ PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
+ PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
+ *) echo hppa-unknown-linux-${LIBC} ;;
esac
exit ;;
ppc64:Linux:*:*)
- echo powerpc64-unknown-linux-gnu
+ echo powerpc64-unknown-linux-${LIBC}
exit ;;
ppc:Linux:*:*)
- echo powerpc-unknown-linux-gnu
+ echo powerpc-unknown-linux-${LIBC}
+ exit ;;
+ ppc64le:Linux:*:*)
+ echo powerpc64le-unknown-linux-${LIBC}
+ exit ;;
+ ppcle:Linux:*:*)
+ echo powerpcle-unknown-linux-${LIBC}
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
- echo ${UNAME_MACHINE}-ibm-linux
+ echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
exit ;;
sh64*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
sh*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
tile*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
vax:Linux:*:*)
- echo ${UNAME_MACHINE}-dec-linux-gnu
+ echo ${UNAME_MACHINE}-dec-linux-${LIBC}
exit ;;
x86_64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
xtensa*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@@ -1201,6 +1242,9 @@ EOF
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
echo i586-pc-haiku
exit ;;
+ x86_64:Haiku:*:*)
+ echo x86_64-unknown-haiku
+ exit ;;
SX-4:SUPER-UX:*:*)
echo sx4-nec-superux${UNAME_RELEASE}
exit ;;
@@ -1227,19 +1271,31 @@ EOF
exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
- case $UNAME_PROCESSOR in
- i386)
- eval $set_cc_for_build
- if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
- if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
- (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
- grep IS_64BIT_ARCH >/dev/null
- then
- UNAME_PROCESSOR="x86_64"
- fi
- fi ;;
- unknown) UNAME_PROCESSOR=powerpc ;;
- esac
+ eval $set_cc_for_build
+ if test "$UNAME_PROCESSOR" = unknown ; then
+ UNAME_PROCESSOR=powerpc
+ fi
+ if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
+ if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ case $UNAME_PROCESSOR in
+ i386) UNAME_PROCESSOR=x86_64 ;;
+ powerpc) UNAME_PROCESSOR=powerpc64 ;;
+ esac
+ fi
+ fi
+ elif test "$UNAME_PROCESSOR" = i386 ; then
+ # Avoid executing cc on OS X 10.9, as it ships with a stub
+ # that puts up a graphical alert prompting to install
+ # developer tools. Any system running Mac OS X 10.7 or
+ # later (Darwin 11 and later) is required to have a 64-bit
+ # processor. This is not true of the ARM version of Darwin
+ # that Apple uses in portable devices.
+ UNAME_PROCESSOR=x86_64
+ fi
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
exit ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
@@ -1256,7 +1312,7 @@ EOF
NEO-?:NONSTOP_KERNEL:*:*)
echo neo-tandem-nsk${UNAME_RELEASE}
exit ;;
- NSE-?:NONSTOP_KERNEL:*:*)
+ NSE-*:NONSTOP_KERNEL:*:*)
echo nse-tandem-nsk${UNAME_RELEASE}
exit ;;
NSR-?:NONSTOP_KERNEL:*:*)
@@ -1330,157 +1386,6 @@ EOF
exit ;;
esac
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
- /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
- I don't know.... */
- printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
- printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
- "4"
-#else
- ""
-#endif
- ); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
- printf ("arm-acorn-riscix\n"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
- printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
- int version;
- version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
- if (version < 4)
- printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
- else
- printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
- exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
- printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
- printf ("ns32k-encore-mach\n"); exit (0);
-#else
- printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
- printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
- printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
- printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
- struct utsname un;
-
- uname(&un);
-
- if (strncmp(un.version, "V2", 2) == 0) {
- printf ("i386-sequent-ptx2\n"); exit (0);
- }
- if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
- printf ("i386-sequent-ptx1\n"); exit (0);
- }
- printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-# include <sys/param.h>
-# if defined (BSD)
-# if BSD == 43
- printf ("vax-dec-bsd4.3\n"); exit (0);
-# else
-# if BSD == 199006
- printf ("vax-dec-bsd4.3reno\n"); exit (0);
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# endif
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# else
- printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
- printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
- exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
- { echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
- case `getsysinfo -f cpu_type` in
- c1*)
- echo c1-convex-bsd
- exit ;;
- c2*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit ;;
- c34*)
- echo c34-convex-bsd
- exit ;;
- c38*)
- echo c38-convex-bsd
- exit ;;
- c4*)
- echo c4-convex-bsd
- exit ;;
- esac
-fi
-
cat >&2 <<EOF
$0: unable to guess system type
diff --git a/config.h.in b/config.h.in
index 4bbb491ec168..e85b2a3f5617 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,4 +1,4 @@
-/* config.h.in. Generated from configure.in by autoheader. */
+/* config.h.in. Generated from configure.ac by autoheader. */
/* Enable optimizer debugging */
#undef BDEBUG
@@ -76,12 +76,18 @@
/* Define to 1 if you have the <linux/ethtool.h> header file. */
#undef HAVE_LINUX_ETHTOOL_H
+/* Define to 1 if you have the <linux/if_bonding.h> header file. */
+#undef HAVE_LINUX_IF_BONDING_H
+
/* Define to 1 if you have the <linux/if_packet.h> header file. */
#undef HAVE_LINUX_IF_PACKET_H
/* Define to 1 if you have the <linux/net_tstamp.h> header file. */
#undef HAVE_LINUX_NET_TSTAMP_H
+/* Define to 1 if you have the <linux/sockios.h> header file. */
+#undef HAVE_LINUX_SOCKIOS_H
+
/* if tp_vlan_tci exists */
#undef HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI
@@ -118,16 +124,13 @@
/* if there's an os_proto.h for this platform, to use additional prototypes */
#undef HAVE_OS_PROTO_H
-/* Define to 1 if you have the <paths.h> header file. */
-#undef HAVE_PATHS_H
-
/* define if net/pfvar.h defines PF_NAT through PF_NORDR */
#undef HAVE_PF_NAT_THROUGH_PF_NORDR
-/* define if you have a Septel API */
+/* define if you have the Septel API */
#undef HAVE_SEPTEL_API
-/* define if you have Myricom SNF API */
+/* define if you have the Myricom SNF API */
#undef HAVE_SNF_API
/* Define to 1 if you have the `snprintf' function. */
@@ -163,6 +166,9 @@
/* Define to 1 if you have the `strlcpy' function. */
#undef HAVE_STRLCPY
+/* Define to 1 if you have the `strtok_r' function. */
+#undef HAVE_STRTOK_R
+
/* Define to 1 if the system has the type `struct BPF_TIMEVAL'. */
#undef HAVE_STRUCT_BPF_TIMEVAL
@@ -181,6 +187,9 @@
/* Define to 1 if you have the <sys/ioccom.h> header file. */
#undef HAVE_SYS_IOCCOM_H
+/* Define to 1 if you have the <sys/select.h> header file. */
+#undef HAVE_SYS_SELECT_H
+
/* Define to 1 if you have the <sys/sockio.h> header file. */
#undef HAVE_SYS_SOCKIO_H
@@ -190,6 +199,9 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
+/* define if you have the TurboCap API */
+#undef HAVE_TC_API
+
/* if if_packet.h has tpacket_stats defined */
#undef HAVE_TPACKET_STATS
@@ -199,9 +211,6 @@
/* if struct usbdevfs_ctrltransfer has bRequestType */
#undef HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE
-/* define if version.h is generated in the build procedure */
-#undef HAVE_VERSION_H
-
/* Define to 1 if you have the `vsnprintf' function. */
#undef HAVE_VSNPRINTF
@@ -220,9 +229,6 @@
/* path for device for USB sniffing */
#undef LINUX_USB_MON_DEV
-/* if we need a pcap_parse wrapper around yyparse */
-#undef NEED_YYPARSE_WRAPPER
-
/* Define to 1 if netinet/ether.h declares `ether_hostton' */
#undef NETINET_ETHER_H_DECLARES_ETHER_HOSTTON
@@ -259,18 +265,15 @@
/* target host supports Bluetooth Monitor */
#undef PCAP_SUPPORT_BT_MONITOR
-/* target host supports CAN sniffing */
-#undef PCAP_SUPPORT_CAN
-
-/* target host supports canusb */
-#undef PCAP_SUPPORT_CANUSB
-
/* support D-Bus sniffing */
#undef PCAP_SUPPORT_DBUS
/* target host supports netfilter sniffing */
#undef PCAP_SUPPORT_NETFILTER
+/* use Linux packet ring capture if available */
+#undef PCAP_SUPPORT_PACKET_RING
+
/* target host supports USB sniffing */
#undef PCAP_SUPPORT_USB
@@ -286,6 +289,10 @@
/* Enable parser debugging */
#undef YYDEBUG
+/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
+ `char[]'. */
+#undef YYTEXT_POINTER
+
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
diff --git a/config.sub b/config.sub
index 59bb593f109c..bc855a2a910e 100755
--- a/config.sub
+++ b/config.sub
@@ -1,24 +1,18 @@
#! /bin/sh
# Configuration validation subroutine script.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-# 2011, 2012 Free Software Foundation, Inc.
+# Copyright 1992-2015 Free Software Foundation, Inc.
-timestamp='2012-04-18'
+timestamp='2015-02-22'
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine. It does not imply ALL GNU software can.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
@@ -26,11 +20,12 @@ timestamp='2012-04-18'
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
+# the same distribution terms that you use for the rest of that
+# program. This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
-# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted GNU ChangeLog entry.
+# Please send patches to <config-patches@gnu.org>.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
@@ -73,9 +68,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-Free Software Foundation, Inc.
+Copyright 1992-2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -123,8 +116,8 @@ esac
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
- linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
- knetbsd*-gnu* | netbsd*-gnu* | \
+ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
kopensolaris*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
@@ -156,7 +149,7 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
- -apple | -axis | -knuth | -cray | -microblaze)
+ -apple | -axis | -knuth | -cray | -microblaze*)
os=
basic_machine=$1
;;
@@ -259,21 +252,24 @@ case $basic_machine in
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
- | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
- | be32 | be64 \
+ | arc | arceb \
+ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
+ | avr | avr32 \
+ | be32 | be64 \
| bfin \
- | c4x | clipper \
+ | c4x | c8051 | clipper \
| d10v | d30v | dlx | dsp16xx \
| epiphany \
- | fido | fr30 | frv \
+ | fido | fr30 | frv | ft32 \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| hexagon \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
+ | k1om \
| le32 | le64 \
| lm32 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
- | maxq | mb | microblaze | mcore | mep | metag \
+ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
@@ -287,23 +283,26 @@ case $basic_machine in
| mips64vr5900 | mips64vr5900el \
| mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \
+ | mipsisa32r6 | mipsisa32r6el \
| mipsisa64 | mipsisa64el \
| mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64r6 | mipsisa64r6el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
+ | mipsr5900 | mipsr5900el \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| moxie \
| mt \
| msp430 \
| nds32 | nds32le | nds32be \
- | nios | nios2 \
+ | nios | nios2 | nios2eb | nios2el \
| ns16k | ns32k \
- | open8 \
- | or32 \
+ | open8 | or1k | or1knd | or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle \
| pyramid \
+ | riscv32 | riscv64 \
| rl78 | rx \
| score \
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
@@ -314,6 +313,7 @@ case $basic_machine in
| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
| ubicom32 \
| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
+ | visium \
| we32k \
| x86 | xc16x | xstormy16 | xtensa \
| z8k | z80)
@@ -328,7 +328,10 @@ case $basic_machine in
c6x)
basic_machine=tic6x-unknown
;;
- m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
+ leon|leon[3-9])
+ basic_machine=sparc-$basic_machine
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
basic_machine=$basic_machine-unknown
os=-none
;;
@@ -370,13 +373,13 @@ case $basic_machine in
| aarch64-* | aarch64_be-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
- | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \
| be32-* | be64-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* \
- | clipper-* | craynv-* | cydra-* \
+ | c8051-* | clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
@@ -385,11 +388,13 @@ case $basic_machine in
| hexagon-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
+ | k1om-* \
| le32-* | le64-* \
| lm32-* \
| m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
- | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+ | microblaze-* | microblazeel-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
@@ -403,18 +408,22 @@ case $basic_machine in
| mips64vr5900-* | mips64vr5900el-* \
| mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa32r6-* | mipsisa32r6el-* \
| mipsisa64-* | mipsisa64el-* \
| mipsisa64r2-* | mipsisa64r2el-* \
+ | mipsisa64r6-* | mipsisa64r6el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipsr5900-* | mipsr5900el-* \
| mipstx39-* | mipstx39el-* \
| mmix-* \
| mt-* \
| msp430-* \
| nds32-* | nds32le-* | nds32be-* \
- | nios-* | nios2-* \
+ | nios-* | nios2-* | nios2eb-* | nios2el-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| open8-* \
+ | or1k*-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
@@ -432,6 +441,7 @@ case $basic_machine in
| ubicom32-* \
| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
| vax-* \
+ | visium-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* \
| xstormy16-* | xtensa*-* \
@@ -769,6 +779,9 @@ case $basic_machine in
basic_machine=m68k-isi
os=-sysv
;;
+ leon-*|leon[3-9]-*)
+ basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
+ ;;
m68knommu)
basic_machine=m68k-unknown
os=-linux
@@ -788,11 +801,15 @@ case $basic_machine in
basic_machine=ns32k-utek
os=-sysv
;;
- microblaze)
+ microblaze*)
basic_machine=microblaze-xilinx
;;
+ mingw64)
+ basic_machine=x86_64-pc
+ os=-mingw64
+ ;;
mingw32)
- basic_machine=i386-pc
+ basic_machine=i686-pc
os=-mingw32
;;
mingw32ce)
@@ -820,6 +837,10 @@ case $basic_machine in
basic_machine=powerpc-unknown
os=-morphos
;;
+ moxiebox)
+ basic_machine=moxie-unknown
+ os=-moxiebox
+ ;;
msdos)
basic_machine=i386-pc
os=-msdos
@@ -828,7 +849,7 @@ case $basic_machine in
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
msys)
- basic_machine=i386-pc
+ basic_machine=i686-pc
os=-msys
;;
mvs)
@@ -1019,7 +1040,11 @@ case $basic_machine in
basic_machine=i586-unknown
os=-pw32
;;
- rdos)
+ rdos | rdos64)
+ basic_machine=x86_64-pc
+ os=-rdos
+ ;;
+ rdos32)
basic_machine=i386-pc
os=-rdos
;;
@@ -1346,29 +1371,29 @@ case $os in
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
- | -sym* | -kopensolaris* \
+ | -sym* | -kopensolaris* | -plan9* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* | -aros* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
- | -openbsd* | -solidbsd* \
+ | -bitrig* | -openbsd* | -solidbsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* | -cegcc* \
| -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -mingw32* | -linux-gnu* | -linux-android* \
- | -linux-newlib* | -linux-uclibc* \
- | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+ | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
- | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@@ -1492,9 +1517,6 @@ case $os in
-aros*)
os=-aros
;;
- -kaos*)
- os=-kaos
- ;;
-zvmoe)
os=-zvmoe
;;
@@ -1543,6 +1565,12 @@ case $basic_machine in
c4x-* | tic4x-*)
os=-coff
;;
+ c8051-*)
+ os=-elf
+ ;;
+ hexagon-*)
+ os=-elf
+ ;;
tic54x-*)
os=-coff
;;
diff --git a/config/have_siocglifconf.c b/config/have_siocglifconf.c
new file mode 100644
index 000000000000..5a67abc192c4
--- /dev/null
+++ b/config/have_siocglifconf.c
@@ -0,0 +1,6 @@
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+int main() {
+ ioctl(0, SIOCGLIFCONF, (char *)0);
+}
diff --git a/configure b/configure
index e665cb9bbc0c..4c64875e3e69 100755
--- a/configure
+++ b/configure
@@ -623,13 +623,10 @@ ac_subst_vars='LTLIBOBJS
INSTALL_DATA
INSTALL_SCRIPT
INSTALL_PROGRAM
+PCAP_SUPPORT_PACKET_RING
DBUS_SRC
PCAP_SUPPORT_DBUS
PKGCONFIG
-CAN_SRC
-PCAP_SUPPORT_CAN
-CANUSB_SRC
-PCAP_SUPPORT_CANUSB
BT_MONITOR_SRC
BT_SRC
PCAP_SUPPORT_BT
@@ -643,11 +640,13 @@ DYEXT
SSRC
ADDLARCHIVEOBJS
ADDLOBJS
+V_YACC
V_RPATH_OPT
V_SONAME_OPT
V_SHLIB_OPT
V_SHLIB_CMD
V_PCAP
+V_LEX
V_INCLS
V_FINDALLDEVS
V_DEFS
@@ -657,9 +656,13 @@ DEPENDENCY_CFLAG
LN_S
AR
RANLIB
-V_YACC
-V_LEX
+YFLAGS
+YACC
+LEXLIB
+LEX_OUTPUT_ROOT
+LEX
HAVE_LINUX_TPACKET_AUXDATA
+VALGRINDTEST
LIBOBJS
EGREP
GREP
@@ -741,14 +744,13 @@ with_septel
with_snf
with_snf_includes
with_snf_libraries
-with_flex
-with_bison
+with_turbocap
enable_universal
enable_shared
+enable_usb
enable_bluetooth
-enable_canusb
-enable_can
enable_dbus
+enable_packet_ring
'
ac_precious_vars='build_alias
host_alias
@@ -758,7 +760,9 @@ CFLAGS
LDFLAGS
LIBS
CPPFLAGS
-CPP'
+CPP
+YACC
+YFLAGS'
# Initialize some variables set by options.
@@ -1380,14 +1384,13 @@ Optional Features:
--disable-universal don't build universal on OS X
--enable-shared build shared libraries [default=yes, if support
available]
- --enable-bluetooth enable Bluetooth support [default=yes, if support
- available]
- --enable-canusb enable canusb support [default=yes, if support
+ --enable-usb enable nusb support [default=yes, if support
available]
- --enable-can enable CAN support [default=yes, if support
+ --enable-bluetooth enable Bluetooth support [default=yes, if support
available]
--enable-dbus enable D-Bus capture support [default=yes, if
support available]
+ --enable-packet-ring enable Linux packet ring support [default=yes]
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -1397,20 +1400,23 @@ Optional Packages:
--with-pcap=TYPE use packet capture TYPE
--without-libnl disable libnl support [default=yes, on Linux, if
present]
- --with-dag[=DIR] include Endace DAG support ["yes", "no" or DIR;
- default="yes" on BSD and Linux if present]
- --with-dag-includes=DIR Endace DAG include directory
- --with-dag-libraries=DIR
- Endace DAG library directory
+ --with-dag[=DIR] include Endace DAG support (located in directory
+ DIR, if supplied). [default=yes, if present]
+ --with-dag-includes=IDIR
+ Endace DAG include directory, if not DIR/include
+ --with-dag-libraries=LDIR
+ Endace DAG library directory, if not DIR/lib
--with-septel[=DIR] include Septel support (located in directory DIR, if
- supplied). [default=yes, on Linux, if present]
- --with-snf[=DIR] include Myricom SNF support ["yes", "no" or DIR;
- default="yes" on BSD and Linux if present]
- --with-snf-includes=DIR Myricom SNF include directory
- --with-snf-libraries=DIR
- Myricom SNF library directory
- --without-flex don't use flex
- --without-bison don't use bison
+ supplied). [default=yes, if present]
+ --with-snf[=DIR] include Myricom SNF support (located in directory
+ DIR, if supplied). [default=yes, if present]
+ --with-snf-includes=IDIR
+ Myricom SNF include directory, if not DIR/include
+ --with-snf-libraries=LDIR
+ Myricom SNF library directory, if not DIR/lib
+ --with-turbocap[=DIR] include Riverbed TurboCap support (located in
+ directory DIR, if supplied). [default=yes, if
+ present]
Some influential environment variables:
CC C compiler command
@@ -1421,6 +1427,12 @@ Some influential environment variables:
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
+ YACC The `Yet Another Compiler Compiler' implementation to use.
+ Defaults to the first program found out of: `bison -y', `byacc',
+ `yacc'.
+ YFLAGS The list of arguments that will be passed by default to $YACC.
+ This script will default YFLAGS to the empty string to avoid a
+ default value of `-d' given by some make applications.
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
@@ -3308,11 +3320,61 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
if test "$GCC" = yes ; then
#
# -Werror forces warnings to be errors.
#
ac_lbl_cc_force_warning_errors=-Werror
+
+ #
+ # Try to have the compiler default to hiding symbols,
+ # so that only symbols explicitly exported with
+ # PCAP_API will be visible outside (shared) libraries.
+ #
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -fvisibility=hidden option" >&5
+$as_echo_n "checking whether the compiler supports the -fvisibility=hidden option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-fvisibility=hidden" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -fvisibility=hidden"
+ elif expr "x-fvisibility=hidden" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -fvisibility=hidden"
+ elif expr "x-fvisibility=hidden" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -fvisibility=hidden"
+ else
+ CFLAGS="$CFLAGS -fvisibility=hidden"
+ fi
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -fvisibility=hidden"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
else
V_INCLS="$V_INCLS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
@@ -3325,6 +3387,55 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# of which use -Werror to force warnings to be errors.
#
ac_lbl_cc_force_warning_errors=-Werror
+
+ #
+ # Try to have the compiler default to hiding symbols,
+ # so that only symbols explicitly exported with
+ # PCAP_API will be visible outside (shared) libraries.
+ #
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -fvisibility=hidden option" >&5
+$as_echo_n "checking whether the compiler supports the -fvisibility=hidden option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-fvisibility=hidden" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -fvisibility=hidden"
+ elif expr "x-fvisibility=hidden" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -fvisibility=hidden"
+ elif expr "x-fvisibility=hidden" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -fvisibility=hidden"
+ else
+ CFLAGS="$CFLAGS -fvisibility=hidden"
+ fi
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -fvisibility=hidden"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
;;
hpux*)
@@ -3399,6 +3510,55 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# warnings to be treated as errors.
#
ac_lbl_cc_force_warning_errors=-errwarn
+
+ #
+ # Try to have the compiler default to hiding symbols,
+ # so that only symbols explicitly exported with
+ # PCAP_API will be visible outside (shared) libraries.
+ #
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -xldscope=hidden option" >&5
+$as_echo_n "checking whether the compiler supports the -xldscope=hidden option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-xldscope=hidden" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -xldscope=hidden"
+ elif expr "x-xldscope=hidden" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -xldscope=hidden"
+ elif expr "x-xldscope=hidden" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -xldscope=hidden"
+ else
+ CFLAGS="$CFLAGS -xldscope=hidden"
+ fi
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -xldscope=hidden"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
;;
ultrix*)
@@ -3407,8 +3567,7 @@ $as_echo_n "checking that Ultrix $CC hacks const in prototypes... " >&6; }
if ${ac_cv_lbl_cc_const_proto+:} false; then :
$as_echo_n "(cached) " >&6
else
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/types.h>
int
@@ -4572,7 +4731,7 @@ $as_echo "#define HAVE_FSEEKO 1" >>confdefs.h
fi
-for ac_header in sys/ioccom.h sys/sockio.h limits.h paths.h
+for ac_header in sys/ioccom.h sys/select.h sys/sockio.h limits.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -4704,6 +4863,28 @@ done
fi
+case "$host_os" in
+linux*|uclinux*)
+ for ac_header in linux/sockios.h linux/if_bonding.h
+do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "
+#include <sys/socket.h>
+#include <linux/if.h>
+
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+ ;;
+esac
+
if test "$GCC" = yes ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI ioctl definitions" >&5
$as_echo_n "checking for ANSI ioctl definitions... " >&6; }
@@ -4787,6 +4968,29 @@ esac
fi
+needstrtok_r=no
+for ac_func in strtok_r
+do :
+ ac_fn_c_check_func "$LINENO" "strtok_r" "ac_cv_func_strtok_r"
+if test "x$ac_cv_func_strtok_r" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_STRTOK_R 1
+_ACEOF
+
+else
+ needstrtok_r=yes
+fi
+done
+
+if test $needstrtok_r = yes; then
+ case " $LIBOBJS " in
+ *" strtok_r.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS strtok_r.$ac_objext"
+ ;;
+esac
+
+fi
+
#
# Do this before checking for ether_hostton(), as it's a
# "gethostbyname() -ish function".
@@ -5204,6 +5408,13 @@ fi
$as_echo "${enable_protochain}" >&6; }
#
+# valgrindtest directly uses the native capture mechanism, but
+# only tests with BPF and PF_PACKET sockets; only enable it if
+# we have BPF or PF_PACKET sockets.
+#
+VALGRINDTEST=
+
+#
# SITA support is mutually exclusive with native capture support;
# "--with-sita" selects SITA support.
#
@@ -5218,7 +5429,6 @@ $as_echo "#define SITA 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: Enabling SITA ACN support" >&5
$as_echo "$as_me: Enabling SITA ACN support" >&6;}
V_PCAP=sita
- V_FINDALLDEVS=sita
fi
else
@@ -5244,8 +5454,18 @@ elif test -r /dev/bpf -o -h /dev/bpf ; then
$as_echo "#define HAVE_CLONING_BPF 1" >>confdefs.h
+
+ #
+ # We have BPF, so build valgrindtest with "make test".
+ #
+ VALGRINDTEST=valgrindtest
elif test -r /dev/bpf0 ; then
V_PCAP=bpf
+
+ #
+ # We have BPF, so build valgrindtest with "make test".
+ #
+ VALGRINDTEST=valgrindtest
elif test -r /usr/include/net/pfilt.h ; then
V_PCAP=pf
elif test -r /dev/enet ; then
@@ -5256,6 +5476,12 @@ elif test -r /usr/include/sys/net/nit.h ; then
V_PCAP=nit
elif test -r /usr/include/linux/socket.h ; then
V_PCAP=linux
+
+ #
+ # XXX - this won't work with older kernels that have SOCK_PACKET
+ # sockets but not PF_PACKET sockets.
+ #
+ VALGRINDTEST=valgrindtest
elif test -r /usr/include/net/raw.h ; then
V_PCAP=snoop
elif test -r /usr/include/odmi.h ; then
@@ -5267,6 +5493,11 @@ elif test -r /usr/include/odmi.h ; then
V_PCAP=bpf
elif test -c /dev/bpf0 ; then # check again in case not readable
V_PCAP=bpf
+
+ #
+ # We have BPF, so build valgrindtest with "make test".
+ #
+ VALGRINDTEST=valgrindtest
elif test -r /usr/include/sys/dlpi.h ; then
V_PCAP=dlpi
elif test -c /dev/enet ; then # check again in case not readable
@@ -5279,6 +5510,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $V_PCAP" >&5
$as_echo "$V_PCAP" >&6; }
+
#
# Do capture-mechanism-dependent tests.
#
@@ -5512,6 +5744,13 @@ fi
if test x$with_libnl != xno ; then
have_any_nl="no"
+ incdir=-I/usr/include/libnl3
+ libnldir=
+ if test x$withval != x ; then
+ libnldir=-L${withval}/lib/.libs
+ incdir=-I${withval}/include
+ fi
+
#
# Try libnl 3.x first.
#
@@ -5521,7 +5760,7 @@ if ${ac_cv_lib_nl_3_nl_socket_alloc+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
-LIBS="-lnl-3 $LIBS"
+LIBS="-lnl-3 ${incdir} ${libnldir} -lnl-genl-3 -lnl-3 $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -5556,7 +5795,7 @@ if test "x$ac_cv_lib_nl_3_nl_socket_alloc" = xyes; then :
#
# Yes, we have libnl 3.x.
#
- LIBS="-lnl-genl-3 -lnl-3 $LIBS"
+ LIBS="${libnldir} -lnl-genl-3 -lnl-3 $LIBS"
$as_echo "#define HAVE_LIBNL 1" >>confdefs.h
@@ -5569,7 +5808,7 @@ $as_echo "#define HAVE_LIBNL_NLE 1" >>confdefs.h
$as_echo "#define HAVE_LIBNL_SOCKETS 1" >>confdefs.h
- V_INCLS="$V_INCLS -I/usr/include/libnl3"
+ V_INCLS="$V_INCLS ${incdir}"
have_any_nl="yes"
fi
@@ -5620,7 +5859,7 @@ if test "x$ac_cv_lib_nl_nl_socket_alloc" = xyes; then :
#
# Yes, we have libnl 2.x.
#
- LIBS="-lnl-genl -lnl $LIBS"
+ LIBS="${libnldir} -lnl-genl -lnl $LIBS"
$as_echo "#define HAVE_LIBNL 1" >>confdefs.h
@@ -5684,7 +5923,7 @@ if test "x$ac_cv_lib_nl_nl_handle_alloc" = xyes; then :
#
# Yes.
#
- LIBS="-lnl $LIBS"
+ LIBS="${libnldir} -lnl $LIBS"
$as_echo "#define HAVE_LIBNL 1" >>confdefs.h
@@ -5860,15 +6099,30 @@ fi
;;
dag)
+ #
+ # --with-pcap=dag is the only way to get here, and it means
+ # "DAG support but nothing else"
+ #
V_DEFS="$V_DEFS -DDAG_ONLY"
+ xxx_only=yes
;;
septel)
+ #
+ # --with-pcap=septel is the only way to get here, and it means
+ # "Septel support but nothing else"
+ #
V_DEFS="$V_DEFS -DSEPTEL_ONLY"
+ xxx_only=yes
;;
snf)
+ #
+ # --with-pcap=snf is the only way to get here, and it means
+ # "SNF support but nothing else"
+ #
V_DEFS="$V_DEFS -DSNF_ONLY"
+ xxx_only=yes
;;
null)
@@ -5879,14 +6133,8 @@ $as_echo "$as_me: WARNING: (see the INSTALL doc for more info)" >&2;}
;;
esac
-if test "$V_PCAP" = null
+if test "$V_PCAP" != null
then
- #
- # We can't capture, so we can't open any capture
- # devices, so we won't return any interfaces.
- #
- V_FINDALLDEVS=null
-else
ac_fn_c_check_func "$LINENO" "getifaddrs" "ac_cv_func_getifaddrs"
if test "x$ac_cv_func_getifaddrs" = xyes; then :
@@ -5901,7 +6149,7 @@ if test "x$ac_cv_header_ifaddrs_h" = xyes; then :
# We have the header, so we use "getifaddrs()" to
# get the list of interfaces.
#
- V_FINDALLDEVS=getad
+ V_FINDALLDEVS=fad-getad.c
else
@@ -5969,9 +6217,9 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_have_siocglifconf" >&5
$as_echo "$ac_cv_lbl_have_siocglifconf" >&6; }
if test $ac_cv_lbl_have_siocglifconf = yes ; then
- V_FINDALLDEVS=glifc
+ V_FINDALLDEVS=fad-glifc.c
else
- V_FINDALLDEVS=gifc
+ V_FINDALLDEVS=fad-gifc.c
fi
;;
@@ -5982,7 +6230,7 @@ $as_echo "$ac_cv_lbl_have_siocglifconf" >&6; }
# another mechanism, and we should be using that
# instead.)
#
- V_FINDALLDEVS=gifc
+ V_FINDALLDEVS=fad-gifc.c
;;
esac
fi
@@ -6101,10 +6349,20 @@ if test "${with_dag+set}" = set; then :
else
- #
- # Use DAG API if present, otherwise don't
- #
- want_dag=ifpresent
+ if test "$V_PCAP" = dag; then
+ # User requested DAG-only libpcap, so we'd better have
+ # the DAG API.
+ want_dag=yes
+ elif test "xxx_only" = yes; then
+ # User requested something-else-only pcap, so they don't
+ # want DAG support.
+ want_dag=no
+ else
+ #
+ # Use DAG API if present, otherwise don't
+ #
+ want_dag=ifpresent
+ fi
fi
@@ -6131,28 +6389,6 @@ if test "${with_dag_libraries+set}" = set; then :
fi
-case "$V_PCAP" in
-linux|bpf|dag)
- #
- # We support the DAG API if we're on Linux or BSD, or if we're
- # building a DAG-only libpcap.
- #
- ;;
-*)
- #
- # If the user explicitly requested DAG, tell them it's not
- # supported.
- #
- # If they expressed no preference, don't include it.
- #
- if test $want_dag = yes; then
- as_fn_error $? "DAG support is only available with 'linux' 'bpf' and 'dag' packet capture types" "$LINENO" 5
- elif test $want_dag = yes; then
- want_dag=no
- fi
- ;;
-esac
-
ac_cv_lbl_dag_api=no
if test "$want_dag" != no; then
@@ -6161,7 +6397,7 @@ $as_echo_n "checking whether we have DAG API headers... " >&6; }
# If necessary, set default paths for DAG API headers and libraries.
if test -z "$dag_root"; then
- dag_root=/usr/local
+ dag_root=/usr/local
fi
if test -z "$dag_include_dir"; then
@@ -6169,33 +6405,33 @@ $as_echo_n "checking whether we have DAG API headers... " >&6; }
fi
if test -z "$dag_lib_dir"; then
- dag_lib_dir="$dag_root/lib"
+ dag_lib_dir="$dag_root/lib"
fi
if test -z "$dag_tools_dir"; then
- dag_tools_dir="$dag_root/tools"
+ dag_tools_dir="$dag_root/tools"
fi
if test -r $dag_include_dir/dagapi.h; then
ac_cv_lbl_dag_api=yes
fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_dag_api ($dag_include_dir)" >&5
-$as_echo "$ac_cv_lbl_dag_api ($dag_include_dir)" >&6; }
-fi
-if test $ac_cv_lbl_dag_api = yes; then
- V_INCLS="$V_INCLS -I$dag_include_dir"
+ if test "$ac_cv_lbl_dag_api" = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes ($dag_include_dir)" >&5
+$as_echo "yes ($dag_include_dir)" >&6; }
- if test $V_PCAP != dag ; then
- SSRC="pcap-dag.c"
- fi
+ V_INCLS="$V_INCLS -I$dag_include_dir"
- # See if we can find a general version string.
- # Don't need to save and restore LIBS to prevent -ldag being
- # included if there's a found-action (arg 3).
- saved_ldflags=$LDFLAGS
- LDFLAGS="-L$dag_lib_dir"
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_attach_stream in -ldag" >&5
+ if test $V_PCAP != dag ; then
+ SSRC="$SSRC pcap-dag.c"
+ fi
+
+ # See if we can find a general version string.
+ # Don't need to save and restore LIBS to prevent -ldag being
+ # included if there's a found-action (arg 3).
+ saved_ldflags=$LDFLAGS
+ LDFLAGS="-L$dag_lib_dir"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_attach_stream in -ldag" >&5
$as_echo_n "checking for dag_attach_stream in -ldag... " >&6; }
if ${ac_cv_lib_dag_dag_attach_stream+:} false; then :
$as_echo_n "(cached) " >&6
@@ -6237,7 +6473,7 @@ else
dag_streams="0"
fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_get_erf_types in -ldag" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_get_erf_types in -ldag" >&5
$as_echo_n "checking for dag_get_erf_types in -ldag... " >&6; }
if ${ac_cv_lib_dag_dag_get_erf_types+:} false; then :
$as_echo_n "(cached) " >&6
@@ -6280,7 +6516,7 @@ $as_echo "#define HAVE_DAG_GET_ERF_TYPES 1" >>confdefs.h
fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_get_stream_erf_types in -ldag" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_get_stream_erf_types in -ldag" >&5
$as_echo_n "checking for dag_get_stream_erf_types in -ldag... " >&6; }
if ${ac_cv_lib_dag_dag_get_stream_erf_types+:} false; then :
$as_echo_n "(cached) " >&6
@@ -6324,16 +6560,16 @@ $as_echo "#define HAVE_DAG_GET_STREAM_ERF_TYPES 1" >>confdefs.h
fi
- LDFLAGS=$saved_ldflags
+ LDFLAGS=$saved_ldflags
- if test "$dag_streams" = 1; then
+ if test "$dag_streams" = 1; then
$as_echo "#define HAVE_DAG_STREAMS_API 1" >>confdefs.h
- LIBS="$LIBS -ldag"
- LDFLAGS="$LDFLAGS -L$dag_lib_dir"
+ LIBS="$LIBS -ldag"
+ LDFLAGS="$LDFLAGS -L$dag_lib_dir"
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for vdag_set_device_info in -lvdag" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for vdag_set_device_info in -lvdag" >&5
$as_echo_n "checking for vdag_set_device_info in -lvdag... " >&6; }
if ${ac_cv_lib_vdag_vdag_set_device_info+:} false; then :
$as_echo_n "(cached) " >&6
@@ -6375,38 +6611,32 @@ else
ac_dag_have_vdag="0"
fi
- if test "$ac_dag_have_vdag" = 1; then
+ if test "$ac_dag_have_vdag" = 1; then
$as_echo "#define HAVE_DAG_VDAG 1" >>confdefs.h
- LIBS="$LIBS -lpthread"
+ LIBS="$LIBS -lpthread"
+ fi
fi
- fi
$as_echo "#define HAVE_DAG_API 1" >>confdefs.h
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have the DAG API" >&5
-$as_echo_n "checking whether we have the DAG API... " >&6; }
-
-if test $ac_cv_lbl_dag_api = no; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- if test "$want_dag" = yes; then
- # User wanted DAG support but we couldn't find it.
- as_fn_error $? "DAG API requested, but not found at $dag_root: use --without-dag" "$LINENO" 5
- fi
- if test "$V_PCAP" = dag; then
- # User requested "dag" capture type but the DAG API wasn't
- # found.
- as_fn_error $? "Specifying the capture type as \"dag\" requires the DAG API to be present; use the --with-dag options to specify the location. (Try \"./configure --help\" for more information.)" "$LINENO" 5
+ if test "$V_PCAP" = dag; then
+ # User requested "dag" capture type but we couldn't
+ # find the DAG API support.
+ as_fn_error $? "DAG support requested with --with-pcap=dag, but the DAG headers weren't found at $dag_include_dir: make sure the DAG support is installed, specify a different path or paths if necessary, or don't request DAG support" "$LINENO" 5
+ fi
+
+ if test "$want_dag" = yes; then
+ # User wanted DAG support but we couldn't find it.
+ as_fn_error $? "DAG support requested with --with-dag, but the DAG headers weren't found at $dag_include_dir: make sure the DAG support is installed, specify a different path or paths if necessary, or don't request DAG support" "$LINENO" 5
+ fi
fi
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
fi
@@ -6427,41 +6657,31 @@ if test "${with_septel+set}" = set; then :
else
- #
- # Use Septel API if present, otherwise don't
- #
- want_septel=ifpresent
- septel_root=./../septel
+ if test "$V_PCAP" = septel; then
+ # User requested Septel-only libpcap, so we'd better have
+ # the Septel API.
+ want_septel=yes
+ elif test "xxx_only" = yes; then
+ # User requested something-else-only pcap, so they don't
+ # want Septel support.
+ want_septel=no
+ else
+ #
+ # Use Septel API if present, otherwise don't
+ #
+ want_septel=ifpresent
+ fi
fi
-ac_cv_lbl_septel_api=no
-case "$V_PCAP" in
-linux|septel)
- #
- # We support the Septel API if we're on Linux, or if we're building
- # a Septel-only libpcap.
- #
- ;;
-*)
- #
- # If the user explicitly requested Septel, tell them it's not
- # supported.
- #
- # If they expressed no preference, don't include it.
- #
- if test $want_septel = yes; then
- as_fn_error $? "Septel support only available with 'linux' and 'septel' packet capture types" "$LINENO" 5
- elif test $want_septel = yes; then
- want_septel=no
- fi
- ;;
-esac
+ac_cv_lbl_septel_api=no
if test "$with_septel" != no; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have Septel API" >&5
-$as_echo_n "checking whether we have Septel API... " >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have Septel API headers" >&5
+$as_echo_n "checking whether we have Septel API headers... " >&6; }
+
+ # If necessary, set default paths for Septel API headers and libraries.
if test -z "$septel_root"; then
septel_root=$srcdir/../septel
fi
@@ -6469,33 +6689,40 @@ $as_echo_n "checking whether we have Septel API... " >&6; }
septel_tools_dir="$septel_root"
septel_include_dir="$septel_root/INC"
- ac_cv_lbl_septel_api=no
if test -r "$septel_include_dir/msg.h"; then
+ ac_cv_lbl_septel_api=yes
+ fi
+
+ if test "$ac_cv_lbl_septel_api" = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes ($septel_include_dir)" >&5
+$as_echo "yes ($septel_include_dir)" >&6; }
+
V_INCLS="$V_INCLS -I$septel_include_dir"
ADDLOBJS="$ADDLOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o"
ADDLARCHIVEOBJS="$ADDLARCHIVEOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o"
if test "$V_PCAP" != septel ; then
- SSRC="pcap-septel.c"
+ SSRC="$SSRC pcap-septel.c"
fi
- ac_cv_lbl_septel_api=yes
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_septel_api" >&5
-$as_echo "$ac_cv_lbl_septel_api" >&6; }
- if test $ac_cv_lbl_septel_api = no; then
- if test "$want_septel" = yes; then
- as_fn_error $? "Septel API not found under directory $septel_root; use --without-septel" "$LINENO" 5
- fi
- else
$as_echo "#define HAVE_SEPTEL_API 1" >>confdefs.h
- fi
-fi
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
-if test "$V_PCAP" = septel -a "$ac_cv_lbl_septel_api" = no; then
- as_fn_error $? "Specifying the capture type as 'septel' requires the Septel API to be present; use --with-septel=DIR" "$LINENO" 5
+ if test "$V_PCAP" = septel; then
+ # User requested "septel" capture type but
+ # we couldn't find the Septel API support.
+ as_fn_error $? "Septel support requested with --with-pcap=septel, but the Septel headers weren't found at $septel_include_dir: make sure the Septel support is installed, specify a different path or paths if necessary, or don't request Septel support" "$LINENO" 5
+ fi
+
+ if test "$want_septel" = yes; then
+ # User wanted Septel support but we couldn't find it.
+ as_fn_error $? "Septel support requested with --with-septel, but the Septel headers weren't found at $septel_include_dir: make sure the Septel support is installed, specify a different path or paths if necessary, or don't request Septel support" "$LINENO" 5
+ fi
+ fi
fi
# Check for Myricom SNF support.
@@ -6509,7 +6736,7 @@ if test "${with_snf+set}" = set; then :
want_snf=no
elif test "$withval" = yes
then
- # User wants SNF support but hasn't specific a directory.
+ # User wants SNF support but hasn't specified a directory.
want_snf=yes
else
# User wants SNF support with a specified directory.
@@ -6519,10 +6746,20 @@ if test "${with_snf+set}" = set; then :
else
- #
- # Use Sniffer API if present, otherwise don't
- #
- want_snf=ifpresent
+ if test "$V_PCAP" = snf; then
+ # User requested Sniffer-only libpcap, so we'd better have
+ # the Sniffer API.
+ want_snf=yes
+ elif test "xxx_only" = yes; then
+ # User requested something-else-only pcap, so they don't
+ # want SNF support.
+ want_snf=no
+ else
+ #
+ # Use Sniffer API if present, otherwise don't
+ #
+ want_snf=ifpresent
+ fi
fi
@@ -6549,34 +6786,13 @@ if test "${with_snf_libraries+set}" = set; then :
fi
-case "$V_PCAP" in
-bpf|linux|snf)
- #
- # We support the Sniffer API if we're on BSD, Linux, or if we're
- # building a Sniffer-only libpcap.
- #
- ;;
-*)
- #
- # If the user explicitly requested Sniffer, tell them it's not
- # supported.
- #
- # If they expressed no preference, don't include it.
- #
- if test $want_snf = yes; then
- as_fn_error $? "Myricom SNF support only available with 'bpf' 'linux' and 'snf' packet capture types" "$LINENO" 5
- elif test $want_snf = yes; then
- want_snf=no
- fi
- ;;
-esac
-
ac_cv_lbl_snf_api=no
if test "$with_snf" != no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have Myricom Sniffer API" >&5
$as_echo_n "checking whether we have Myricom Sniffer API... " >&6; }
+ # If necessary, set default paths for Sniffer headers and libraries.
if test -z "$snf_root"; then
snf_root=/opt/snf
fi
@@ -6590,16 +6806,7 @@ $as_echo_n "checking whether we have Myricom Sniffer API... " >&6; }
fi
if test -f "$snf_include_dir/snf.h"; then
- ac_cv_lbl_snf_api=yes
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_snf_api ($snf_root)" >&5
-$as_echo "$ac_cv_lbl_snf_api ($snf_root)" >&6; }
-
- if test $ac_cv_lbl_snf_api = no; then
- if test "$want_snf" = yes; then
- as_fn_error $? "SNF API headers not found under $snf_include_dir; use --without-snf" "$LINENO" 5
- fi
- else
+ # We found a header; make sure we can link with the library
saved_ldflags=$LDFLAGS
LDFLAGS="$LDFLAGS -L$snf_lib_dir"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for snf_init in -lsnf" >&5
@@ -6640,60 +6847,153 @@ fi
$as_echo "$ac_cv_lib_snf_snf_init" >&6; }
if test "x$ac_cv_lib_snf_snf_init" = xyes; then :
ac_cv_lbl_snf_api="yes"
-else
- ac_cv_lbl_snf_api="no"
fi
LDFLAGS="$saved_ldflags"
+ if test "$ac_cv_lbl_snf_api" = no; then
+ as_fn_error $? "SNF API cannot correctly be linked; check config.log" "$LINENO" 5
+ fi
+ fi
+
+ if test "$ac_cv_lbl_snf_api" = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes ($snf_root)" >&5
+$as_echo "yes ($snf_root)" >&6; }
+
+ V_INCLS="$V_INCLS -I$snf_include_dir"
+ LIBS="$LIBS -lsnf"
+ LDFLAGS="$LDFLAGS -L$snf_lib_dir"
+
+ if test "$V_PCAP" != snf ; then
+ SSRC="$SSRC pcap-snf.c"
+ fi
- if test $ac_cv_lbl_snf_api = no; then
- if test "$want_snf" = yes; then
- as_fn_error $? "SNF API cannot correctly be linked check config.log; use --without-snf" "$LINENO" 5
- fi
- else
- V_INCLS="$V_INCLS -I$snf_include_dir"
- LIBS="$LIBS -lsnf"
- LDFLAGS="$LDFLAGS -L$snf_lib_dir"
- if test "$V_PCAP" != snf ; then
- SSRC="pcap-snf.c"
- fi
$as_echo "#define HAVE_SNF_API 1" >>confdefs.h
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+ if test "$want_snf" = yes; then
+ # User requested "snf" capture type but
+ # we couldn't find the Sniffer API support.
+ as_fn_error $? "Myricom Sniffer support requested with --with-pcap=snf, but the Sniffer headers weren't found at $snf_include_dir: make sure the Sniffer support is installed, specify a different path or paths if necessary, or don't request Sniffer support" "$LINENO" 5
+ fi
+
+ if test "$want_snf" = yes; then
+ as_fn_error $? "Myricom Sniffer support requested with --with-snf, but the Sniffer headers weren't found at $snf_include_dir: make sure the Sniffer support is installed, specify a different path or paths if necessary, or don't request Sniffer support" "$LINENO" 5
fi
fi
fi
-if test "$V_PCAP" = snf -a "$ac_cv_lbl_snf_api" = no; then
- as_fn_error $? "Specifying the capture type as 'snf' requires the Myricom Sniffer API to be present; use --with-snf=DIR" "$LINENO" 5
+# Check for Riverbed TurboCap support.
+
+# Check whether --with-turbocap was given.
+if test "${with_turbocap+set}" = set; then :
+ withval=$with_turbocap;
+ if test "$withval" = no
+ then
+ # User explicitly doesn't want TurboCap
+ want_turbocap=no
+ elif test "$withval" = yes
+ then
+ # User wants TurboCap support but hasn't specified a directory.
+ want_turbocap=yes
+ else
+ # User wants TurboCap support with a specified directory.
+ want_turbocap=yes
+ turbocap_root=$withval
+ fi
+
+else
+
+ if test "xxx_only" = yes; then
+ # User requested something-else-only pcap, so they don't
+ # want TurboCap support.
+ want_turbocap=no
+ else
+ #
+ # Use TurboCap API if present, otherwise don't
+ #
+ want_turbocap=ifpresent
+ fi
+
fi
-# Check whether --with-flex was given.
-if test "${with_flex+set}" = set; then :
- withval=$with_flex;
+ac_cv_lbl_turbocap_api=no
+if test "$want_turbocap" != no; then
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether TurboCap is supported" >&5
+$as_echo_n "checking whether TurboCap is supported... " >&6; }
+
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ if test ! -z "$turbocap_root"; then
+ TURBOCAP_CFLAGS="-I$turbocap_root/include"
+ TURBOCAP_LIBS="-L$turbocap_root/lib"
+ CFLAGS="$CFLAGS $TURBOCAP_CFLAGS"
+ fi
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #include <TcApi.h>
+
+int
+main ()
+{
+
+ TC_INSTANCE a; TC_PORT b; TC_BOARD c;
+ TC_INSTANCE i;
+ (void)TcInstanceCreateByName("foo", &i);
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_lbl_turbocap_api=yes
fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+ CFLAGS="$save_CFLAGS"
+ if test $ac_cv_lbl_turbocap_api = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ SSRC="$SSRC pcap-tc.c"
+ V_INCLS="$V_INCLS $TURBOCAP_CFLAGS"
+ LIBS="$LIBS $TURBOCAP_LIBS -lTcApi -lpthread -lstdc++"
+
+
+$as_echo "#define HAVE_TC_API 1" >>confdefs.h
+
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
-# Check whether --with-bison was given.
-if test "${with_bison+set}" = set; then :
- withval=$with_bison;
+ if test "$want_turbocap" = yes; then
+ # User wanted Turbo support but we couldn't find it.
+ as_fn_error $? "TurboCap support requested with --with-turbocap, but the TurboCap headers weren't found: make sure the TurboCap support is installed or don't request TurboCap support" "$LINENO" 5
+ fi
+ fi
fi
- if test "$with_flex" = no ; then
- V_LEX=lex
- else
- for ac_prog in flex
+#
+# Look for {f}lex.
+#
+for ac_prog in flex lex
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_V_LEX+:} false; then :
+if ${ac_cv_prog_LEX+:} false; then :
$as_echo_n "(cached) " >&6
else
- if test -n "$V_LEX"; then
- ac_cv_prog_V_LEX="$V_LEX" # Let the user override the test.
+ if test -n "$LEX"; then
+ ac_cv_prog_LEX="$LEX" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
@@ -6702,7 +7002,7 @@ do
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_V_LEX="$ac_prog"
+ ac_cv_prog_LEX="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
@@ -6712,58 +7012,176 @@ IFS=$as_save_IFS
fi
fi
-V_LEX=$ac_cv_prog_V_LEX
-if test -n "$V_LEX"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $V_LEX" >&5
-$as_echo "$V_LEX" >&6; }
+LEX=$ac_cv_prog_LEX
+if test -n "$LEX"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LEX" >&5
+$as_echo "$LEX" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
- test -n "$V_LEX" && break
+ test -n "$LEX" && break
done
-test -n "$V_LEX" || V_LEX="lex"
+test -n "$LEX" || LEX=":"
+
+if test "x$LEX" != "x:"; then
+ cat >conftest.l <<_ACEOF
+%%
+a { ECHO; }
+b { REJECT; }
+c { yymore (); }
+d { yyless (1); }
+e { /* IRIX 6.5 flex 2.5.4 underquotes its yyless argument. */
+ yyless ((input () != 0)); }
+f { unput (yytext[0]); }
+. { BEGIN INITIAL; }
+%%
+#ifdef YYTEXT_POINTER
+extern char *yytext;
+#endif
+int
+main (void)
+{
+ return ! yylex () + ! yywrap ();
+}
+_ACEOF
+{ { ac_try="$LEX conftest.l"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$LEX conftest.l") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking lex output file root" >&5
+$as_echo_n "checking lex output file root... " >&6; }
+if ${ac_cv_prog_lex_root+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
- fi
- if test "$V_LEX" = flex ; then
- # The -V flag was added in 2.4
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for flex 2.4 or higher" >&5
-$as_echo_n "checking for flex 2.4 or higher... " >&6; }
- if ${ac_cv_lbl_flex_v24+:} false; then :
+if test -f lex.yy.c; then
+ ac_cv_prog_lex_root=lex.yy
+elif test -f lexyy.c; then
+ ac_cv_prog_lex_root=lexyy
+else
+ as_fn_error $? "cannot find output from $LEX; giving up" "$LINENO" 5
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_root" >&5
+$as_echo "$ac_cv_prog_lex_root" >&6; }
+LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root
+
+if test -z "${LEXLIB+set}"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking lex library" >&5
+$as_echo_n "checking lex library... " >&6; }
+if ${ac_cv_lib_lex+:} false; then :
$as_echo_n "(cached) " >&6
else
- if flex -V >/dev/null 2>&1; then
- ac_cv_lbl_flex_v24=yes
- else
- ac_cv_lbl_flex_v24=no
- fi
+
+ ac_save_LIBS=$LIBS
+ ac_cv_lib_lex='none needed'
+ for ac_lib in '' -lfl -ll; do
+ LIBS="$ac_lib $ac_save_LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+`cat $LEX_OUTPUT_ROOT.c`
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_lex=$ac_lib
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ test "$ac_cv_lib_lex" != 'none needed' && break
+ done
+ LIBS=$ac_save_LIBS
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lex" >&5
+$as_echo "$ac_cv_lib_lex" >&6; }
+ test "$ac_cv_lib_lex" != 'none needed' && LEXLIB=$ac_cv_lib_lex
fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_flex_v24" >&5
-$as_echo "$ac_cv_lbl_flex_v24" >&6; }
- if test $ac_cv_lbl_flex_v24 = no ; then
- s="2.4 or higher required"
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: ignoring obsolete flex executable ($s)" >&5
-$as_echo "$as_me: WARNING: ignoring obsolete flex executable ($s)" >&2;}
- V_LEX=lex
- fi
- fi
- if test "$with_bison" = no ; then
- V_YACC=yacc
- else
- for ac_prog in bison
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether yytext is a pointer" >&5
+$as_echo_n "checking whether yytext is a pointer... " >&6; }
+if ${ac_cv_prog_lex_yytext_pointer+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # POSIX says lex can declare yytext either as a pointer or an array; the
+# default is implementation-dependent. Figure out which it is, since
+# not all implementations provide the %pointer and %array declarations.
+ac_cv_prog_lex_yytext_pointer=no
+ac_save_LIBS=$LIBS
+LIBS="$LEXLIB $ac_save_LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #define YYTEXT_POINTER 1
+`cat $LEX_OUTPUT_ROOT.c`
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_prog_lex_yytext_pointer=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_save_LIBS
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_yytext_pointer" >&5
+$as_echo "$ac_cv_prog_lex_yytext_pointer" >&6; }
+if test $ac_cv_prog_lex_yytext_pointer = yes; then
+
+$as_echo "#define YYTEXT_POINTER 1" >>confdefs.h
+
+fi
+rm -f conftest.l $LEX_OUTPUT_ROOT.c
+
+fi
+if test "$LEX" = ":"; then
+ as_fn_error $? "Neither flex nor lex was found." "$LINENO" 5
+fi
+
+#
+# Make sure {f}lex supports the -P, --header-file, and --nounput flags
+# and supports processing our scanner.l.
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for capable lex" >&5
+$as_echo_n "checking for capable lex... " >&6; }
+if ${tcpdump_cv_capable_lex+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if $LEX -P pcap_ --header-file=/dev/null --nounput -t $srcdir/scanner.l > /dev/null 2>&1; then
+ tcpdump_cv_capable_lex=yes
+ else
+ tcpdump_cv_capable_lex=insufficient
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcpdump_cv_capable_lex" >&5
+$as_echo "$tcpdump_cv_capable_lex" >&6; }
+if test $tcpdump_cv_capable_lex = insufficient ; then
+ as_fn_error $? "$LEX is insufficient to compile libpcap.
+ libpcap requires Flex 2.5.31 or later, or a compatible version of lex." "$LINENO" 5
+fi
+
+#
+# Look for yacc/bison/byacc.
+#
+for ac_prog in 'bison -y' byacc
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_V_YACC+:} false; then :
+if ${ac_cv_prog_YACC+:} false; then :
$as_echo_n "(cached) " >&6
else
- if test -n "$V_YACC"; then
- ac_cv_prog_V_YACC="$V_YACC" # Let the user override the test.
+ if test -n "$YACC"; then
+ ac_cv_prog_YACC="$YACC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
@@ -6772,7 +7190,7 @@ do
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_V_YACC="$ac_prog"
+ ac_cv_prog_YACC="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
@@ -6782,61 +7200,42 @@ IFS=$as_save_IFS
fi
fi
-V_YACC=$ac_cv_prog_V_YACC
-if test -n "$V_YACC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $V_YACC" >&5
-$as_echo "$V_YACC" >&6; }
+YACC=$ac_cv_prog_YACC
+if test -n "$YACC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YACC" >&5
+$as_echo "$YACC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
- test -n "$V_YACC" && break
+ test -n "$YACC" && break
done
-test -n "$V_YACC" || V_YACC="yacc"
+test -n "$YACC" || YACC="yacc"
- fi
- if test "$V_YACC" = bison ; then
- V_YACC="$V_YACC -y"
- fi
- if test "$V_LEX" != lex -a "$V_YACC" = yacc -o "$V_LEX" = lex -a "$V_YACC" != yacc ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: don't have both flex and bison; reverting to lex/yacc" >&5
-$as_echo "$as_me: WARNING: don't have both flex and bison; reverting to lex/yacc" >&2;}
- V_LEX=lex
- V_YACC=yacc
- fi
- if test "$V_LEX" = flex -a -n "pcap_" ; then
- V_LEX="$V_LEX -Ppcap_"
- V_YACC="$V_YACC -p pcap_"
- else
-
-$as_echo "#define NEED_YYPARSE_WRAPPER 1" >>confdefs.h
- fi
-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.
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for capable lex" >&5
-$as_echo_n "checking for capable lex... " >&6; }
-if ${tcpdump_cv_capable_lex+:} false; then :
+#
+# Make sure it supports the -p flag and supports processing our
+# grammar.y.
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for capable yacc/bison" >&5
+$as_echo_n "checking for capable yacc/bison... " >&6; }
+if ${tcpdump_cv_capable_yacc+:} false; then :
$as_echo_n "(cached) " >&6
else
- if lex -t scanner.l > /dev/null 2>&1; then
- tcpdump_cv_capable_lex=yes
- else
- tcpdump_cv_capable_lex=insufficient
- fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcpdump_cv_capable_lex" >&5
-$as_echo "$tcpdump_cv_capable_lex" >&6; }
- if test $tcpdump_cv_capable_lex = insufficient ; then
- as_fn_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 ." "$LINENO" 5
+ if $YACC -p pcap_ -o /dev/null $srcdir/grammar.y >/dev/null 2>&1; then
+ tcpdump_cv_capable_yacc=yes
+ else
+ tcpdump_cv_capable_yacc=insufficient
fi
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcpdump_cv_capable_yacc" >&5
+$as_echo "$tcpdump_cv_capable_yacc" >&6; }
+if test $tcpdump_cv_capable_yacc = insufficient ; then
+ as_fn_error $? "$YACC is insufficient to compile libpcap.
+ libpcap requires Bison, Berkeley YACC, or another YACC compatible with them." "$LINENO" 5
+fi
#
# Assume, by default, no support for shared libraries and V7/BSD convention
@@ -7367,7 +7766,18 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wall option" >&5
$as_echo_n "checking whether the compiler supports the -Wall option... " >&6; }
save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wall"
+ if expr "x-Wall" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wall"
+ elif expr "x-Wall" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wall"
+ elif expr "x-Wall" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wall"
+ else
+ CFLAGS="$CFLAGS -Wall"
+ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -7396,10 +7806,64 @@ fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wsign-compare option" >&5
+$as_echo_n "checking whether the compiler supports the -Wsign-compare option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-Wsign-compare" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wsign-compare"
+ elif expr "x-Wsign-compare" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wsign-compare"
+ elif expr "x-Wsign-compare" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wsign-compare"
+ else
+ CFLAGS="$CFLAGS -Wsign-compare"
+ fi
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wsign-compare"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-prototypes option" >&5
$as_echo_n "checking whether the compiler supports the -Wmissing-prototypes option... " >&6; }
save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wmissing-prototypes"
+ if expr "x-Wmissing-prototypes" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wmissing-prototypes"
+ elif expr "x-Wmissing-prototypes" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wmissing-prototypes"
+ elif expr "x-Wmissing-prototypes" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wmissing-prototypes"
+ else
+ CFLAGS="$CFLAGS -Wmissing-prototypes"
+ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -7431,7 +7895,18 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wstrict-prototypes option" >&5
$as_echo_n "checking whether the compiler supports the -Wstrict-prototypes option... " >&6; }
save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wstrict-prototypes"
+ if expr "x-Wstrict-prototypes" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wstrict-prototypes"
+ elif expr "x-Wstrict-prototypes" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wstrict-prototypes"
+ elif expr "x-Wstrict-prototypes" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wstrict-prototypes"
+ else
+ CFLAGS="$CFLAGS -Wstrict-prototypes"
+ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -7459,6 +7934,135 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wshadow option" >&5
+$as_echo_n "checking whether the compiler supports the -Wshadow option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-Wshadow" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wshadow"
+ elif expr "x-Wshadow" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wshadow"
+ elif expr "x-Wshadow" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wshadow"
+ else
+ CFLAGS="$CFLAGS -Wshadow"
+ fi
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wshadow"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wdeclaration-after-statement option" >&5
+$as_echo_n "checking whether the compiler supports the -Wdeclaration-after-statement option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-Wdeclaration-after-statement" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wdeclaration-after-statement"
+ elif expr "x-Wdeclaration-after-statement" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wdeclaration-after-statement"
+ elif expr "x-Wdeclaration-after-statement" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wdeclaration-after-statement"
+ else
+ CFLAGS="$CFLAGS -Wdeclaration-after-statement"
+ fi
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wdeclaration-after-statement"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wused-but-marked-unused option" >&5
+$as_echo_n "checking whether the compiler supports the -Wused-but-marked-unused option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-Wused-but-marked-unused" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wused-but-marked-unused"
+ elif expr "x-Wused-but-marked-unused" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused"
+ elif expr "x-Wused-but-marked-unused" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused"
+ else
+ CFLAGS="$CFLAGS -Wused-but-marked-unused"
+ fi
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wused-but-marked-unused"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports generating dependencies" >&5
@@ -7778,16 +8382,11 @@ $as_echo "#define LBL_ALIGN 1" >>confdefs.h
fi
-#
-# Makefile.in includes rules to generate version.h, so we assume
-# that it will be generated if autoconf is used.
-#
+rm -f net
+ln -s ${srcdir}/bpf/net net
-$as_echo "#define HAVE_VERSION_H 1" >>confdefs.h
-rm -f net
-ln -s ${srcdir}/bpf/net net
@@ -7804,13 +8403,25 @@ ln -s ${srcdir}/bpf/net net
+# Check whether --enable-usb was given.
+if test "${enable_usb+set}" = set; then :
+ enableval=$enable_usb;
+else
+ enable_usb=yes
+fi
+if test "xxx_only" = yes; then
+ # User requested something-else-only pcap, so they don't
+ # want USB support.
+ enable_usb=no
+fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for USB sniffing support" >&5
+if test "x$enable_usb" != "xno" ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for USB sniffing support" >&5
$as_echo_n "checking for USB sniffing support... " >&6; }
-case "$host_os" in
-linux*)
+ case "$host_os" in
+ linux*)
$as_echo "#define PCAP_SUPPORT_USB 1" >>confdefs.h
@@ -7923,31 +8534,42 @@ $as_echo "#define HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE 1" >>confdefs.h
fi
fi
;;
-*)
+ freebsd*)
+ #
+ # This just uses BPF in FreeBSD 8.4 and later; we don't need
+ # to check for anything special for capturing.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, in FreeBSD 8.4 and later" >&5
+$as_echo "yes, in FreeBSD 8.4 and later" >&6; }
+ ;;
+
+ *)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
;;
esac
+fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the platform could support netfilter sniffing" >&5
+if test "xxx_only" != yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the platform could support netfilter sniffing" >&5
$as_echo_n "checking whether the platform could support netfilter sniffing... " >&6; }
-case "$host_os" in
-linux*)
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ case "$host_os" in
+ linux*)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- #
- # Life's too short to deal with trying to get this to compile
- # if you don't get the right types defined with
- # __KERNEL_STRICT_NAMES getting defined by some other include.
- #
- # Check whether the includes Just Work. If not, don't turn on
- # netfilter support.
- #
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can compile the netfilter support" >&5
+ #
+ # Life's too short to deal with trying to get this to compile
+ # if you don't get the right types defined with
+ # __KERNEL_STRICT_NAMES getting defined by some other include.
+ #
+ # Check whether the includes Just Work. If not, don't turn on
+ # netfilter support.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can compile the netfilter support" >&5
$as_echo_n "checking whether we can compile the netfilter support... " >&6; }
- if ${ac_cv_netfilter_can_compile+:} false; then :
+ if ${ac_cv_netfilter_can_compile+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -7979,20 +8601,21 @@ fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_netfilter_can_compile" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_netfilter_can_compile" >&5
$as_echo "$ac_cv_netfilter_can_compile" >&6; }
- if test $ac_cv_netfilter_can_compile = yes ; then
+ if test $ac_cv_netfilter_can_compile = yes ; then
$as_echo "#define PCAP_SUPPORT_NETFILTER 1" >>confdefs.h
- NETFILTER_SRC=pcap-netfilter-linux.c
- fi
- ;;
-*)
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ NETFILTER_SRC=pcap-netfilter-linux.c
+ fi
+ ;;
+ *)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- ;;
-esac
+ ;;
+ esac
+fi
@@ -8004,6 +8627,12 @@ else
fi
+if test "xxx_only" = yes; then
+ # User requested something-else-only pcap, so they don't
+ # want Bluetooth support.
+ enable_bluetooth=no
+fi
+
if test "x$enable_bluetooth" != "xno" ; then
case "$host_os" in
linux*)
@@ -8125,151 +8754,6 @@ $as_echo "$as_me: no Bluetooth sniffing support implemented for $host_os" >&6;}
fi
-# Check whether --enable-canusb was given.
-if test "${enable_canusb+set}" = set; then :
- enableval=$enable_canusb;
-else
- enable_canusb=ifsupportavailable
-fi
-
-
-if test "x$enable_canusb" != "xno" ; then
- case "$host_os" in
- linux*)
- ac_fn_c_check_header_mongrel "$LINENO" "libusb-1.0/libusb.h" "ac_cv_header_libusb_1_0_libusb_h" "$ac_includes_default"
-if test "x$ac_cv_header_libusb_1_0_libusb_h" = xyes; then :
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb_init in -lusb-1.0" >&5
-$as_echo_n "checking for libusb_init in -lusb-1.0... " >&6; }
-if ${ac_cv_lib_usb_1_0_libusb_init+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lusb-1.0 $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char libusb_init ();
-int
-main ()
-{
-return libusb_init ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_usb_1_0_libusb_init=yes
-else
- ac_cv_lib_usb_1_0_libusb_init=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usb_1_0_libusb_init" >&5
-$as_echo "$ac_cv_lib_usb_1_0_libusb_init" >&6; }
-if test "x$ac_cv_lib_usb_1_0_libusb_init" = xyes; then :
-
-
-$as_echo "#define PCAP_SUPPORT_CANUSB 1" >>confdefs.h
-
- CANUSB_SRC=pcap-canusb-linux.c
- LIBS="-lusb-1.0 -lpthread $LIBS"
- ac_lbl_has_libusb=yes
-
-else
- ac_lbl_has_libusb=no
-
-fi
-
-
-else
- ac_lbl_has_libusb=no
-
-fi
-
-
- if test "x$ac_lbl_has_libusb" = "xyes" ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: canusb sniffing is supported" >&5
-$as_echo "$as_me: canusb sniffing is supported" >&6;}
- else
- if test "x$enable_canusb" = "xyes" ; then
- as_fn_error $? "canusb sniffing is not supported; install libusb1.0 lib devel to enable it" "$LINENO" 5
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: canusb sniffing is not supported; install libusb1.0 lib devel to enable it" >&5
-$as_echo "$as_me: canusb sniffing is not supported; install libusb1.0 lib devel to enable it" >&6;}
- fi
- fi
- ;;
- *)
- if test "x$enable_canusb" = "xyes" ; then
- as_fn_error $? "no canusb support implemented for $host_os" "$LINENO" 5
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: no canusb support implemented for $host_os" >&5
-$as_echo "$as_me: no canusb support implemented for $host_os" >&6;}
- fi
- ;;
- esac
-
-
-fi
-
-# Check whether --enable-can was given.
-if test "${enable_can+set}" = set; then :
- enableval=$enable_can;
-else
- enable_can=ifsupportavailable
-fi
-
-
-if test "x$enable_can" != "xno" ; then
- case "$host_os" in
- linux*)
- ac_fn_c_check_header_compile "$LINENO" "linux/can.h" "ac_cv_header_linux_can_h" "#include <sys/socket.h>
-
-"
-if test "x$ac_cv_header_linux_can_h" = xyes; then :
-
-
-$as_echo "#define PCAP_SUPPORT_CAN 1" >>confdefs.h
-
- CAN_SRC=pcap-can-linux.c
- { $as_echo "$as_me:${as_lineno-$LINENO}: CAN sniffing is supported" >&5
-$as_echo "$as_me: CAN sniffing is supported" >&6;}
-
-else
-
- if test "x$enable_can" = "xyes" ; then
- as_fn_error $? "CAN sniffing is not supported" "$LINENO" 5
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: CAN sniffing is not supported" >&5
-$as_echo "$as_me: CAN sniffing is not supported" >&6;}
- fi
-
-fi
-
-
- ;;
- *)
- if test "x$enable_can" = "xyes" ; then
- as_fn_error $? "no CAN sniffing support implemented for $host_os" "$LINENO" 5
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: no CAN sniffing support implemented for $host_os" >&5
-$as_echo "$as_me: no CAN sniffing support implemented for $host_os" >&6;}
- fi
- ;;
- esac
-
-
-fi
-
# Check whether --enable-dbus was given.
if test "${enable_dbus+set}" = set; then :
enableval=$enable_dbus;
@@ -8278,28 +8762,46 @@ else
fi
+if test "xxx_only" = yes; then
+ # User requested something-else-only pcap, so they don't
+ # want D-Bus support.
+ enable_dbus=no
+fi
+
if test "x$enable_dbus" != "xno"; then
if test "x$enable_dbus" = "xyes"; then
case "$host_os" in
darwin*)
#
+ # We don't support D-Bus sniffing on OS X; see
+ #
# https://bugs.freedesktop.org/show_bug.cgi?id=74029
#
+ # The user requested it, so fail.
+ #
as_fn_error $? "Due to freedesktop.org bug 74029, D-Bus capture support is not available on OS X" "$LINENO" 5
- ;;
esac
else
case "$host_os" in
darwin*)
#
+ # We don't support D-Bus sniffing on OS X; see
+ #
# https://bugs.freedesktop.org/show_bug.cgi?id=74029
#
+ # The user dind't explicitly request it, so just
+ # silently refuse to enable it.
+ #
+ enable_dbus="no"
;;
+ esac
+ fi
+fi
- *)
- # Extract the first word of "pkg-config", so it can be a program name with args.
+if test "x$enable_dbus" != "xno"; then
+ # Extract the first word of "pkg-config", so it can be a program name with args.
set dummy pkg-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
@@ -8337,28 +8839,28 @@ $as_echo "no" >&6; }
fi
- if test "x$PKGCONFIG" != "xno"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for D-Bus" >&5
+ if test "x$PKGCONFIG" != "xno"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for D-Bus" >&5
$as_echo_n "checking for D-Bus... " >&6; }
- if "$PKGCONFIG" dbus-1; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ if "$PKGCONFIG" dbus-1; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
- DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
- save_CFLAGS="$CFLAGS"
- save_LIBS="$LIBS"
- CFLAGS="$CFLAGS $DBUS_CFLAGS"
- LIBS="$LIBS $DBUS_LIBS"
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the D-Bus library defines dbus_connection_read_write" >&5
+ DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
+ DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ CFLAGS="$CFLAGS $DBUS_CFLAGS"
+ LIBS="$LIBS $DBUS_LIBS"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the D-Bus library defines dbus_connection_read_write" >&5
$as_echo_n "checking whether the D-Bus library defines dbus_connection_read_write... " >&6; }
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <string.h>
- #include <time.h>
- #include <sys/time.h>
+ #include <time.h>
+ #include <sys/time.h>
- #include <dbus/dbus.h>
+ #include <dbus/dbus.h>
int
main ()
{
@@ -8369,37 +8871,34 @@ return dbus_connection_read_write(NULL, 0);
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define PCAP_SUPPORT_DBUS 1" >>confdefs.h
- DBUS_SRC=pcap-dbus.c
- V_INCLS="$V_INCLS $DBUS_CFLAGS"
+ DBUS_SRC=pcap-dbus.c
+ V_INCLS="$V_INCLS $DBUS_CFLAGS"
else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- if test "x$enable_dbus" = "xyes"; then
- as_fn_error $? "--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()" "$LINENO" 5
- fi
- LIBS="$save_LIBS"
+ if test "x$enable_dbus" = "xyes"; then
+ as_fn_error $? "--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()" "$LINENO" 5
+ fi
+ LIBS="$save_LIBS"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- CFLAGS="$save_CFLAGS"
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ CFLAGS="$save_CFLAGS"
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- if test "x$enable_dbus" = "xyes"; then
- as_fn_error $? "--enable-dbus was given, but the dbus-1 package is not installed" "$LINENO" 5
- fi
- fi
+ if test "x$enable_dbus" = "xyes"; then
+ as_fn_error $? "--enable-dbus was given, but the dbus-1 package is not installed" "$LINENO" 5
fi
- ;;
- esac
+ fi
fi
@@ -8426,6 +8925,21 @@ $as_echo "$as_me: no hardware timestamp support implemented for $host_os" >&6;}
;;
esac
+# Check whether --enable-packet-ring was given.
+if test "${enable_packet_ring+set}" = set; then :
+ enableval=$enable_packet_ring;
+else
+ enable_packet_ring=yes
+fi
+
+
+if test "x$enable_packet_ring" != "xno" ; then
+
+$as_echo "#define PCAP_SUPPORT_PACKET_RING 1" >>confdefs.h
+
+
+fi
+
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
# incompatible versions:
diff --git a/configure.in b/configure.ac
index 4530aed3a7d0..da2f940da963 100755..100644
--- a/configure.in
+++ b/configure.ac
@@ -104,7 +104,7 @@ dnl in "aclocal.m4" uses it, so we would still have to test for it
dnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
dnl
-AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h limits.h paths.h)
+AC_CHECK_HEADERS(sys/ioccom.h sys/select.h sys/sockio.h limits.h)
AC_CHECK_HEADERS(linux/types.h)
AC_CHECK_HEADERS(linux/if_packet.h netpacket/packet.h netpacket/if_packet.h)
AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
@@ -148,6 +148,16 @@ struct rtentry;
#include <net/if.h>])
fi
+case "$host_os" in
+linux*|uclinux*)
+ AC_CHECK_HEADERS(linux/sockios.h linux/if_bonding.h,,,
+ [
+#include <sys/socket.h>
+#include <linux/if.h>
+ ])
+ ;;
+esac
+
AC_LBL_FIXINCLUDES
AC_CHECK_FUNCS(strerror strlcpy)
@@ -159,6 +169,13 @@ if test $needsnprintf = yes; then
AC_LIBOBJ([snprintf])
fi
+needstrtok_r=no
+AC_CHECK_FUNCS(strtok_r,,
+ [needstrtok_r=yes])
+if test $needstrtok_r = yes; then
+ AC_LIBOBJ([strtok_r])
+fi
+
#
# Do this before checking for ether_hostton(), as it's a
# "gethostbyname() -ish function".
@@ -272,6 +289,13 @@ fi
AC_MSG_RESULT(${enable_protochain})
#
+# valgrindtest directly uses the native capture mechanism, but
+# only tests with BPF and PF_PACKET sockets; only enable it if
+# we have BPF or PF_PACKET sockets.
+#
+VALGRINDTEST=
+
+#
# SITA support is mutually exclusive with native capture support;
# "--with-sita" selects SITA support.
#
@@ -282,7 +306,6 @@ AC_HELP_STRING([--with-sita],[include SITA support]),
AC_DEFINE(SITA,1,[include ACN support])
AC_MSG_NOTICE(Enabling SITA ACN support)
V_PCAP=sita
- V_FINDALLDEVS=sita
fi
],
[
@@ -308,8 +331,18 @@ elif test -r /dev/bpf -o -h /dev/bpf ; then
#
V_PCAP=bpf
AC_DEFINE(HAVE_CLONING_BPF,1,[define if you have a cloning BPF device])
+
+ #
+ # We have BPF, so build valgrindtest with "make test".
+ #
+ VALGRINDTEST=valgrindtest
elif test -r /dev/bpf0 ; then
V_PCAP=bpf
+
+ #
+ # We have BPF, so build valgrindtest with "make test".
+ #
+ VALGRINDTEST=valgrindtest
elif test -r /usr/include/net/pfilt.h ; then
V_PCAP=pf
elif test -r /dev/enet ; then
@@ -320,6 +353,12 @@ elif test -r /usr/include/sys/net/nit.h ; then
V_PCAP=nit
elif test -r /usr/include/linux/socket.h ; then
V_PCAP=linux
+
+ #
+ # XXX - this won't work with older kernels that have SOCK_PACKET
+ # sockets but not PF_PACKET sockets.
+ #
+ VALGRINDTEST=valgrindtest
elif test -r /usr/include/net/raw.h ; then
V_PCAP=snoop
elif test -r /usr/include/odmi.h ; then
@@ -331,6 +370,11 @@ elif test -r /usr/include/odmi.h ; then
V_PCAP=bpf
elif test -c /dev/bpf0 ; then # check again in case not readable
V_PCAP=bpf
+
+ #
+ # We have BPF, so build valgrindtest with "make test".
+ #
+ VALGRINDTEST=valgrindtest
elif test -r /usr/include/sys/dlpi.h ; then
V_PCAP=dlpi
elif test -c /dev/enet ; then # check again in case not readable
@@ -341,6 +385,7 @@ else
V_PCAP=null
fi
AC_MSG_RESULT($V_PCAP)
+AC_SUBST(VALGRINDTEST)
#
# Do capture-mechanism-dependent tests.
@@ -360,11 +405,11 @@ dlpi)
#
# Checks to see if Solaris has the public libdlpi(3LIB) library.
# Note: The existence of /usr/include/libdlpi.h does not mean it is the
- # public libdlpi(3LIB) version. Before libdlpi was made public, a
- # private version also existed, which did not have the same APIs.
+ # public libdlpi(3LIB) version. Before libdlpi was made public, a
+ # private version also existed, which did not have the same APIs.
# Due to a gcc bug, the default search path for 32-bit libraries does
# not include /lib, we add it explicitly here.
- # [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485].
+ # [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485].
# Also, due to the bug above applications that link to libpcap with
# libdlpi will have to add "-L/lib" option to "configure".
#
@@ -446,6 +491,13 @@ linux)
if test x$with_libnl != xno ; then
have_any_nl="no"
+ incdir=-I/usr/include/libnl3
+ libnldir=
+ if test x$withval != x ; then
+ libnldir=-L${withval}/lib/.libs
+ incdir=-I${withval}/include
+ fi
+
#
# Try libnl 3.x first.
#
@@ -454,14 +506,14 @@ linux)
#
# Yes, we have libnl 3.x.
#
- LIBS="-lnl-genl-3 -lnl-3 $LIBS"
+ LIBS="${libnldir} -lnl-genl-3 -lnl-3 $LIBS"
AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
AC_DEFINE(HAVE_LIBNL_3_x,1,[if libnl exists and is version 3.x])
AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
- V_INCLS="$V_INCLS -I/usr/include/libnl3"
+ V_INCLS="$V_INCLS ${incdir}"
have_any_nl="yes"
- ])
+ ],[], ${incdir} ${libnldir} -lnl-genl-3 -lnl-3 )
if test x$have_any_nl = xno ; then
#
@@ -472,7 +524,7 @@ linux)
#
# Yes, we have libnl 2.x.
#
- LIBS="-lnl-genl -lnl $LIBS"
+ LIBS="${libnldir} -lnl-genl -lnl $LIBS"
AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
AC_DEFINE(HAVE_LIBNL_2_x,1,[if libnl exists and is version 2.x])
AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
@@ -490,7 +542,7 @@ linux)
#
# Yes.
#
- LIBS="-lnl $LIBS"
+ LIBS="${libnldir} -lnl $LIBS"
AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
have_any_nl="yes"
])
@@ -528,7 +580,7 @@ bpf)
#include <net/if.h>
#include <net/bpf.h>],
[return (BIOCROTZBUF + BPF_BUFMODE_ZBUF);],
- [
+ [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_ZEROCOPY_BPF, 1,
[define if the system supports zerocopy BPF])
@@ -550,15 +602,30 @@ bpf)
;;
dag)
+ #
+ # --with-pcap=dag is the only way to get here, and it means
+ # "DAG support but nothing else"
+ #
V_DEFS="$V_DEFS -DDAG_ONLY"
+ xxx_only=yes
;;
septel)
+ #
+ # --with-pcap=septel is the only way to get here, and it means
+ # "Septel support but nothing else"
+ #
V_DEFS="$V_DEFS -DSEPTEL_ONLY"
+ xxx_only=yes
;;
snf)
+ #
+ # --with-pcap=snf is the only way to get here, and it means
+ # "SNF support but nothing else"
+ #
V_DEFS="$V_DEFS -DSNF_ONLY"
+ xxx_only=yes
;;
null)
@@ -572,14 +639,8 @@ dnl Now figure out how we get a list of interfaces and addresses,
dnl if we support capturing. Don't bother if we don't support
dnl capturing.
dnl
-if test "$V_PCAP" = null
+if test "$V_PCAP" != null
then
- #
- # We can't capture, so we can't open any capture
- # devices, so we won't return any interfaces.
- #
- V_FINDALLDEVS=null
-else
AC_CHECK_FUNC(getifaddrs,[
#
# We have "getifaddrs()"; make sure we have <ifaddrs.h>
@@ -590,7 +651,7 @@ else
# We have the header, so we use "getifaddrs()" to
# get the list of interfaces.
#
- V_FINDALLDEVS=getad
+ V_FINDALLDEVS=fad-getad.c
],[
#
# We don't have the header - give up.
@@ -633,9 +694,9 @@ else
ac_cv_lbl_have_siocglifconf=no))
AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
if test $ac_cv_lbl_have_siocglifconf = yes ; then
- V_FINDALLDEVS=glifc
+ V_FINDALLDEVS=fad-glifc.c
else
- V_FINDALLDEVS=gifc
+ V_FINDALLDEVS=fad-gifc.c
fi
;;
@@ -646,7 +707,7 @@ else
# another mechanism, and we should be using that
# instead.)
#
- V_FINDALLDEVS=gifc
+ V_FINDALLDEVS=fad-gifc.c
;;
esac])
fi
@@ -699,7 +760,7 @@ AC_MSG_RESULT(${enable_yydebug-no})
# Check for Endace DAG card support.
AC_ARG_WITH([dag],
-AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support @<:@"yes", "no" or DIR; default="yes" on BSD and Linux if present@:>@]),
+AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
[
if test "$withval" = no
then
@@ -715,14 +776,24 @@ AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support @<:@"yes", "
dag_root=$withval
fi
],[
- #
- # Use DAG API if present, otherwise don't
- #
- want_dag=ifpresent
+ if test "$V_PCAP" = dag; then
+ # User requested DAG-only libpcap, so we'd better have
+ # the DAG API.
+ want_dag=yes
+ elif test "xxx_only" = yes; then
+ # User requested something-else-only pcap, so they don't
+ # want DAG support.
+ want_dag=no
+ else
+ #
+ # Use DAG API if present, otherwise don't
+ #
+ want_dag=ifpresent
+ fi
])
AC_ARG_WITH([dag-includes],
-AC_HELP_STRING([--with-dag-includes=DIR],[Endace DAG include directory]),
+AC_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not DIR/include]),
[
# User wants DAG support and has specified a header directory, so use the provided value.
want_dag=yes
@@ -730,35 +801,13 @@ AC_HELP_STRING([--with-dag-includes=DIR],[Endace DAG include directory]),
],[])
AC_ARG_WITH([dag-libraries],
-AC_HELP_STRING([--with-dag-libraries=DIR],[Endace DAG library directory]),
+AC_HELP_STRING([--with-dag-libraries=LDIR],[Endace DAG library directory, if not DIR/lib]),
[
# User wants DAG support and has specified a library directory, so use the provided value.
want_dag=yes
dag_lib_dir=$withval
],[])
-case "$V_PCAP" in
-linux|bpf|dag)
- #
- # We support the DAG API if we're on Linux or BSD, or if we're
- # building a DAG-only libpcap.
- #
- ;;
-*)
- #
- # If the user explicitly requested DAG, tell them it's not
- # supported.
- #
- # If they expressed no preference, don't include it.
- #
- if test $want_dag = yes; then
- AC_MSG_ERROR([DAG support is only available with 'linux' 'bpf' and 'dag' packet capture types])
- elif test $want_dag = yes; then
- want_dag=no
- fi
- ;;
-esac
-
ac_cv_lbl_dag_api=no
if test "$want_dag" != no; then
@@ -766,7 +815,7 @@ if test "$want_dag" != no; then
# If necessary, set default paths for DAG API headers and libraries.
if test -z "$dag_root"; then
- dag_root=/usr/local
+ dag_root=/usr/local
fi
if test -z "$dag_include_dir"; then
@@ -774,74 +823,70 @@ if test "$want_dag" != no; then
fi
if test -z "$dag_lib_dir"; then
- dag_lib_dir="$dag_root/lib"
+ dag_lib_dir="$dag_root/lib"
fi
-
+
if test -z "$dag_tools_dir"; then
- dag_tools_dir="$dag_root/tools"
+ dag_tools_dir="$dag_root/tools"
fi
if test -r $dag_include_dir/dagapi.h; then
ac_cv_lbl_dag_api=yes
fi
- AC_MSG_RESULT([$ac_cv_lbl_dag_api ($dag_include_dir)])
-fi
-if test $ac_cv_lbl_dag_api = yes; then
- V_INCLS="$V_INCLS -I$dag_include_dir"
+ if test "$ac_cv_lbl_dag_api" = yes; then
+ AC_MSG_RESULT([yes ($dag_include_dir)])
- if test $V_PCAP != dag ; then
- SSRC="pcap-dag.c"
- fi
-
- # See if we can find a general version string.
- # Don't need to save and restore LIBS to prevent -ldag being
- # included if there's a found-action (arg 3).
- saved_ldflags=$LDFLAGS
- LDFLAGS="-L$dag_lib_dir"
- AC_CHECK_LIB([dag], [dag_attach_stream], [dag_streams="1"], [dag_streams="0"])
- AC_CHECK_LIB([dag],[dag_get_erf_types], [
- AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])])
- AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [
- AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])])
-
- LDFLAGS=$saved_ldflags
+ V_INCLS="$V_INCLS -I$dag_include_dir"
- if test "$dag_streams" = 1; then
- AC_DEFINE(HAVE_DAG_STREAMS_API, 1, [define if you have streams capable DAG API])
- LIBS="$LIBS -ldag"
- LDFLAGS="$LDFLAGS -L$dag_lib_dir"
-
- AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
- if test "$ac_dag_have_vdag" = 1; then
- AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
- LIBS="$LIBS -lpthread"
+ if test $V_PCAP != dag ; then
+ SSRC="$SSRC pcap-dag.c"
fi
- fi
- AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
-fi
+ # See if we can find a general version string.
+ # Don't need to save and restore LIBS to prevent -ldag being
+ # included if there's a found-action (arg 3).
+ saved_ldflags=$LDFLAGS
+ LDFLAGS="-L$dag_lib_dir"
+ AC_CHECK_LIB([dag], [dag_attach_stream], [dag_streams="1"], [dag_streams="0"])
+ AC_CHECK_LIB([dag],[dag_get_erf_types], [
+ AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])])
+ AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [
+ AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])])
+
+ LDFLAGS=$saved_ldflags
+
+ if test "$dag_streams" = 1; then
+ AC_DEFINE(HAVE_DAG_STREAMS_API, 1, [define if you have streams capable DAG API])
+ LIBS="$LIBS -ldag"
+ LDFLAGS="$LDFLAGS -L$dag_lib_dir"
+
+ AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
+ if test "$ac_dag_have_vdag" = 1; then
+ AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
+ LIBS="$LIBS -lpthread"
+ fi
+ fi
-AC_MSG_CHECKING(whether we have the DAG API)
+ AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
+ else
+ AC_MSG_RESULT(no)
-if test $ac_cv_lbl_dag_api = no; then
- AC_MSG_RESULT(no)
- if test "$want_dag" = yes; then
- # User wanted DAG support but we couldn't find it.
- AC_MSG_ERROR([DAG API requested, but not found at $dag_root: use --without-dag])
- fi
+ if test "$V_PCAP" = dag; then
+ # User requested "dag" capture type but we couldn't
+ # find the DAG API support.
+ AC_MSG_ERROR([DAG support requested with --with-pcap=dag, but the DAG headers weren't found at $dag_include_dir: make sure the DAG support is installed, specify a different path or paths if necessary, or don't request DAG support])
+ fi
- if test "$V_PCAP" = dag; then
- # User requested "dag" capture type but the DAG API wasn't
- # found.
- AC_MSG_ERROR([Specifying the capture type as "dag" requires the DAG API to be present; use the --with-dag options to specify the location. (Try "./configure --help" for more information.)])
+ if test "$want_dag" = yes; then
+ # User wanted DAG support but we couldn't find it.
+ AC_MSG_ERROR([DAG support requested with --with-dag, but the DAG headers weren't found at $dag_include_dir: make sure the DAG support is installed, specify a different path or paths if necessary, or don't request DAG support])
+ fi
fi
-else
- AC_MSG_RESULT(yes)
fi
AC_ARG_WITH(septel,
-AC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, on Linux, if present@:>@]),
+AC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
[
if test "$withval" = no
then
@@ -855,38 +900,28 @@ AC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in d
septel_root=$withval
fi
],[
- #
- # Use Septel API if present, otherwise don't
- #
- want_septel=ifpresent
- septel_root=./../septel
-])
-ac_cv_lbl_septel_api=no
-case "$V_PCAP" in
-linux|septel)
- #
- # We support the Septel API if we're on Linux, or if we're building
- # a Septel-only libpcap.
- #
- ;;
-*)
- #
- # If the user explicitly requested Septel, tell them it's not
- # supported.
- #
- # If they expressed no preference, don't include it.
- #
- if test $want_septel = yes; then
- AC_MSG_ERROR(Septel support only available with 'linux' and 'septel' packet capture types)
- elif test $want_septel = yes; then
+ if test "$V_PCAP" = septel; then
+ # User requested Septel-only libpcap, so we'd better have
+ # the Septel API.
+ want_septel=yes
+ elif test "xxx_only" = yes; then
+ # User requested something-else-only pcap, so they don't
+ # want Septel support.
want_septel=no
+ else
+ #
+ # Use Septel API if present, otherwise don't
+ #
+ want_septel=ifpresent
fi
- ;;
-esac
+])
+ac_cv_lbl_septel_api=no
if test "$with_septel" != no; then
- AC_MSG_CHECKING(whether we have Septel API)
+ AC_MSG_CHECKING([whether we have Septel API headers])
+
+ # If necessary, set default paths for Septel API headers and libraries.
if test -z "$septel_root"; then
septel_root=$srcdir/../septel
fi
@@ -894,35 +929,41 @@ if test "$with_septel" != no; then
septel_tools_dir="$septel_root"
septel_include_dir="$septel_root/INC"
- ac_cv_lbl_septel_api=no
if test -r "$septel_include_dir/msg.h"; then
+ ac_cv_lbl_septel_api=yes
+ fi
+
+ if test "$ac_cv_lbl_septel_api" = yes; then
+ AC_MSG_RESULT([yes ($septel_include_dir)])
+
V_INCLS="$V_INCLS -I$septel_include_dir"
ADDLOBJS="$ADDLOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o"
ADDLARCHIVEOBJS="$ADDLARCHIVEOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o"
if test "$V_PCAP" != septel ; then
- SSRC="pcap-septel.c"
+ SSRC="$SSRC pcap-septel.c"
+ fi
+
+ AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have the Septel API])
+ else
+ AC_MSG_RESULT(no)
+
+ if test "$V_PCAP" = septel; then
+ # User requested "septel" capture type but
+ # we couldn't find the Septel API support.
+ AC_MSG_ERROR([Septel support requested with --with-pcap=septel, but the Septel headers weren't found at $septel_include_dir: make sure the Septel support is installed, specify a different path or paths if necessary, or don't request Septel support])
fi
- ac_cv_lbl_septel_api=yes
- fi
- AC_MSG_RESULT($ac_cv_lbl_septel_api)
- if test $ac_cv_lbl_septel_api = no; then
if test "$want_septel" = yes; then
- AC_MSG_ERROR(Septel API not found under directory $septel_root; use --without-septel)
+ # User wanted Septel support but we couldn't find it.
+ AC_MSG_ERROR([Septel support requested with --with-septel, but the Septel headers weren't found at $septel_include_dir: make sure the Septel support is installed, specify a different path or paths if necessary, or don't request Septel support])
fi
- else
- AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have a Septel API])
fi
fi
-if test "$V_PCAP" = septel -a "$ac_cv_lbl_septel_api" = no; then
- AC_MSG_ERROR(Specifying the capture type as 'septel' requires the Septel API to be present; use --with-septel=DIR)
-fi
-
# Check for Myricom SNF support.
AC_ARG_WITH([snf],
-AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support @<:@"yes", "no" or DIR; default="yes" on BSD and Linux if present@:>@]),
+AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
[
if test "$withval" = no
then
@@ -930,7 +971,7 @@ AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support @<:@"yes",
want_snf=no
elif test "$withval" = yes
then
- # User wants SNF support but hasn't specific a directory.
+ # User wants SNF support but hasn't specified a directory.
want_snf=yes
else
# User wants SNF support with a specified directory.
@@ -938,14 +979,24 @@ AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support @<:@"yes",
snf_root=$withval
fi
],[
- #
- # Use Sniffer API if present, otherwise don't
- #
- want_snf=ifpresent
+ if test "$V_PCAP" = snf; then
+ # User requested Sniffer-only libpcap, so we'd better have
+ # the Sniffer API.
+ want_snf=yes
+ elif test "xxx_only" = yes; then
+ # User requested something-else-only pcap, so they don't
+ # want SNF support.
+ want_snf=no
+ else
+ #
+ # Use Sniffer API if present, otherwise don't
+ #
+ want_snf=ifpresent
+ fi
])
AC_ARG_WITH([snf-includes],
-AC_HELP_STRING([--with-snf-includes=DIR],[Myricom SNF include directory]),
+AC_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not DIR/include]),
[
# User wants SNF with specific header directory
want_snf=yes
@@ -953,40 +1004,19 @@ AC_HELP_STRING([--with-snf-includes=DIR],[Myricom SNF include directory]),
],[])
AC_ARG_WITH([snf-libraries],
-AC_HELP_STRING([--with-snf-libraries=DIR],[Myricom SNF library directory]),
+AC_HELP_STRING([--with-snf-libraries=LDIR],[Myricom SNF library directory, if not DIR/lib]),
[
# User wants SNF with specific lib directory
want_snf=yes
snf_lib_dir=$withval
],[])
-case "$V_PCAP" in
-bpf|linux|snf)
- #
- # We support the Sniffer API if we're on BSD, Linux, or if we're
- # building a Sniffer-only libpcap.
- #
- ;;
-*)
- #
- # If the user explicitly requested Sniffer, tell them it's not
- # supported.
- #
- # If they expressed no preference, don't include it.
- #
- if test $want_snf = yes; then
- AC_MSG_ERROR(Myricom SNF support only available with 'bpf' 'linux' and 'snf' packet capture types)
- elif test $want_snf = yes; then
- want_snf=no
- fi
- ;;
-esac
-
ac_cv_lbl_snf_api=no
if test "$with_snf" != no; then
AC_MSG_CHECKING(whether we have Myricom Sniffer API)
+ # If necessary, set default paths for Sniffer headers and libraries.
if test -z "$snf_root"; then
snf_root=/opt/snf
fi
@@ -1000,56 +1030,157 @@ if test "$with_snf" != no; then
fi
if test -f "$snf_include_dir/snf.h"; then
- ac_cv_lbl_snf_api=yes
+ # We found a header; make sure we can link with the library
+ saved_ldflags=$LDFLAGS
+ LDFLAGS="$LDFLAGS -L$snf_lib_dir"
+ AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"])
+ LDFLAGS="$saved_ldflags"
+ if test "$ac_cv_lbl_snf_api" = no; then
+ AC_MSG_ERROR(SNF API cannot correctly be linked; check config.log)
+ fi
fi
- AC_MSG_RESULT([$ac_cv_lbl_snf_api ($snf_root)])
- if test $ac_cv_lbl_snf_api = no; then
+ if test "$ac_cv_lbl_snf_api" = yes; then
+ AC_MSG_RESULT([yes ($snf_root)])
+
+ V_INCLS="$V_INCLS -I$snf_include_dir"
+ LIBS="$LIBS -lsnf"
+ LDFLAGS="$LDFLAGS -L$snf_lib_dir"
+
+ if test "$V_PCAP" != snf ; then
+ SSRC="$SSRC pcap-snf.c"
+ fi
+
+ AC_DEFINE(HAVE_SNF_API, 1, [define if you have the Myricom SNF API])
+ else
+ AC_MSG_RESULT(no)
+
+ if test "$want_snf" = yes; then
+ # User requested "snf" capture type but
+ # we couldn't find the Sniffer API support.
+ AC_MSG_ERROR([Myricom Sniffer support requested with --with-pcap=snf, but the Sniffer headers weren't found at $snf_include_dir: make sure the Sniffer support is installed, specify a different path or paths if necessary, or don't request Sniffer support])
+ fi
+
if test "$want_snf" = yes; then
- AC_MSG_ERROR(SNF API headers not found under $snf_include_dir; use --without-snf)
+ AC_MSG_ERROR([Myricom Sniffer support requested with --with-snf, but the Sniffer headers weren't found at $snf_include_dir: make sure the Sniffer support is installed, specify a different path or paths if necessary, or don't request Sniffer support])
fi
+ fi
+fi
+
+# Check for Riverbed TurboCap support.
+AC_ARG_WITH([turbocap],
+AC_HELP_STRING([--with-turbocap@<:@=DIR@:>@],[include Riverbed TurboCap support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
+[
+ if test "$withval" = no
+ then
+ # User explicitly doesn't want TurboCap
+ want_turbocap=no
+ elif test "$withval" = yes
+ then
+ # User wants TurboCap support but hasn't specified a directory.
+ want_turbocap=yes
else
- saved_ldflags=$LDFLAGS
- LDFLAGS="$LDFLAGS -L$snf_lib_dir"
- AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"], [ac_cv_lbl_snf_api="no"])
- LDFLAGS="$saved_ldflags"
+ # User wants TurboCap support with a specified directory.
+ want_turbocap=yes
+ turbocap_root=$withval
+ fi
+],[
+ if test "xxx_only" = yes; then
+ # User requested something-else-only pcap, so they don't
+ # want TurboCap support.
+ want_turbocap=no
+ else
+ #
+ # Use TurboCap API if present, otherwise don't
+ #
+ want_turbocap=ifpresent
+ fi
+])
- if test $ac_cv_lbl_snf_api = no; then
- if test "$want_snf" = yes; then
- AC_MSG_ERROR(SNF API cannot correctly be linked check config.log; use --without-snf)
- fi
- else
- V_INCLS="$V_INCLS -I$snf_include_dir"
- LIBS="$LIBS -lsnf"
- LDFLAGS="$LDFLAGS -L$snf_lib_dir"
- if test "$V_PCAP" != snf ; then
- SSRC="pcap-snf.c"
- fi
- AC_DEFINE(HAVE_SNF_API, 1, [define if you have Myricom SNF API])
+ac_cv_lbl_turbocap_api=no
+if test "$want_turbocap" != no; then
+
+ AC_MSG_CHECKING(whether TurboCap is supported)
+
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ if test ! -z "$turbocap_root"; then
+ TURBOCAP_CFLAGS="-I$turbocap_root/include"
+ TURBOCAP_LIBS="-L$turbocap_root/lib"
+ CFLAGS="$CFLAGS $TURBOCAP_CFLAGS"
+ fi
+
+ AC_TRY_COMPILE(
+ [
+ #include <TcApi.h>
+ ],
+ [
+ TC_INSTANCE a; TC_PORT b; TC_BOARD c;
+ TC_INSTANCE i;
+ (void)TcInstanceCreateByName("foo", &i);
+ ],
+ ac_cv_lbl_turbocap_api=yes)
+
+ CFLAGS="$save_CFLAGS"
+ if test $ac_cv_lbl_turbocap_api = yes; then
+ AC_MSG_RESULT(yes)
+
+ SSRC="$SSRC pcap-tc.c"
+ V_INCLS="$V_INCLS $TURBOCAP_CFLAGS"
+ LIBS="$LIBS $TURBOCAP_LIBS -lTcApi -lpthread -lstdc++"
+
+ AC_DEFINE(HAVE_TC_API, 1, [define if you have the TurboCap API])
+ else
+ AC_MSG_RESULT(no)
+
+ if test "$want_turbocap" = yes; then
+ # User wanted Turbo support but we couldn't find it.
+ AC_MSG_ERROR([TurboCap support requested with --with-turbocap, but the TurboCap headers weren't found: make sure the TurboCap support is installed or don't request TurboCap support])
fi
fi
fi
-if test "$V_PCAP" = snf -a "$ac_cv_lbl_snf_api" = no; then
- AC_MSG_ERROR(Specifying the capture type as 'snf' requires the Myricom Sniffer API to be present; use --with-snf=DIR)
+#
+# Look for {f}lex.
+#
+AC_PROG_LEX
+if test "$LEX" = ":"; then
+ AC_MSG_ERROR([Neither flex nor lex was found.])
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
+#
+# Make sure {f}lex supports the -P, --header-file, and --nounput flags
+# and supports processing our scanner.l.
+#
+AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
+ if $LEX -P pcap_ --header-file=/dev/null --nounput -t $srcdir/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([$LEX is insufficient to compile libpcap.
+ libpcap requires Flex 2.5.31 or later, or a compatible version of lex.])
+fi
+
+#
+# Look for yacc/bison/byacc.
+#
+AC_PROG_YACC
+
+#
+# Make sure it supports the -p flag and supports processing our
+# grammar.y.
+#
+AC_CACHE_CHECK([for capable yacc/bison], tcpdump_cv_capable_yacc,
+ if $YACC -p pcap_ -o /dev/null $srcdir/grammar.y >/dev/null 2>&1; then
+ tcpdump_cv_capable_yacc=yes
+ else
+ tcpdump_cv_capable_yacc=insufficient
+ fi)
+if test $tcpdump_cv_capable_yacc = insufficient ; then
+ AC_MSG_ERROR([$YACC is insufficient to compile libpcap.
+ libpcap requires Bison, Berkeley YACC, or another YACC compatible with them.])
fi
#
@@ -1321,12 +1452,6 @@ AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
AC_LBL_UNALIGNED_ACCESS
-#
-# Makefile.in includes rules to generate version.h, so we assume
-# that it will be generated if autoconf is used.
-#
-AC_DEFINE(HAVE_VERSION_H, 1, [define if version.h is generated in the build procedure])
-
rm -f net
ln -s ${srcdir}/bpf/net net
@@ -1348,10 +1473,22 @@ AC_SUBST(DYEXT)
AC_SUBST(MAN_FILE_FORMATS)
AC_SUBST(MAN_MISC_INFO)
-dnl check for USB sniffing support
-AC_MSG_CHECKING(for USB sniffing support)
-case "$host_os" in
-linux*)
+AC_ARG_ENABLE([usb],
+[AC_HELP_STRING([--enable-usb],[enable nusb support @<:@default=yes, if support available@:>@])],
+ [],
+ [enable_usb=yes])
+
+if test "xxx_only" = yes; then
+ # User requested something-else-only pcap, so they don't
+ # want USB support.
+ enable_usb=no
+fi
+
+if test "x$enable_usb" != "xno" ; then
+ dnl check for USB sniffing support
+ AC_MSG_CHECKING(for USB sniffing support)
+ case "$host_os" in
+ linux*)
AC_DEFINE(PCAP_SUPPORT_USB, 1, [target host supports USB sniffing])
USB_SRC=pcap-usb-linux.c
AC_MSG_RESULT(yes)
@@ -1402,29 +1539,39 @@ AC_INCLUDES_DEFAULT
fi
fi
;;
-*)
+ freebsd*)
+ #
+ # This just uses BPF in FreeBSD 8.4 and later; we don't need
+ # to check for anything special for capturing.
+ #
+ AC_MSG_RESULT([yes, in FreeBSD 8.4 and later])
+ ;;
+
+ *)
AC_MSG_RESULT(no)
;;
esac
+fi
AC_SUBST(PCAP_SUPPORT_USB)
AC_SUBST(USB_SRC)
dnl check for netfilter sniffing support
-AC_MSG_CHECKING(whether the platform could support netfilter sniffing)
-case "$host_os" in
-linux*)
- AC_MSG_RESULT(yes)
- #
- # Life's too short to deal with trying to get this to compile
- # if you don't get the right types defined with
- # __KERNEL_STRICT_NAMES getting defined by some other include.
- #
- # Check whether the includes Just Work. If not, don't turn on
- # netfilter support.
- #
- AC_MSG_CHECKING(whether we can compile the netfilter support)
- AC_CACHE_VAL(ac_cv_netfilter_can_compile,
- AC_TRY_COMPILE([
+if test "xxx_only" != yes; then
+ AC_MSG_CHECKING(whether the platform could support netfilter sniffing)
+ case "$host_os" in
+ linux*)
+ AC_MSG_RESULT(yes)
+ #
+ # Life's too short to deal with trying to get this to compile
+ # if you don't get the right types defined with
+ # __KERNEL_STRICT_NAMES getting defined by some other include.
+ #
+ # Check whether the includes Just Work. If not, don't turn on
+ # netfilter support.
+ #
+ AC_MSG_CHECKING(whether we can compile the netfilter support)
+ AC_CACHE_VAL(ac_cv_netfilter_can_compile,
+ AC_TRY_COMPILE([
AC_INCLUDES_DEFAULT
#include <sys/socket.h>
#include <netinet/in.h>
@@ -1438,17 +1585,18 @@ AC_INCLUDES_DEFAULT
[],
ac_cv_netfilter_can_compile=yes,
ac_cv_netfilter_can_compile=no))
- AC_MSG_RESULT($ac_cv_netfilter_can_compile)
- if test $ac_cv_netfilter_can_compile = yes ; then
- AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1,
- [target host supports netfilter sniffing])
- NETFILTER_SRC=pcap-netfilter-linux.c
- fi
- ;;
-*)
- AC_MSG_RESULT(no)
- ;;
-esac
+ AC_MSG_RESULT($ac_cv_netfilter_can_compile)
+ if test $ac_cv_netfilter_can_compile = yes ; then
+ AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1,
+ [target host supports netfilter sniffing])
+ NETFILTER_SRC=pcap-netfilter-linux.c
+ fi
+ ;;
+ *)
+ AC_MSG_RESULT(no)
+ ;;
+ esac
+fi
AC_SUBST(PCAP_SUPPORT_NETFILTER)
AC_SUBST(NETFILTER_SRC)
@@ -1457,6 +1605,12 @@ AC_ARG_ENABLE([bluetooth],
[],
[enable_bluetooth=ifsupportavailable])
+if test "xxx_only" = yes; then
+ # User requested something-else-only pcap, so they don't
+ # want Bluetooth support.
+ enable_bluetooth=no
+fi
+
if test "x$enable_bluetooth" != "xno" ; then
dnl check for Bluetooth sniffing support
case "$host_os" in
@@ -1531,157 +1685,90 @@ if test "x$enable_bluetooth" != "xno" ; then
AC_SUBST(BT_MONITOR_SRC)
fi
-AC_ARG_ENABLE([canusb],
-[AC_HELP_STRING([--enable-canusb],[enable canusb support @<:@default=yes, if support available@:>@])],
- [],
- [enable_canusb=ifsupportavailable])
-
-if test "x$enable_canusb" != "xno" ; then
- dnl check for canusb support
- case "$host_os" in
- linux*)
- AC_CHECK_HEADER(libusb-1.0/libusb.h,
- [
- AC_CHECK_LIB(usb-1.0, libusb_init,
- [
- AC_DEFINE(PCAP_SUPPORT_CANUSB, 1, [target host supports canusb])
- CANUSB_SRC=pcap-canusb-linux.c
- LIBS="-lusb-1.0 -lpthread $LIBS"
- ac_lbl_has_libusb=yes
- ],
- ac_lbl_has_libusb=no
- )
- ],
- ac_lbl_has_libusb=no
- )
- if test "x$ac_lbl_has_libusb" = "xyes" ; then
- AC_MSG_NOTICE(canusb sniffing is supported)
- else
- if test "x$enable_canusb" = "xyes" ; then
- AC_MSG_ERROR(canusb sniffing is not supported; install libusb1.0 lib devel to enable it)
- else
- AC_MSG_NOTICE(canusb sniffing is not supported; install libusb1.0 lib devel to enable it)
- fi
- fi
- ;;
- *)
- if test "x$enable_canusb" = "xyes" ; then
- AC_MSG_ERROR(no canusb support implemented for $host_os)
- else
- AC_MSG_NOTICE(no canusb support implemented for $host_os)
- fi
- ;;
- esac
- AC_SUBST(PCAP_SUPPORT_CANUSB)
- AC_SUBST(CANUSB_SRC)
-fi
-
-AC_ARG_ENABLE([can],
-[AC_HELP_STRING([--enable-can],[enable CAN support @<:@default=yes, if support available@:>@])],
- [],
- [enable_can=ifsupportavailable])
-
-if test "x$enable_can" != "xno" ; then
- dnl check for CAN sniffing support
- case "$host_os" in
- linux*)
- AC_CHECK_HEADER(linux/can.h,
- [
- AC_DEFINE(PCAP_SUPPORT_CAN, 1, [target host supports CAN sniffing])
- CAN_SRC=pcap-can-linux.c
- AC_MSG_NOTICE(CAN sniffing is supported)
- ],
- [
- if test "x$enable_can" = "xyes" ; then
- AC_MSG_ERROR(CAN sniffing is not supported)
- else
- AC_MSG_NOTICE(CAN sniffing is not supported)
- fi
- ],
- [#include <sys/socket.h>]
- )
- ;;
- *)
- if test "x$enable_can" = "xyes" ; then
- AC_MSG_ERROR(no CAN sniffing support implemented for $host_os)
- else
- AC_MSG_NOTICE(no CAN sniffing support implemented for $host_os)
- fi
- ;;
- esac
- AC_SUBST(PCAP_SUPPORT_CAN)
- AC_SUBST(CAN_SRC)
-fi
-
AC_ARG_ENABLE([dbus],
[AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
[],
[enable_dbus=ifavailable])
+if test "xxx_only" = yes; then
+ # User requested something-else-only pcap, so they don't
+ # want D-Bus support.
+ enable_dbus=no
+fi
+
if test "x$enable_dbus" != "xno"; then
if test "x$enable_dbus" = "xyes"; then
case "$host_os" in
darwin*)
#
+ # We don't support D-Bus sniffing on OS X; see
+ #
# https://bugs.freedesktop.org/show_bug.cgi?id=74029
#
+ # The user requested it, so fail.
+ #
AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on OS X])
- ;;
esac
- else
+ else
case "$host_os" in
darwin*)
#
+ # We don't support D-Bus sniffing on OS X; see
+ #
# https://bugs.freedesktop.org/show_bug.cgi?id=74029
#
+ # The user dind't explicitly request it, so just
+ # silently refuse to enable it.
+ #
+ enable_dbus="no"
;;
+ esac
+ fi
+fi
- *)
- AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no])
- if test "x$PKGCONFIG" != "xno"; then
- AC_MSG_CHECKING([for D-Bus])
- if "$PKGCONFIG" dbus-1; then
- AC_MSG_RESULT([yes])
- DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
- DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
- save_CFLAGS="$CFLAGS"
- save_LIBS="$LIBS"
- CFLAGS="$CFLAGS $DBUS_CFLAGS"
- LIBS="$LIBS $DBUS_LIBS"
- AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
- AC_TRY_LINK(
- [#include <string.h>
-
- #include <time.h>
- #include <sys/time.h>
-
- #include <dbus/dbus.h>],
- [return dbus_connection_read_write(NULL, 0);],
- [
- AC_MSG_RESULT([yes])
- AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
- DBUS_SRC=pcap-dbus.c
- V_INCLS="$V_INCLS $DBUS_CFLAGS"
- ],
- [
- AC_MSG_RESULT([no])
- if test "x$enable_dbus" = "xyes"; then
- AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
- fi
- LIBS="$save_LIBS"
- ])
- CFLAGS="$save_CFLAGS"
- else
- AC_MSG_RESULT([no])
- if test "x$enable_dbus" = "xyes"; then
- AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
- fi
+if test "x$enable_dbus" != "xno"; then
+ AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no])
+ if test "x$PKGCONFIG" != "xno"; then
+ AC_MSG_CHECKING([for D-Bus])
+ if "$PKGCONFIG" dbus-1; then
+ AC_MSG_RESULT([yes])
+ DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
+ DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ CFLAGS="$CFLAGS $DBUS_CFLAGS"
+ LIBS="$LIBS $DBUS_LIBS"
+ AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
+ AC_TRY_LINK(
+ [#include <string.h>
+
+ #include <time.h>
+ #include <sys/time.h>
+
+ #include <dbus/dbus.h>],
+ [return dbus_connection_read_write(NULL, 0);],
+ [
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
+ DBUS_SRC=pcap-dbus.c
+ V_INCLS="$V_INCLS $DBUS_CFLAGS"
+ ],
+ [
+ AC_MSG_RESULT([no])
+ if test "x$enable_dbus" = "xyes"; then
+ AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
fi
+ LIBS="$save_LIBS"
+ ])
+ CFLAGS="$save_CFLAGS"
+ else
+ AC_MSG_RESULT([no])
+ if test "x$enable_dbus" = "xyes"; then
+ AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
fi
- ;;
- esac
+ fi
fi
AC_SUBST(PCAP_SUPPORT_DBUS)
AC_SUBST(DBUS_SRC)
@@ -1697,6 +1784,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 a/dlpisubs.c b/dlpisubs.c
index 131fa279d843..fb94a6057675 100644
--- a/dlpisubs.c
+++ b/dlpisubs.c
@@ -186,8 +186,8 @@ pcap_process_pkts(pcap_t *p, pcap_handler callback, u_char *user,
pkthdr.len = origlen;
pkthdr.caplen = caplen;
/* Insure caplen does not exceed snapshot */
- if (pkthdr.caplen > p->snapshot)
- pkthdr.caplen = p->snapshot;
+ if (pkthdr.caplen > (bpf_u_int32)p->snapshot)
+ pkthdr.caplen = (bpf_u_int32)p->snapshot;
(*callback)(user, &pkthdr, pk);
if (++n >= count && !PACKET_COUNT_IS_UNLIMITED(count)) {
p->cc = ep - bufp;
@@ -255,8 +255,29 @@ pcap_process_mactype(pcap_t *p, u_int mactype)
break;
#endif
+#ifdef DL_IPV4
+ case DL_IPV4:
+ p->linktype = DLT_IPV4;
+ p->offset = 0;
+ break;
+#endif
+
+#ifdef DL_IPV6
+ case DL_IPV6:
+ p->linktype = DLT_IPV6;
+ p->offset = 0;
+ break;
+#endif
+
+#ifdef DL_IPNET
+ case DL_IPNET:
+ p->linktype = DLT_IPNET;
+ p->offset = 0;
+ break;
+#endif
+
default:
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "unknown mactype %u",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "unknown mactype 0x%x",
mactype);
retv = -1;
}
@@ -326,7 +347,7 @@ int
pcap_alloc_databuf(pcap_t *p)
{
p->bufsize = PKTBUFSIZE;
- p->buffer = (u_char *)malloc(p->bufsize + p->offset);
+ p->buffer = malloc(p->bufsize + p->offset);
if (p->buffer == NULL) {
strlcpy(p->errbuf, pcap_strerror(errno), PCAP_ERRBUF_SIZE);
return (-1);
@@ -362,6 +383,6 @@ strioctl(int fd, int cmd, int len, char *dp)
static void
pcap_stream_err(const char *func, int err, char *errbuf)
{
- snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", func, pcap_strerror(err));
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", func, pcap_strerror(err));
}
#endif
diff --git a/etherent.c b/etherent.c
index 707fd9d148b7..5cfd1b4c3bbb 100644
--- a/etherent.c
+++ b/etherent.c
@@ -23,9 +23,9 @@
#include "config.h"
#endif
-#ifdef WIN32
+#ifdef _WIN32
#include <pcap-stdinc.h>
-#else /* WIN32 */
+#else /* _WIN32 */
#if HAVE_INTTYPES_H
#include <inttypes.h>
#elif HAVE_STDINT_H
@@ -35,7 +35,7 @@
#include <sys/bitypes.h>
#endif
#include <sys/types.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include <ctype.h>
#include <memory.h>
diff --git a/ethertype.h b/ethertype.h
index 8bab881634d6..51f63083f8b8 100644
--- a/ethertype.h
+++ b/ethertype.h
@@ -112,6 +112,9 @@
#ifndef ETHERTYPE_PPPOES
#define ETHERTYPE_PPPOES 0x8864
#endif
+#ifndef ETHERTYPE_8021AD
+#define ETHERTYPE_8021AD 0x88a8
+#endif
#ifndef ETHERTYPE_LOOPBACK
#define ETHERTYPE_LOOPBACK 0x9000
#endif
diff --git a/extract.h b/extract.h
new file mode 100644
index 000000000000..face5b7e94cd
--- /dev/null
+++ b/extract.h
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 1992, 1993, 1994, 1995, 1996
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef _WIN32
+#include <arpa/inet.h>
+#endif
+
+/*
+ * Macros to extract possibly-unaligned big-endian integral values.
+ */
+#ifdef LBL_ALIGN
+/*
+ * The processor doesn't natively handle unaligned loads.
+ */
+#if defined(__GNUC__) && defined(HAVE___ATTRIBUTE__) && \
+ (defined(__alpha) || defined(__alpha__) || \
+ defined(__mips) || defined(__mips__))
+
+/*
+ * This is a GCC-compatible compiler and we have __attribute__, which
+ * we assume that mean we have __attribute__((packed)), and this is
+ * MIPS or Alpha, which has instructions that can help when doing
+ * unaligned loads.
+ *
+ * Declare packed structures containing a uint16_t and a uint32_t,
+ * cast the pointer to point to one of those, and fetch through it;
+ * the GCC manual doesn't appear to explicitly say that
+ * __attribute__((packed)) causes the compiler to generate unaligned-safe
+ * code, but it apppears to do so.
+ *
+ * We do this in case the compiler can generate code using those
+ * instructions to do an unaligned load and pass stuff to "ntohs()" or
+ * "ntohl()", which might be better than than the code to fetch the
+ * bytes one at a time and assemble them. (That might not be the
+ * case on a little-endian platform, such as DEC's MIPS machines and
+ * Alpha machines, where "ntohs()" and "ntohl()" might not be done
+ * inline.)
+ *
+ * We do this only for specific architectures because, for example,
+ * at least some versions of GCC, when compiling for 64-bit SPARC,
+ * generate code that assumes alignment if we do this.
+ *
+ * XXX - add other architectures and compilers as possible and
+ * appropriate.
+ *
+ * HP's C compiler, indicated by __HP_cc being defined, supports
+ * "#pragma unaligned N" in version A.05.50 and later, where "N"
+ * specifies a number of bytes at which the typedef on the next
+ * line is aligned, e.g.
+ *
+ * #pragma unalign 1
+ * typedef uint16_t unaligned_uint16_t;
+ *
+ * to define unaligned_uint16_t as a 16-bit unaligned data type.
+ * This could be presumably used, in sufficiently recent versions of
+ * the compiler, with macros similar to those below. This would be
+ * useful only if that compiler could generate better code for PA-RISC
+ * or Itanium than would be generated by a bunch of shifts-and-ORs.
+ *
+ * DEC C, indicated by __DECC being defined, has, at least on Alpha,
+ * an __unaligned qualifier that can be applied to pointers to get the
+ * compiler to generate code that does unaligned loads and stores when
+ * dereferencing the pointer in question.
+ *
+ * XXX - what if the native C compiler doesn't support
+ * __attribute__((packed))? How can we get it to generate unaligned
+ * accesses for *specific* items?
+ */
+typedef struct {
+ uint16_t val;
+} __attribute__((packed)) unaligned_uint16_t;
+
+typedef struct {
+ uint32_t val;
+} __attribute__((packed)) unaligned_uint32_t;
+
+static inline uint16_t
+EXTRACT_16BITS(const void *p)
+{
+ return ((uint16_t)ntohs(((const unaligned_uint16_t *)(p))->val));
+}
+
+static inline uint32_t
+EXTRACT_32BITS(const void *p)
+{
+ return ((uint32_t)ntohl(((const unaligned_uint32_t *)(p))->val));
+}
+
+static inline uint64_t
+EXTRACT_64BITS(const void *p)
+{
+ return ((uint64_t)(((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 0)->val)) << 32 | \
+ ((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 1)->val)) << 0));
+}
+
+#else /* have to do it a byte at a time */
+/*
+ * This isn't a GCC-compatible compiler, we don't have __attribute__,
+ * or we do but we don't know of any better way with this instruction
+ * set to do unaligned loads, so do unaligned loads of big-endian
+ * quantities the hard way - fetch the bytes one at a time and
+ * assemble them.
+ */
+#define EXTRACT_16BITS(p) \
+ ((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 0)) << 8) | \
+ ((uint16_t)(*((const uint8_t *)(p) + 1)) << 0)))
+#define EXTRACT_32BITS(p) \
+ ((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 24) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 1)) << 16) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 2)) << 8) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 3)) << 0)))
+#define EXTRACT_64BITS(p) \
+ ((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 56) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 1)) << 48) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 2)) << 40) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 3)) << 32) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 4)) << 24) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 5)) << 16) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 6)) << 8) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 7)) << 0)))
+#endif /* must special-case unaligned accesses */
+#else /* LBL_ALIGN */
+/*
+ * The processor natively handles unaligned loads, so we can just
+ * cast the pointer and fetch through it.
+ */
+static inline uint16_t
+EXTRACT_16BITS(const void *p)
+{
+ return ((uint16_t)ntohs(*(const uint16_t *)(p)));
+}
+
+static inline uint32_t
+EXTRACT_32BITS(const void *p)
+{
+ return ((uint32_t)ntohl(*(const uint32_t *)(p)));
+}
+
+static inline uint64_t
+EXTRACT_64BITS(const void *p)
+{
+ return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 | \
+ ((uint64_t)ntohl(*((const uint32_t *)(p) + 1))) << 0));
+
+}
+
+#endif /* LBL_ALIGN */
+
+#define EXTRACT_24BITS(p) \
+ ((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 16) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 2)) << 0)))
+
+#define EXTRACT_40BITS(p) \
+ ((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 32) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 1)) << 24) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 3)) << 8) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 4)) << 0)))
+
+#define EXTRACT_48BITS(p) \
+ ((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 40) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 1)) << 32) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 2)) << 24) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 3)) << 16) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 4)) << 8) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 5)) << 0)))
+
+#define EXTRACT_56BITS(p) \
+ ((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 48) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 1)) << 40) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 2)) << 32) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 4)) << 16) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 5)) << 8) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 6)) << 0)))
+
+/*
+ * Macros to extract possibly-unaligned little-endian integral values.
+ * XXX - do loads on little-endian machines that support unaligned loads?
+ */
+#define EXTRACT_LE_8BITS(p) (*(p))
+#define EXTRACT_LE_16BITS(p) \
+ ((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+ ((uint16_t)(*((const uint8_t *)(p) + 0)) << 0)))
+#define EXTRACT_LE_32BITS(p) \
+ ((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 3)) << 24) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
+#define EXTRACT_LE_24BITS(p) \
+ ((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
+#define EXTRACT_LE_64BITS(p) \
+ ((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 7)) << 56) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 6)) << 48) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 5)) << 40) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 4)) << 32) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 0)) << 0)))
diff --git a/fad-getad.c b/fad-getad.c
index 6fd3360f788f..b67b5cdcd46a 100644
--- a/fad-getad.c
+++ b/fad-getad.c
@@ -144,7 +144,8 @@ get_sa_len(struct sockaddr *addr)
* could be opened.
*/
int
-pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
+pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf,
+ int (*check_usable)(const char *))
{
pcap_if_t *devlist = NULL;
struct ifaddrs *ifap, *ifa;
@@ -168,12 +169,51 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
* those.
*/
if (getifaddrs(&ifap) != 0) {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"getifaddrs: %s", pcap_strerror(errno));
return (-1);
}
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
/*
+ * If this entry has a colon followed by a number at
+ * the end, we assume it's a logical interface. Those
+ * are just the way you assign multiple IP addresses to
+ * a real interface on Linux, so an entry for a logical
+ * interface should be treated like the entry for the
+ * real interface; we do that by stripping off the ":"
+ * and the number.
+ *
+ * XXX - should we do this only on Linux?
+ */
+ p = strchr(ifa->ifa_name, ':');
+ if (p != NULL) {
+ /*
+ * We have a ":"; is it followed by a number?
+ */
+ q = p + 1;
+ while (isdigit((unsigned char)*q))
+ q++;
+ if (*q == '\0') {
+ /*
+ * All digits after the ":" until the end.
+ * Strip off the ":" and everything after
+ * it.
+ */
+ *p = '\0';
+ }
+ }
+
+ /*
+ * Can we capture on this device?
+ */
+ if (!(*check_usable)(ifa->ifa_name)) {
+ /*
+ * No.
+ */
+ continue;
+ }
+
+ /*
* "ifa_addr" was apparently null on at least one
* interface on some system. Therefore, we supply
* the address and netmask only if "ifa_addr" is
@@ -223,39 +263,11 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
}
/*
- * If this entry has a colon followed by a number at
- * the end, we assume it's a logical interface. Those
- * are just the way you assign multiple IP addresses to
- * a real interface on Linux, so an entry for a logical
- * interface should be treated like the entry for the
- * real interface; we do that by stripping off the ":"
- * and the number.
- *
- * XXX - should we do this only on Linux?
- */
- p = strchr(ifa->ifa_name, ':');
- if (p != NULL) {
- /*
- * We have a ":"; is it followed by a number?
- */
- q = p + 1;
- while (isdigit((unsigned char)*q))
- q++;
- if (*q == '\0') {
- /*
- * All digits after the ":" until the end.
- * Strip off the ":" and everything after
- * it.
- */
- *p = '\0';
- }
- }
-
- /*
* Add information for this address to the list.
*/
if (add_addr_to_iflist(&devlist, ifa->ifa_name,
- ifa->ifa_flags, addr, addr_size, netmask, addr_size,
+ if_flags_to_pcap_flags(ifa->ifa_name, ifa->ifa_flags),
+ addr, addr_size, netmask, addr_size,
broadaddr, broadaddr_size, dstaddr, dstaddr_size,
errbuf) < 0) {
ret = -1;
diff --git a/fad-gifc.c b/fad-gifc.c
index 5c3357c7cea0..1b24af292985 100644
--- a/fad-gifc.c
+++ b/fad-gifc.c
@@ -132,12 +132,13 @@ struct rtentry; /* declarations in <net/if.h> */
* we already have that.
*/
int
-pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
+pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf,
+ int (*check_usable)(const char *))
{
pcap_if_t *devlist = NULL;
register int fd;
register struct ifreq *ifrp, *ifend, *ifnext;
- int n;
+ size_t n;
struct ifconf ifc;
char *buf = NULL;
unsigned buf_size;
@@ -154,7 +155,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
*/
fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"socket: %s", pcap_strerror(errno));
return (-1);
}
@@ -170,7 +171,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
for (;;) {
buf = malloc(buf_size);
if (buf == NULL) {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"malloc: %s", pcap_strerror(errno));
(void)close(fd);
return (-1);
@@ -181,7 +182,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
memset(buf, 0, buf_size);
if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0
&& errno != EINVAL) {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"SIOCGIFCONF: %s", pcap_strerror(errno));
(void)close(fd);
free(buf);
@@ -217,12 +218,12 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
/*
* XXX - The 32-bit compatibility layer for Linux on IA-64
* is slightly broken. It correctly converts the structures
- * to and from kernel land from 64 bit to 32 bit but
- * doesn't update ifc.ifc_len, leaving it larger than the
- * amount really used. This means we read off the end
- * of the buffer and encounter an interface with an
- * "empty" name. Since this is highly unlikely to ever
- * occur in a valid case we can just finish looking for
+ * to and from kernel land from 64 bit to 32 bit but
+ * doesn't update ifc.ifc_len, leaving it larger than the
+ * amount really used. This means we read off the end
+ * of the buffer and encounter an interface with an
+ * "empty" name. Since this is highly unlikely to ever
+ * occur in a valid case we can just finish looking for
* interfaces if we see an empty name.
*/
if (!(*ifrp->ifr_name))
@@ -237,6 +238,16 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
continue;
/*
+ * Can we capture on this device?
+ */
+ if (!(*check_usable)(ifrp->ifr_name)) {
+ /*
+ * No.
+ */
+ continue;
+ }
+
+ /*
* Get the flags for this interface.
*/
strncpy(ifrflags.ifr_name, ifrp->ifr_name,
@@ -244,7 +255,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifrflags) < 0) {
if (errno == ENXIO)
continue;
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"SIOCGIFFLAGS: %.*s: %s",
(int)sizeof(ifrflags.ifr_name),
ifrflags.ifr_name,
@@ -268,7 +279,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
netmask = NULL;
netmask_size = 0;
} else {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"SIOCGIFNETMASK: %.*s: %s",
(int)sizeof(ifrnetmask.ifr_name),
ifrnetmask.ifr_name,
@@ -299,7 +310,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
broadaddr = NULL;
broadaddr_size = 0;
} else {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"SIOCGIFBRDADDR: %.*s: %s",
(int)sizeof(ifrbroadaddr.ifr_name),
ifrbroadaddr.ifr_name,
@@ -338,7 +349,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
dstaddr = NULL;
dstaddr_size = 0;
} else {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"SIOCGIFDSTADDR: %.*s: %s",
(int)sizeof(ifrdstaddr.ifr_name),
ifrdstaddr.ifr_name,
@@ -391,10 +402,10 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
* Add information for this address to the list.
*/
if (add_addr_to_iflist(&devlist, ifrp->ifr_name,
- ifrflags.ifr_flags, &ifrp->ifr_addr,
- SA_LEN(&ifrp->ifr_addr), netmask, netmask_size,
- broadaddr, broadaddr_size, dstaddr, dstaddr_size,
- errbuf) < 0) {
+ if_flags_to_pcap_flags(ifrp->ifr_name, ifrflags.ifr_flags),
+ &ifrp->ifr_addr, SA_LEN(&ifrp->ifr_addr),
+ netmask, netmask_size, broadaddr, broadaddr_size,
+ dstaddr, dstaddr_size, errbuf) < 0) {
ret = -1;
break;
}
diff --git a/fad-glifc.c b/fad-glifc.c
index 1a820ad90c61..511481cf9636 100644
--- a/fad-glifc.c
+++ b/fad-glifc.c
@@ -75,7 +75,8 @@ struct rtentry; /* declarations in <net/if.h> */
* SIOCGLIFCONF rather than SIOCGIFCONF in order to get IPv6 addresses.)
*/
int
-pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
+pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf,
+ int (*check_usable)(const char *))
{
pcap_if_t *devlist = NULL;
register int fd4, fd6, fd;
@@ -97,7 +98,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
*/
fd4 = socket(AF_INET, SOCK_DGRAM, 0);
if (fd4 < 0) {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"socket: %s", pcap_strerror(errno));
return (-1);
}
@@ -107,7 +108,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
*/
fd6 = socket(AF_INET6, SOCK_DGRAM, 0);
if (fd6 < 0) {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"socket: %s", pcap_strerror(errno));
(void)close(fd4);
return (-1);
@@ -120,7 +121,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
ifn.lifn_flags = 0;
ifn.lifn_count = 0;
if (ioctl(fd4, SIOCGLIFNUM, (char *)&ifn) < 0) {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"SIOCGLIFNUM: %s", pcap_strerror(errno));
(void)close(fd6);
(void)close(fd4);
@@ -133,7 +134,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
buf_size = ifn.lifn_count * sizeof (struct lifreq);
buf = malloc(buf_size);
if (buf == NULL) {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"malloc: %s", pcap_strerror(errno));
(void)close(fd6);
(void)close(fd4);
@@ -149,7 +150,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
ifc.lifc_flags = 0;
memset(buf, 0, buf_size);
if (ioctl(fd4, SIOCGLIFCONF, (char *)&ifc) < 0) {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"SIOCGLIFCONF: %s", pcap_strerror(errno));
(void)close(fd6);
(void)close(fd4);
@@ -165,14 +166,6 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
for (; ifrp < ifend; ifrp++) {
/*
- * IPv6 or not?
- */
- if (((struct sockaddr *)&ifrp->lifr_addr)->sa_family == AF_INET6)
- fd = fd6;
- else
- fd = fd4;
-
- /*
* Skip entries that begin with "dummy".
* XXX - what are these? Is this Linux-specific?
* Are there platforms on which we shouldn't do this?
@@ -180,27 +173,23 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
if (strncmp(ifrp->lifr_name, "dummy", 5) == 0)
continue;
-#ifdef HAVE_SOLARIS
/*
- * Skip entries that have a ":" followed by a number
- * at the end - those are Solaris virtual interfaces
- * on which you can't capture.
+ * Can we capture on this device?
*/
- p = strchr(ifrp->lifr_name, ':');
- if (p != NULL) {
+ if (!(*check_usable)(ifrp->lifr_name)) {
/*
- * We have a ":"; is it followed by a number?
+ * No.
*/
- while (isdigit((unsigned char)*p))
- p++;
- if (*p == '\0') {
- /*
- * All digits after the ":" until the end.
- */
- continue;
- }
+ continue;
}
-#endif
+
+ /*
+ * IPv6 or not?
+ */
+ if (((struct sockaddr *)&ifrp->lifr_addr)->sa_family == AF_INET6)
+ fd = fd6;
+ else
+ fd = fd4;
/*
* Get the flags for this interface.
@@ -210,7 +199,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
if (ioctl(fd, SIOCGLIFFLAGS, (char *)&ifrflags) < 0) {
if (errno == ENXIO)
continue;
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"SIOCGLIFFLAGS: %.*s: %s",
(int)sizeof(ifrflags.lifr_name),
ifrflags.lifr_name,
@@ -233,7 +222,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
*/
netmask = NULL;
} else {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"SIOCGLIFNETMASK: %.*s: %s",
(int)sizeof(ifrnetmask.lifr_name),
ifrnetmask.lifr_name,
@@ -261,7 +250,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
*/
broadaddr = NULL;
} else {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"SIOCGLIFBRDADDR: %.*s: %s",
(int)sizeof(ifrbroadaddr.lifr_name),
ifrbroadaddr.lifr_name,
@@ -296,7 +285,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
*/
dstaddr = NULL;
} else {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"SIOCGLIFDSTADDR: %.*s: %s",
(int)sizeof(ifrdstaddr.lifr_name),
ifrdstaddr.lifr_name,
@@ -341,7 +330,8 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
* Add information for this address to the list.
*/
if (add_addr_to_iflist(&devlist, ifrp->lifr_name,
- ifrflags.lifr_flags, (struct sockaddr *)&ifrp->lifr_addr,
+ if_flags_to_pcap_flags(ifrp->lifr_name, ifrflags.lifr_flags),
+ (struct sockaddr *)&ifrp->lifr_addr,
sizeof (struct sockaddr_storage),
netmask, sizeof (struct sockaddr_storage),
broadaddr, sizeof (struct sockaddr_storage),
diff --git a/fad-helpers.c b/fad-helpers.c
new file mode 100644
index 000000000000..4860bc55ca80
--- /dev/null
+++ b/fad-helpers.c
@@ -0,0 +1,884 @@
+/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
+/*
+ * Copyright (c) 1994, 1995, 1996, 1997, 1998
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the Computer Systems
+ * Engineering Group at Lawrence Berkeley Laboratory.
+ * 4. Neither the name of the University nor of the Laboratory may be used
+ * to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef _WIN32
+#include <pcap-stdinc.h>
+#else /* _WIN32 */
+
+#include <sys/param.h>
+#ifndef MSDOS
+#include <sys/file.h>
+#endif
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#ifdef HAVE_SYS_SOCKIO_H
+#include <sys/sockio.h>
+#endif
+
+struct mbuf; /* Squelch compiler warnings on some platforms for */
+struct rtentry; /* declarations in <net/if.h> */
+#include <net/if.h>
+#include <netinet/in.h>
+#endif /* _WIN32 */
+
+#include <ctype.h>
+#include <errno.h>
+#include <memory.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#if !defined(_WIN32) && !defined(__BORLANDC__)
+#include <unistd.h>
+#endif /* !_WIN32 && !__BORLANDC__ */
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#else
+#define INT_MAX 2147483647
+#endif
+
+#include "pcap-int.h"
+
+#ifdef HAVE_OS_PROTO_H
+#include "os-proto.h"
+#endif
+
+#ifndef _WIN32
+/* Not all systems have IFF_LOOPBACK */
+#ifdef IFF_LOOPBACK
+#define ISLOOPBACK(name, flags) ((flags) & IFF_LOOPBACK)
+#else
+#define ISLOOPBACK(name, flags) ((name)[0] == 'l' && (name)[1] == 'o' && \
+ (isdigit((unsigned char)((name)[2])) || (name)[2] == '\0'))
+#endif
+
+#ifdef IFF_UP
+#define ISUP(flags) ((flags) & IFF_UP)
+#else
+#define ISUP(flags) 0
+#endif
+
+#ifdef IFF_RUNNING
+#define ISRUNNING(flags) ((flags) & IFF_RUNNING)
+#else
+#define ISRUNNING(flags) 0
+#endif
+
+/*
+ * Map UN*X-style interface flags to libpcap flags.
+ */
+bpf_u_int32
+if_flags_to_pcap_flags(const char *name _U_, u_int if_flags)
+{
+ bpf_u_int32 pcap_flags;
+
+ pcap_flags = 0;
+ if (ISLOOPBACK(name, if_flags))
+ pcap_flags |= PCAP_IF_LOOPBACK;
+ if (ISUP(if_flags))
+ pcap_flags |= PCAP_IF_UP;
+ if (ISRUNNING(if_flags))
+ pcap_flags |= PCAP_IF_RUNNING;
+ return (pcap_flags);
+}
+#endif
+
+static struct sockaddr *
+dup_sockaddr(struct sockaddr *sa, size_t sa_length)
+{
+ struct sockaddr *newsa;
+
+ if ((newsa = malloc(sa_length)) == NULL)
+ return (NULL);
+ return (memcpy(newsa, sa, sa_length));
+}
+
+/*
+ * Construct a "figure of merit" for an interface, for use when sorting
+ * the list of interfaces, in which interfaces that are up are superior
+ * to interfaces that aren't up, interfaces that are up and running are
+ * superior to interfaces that are up but not running, and non-loopback
+ * interfaces that are up and running are superior to loopback interfaces,
+ * and interfaces with the same flags have a figure of merit that's higher
+ * the lower the instance number.
+ *
+ * The goal is to try to put the interfaces most likely to be useful for
+ * capture at the beginning of the list.
+ *
+ * The figure of merit, which is lower the "better" the interface is,
+ * has the uppermost bit set if the interface isn't running, the bit
+ * below that set if the interface isn't up, the bit below that set
+ * if the interface is a loopback interface, and the interface index
+ * in the 29 bits below that. (Yes, we assume u_int is 32 bits.)
+ */
+static u_int
+get_figure_of_merit(pcap_if_t *dev)
+{
+ const char *cp;
+ u_int n;
+
+ if (strcmp(dev->name, "any") == 0) {
+ /*
+ * Give the "any" device an artificially high instance
+ * number, so it shows up after all other non-loopback
+ * interfaces.
+ */
+ n = 0x1FFFFFFF; /* 29 all-1 bits */
+ } else {
+ /*
+ * A number at the end of the device name string is
+ * assumed to be a unit number.
+ */
+ cp = dev->name + strlen(dev->name) - 1;
+ while (cp-1 >= dev->name && *(cp-1) >= '0' && *(cp-1) <= '9')
+ cp--;
+ if (*cp >= '0' && *cp <= '9')
+ n = atoi(cp);
+ else
+ n = 0;
+ }
+ if (!(dev->flags & PCAP_IF_RUNNING))
+ n |= 0x80000000;
+ if (!(dev->flags & PCAP_IF_UP))
+ n |= 0x40000000;
+ if (dev->flags & PCAP_IF_LOOPBACK)
+ n |= 0x20000000;
+ return (n);
+}
+
+/*
+ * Try to get a description for a given device.
+ * Returns a mallocated description if it could and NULL if it couldn't.
+ *
+ * XXX - on FreeBSDs that support it, should it get the sysctl named
+ * "dev.{adapter family name}.{adapter unit}.%desc" to get a description
+ * of the adapter? Note that "dev.an.0.%desc" is "Aironet PC4500/PC4800"
+ * with my Cisco 350 card, so the name isn't entirely descriptive. The
+ * "dev.an.0.%pnpinfo" has a better description, although one might argue
+ * that the problem is really a driver bug - if it can find out that it's
+ * a Cisco 340 or 350, rather than an old Aironet card, it should use
+ * that in the description.
+ *
+ * Do NetBSD, DragonflyBSD, or OpenBSD support this as well? FreeBSD
+ * and OpenBSD let you get a description, but it's not generated by the OS,
+ * it's set with another ioctl that ifconfig supports; we use that to get
+ * a description in FreeBSD and OpenBSD, but if there is no such
+ * description available, it still might be nice to get some description
+ * string based on the device type or something such as that.
+ *
+ * In OS X, the System Configuration framework can apparently return
+ * names in 10.4 and later.
+ *
+ * It also appears that freedesktop.org's HAL offers an "info.product"
+ * string, but the HAL specification says it "should not be used in any
+ * UI" and "subsystem/capability specific properties" should be used
+ * instead and, in any case, I think HAL is being deprecated in
+ * favor of other stuff such as DeviceKit. DeviceKit doesn't appear
+ * to have any obvious product information for devices, but maybe
+ * I haven't looked hard enough.
+ *
+ * Using the System Configuration framework, or HAL, or DeviceKit, or
+ * whatever, would require that libpcap applications be linked with
+ * the frameworks/libraries in question. That shouldn't be a problem
+ * for programs linking with the shared version of libpcap (unless
+ * you're running on AIX - which I think is the only UN*X that doesn't
+ * support linking a shared library with other libraries on which it
+ * depends, and having an executable linked only with the first shared
+ * library automatically pick up the other libraries when started -
+ * and using HAL or whatever). Programs linked with the static
+ * version of libpcap would have to use pcap-config with the --static
+ * flag in order to get the right linker flags in order to pick up
+ * the additional libraries/frameworks; those programs need that anyway
+ * for libpcap 1.1 and beyond on Linux, as, by default, it requires
+ * -lnl.
+ *
+ * Do any other UN*Xes, or desktop environments support getting a
+ * description?
+ */
+static char *
+get_if_description(const char *name)
+{
+#ifdef SIOCGIFDESCR
+ char *description = NULL;
+ int s;
+ struct ifreq ifrdesc;
+#ifndef IFDESCRSIZE
+ size_t descrlen = 64;
+#else
+ size_t descrlen = IFDESCRSIZE;
+#endif /* IFDESCRSIZE */
+
+ /*
+ * Get the description for the interface.
+ */
+ memset(&ifrdesc, 0, sizeof ifrdesc);
+ strlcpy(ifrdesc.ifr_name, name, sizeof ifrdesc.ifr_name);
+ s = socket(AF_INET, SOCK_DGRAM, 0);
+ if (s >= 0) {
+#ifdef __FreeBSD__
+ /*
+ * On FreeBSD, if the buffer isn't big enough for the
+ * description, the ioctl succeeds, but the description
+ * isn't copied, ifr_buffer.length is set to the description
+ * length, and ifr_buffer.buffer is set to NULL.
+ */
+ for (;;) {
+ free(description);
+ if ((description = malloc(descrlen)) != NULL) {
+ ifrdesc.ifr_buffer.buffer = description;
+ ifrdesc.ifr_buffer.length = descrlen;
+ if (ioctl(s, SIOCGIFDESCR, &ifrdesc) == 0) {
+ if (ifrdesc.ifr_buffer.buffer ==
+ description)
+ break;
+ else
+ descrlen = ifrdesc.ifr_buffer.length;
+ } else {
+ /*
+ * Failed to get interface description.
+ */
+ free(description);
+ description = NULL;
+ break;
+ }
+ } else
+ break;
+ }
+#else /* __FreeBSD__ */
+ /*
+ * The only other OS that currently supports
+ * SIOCGIFDESCR is OpenBSD, and it has no way
+ * to get the description length - it's clamped
+ * to a maximum of IFDESCRSIZE.
+ */
+ if ((description = malloc(descrlen)) != NULL) {
+ ifrdesc.ifr_data = (caddr_t)description;
+ if (ioctl(s, SIOCGIFDESCR, &ifrdesc) != 0) {
+ /*
+ * Failed to get interface description.
+ */
+ free(description);
+ description = NULL;
+ }
+ }
+#endif /* __FreeBSD__ */
+ close(s);
+ if (description != NULL && strlen(description) == 0) {
+ /*
+ * Description is empty, so discard it.
+ */
+ free(description);
+ description = NULL;
+ }
+ }
+
+#ifdef __FreeBSD__
+ /*
+ * For FreeBSD, if we didn't get a description, and this is
+ * a device with a name of the form usbusN, label it as a USB
+ * bus.
+ */
+ if (description == NULL) {
+ if (strncmp(name, "usbus", 5) == 0) {
+ /*
+ * OK, it begins with "usbus".
+ */
+ long busnum;
+ char *p;
+
+ errno = 0;
+ busnum = strtol(name + 5, &p, 10);
+ if (errno == 0 && p != name + 5 && *p == '\0' &&
+ busnum >= 0 && busnum <= INT_MAX) {
+ /*
+ * OK, it's a valid number that's not
+ * bigger than INT_MAX. Construct
+ * a description from it.
+ */
+ static const char descr_prefix[] = "USB bus number ";
+ size_t descr_size;
+
+ /*
+ * Allow enough room for a 32-bit bus number.
+ * sizeof (descr_prefix) includes the
+ * terminating NUL.
+ */
+ descr_size = sizeof (descr_prefix) + 10;
+ description = malloc(descr_size);
+ if (description != NULL) {
+ pcap_snprintf(description, descr_size,
+ "%s%ld", descr_prefix, busnum);
+ }
+ }
+ }
+ }
+#endif
+ return (description);
+#else /* SIOCGIFDESCR */
+ return (NULL);
+#endif /* SIOCGIFDESCR */
+}
+
+/*
+ * Look for a given device in the specified list of devices.
+ *
+ * If we find it, return 0 and set *curdev_ret to point to it.
+ *
+ * If we don't find it, check whether we can open it:
+ *
+ * If that fails with PCAP_ERROR_NO_SUCH_DEVICE or
+ * PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for
+ * it, as that probably means it exists but doesn't support
+ * packet capture.
+ *
+ * Otherwise, attempt to add an entry for it, with the specified
+ * ifnet flags and description, and, if that succeeds, return 0
+ * and set *curdev_ret to point to the new entry, otherwise
+ * return PCAP_ERROR and set errbuf to an error message. If we
+ * weren't given a description, try to get one.
+ */
+int
+add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name,
+ bpf_u_int32 flags, const char *description, char *errbuf)
+{
+ pcap_t *p;
+ pcap_if_t *curdev, *prevdev, *nextdev;
+ u_int this_figure_of_merit, nextdev_figure_of_merit;
+ char open_errbuf[PCAP_ERRBUF_SIZE];
+ int ret;
+
+ /*
+ * Is there already an entry in the list for this interface?
+ */
+ for (curdev = *alldevs; curdev != NULL; curdev = curdev->next) {
+ if (strcmp(name, curdev->name) == 0)
+ break; /* yes, we found it */
+ }
+
+ if (curdev == NULL) {
+ /*
+ * No, we didn't find it.
+ *
+ * Can we open this interface for live capture?
+ *
+ * We do this check so that interfaces that are
+ * supplied by the interface enumeration mechanism
+ * we're using but that don't support packet capture
+ * aren't included in the list. Loopback interfaces
+ * on Solaris are an example of this; we don't just
+ * omit loopback interfaces on all platforms because
+ * you *can* capture on loopback interfaces on some
+ * OSes.
+ *
+ * On OS X, we don't do this check if the device
+ * name begins with "wlt"; at least some versions
+ * of OS X offer monitor mode capturing by having
+ * a separate "monitor mode" device for each wireless
+ * adapter, rather than by implementing the ioctls
+ * that {Free,Net,Open,DragonFly}BSD provide.
+ * Opening that device puts the adapter into monitor
+ * mode, which, at least for some adapters, causes
+ * them to deassociate from the network with which
+ * they're associated.
+ *
+ * Instead, we try to open the corresponding "en"
+ * device (so that we don't end up with, for users
+ * without sufficient privilege to open capture
+ * devices, a list of adapters that only includes
+ * the wlt devices).
+ */
+#ifdef __APPLE__
+ if (strncmp(name, "wlt", 3) == 0) {
+ char *en_name;
+ size_t en_name_len;
+
+ /*
+ * Try to allocate a buffer for the "en"
+ * device's name.
+ */
+ en_name_len = strlen(name) - 1;
+ en_name = malloc(en_name_len + 1);
+ if (en_name == NULL) {
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "malloc: %s", pcap_strerror(errno));
+ return (-1);
+ }
+ strcpy(en_name, "en");
+ strcat(en_name, name + 3);
+ p = pcap_create(en_name, open_errbuf);
+ free(en_name);
+ } else
+#endif /* __APPLE */
+ p = pcap_create(name, open_errbuf);
+ if (p == NULL) {
+ /*
+ * The attempt to create the pcap_t failed;
+ * that's probably an indication that we're
+ * out of memory.
+ *
+ * Don't bother including this interface,
+ * but don't treat it as an error.
+ */
+ *curdev_ret = NULL;
+ return (0);
+ }
+ /* Small snaplen, so we don't try to allocate much memory. */
+ pcap_set_snaplen(p, 68);
+ ret = pcap_activate(p);
+ pcap_close(p);
+ switch (ret) {
+
+ case PCAP_ERROR_NO_SUCH_DEVICE:
+ case PCAP_ERROR_IFACE_NOT_UP:
+ /*
+ * We expect these two errors - they're the
+ * reason we try to open the device.
+ *
+ * PCAP_ERROR_NO_SUCH_DEVICE typically means
+ * "there's no such device *known to the
+ * OS's capture mechanism*", so, even though
+ * it might be a valid network interface, you
+ * can't capture on it (e.g., the loopback
+ * device in Solaris up to Solaris 10, or
+ * the vmnet devices in OS X with VMware
+ * Fusion). We don't include those devices
+ * in our list of devices, as there's no
+ * point in doing so - they're not available
+ * for capture.
+ *
+ * PCAP_ERROR_IFACE_NOT_UP means that the
+ * OS's capture mechanism doesn't work on
+ * interfaces not marked as up; some capture
+ * mechanisms *do* support that, so we no
+ * longer reject those interfaces out of hand,
+ * but we *do* want to reject them if they
+ * can't be opened for capture.
+ */
+ *curdev_ret = NULL;
+ return (0);
+ }
+
+ /*
+ * Yes, we can open it, or we can't, for some other
+ * reason.
+ *
+ * If we can open it, we want to offer it for
+ * capture, as you can capture on it. If we can't,
+ * we want to offer it for capture, so that, if
+ * the user tries to capture on it, they'll get
+ * an error and they'll know why they can't
+ * capture on it (e.g., insufficient permissions)
+ * or they'll report it as a problem (and then
+ * have the error message to provide as information).
+ *
+ * Allocate a new entry.
+ */
+ curdev = malloc(sizeof(pcap_if_t));
+ if (curdev == NULL) {
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "malloc: %s", pcap_strerror(errno));
+ return (-1);
+ }
+
+ /*
+ * Fill in the entry.
+ */
+ curdev->next = NULL;
+ curdev->name = strdup(name);
+ if (curdev->name == NULL) {
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "malloc: %s", pcap_strerror(errno));
+ free(curdev);
+ return (-1);
+ }
+ if (description == NULL) {
+ /*
+ * We weren't handed a description for the
+ * interface, so see if we can generate one
+ * ourselves.
+ */
+ curdev->description = get_if_description(name);
+ } else {
+ /*
+ * We were handed a description; make a copy.
+ */
+ curdev->description = strdup(description);
+ if (curdev->description == NULL) {
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "malloc: %s", pcap_strerror(errno));
+ free(curdev->name);
+ free(curdev);
+ return (-1);
+ }
+ }
+ curdev->addresses = NULL; /* list starts out as empty */
+ curdev->flags = flags;
+
+ /*
+ * Add it to the list, in the appropriate location.
+ * First, get the "figure of merit" for this
+ * interface.
+ */
+ this_figure_of_merit = get_figure_of_merit(curdev);
+
+ /*
+ * Now look for the last interface with an figure of merit
+ * less than or equal to the new interface's figure of
+ * merit.
+ *
+ * We start with "prevdev" being NULL, meaning we're before
+ * the first element in the list.
+ */
+ prevdev = NULL;
+ for (;;) {
+ /*
+ * Get the interface after this one.
+ */
+ if (prevdev == NULL) {
+ /*
+ * The next element is the first element.
+ */
+ nextdev = *alldevs;
+ } else
+ nextdev = prevdev->next;
+
+ /*
+ * Are we at the end of the list?
+ */
+ if (nextdev == NULL) {
+ /*
+ * Yes - we have to put the new entry
+ * after "prevdev".
+ */
+ break;
+ }
+
+ /*
+ * Is the new interface's figure of merit less
+ * than the next interface's figure of merit,
+ * meaning that the new interface is better
+ * than the next interface?
+ */
+ nextdev_figure_of_merit = get_figure_of_merit(nextdev);
+ if (this_figure_of_merit < nextdev_figure_of_merit) {
+ /*
+ * Yes - we should put the new entry
+ * before "nextdev", i.e. after "prevdev".
+ */
+ break;
+ }
+
+ prevdev = nextdev;
+ }
+
+ /*
+ * Insert before "nextdev".
+ */
+ curdev->next = nextdev;
+
+ /*
+ * Insert after "prevdev" - unless "prevdev" is null,
+ * in which case this is the first interface.
+ */
+ if (prevdev == NULL) {
+ /*
+ * This is the first interface. Pass back a
+ * pointer to it, and put "curdev" before
+ * "nextdev".
+ */
+ *alldevs = curdev;
+ } else
+ prevdev->next = curdev;
+ }
+
+ *curdev_ret = curdev;
+ return (0);
+}
+
+/*
+ * Try to get a description for a given device, and then look for that
+ * device in the specified list of devices.
+ *
+ * If we find it, then, if the specified address isn't null, add it to
+ * the list of addresses for the device and return 0.
+ *
+ * If we don't find it, check whether we can open it:
+ *
+ * If that fails with PCAP_ERROR_NO_SUCH_DEVICE or
+ * PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for
+ * it, as that probably means it exists but doesn't support
+ * packet capture.
+ *
+ * Otherwise, attempt to add an entry for it, with the specified
+ * ifnet flags, and, if that succeeds, add the specified address
+ * to its list of addresses if that address is non-null, set
+ * *curdev_ret to point to the new entry, and return 0, otherwise
+ * return PCAP_ERROR and set errbuf to an error message.
+ *
+ * (We can get called with a null address because we might get a list
+ * of interface name/address combinations from the underlying OS, with
+ * the address being absent in some cases, rather than a list of
+ * interfaces with each interface having a list of addresses, so this
+ * call may be the only call made to add to the list, and we want to
+ * add interfaces even if they have no addresses.)
+ */
+int
+add_addr_to_iflist(pcap_if_t **alldevs, const char *name, bpf_u_int32 flags,
+ struct sockaddr *addr, size_t addr_size,
+ struct sockaddr *netmask, size_t netmask_size,
+ struct sockaddr *broadaddr, size_t broadaddr_size,
+ struct sockaddr *dstaddr, size_t dstaddr_size,
+ char *errbuf)
+{
+ pcap_if_t *curdev;
+
+ if (add_or_find_if(&curdev, alldevs, name, flags, NULL, errbuf) == -1) {
+ /*
+ * Error - give up.
+ */
+ return (-1);
+ }
+ if (curdev == NULL) {
+ /*
+ * Device wasn't added because it can't be opened.
+ * Not a fatal error.
+ */
+ return (0);
+ }
+
+ if (addr == NULL) {
+ /*
+ * There's no address to add; this entry just meant
+ * "here's a new interface".
+ */
+ return (0);
+ }
+
+ /*
+ * "curdev" is an entry for this interface, and we have an
+ * address for it; add an entry for that address to the
+ * interface's list of addresses.
+ *
+ * Allocate the new entry and fill it in.
+ */
+ return (add_addr_to_dev(curdev, addr, addr_size, netmask,
+ netmask_size, broadaddr, broadaddr_size, dstaddr,
+ dstaddr_size, errbuf));
+}
+
+/*
+ * Add an entry to the list of addresses for an interface.
+ * "curdev" is the entry for that interface.
+ * If this is the first IP address added to the interface, move it
+ * in the list as appropriate.
+ */
+int
+add_addr_to_dev(pcap_if_t *curdev,
+ struct sockaddr *addr, size_t addr_size,
+ struct sockaddr *netmask, size_t netmask_size,
+ struct sockaddr *broadaddr, size_t broadaddr_size,
+ struct sockaddr *dstaddr, size_t dstaddr_size,
+ char *errbuf)
+{
+ pcap_addr_t *curaddr, *prevaddr, *nextaddr;
+
+ curaddr = malloc(sizeof(pcap_addr_t));
+ if (curaddr == NULL) {
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "malloc: %s", pcap_strerror(errno));
+ return (-1);
+ }
+
+ curaddr->next = NULL;
+ if (addr != NULL) {
+ curaddr->addr = dup_sockaddr(addr, addr_size);
+ if (curaddr->addr == NULL) {
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "malloc: %s", pcap_strerror(errno));
+ free(curaddr);
+ return (-1);
+ }
+ } else
+ curaddr->addr = NULL;
+
+ if (netmask != NULL) {
+ curaddr->netmask = dup_sockaddr(netmask, netmask_size);
+ if (curaddr->netmask == NULL) {
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "malloc: %s", pcap_strerror(errno));
+ if (curaddr->addr != NULL)
+ free(curaddr->addr);
+ free(curaddr);
+ return (-1);
+ }
+ } else
+ curaddr->netmask = NULL;
+
+ if (broadaddr != NULL) {
+ curaddr->broadaddr = dup_sockaddr(broadaddr, broadaddr_size);
+ if (curaddr->broadaddr == NULL) {
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "malloc: %s", pcap_strerror(errno));
+ if (curaddr->netmask != NULL)
+ free(curaddr->netmask);
+ if (curaddr->addr != NULL)
+ free(curaddr->addr);
+ free(curaddr);
+ return (-1);
+ }
+ } else
+ curaddr->broadaddr = NULL;
+
+ if (dstaddr != NULL) {
+ curaddr->dstaddr = dup_sockaddr(dstaddr, dstaddr_size);
+ if (curaddr->dstaddr == NULL) {
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "malloc: %s", pcap_strerror(errno));
+ if (curaddr->broadaddr != NULL)
+ free(curaddr->broadaddr);
+ if (curaddr->netmask != NULL)
+ free(curaddr->netmask);
+ if (curaddr->addr != NULL)
+ free(curaddr->addr);
+ free(curaddr);
+ return (-1);
+ }
+ } else
+ curaddr->dstaddr = NULL;
+
+ /*
+ * Find the end of the list of addresses.
+ */
+ for (prevaddr = curdev->addresses; prevaddr != NULL; prevaddr = nextaddr) {
+ nextaddr = prevaddr->next;
+ if (nextaddr == NULL) {
+ /*
+ * This is the end of the list.
+ */
+ break;
+ }
+ }
+
+ if (prevaddr == NULL) {
+ /*
+ * The list was empty; this is the first member.
+ */
+ curdev->addresses = curaddr;
+ } else {
+ /*
+ * "prevaddr" is the last member of the list; append
+ * this member to it.
+ */
+ prevaddr->next = curaddr;
+ }
+
+ return (0);
+}
+
+/*
+ * Look for a given device in the specified list of devices.
+ *
+ * If we find it, return 0.
+ *
+ * If we don't find it, check whether we can open it:
+ *
+ * If that fails with PCAP_ERROR_NO_SUCH_DEVICE or
+ * PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for
+ * it, as that probably means it exists but doesn't support
+ * packet capture.
+ *
+ * Otherwise, attempt to add an entry for it, with the specified
+ * ifnet flags and description, and, if that succeeds, return 0
+ * and set *curdev_ret to point to the new entry, otherwise
+ * return PCAP_ERROR and set errbuf to an error message.
+ */
+int
+pcap_add_if(pcap_if_t **devlist, const char *name, u_int flags,
+ const char *description, char *errbuf)
+{
+ pcap_if_t *curdev;
+
+ return (add_or_find_if(&curdev, devlist, name, flags, description,
+ errbuf));
+}
+
+
+/*
+ * Free a list of interfaces.
+ */
+void
+pcap_freealldevs(pcap_if_t *alldevs)
+{
+ pcap_if_t *curdev, *nextdev;
+ pcap_addr_t *curaddr, *nextaddr;
+
+ for (curdev = alldevs; curdev != NULL; curdev = nextdev) {
+ nextdev = curdev->next;
+
+ /*
+ * Free all addresses.
+ */
+ for (curaddr = curdev->addresses; curaddr != NULL; curaddr = nextaddr) {
+ nextaddr = curaddr->next;
+ if (curaddr->addr)
+ free(curaddr->addr);
+ if (curaddr->netmask)
+ free(curaddr->netmask);
+ if (curaddr->broadaddr)
+ free(curaddr->broadaddr);
+ if (curaddr->dstaddr)
+ free(curaddr->dstaddr);
+ free(curaddr);
+ }
+
+ /*
+ * Free the name string.
+ */
+ free(curdev->name);
+
+ /*
+ * Free the description string, if any.
+ */
+ if (curdev->description != NULL)
+ free(curdev->description);
+
+ /*
+ * Free the interface.
+ */
+ free(curdev);
+ }
+}
diff --git a/fad-sita.c b/fad-sita.c
deleted file mode 100644
index 34ddf1d85186..000000000000
--- a/fad-sita.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * fad-sita.c: Packet capture interface additions for SITA ACN devices
- *
- * Copyright (c) 2007 Fulko Hew, SITA INC Canada, Inc <fulko.hew@sita.aero>
- *
- * License: BSD
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. The names of the authors may not be used to endorse or promote
- * products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include "pcap-int.h"
-
-#include "pcap-sita.h"
-
-extern pcap_if_t *acn_if_list; /* pcap's list of available interfaces */
-
-int pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf) {
-
- //printf("pcap_findalldevs()\n"); // fulko
-
- *alldevsp = 0; /* initialize the returned variables before we do anything */
- strcpy(errbuf, "");
- if (acn_parse_hosts_file(errbuf)) /* scan the hosts file for potential IOPs */
- {
- //printf("pcap_findalldevs() returning BAD after parsehosts\n"); // fulko
- return -1;
- }
- //printf("pcap_findalldevs() got hostlist now finding devs\n"); // fulko
- if (acn_findalldevs(errbuf)) /* then ask the IOPs for their monitorable devices */
- {
- //printf("pcap_findalldevs() returning BAD after findalldevs\n"); // fulko
- return -1;
- }
- *alldevsp = acn_if_list;
- acn_if_list = 0; /* then forget our list head, because someone will call pcap_freealldevs() to empty the malloc'ed stuff */
- //printf("pcap_findalldevs() returning ZERO OK\n"); // fulko
- return 0;
-}
diff --git a/fad-win32.c b/fad-win32.c
deleted file mode 100644
index 0de893ef5487..000000000000
--- a/fad-win32.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright (c) 2002 - 2005 NetGroup, Politecnico di Torino (Italy)
- * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the Politecnico di Torino, CACE Technologies
- * nor the names of its contributors may be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <pcap.h>
-#include <pcap-int.h>
-#include <Packet32.h>
-
-#include <errno.h>
-
-static int
-pcap_add_if_win32(pcap_if_t **devlist, char *name, const char *desc,
- char *errbuf)
-{
- pcap_if_t *curdev;
- npf_if_addr if_addrs[MAX_NETWORK_ADDRESSES];
- LONG if_addr_size;
- int res = 0;
-
- if_addr_size = MAX_NETWORK_ADDRESSES;
-
- /*
- * Add an entry for this interface, with no addresses.
- */
- if (add_or_find_if(&curdev, devlist, name, 0, desc, errbuf) == -1) {
- /*
- * Failure.
- */
- return (-1);
- }
-
- /*
- * Get the list of addresses for the interface.
- */
- if (!PacketGetNetInfoEx((void *)name, if_addrs, &if_addr_size)) {
- /*
- * Failure.
- *
- * We don't return an error, because this can happen with
- * NdisWan interfaces, and we want to supply them even
- * if we can't supply their addresses.
- *
- * We return an entry with an empty address list.
- */
- return (0);
- }
-
- /*
- * Now add the addresses.
- */
- while (if_addr_size-- > 0) {
- /*
- * "curdev" is an entry for this interface; add an entry for
- * this address to its list of addresses.
- */
- if(curdev == NULL)
- break;
- res = add_addr_to_dev(curdev,
- (struct sockaddr *)&if_addrs[if_addr_size].IPAddress,
- sizeof (struct sockaddr_storage),
- (struct sockaddr *)&if_addrs[if_addr_size].SubnetMask,
- sizeof (struct sockaddr_storage),
- (struct sockaddr *)&if_addrs[if_addr_size].Broadcast,
- sizeof (struct sockaddr_storage),
- NULL,
- 0,
- errbuf);
- if (res == -1) {
- /*
- * Failure.
- */
- break;
- }
- }
-
- return (res);
-}
-
-
-/*
- * Get a list of all interfaces that are up and that we can open.
- * Returns -1 on error, 0 otherwise.
- * The list, as returned through "alldevsp", may be null if no interfaces
- * were up and could be opened.
- *
- * Win32 implementation, based on WinPcap
- */
-int
-pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
-{
- pcap_if_t *devlist = NULL;
- int ret = 0;
- const char *desc;
- char *AdaptersName;
- ULONG NameLength;
- char *name;
-
- /*
- * Find out how big a buffer we need.
- *
- * This call should always return FALSE; if the error is
- * ERROR_INSUFFICIENT_BUFFER, NameLength will be set to
- * the size of the buffer we need, otherwise there's a
- * problem, and NameLength should be set to 0.
- *
- * It shouldn't require NameLength to be set, but,
- * at least as of WinPcap 4.1.3, it checks whether
- * NameLength is big enough before it checks for a
- * NULL buffer argument, so, while it'll still do
- * the right thing if NameLength is uninitialized and
- * whatever junk happens to be there is big enough
- * (because the pointer argument will be null), it's
- * still reading an uninitialized variable.
- */
- NameLength = 0;
- if (!PacketGetAdapterNames(NULL, &NameLength))
- {
- DWORD last_error = GetLastError();
-
- if (last_error != ERROR_INSUFFICIENT_BUFFER)
- {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
- "PacketGetAdapterNames: %s",
- pcap_win32strerror());
- return (-1);
- }
- }
-
- if (NameLength > 0)
- AdaptersName = (char*) malloc(NameLength);
- else
- {
- *alldevsp = NULL;
- return 0;
- }
- if (AdaptersName == NULL)
- {
- snprintf(errbuf, PCAP_ERRBUF_SIZE, "Cannot allocate enough memory to list the adapters.");
- return (-1);
- }
-
- if (!PacketGetAdapterNames(AdaptersName, &NameLength)) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
- "PacketGetAdapterNames: %s",
- pcap_win32strerror());
- free(AdaptersName);
- return (-1);
- }
-
- /*
- * "PacketGetAdapterNames()" returned a list of
- * null-terminated ASCII interface name strings,
- * terminated by a null string, followed by a list
- * of null-terminated ASCII interface description
- * strings, terminated by a null string.
- * This means there are two ASCII nulls at the end
- * of the first list.
- *
- * Find the end of the first list; that's the
- * beginning of the second list.
- */
- desc = &AdaptersName[0];
- while (*desc != '\0' || *(desc + 1) != '\0')
- desc++;
-
- /*
- * Found it - "desc" points to the first of the two
- * nulls at the end of the list of names, so the
- * first byte of the list of descriptions is two bytes
- * after it.
- */
- desc += 2;
-
- /*
- * Loop over the elements in the first list.
- */
- name = &AdaptersName[0];
- while (*name != '\0') {
- /*
- * Add an entry for this interface.
- */
- if (pcap_add_if_win32(&devlist, name, desc, errbuf) == -1) {
- /*
- * Failure.
- */
- ret = -1;
- break;
- }
- name += strlen(name) + 1;
- desc += strlen(desc) + 1;
- }
-
- if (ret != -1) {
- /*
- * We haven't had any errors yet; do any platform-specific
- * operations to add devices.
- */
- if (pcap_platform_finddevs(&devlist, errbuf) < 0)
- ret = -1;
- }
-
- if (ret == -1) {
- /*
- * We had an error; free the list we've been constructing.
- */
- if (devlist != NULL) {
- pcap_freealldevs(devlist);
- devlist = NULL;
- }
- }
-
- *alldevsp = devlist;
- free(AdaptersName);
- return (ret);
-}
diff --git a/gen_version_c.sh b/gen_version_c.sh
new file mode 100755
index 000000000000..d5a5e75bfec8
--- /dev/null
+++ b/gen_version_c.sh
@@ -0,0 +1,11 @@
+#! /bin/sh
+echo '#include <pcap/export-defs.h>' > "$2"
+echo 'PCAP_API_DEF' >> "$2"
+if grep GIT "$1" >/dev/null; then
+ read ver <"$1"
+ echo $ver | tr -d '\012'
+ date +_%Y_%m_%d
+else
+ cat "$1"
+fi | sed -e 's/.*/char pcap_version[] = "&";/' >> "$2"
+
diff --git a/gen_version_header.sh b/gen_version_header.sh
new file mode 100755
index 000000000000..6b4b82da1af7
--- /dev/null
+++ b/gen_version_header.sh
@@ -0,0 +1,19 @@
+#! /bin/sh
+print_version_string()
+{
+ if grep GIT "$1" >/dev/null
+ then
+ read ver <"$1"
+ echo $ver | tr -d '\012'
+ date +_%Y_%m_%d
+ else
+ cat "$1"
+ fi
+}
+if test $# != 3
+then
+ echo "Usage: gen_version_header.sh <version file> <template> <output file>" 1>&2
+ exit 1
+fi
+version_string=`print_version_string "$1"`
+sed "s/%%LIBPCAP_VERSION%%/$version_string/" "$2" >"$3"
diff --git a/gencode.c b/gencode.c
index 4a97aba46d2c..a887f2730f7a 100644
--- a/gencode.c
+++ b/gencode.c
@@ -24,9 +24,9 @@
#include "config.h"
#endif
-#ifdef WIN32
+#ifdef _WIN32
#include <pcap-stdinc.h>
-#else /* WIN32 */
+#else /* _WIN32 */
#if HAVE_INTTYPES_H
#include <inttypes.h>
#elif HAVE_STDINT_H
@@ -37,16 +37,9 @@
#endif
#include <sys/types.h>
#include <sys/socket.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
-/*
- * XXX - why was this included even on UNIX?
- */
-#ifdef __MINGW32__
-#include "ip6_misc.h"
-#endif
-
-#ifndef WIN32
+#ifndef _WIN32
#ifdef __NetBSD__
#include <sys/param.h>
@@ -55,7 +48,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include <stdlib.h>
#include <string.h>
@@ -80,29 +73,86 @@
#include "pcap/sll.h"
#include "pcap/ipnet.h"
#include "arcnet.h"
+
+#include "grammar.h"
+#include "scanner.h"
+
#if defined(linux) && defined(PF_PACKET) && defined(SO_ATTACH_FILTER)
#include <linux/types.h>
#include <linux/if_packet.h>
#include <linux/filter.h>
#endif
+
#ifdef HAVE_NET_PFVAR_H
#include <sys/socket.h>
#include <net/if.h>
#include <net/pfvar.h>
#include <net/if_pflog.h>
#endif
+
#ifndef offsetof
#define offsetof(s, e) ((size_t)&((s *)0)->e)
#endif
+
#ifdef INET6
-#ifndef WIN32
+#ifdef _WIN32
+#if defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF)
+/* IPv6 address */
+struct in6_addr
+ {
+ union
+ {
+ u_int8_t u6_addr8[16];
+ u_int16_t u6_addr16[8];
+ u_int32_t u6_addr32[4];
+ } in6_u;
+#define s6_addr in6_u.u6_addr8
+#define s6_addr16 in6_u.u6_addr16
+#define s6_addr32 in6_u.u6_addr32
+#define s6_addr64 in6_u.u6_addr64
+ };
+
+typedef unsigned short sa_family_t;
+
+#define __SOCKADDR_COMMON(sa_prefix) \
+ sa_family_t sa_prefix##family
+
+/* Ditto, for IPv6. */
+struct sockaddr_in6
+ {
+ __SOCKADDR_COMMON (sin6_);
+ u_int16_t sin6_port; /* Transport layer port # */
+ u_int32_t sin6_flowinfo; /* IPv6 flow information */
+ struct in6_addr sin6_addr; /* IPv6 address */
+ };
+
+#ifndef EAI_ADDRFAMILY
+struct addrinfo {
+ int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
+ int ai_family; /* PF_xxx */
+ int ai_socktype; /* SOCK_xxx */
+ int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
+ size_t ai_addrlen; /* length of ai_addr */
+ char *ai_canonname; /* canonical name for hostname */
+ struct sockaddr *ai_addr; /* binary address */
+ struct addrinfo *ai_next; /* next structure in linked list */
+};
+#endif /* EAI_ADDRFAMILY */
+#endif /* defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF) */
+#else /* _WIN32 */
#include <netdb.h> /* for "struct addrinfo" */
-#endif /* WIN32 */
-#endif /*INET6*/
+#endif /* _WIN32 */
+#endif /* INET6 */
#include <pcap/namedb.h>
+#include "nametoaddr.h"
+
#define ETHERMTU 1500
+#ifndef ETHERTYPE_TEB
+#define ETHERTYPE_TEB 0x6558
+#endif
+
#ifndef IPPROTO_HOPOPTS
#define IPPROTO_HOPOPTS 0
#endif
@@ -119,74 +169,75 @@
#define IPPROTO_SCTP 132
#endif
+#define GENEVE_PORT 6081
+
#ifdef HAVE_OS_PROTO_H
#include "os-proto.h"
#endif
#define JMP(c) ((c)|BPF_JMP|BPF_K)
-/* Locals */
-static jmp_buf top_ctx;
-static pcap_t *bpf_pcap;
-
-/* Hack for updating VLAN, MPLS, and PPPoE offsets. */
-#ifdef WIN32
-static u_int orig_linktype = (u_int)-1, orig_nl = (u_int)-1, label_stack_depth = (u_int)-1;
-#else
-static u_int orig_linktype = -1U, orig_nl = -1U, label_stack_depth = -1U;
-#endif
-
-/* XXX */
-static int pcap_fddipad;
-
-/* VARARGS */
-void
-bpf_error(const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- if (bpf_pcap != NULL)
- (void)vsnprintf(pcap_geterr(bpf_pcap), PCAP_ERRBUF_SIZE,
- fmt, ap);
- va_end(ap);
- longjmp(top_ctx, 1);
- /* NOTREACHED */
+/*
+ * "Push" the current value of the link-layer header type and link-layer
+ * header offset onto a "stack", and set a new value. (It's not a
+ * full-blown stack; we keep only the top two items.)
+ */
+#define PUSH_LINKHDR(cs, new_linktype, new_is_variable, new_constant_part, new_reg) \
+{ \
+ (cs)->prevlinktype = (cs)->linktype; \
+ (cs)->off_prevlinkhdr = (cs)->off_linkhdr; \
+ (cs)->linktype = (new_linktype); \
+ (cs)->off_linkhdr.is_variable = (new_is_variable); \
+ (cs)->off_linkhdr.constant_part = (new_constant_part); \
+ (cs)->off_linkhdr.reg = (new_reg); \
+ (cs)->is_geneve = 0; \
}
-static void init_linktype(pcap_t *);
-
-static void init_regs(void);
-static int alloc_reg(void);
-static void free_reg(int);
+/*
+ * Offset "not set" value.
+ */
+#define OFFSET_NOT_SET 0xffffffffU
-static struct block *root;
+/*
+ * Absolute offsets, which are offsets from the beginning of the raw
+ * packet data, are, in the general case, the sum of a variable value
+ * and a constant value; the variable value may be absent, in which
+ * case the offset is only the constant value, and the constant value
+ * may be zero, in which case the offset is only the variable value.
+ *
+ * bpf_abs_offset is a structure containing all that information:
+ *
+ * is_variable is 1 if there's a variable part.
+ *
+ * constant_part is the constant part of the value, possibly zero;
+ *
+ * if is_variable is 1, reg is the register number for a register
+ * containing the variable value if the register has been assigned,
+ * and -1 otherwise.
+ */
+typedef struct {
+ int is_variable;
+ u_int constant_part;
+ int reg;
+} bpf_abs_offset;
/*
* Value passed to gen_load_a() to indicate what the offset argument
- * is relative to.
+ * is relative to the beginning of.
*/
enum e_offrel {
- OR_PACKET, /* relative to the beginning of the packet */
- OR_LINK, /* relative to the beginning of the link-layer header */
- OR_MACPL, /* relative to the end of the MAC-layer header */
- OR_NET, /* relative to the network-layer header */
- OR_NET_NOSNAP, /* relative to the network-layer header, with no SNAP header at the link layer */
- OR_TRAN_IPV4, /* relative to the transport-layer header, with IPv4 network layer */
- OR_TRAN_IPV6 /* relative to the transport-layer header, with IPv6 network layer */
+ OR_PACKET, /* full packet data */
+ OR_LINKHDR, /* link-layer header */
+ OR_PREVLINKHDR, /* previous link-layer header */
+ OR_LLC, /* 802.2 LLC header */
+ OR_PREVMPLSHDR, /* previous MPLS header */
+ OR_LINKTYPE, /* link-layer type */
+ OR_LINKPL, /* link-layer payload */
+ OR_LINKPL_NOSNAP, /* link-layer payload, with no SNAP header at the link layer */
+ OR_TRAN_IPV4, /* transport-layer header, with IPv4 network layer */
+ OR_TRAN_IPV6 /* transport-layer header, with IPv6 network layer */
};
-#ifdef INET6
-/*
- * As errors are handled by a longjmp, anything allocated must be freed
- * in the longjmp handler, so it must be reachable from that handler.
- * One thing that's allocated is the result of pcap_nametoaddrinfo();
- * it must be freed with freeaddrinfo(). This variable points to any
- * addrinfo structure that would need to be freed.
- */
-static struct addrinfo *ai;
-#endif
-
/*
* We divy out chunks of memory rather than call malloc each time so
* we don't have to worry about leaking memory. It's probably
@@ -198,100 +249,324 @@ static struct addrinfo *ai;
#define NCHUNKS 16
#define CHUNK0SIZE 1024
struct chunk {
- u_int n_left;
+ size_t n_left;
void *m;
};
-static struct chunk chunks[NCHUNKS];
-static int cur_chunk;
+/* Code generator state */
+
+struct _compiler_state {
+ jmp_buf top_ctx;
+ pcap_t *bpf_pcap;
+
+ struct icode ic;
+
+ int snaplen;
+
+ int linktype;
+ int prevlinktype;
+ int outermostlinktype;
+
+ bpf_u_int32 netmask;
+ int no_optimize;
+
+ /* Hack for handling VLAN and MPLS stacks. */
+ u_int label_stack_depth;
+ u_int vlan_stack_depth;
+
+ /* XXX */
+ u_int pcap_fddipad;
+
+#ifdef INET6
+ /*
+ * As errors are handled by a longjmp, anything allocated must
+ * be freed in the longjmp handler, so it must be reachable
+ * from that handler.
+ *
+ * One thing that's allocated is the result of pcap_nametoaddrinfo();
+ * it must be freed with freeaddrinfo(). This variable points to
+ * any addrinfo structure that would need to be freed.
+ */
+ struct addrinfo *ai;
+#endif
+
+ /*
+ * Various code constructs need to know the layout of the packet.
+ * These values give the necessary offsets from the beginning
+ * of the packet data.
+ */
+
+ /*
+ * Absolute offset of the beginning of the link-layer header.
+ */
+ bpf_abs_offset off_linkhdr;
+
+ /*
+ * If we're checking a link-layer header for a packet encapsulated
+ * in another protocol layer, this is the equivalent information
+ * for the previous layers' link-layer header from the beginning
+ * of the raw packet data.
+ */
+ bpf_abs_offset off_prevlinkhdr;
+
+ /*
+ * This is the equivalent information for the outermost layers'
+ * link-layer header.
+ */
+ bpf_abs_offset off_outermostlinkhdr;
+
+ /*
+ * Absolute offset of the beginning of the link-layer payload.
+ */
+ bpf_abs_offset off_linkpl;
+
+ /*
+ * "off_linktype" is the offset to information in the link-layer
+ * header giving the packet type. This is an absolute offset
+ * from the beginning of the packet.
+ *
+ * For Ethernet, it's the offset of the Ethernet type field; this
+ * means that it must have a value that skips VLAN tags.
+ *
+ * For link-layer types that always use 802.2 headers, it's the
+ * offset of the LLC header; this means that it must have a value
+ * that skips VLAN tags.
+ *
+ * For PPP, it's the offset of the PPP type field.
+ *
+ * For Cisco HDLC, it's the offset of the CHDLC type field.
+ *
+ * For BSD loopback, it's the offset of the AF_ value.
+ *
+ * For Linux cooked sockets, it's the offset of the type field.
+ *
+ * off_linktype.constant_part is set to OFFSET_NOT_SET for no
+ * encapsulation, in which case, IP is assumed.
+ */
+ bpf_abs_offset off_linktype;
+
+ /*
+ * TRUE if the link layer includes an ATM pseudo-header.
+ */
+ int is_atm;
+
+ /*
+ * TRUE if "geneve" appeared in the filter; it causes us to
+ * generate code that checks for a Geneve header and assume
+ * that later filters apply to the encapsulated payload.
+ */
+ int is_geneve;
+
+ /*
+ * These are offsets for the ATM pseudo-header.
+ */
+ u_int off_vpi;
+ u_int off_vci;
+ u_int off_proto;
+
+ /*
+ * These are offsets for the MTP2 fields.
+ */
+ u_int off_li;
+ u_int off_li_hsl;
+
+ /*
+ * These are offsets for the MTP3 fields.
+ */
+ u_int off_sio;
+ u_int off_opc;
+ u_int off_dpc;
+ u_int off_sls;
+
+ /*
+ * This is the offset of the first byte after the ATM pseudo_header,
+ * or -1 if there is no ATM pseudo-header.
+ */
+ u_int off_payload;
+
+ /*
+ * These are offsets to the beginning of the network-layer header.
+ * They are relative to the beginning of the link-layer payload
+ * (i.e., they don't include off_linkhdr.constant_part or
+ * off_linkpl.constant_part).
+ *
+ * If the link layer never uses 802.2 LLC:
+ *
+ * "off_nl" and "off_nl_nosnap" are the same.
+ *
+ * If the link layer always uses 802.2 LLC:
+ *
+ * "off_nl" is the offset if there's a SNAP header following
+ * the 802.2 header;
+ *
+ * "off_nl_nosnap" is the offset if there's no SNAP header.
+ *
+ * If the link layer is Ethernet:
+ *
+ * "off_nl" is the offset if the packet is an Ethernet II packet
+ * (we assume no 802.3+802.2+SNAP);
+ *
+ * "off_nl_nosnap" is the offset if the packet is an 802.3 packet
+ * with an 802.2 header following it.
+ */
+ u_int off_nl;
+ u_int off_nl_nosnap;
+
+ /*
+ * Here we handle simple allocation of the scratch registers.
+ * If too many registers are alloc'd, the allocator punts.
+ */
+ int regused[BPF_MEMWORDS];
+ int curreg;
+
+ /*
+ * Memory chunks.
+ */
+ struct chunk chunks[NCHUNKS];
+ int cur_chunk;
+};
+
+void
+bpf_syntax_error(compiler_state_t *cstate, const char *msg)
+{
+ bpf_error(cstate, "syntax error in filter expression: %s", msg);
+ /* NOTREACHED */
+}
-static void *newchunk(u_int);
-static void freechunks(void);
-static inline struct block *new_block(int);
-static inline struct slist *new_stmt(int);
-static struct block *gen_retblk(int);
-static inline void syntax(void);
+/* VARARGS */
+void
+bpf_error(compiler_state_t *cstate, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ if (cstate->bpf_pcap != NULL)
+ (void)pcap_vsnprintf(pcap_geterr(cstate->bpf_pcap),
+ PCAP_ERRBUF_SIZE, fmt, ap);
+ va_end(ap);
+ longjmp(cstate->top_ctx, 1);
+ /* NOTREACHED */
+}
+
+static void init_linktype(compiler_state_t *, pcap_t *);
+
+static void init_regs(compiler_state_t *);
+static int alloc_reg(compiler_state_t *);
+static void free_reg(compiler_state_t *, int);
+
+static void initchunks(compiler_state_t *cstate);
+static void *newchunk(compiler_state_t *cstate, size_t);
+static void freechunks(compiler_state_t *cstate);
+static inline struct block *new_block(compiler_state_t *cstate, int);
+static inline struct slist *new_stmt(compiler_state_t *cstate, int);
+static struct block *gen_retblk(compiler_state_t *cstate, int);
+static inline void syntax(compiler_state_t *cstate);
static void backpatch(struct block *, struct block *);
static void merge(struct block *, struct block *);
-static struct block *gen_cmp(enum e_offrel, u_int, u_int, bpf_int32);
-static struct block *gen_cmp_gt(enum e_offrel, u_int, u_int, bpf_int32);
-static struct block *gen_cmp_ge(enum e_offrel, u_int, u_int, bpf_int32);
-static struct block *gen_cmp_lt(enum e_offrel, u_int, u_int, bpf_int32);
-static struct block *gen_cmp_le(enum e_offrel, u_int, u_int, bpf_int32);
-static struct block *gen_mcmp(enum e_offrel, u_int, u_int, bpf_int32,
- bpf_u_int32);
-static struct block *gen_bcmp(enum e_offrel, u_int, u_int, const u_char *);
-static struct block *gen_ncmp(enum e_offrel, bpf_u_int32, bpf_u_int32,
- bpf_u_int32, bpf_u_int32, int, bpf_int32);
-static struct slist *gen_load_llrel(u_int, u_int);
-static struct slist *gen_load_macplrel(u_int, u_int);
-static struct slist *gen_load_a(enum e_offrel, u_int, u_int);
-static struct slist *gen_loadx_iphdrlen(void);
-static struct block *gen_uncond(int);
-static inline struct block *gen_true(void);
-static inline struct block *gen_false(void);
-static struct block *gen_ether_linktype(int);
-static struct block *gen_ipnet_linktype(int);
-static struct block *gen_linux_sll_linktype(int);
-static struct slist *gen_load_prism_llprefixlen(void);
-static struct slist *gen_load_avs_llprefixlen(void);
-static struct slist *gen_load_radiotap_llprefixlen(void);
-static struct slist *gen_load_ppi_llprefixlen(void);
-static void insert_compute_vloffsets(struct block *);
-static struct slist *gen_llprefixlen(void);
-static struct slist *gen_off_macpl(void);
+static struct block *gen_cmp(compiler_state_t *, enum e_offrel, u_int,
+ u_int, bpf_int32);
+static struct block *gen_cmp_gt(compiler_state_t *, enum e_offrel, u_int,
+ u_int, bpf_int32);
+static struct block *gen_cmp_ge(compiler_state_t *, enum e_offrel, u_int,
+ u_int, bpf_int32);
+static struct block *gen_cmp_lt(compiler_state_t *, enum e_offrel, u_int,
+ u_int, bpf_int32);
+static struct block *gen_cmp_le(compiler_state_t *, enum e_offrel, u_int,
+ u_int, bpf_int32);
+static struct block *gen_mcmp(compiler_state_t *, enum e_offrel, u_int,
+ u_int, bpf_int32, bpf_u_int32);
+static struct block *gen_bcmp(compiler_state_t *, enum e_offrel, u_int,
+ u_int, const u_char *);
+static struct block *gen_ncmp(compiler_state_t *, enum e_offrel, bpf_u_int32,
+ bpf_u_int32, bpf_u_int32, bpf_u_int32, int, bpf_int32);
+static struct slist *gen_load_absoffsetrel(compiler_state_t *, bpf_abs_offset *,
+ u_int, u_int);
+static struct slist *gen_load_a(compiler_state_t *, enum e_offrel, u_int,
+ u_int);
+static struct slist *gen_loadx_iphdrlen(compiler_state_t *);
+static struct block *gen_uncond(compiler_state_t *, int);
+static inline struct block *gen_true(compiler_state_t *);
+static inline struct block *gen_false(compiler_state_t *);
+static struct block *gen_ether_linktype(compiler_state_t *, int);
+static struct block *gen_ipnet_linktype(compiler_state_t *, int);
+static struct block *gen_linux_sll_linktype(compiler_state_t *, int);
+static struct slist *gen_load_prism_llprefixlen(compiler_state_t *);
+static struct slist *gen_load_avs_llprefixlen(compiler_state_t *);
+static struct slist *gen_load_radiotap_llprefixlen(compiler_state_t *);
+static struct slist *gen_load_ppi_llprefixlen(compiler_state_t *);
+static void insert_compute_vloffsets(compiler_state_t *, struct block *);
+static struct slist *gen_abs_offset_varpart(compiler_state_t *,
+ bpf_abs_offset *);
static int ethertype_to_ppptype(int);
-static struct block *gen_linktype(int);
-static struct block *gen_snap(bpf_u_int32, bpf_u_int32);
-static struct block *gen_llc_linktype(int);
-static struct block *gen_hostop(bpf_u_int32, bpf_u_int32, int, int, u_int, u_int);
+static struct block *gen_linktype(compiler_state_t *, int);
+static struct block *gen_snap(compiler_state_t *, bpf_u_int32, bpf_u_int32);
+static struct block *gen_llc_linktype(compiler_state_t *, int);
+static struct block *gen_hostop(compiler_state_t *, bpf_u_int32, bpf_u_int32,
+ int, int, u_int, u_int);
#ifdef INET6
-static struct block *gen_hostop6(struct in6_addr *, struct in6_addr *, int, int, u_int, u_int);
+static struct block *gen_hostop6(compiler_state_t *, struct in6_addr *,
+ struct in6_addr *, int, int, u_int, u_int);
#endif
-static struct block *gen_ahostop(const u_char *, int);
-static struct block *gen_ehostop(const u_char *, int);
-static struct block *gen_fhostop(const u_char *, int);
-static struct block *gen_thostop(const u_char *, int);
-static struct block *gen_wlanhostop(const u_char *, int);
-static struct block *gen_ipfchostop(const u_char *, int);
-static struct block *gen_dnhostop(bpf_u_int32, int);
-static struct block *gen_mpls_linktype(int);
-static struct block *gen_host(bpf_u_int32, bpf_u_int32, int, int, int);
+static struct block *gen_ahostop(compiler_state_t *, const u_char *, int);
+static struct block *gen_ehostop(compiler_state_t *, const u_char *, int);
+static struct block *gen_fhostop(compiler_state_t *, const u_char *, int);
+static struct block *gen_thostop(compiler_state_t *, const u_char *, int);
+static struct block *gen_wlanhostop(compiler_state_t *, const u_char *, int);
+static struct block *gen_ipfchostop(compiler_state_t *, const u_char *, int);
+static struct block *gen_dnhostop(compiler_state_t *, bpf_u_int32, int);
+static struct block *gen_mpls_linktype(compiler_state_t *, int);
+static struct block *gen_host(compiler_state_t *, bpf_u_int32, bpf_u_int32,
+ int, int, int);
#ifdef INET6
-static struct block *gen_host6(struct in6_addr *, struct in6_addr *, int, int, int);
+static struct block *gen_host6(compiler_state_t *, struct in6_addr *,
+ struct in6_addr *, int, int, int);
#endif
#ifndef INET6
static struct block *gen_gateway(const u_char *, bpf_u_int32 **, int, int);
#endif
-static struct block *gen_ipfrag(void);
-static struct block *gen_portatom(int, bpf_int32);
-static struct block *gen_portrangeatom(int, bpf_int32, bpf_int32);
-static struct block *gen_portatom6(int, bpf_int32);
-static struct block *gen_portrangeatom6(int, bpf_int32, bpf_int32);
-struct block *gen_portop(int, int, int);
-static struct block *gen_port(int, int, int);
-struct block *gen_portrangeop(int, int, int, int);
-static struct block *gen_portrange(int, int, int, int);
-struct block *gen_portop6(int, int, int);
-static struct block *gen_port6(int, int, int);
-struct block *gen_portrangeop6(int, int, int, int);
-static struct block *gen_portrange6(int, int, int, int);
-static int lookup_proto(const char *, int);
-static struct block *gen_protochain(int, int, int);
-static struct block *gen_proto(int, int, int);
-static struct slist *xfer_to_x(struct arth *);
-static struct slist *xfer_to_a(struct arth *);
-static struct block *gen_mac_multicast(int);
-static struct block *gen_len(int, int);
-static struct block *gen_check_802_11_data_frame(void);
-
-static struct block *gen_ppi_dlt_check(void);
-static struct block *gen_msg_abbrev(int type);
+static struct block *gen_ipfrag(compiler_state_t *);
+static struct block *gen_portatom(compiler_state_t *, int, bpf_int32);
+static struct block *gen_portrangeatom(compiler_state_t *, int, bpf_int32,
+ bpf_int32);
+static struct block *gen_portatom6(compiler_state_t *, int, bpf_int32);
+static struct block *gen_portrangeatom6(compiler_state_t *, int, bpf_int32,
+ bpf_int32);
+struct block *gen_portop(compiler_state_t *, int, int, int);
+static struct block *gen_port(compiler_state_t *, int, int, int);
+struct block *gen_portrangeop(compiler_state_t *, int, int, int, int);
+static struct block *gen_portrange(compiler_state_t *, int, int, int, int);
+struct block *gen_portop6(compiler_state_t *, int, int, int);
+static struct block *gen_port6(compiler_state_t *, int, int, int);
+struct block *gen_portrangeop6(compiler_state_t *, int, int, int, int);
+static struct block *gen_portrange6(compiler_state_t *, int, int, int, int);
+static int lookup_proto(compiler_state_t *, const char *, int);
+static struct block *gen_protochain(compiler_state_t *, int, int, int);
+static struct block *gen_proto(compiler_state_t *, int, int, int);
+static struct slist *xfer_to_x(compiler_state_t *, struct arth *);
+static struct slist *xfer_to_a(compiler_state_t *, struct arth *);
+static struct block *gen_mac_multicast(compiler_state_t *, int);
+static struct block *gen_len(compiler_state_t *, int, int);
+static struct block *gen_check_802_11_data_frame(compiler_state_t *);
+static struct block *gen_geneve_ll_check(compiler_state_t *cstate);
+
+static struct block *gen_ppi_dlt_check(compiler_state_t *);
+static struct block *gen_msg_abbrev(compiler_state_t *, int type);
+
+static void
+initchunks(compiler_state_t *cstate)
+{
+ int i;
+
+ for (i = 0; i < NCHUNKS; i++) {
+ cstate->chunks[i].n_left = 0;
+ cstate->chunks[i].m = NULL;
+ }
+ cstate->cur_chunk = 0;
+}
static void *
-newchunk(n)
- u_int n;
+newchunk(compiler_state_t *cstate, size_t n)
{
struct chunk *cp;
int k;
@@ -305,58 +580,53 @@ newchunk(n)
n = ALIGN(n);
#endif
- cp = &chunks[cur_chunk];
+ cp = &cstate->chunks[cstate->cur_chunk];
if (n > cp->n_left) {
- ++cp, k = ++cur_chunk;
+ ++cp, k = ++cstate->cur_chunk;
if (k >= NCHUNKS)
- bpf_error("out of memory");
+ bpf_error(cstate, "out of memory");
size = CHUNK0SIZE << k;
cp->m = (void *)malloc(size);
if (cp->m == NULL)
- bpf_error("out of memory");
+ bpf_error(cstate, "out of memory");
memset((char *)cp->m, 0, size);
cp->n_left = size;
if (n > size)
- bpf_error("out of memory");
+ bpf_error(cstate, "out of memory");
}
cp->n_left -= n;
return (void *)((char *)cp->m + cp->n_left);
}
static void
-freechunks()
+freechunks(compiler_state_t *cstate)
{
int i;
- cur_chunk = 0;
for (i = 0; i < NCHUNKS; ++i)
- if (chunks[i].m != NULL) {
- free(chunks[i].m);
- chunks[i].m = NULL;
- }
+ if (cstate->chunks[i].m != NULL)
+ free(cstate->chunks[i].m);
}
/*
* A strdup whose allocations are freed after code generation is over.
*/
char *
-sdup(s)
- register const char *s;
+sdup(compiler_state_t *cstate, const char *s)
{
- int n = strlen(s) + 1;
- char *cp = newchunk(n);
+ size_t n = strlen(s) + 1;
+ char *cp = newchunk(cstate, n);
strlcpy(cp, s, n);
return (cp);
}
static inline struct block *
-new_block(code)
- int code;
+new_block(compiler_state_t *cstate, int code)
{
struct block *p;
- p = (struct block *)newchunk(sizeof(*p));
+ p = (struct block *)newchunk(cstate, sizeof(*p));
p->s.code = code;
p->head = p;
@@ -364,59 +634,48 @@ new_block(code)
}
static inline struct slist *
-new_stmt(code)
- int code;
+new_stmt(compiler_state_t *cstate, int code)
{
struct slist *p;
- p = (struct slist *)newchunk(sizeof(*p));
+ p = (struct slist *)newchunk(cstate, sizeof(*p));
p->s.code = code;
return p;
}
static struct block *
-gen_retblk(v)
- int v;
+gen_retblk(compiler_state_t *cstate, int v)
{
- struct block *b = new_block(BPF_RET|BPF_K);
+ struct block *b = new_block(cstate, BPF_RET|BPF_K);
b->s.k = v;
return b;
}
static inline void
-syntax()
+syntax(compiler_state_t *cstate)
{
- bpf_error("syntax error in filter expression");
+ bpf_error(cstate, "syntax error in filter expression");
}
-static bpf_u_int32 netmask;
-static int snaplen;
-int no_optimize;
-
int
pcap_compile(pcap_t *p, struct bpf_program *program,
const char *buf, int optimize, bpf_u_int32 mask)
{
- extern int n_errors;
+ compiler_state_t cstate;
const char * volatile xbuf = buf;
+ yyscan_t scanner = NULL;
+ YY_BUFFER_STATE in_buffer = NULL;
u_int len;
int rc;
- /*
- * XXX - single-thread this code path with pthread calls on
- * UN*X, if the platform supports pthreads? If that requires
- * a separate -lpthread, we might not want to do that.
- */
-#ifdef WIN32
- extern int wsockinit (void);
+#ifdef _WIN32
static int done = 0;
if (!done)
- wsockinit();
+ pcap_wsockinit();
done = 1;
- EnterCriticalSection(&g_PcapCompileCriticalSection);
#endif
/*
@@ -424,69 +683,78 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
* link-layer type, so we can't use it.
*/
if (!p->activated) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"not-yet-activated pcap_t passed to pcap_compile");
rc = -1;
goto quit;
}
- no_optimize = 0;
- n_errors = 0;
- root = NULL;
- bpf_pcap = p;
- init_regs();
-
- if (setjmp(top_ctx)) {
+ initchunks(&cstate);
+ cstate.no_optimize = 0;
+ cstate.ai = NULL;
+ cstate.ic.root = NULL;
+ cstate.ic.cur_mark = 0;
+ cstate.bpf_pcap = p;
+ init_regs(&cstate);
+
+ if (setjmp(cstate.top_ctx)) {
#ifdef INET6
- if (ai != NULL) {
- freeaddrinfo(ai);
- ai = NULL;
- }
+ if (cstate.ai != NULL)
+ freeaddrinfo(cstate.ai);
#endif
- lex_cleanup();
- freechunks();
rc = -1;
goto quit;
}
- netmask = mask;
+ cstate.netmask = mask;
- snaplen = pcap_snapshot(p);
- if (snaplen == 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ cstate.snaplen = pcap_snapshot(p);
+ if (cstate.snaplen == 0) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"snaplen of 0 rejects all packets");
rc = -1;
goto quit;
}
- lex_init(xbuf ? xbuf : "");
- init_linktype(p);
- (void)pcap_parse();
+ if (pcap_lex_init(&scanner) != 0)
+ bpf_error(&cstate, "can't initialize scanner: %s", pcap_strerror(errno));
+ in_buffer = pcap__scan_string(xbuf ? xbuf : "", scanner);
+
+ /*
+ * Associate the compiler state with the lexical analyzer
+ * state.
+ */
+ pcap_set_extra(&cstate, scanner);
- if (n_errors)
- syntax();
+ init_linktype(&cstate, p);
+ (void)pcap_parse(scanner, &cstate);
- if (root == NULL)
- root = gen_retblk(snaplen);
+ if (cstate.ic.root == NULL)
+ cstate.ic.root = gen_retblk(&cstate, cstate.snaplen);
- if (optimize && !no_optimize) {
- bpf_optimize(&root);
- if (root == NULL ||
- (root->s.code == (BPF_RET|BPF_K) && root->s.k == 0))
- bpf_error("expression rejects all packets");
+ if (optimize && !cstate.no_optimize) {
+ bpf_optimize(&cstate, &cstate.ic);
+ if (cstate.ic.root == NULL ||
+ (cstate.ic.root->s.code == (BPF_RET|BPF_K) && cstate.ic.root->s.k == 0))
+ bpf_error(&cstate, "expression rejects all packets");
}
- program->bf_insns = icode_to_fcode(root, &len);
+ program->bf_insns = icode_to_fcode(&cstate, &cstate.ic, cstate.ic.root, &len);
program->bf_len = len;
- lex_cleanup();
- freechunks();
-
rc = 0; /* We're all okay */
quit:
+ /*
+ * Clean up everything for the lexical analyzer.
+ */
+ if (in_buffer != NULL)
+ pcap__delete_buffer(in_buffer, scanner);
+ if (scanner != NULL)
+ pcap_lex_destroy(scanner);
-#ifdef WIN32
- LeaveCriticalSection(&g_PcapCompileCriticalSection);
-#endif
+ /*
+ * Clean up our own allocated memory.
+ */
+ freechunks(&cstate);
return (rc);
}
@@ -568,8 +836,7 @@ merge(b0, b1)
}
void
-finish_parse(p)
- struct block *p;
+finish_parse(compiler_state_t *cstate, struct block *p)
{
struct block *ppi_dlt_check;
@@ -592,20 +859,29 @@ finish_parse(p)
* for tests that fail early, and it's not clear that's
* worth the effort.
*/
- insert_compute_vloffsets(p->head);
+ insert_compute_vloffsets(cstate, p->head);
/*
* For DLT_PPI captures, generate a check of the per-packet
* DLT value to make sure it's DLT_IEEE802_11.
+ *
+ * XXX - TurboCap cards use DLT_PPI for Ethernet.
+ * Can we just define some DLT_ETHERNET_WITH_PHDR pseudo-header
+ * with appropriate Ethernet information and use that rather
+ * than using something such as DLT_PPI where you don't know
+ * the link-layer header type until runtime, which, in the
+ * general case, would force us to generate both Ethernet *and*
+ * 802.11 code (*and* anything else for which PPI is used)
+ * and choose between them early in the BPF program?
*/
- ppi_dlt_check = gen_ppi_dlt_check();
+ ppi_dlt_check = gen_ppi_dlt_check(cstate);
if (ppi_dlt_check != NULL)
gen_and(ppi_dlt_check, p);
- backpatch(p, gen_retblk(snaplen));
+ backpatch(p, gen_retblk(cstate, cstate->snaplen));
p->sense = !p->sense;
- backpatch(p, gen_retblk(0));
- root = p->head;
+ backpatch(p, gen_retblk(cstate, 0));
+ cstate->ic.root = p->head;
}
void
@@ -639,65 +915,50 @@ gen_not(b)
}
static struct block *
-gen_cmp(offrel, offset, size, v)
- enum e_offrel offrel;
- u_int offset, size;
- bpf_int32 v;
+gen_cmp(compiler_state_t *cstate, enum e_offrel offrel, u_int offset,
+ u_int size, bpf_int32 v)
{
- return gen_ncmp(offrel, offset, size, 0xffffffff, BPF_JEQ, 0, v);
+ return gen_ncmp(cstate, offrel, offset, size, 0xffffffff, BPF_JEQ, 0, v);
}
static struct block *
-gen_cmp_gt(offrel, offset, size, v)
- enum e_offrel offrel;
- u_int offset, size;
- bpf_int32 v;
+gen_cmp_gt(compiler_state_t *cstate, enum e_offrel offrel, u_int offset,
+ u_int size, bpf_int32 v)
{
- return gen_ncmp(offrel, offset, size, 0xffffffff, BPF_JGT, 0, v);
+ return gen_ncmp(cstate, offrel, offset, size, 0xffffffff, BPF_JGT, 0, v);
}
static struct block *
-gen_cmp_ge(offrel, offset, size, v)
- enum e_offrel offrel;
- u_int offset, size;
- bpf_int32 v;
+gen_cmp_ge(compiler_state_t *cstate, enum e_offrel offrel, u_int offset,
+ u_int size, bpf_int32 v)
{
- return gen_ncmp(offrel, offset, size, 0xffffffff, BPF_JGE, 0, v);
+ return gen_ncmp(cstate, offrel, offset, size, 0xffffffff, BPF_JGE, 0, v);
}
static struct block *
-gen_cmp_lt(offrel, offset, size, v)
- enum e_offrel offrel;
- u_int offset, size;
- bpf_int32 v;
+gen_cmp_lt(compiler_state_t *cstate, enum e_offrel offrel, u_int offset,
+ u_int size, bpf_int32 v)
{
- return gen_ncmp(offrel, offset, size, 0xffffffff, BPF_JGE, 1, v);
+ return gen_ncmp(cstate, offrel, offset, size, 0xffffffff, BPF_JGE, 1, v);
}
static struct block *
-gen_cmp_le(offrel, offset, size, v)
- enum e_offrel offrel;
- u_int offset, size;
- bpf_int32 v;
+gen_cmp_le(compiler_state_t *cstate, enum e_offrel offrel, u_int offset,
+ u_int size, bpf_int32 v)
{
- return gen_ncmp(offrel, offset, size, 0xffffffff, BPF_JGT, 1, v);
+ return gen_ncmp(cstate, offrel, offset, size, 0xffffffff, BPF_JGT, 1, v);
}
static struct block *
-gen_mcmp(offrel, offset, size, v, mask)
- enum e_offrel offrel;
- u_int offset, size;
- bpf_int32 v;
- bpf_u_int32 mask;
+gen_mcmp(compiler_state_t *cstate, enum e_offrel offrel, u_int offset,
+ u_int size, bpf_int32 v, bpf_u_int32 mask)
{
- return gen_ncmp(offrel, offset, size, mask, BPF_JEQ, 0, v);
+ return gen_ncmp(cstate, offrel, offset, size, mask, BPF_JEQ, 0, v);
}
static struct block *
-gen_bcmp(offrel, offset, size, v)
- enum e_offrel offrel;
- register u_int offset, size;
- register const u_char *v;
+gen_bcmp(compiler_state_t *cstate, enum e_offrel offrel, u_int offset,
+ u_int size, const u_char *v)
{
register struct block *b, *tmp;
@@ -707,7 +968,7 @@ gen_bcmp(offrel, offset, size, v)
bpf_int32 w = ((bpf_int32)p[0] << 24) |
((bpf_int32)p[1] << 16) | ((bpf_int32)p[2] << 8) | p[3];
- tmp = gen_cmp(offrel, offset + size - 4, BPF_W, w);
+ tmp = gen_cmp(cstate, offrel, offset + size - 4, BPF_W, w);
if (b != NULL)
gen_and(b, tmp);
b = tmp;
@@ -717,14 +978,14 @@ gen_bcmp(offrel, offset, size, v)
register const u_char *p = &v[size - 2];
bpf_int32 w = ((bpf_int32)p[0] << 8) | p[1];
- tmp = gen_cmp(offrel, offset + size - 2, BPF_H, w);
+ tmp = gen_cmp(cstate, offrel, offset + size - 2, BPF_H, w);
if (b != NULL)
gen_and(b, tmp);
b = tmp;
size -= 2;
}
if (size > 0) {
- tmp = gen_cmp(offrel, offset, BPF_B, (bpf_int32)v[0]);
+ tmp = gen_cmp(cstate, offrel, offset, BPF_B, (bpf_int32)v[0]);
if (b != NULL)
gen_and(b, tmp);
b = tmp;
@@ -739,24 +1000,22 @@ gen_bcmp(offrel, offset, size, v)
* should test the opposite of "jtype".
*/
static struct block *
-gen_ncmp(offrel, offset, size, mask, jtype, reverse, v)
- enum e_offrel offrel;
- bpf_int32 v;
- bpf_u_int32 offset, size, mask, jtype;
- int reverse;
+gen_ncmp(compiler_state_t *cstate, enum e_offrel offrel, bpf_u_int32 offset,
+ bpf_u_int32 size, bpf_u_int32 mask, bpf_u_int32 jtype, int reverse,
+ bpf_int32 v)
{
struct slist *s, *s2;
struct block *b;
- s = gen_load_a(offrel, offset, size);
+ s = gen_load_a(cstate, offrel, offset, size);
if (mask != 0xffffffff) {
- s2 = new_stmt(BPF_ALU|BPF_AND|BPF_K);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_AND|BPF_K);
s2->s.k = mask;
sappend(s, s2);
}
- b = new_block(JMP(jtype));
+ b = new_block(cstate, JMP(jtype));
b->stmts = s;
b->s.k = v;
if (reverse && (jtype == BPF_JGT || jtype == BPF_JGE))
@@ -764,294 +1023,152 @@ gen_ncmp(offrel, offset, size, mask, jtype, reverse, v)
return b;
}
-/*
- * Various code constructs need to know the layout of the data link
- * layer. These variables give the necessary offsets from the beginning
- * of the packet data.
- */
-
-/*
- * This is the offset of the beginning of the link-layer header from
- * the beginning of the raw packet data.
- *
- * It's usually 0, except for 802.11 with a fixed-length radio header.
- * (For 802.11 with a variable-length radio header, we have to generate
- * code to compute that offset; off_ll is 0 in that case.)
- */
-static u_int off_ll;
-
-/*
- * If there's a variable-length header preceding the link-layer header,
- * "reg_off_ll" is the register number for a register containing the
- * length of that header, and therefore the offset of the link-layer
- * header from the beginning of the raw packet data. Otherwise,
- * "reg_off_ll" is -1.
- */
-static int reg_off_ll;
-
-/*
- * This is the offset of the beginning of the MAC-layer header from
- * the beginning of the link-layer header.
- * It's usually 0, except for ATM LANE, where it's the offset, relative
- * to the beginning of the raw packet data, of the Ethernet header, and
- * for Ethernet with various additional information.
- */
-static u_int off_mac;
-
-/*
- * This is the offset of the beginning of the MAC-layer payload,
- * from the beginning of the raw packet data.
- *
- * I.e., it's the sum of the length of the link-layer header (without,
- * for example, any 802.2 LLC header, so it's the MAC-layer
- * portion of that header), plus any prefix preceding the
- * link-layer header.
- */
-static u_int off_macpl;
-
-/*
- * This is 1 if the offset of the beginning of the MAC-layer payload
- * from the beginning of the link-layer header is variable-length.
- */
-static int off_macpl_is_variable;
-
-/*
- * If the link layer has variable_length headers, "reg_off_macpl"
- * is the register number for a register containing the length of the
- * link-layer header plus the length of any variable-length header
- * preceding the link-layer header. Otherwise, "reg_off_macpl"
- * is -1.
- */
-static int reg_off_macpl;
-
-/*
- * "off_linktype" is the offset to information in the link-layer header
- * giving the packet type. This offset is relative to the beginning
- * of the link-layer header (i.e., it doesn't include off_ll).
- *
- * For Ethernet, it's the offset of the Ethernet type field.
- *
- * For link-layer types that always use 802.2 headers, it's the
- * offset of the LLC header.
- *
- * For PPP, it's the offset of the PPP type field.
- *
- * For Cisco HDLC, it's the offset of the CHDLC type field.
- *
- * For BSD loopback, it's the offset of the AF_ value.
- *
- * For Linux cooked sockets, it's the offset of the type field.
- *
- * It's set to -1 for no encapsulation, in which case, IP is assumed.
- */
-static u_int off_linktype;
-
-/*
- * TRUE if "pppoes" appeared in the filter; it causes link-layer type
- * checks to check the PPP header, assumed to follow a LAN-style link-
- * layer header and a PPPoE session header.
- */
-static int is_pppoes = 0;
-
-/*
- * TRUE if the link layer includes an ATM pseudo-header.
- */
-static int is_atm = 0;
-
-/*
- * TRUE if "lane" appeared in the filter; it causes us to generate
- * code that assumes LANE rather than LLC-encapsulated traffic in SunATM.
- */
-static int is_lane = 0;
-
-/*
- * These are offsets for the ATM pseudo-header.
- */
-static u_int off_vpi;
-static u_int off_vci;
-static u_int off_proto;
+static void
+init_linktype(compiler_state_t *cstate, pcap_t *p)
+{
+ cstate->pcap_fddipad = p->fddipad;
-/*
- * These are offsets for the MTP2 fields.
- */
-static u_int off_li;
-static u_int off_li_hsl;
+ /*
+ * We start out with only one link-layer header.
+ */
+ cstate->outermostlinktype = pcap_datalink(p);
+ cstate->off_outermostlinkhdr.constant_part = 0;
+ cstate->off_outermostlinkhdr.is_variable = 0;
+ cstate->off_outermostlinkhdr.reg = -1;
-/*
- * These are offsets for the MTP3 fields.
- */
-static u_int off_sio;
-static u_int off_opc;
-static u_int off_dpc;
-static u_int off_sls;
+ cstate->prevlinktype = cstate->outermostlinktype;
+ cstate->off_prevlinkhdr.constant_part = 0;
+ cstate->off_prevlinkhdr.is_variable = 0;
+ cstate->off_prevlinkhdr.reg = -1;
-/*
- * This is the offset of the first byte after the ATM pseudo_header,
- * or -1 if there is no ATM pseudo-header.
- */
-static u_int off_payload;
+ cstate->linktype = cstate->outermostlinktype;
+ cstate->off_linkhdr.constant_part = 0;
+ cstate->off_linkhdr.is_variable = 0;
+ cstate->off_linkhdr.reg = -1;
-/*
- * These are offsets to the beginning of the network-layer header.
- * They are relative to the beginning of the MAC-layer payload (i.e.,
- * they don't include off_ll or off_macpl).
- *
- * If the link layer never uses 802.2 LLC:
- *
- * "off_nl" and "off_nl_nosnap" are the same.
- *
- * If the link layer always uses 802.2 LLC:
- *
- * "off_nl" is the offset if there's a SNAP header following
- * the 802.2 header;
- *
- * "off_nl_nosnap" is the offset if there's no SNAP header.
- *
- * If the link layer is Ethernet:
- *
- * "off_nl" is the offset if the packet is an Ethernet II packet
- * (we assume no 802.3+802.2+SNAP);
- *
- * "off_nl_nosnap" is the offset if the packet is an 802.3 packet
- * with an 802.2 header following it.
- */
-static u_int off_nl;
-static u_int off_nl_nosnap;
-
-static int linktype;
+ /*
+ * XXX
+ */
+ cstate->off_linkpl.constant_part = 0;
+ cstate->off_linkpl.is_variable = 0;
+ cstate->off_linkpl.reg = -1;
-static void
-init_linktype(p)
- pcap_t *p;
-{
- linktype = pcap_datalink(p);
- pcap_fddipad = p->fddipad;
+ cstate->off_linktype.constant_part = 0;
+ cstate->off_linktype.is_variable = 0;
+ cstate->off_linktype.reg = -1;
/*
* Assume it's not raw ATM with a pseudo-header, for now.
*/
- off_mac = 0;
- is_atm = 0;
- is_lane = 0;
- off_vpi = -1;
- off_vci = -1;
- off_proto = -1;
- off_payload = -1;
+ cstate->is_atm = 0;
+ cstate->off_vpi = -1;
+ cstate->off_vci = -1;
+ cstate->off_proto = -1;
+ cstate->off_payload = -1;
/*
- * And that we're not doing PPPoE.
+ * And not Geneve.
*/
- is_pppoes = 0;
+ cstate->is_geneve = 0;
/*
* And assume we're not doing SS7.
*/
- off_li = -1;
- off_li_hsl = -1;
- off_sio = -1;
- off_opc = -1;
- off_dpc = -1;
- off_sls = -1;
-
- /*
- * Also assume it's not 802.11.
- */
- off_ll = 0;
- off_macpl = 0;
- off_macpl_is_variable = 0;
-
- orig_linktype = -1;
- orig_nl = -1;
- label_stack_depth = 0;
+ cstate->off_li = -1;
+ cstate->off_li_hsl = -1;
+ cstate->off_sio = -1;
+ cstate->off_opc = -1;
+ cstate->off_dpc = -1;
+ cstate->off_sls = -1;
- reg_off_ll = -1;
- reg_off_macpl = -1;
+ cstate->label_stack_depth = 0;
+ cstate->vlan_stack_depth = 0;
- switch (linktype) {
+ switch (cstate->linktype) {
case DLT_ARCNET:
- off_linktype = 2;
- off_macpl = 6;
- off_nl = 0; /* XXX in reality, variable! */
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 2;
+ cstate->off_linkpl.constant_part = 6;
+ cstate->off_nl = 0; /* XXX in reality, variable! */
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_ARCNET_LINUX:
- off_linktype = 4;
- off_macpl = 8;
- off_nl = 0; /* XXX in reality, variable! */
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 4;
+ cstate->off_linkpl.constant_part = 8;
+ cstate->off_nl = 0; /* XXX in reality, variable! */
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_EN10MB:
- off_linktype = 12;
- off_macpl = 14; /* Ethernet header length */
- off_nl = 0; /* Ethernet II */
- off_nl_nosnap = 3; /* 802.3+802.2 */
- return;
+ cstate->off_linktype.constant_part = 12;
+ cstate->off_linkpl.constant_part = 14; /* Ethernet header length */
+ cstate->off_nl = 0; /* Ethernet II */
+ cstate->off_nl_nosnap = 3; /* 802.3+802.2 */
+ break;
case DLT_SLIP:
/*
* SLIP doesn't have a link level type. The 16 byte
* header is hacked into our SLIP driver.
*/
- off_linktype = -1;
- off_macpl = 16;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
+ cstate->off_linkpl.constant_part = 16;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_SLIP_BSDOS:
/* XXX this may be the same as the DLT_PPP_BSDOS case */
- off_linktype = -1;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
/* XXX end */
- off_macpl = 24;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linkpl.constant_part = 24;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_NULL:
case DLT_LOOP:
- off_linktype = 0;
- off_macpl = 4;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 0;
+ cstate->off_linkpl.constant_part = 4;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_ENC:
- off_linktype = 0;
- off_macpl = 12;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 0;
+ cstate->off_linkpl.constant_part = 12;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_PPP:
case DLT_PPP_PPPD:
case DLT_C_HDLC: /* BSD/OS Cisco HDLC */
case DLT_PPP_SERIAL: /* NetBSD sync/async serial PPP */
- off_linktype = 2;
- off_macpl = 4;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 2; /* skip HDLC-like framing */
+ cstate->off_linkpl.constant_part = 4; /* skip HDLC-like framing and protocol field */
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_PPP_ETHER:
/*
* This does no include the Ethernet header, and
* only covers session state.
*/
- off_linktype = 6;
- off_macpl = 8;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 6;
+ cstate->off_linkpl.constant_part = 8;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_PPP_BSDOS:
- off_linktype = 5;
- off_macpl = 24;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 5;
+ cstate->off_linkpl.constant_part = 24;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_FDDI:
/*
@@ -1062,13 +1179,13 @@ init_linktype(p)
* is being used and pick out the encapsulated Ethernet type.
* XXX - should we generate code to check for SNAP?
*/
- off_linktype = 13;
- off_linktype += pcap_fddipad;
- off_macpl = 13; /* FDDI MAC header length */
- off_macpl += pcap_fddipad;
- off_nl = 8; /* 802.2+SNAP */
- off_nl_nosnap = 3; /* 802.2 */
- return;
+ cstate->off_linktype.constant_part = 13;
+ cstate->off_linktype.constant_part += cstate->pcap_fddipad;
+ cstate->off_linkpl.constant_part = 13; /* FDDI MAC header length */
+ cstate->off_linkpl.constant_part += cstate->pcap_fddipad;
+ cstate->off_nl = 8; /* 802.2+SNAP */
+ cstate->off_nl_nosnap = 3; /* 802.2 */
+ break;
case DLT_IEEE802:
/*
@@ -1094,19 +1211,24 @@ init_linktype(p)
* the 16-bit value at an offset of 14 (shifted right
* 8 - figure out which byte that is).
*/
- off_linktype = 14;
- off_macpl = 14; /* Token Ring MAC header length */
- off_nl = 8; /* 802.2+SNAP */
- off_nl_nosnap = 3; /* 802.2 */
- return;
+ cstate->off_linktype.constant_part = 14;
+ cstate->off_linkpl.constant_part = 14; /* Token Ring MAC header length */
+ cstate->off_nl = 8; /* 802.2+SNAP */
+ cstate->off_nl_nosnap = 3; /* 802.2 */
+ break;
- case DLT_IEEE802_11:
case DLT_PRISM_HEADER:
case DLT_IEEE802_11_RADIO_AVS:
case DLT_IEEE802_11_RADIO:
+ cstate->off_linkhdr.is_variable = 1;
+ /* Fall through, 802.11 doesn't have a variable link
+ * prefix but is otherwise the same. */
+
+ case DLT_IEEE802_11:
/*
* 802.11 doesn't really have a link-level type field.
- * We set "off_linktype" to the offset of the LLC header.
+ * We set "off_linktype.constant_part" to the offset of
+ * the LLC header.
*
* To check for Ethernet types, we assume that SSAP = SNAP
* is being used and pick out the encapsulated Ethernet type.
@@ -1121,12 +1243,12 @@ init_linktype(p)
* header or an AVS header, so, in practice, it's
* variable-length.
*/
- off_linktype = 24;
- off_macpl = 0; /* link-layer header is variable-length */
- off_macpl_is_variable = 1;
- off_nl = 8; /* 802.2+SNAP */
- off_nl_nosnap = 3; /* 802.2 */
- return;
+ cstate->off_linktype.constant_part = 24;
+ cstate->off_linkpl.constant_part = 0; /* link-layer header is variable-length */
+ cstate->off_linkpl.is_variable = 1;
+ cstate->off_nl = 8; /* 802.2+SNAP */
+ cstate->off_nl_nosnap = 3; /* 802.2 */
+ break;
case DLT_PPI:
/*
@@ -1138,12 +1260,13 @@ init_linktype(p)
* the encapsulated DLT should be DLT_IEEE802_11) we
* generate code to check for this too.
*/
- off_linktype = 24;
- off_macpl = 0; /* link-layer header is variable-length */
- off_macpl_is_variable = 1;
- off_nl = 8; /* 802.2+SNAP */
- off_nl_nosnap = 3; /* 802.2 */
- return;
+ cstate->off_linktype.constant_part = 24;
+ cstate->off_linkpl.constant_part = 0; /* link-layer header is variable-length */
+ cstate->off_linkpl.is_variable = 1;
+ cstate->off_linkhdr.is_variable = 1;
+ cstate->off_nl = 8; /* 802.2+SNAP */
+ cstate->off_nl_nosnap = 3; /* 802.2 */
+ break;
case DLT_ATM_RFC1483:
case DLT_ATM_CLIP: /* Linux ATM defines this */
@@ -1158,44 +1281,43 @@ init_linktype(p)
* or "pppoa and tcp port 80" and have it check for
* PPPo{A,E} and a PPP protocol of IP and....
*/
- off_linktype = 0;
- off_macpl = 0; /* packet begins with LLC header */
- off_nl = 8; /* 802.2+SNAP */
- off_nl_nosnap = 3; /* 802.2 */
- return;
+ cstate->off_linktype.constant_part = 0;
+ cstate->off_linkpl.constant_part = 0; /* packet begins with LLC header */
+ cstate->off_nl = 8; /* 802.2+SNAP */
+ cstate->off_nl_nosnap = 3; /* 802.2 */
+ break;
case DLT_SUNATM:
/*
* Full Frontal ATM; you get AALn PDUs with an ATM
* pseudo-header.
*/
- is_atm = 1;
- off_vpi = SUNATM_VPI_POS;
- off_vci = SUNATM_VCI_POS;
- off_proto = PROTO_POS;
- off_mac = -1; /* assume LLC-encapsulated, so no MAC-layer header */
- off_payload = SUNATM_PKT_BEGIN_POS;
- off_linktype = off_payload;
- off_macpl = off_payload; /* if LLC-encapsulated */
- off_nl = 8; /* 802.2+SNAP */
- off_nl_nosnap = 3; /* 802.2 */
- return;
+ cstate->is_atm = 1;
+ cstate->off_vpi = SUNATM_VPI_POS;
+ cstate->off_vci = SUNATM_VCI_POS;
+ cstate->off_proto = PROTO_POS;
+ cstate->off_payload = SUNATM_PKT_BEGIN_POS;
+ cstate->off_linktype.constant_part = cstate->off_payload;
+ cstate->off_linkpl.constant_part = cstate->off_payload; /* if LLC-encapsulated */
+ cstate->off_nl = 8; /* 802.2+SNAP */
+ cstate->off_nl_nosnap = 3; /* 802.2 */
+ break;
case DLT_RAW:
case DLT_IPV4:
case DLT_IPV6:
- off_linktype = -1;
- off_macpl = 0;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
+ cstate->off_linkpl.constant_part = 0;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_LINUX_SLL: /* fake header for Linux cooked socket */
- off_linktype = 14;
- off_macpl = 16;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 14;
+ cstate->off_linkpl.constant_part = 16;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_LTALK:
/*
@@ -1203,11 +1325,11 @@ init_linktype(p)
* but really it just indicates whether there is a "short" or
* "long" DDP packet following.
*/
- off_linktype = -1;
- off_macpl = 0;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
+ cstate->off_linkpl.constant_part = 0;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_IP_OVER_FC:
/*
@@ -1220,22 +1342,22 @@ init_linktype(p)
* XXX - should we generate code to check for SNAP? RFC
* 2625 says SNAP should be used.
*/
- off_linktype = 16;
- off_macpl = 16;
- off_nl = 8; /* 802.2+SNAP */
- off_nl_nosnap = 3; /* 802.2 */
- return;
+ cstate->off_linktype.constant_part = 16;
+ cstate->off_linkpl.constant_part = 16;
+ cstate->off_nl = 8; /* 802.2+SNAP */
+ cstate->off_nl_nosnap = 3; /* 802.2 */
+ break;
case DLT_FRELAY:
/*
* XXX - we should set this to handle SNAP-encapsulated
* frames (NLPID of 0x80).
*/
- off_linktype = -1;
- off_macpl = 0;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
+ cstate->off_linkpl.constant_part = 0;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
/*
* the only BPF-interesting FRF.16 frames are non-control frames;
@@ -1243,33 +1365,33 @@ init_linktype(p)
* so lets start with offset 4 for now and increments later on (FIXME);
*/
case DLT_MFR:
- off_linktype = -1;
- off_macpl = 0;
- off_nl = 4;
- off_nl_nosnap = 0; /* XXX - for now -> no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
+ cstate->off_linkpl.constant_part = 0;
+ cstate->off_nl = 4;
+ cstate->off_nl_nosnap = 0; /* XXX - for now -> no 802.2 LLC */
+ break;
case DLT_APPLE_IP_OVER_IEEE1394:
- off_linktype = 16;
- off_macpl = 18;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 16;
+ cstate->off_linkpl.constant_part = 18;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_SYMANTEC_FIREWALL:
- off_linktype = 6;
- off_macpl = 44;
- off_nl = 0; /* Ethernet II */
- off_nl_nosnap = 0; /* XXX - what does it do with 802.3 packets? */
- return;
+ cstate->off_linktype.constant_part = 6;
+ cstate->off_linkpl.constant_part = 44;
+ cstate->off_nl = 0; /* Ethernet II */
+ cstate->off_nl_nosnap = 0; /* XXX - what does it do with 802.3 packets? */
+ break;
#ifdef HAVE_NET_PFVAR_H
case DLT_PFLOG:
- off_linktype = 0;
- off_macpl = PFLOG_HDRLEN;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 0;
+ cstate->off_linkpl.constant_part = PFLOG_HDRLEN;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
#endif
case DLT_JUNIPER_MFR:
@@ -1278,289 +1400,244 @@ init_linktype(p)
case DLT_JUNIPER_PPP:
case DLT_JUNIPER_CHDLC:
case DLT_JUNIPER_FRELAY:
- off_linktype = 4;
- off_macpl = 4;
- off_nl = 0;
- off_nl_nosnap = -1; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 4;
+ cstate->off_linkpl.constant_part = 4;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = -1; /* no 802.2 LLC */
+ break;
case DLT_JUNIPER_ATM1:
- off_linktype = 4; /* in reality variable between 4-8 */
- off_macpl = 4; /* in reality variable between 4-8 */
- off_nl = 0;
- off_nl_nosnap = 10;
- return;
+ cstate->off_linktype.constant_part = 4; /* in reality variable between 4-8 */
+ cstate->off_linkpl.constant_part = 4; /* in reality variable between 4-8 */
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 10;
+ break;
case DLT_JUNIPER_ATM2:
- off_linktype = 8; /* in reality variable between 8-12 */
- off_macpl = 8; /* in reality variable between 8-12 */
- off_nl = 0;
- off_nl_nosnap = 10;
- return;
+ cstate->off_linktype.constant_part = 8; /* in reality variable between 8-12 */
+ cstate->off_linkpl.constant_part = 8; /* in reality variable between 8-12 */
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 10;
+ break;
/* frames captured on a Juniper PPPoE service PIC
* contain raw ethernet frames */
case DLT_JUNIPER_PPPOE:
case DLT_JUNIPER_ETHER:
- off_macpl = 14;
- off_linktype = 16;
- off_nl = 18; /* Ethernet II */
- off_nl_nosnap = 21; /* 802.3+802.2 */
- return;
+ cstate->off_linkpl.constant_part = 14;
+ cstate->off_linktype.constant_part = 16;
+ cstate->off_nl = 18; /* Ethernet II */
+ cstate->off_nl_nosnap = 21; /* 802.3+802.2 */
+ break;
case DLT_JUNIPER_PPPOE_ATM:
- off_linktype = 4;
- off_macpl = 6;
- off_nl = 0;
- off_nl_nosnap = -1; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 4;
+ cstate->off_linkpl.constant_part = 6;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = -1; /* no 802.2 LLC */
+ break;
case DLT_JUNIPER_GGSN:
- off_linktype = 6;
- off_macpl = 12;
- off_nl = 0;
- off_nl_nosnap = -1; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 6;
+ cstate->off_linkpl.constant_part = 12;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = -1; /* no 802.2 LLC */
+ break;
case DLT_JUNIPER_ES:
- off_linktype = 6;
- off_macpl = -1; /* not really a network layer but raw IP addresses */
- off_nl = -1; /* not really a network layer but raw IP addresses */
- off_nl_nosnap = -1; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 6;
+ cstate->off_linkpl.constant_part = OFFSET_NOT_SET; /* not really a network layer but raw IP addresses */
+ cstate->off_nl = -1; /* not really a network layer but raw IP addresses */
+ cstate->off_nl_nosnap = -1; /* no 802.2 LLC */
+ break;
case DLT_JUNIPER_MONITOR:
- off_linktype = 12;
- off_macpl = 12;
- off_nl = 0; /* raw IP/IP6 header */
- off_nl_nosnap = -1; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 12;
+ cstate->off_linkpl.constant_part = 12;
+ cstate->off_nl = 0; /* raw IP/IP6 header */
+ cstate->off_nl_nosnap = -1; /* no 802.2 LLC */
+ break;
case DLT_BACNET_MS_TP:
- off_linktype = -1;
- off_macpl = -1;
- off_nl = -1;
- off_nl_nosnap = -1;
- return;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
+ cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
+ cstate->off_nl = -1;
+ cstate->off_nl_nosnap = -1;
+ break;
case DLT_JUNIPER_SERVICES:
- off_linktype = 12;
- off_macpl = -1; /* L3 proto location dep. on cookie type */
- off_nl = -1; /* L3 proto location dep. on cookie type */
- off_nl_nosnap = -1; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 12;
+ cstate->off_linkpl.constant_part = OFFSET_NOT_SET; /* L3 proto location dep. on cookie type */
+ cstate->off_nl = -1; /* L3 proto location dep. on cookie type */
+ cstate->off_nl_nosnap = -1; /* no 802.2 LLC */
+ break;
case DLT_JUNIPER_VP:
- off_linktype = 18;
- off_macpl = -1;
- off_nl = -1;
- off_nl_nosnap = -1;
- return;
+ cstate->off_linktype.constant_part = 18;
+ cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
+ cstate->off_nl = -1;
+ cstate->off_nl_nosnap = -1;
+ break;
case DLT_JUNIPER_ST:
- off_linktype = 18;
- off_macpl = -1;
- off_nl = -1;
- off_nl_nosnap = -1;
- return;
+ cstate->off_linktype.constant_part = 18;
+ cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
+ cstate->off_nl = -1;
+ cstate->off_nl_nosnap = -1;
+ break;
case DLT_JUNIPER_ISM:
- off_linktype = 8;
- off_macpl = -1;
- off_nl = -1;
- off_nl_nosnap = -1;
- return;
+ cstate->off_linktype.constant_part = 8;
+ cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
+ cstate->off_nl = -1;
+ cstate->off_nl_nosnap = -1;
+ break;
case DLT_JUNIPER_VS:
case DLT_JUNIPER_SRX_E2E:
case DLT_JUNIPER_FIBRECHANNEL:
case DLT_JUNIPER_ATM_CEMIC:
- off_linktype = 8;
- off_macpl = -1;
- off_nl = -1;
- off_nl_nosnap = -1;
- return;
+ cstate->off_linktype.constant_part = 8;
+ cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
+ cstate->off_nl = -1;
+ cstate->off_nl_nosnap = -1;
+ break;
case DLT_MTP2:
- off_li = 2;
- off_li_hsl = 4;
- off_sio = 3;
- off_opc = 4;
- off_dpc = 4;
- off_sls = 7;
- off_linktype = -1;
- off_macpl = -1;
- off_nl = -1;
- off_nl_nosnap = -1;
- return;
+ cstate->off_li = 2;
+ cstate->off_li_hsl = 4;
+ cstate->off_sio = 3;
+ cstate->off_opc = 4;
+ cstate->off_dpc = 4;
+ cstate->off_sls = 7;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
+ cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
+ cstate->off_nl = -1;
+ cstate->off_nl_nosnap = -1;
+ break;
case DLT_MTP2_WITH_PHDR:
- off_li = 6;
- off_li_hsl = 8;
- off_sio = 7;
- off_opc = 8;
- off_dpc = 8;
- off_sls = 11;
- off_linktype = -1;
- off_macpl = -1;
- off_nl = -1;
- off_nl_nosnap = -1;
- return;
+ cstate->off_li = 6;
+ cstate->off_li_hsl = 8;
+ cstate->off_sio = 7;
+ cstate->off_opc = 8;
+ cstate->off_dpc = 8;
+ cstate->off_sls = 11;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
+ cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
+ cstate->off_nl = -1;
+ cstate->off_nl_nosnap = -1;
+ break;
case DLT_ERF:
- off_li = 22;
- off_li_hsl = 24;
- off_sio = 23;
- off_opc = 24;
- off_dpc = 24;
- off_sls = 27;
- off_linktype = -1;
- off_macpl = -1;
- off_nl = -1;
- off_nl_nosnap = -1;
- return;
+ cstate->off_li = 22;
+ cstate->off_li_hsl = 24;
+ cstate->off_sio = 23;
+ cstate->off_opc = 24;
+ cstate->off_dpc = 24;
+ cstate->off_sls = 27;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
+ cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
+ cstate->off_nl = -1;
+ cstate->off_nl_nosnap = -1;
+ break;
case DLT_PFSYNC:
- off_linktype = -1;
- off_macpl = 4;
- off_nl = 0;
- off_nl_nosnap = 0;
- return;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
+ cstate->off_linkpl.constant_part = 4;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0;
+ break;
case DLT_AX25_KISS:
/*
* Currently, only raw "link[N:M]" filtering is supported.
*/
- off_linktype = -1; /* variable, min 15, max 71 steps of 7 */
- off_macpl = -1;
- off_nl = -1; /* variable, min 16, max 71 steps of 7 */
- off_nl_nosnap = -1; /* no 802.2 LLC */
- off_mac = 1; /* step over the kiss length byte */
- return;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET; /* variable, min 15, max 71 steps of 7 */
+ cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
+ cstate->off_nl = -1; /* variable, min 16, max 71 steps of 7 */
+ cstate->off_nl_nosnap = -1; /* no 802.2 LLC */
+ break;
case DLT_IPNET:
- off_linktype = 1;
- off_macpl = 24; /* ipnet header length */
- off_nl = 0;
- off_nl_nosnap = -1;
- return;
+ cstate->off_linktype.constant_part = 1;
+ cstate->off_linkpl.constant_part = 24; /* ipnet header length */
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = -1;
+ break;
case DLT_NETANALYZER:
- off_mac = 4; /* MAC header is past 4-byte pseudo-header */
- off_linktype = 16; /* includes 4-byte pseudo-header */
- off_macpl = 18; /* pseudo-header+Ethernet header length */
- off_nl = 0; /* Ethernet II */
- off_nl_nosnap = 3; /* 802.3+802.2 */
- return;
+ cstate->off_linkhdr.constant_part = 4; /* Ethernet header is past 4-byte pseudo-header */
+ cstate->off_linktype.constant_part = cstate->off_linkhdr.constant_part + 12;
+ cstate->off_linkpl.constant_part = cstate->off_linkhdr.constant_part + 14; /* pseudo-header+Ethernet header length */
+ cstate->off_nl = 0; /* Ethernet II */
+ cstate->off_nl_nosnap = 3; /* 802.3+802.2 */
+ break;
case DLT_NETANALYZER_TRANSPARENT:
- off_mac = 12; /* MAC header is past 4-byte pseudo-header, preamble, and SFD */
- off_linktype = 24; /* includes 4-byte pseudo-header+preamble+SFD */
- off_macpl = 26; /* pseudo-header+preamble+SFD+Ethernet header length */
- off_nl = 0; /* Ethernet II */
- off_nl_nosnap = 3; /* 802.3+802.2 */
- return;
+ cstate->off_linkhdr.constant_part = 12; /* MAC header is past 4-byte pseudo-header, preamble, and SFD */
+ cstate->off_linktype.constant_part = cstate->off_linkhdr.constant_part + 12;
+ cstate->off_linkpl.constant_part = cstate->off_linkhdr.constant_part + 14; /* pseudo-header+preamble+SFD+Ethernet header length */
+ cstate->off_nl = 0; /* Ethernet II */
+ cstate->off_nl_nosnap = 3; /* 802.3+802.2 */
+ break;
default:
/*
* For values in the range in which we've assigned new
* DLT_ values, only raw "link[N:M]" filtering is supported.
*/
- if (linktype >= DLT_MATCHING_MIN &&
- linktype <= DLT_MATCHING_MAX) {
- off_linktype = -1;
- off_macpl = -1;
- off_nl = -1;
- off_nl_nosnap = -1;
- return;
+ if (cstate->linktype >= DLT_MATCHING_MIN &&
+ cstate->linktype <= DLT_MATCHING_MAX) {
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
+ cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
+ cstate->off_nl = -1;
+ cstate->off_nl_nosnap = -1;
+ } else {
+ bpf_error(cstate, "unknown data link type %d", cstate->linktype);
}
-
+ break;
}
- bpf_error("unknown data link type %d", linktype);
- /* NOTREACHED */
-}
-
-/*
- * Load a value relative to the beginning of the link-layer header.
- * The link-layer header doesn't necessarily begin at the beginning
- * of the packet data; there might be a variable-length prefix containing
- * radio information.
- */
-static struct slist *
-gen_load_llrel(offset, size)
- u_int offset, size;
-{
- struct slist *s, *s2;
-
- s = gen_llprefixlen();
- /*
- * If "s" is non-null, it has code to arrange that the X register
- * contains the length of the prefix preceding the link-layer
- * header.
- *
- * Otherwise, the length of the prefix preceding the link-layer
- * header is "off_ll".
- */
- if (s != NULL) {
- /*
- * There's a variable-length prefix preceding the
- * link-layer header. "s" points to a list of statements
- * that put the length of that prefix into the X register.
- * do an indirect load, to use the X register as an offset.
- */
- s2 = new_stmt(BPF_LD|BPF_IND|size);
- s2->s.k = offset;
- sappend(s, s2);
- } else {
- /*
- * There is no variable-length header preceding the
- * link-layer header; add in off_ll, which, if there's
- * a fixed-length header preceding the link-layer header,
- * is the length of that header.
- */
- s = new_stmt(BPF_LD|BPF_ABS|size);
- s->s.k = offset + off_ll;
- }
- return s;
+ cstate->off_outermostlinkhdr = cstate->off_prevlinkhdr = cstate->off_linkhdr;
}
/*
- * Load a value relative to the beginning of the MAC-layer payload.
+ * Load a value relative to the specified absolute offset.
*/
static struct slist *
-gen_load_macplrel(offset, size)
- u_int offset, size;
+gen_load_absoffsetrel(compiler_state_t *cstate, bpf_abs_offset *abs_offset,
+ u_int offset, u_int size)
{
struct slist *s, *s2;
- s = gen_off_macpl();
+ s = gen_abs_offset_varpart(cstate, abs_offset);
/*
- * If s is non-null, the offset of the MAC-layer payload is
- * variable, and s points to a list of instructions that
- * arrange that the X register contains that offset.
+ * If "s" is non-null, it has code to arrange that the X register
+ * contains the variable part of the absolute offset, so we
+ * generate a load relative to that, with an offset of
+ * abs_offset->constant_part + offset.
*
- * Otherwise, the offset of the MAC-layer payload is constant,
- * and is in off_macpl.
+ * Otherwise, we can do an absolute load with an offset of
+ * abs_offset->constant_part + offset.
*/
if (s != NULL) {
/*
- * The offset of the MAC-layer payload is in the X
- * register. Do an indirect load, to use the X register
- * as an offset.
+ * "s" points to a list of statements that puts the
+ * variable part of the absolute offset into the X register.
+ * Do an indirect load, to use the X register as an offset.
*/
- s2 = new_stmt(BPF_LD|BPF_IND|size);
- s2->s.k = offset;
+ s2 = new_stmt(cstate, BPF_LD|BPF_IND|size);
+ s2->s.k = abs_offset->constant_part + offset;
sappend(s, s2);
} else {
/*
- * The offset of the MAC-layer payload is constant,
- * and is in off_macpl; load the value at that offset
- * plus the specified offset.
+ * There is no variable part of the absolute offset, so
+ * just do an absolute load.
*/
- s = new_stmt(BPF_LD|BPF_ABS|size);
- s->s.k = off_macpl + offset;
+ s = new_stmt(cstate, BPF_LD|BPF_ABS|size);
+ s->s.k = abs_offset->constant_part + offset;
}
return s;
}
@@ -1569,33 +1646,44 @@ gen_load_macplrel(offset, size)
* Load a value relative to the beginning of the specified header.
*/
static struct slist *
-gen_load_a(offrel, offset, size)
- enum e_offrel offrel;
- u_int offset, size;
+gen_load_a(compiler_state_t *cstate, enum e_offrel offrel, u_int offset,
+ u_int size)
{
struct slist *s, *s2;
switch (offrel) {
case OR_PACKET:
- s = new_stmt(BPF_LD|BPF_ABS|size);
+ s = new_stmt(cstate, BPF_LD|BPF_ABS|size);
s->s.k = offset;
break;
- case OR_LINK:
- s = gen_load_llrel(offset, size);
+ case OR_LINKHDR:
+ s = gen_load_absoffsetrel(cstate, &cstate->off_linkhdr, offset, size);
break;
- case OR_MACPL:
- s = gen_load_macplrel(offset, size);
+ case OR_PREVLINKHDR:
+ s = gen_load_absoffsetrel(cstate, &cstate->off_prevlinkhdr, offset, size);
break;
- case OR_NET:
- s = gen_load_macplrel(off_nl + offset, size);
+ case OR_LLC:
+ s = gen_load_absoffsetrel(cstate, &cstate->off_linkpl, offset, size);
break;
- case OR_NET_NOSNAP:
- s = gen_load_macplrel(off_nl_nosnap + offset, size);
+ case OR_PREVMPLSHDR:
+ s = gen_load_absoffsetrel(cstate, &cstate->off_linkpl, cstate->off_nl - 4 + offset, size);
+ break;
+
+ case OR_LINKPL:
+ s = gen_load_absoffsetrel(cstate, &cstate->off_linkpl, cstate->off_nl + offset, size);
+ break;
+
+ case OR_LINKPL_NOSNAP:
+ s = gen_load_absoffsetrel(cstate, &cstate->off_linkpl, cstate->off_nl_nosnap + offset, size);
+ break;
+
+ case OR_LINKTYPE:
+ s = gen_load_absoffsetrel(cstate, &cstate->off_linktype, offset, size);
break;
case OR_TRAN_IPV4:
@@ -1605,25 +1693,26 @@ gen_load_a(offrel, offset, size)
* preceded by a variable-length header such as a radio
* header), in bytes.
*/
- s = gen_loadx_iphdrlen();
+ s = gen_loadx_iphdrlen(cstate);
/*
- * Load the item at {offset of the MAC-layer payload} +
- * {offset, relative to the start of the MAC-layer
+ * Load the item at {offset of the link-layer payload} +
+ * {offset, relative to the start of the link-layer
* paylod, of the IPv4 header} + {length of the IPv4 header} +
* {specified offset}.
*
- * (If the offset of the MAC-layer payload is variable,
- * it's included in the value in the X register, and
- * off_macpl is 0.)
+ * If the offset of the link-layer payload is variable,
+ * the variable part of that offset is included in the
+ * value in the X register, and we include the constant
+ * part in the offset of the load.
*/
- s2 = new_stmt(BPF_LD|BPF_IND|size);
- s2->s.k = off_macpl + off_nl + offset;
+ s2 = new_stmt(cstate, BPF_LD|BPF_IND|size);
+ s2->s.k = cstate->off_linkpl.constant_part + cstate->off_nl + offset;
sappend(s, s2);
break;
case OR_TRAN_IPV6:
- s = gen_load_macplrel(off_nl + 40 + offset, size);
+ s = gen_load_absoffsetrel(cstate, &cstate->off_linkpl, cstate->off_nl + 40 + offset, size);
break;
default:
@@ -1635,87 +1724,87 @@ gen_load_a(offrel, offset, size)
/*
* Generate code to load into the X register the sum of the length of
- * the IPv4 header and any variable-length header preceding the link-layer
- * header.
+ * the IPv4 header and the variable part of the offset of the link-layer
+ * payload.
*/
static struct slist *
-gen_loadx_iphdrlen()
+gen_loadx_iphdrlen(compiler_state_t *cstate)
{
struct slist *s, *s2;
- s = gen_off_macpl();
+ s = gen_abs_offset_varpart(cstate, &cstate->off_linkpl);
if (s != NULL) {
/*
- * There's a variable-length prefix preceding the
- * link-layer header, or the link-layer header is itself
- * variable-length. "s" points to a list of statements
- * that put the offset of the MAC-layer payload into
- * the X register.
+ * The offset of the link-layer payload has a variable
+ * part. "s" points to a list of statements that put
+ * the variable part of that offset into the X register.
*
* The 4*([k]&0xf) addressing mode can't be used, as we
* don't have a constant offset, so we have to load the
* value in question into the A register and add to it
* the value from the X register.
*/
- s2 = new_stmt(BPF_LD|BPF_IND|BPF_B);
- s2->s.k = off_nl;
+ s2 = new_stmt(cstate, BPF_LD|BPF_IND|BPF_B);
+ s2->s.k = cstate->off_linkpl.constant_part + cstate->off_nl;
sappend(s, s2);
- s2 = new_stmt(BPF_ALU|BPF_AND|BPF_K);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_AND|BPF_K);
s2->s.k = 0xf;
sappend(s, s2);
- s2 = new_stmt(BPF_ALU|BPF_LSH|BPF_K);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_LSH|BPF_K);
s2->s.k = 2;
sappend(s, s2);
/*
- * The A register now contains the length of the
- * IP header. We need to add to it the offset of
- * the MAC-layer payload, which is still in the X
+ * The A register now contains the length of the IP header.
+ * We need to add to it the variable part of the offset of
+ * the link-layer payload, which is still in the X
* register, and move the result into the X register.
*/
- sappend(s, new_stmt(BPF_ALU|BPF_ADD|BPF_X));
- sappend(s, new_stmt(BPF_MISC|BPF_TAX));
+ sappend(s, new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_X));
+ sappend(s, new_stmt(cstate, BPF_MISC|BPF_TAX));
} else {
/*
- * There is no variable-length header preceding the
- * link-layer header, and the link-layer header is
- * fixed-length; load the length of the IPv4 header,
- * which is at an offset of off_nl from the beginning
- * of the MAC-layer payload, and thus at an offset
- * of off_mac_pl + off_nl from the beginning of the
- * raw packet data.
- */
- s = new_stmt(BPF_LDX|BPF_MSH|BPF_B);
- s->s.k = off_macpl + off_nl;
+ * The offset of the link-layer payload is a constant,
+ * so no code was generated to load the (non-existent)
+ * variable part of that offset.
+ *
+ * This means we can use the 4*([k]&0xf) addressing
+ * mode. Load the length of the IPv4 header, which
+ * is at an offset of cstate->off_nl from the beginning of
+ * the link-layer payload, and thus at an offset of
+ * cstate->off_linkpl.constant_part + cstate->off_nl from the beginning
+ * of the raw packet data, using that addressing mode.
+ */
+ s = new_stmt(cstate, BPF_LDX|BPF_MSH|BPF_B);
+ s->s.k = cstate->off_linkpl.constant_part + cstate->off_nl;
}
return s;
}
static struct block *
-gen_uncond(rsense)
- int rsense;
+gen_uncond(compiler_state_t *cstate, int rsense)
{
struct block *b;
struct slist *s;
- s = new_stmt(BPF_LD|BPF_IMM);
+ s = new_stmt(cstate, BPF_LD|BPF_IMM);
s->s.k = !rsense;
- b = new_block(JMP(BPF_JEQ));
+ b = new_block(cstate, JMP(BPF_JEQ));
b->stmts = s;
return b;
}
static inline struct block *
-gen_true()
+gen_true(compiler_state_t *cstate)
{
- return gen_uncond(1);
+ return gen_uncond(cstate, 1);
}
static inline struct block *
-gen_false()
+gen_false(compiler_state_t *cstate)
{
- return gen_uncond(0);
+ return gen_uncond(cstate, 0);
}
/*
@@ -1736,8 +1825,7 @@ gen_false()
* the appropriate test.
*/
static struct block *
-gen_ether_linktype(proto)
- register int proto;
+gen_ether_linktype(compiler_state_t *cstate, int proto)
{
struct block *b0, *b1;
@@ -1758,9 +1846,9 @@ gen_ether_linktype(proto)
* DSAP, as we do for other types <= ETHERMTU
* (i.e., other SAP values)?
*/
- b0 = gen_cmp_gt(OR_LINK, off_linktype, BPF_H, ETHERMTU);
+ b0 = gen_cmp_gt(cstate, OR_LINKTYPE, 0, BPF_H, ETHERMTU);
gen_not(b0);
- b1 = gen_cmp(OR_MACPL, 0, BPF_H, (bpf_int32)
+ b1 = gen_cmp(cstate, OR_LLC, 0, BPF_H, (bpf_int32)
((proto << 8) | proto));
gen_and(b0, b1);
return b1;
@@ -1798,22 +1886,22 @@ gen_ether_linktype(proto)
* This generates code to check both for the
* IPX LSAP (Ethernet_802.2) and for Ethernet_802.3.
*/
- b0 = gen_cmp(OR_MACPL, 0, BPF_B, (bpf_int32)LLCSAP_IPX);
- b1 = gen_cmp(OR_MACPL, 0, BPF_H, (bpf_int32)0xFFFF);
+ b0 = gen_cmp(cstate, OR_LLC, 0, BPF_B, (bpf_int32)LLCSAP_IPX);
+ b1 = gen_cmp(cstate, OR_LLC, 0, BPF_H, (bpf_int32)0xFFFF);
gen_or(b0, b1);
/*
* Now we add code to check for SNAP frames with
* ETHERTYPE_IPX, i.e. Ethernet_SNAP.
*/
- b0 = gen_snap(0x000000, ETHERTYPE_IPX);
+ b0 = gen_snap(cstate, 0x000000, ETHERTYPE_IPX);
gen_or(b0, b1);
/*
* Now we generate code to check for 802.3
* frames in general.
*/
- b0 = gen_cmp_gt(OR_LINK, off_linktype, BPF_H, ETHERMTU);
+ b0 = gen_cmp_gt(cstate, OR_LINKTYPE, 0, BPF_H, ETHERMTU);
gen_not(b0);
/*
@@ -1829,8 +1917,7 @@ gen_ether_linktype(proto)
* do that before checking for the other frame
* types.
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H,
- (bpf_int32)ETHERTYPE_IPX);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)ETHERTYPE_IPX);
gen_or(b0, b1);
return b1;
@@ -1846,7 +1933,7 @@ gen_ether_linktype(proto)
* we check for an Ethernet type field less than
* 1500, which means it's an 802.3 length field.
*/
- b0 = gen_cmp_gt(OR_LINK, off_linktype, BPF_H, ETHERMTU);
+ b0 = gen_cmp_gt(cstate, OR_LINKTYPE, 0, BPF_H, ETHERMTU);
gen_not(b0);
/*
@@ -1861,9 +1948,9 @@ gen_ether_linktype(proto)
* type of ETHERTYPE_AARP (Appletalk ARP).
*/
if (proto == ETHERTYPE_ATALK)
- b1 = gen_snap(0x080007, ETHERTYPE_ATALK);
+ b1 = gen_snap(cstate, 0x080007, ETHERTYPE_ATALK);
else /* proto == ETHERTYPE_AARP */
- b1 = gen_snap(0x000000, ETHERTYPE_AARP);
+ b1 = gen_snap(cstate, 0x000000, ETHERTYPE_AARP);
gen_and(b0, b1);
/*
@@ -1871,7 +1958,7 @@ gen_ether_linktype(proto)
* phase 1?); we just check for the Ethernet
* protocol type.
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H, (bpf_int32)proto);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)proto);
gen_or(b0, b1);
return b1;
@@ -1886,10 +1973,9 @@ gen_ether_linktype(proto)
* a length field, <= ETHERMTU) and
* then check the DSAP.
*/
- b0 = gen_cmp_gt(OR_LINK, off_linktype, BPF_H, ETHERMTU);
+ b0 = gen_cmp_gt(cstate, OR_LINKTYPE, 0, BPF_H, ETHERMTU);
gen_not(b0);
- b1 = gen_cmp(OR_LINK, off_linktype + 2, BPF_B,
- (bpf_int32)proto);
+ b1 = gen_cmp(cstate, OR_LINKTYPE, 2, BPF_B, (bpf_int32)proto);
gen_and(b0, b1);
return b1;
} else {
@@ -1902,29 +1988,62 @@ gen_ether_linktype(proto)
* will fail and the frame won't match,
* which is what we want).
*/
- return gen_cmp(OR_LINK, off_linktype, BPF_H,
+ return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H,
(bpf_int32)proto);
}
}
}
+static struct block *
+gen_loopback_linktype(compiler_state_t *cstate, int proto)
+{
+ /*
+ * For DLT_NULL, the link-layer header is a 32-bit word
+ * containing an AF_ value in *host* byte order, and for
+ * DLT_ENC, the link-layer header begins with a 32-bit
+ * word containing an AF_ value in host byte order.
+ *
+ * In addition, if we're reading a saved capture file,
+ * the host byte order in the capture may not be the
+ * same as the host byte order on this machine.
+ *
+ * For DLT_LOOP, the link-layer header is a 32-bit
+ * word containing an AF_ value in *network* byte order.
+ */
+ if (cstate->linktype == DLT_NULL || cstate->linktype == DLT_ENC) {
+ /*
+ * The AF_ value is in host byte order, but the BPF
+ * interpreter will convert it to network byte order.
+ *
+ * If this is a save file, and it's from a machine
+ * with the opposite byte order to ours, we byte-swap
+ * the AF_ value.
+ *
+ * Then we run it through "htonl()", and generate
+ * code to compare against the result.
+ */
+ if (cstate->bpf_pcap->rfile != NULL && cstate->bpf_pcap->swapped)
+ proto = SWAPLONG(proto);
+ proto = htonl(proto);
+ }
+ return (gen_cmp(cstate, OR_LINKHDR, 0, BPF_W, (bpf_int32)proto));
+}
+
/*
* "proto" is an Ethernet type value and for IPNET, if it is not IPv4
* or IPv6 then we have an error.
*/
static struct block *
-gen_ipnet_linktype(proto)
- register int proto;
+gen_ipnet_linktype(compiler_state_t *cstate, int proto)
{
switch (proto) {
case ETHERTYPE_IP:
- return gen_cmp(OR_LINK, off_linktype, BPF_B,
- (bpf_int32)IPH_AF_INET);
+ return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B, (bpf_int32)IPH_AF_INET);
/* NOTREACHED */
case ETHERTYPE_IPV6:
- return gen_cmp(OR_LINK, off_linktype, BPF_B,
+ return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B,
(bpf_int32)IPH_AF_INET6);
/* NOTREACHED */
@@ -1932,7 +2051,7 @@ gen_ipnet_linktype(proto)
break;
}
- return gen_false();
+ return gen_false(cstate);
}
/*
@@ -1944,8 +2063,7 @@ gen_ipnet_linktype(proto)
* LINUX_SLL_P_802_2 value and then do the appropriate test.
*/
static struct block *
-gen_linux_sll_linktype(proto)
- register int proto;
+gen_linux_sll_linktype(compiler_state_t *cstate, int proto)
{
struct block *b0, *b1;
@@ -1966,8 +2084,8 @@ gen_linux_sll_linktype(proto)
* DSAP, as we do for other types <= ETHERMTU
* (i.e., other SAP values)?
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H, LINUX_SLL_P_802_2);
- b1 = gen_cmp(OR_MACPL, 0, BPF_H, (bpf_int32)
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, LINUX_SLL_P_802_2);
+ b1 = gen_cmp(cstate, OR_LLC, 0, BPF_H, (bpf_int32)
((proto << 8) | proto));
gen_and(b0, b1);
return b1;
@@ -1998,17 +2116,17 @@ gen_linux_sll_linktype(proto)
* then put a check for LINUX_SLL_P_802_2 frames
* before it.
*/
- b0 = gen_cmp(OR_MACPL, 0, BPF_B, (bpf_int32)LLCSAP_IPX);
- b1 = gen_snap(0x000000, ETHERTYPE_IPX);
+ b0 = gen_cmp(cstate, OR_LLC, 0, BPF_B, (bpf_int32)LLCSAP_IPX);
+ b1 = gen_snap(cstate, 0x000000, ETHERTYPE_IPX);
gen_or(b0, b1);
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H, LINUX_SLL_P_802_2);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, LINUX_SLL_P_802_2);
gen_and(b0, b1);
/*
* Now check for 802.3 frames and OR that with
* the previous test.
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H, LINUX_SLL_P_802_3);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, LINUX_SLL_P_802_3);
gen_or(b0, b1);
/*
@@ -2016,8 +2134,7 @@ gen_linux_sll_linktype(proto)
* do that before checking for the other frame
* types.
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H,
- (bpf_int32)ETHERTYPE_IPX);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)ETHERTYPE_IPX);
gen_or(b0, b1);
return b1;
@@ -2033,7 +2150,7 @@ gen_linux_sll_linktype(proto)
* we check for the 802.2 protocol type in the
* "Ethernet type" field.
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H, LINUX_SLL_P_802_2);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, LINUX_SLL_P_802_2);
/*
* 802.2-encapsulated ETHERTYPE_ATALK packets are
@@ -2047,9 +2164,9 @@ gen_linux_sll_linktype(proto)
* type of ETHERTYPE_AARP (Appletalk ARP).
*/
if (proto == ETHERTYPE_ATALK)
- b1 = gen_snap(0x080007, ETHERTYPE_ATALK);
+ b1 = gen_snap(cstate, 0x080007, ETHERTYPE_ATALK);
else /* proto == ETHERTYPE_AARP */
- b1 = gen_snap(0x000000, ETHERTYPE_AARP);
+ b1 = gen_snap(cstate, 0x000000, ETHERTYPE_AARP);
gen_and(b0, b1);
/*
@@ -2057,7 +2174,7 @@ gen_linux_sll_linktype(proto)
* phase 1?); we just check for the Ethernet
* protocol type.
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H, (bpf_int32)proto);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)proto);
gen_or(b0, b1);
return b1;
@@ -2071,9 +2188,8 @@ gen_linux_sll_linktype(proto)
* in the "Ethernet type" field, and
* then check the DSAP.
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H,
- LINUX_SLL_P_802_2);
- b1 = gen_cmp(OR_LINK, off_macpl, BPF_B,
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, LINUX_SLL_P_802_2);
+ b1 = gen_cmp(cstate, OR_LINKHDR, cstate->off_linkpl.constant_part, BPF_B,
(bpf_int32)proto);
gen_and(b0, b1);
return b1;
@@ -2087,14 +2203,13 @@ gen_linux_sll_linktype(proto)
* will fail and the frame won't match,
* which is what we want).
*/
- return gen_cmp(OR_LINK, off_linktype, BPF_H,
- (bpf_int32)proto);
+ return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)proto);
}
}
}
static struct slist *
-gen_load_prism_llprefixlen()
+gen_load_prism_llprefixlen(compiler_state_t *cstate)
{
struct slist *s1, *s2;
struct slist *sjeq_avs_cookie;
@@ -2105,7 +2220,7 @@ gen_load_prism_llprefixlen()
* we are generating jmp instructions within a normal
* slist of instructions
*/
- no_optimize = 1;
+ cstate->no_optimize = 1;
/*
* Generate code to load the length of the radio header into
@@ -2126,24 +2241,24 @@ gen_load_prism_llprefixlen()
* but no known software generates headers that aren't 144
* bytes long.
*/
- if (reg_off_ll != -1) {
+ if (cstate->off_linkhdr.reg != -1) {
/*
* Load the cookie.
*/
- s1 = new_stmt(BPF_LD|BPF_W|BPF_ABS);
+ s1 = new_stmt(cstate, BPF_LD|BPF_W|BPF_ABS);
s1->s.k = 0;
/*
* AND it with 0xFFFFF000.
*/
- s2 = new_stmt(BPF_ALU|BPF_AND|BPF_K);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_AND|BPF_K);
s2->s.k = 0xFFFFF000;
sappend(s1, s2);
/*
* Compare with 0x80211000.
*/
- sjeq_avs_cookie = new_stmt(JMP(BPF_JEQ));
+ sjeq_avs_cookie = new_stmt(cstate, JMP(BPF_JEQ));
sjeq_avs_cookie->s.k = 0x80211000;
sappend(s1, sjeq_avs_cookie);
@@ -2154,7 +2269,7 @@ gen_load_prism_llprefixlen()
* the AVS header are the length of the AVS header.
* That field is big-endian.
*/
- s2 = new_stmt(BPF_LD|BPF_W|BPF_ABS);
+ s2 = new_stmt(cstate, BPF_LD|BPF_W|BPF_ABS);
s2->s.k = 4;
sappend(s1, s2);
sjeq_avs_cookie->s.jt = s2;
@@ -2167,7 +2282,7 @@ gen_load_prism_llprefixlen()
* it's added to the PC, so, as we're jumping
* over a single instruction, it should be 1.)
*/
- sjcommon = new_stmt(JMP(BPF_JA));
+ sjcommon = new_stmt(cstate, JMP(BPF_JA));
sjcommon->s.k = 1;
sappend(s1, sjcommon);
@@ -2177,7 +2292,7 @@ gen_load_prism_llprefixlen()
* into the A register. Have the test for an AVS
* header branch here if we don't have an AVS header.
*/
- s2 = new_stmt(BPF_LD|BPF_W|BPF_IMM);
+ s2 = new_stmt(cstate, BPF_LD|BPF_W|BPF_IMM);
s2->s.k = 144;
sappend(s1, s2);
sjeq_avs_cookie->s.jf = s2;
@@ -2187,15 +2302,15 @@ gen_load_prism_llprefixlen()
* it. The code for the AVS header will jump here after
* loading the length of the AVS header.
*/
- s2 = new_stmt(BPF_ST);
- s2->s.k = reg_off_ll;
+ s2 = new_stmt(cstate, BPF_ST);
+ s2->s.k = cstate->off_linkhdr.reg;
sappend(s1, s2);
sjcommon->s.jf = s2;
/*
* Now move it into the X register.
*/
- s2 = new_stmt(BPF_MISC|BPF_TAX);
+ s2 = new_stmt(cstate, BPF_MISC|BPF_TAX);
sappend(s1, s2);
return (s1);
@@ -2204,7 +2319,7 @@ gen_load_prism_llprefixlen()
}
static struct slist *
-gen_load_avs_llprefixlen()
+gen_load_avs_llprefixlen(compiler_state_t *cstate)
{
struct slist *s1, *s2;
@@ -2215,27 +2330,27 @@ gen_load_avs_llprefixlen()
* generated uses that prefix, so we don't need to generate any
* code to load it.)
*/
- if (reg_off_ll != -1) {
+ if (cstate->off_linkhdr.reg != -1) {
/*
* The 4 bytes at an offset of 4 from the beginning of
* the AVS header are the length of the AVS header.
* That field is big-endian.
*/
- s1 = new_stmt(BPF_LD|BPF_W|BPF_ABS);
+ s1 = new_stmt(cstate, BPF_LD|BPF_W|BPF_ABS);
s1->s.k = 4;
/*
* Now allocate a register to hold that value and store
* it.
*/
- s2 = new_stmt(BPF_ST);
- s2->s.k = reg_off_ll;
+ s2 = new_stmt(cstate, BPF_ST);
+ s2->s.k = cstate->off_linkhdr.reg;
sappend(s1, s2);
/*
* Now move it into the X register.
*/
- s2 = new_stmt(BPF_MISC|BPF_TAX);
+ s2 = new_stmt(cstate, BPF_MISC|BPF_TAX);
sappend(s1, s2);
return (s1);
@@ -2244,7 +2359,7 @@ gen_load_avs_llprefixlen()
}
static struct slist *
-gen_load_radiotap_llprefixlen()
+gen_load_radiotap_llprefixlen(compiler_state_t *cstate)
{
struct slist *s1, *s2;
@@ -2255,7 +2370,7 @@ gen_load_radiotap_llprefixlen()
* generated uses that prefix, so we don't need to generate any
* code to load it.)
*/
- if (reg_off_ll != -1) {
+ if (cstate->off_linkhdr.reg != -1) {
/*
* The 2 bytes at offsets of 2 and 3 from the beginning
* of the radiotap header are the length of the radiotap
@@ -2267,36 +2382,36 @@ gen_load_radiotap_llprefixlen()
* Load the high-order byte, at an offset of 3, shift it
* left a byte, and put the result in the X register.
*/
- s1 = new_stmt(BPF_LD|BPF_B|BPF_ABS);
+ s1 = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS);
s1->s.k = 3;
- s2 = new_stmt(BPF_ALU|BPF_LSH|BPF_K);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_LSH|BPF_K);
sappend(s1, s2);
s2->s.k = 8;
- s2 = new_stmt(BPF_MISC|BPF_TAX);
+ s2 = new_stmt(cstate, BPF_MISC|BPF_TAX);
sappend(s1, s2);
/*
* Load the next byte, at an offset of 2, and OR the
* value from the X register into it.
*/
- s2 = new_stmt(BPF_LD|BPF_B|BPF_ABS);
+ s2 = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS);
sappend(s1, s2);
s2->s.k = 2;
- s2 = new_stmt(BPF_ALU|BPF_OR|BPF_X);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_OR|BPF_X);
sappend(s1, s2);
/*
* Now allocate a register to hold that value and store
* it.
*/
- s2 = new_stmt(BPF_ST);
- s2->s.k = reg_off_ll;
+ s2 = new_stmt(cstate, BPF_ST);
+ s2->s.k = cstate->off_linkhdr.reg;
sappend(s1, s2);
/*
* Now move it into the X register.
*/
- s2 = new_stmt(BPF_MISC|BPF_TAX);
+ s2 = new_stmt(cstate, BPF_MISC|BPF_TAX);
sappend(s1, s2);
return (s1);
@@ -2314,7 +2429,7 @@ gen_load_radiotap_llprefixlen()
* that's done in finish_parse().
*/
static struct slist *
-gen_load_ppi_llprefixlen()
+gen_load_ppi_llprefixlen(compiler_state_t *cstate)
{
struct slist *s1, *s2;
@@ -2323,7 +2438,7 @@ gen_load_ppi_llprefixlen()
* into the register assigned to hold that length, if one has
* been assigned.
*/
- if (reg_off_ll != -1) {
+ if (cstate->off_linkhdr.reg != -1) {
/*
* The 2 bytes at offsets of 2 and 3 from the beginning
* of the radiotap header are the length of the radiotap
@@ -2335,36 +2450,36 @@ gen_load_ppi_llprefixlen()
* Load the high-order byte, at an offset of 3, shift it
* left a byte, and put the result in the X register.
*/
- s1 = new_stmt(BPF_LD|BPF_B|BPF_ABS);
+ s1 = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS);
s1->s.k = 3;
- s2 = new_stmt(BPF_ALU|BPF_LSH|BPF_K);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_LSH|BPF_K);
sappend(s1, s2);
s2->s.k = 8;
- s2 = new_stmt(BPF_MISC|BPF_TAX);
+ s2 = new_stmt(cstate, BPF_MISC|BPF_TAX);
sappend(s1, s2);
/*
* Load the next byte, at an offset of 2, and OR the
* value from the X register into it.
*/
- s2 = new_stmt(BPF_LD|BPF_B|BPF_ABS);
+ s2 = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS);
sappend(s1, s2);
s2->s.k = 2;
- s2 = new_stmt(BPF_ALU|BPF_OR|BPF_X);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_OR|BPF_X);
sappend(s1, s2);
/*
* Now allocate a register to hold that value and store
* it.
*/
- s2 = new_stmt(BPF_ST);
- s2->s.k = reg_off_ll;
+ s2 = new_stmt(cstate, BPF_ST);
+ s2->s.k = cstate->off_linkhdr.reg;
sappend(s1, s2);
/*
* Now move it into the X register.
*/
- s2 = new_stmt(BPF_MISC|BPF_TAX);
+ s2 = new_stmt(cstate, BPF_MISC|BPF_TAX);
sappend(s1, s2);
return (s1);
@@ -2380,21 +2495,22 @@ gen_load_ppi_llprefixlen()
* radio information.
*/
static struct slist *
-gen_load_802_11_header_len(struct slist *s, struct slist *snext)
+gen_load_802_11_header_len(compiler_state_t *cstate, struct slist *s, struct slist *snext)
{
struct slist *s2;
struct slist *sjset_data_frame_1;
struct slist *sjset_data_frame_2;
struct slist *sjset_qos;
- struct slist *sjset_radiotap_flags;
- struct slist *sjset_radiotap_tsft;
+ struct slist *sjset_radiotap_flags_present;
+ struct slist *sjset_radiotap_ext_present;
+ struct slist *sjset_radiotap_tsft_present;
struct slist *sjset_tsft_datapad, *sjset_notsft_datapad;
struct slist *s_roundup;
- if (reg_off_macpl == -1) {
+ if (cstate->off_linkpl.reg == -1) {
/*
* No register has been assigned to the offset of
- * the MAC-layer payload, which means nobody needs
+ * the link-layer payload, which means nobody needs
* it; don't bother computing it - just return
* what we already have.
*/
@@ -2406,7 +2522,7 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* we are generating jmp instructions within a normal
* slist of instructions
*/
- no_optimize = 1;
+ cstate->no_optimize = 1;
/*
* If "s" is non-null, it has code to arrange that the X register
@@ -2414,7 +2530,7 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* header.
*
* Otherwise, the length of the prefix preceding the link-layer
- * header is "off_ll".
+ * header is "off_outermostlinkhdr.constant_part".
*/
if (s == NULL) {
/*
@@ -2423,30 +2539,30 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
*
* Load the length of the fixed-length prefix preceding
* the link-layer header (if any) into the X register,
- * and store it in the reg_off_macpl register.
- * That length is off_ll.
+ * and store it in the cstate->off_linkpl.reg register.
+ * That length is off_outermostlinkhdr.constant_part.
*/
- s = new_stmt(BPF_LDX|BPF_IMM);
- s->s.k = off_ll;
+ s = new_stmt(cstate, BPF_LDX|BPF_IMM);
+ s->s.k = cstate->off_outermostlinkhdr.constant_part;
}
/*
* The X register contains the offset of the beginning of the
* link-layer header; add 24, which is the minimum length
* of the MAC header for a data frame, to that, and store it
- * in reg_off_macpl, and then load the Frame Control field,
+ * in cstate->off_linkpl.reg, and then load the Frame Control field,
* which is at the offset in the X register, with an indexed load.
*/
- s2 = new_stmt(BPF_MISC|BPF_TXA);
+ s2 = new_stmt(cstate, BPF_MISC|BPF_TXA);
sappend(s, s2);
- s2 = new_stmt(BPF_ALU|BPF_ADD|BPF_K);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_K);
s2->s.k = 24;
sappend(s, s2);
- s2 = new_stmt(BPF_ST);
- s2->s.k = reg_off_macpl;
+ s2 = new_stmt(cstate, BPF_ST);
+ s2->s.k = cstate->off_linkpl.reg;
sappend(s, s2);
- s2 = new_stmt(BPF_LD|BPF_IND|BPF_B);
+ s2 = new_stmt(cstate, BPF_LD|BPF_IND|BPF_B);
s2->s.k = 0;
sappend(s, s2);
@@ -2455,7 +2571,7 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* a data frame has the 0x08 bit (b3) in that field set and the
* 0x04 bit (b2) clear.
*/
- sjset_data_frame_1 = new_stmt(JMP(BPF_JSET));
+ sjset_data_frame_1 = new_stmt(cstate, JMP(BPF_JSET));
sjset_data_frame_1->s.k = 0x08;
sappend(s, sjset_data_frame_1);
@@ -2463,7 +2579,7 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* If b3 is set, test b2, otherwise go to the first statement of
* the rest of the program.
*/
- sjset_data_frame_1->s.jt = sjset_data_frame_2 = new_stmt(JMP(BPF_JSET));
+ sjset_data_frame_1->s.jt = sjset_data_frame_2 = new_stmt(cstate, JMP(BPF_JSET));
sjset_data_frame_2->s.k = 0x04;
sappend(s, sjset_data_frame_2);
sjset_data_frame_1->s.jf = snext;
@@ -2474,24 +2590,24 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* program.
*/
sjset_data_frame_2->s.jt = snext;
- sjset_data_frame_2->s.jf = sjset_qos = new_stmt(JMP(BPF_JSET));
+ sjset_data_frame_2->s.jf = sjset_qos = new_stmt(cstate, JMP(BPF_JSET));
sjset_qos->s.k = 0x80; /* QoS bit */
sappend(s, sjset_qos);
/*
- * If it's set, add 2 to reg_off_macpl, to skip the QoS
+ * If it's set, add 2 to cstate->off_linkpl.reg, to skip the QoS
* field.
* Otherwise, go to the first statement of the rest of the
* program.
*/
- sjset_qos->s.jt = s2 = new_stmt(BPF_LD|BPF_MEM);
- s2->s.k = reg_off_macpl;
+ sjset_qos->s.jt = s2 = new_stmt(cstate, BPF_LD|BPF_MEM);
+ s2->s.k = cstate->off_linkpl.reg;
sappend(s, s2);
- s2 = new_stmt(BPF_ALU|BPF_ADD|BPF_IMM);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_IMM);
s2->s.k = 2;
sappend(s, s2);
- s2 = new_stmt(BPF_ST);
- s2->s.k = reg_off_macpl;
+ s2 = new_stmt(cstate, BPF_ST);
+ s2->s.k = cstate->off_linkpl.reg;
sappend(s, s2);
/*
@@ -2503,32 +2619,54 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* little-endian, so we byte-swap all of the values
* we test against, as they will be loaded as big-endian
* values.
+ *
+ * XXX - in the general case, we would have to scan through
+ * *all* the presence bits, if there's more than one word of
+ * presence bits. That would require a loop, meaning that
+ * we wouldn't be able to run the filter in the kernel.
+ *
+ * We assume here that the Atheros adapters that insert the
+ * annoying padding don't have multiple antennae and therefore
+ * do not generate radiotap headers with multiple presence words.
*/
- if (linktype == DLT_IEEE802_11_RADIO) {
+ if (cstate->linktype == DLT_IEEE802_11_RADIO) {
/*
* Is the IEEE80211_RADIOTAP_FLAGS bit (0x0000002) set
- * in the presence flag?
+ * in the first presence flag word?
*/
- sjset_qos->s.jf = s2 = new_stmt(BPF_LD|BPF_ABS|BPF_W);
+ sjset_qos->s.jf = s2 = new_stmt(cstate, BPF_LD|BPF_ABS|BPF_W);
s2->s.k = 4;
sappend(s, s2);
- sjset_radiotap_flags = new_stmt(JMP(BPF_JSET));
- sjset_radiotap_flags->s.k = SWAPLONG(0x00000002);
- sappend(s, sjset_radiotap_flags);
+ sjset_radiotap_flags_present = new_stmt(cstate, JMP(BPF_JSET));
+ sjset_radiotap_flags_present->s.k = SWAPLONG(0x00000002);
+ sappend(s, sjset_radiotap_flags_present);
/*
* If not, skip all of this.
*/
- sjset_radiotap_flags->s.jf = snext;
+ sjset_radiotap_flags_present->s.jf = snext;
+
+ /*
+ * Otherwise, is the "extension" bit set in that word?
+ */
+ sjset_radiotap_ext_present = new_stmt(cstate, JMP(BPF_JSET));
+ sjset_radiotap_ext_present->s.k = SWAPLONG(0x80000000);
+ sappend(s, sjset_radiotap_ext_present);
+ sjset_radiotap_flags_present->s.jt = sjset_radiotap_ext_present;
+
+ /*
+ * If so, skip all of this.
+ */
+ sjset_radiotap_ext_present->s.jt = snext;
/*
* Otherwise, is the IEEE80211_RADIOTAP_TSFT bit set?
*/
- sjset_radiotap_tsft = sjset_radiotap_flags->s.jt =
- new_stmt(JMP(BPF_JSET));
- sjset_radiotap_tsft->s.k = SWAPLONG(0x00000001);
- sappend(s, sjset_radiotap_tsft);
+ sjset_radiotap_tsft_present = new_stmt(cstate, JMP(BPF_JSET));
+ sjset_radiotap_tsft_present->s.k = SWAPLONG(0x00000001);
+ sappend(s, sjset_radiotap_tsft_present);
+ sjset_radiotap_ext_present->s.jf = sjset_radiotap_tsft_present;
/*
* If IEEE80211_RADIOTAP_TSFT is set, the flags field is
@@ -2539,11 +2677,12 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* Test whether the IEEE80211_RADIOTAP_F_DATAPAD bit (0x20)
* is set.
*/
- sjset_radiotap_tsft->s.jt = s2 = new_stmt(BPF_LD|BPF_ABS|BPF_B);
+ s2 = new_stmt(cstate, BPF_LD|BPF_ABS|BPF_B);
s2->s.k = 16;
sappend(s, s2);
+ sjset_radiotap_tsft_present->s.jt = s2;
- sjset_tsft_datapad = new_stmt(JMP(BPF_JSET));
+ sjset_tsft_datapad = new_stmt(cstate, JMP(BPF_JSET));
sjset_tsft_datapad->s.k = 0x20;
sappend(s, sjset_tsft_datapad);
@@ -2555,11 +2694,12 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* Test whether the IEEE80211_RADIOTAP_F_DATAPAD bit (0x20)
* is set.
*/
- sjset_radiotap_tsft->s.jf = s2 = new_stmt(BPF_LD|BPF_ABS|BPF_B);
+ s2 = new_stmt(cstate, BPF_LD|BPF_ABS|BPF_B);
s2->s.k = 8;
sappend(s, s2);
+ sjset_radiotap_tsft_present->s.jf = s2;
- sjset_notsft_datapad = new_stmt(JMP(BPF_JSET));
+ sjset_notsft_datapad = new_stmt(cstate, JMP(BPF_JSET));
sjset_notsft_datapad->s.k = 0x20;
sappend(s, sjset_notsft_datapad);
@@ -2570,17 +2710,17 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* dividing by and multiplying by 4, which we do by
* ANDing with ~3.
*/
- s_roundup = new_stmt(BPF_LD|BPF_MEM);
- s_roundup->s.k = reg_off_macpl;
+ s_roundup = new_stmt(cstate, BPF_LD|BPF_MEM);
+ s_roundup->s.k = cstate->off_linkpl.reg;
sappend(s, s_roundup);
- s2 = new_stmt(BPF_ALU|BPF_ADD|BPF_IMM);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_IMM);
s2->s.k = 3;
sappend(s, s2);
- s2 = new_stmt(BPF_ALU|BPF_AND|BPF_IMM);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_AND|BPF_IMM);
s2->s.k = ~3;
sappend(s, s2);
- s2 = new_stmt(BPF_ST);
- s2->s.k = reg_off_macpl;
+ s2 = new_stmt(cstate, BPF_ST);
+ s2->s.k = cstate->off_linkpl.reg;
sappend(s, s2);
sjset_tsft_datapad->s.jt = s_roundup;
@@ -2594,33 +2734,46 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
}
static void
-insert_compute_vloffsets(b)
- struct block *b;
+insert_compute_vloffsets(compiler_state_t *cstate, struct block *b)
{
struct slist *s;
+ /* There is an implicit dependency between the link
+ * payload and link header since the payload computation
+ * includes the variable part of the header. Therefore,
+ * if nobody else has allocated a register for the link
+ * header and we need it, do it now. */
+ if (cstate->off_linkpl.reg != -1 && cstate->off_linkhdr.is_variable &&
+ cstate->off_linkhdr.reg == -1)
+ cstate->off_linkhdr.reg = alloc_reg(cstate);
+
/*
* For link-layer types that have a variable-length header
* preceding the link-layer header, generate code to load
* the offset of the link-layer header into the register
* assigned to that offset, if any.
+ *
+ * XXX - this, and the next switch statement, won't handle
+ * encapsulation of 802.11 or 802.11+radio information in
+ * some other protocol stack. That's significantly more
+ * complicated.
*/
- switch (linktype) {
+ switch (cstate->outermostlinktype) {
case DLT_PRISM_HEADER:
- s = gen_load_prism_llprefixlen();
+ s = gen_load_prism_llprefixlen(cstate);
break;
case DLT_IEEE802_11_RADIO_AVS:
- s = gen_load_avs_llprefixlen();
+ s = gen_load_avs_llprefixlen(cstate);
break;
case DLT_IEEE802_11_RADIO:
- s = gen_load_radiotap_llprefixlen();
+ s = gen_load_radiotap_llprefixlen(cstate);
break;
case DLT_PPI:
- s = gen_load_ppi_llprefixlen();
+ s = gen_load_ppi_llprefixlen(cstate);
break;
default:
@@ -2630,17 +2783,17 @@ insert_compute_vloffsets(b)
/*
* For link-layer types that have a variable-length link-layer
- * header, generate code to load the offset of the MAC-layer
+ * header, generate code to load the offset of the link-layer
* payload into the register assigned to that offset, if any.
*/
- switch (linktype) {
+ switch (cstate->outermostlinktype) {
case DLT_IEEE802_11:
case DLT_PRISM_HEADER:
case DLT_IEEE802_11_RADIO_AVS:
case DLT_IEEE802_11_RADIO:
case DLT_PPI:
- s = gen_load_802_11_header_len(s, b->stmts);
+ s = gen_load_802_11_header_len(cstate, s, b->stmts);
break;
}
@@ -2657,19 +2810,19 @@ insert_compute_vloffsets(b)
}
static struct block *
-gen_ppi_dlt_check(void)
+gen_ppi_dlt_check(compiler_state_t *cstate)
{
struct slist *s_load_dlt;
struct block *b;
- if (linktype == DLT_PPI)
+ if (cstate->linktype == DLT_PPI)
{
/* Create the statements that check for the DLT
*/
- s_load_dlt = new_stmt(BPF_LD|BPF_W|BPF_ABS);
+ s_load_dlt = new_stmt(cstate, BPF_LD|BPF_W|BPF_ABS);
s_load_dlt->s.k = 4;
- b = new_block(JMP(BPF_JEQ));
+ b = new_block(cstate, JMP(BPF_JEQ));
b->stmts = s_load_dlt;
b->s.k = SWAPLONG(DLT_IEEE802_11);
@@ -2682,160 +2835,45 @@ gen_ppi_dlt_check(void)
return b;
}
-static struct slist *
-gen_prism_llprefixlen(void)
-{
- struct slist *s;
-
- if (reg_off_ll == -1) {
- /*
- * We haven't yet assigned a register for the length
- * of the radio header; allocate one.
- */
- reg_off_ll = alloc_reg();
- }
-
- /*
- * Load the register containing the radio length
- * into the X register.
- */
- s = new_stmt(BPF_LDX|BPF_MEM);
- s->s.k = reg_off_ll;
- return s;
-}
-
-static struct slist *
-gen_avs_llprefixlen(void)
-{
- struct slist *s;
-
- if (reg_off_ll == -1) {
- /*
- * We haven't yet assigned a register for the length
- * of the AVS header; allocate one.
- */
- reg_off_ll = alloc_reg();
- }
-
- /*
- * Load the register containing the AVS length
- * into the X register.
- */
- s = new_stmt(BPF_LDX|BPF_MEM);
- s->s.k = reg_off_ll;
- return s;
-}
-
-static struct slist *
-gen_radiotap_llprefixlen(void)
-{
- struct slist *s;
-
- if (reg_off_ll == -1) {
- /*
- * We haven't yet assigned a register for the length
- * of the radiotap header; allocate one.
- */
- reg_off_ll = alloc_reg();
- }
-
- /*
- * Load the register containing the radiotap length
- * into the X register.
- */
- s = new_stmt(BPF_LDX|BPF_MEM);
- s->s.k = reg_off_ll;
- return s;
-}
-
-/*
- * At the moment we treat PPI as normal Radiotap encoded
- * packets. The difference is in the function that generates
- * the code at the beginning to compute the header length.
- * Since this code generator of PPI supports bare 802.11
- * encapsulation only (i.e. the encapsulated DLT should be
- * DLT_IEEE802_11) we generate code to check for this too.
- */
-static struct slist *
-gen_ppi_llprefixlen(void)
-{
- struct slist *s;
-
- if (reg_off_ll == -1) {
- /*
- * We haven't yet assigned a register for the length
- * of the radiotap header; allocate one.
- */
- reg_off_ll = alloc_reg();
- }
-
- /*
- * Load the register containing the PPI length
- * into the X register.
- */
- s = new_stmt(BPF_LDX|BPF_MEM);
- s->s.k = reg_off_ll;
- return s;
-}
-
/*
- * Generate code to compute the link-layer header length, if necessary,
- * putting it into the X register, and to return either a pointer to a
- * "struct slist" for the list of statements in that code, or NULL if
- * no code is necessary.
- */
-static struct slist *
-gen_llprefixlen(void)
-{
- switch (linktype) {
-
- case DLT_PRISM_HEADER:
- return gen_prism_llprefixlen();
-
- case DLT_IEEE802_11_RADIO_AVS:
- return gen_avs_llprefixlen();
-
- case DLT_IEEE802_11_RADIO:
- return gen_radiotap_llprefixlen();
-
- case DLT_PPI:
- return gen_ppi_llprefixlen();
-
- default:
- return NULL;
- }
-}
-
-/*
- * Generate code to load the register containing the offset of the
- * MAC-layer payload into the X register; if no register for that offset
- * has been allocated, allocate it first.
+ * Take an absolute offset, and:
+ *
+ * if it has no variable part, return NULL;
+ *
+ * if it has a variable part, generate code to load the register
+ * containing that variable part into the X register, returning
+ * a pointer to that code - if no register for that offset has
+ * been allocated, allocate it first.
+ *
+ * (The code to set that register will be generated later, but will
+ * be placed earlier in the code sequence.)
*/
static struct slist *
-gen_off_macpl(void)
+gen_abs_offset_varpart(compiler_state_t *cstate, bpf_abs_offset *off)
{
struct slist *s;
- if (off_macpl_is_variable) {
- if (reg_off_macpl == -1) {
+ if (off->is_variable) {
+ if (off->reg == -1) {
/*
- * We haven't yet assigned a register for the offset
- * of the MAC-layer payload; allocate one.
+ * We haven't yet assigned a register for the
+ * variable part of the offset of the link-layer
+ * header; allocate one.
*/
- reg_off_macpl = alloc_reg();
+ off->reg = alloc_reg(cstate);
}
/*
- * Load the register containing the offset of the MAC-layer
- * payload into the X register.
+ * Load the register containing the variable part of the
+ * offset of the link-layer header into the X register.
*/
- s = new_stmt(BPF_LDX|BPF_MEM);
- s->s.k = reg_off_macpl;
+ s = new_stmt(cstate, BPF_LDX|BPF_MEM);
+ s->s.k = off->reg;
return s;
} else {
/*
- * That offset isn't variable, so we don't need to
- * generate any code.
+ * That offset isn't variable, there's no variable part,
+ * so we don't need to generate any code.
*/
return NULL;
}
@@ -2891,6 +2929,51 @@ ethertype_to_ppptype(proto)
}
/*
+ * Generate any tests that, for encapsulation of a link-layer packet
+ * inside another protocol stack, need to be done to check for those
+ * link-layer packets (and that haven't already been done by a check
+ * for that encapsulation).
+ */
+static struct block *
+gen_prevlinkhdr_check(compiler_state_t *cstate)
+{
+ struct block *b0;
+
+ if (cstate->is_geneve)
+ return gen_geneve_ll_check(cstate);
+
+ switch (cstate->prevlinktype) {
+
+ case DLT_SUNATM:
+ /*
+ * This is LANE-encapsulated Ethernet; check that the LANE
+ * packet doesn't begin with an LE Control marker, i.e.
+ * that it's data, not a control message.
+ *
+ * (We've already generated a test for LANE.)
+ */
+ b0 = gen_cmp(cstate, OR_PREVLINKHDR, SUNATM_PKT_BEGIN_POS, BPF_H, 0xFF00);
+ gen_not(b0);
+ return b0;
+
+ default:
+ /*
+ * No such tests are necessary.
+ */
+ return NULL;
+ }
+ /*NOTREACHED*/
+}
+
+/*
+ * The three different values we should check for when checking for an
+ * IPv6 packet with DLT_NULL.
+ */
+#define BSD_AFNUM_INET6_BSD 24 /* NetBSD, OpenBSD, BSD/OS, Npcap */
+#define BSD_AFNUM_INET6_FREEBSD 28 /* FreeBSD */
+#define BSD_AFNUM_INET6_DARWIN 30 /* OS X, iOS, other Darwin-based OSes */
+
+/*
* Generate code to match a particular packet type by matching the
* link-layer type field or fields in the 802.2 LLC header.
*
@@ -2898,56 +2981,46 @@ ethertype_to_ppptype(proto)
* value, if <= ETHERMTU.
*/
static struct block *
-gen_linktype(proto)
- register int proto;
+gen_linktype(compiler_state_t *cstate, int proto)
{
struct block *b0, *b1, *b2;
const char *description;
/* are we checking MPLS-encapsulated packets? */
- if (label_stack_depth > 0) {
+ if (cstate->label_stack_depth > 0) {
switch (proto) {
case ETHERTYPE_IP:
case PPP_IP:
/* FIXME add other L3 proto IDs */
- return gen_mpls_linktype(Q_IP);
+ return gen_mpls_linktype(cstate, Q_IP);
case ETHERTYPE_IPV6:
case PPP_IPV6:
/* FIXME add other L3 proto IDs */
- return gen_mpls_linktype(Q_IPV6);
+ return gen_mpls_linktype(cstate, Q_IPV6);
default:
- bpf_error("unsupported protocol over mpls");
+ bpf_error(cstate, "unsupported protocol over mpls");
/* NOTREACHED */
}
}
- /*
- * Are we testing PPPoE packets?
- */
- if (is_pppoes) {
- /*
- * The PPPoE session header is part of the
- * MAC-layer payload, so all references
- * should be relative to the beginning of
- * that payload.
- */
-
- /*
- * We use Ethernet protocol types inside libpcap;
- * map them to the corresponding PPP protocol types.
- */
- proto = ethertype_to_ppptype(proto);
- return gen_cmp(OR_MACPL, off_linktype, BPF_H, (bpf_int32)proto);
- }
-
- switch (linktype) {
+ switch (cstate->linktype) {
case DLT_EN10MB:
case DLT_NETANALYZER:
case DLT_NETANALYZER_TRANSPARENT:
- return gen_ether_linktype(proto);
+ /* Geneve has an EtherType regardless of whether there is an
+ * L2 header. */
+ if (!cstate->is_geneve)
+ b0 = gen_prevlinkhdr_check(cstate);
+ else
+ b0 = NULL;
+
+ b1 = gen_ether_linktype(cstate, proto);
+ if (b0 != NULL)
+ gen_and(b0, b1);
+ return b1;
/*NOTREACHED*/
break;
@@ -2959,8 +3032,7 @@ gen_linktype(proto)
/* fall through */
default:
- return gen_cmp(OR_LINK, off_linktype, BPF_H,
- (bpf_int32)proto);
+ return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)proto);
/*NOTREACHED*/
break;
}
@@ -2974,12 +3046,12 @@ gen_linktype(proto)
/*
* Check that we have a data frame.
*/
- b0 = gen_check_802_11_data_frame();
+ b0 = gen_check_802_11_data_frame(cstate);
/*
* Now check for the specified link-layer type.
*/
- b1 = gen_llc_linktype(proto);
+ b1 = gen_llc_linktype(cstate, proto);
gen_and(b0, b1);
return b1;
/*NOTREACHED*/
@@ -2989,7 +3061,7 @@ gen_linktype(proto)
/*
* XXX - check for LLC frames.
*/
- return gen_llc_linktype(proto);
+ return gen_llc_linktype(cstate, proto);
/*NOTREACHED*/
break;
@@ -2997,56 +3069,34 @@ gen_linktype(proto)
/*
* XXX - check for LLC PDUs, as per IEEE 802.5.
*/
- return gen_llc_linktype(proto);
+ return gen_llc_linktype(cstate, proto);
/*NOTREACHED*/
break;
case DLT_ATM_RFC1483:
case DLT_ATM_CLIP:
case DLT_IP_OVER_FC:
- return gen_llc_linktype(proto);
+ return gen_llc_linktype(cstate, proto);
/*NOTREACHED*/
break;
case DLT_SUNATM:
/*
- * If "is_lane" is set, check for a LANE-encapsulated
- * version of this protocol, otherwise check for an
- * LLC-encapsulated version of this protocol.
+ * Check for an LLC-encapsulated version of this protocol;
+ * if we were checking for LANE, linktype would no longer
+ * be DLT_SUNATM.
*
- * We assume LANE means Ethernet, not Token Ring.
+ * Check for LLC encapsulation and then check the protocol.
*/
- if (is_lane) {
- /*
- * Check that the packet doesn't begin with an
- * LE Control marker. (We've already generated
- * a test for LANE.)
- */
- b0 = gen_cmp(OR_LINK, SUNATM_PKT_BEGIN_POS, BPF_H,
- 0xFF00);
- gen_not(b0);
-
- /*
- * Now generate an Ethernet test.
- */
- b1 = gen_ether_linktype(proto);
- gen_and(b0, b1);
- return b1;
- } else {
- /*
- * Check for LLC encapsulation and then check the
- * protocol.
- */
- b0 = gen_atmfield_code(A_PROTOTYPE, PT_LLC, BPF_JEQ, 0);
- b1 = gen_llc_linktype(proto);
- gen_and(b0, b1);
- return b1;
- }
+ b0 = gen_atmfield_code(cstate, A_PROTOTYPE, PT_LLC, BPF_JEQ, 0);
+ b1 = gen_llc_linktype(cstate, proto);
+ gen_and(b0, b1);
+ return b1;
/*NOTREACHED*/
break;
case DLT_LINUX_SLL:
- return gen_linux_sll_linktype(proto);
+ return gen_linux_sll_linktype(cstate, proto);
/*NOTREACHED*/
break;
@@ -3064,14 +3114,14 @@ gen_linktype(proto)
case ETHERTYPE_IP:
/* Check for a version number of 4. */
- return gen_mcmp(OR_LINK, 0, BPF_B, 0x40, 0xF0);
+ return gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, 0x40, 0xF0);
case ETHERTYPE_IPV6:
/* Check for a version number of 6. */
- return gen_mcmp(OR_LINK, 0, BPF_B, 0x60, 0xF0);
+ return gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, 0x60, 0xF0);
default:
- return gen_false(); /* always false */
+ return gen_false(cstate); /* always false */
}
/*NOTREACHED*/
break;
@@ -3081,10 +3131,10 @@ gen_linktype(proto)
* Raw IPv4, so no type field.
*/
if (proto == ETHERTYPE_IP)
- return gen_true(); /* always true */
+ return gen_true(cstate); /* always true */
/* Checking for something other than IPv4; always false */
- return gen_false();
+ return gen_false(cstate);
/*NOTREACHED*/
break;
@@ -3093,10 +3143,10 @@ gen_linktype(proto)
* Raw IPv6, so no type field.
*/
if (proto == ETHERTYPE_IPV6)
- return gen_true(); /* always true */
+ return gen_true(cstate); /* always true */
/* Checking for something other than IPv6; always false */
- return gen_false();
+ return gen_false(cstate);
/*NOTREACHED*/
break;
@@ -3109,7 +3159,7 @@ gen_linktype(proto)
* map them to the corresponding PPP protocol types.
*/
proto = ethertype_to_ppptype(proto);
- return gen_cmp(OR_LINK, off_linktype, BPF_H, (bpf_int32)proto);
+ return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)proto);
/*NOTREACHED*/
break;
@@ -3125,16 +3175,16 @@ gen_linktype(proto)
* Also check for Van Jacobson-compressed IP.
* XXX - do this for other forms of PPP?
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H, PPP_IP);
- b1 = gen_cmp(OR_LINK, off_linktype, BPF_H, PPP_VJC);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, PPP_IP);
+ b1 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, PPP_VJC);
gen_or(b0, b1);
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H, PPP_VJNC);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, PPP_VJNC);
gen_or(b1, b0);
return b0;
default:
proto = ethertype_to_ppptype(proto);
- return gen_cmp(OR_LINK, off_linktype, BPF_H,
+ return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H,
(bpf_int32)proto);
}
/*NOTREACHED*/
@@ -3143,39 +3193,71 @@ gen_linktype(proto)
case DLT_NULL:
case DLT_LOOP:
case DLT_ENC:
- /*
- * For DLT_NULL, the link-layer header is a 32-bit
- * word containing an AF_ value in *host* byte order,
- * and for DLT_ENC, the link-layer header begins
- * with a 32-bit work containing an AF_ value in
- * host byte order.
- *
- * In addition, if we're reading a saved capture file,
- * the host byte order in the capture may not be the
- * same as the host byte order on this machine.
- *
- * For DLT_LOOP, the link-layer header is a 32-bit
- * word containing an AF_ value in *network* byte order.
- *
- * XXX - AF_ values may, unfortunately, be platform-
- * dependent; for example, FreeBSD's AF_INET6 is 24
- * whilst NetBSD's and OpenBSD's is 26.
- *
- * This means that, when reading a capture file, just
- * checking for our AF_INET6 value won't work if the
- * capture file came from another OS.
- */
switch (proto) {
case ETHERTYPE_IP:
- proto = AF_INET;
- break;
+ return (gen_loopback_linktype(cstate, AF_INET));
-#ifdef INET6
case ETHERTYPE_IPV6:
- proto = AF_INET6;
- break;
-#endif
+ /*
+ * AF_ values may, unfortunately, be platform-
+ * dependent; AF_INET isn't, because everybody
+ * used 4.2BSD's value, but AF_INET6 is, because
+ * 4.2BSD didn't have a value for it (given that
+ * IPv6 didn't exist back in the early 1980's),
+ * and they all picked their own values.
+ *
+ * This means that, if we're reading from a
+ * savefile, we need to check for all the
+ * possible values.
+ *
+ * If we're doing a live capture, we only need
+ * to check for this platform's value; however,
+ * Npcap uses 24, which isn't Windows's AF_INET6
+ * value. (Given the multiple different values,
+ * programs that read pcap files shouldn't be
+ * checking for their platform's AF_INET6 value
+ * anyway, they should check for all of the
+ * possible values. and they might as well do
+ * that even for live captures.)
+ */
+ if (cstate->bpf_pcap->rfile != NULL) {
+ /*
+ * Savefile - check for all three
+ * possible IPv6 values.
+ */
+ b0 = gen_loopback_linktype(cstate, BSD_AFNUM_INET6_BSD);
+ b1 = gen_loopback_linktype(cstate, BSD_AFNUM_INET6_FREEBSD);
+ gen_or(b0, b1);
+ b0 = gen_loopback_linktype(cstate, BSD_AFNUM_INET6_DARWIN);
+ gen_or(b0, b1);
+ return (b1);
+ } else {
+ /*
+ * Live capture, so we only need to
+ * check for the value used on this
+ * platform.
+ */
+#ifdef _WIN32
+ /*
+ * Npcap doesn't use Windows's AF_INET6,
+ * as that collides with AF_IPX on
+ * some BSDs (both have the value 23).
+ * Instead, it uses 24.
+ */
+ return (gen_loopback_linktype(cstate, 24));
+#else /* _WIN32 */
+#ifdef AF_INET6
+ return (gen_loopback_linktype(cstate, AF_INET6));
+#else /* AF_INET6 */
+ /*
+ * I guess this platform doesn't support
+ * IPv6, so we just reject all packets.
+ */
+ return gen_false(cstate);
+#endif /* AF_INET6 */
+#endif /* _WIN32 */
+ }
default:
/*
@@ -3183,27 +3265,8 @@ gen_linktype(proto)
* XXX - support those that have AF_ values
* #defined on this platform, at least?
*/
- return gen_false();
- }
-
- if (linktype == DLT_NULL || linktype == DLT_ENC) {
- /*
- * The AF_ value is in host byte order, but
- * the BPF interpreter will convert it to
- * network byte order.
- *
- * If this is a save file, and it's from a
- * machine with the opposite byte order to
- * ours, we byte-swap the AF_ value.
- *
- * Then we run it through "htonl()", and
- * generate code to compare against the result.
- */
- if (bpf_pcap->rfile != NULL && bpf_pcap->swapped)
- proto = SWAPLONG(proto);
- proto = htonl(proto);
+ return gen_false(cstate);
}
- return (gen_cmp(OR_LINK, 0, BPF_W, (bpf_int32)proto));
#ifdef HAVE_NET_PFVAR_H
case DLT_PFLOG:
@@ -3212,13 +3275,13 @@ gen_linktype(proto)
* the packet.
*/
if (proto == ETHERTYPE_IP)
- return (gen_cmp(OR_LINK, offsetof(struct pfloghdr, af),
+ return (gen_cmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, af),
BPF_B, (bpf_int32)AF_INET));
else if (proto == ETHERTYPE_IPV6)
- return (gen_cmp(OR_LINK, offsetof(struct pfloghdr, af),
+ return (gen_cmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, af),
BPF_B, (bpf_int32)AF_INET6));
else
- return gen_false();
+ return gen_false(cstate);
/*NOTREACHED*/
break;
#endif /* HAVE_NET_PFVAR_H */
@@ -3232,34 +3295,34 @@ gen_linktype(proto)
switch (proto) {
default:
- return gen_false();
+ return gen_false(cstate);
case ETHERTYPE_IPV6:
- return (gen_cmp(OR_LINK, off_linktype, BPF_B,
+ return (gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B,
(bpf_int32)ARCTYPE_INET6));
case ETHERTYPE_IP:
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_B,
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B,
(bpf_int32)ARCTYPE_IP);
- b1 = gen_cmp(OR_LINK, off_linktype, BPF_B,
+ b1 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B,
(bpf_int32)ARCTYPE_IP_OLD);
gen_or(b0, b1);
return (b1);
case ETHERTYPE_ARP:
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_B,
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B,
(bpf_int32)ARCTYPE_ARP);
- b1 = gen_cmp(OR_LINK, off_linktype, BPF_B,
+ b1 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B,
(bpf_int32)ARCTYPE_ARP_OLD);
gen_or(b0, b1);
return (b1);
case ETHERTYPE_REVARP:
- return (gen_cmp(OR_LINK, off_linktype, BPF_B,
+ return (gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B,
(bpf_int32)ARCTYPE_REVARP));
case ETHERTYPE_ATALK:
- return (gen_cmp(OR_LINK, off_linktype, BPF_B,
+ return (gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B,
(bpf_int32)ARCTYPE_ATALK));
}
/*NOTREACHED*/
@@ -3268,9 +3331,9 @@ gen_linktype(proto)
case DLT_LTALK:
switch (proto) {
case ETHERTYPE_ATALK:
- return gen_true();
+ return gen_true(cstate);
default:
- return gen_false();
+ return gen_false(cstate);
}
/*NOTREACHED*/
break;
@@ -3286,13 +3349,13 @@ gen_linktype(proto)
/*
* Check for the special NLPID for IP.
*/
- return gen_cmp(OR_LINK, 2, BPF_H, (0x03<<8) | 0xcc);
+ return gen_cmp(cstate, OR_LINKHDR, 2, BPF_H, (0x03<<8) | 0xcc);
case ETHERTYPE_IPV6:
/*
* Check for the special NLPID for IPv6.
*/
- return gen_cmp(OR_LINK, 2, BPF_H, (0x03<<8) | 0x8e);
+ return gen_cmp(cstate, OR_LINKHDR, 2, BPF_H, (0x03<<8) | 0x8e);
case LLCSAP_ISONS:
/*
@@ -3306,21 +3369,21 @@ gen_linktype(proto)
* control field of UI, i.e. 0x03 followed
* by the NLPID.
*/
- b0 = gen_cmp(OR_LINK, 2, BPF_H, (0x03<<8) | ISO8473_CLNP);
- b1 = gen_cmp(OR_LINK, 2, BPF_H, (0x03<<8) | ISO9542_ESIS);
- b2 = gen_cmp(OR_LINK, 2, BPF_H, (0x03<<8) | ISO10589_ISIS);
+ b0 = gen_cmp(cstate, OR_LINKHDR, 2, BPF_H, (0x03<<8) | ISO8473_CLNP);
+ b1 = gen_cmp(cstate, OR_LINKHDR, 2, BPF_H, (0x03<<8) | ISO9542_ESIS);
+ b2 = gen_cmp(cstate, OR_LINKHDR, 2, BPF_H, (0x03<<8) | ISO10589_ISIS);
gen_or(b1, b2);
gen_or(b0, b2);
return b2;
default:
- return gen_false();
+ return gen_false(cstate);
}
/*NOTREACHED*/
break;
case DLT_MFR:
- bpf_error("Multi-link Frame Relay link-layer type filtering not implemented");
+ bpf_error(cstate, "Multi-link Frame Relay link-layer type filtering not implemented");
case DLT_JUNIPER_MFR:
case DLT_JUNIPER_MLFR:
@@ -3352,99 +3415,100 @@ gen_linktype(proto)
*
* FIXME encapsulation specific BPF_ filters
*/
- return gen_mcmp(OR_LINK, 0, BPF_W, 0x4d474300, 0xffffff00); /* compare the magic number */
+ return gen_mcmp(cstate, OR_LINKHDR, 0, BPF_W, 0x4d474300, 0xffffff00); /* compare the magic number */
case DLT_BACNET_MS_TP:
- return gen_mcmp(OR_LINK, 0, BPF_W, 0x55FF0000, 0xffff0000);
+ return gen_mcmp(cstate, OR_LINKHDR, 0, BPF_W, 0x55FF0000, 0xffff0000);
case DLT_IPNET:
- return gen_ipnet_linktype(proto);
+ return gen_ipnet_linktype(cstate, proto);
case DLT_LINUX_IRDA:
- bpf_error("IrDA link-layer type filtering not implemented");
+ bpf_error(cstate, "IrDA link-layer type filtering not implemented");
case DLT_DOCSIS:
- bpf_error("DOCSIS link-layer type filtering not implemented");
+ bpf_error(cstate, "DOCSIS link-layer type filtering not implemented");
case DLT_MTP2:
case DLT_MTP2_WITH_PHDR:
- bpf_error("MTP2 link-layer type filtering not implemented");
+ bpf_error(cstate, "MTP2 link-layer type filtering not implemented");
case DLT_ERF:
- bpf_error("ERF link-layer type filtering not implemented");
+ bpf_error(cstate, "ERF link-layer type filtering not implemented");
case DLT_PFSYNC:
- bpf_error("PFSYNC link-layer type filtering not implemented");
+ bpf_error(cstate, "PFSYNC link-layer type filtering not implemented");
case DLT_LINUX_LAPD:
- bpf_error("LAPD link-layer type filtering not implemented");
+ bpf_error(cstate, "LAPD link-layer type filtering not implemented");
- case DLT_USB:
+ case DLT_USB_FREEBSD:
case DLT_USB_LINUX:
case DLT_USB_LINUX_MMAPPED:
- bpf_error("USB link-layer type filtering not implemented");
+ case DLT_USBPCAP:
+ bpf_error(cstate, "USB link-layer type filtering not implemented");
case DLT_BLUETOOTH_HCI_H4:
case DLT_BLUETOOTH_HCI_H4_WITH_PHDR:
- bpf_error("Bluetooth link-layer type filtering not implemented");
+ bpf_error(cstate, "Bluetooth link-layer type filtering not implemented");
case DLT_CAN20B:
case DLT_CAN_SOCKETCAN:
- bpf_error("CAN link-layer type filtering not implemented");
+ bpf_error(cstate, "CAN link-layer type filtering not implemented");
case DLT_IEEE802_15_4:
case DLT_IEEE802_15_4_LINUX:
case DLT_IEEE802_15_4_NONASK_PHY:
case DLT_IEEE802_15_4_NOFCS:
- bpf_error("IEEE 802.15.4 link-layer type filtering not implemented");
+ bpf_error(cstate, "IEEE 802.15.4 link-layer type filtering not implemented");
case DLT_IEEE802_16_MAC_CPS_RADIO:
- bpf_error("IEEE 802.16 link-layer type filtering not implemented");
+ bpf_error(cstate, "IEEE 802.16 link-layer type filtering not implemented");
case DLT_SITA:
- bpf_error("SITA link-layer type filtering not implemented");
+ bpf_error(cstate, "SITA link-layer type filtering not implemented");
case DLT_RAIF1:
- bpf_error("RAIF1 link-layer type filtering not implemented");
+ bpf_error(cstate, "RAIF1 link-layer type filtering not implemented");
case DLT_IPMB:
- bpf_error("IPMB link-layer type filtering not implemented");
+ bpf_error(cstate, "IPMB link-layer type filtering not implemented");
case DLT_AX25_KISS:
- bpf_error("AX.25 link-layer type filtering not implemented");
+ bpf_error(cstate, "AX.25 link-layer type filtering not implemented");
case DLT_NFLOG:
/* Using the fixed-size NFLOG header it is possible to tell only
* the address family of the packet, other meaningful data is
* either missing or behind TLVs.
*/
- bpf_error("NFLOG link-layer type filtering not implemented");
+ bpf_error(cstate, "NFLOG link-layer type filtering not implemented");
default:
/*
* Does this link-layer header type have a field
* indicating the type of the next protocol? If
- * so, off_linktype will be the offset of that
- * field in the packet; if not, it will be -1.
+ * so, off_linktype.constant_part will be the offset of that
+ * field in the packet; if not, it will be OFFSET_NOT_SET.
*/
- if (off_linktype != (u_int)-1) {
+ if (cstate->off_linktype.constant_part != OFFSET_NOT_SET) {
/*
* Yes; assume it's an Ethernet type. (If
* it's not, it needs to be handled specially
* above.)
*/
- return gen_cmp(OR_LINK, off_linktype, BPF_H, (bpf_int32)proto);
+ return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)proto);
} else {
/*
* No; report an error.
*/
- description = pcap_datalink_val_to_description(linktype);
+ description = pcap_datalink_val_to_description(cstate->linktype);
if (description != NULL) {
- bpf_error("%s link-layer type filtering not implemented",
+ bpf_error(cstate, "%s link-layer type filtering not implemented",
description);
} else {
- bpf_error("DLT %u link-layer type filtering not implemented",
- linktype);
+ bpf_error(cstate, "DLT %u link-layer type filtering not implemented",
+ cstate->linktype);
}
}
break;
@@ -3459,9 +3523,7 @@ gen_linktype(proto)
* code and protocol type in the SNAP header.
*/
static struct block *
-gen_snap(orgcode, ptype)
- bpf_u_int32 orgcode;
- bpf_u_int32 ptype;
+gen_snap(compiler_state_t *cstate, bpf_u_int32 orgcode, bpf_u_int32 ptype)
{
u_char snapblock[8];
@@ -3473,32 +3535,32 @@ gen_snap(orgcode, ptype)
snapblock[5] = (orgcode >> 0); /* lower 8 bits of organization code */
snapblock[6] = (ptype >> 8); /* upper 8 bits of protocol type */
snapblock[7] = (ptype >> 0); /* lower 8 bits of protocol type */
- return gen_bcmp(OR_MACPL, 0, 8, snapblock);
+ return gen_bcmp(cstate, OR_LLC, 0, 8, snapblock);
}
/*
* Generate code to match frames with an LLC header.
*/
struct block *
-gen_llc(void)
+gen_llc(compiler_state_t *cstate)
{
struct block *b0, *b1;
- switch (linktype) {
+ switch (cstate->linktype) {
case DLT_EN10MB:
/*
* We check for an Ethernet type field less than
* 1500, which means it's an 802.3 length field.
*/
- b0 = gen_cmp_gt(OR_LINK, off_linktype, BPF_H, ETHERMTU);
+ b0 = gen_cmp_gt(cstate, OR_LINKTYPE, 0, BPF_H, ETHERMTU);
gen_not(b0);
/*
* Now check for the purported DSAP and SSAP not being
* 0xFF, to rule out NetWare-over-802.3.
*/
- b1 = gen_cmp(OR_MACPL, 0, BPF_H, (bpf_int32)0xFFFF);
+ b1 = gen_cmp(cstate, OR_LLC, 0, BPF_H, (bpf_int32)0xFFFF);
gen_not(b1);
gen_and(b0, b1);
return b1;
@@ -3507,20 +3569,20 @@ gen_llc(void)
/*
* We check for LLC traffic.
*/
- b0 = gen_atmtype_abbrev(A_LLC);
+ b0 = gen_atmtype_abbrev(cstate, A_LLC);
return b0;
case DLT_IEEE802: /* Token Ring */
/*
* XXX - check for LLC frames.
*/
- return gen_true();
+ return gen_true(cstate);
case DLT_FDDI:
/*
* XXX - check for LLC frames.
*/
- return gen_true();
+ return gen_true(cstate);
case DLT_ATM_RFC1483:
/*
@@ -3531,7 +3593,7 @@ gen_llc(void)
* way to check for that; the protocol used on the VC
* is negotiated out of band.
*/
- return gen_true();
+ return gen_true(cstate);
case DLT_IEEE802_11:
case DLT_PRISM_HEADER:
@@ -3541,17 +3603,17 @@ gen_llc(void)
/*
* Check that we have a data frame.
*/
- b0 = gen_check_802_11_data_frame();
+ b0 = gen_check_802_11_data_frame(cstate);
return b0;
default:
- bpf_error("'llc' not supported for linktype %d", linktype);
+ bpf_error(cstate, "'llc' not supported for linktype %d", cstate->linktype);
/* NOTREACHED */
}
}
struct block *
-gen_llc_i(void)
+gen_llc_i(compiler_state_t *cstate)
{
struct block *b0, *b1;
struct slist *s;
@@ -3559,14 +3621,14 @@ gen_llc_i(void)
/*
* Check whether this is an LLC frame.
*/
- b0 = gen_llc();
+ b0 = gen_llc(cstate);
/*
* Load the control byte and test the low-order bit; it must
* be clear for I frames.
*/
- s = gen_load_a(OR_MACPL, 2, BPF_B);
- b1 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LLC, 2, BPF_B);
+ b1 = new_block(cstate, JMP(BPF_JSET));
b1->s.k = 0x01;
b1->stmts = s;
gen_not(b1);
@@ -3575,75 +3637,75 @@ gen_llc_i(void)
}
struct block *
-gen_llc_s(void)
+gen_llc_s(compiler_state_t *cstate)
{
struct block *b0, *b1;
/*
* Check whether this is an LLC frame.
*/
- b0 = gen_llc();
+ b0 = gen_llc(cstate);
/*
* Now compare the low-order 2 bit of the control byte against
* the appropriate value for S frames.
*/
- b1 = gen_mcmp(OR_MACPL, 2, BPF_B, LLC_S_FMT, 0x03);
+ b1 = gen_mcmp(cstate, OR_LLC, 2, BPF_B, LLC_S_FMT, 0x03);
gen_and(b0, b1);
return b1;
}
struct block *
-gen_llc_u(void)
+gen_llc_u(compiler_state_t *cstate)
{
struct block *b0, *b1;
/*
* Check whether this is an LLC frame.
*/
- b0 = gen_llc();
+ b0 = gen_llc(cstate);
/*
* Now compare the low-order 2 bit of the control byte against
* the appropriate value for U frames.
*/
- b1 = gen_mcmp(OR_MACPL, 2, BPF_B, LLC_U_FMT, 0x03);
+ b1 = gen_mcmp(cstate, OR_LLC, 2, BPF_B, LLC_U_FMT, 0x03);
gen_and(b0, b1);
return b1;
}
struct block *
-gen_llc_s_subtype(bpf_u_int32 subtype)
+gen_llc_s_subtype(compiler_state_t *cstate, bpf_u_int32 subtype)
{
struct block *b0, *b1;
/*
* Check whether this is an LLC frame.
*/
- b0 = gen_llc();
+ b0 = gen_llc(cstate);
/*
* Now check for an S frame with the appropriate type.
*/
- b1 = gen_mcmp(OR_MACPL, 2, BPF_B, subtype, LLC_S_CMD_MASK);
+ b1 = gen_mcmp(cstate, OR_LLC, 2, BPF_B, subtype, LLC_S_CMD_MASK);
gen_and(b0, b1);
return b1;
}
struct block *
-gen_llc_u_subtype(bpf_u_int32 subtype)
+gen_llc_u_subtype(compiler_state_t *cstate, bpf_u_int32 subtype)
{
struct block *b0, *b1;
/*
* Check whether this is an LLC frame.
*/
- b0 = gen_llc();
+ b0 = gen_llc(cstate);
/*
* Now check for a U frame with the appropriate type.
*/
- b1 = gen_mcmp(OR_MACPL, 2, BPF_B, subtype, LLC_U_CMD_MASK);
+ b1 = gen_mcmp(cstate, OR_LLC, 2, BPF_B, subtype, LLC_U_CMD_MASK);
gen_and(b0, b1);
return b1;
}
@@ -3661,8 +3723,7 @@ gen_llc_u_subtype(bpf_u_int32 subtype)
* protocol ID in a SNAP header.
*/
static struct block *
-gen_llc_linktype(proto)
- int proto;
+gen_llc_linktype(compiler_state_t *cstate, int proto)
{
/*
* XXX - handle token-ring variable-length header.
@@ -3675,10 +3736,9 @@ gen_llc_linktype(proto)
/*
* XXX - should we check both the DSAP and the
* SSAP, like this, or should we check