mfontanini / libtins

High-level, multiplatform C++ network packet sniffing and crafting library.
http://libtins.github.io/
BSD 2-Clause "Simplified" License
1.91k stars 377 forks source link

PacketWriter does not have an option to append packets to existing file #410

Open dvilelaf opened 4 years ago

dvilelaf commented 4 years ago

Hi. I've seen that when PacketWriter is instantiated, its init method makes a call to: pcap_dump_open(handle_, file_name.c_str());

If a previous pcap exists, this will clear the existing file and start a new pcap, so the data is lost. Maybe an "append" option could be added calling instead to: pcap_dump_open_append(handle_, file_name.c_str());

According to the documentation: _"pcap_dump_open_append() is like pcap_dumpopen() but, if the file already exists, and is a pcap file with the same byte order as the host opening the file, and has the same time stamp precision, link-layer header type, and snapshot length as p, it will write new packets at the end of the file."