9 typedef struct pcap_dumper pcap_dumper_t;
42 bool m_DeviceOpened =
false;
43 std::string m_FileName;
59 return m_DeviceOpened;
77 m_NumOfPacketsProcessed += numPackets;
84 m_NumOfPacketsDropped += numPackets;
91 uint64_t m_NumOfPacketsProcessed = 0;
92 uint64_t m_NumOfPacketsDropped = 0;
113 virtual bool getNextPacket(
RawPacket& rawPacket) = 0;
142 virtual bool writePacket(
RawPacket const& packet) = 0;
147 virtual bool open(
bool appendMode) = 0;
178 return m_PcapLinkLayerType;
214 pcap_dumper_t* m_PcapDumpHandler;
236 bool nanosecondsPrecision =
false);
287 bool open(
bool appendMode)
override;
306 internal::LightPcapNgHandle* m_LightPcapNg;
389 internal::LightPcapNgHandle* m_LightPcapNg;
390 int m_CompressionLevel;
453 bool open(
bool appendMode)
override;
468 bool open(
const std::string& os,
const std::string& hardware,
const std::string& captureApp,
469 const std::string& fileComment);
487 struct PcapNgMetadata
492 std::string hardware;
494 std::string captureApplication;
499 bool openWrite(PcapNgMetadata
const* metadata =
nullptr);
513 uint64_t identification_pattern;
514 uint32_t version_number;
515 uint32_t datalink_type;
516 } snoop_file_header_t;
521 uint32_t original_length;
522 uint32_t included_length;
523 uint32_t packet_record_length;
524 uint32_t ndrops_cumulative;
527 } snoop_packet_header_t;
531 std::ifstream m_snoopFile;
551 return m_PcapLinkLayerType;
Definition: PcapFilter.h:80
Definition: PcapFileDevice.h:40
std::string getFileName() const
bool isOpened() const override
Definition: PcapFileDevice.h:57
void close() override
Close the file.
void reportPacketProcessed(uint64_t numPackets=1)
Report that packets were processed (read or written, depending on the device type).
Definition: PcapFileDevice.h:75
void reportPacketDropped(uint64_t numPackets=1)
Report that packets were dropped (not read or not written, depending on the device type).
Definition: PcapFileDevice.h:82
void getStatistics(PcapStats &stats) const override
Get the statistics for this device.
void resetStatisticCounters()
Reset the internal statistic counters to zero.
Definition: PcapFileDevice.h:99
virtual ~IFileReaderDevice()=default
A destructor for this class.
int getNextPackets(RawPacketVector &packetVec, int numOfPacketsToRead=-1)
uint64_t getFileSize() const
static IFileReaderDevice * getReader(const std::string &fileName)
IFileReaderDevice(const std::string &fileName)
Definition: PcapFileDevice.h:134
virtual ~IFileWriterDevice()=default
A destructor for this class.
Definition: PcapDevice.h:141
Definition: PcapFileDevice.h:154
PcapFileReaderDevice(const std::string &fileName)
Definition: PcapFileDevice.h:167
static bool isNanoSecondPrecisionSupported()
FileTimestampPrecision getTimestampPrecision() const
Definition: PcapFileDevice.h:184
virtual ~PcapFileReaderDevice()=default
A destructor for this class.
LinkLayerType getLinkLayerType() const
Definition: PcapFileDevice.h:176
bool getNextPacket(RawPacket &rawPacket)
Definition: PcapFileDevice.h:212
bool open(bool appendMode) override
void flush()
Flush packets to disk.
void close() override
Flush and close the pacp file.
PcapFileWriterDevice(const std::string &fileName, LinkLayerType linkLayerType=LINKTYPE_ETHERNET, bool nanosecondsPrecision=false)
bool writePacket(RawPacket const &packet) override
~PcapFileWriterDevice()
A destructor for this class.
Definition: PcapFileDevice.h:239
static bool isNanoSecondPrecisionSupported()
FileTimestampPrecision getTimestampPrecision() const
Definition: PcapFileDevice.h:262
bool writePackets(const RawPacketVector &packets) override
Definition: PcapFileDevice.h:304
std::string getOS() const
virtual ~PcapNgFileReaderDevice()
A destructor for this class.
Definition: PcapFileDevice.h:320
std::string getCaptureApplication() const
void close()
Close the pacp-ng file.
bool getNextPacket(RawPacket &rawPacket, std::string &packetComment)
std::string getCaptureFileComment() const
bool getNextPacket(RawPacket &rawPacket)
PcapNgFileReaderDevice(const std::string &fileName)
std::string getHardware() const
bool setFilter(std::string filterAsString)
Definition: PcapFileDevice.h:387
bool open(const std::string &os, const std::string &hardware, const std::string &captureApp, const std::string &fileComment)
PcapNgFileWriterDevice(const std::string &fileName, int compressionLevel=0)
virtual ~PcapNgFileWriterDevice()
A destructor for this class.
Definition: PcapFileDevice.h:407
bool writePacket(RawPacket const &packet) override
void close() override
Flush and close the pcap-ng file.
bool writePackets(const RawPacketVector &packets) override
bool open(bool appendMode) override
bool setFilter(std::string filterAsString) override
bool writePacket(RawPacket const &packet, const std::string &comment)
void flush()
Flush packets to the pcap-ng file.
Definition: PointerVector.h:50
Definition: RawPacket.h:259
Definition: PcapFileDevice.h:507
void close()
Close the snoop file.
SnoopFileReaderDevice(const std::string &fileName)
Definition: PcapFileDevice.h:541
LinkLayerType getLinkLayerType() const
Definition: PcapFileDevice.h:549
virtual ~SnoopFileReaderDevice()
A destructor for this class.
bool getNextPacket(RawPacket &rawPacket)
The main namespace for the PcapPlusPlus lib.
Definition: AssertionUtils.h:19
FileTimestampPrecision
Definition: PcapFileDevice.h:28
@ Microseconds
Precision is in microseconds.
@ Unknown
Precision is unknown or not set/determined.
@ Nanoseconds
Precision is in nanoseconds.
LinkLayerType
An enum describing all known link layer type. Taken from: http://www.tcpdump.org/linktypes....
Definition: RawPacket.h:20
@ LINKTYPE_ETHERNET
IEEE 802.3 Ethernet.
Definition: RawPacket.h:24
@ Unknown
Unknown ARP message type.
Definition: PcapDevice.h:24