From 6ebacd64ce6772ca76869e82b9c5e10355f4c5b5 Mon Sep 17 00:00:00 2001 From: Shannon Weyrick Date: Tue, 6 Apr 2021 14:37:11 -0400 Subject: [PATCH] fixed af_packet pcap source --- src/inputs/pcap/afpacket.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/inputs/pcap/afpacket.cpp b/src/inputs/pcap/afpacket.cpp index 0e97c95e0..1e100efb5 100644 --- a/src/inputs/pcap/afpacket.cpp +++ b/src/inputs/pcap/afpacket.cpp @@ -76,16 +76,16 @@ void AFPacket::walk_block(struct block_desc *pbd) uint64_t bytes = 0; struct tpacket3_hdr *ppd; - ppd = reinterpret_cast(reinterpret_cast(pbd) + pbd->h1.offset_to_first_pkt); + ppd = (struct tpacket3_hdr *)((uint8_t *)pbd + pbd->h1.offset_to_first_pkt); for (i = 0; i < num_pkts; ++i) { bytes += ppd->tp_snaplen; - auto data_pointer = reinterpret_cast(pbd) + ppd->tp_mac; + auto data_pointer = (uint8_t *)ppd + ppd->tp_mac; pcpp::RawPacket packet(data_pointer, ppd->tp_snaplen, timespec{pbd->h1.ts_last_pkt.ts_sec, pbd->h1.ts_last_pkt.ts_nsec}, false, pcpp::LINKTYPE_ETHERNET); cb(&packet, nullptr, inputStream); - ppd = reinterpret_cast(reinterpret_cast(pbd) + ppd->tp_next_offset); + ppd = (struct tpacket3_hdr *)((uint8_t *)ppd + ppd->tp_next_offset); } } @@ -236,6 +236,8 @@ void AFPacket::start_capture() // Configure the packet socket. setup(); + running = true; + cap_thread = std::make_unique([this] { unsigned int current_block_num = 0;