9 typedef struct pcap_dumper pcap_dumper_t;
35 std::string m_FileName;
56 uint32_t m_NumOfPacketsRead;
57 uint32_t m_NumOfPacketsNotParsed;
71 virtual bool getNextPacket(
RawPacket& rawPacket) = 0;
116 return m_PcapLinkLayerType;
160 uint64_t identification_pattern;
161 uint32_t version_number;
162 uint32_t datalink_type;
163 } snoop_file_header_t;
168 uint32_t original_length;
169 uint32_t included_length;
170 uint32_t packet_record_length;
171 uint32_t ndrops_cumulative;
174 } snoop_packet_header_t;
178 std::ifstream m_snoopFile;
198 return m_PcapLinkLayerType;
314 uint32_t m_NumOfPacketsWritten;
315 uint32_t m_NumOfPacketsNotWritten;
324 virtual bool writePacket(
RawPacket const& packet) = 0;
329 virtual bool open(
bool appendMode) = 0;
339 pcap_dumper_t* m_PcapDumpHandler;
361 bool nanosecondsPrecision =
false);
412 bool open(
bool appendMode)
override;
434 int m_CompressionLevel;
469 bool open(
const std::string& os,
const std::string& hardware,
const std::string& captureApp,
470 const std::string& fileComment);
Definition: PcapFilter.h:80
Definition: PcapFileDevice.h:33
std::string getFileName() const
void close() override
Close the file.
Definition: PcapFileDevice.h:54
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:312
virtual ~IFileWriterDevice()
A destructor for this class.
Definition: PcapFileDevice.h:321
Definition: PcapDevice.h:92
Definition: PcapFileDevice.h:92
PcapFileReaderDevice(const std::string &fileName)
Definition: PcapFileDevice.h:105
static bool isNanoSecondPrecisionSupported()
FileTimestampPrecision getTimestampPrecision() const
Definition: PcapFileDevice.h:122
void getStatistics(PcapStats &stats) const
virtual ~PcapFileReaderDevice()=default
A destructor for this class.
LinkLayerType getLinkLayerType() const
Definition: PcapFileDevice.h:114
bool getNextPacket(RawPacket &rawPacket)
Definition: PcapFileDevice.h:337
bool open(bool appendMode) override
void getStatistics(PcapStats &stats) const 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:364
static bool isNanoSecondPrecisionSupported()
FileTimestampPrecision getTimestampPrecision() const
Definition: PcapFileDevice.h:387
bool writePackets(const RawPacketVector &packets) override
Definition: PcapFileDevice.h:227
std::string getOS() const
virtual ~PcapNgFileReaderDevice()
A destructor for this class.
Definition: PcapFileDevice.h:243
void getStatistics(PcapStats &stats) const
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:431
bool writePackets(const RawPacketVector &packets)
bool writePacket(RawPacket const &packet)
bool setFilter(std::string filterAsString)
void getStatistics(PcapStats &stats) const
bool open(const std::string &os, const std::string &hardware, const std::string &captureApp, const std::string &fileComment)
bool open(bool appendMode)
PcapNgFileWriterDevice(const std::string &fileName, int compressionLevel=0)
void close()
Flush and close the pcap-ng file.
virtual ~PcapNgFileWriterDevice()
A destructor for this class.
Definition: PcapFileDevice.h:451
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:269
Definition: PcapFileDevice.h:154
void close()
Close the snoop file.
SnoopFileReaderDevice(const std::string &fileName)
Definition: PcapFileDevice.h:188
LinkLayerType getLinkLayerType() const
Definition: PcapFileDevice.h:196
virtual ~SnoopFileReaderDevice()
A destructor for this class.
void getStatistics(PcapStats &stats) const
bool getNextPacket(RawPacket &rawPacket)
The main namespace for the PcapPlusPlus lib.
FileTimestampPrecision
Definition: PcapFileDevice.h:21
@ Microseconds
Precision is in microseconds.
@ Unknown
Precision is unknown or not set/determined.
@ Nanoseconds
Precision is in nanoseconds.
LinkLayerType
Definition: RawPacket.h:25
@ LINKTYPE_ETHERNET
Definition: RawPacket.h:29
Definition: PcapDevice.h:104