Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/inputs/pcap/afpacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ void AFPacket::walk_block(struct block_desc *pbd)
uint64_t bytes = 0;
struct tpacket3_hdr *ppd;

ppd = reinterpret_cast<struct tpacket3_hdr *>(reinterpret_cast<uint8_t *>(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<uint8_t *>(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<struct tpacket3_hdr *>(reinterpret_cast<uint8_t *>(pbd) + ppd->tp_next_offset);
ppd = (struct tpacket3_hdr *)((uint8_t *)ppd + ppd->tp_next_offset);
}
}

Expand Down Expand Up @@ -236,6 +236,8 @@ void AFPacket::start_capture()
// Configure the packet socket.
setup();

running = true;

cap_thread = std::make_unique<std::thread>([this] {
unsigned int current_block_num = 0;

Expand Down