Skip to content

Commit

Permalink
The pcap_dump_flush in phys::start_pcap is required to make sure no d…
Browse files Browse the repository at this point in the history
…ouble pcap-headers are written to the .pcap-file.
  • Loading branch information
folkertvanheusden committed Nov 16, 2023
1 parent 7ec78bb commit 33531b6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion phys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,18 @@ void phys::start_pcap(const std::string & pcap_file, const bool in, const bool o
pdh = pcap_dump_open(ph, temp.c_str());
if (!pdh)
error_exit(false, "pcap_dump_open(%s) failed: %s", temp.c_str(), pcap_geterr(ph));

pcap_dump_flush(pdh);
}
}

void phys::stop_pcap()
{
std::unique_lock<std::mutex> lck(pcap_lock);
if (pdh)
if (pdh) {
pcap_dump_flush(pdh);
pcap_dump_close(pdh);
}
}

void phys::pcap_write_packet_incoming(const timespec & ts, const uint8_t *const data, const size_t n)
Expand Down

0 comments on commit 33531b6

Please sign in to comment.