mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Detect if pcap version defines pcap_set_immediate_mode.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
# PCAP_LIBRARY The libpcap library (possibly includes a thread
|
||||
# library e.g. required by pf_ring's libpcap)
|
||||
# HAVE_PF_RING If a found version of libpcap supports PF_RING
|
||||
# HAVE_PCAP_IMMEDIATE_MODE If the version of libpcap found supports immediate mode
|
||||
|
||||
find_path(PCAP_ROOT_DIR
|
||||
NAMES include/pcap.h
|
||||
@@ -73,6 +74,7 @@ endif (NOT PCAP_LINKS_SOLO)
|
||||
include(CheckFunctionExists)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY})
|
||||
check_function_exists(pcap_get_pfring_id HAVE_PF_RING)
|
||||
check_function_exists(pcap_set_immediate_mode HAVE_PCAP_IMMEDIATE_MODE)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
|
||||
mark_as_advanced(
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
SET(LIBTINS_INCLUDE_DIR ../include/tins/)
|
||||
|
||||
IF(HAVE_PCAP_IMMEDIATE_MODE)
|
||||
ADD_DEFINITIONS("-DHAVE_PCAP_IMMEDIATE_MODE=1")
|
||||
ENDIF()
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${LIBTINS_INCLUDE_DIR}
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
|
||||
@@ -343,9 +343,14 @@ void Sniffer::set_promisc_mode(bool promisc_enabled)
|
||||
|
||||
void Sniffer::set_immediate_mode(bool enabled)
|
||||
{
|
||||
// As of libpcap version 1.5.0 this function exists. Before, it was
|
||||
// technically always immediate mode since capture used TPACKET_V1/2
|
||||
// which doesn't do packet buffering.
|
||||
#ifdef HAVE_PCAP_IMMEDIATE_MODE
|
||||
if (pcap_set_immediate_mode(get_pcap_handle(), enabled)) {
|
||||
throw runtime_error(pcap_geterr(get_pcap_handle()));
|
||||
}
|
||||
#endif // HAVE_PCAP_IMMEDIATE_MODE
|
||||
}
|
||||
|
||||
void Sniffer::set_rfmon(bool rfmon_enabled)
|
||||
|
||||
Reference in New Issue
Block a user