else( CMAKE_CL_64 )
link_directories("${PACKET_DLL_DIR}/Lib")
endif( CMAKE_CL_64 )
+
+ #
+ # We want to build with packet.dll, either from WinPcap or NPcap.
+ #
+ set(HAVE_PACKET32)
+
+ #
+ # Check whether we have the NPcap PacketIsLoopbackAdapter()
+ # function.
+ #
+ check_function_exists( PacketIsLoopbackAdapter HAVE_PACKET_IS_LOOPBACK_ADAPTER )
endif()
include_directories(
../Common/
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.
#
endif( HAVE_REMOTE )
#
-# Determine the main pcap-XXX.c file to use.
+# Determine the main pcap-XXX.c file to use, and the libraries with
+# which we need to link libpcap, if any.
#
if( WIN32 )
#
- # WinPcap.
+ # Windows; we need to link with WinSock2.
+ #
+ set(PCAP_LINK_LIBRARIES ws2_32)
+
#
- set( PCAP_TYPE win32 )
+ # Check whether we have packet.dll.
+ #
+ if (HAVE_PACKET32)
+ #
+ # We have packet.dll.
+ # Set the capture type to NPF, and link with packet.dll before
+ # WinSock2.
+ #
+ set( PCAP_TYPE npf )
+ set(PCAP_LINK_LIBRARIES packet ${PCAP_LINK_LIBRARIES})
+ else()
+ #
+ # We don't have any capture type we know about, so just use
+ # the null capture type, and only support reading (and writing)
+ # capture files.
+ #
+ set( PCAP_TYPE null )
+ endif()
else()
#
# UN*X.
#
- # Figure out what type of packet capture mechanism we have.
+ # Figure out what type of packet capture mechanism we have, and
+ # what libraries we'd need to link libpcap with, if any.
#
+ set(PCAP_LINK_LIBRARIES "")
if( EXISTS /dev/bpf )
#
# Cloning BPF device.
add_dependencies(${LIBRARY_NAME}_static SerializeTarget)
set_target_properties(${LIBRARY_NAME}_static PROPERTIES OUTPUT_NAME "${LIBRARY_NAME}")
-if( WIN32 )
- target_link_libraries ( ${LIBRARY_NAME}
- packet
- ws2_32
- )
-endif( WIN32 )
+target_link_libraries(${LIBRARY_NAME} ${PCAP_LINK_LIBRARIES})
######################################
# Write out the config.h file
pcap-namedb.h - header for backwards compatibility
pcap-nit.c - SunOS Network Interface Tap support
pcap-nit.h - SunOS Network Interface Tap definitions
+pcap-npf.c - WinPcap capture support
pcap-null.c - dummy monitor support (allows offline use of libpcap)
pcap-pf.c - Ultrix and Digital/Tru64 UNIX Packet Filter support
pcap-pf.h - Ultrix and Digital/Tru64 UNIX Packet Filter definitions
pcap-snoop.c - IRIX Snoop network monitoring support
pcap-usb-linux.c - USB capture support for Linux
pcap-usb-linux.h - USB capture support for Linux
-pcap-win32.c - WinPcap capture support
pcap.3pcap - manual entry for the library
pcap.c - pcap utility routines
pcap.h - header for backwards compatibility
pcap-netmap.c \
pcap-netmap.h \
pcap-nit.c \
+ pcap-npf.c \
pcap-null.c \
pcap-pf.c \
pcap-rdmasniff.c \
pcap-tc.h \
pcap-usb-linux.c \
pcap-usb-linux.h \
- pcap-win32.c \
sockutils.c \
sockutils.h \
scanner.l \
/* Define to 1 if remote packet capture is to be supported */
#cmakedefine HAVE_REMOTE 1
+/* Define to 1 if Packet32 API (WinPcap NPF driver) is available */
+#cmakedefine HAVE_PACKET32 1
+
/* Define to 1 if you have the <paths.h> header file. */
#cmakedefine HAVE_PATHS_H 1
}
/*
- * Windows has its own pcap_lookupdev(), for compatibility reasons, as
+ * pcap-npf.c has its own pcap_lookupdev(), for compatibility reasons, as
* it actually returns the names of all interfaces, with a NUL separator
* between them; some callers may depend on that.
*
* MS-DOS has its own pcap_lookupdev(), but that might be useful only
* as an optimization.
+ *
+ * In all other cases, we just use pcap_findalldevs() to get a list of
+ * devices, and pick from that list.
*/
-#if !defined(_WIN32) && !defined(MSDOS)
+#if !defined(HAVE_PACKET32) && !defined(MSDOS)
/*
* Return the name of a network interface attached to the system, or NULL
* if none can be found. The interface must be configured up; the