1
0
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:
Matias Fontanini
2015-06-14 11:23:32 -07:00
parent c42c18f5df
commit b451a9eae0
3 changed files with 11 additions and 0 deletions

View File

@@ -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}

View File

@@ -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)