PcapPlusPlus  20.08
pcpp::IFileReaderDevice Class Referenceabstract

#include <PcapFileDevice.h>

Inheritance diagram for pcpp::IFileReaderDevice:
pcpp::IFileDevice pcpp::IPcapDevice pcpp::IDevice pcpp::IFilterableDevice pcpp::PcapFileReaderDevice pcpp::PcapNgFileReaderDevice

Public Member Functions

virtual ~IFileReaderDevice ()
 
uint64_t getFileSize () const
 
int getNextPackets (RawPacketVector &packetVec, int numOfPacketsToRead=-1)
 
- Public Member Functions inherited from pcpp::IFileDevice
std::string getFileName () const
 
virtual void close ()
 
- Public Member Functions inherited from pcpp::IPcapDevice
virtual void getStatistics (PcapStats &stats) const =0
 
virtual bool setFilter (std::string filterAsString)
 
bool clearFilter ()
 
- Public Member Functions inherited from pcpp::IDevice
virtual bool open ()=0
 
bool isOpened ()
 
- Public Member Functions inherited from pcpp::IFilterableDevice
virtual bool setFilter (GeneralFilter &filter)
 

Static Public Member Functions

static IFileReaderDevicegetReader (const char *fileName)
 
- Static Public Member Functions inherited from pcpp::IPcapDevice
static std::string getPcapLibVersionInfo ()
 
static bool verifyFilter (std::string filterAsString)
 
static bool matchPacketWithFilter (std::string filterAsString, RawPacket *rawPacket)
 
static bool matchPacketWithFilter (GeneralFilter &filter, RawPacket *rawPacket)
 

Protected Member Functions

 IFileReaderDevice (const char *fileName)
 

Detailed Description

An abstract class (cannot be instantiated, has a private c'tor) which is the parent class for file reader devices

Constructor & Destructor Documentation

◆ IFileReaderDevice()

pcpp::IFileReaderDevice::IFileReaderDevice ( const char *  fileName)
protected

A constructor for this class that gets the pcap full path file name to open. Notice that after calling this constructor the file isn't opened yet, so reading packets will fail. For opening the file call open()

Parameters
[in]fileNameThe full path of the file to read

◆ ~IFileReaderDevice()

virtual pcpp::IFileReaderDevice::~IFileReaderDevice ( )
inlinevirtual

A destructor for this class

Member Function Documentation

◆ getFileSize()

uint64_t pcpp::IFileReaderDevice::getFileSize ( ) const
Returns
The file size in bytes

◆ getNextPackets()

int pcpp::IFileReaderDevice::getNextPackets ( RawPacketVector packetVec,
int  numOfPacketsToRead = -1 
)

Read the next N packets into a raw packet vector

Parameters
[out]packetVecThe raw packet vector to read packets into
[in]numOfPacketsToReadNumber of packets to read. If value <0 all remaining packets in the file will be read into the raw packet vector (this is the default value)
Returns
The number of packets actually read

◆ getReader()

static IFileReaderDevice* pcpp::IFileReaderDevice::getReader ( const char *  fileName)
static

A static method that creates an instance of the reader best fit to read the file. It decides by the file extension: for .pcapng files it returns an instance of PcapNgFileReaderDevice and for all other extensions it returns an instance of PcapFileReaderDevice

Parameters
[in]fileNameThe file name to open
Returns
An instance of the reader to read the file. Notice you should free this instance when done using it