PcapPlusPlus
Next
|
#include <PcapFileDevice.h>
Public Member Functions | |
PcapFileWriterDevice (const std::string &fileName, LinkLayerType linkLayerType=LINKTYPE_ETHERNET, bool nanosecondsPrecision=false) | |
~PcapFileWriterDevice () | |
bool | writePacket (RawPacket const &packet) override |
bool | writePackets (const RawPacketVector &packets) override |
FileTimestampPrecision | getTimestampPrecision () const |
bool | open () override |
bool | open (bool appendMode) override |
void | close () override |
void | flush () |
void | getStatistics (PcapStats &stats) const override |
Public Member Functions inherited from pcpp::IFileWriterDevice | |
virtual | ~IFileWriterDevice () |
Public Member Functions inherited from pcpp::IFileDevice | |
std::string | getFileName () const |
Public Member Functions inherited from pcpp::IPcapDevice | |
virtual bool | setFilter (std::string filterAsString) |
bool | clearFilter () |
virtual bool | setFilter (GeneralFilter &filter) |
virtual bool | setFilter (std::string filterAsString)=0 |
Public Member Functions inherited from pcpp::IDevice | |
bool | isOpened () |
Public Member Functions inherited from pcpp::IFilterableDevice | |
virtual bool | setFilter (GeneralFilter &filter) |
Static Public Member Functions | |
static bool | isNanoSecondPrecisionSupported () |
Static Public Member Functions inherited from pcpp::IPcapDevice | |
static std::string | getPcapLibVersionInfo () |
static bool | matchPacketWithFilter (GeneralFilter &filter, RawPacket *rawPacket) |
A class for opening a pcap file for writing or create a new pcap file and write packets to it. This class adds a unique capability that isn't supported in WinPcap and in older libpcap versions which is to open a pcap file in append mode where packets are written at the end of the pcap file instead of running it over
pcpp::PcapFileWriterDevice::PcapFileWriterDevice | ( | const std::string & | fileName, |
LinkLayerType | linkLayerType = LINKTYPE_ETHERNET , |
||
bool | nanosecondsPrecision = false |
||
) |
A constructor for this class that gets the pcap full path file name to open for writing or create. Notice that after calling this constructor the file isn't opened yet, so writing packets will fail. For opening the file call open()
[in] | fileName | The full path of the file |
[in] | linkLayerType | The link layer type all packet in this file will be based on. The default is Ethernet |
[in] | nanosecondsPrecision | A boolean indicating whether to write timestamps in nano-precision. If set to false, timestamps will be written in micro-precision |
|
inline |
A destructor for this class
|
overridevirtual |
Flush and close the pacp file
Reimplemented from pcpp::IFileDevice.
void pcpp::PcapFileWriterDevice::flush | ( | ) |
Flush packets to disk.
|
overridevirtual |
Get statistics of packets written so far.
[out] | stats | The stats struct where stats are returned |
Implements pcpp::IPcapDevice.
|
inline |
|
static |
A static method that checks if nano-second precision is supported in the current platform and environment
|
overridevirtual |
Open the file in a write mode. If file doesn't exist, it will be created. If it does exist it will be overwritten, meaning all its current content will be deleted
Implements pcpp::IDevice.
|
overridevirtual |
Same as open(), but enables to open the file in append mode in which packets will be appended to the file instead of overwrite its current content. In append mode file must exist, otherwise opening will fail
[in] | appendMode | A boolean indicating whether to open the file in append mode or not. If set to false this method will act exactly like open(). If set to true, file will be opened in append mode |
Implements pcpp::IFileWriterDevice.
|
overridevirtual |
Write a RawPacket to the file. Before using this method please verify the file is opened using open(). This method won't change the written packet
[in] | packet | A reference for an existing RawPcket to write to the file |
Implements pcpp::IFileWriterDevice.
|
overridevirtual |
Write multiple RawPacket to the file. Before using this method please verify the file is opened using open(). This method won't change the written packets or the RawPacketVector instance
[in] | packets | A reference for an existing RawPcketVector, all of its packets will be written to the file |
Implements pcpp::IFileWriterDevice.