PcapPlusPlus  23.09
pcpp::SnoopFileReaderDevice Class Reference

#include <PcapFileDevice.h>

Inheritance diagram for pcpp::SnoopFileReaderDevice:
pcpp::IFileReaderDevice pcpp::IFileDevice pcpp::IPcapDevice pcpp::IDevice pcpp::IFilterableDevice

Public Member Functions

 SnoopFileReaderDevice (const std::string &fileName)
 
virtual ~SnoopFileReaderDevice ()
 
LinkLayerType getLinkLayerType () const
 
bool getNextPacket (RawPacket &rawPacket)
 
bool open ()
 
void getStatistics (PcapStats &stats) const
 
void close ()
 
- Public Member Functions inherited from pcpp::IFileReaderDevice
virtual ~IFileReaderDevice ()
 
uint64_t getFileSize () const
 
int getNextPackets (RawPacketVector &packetVec, int numOfPacketsToRead=-1)
 
- 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 ()
 
- Public Member Functions inherited from pcpp::IDevice
bool isOpened ()
 
- Public Member Functions inherited from pcpp::IFilterableDevice
virtual bool setFilter (GeneralFilter &filter)
 

Additional Inherited Members

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

Detailed Description

A class for opening a snoop file in read-only mode. This class enable to open the file and read all packets, packet-by-packet

Constructor & Destructor Documentation

◆ SnoopFileReaderDevice()

pcpp::SnoopFileReaderDevice::SnoopFileReaderDevice ( const std::string &  fileName)
inline

A constructor for this class that gets the snoop 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

◆ ~SnoopFileReaderDevice()

virtual pcpp::SnoopFileReaderDevice::~SnoopFileReaderDevice ( )
virtual

A destructor for this class

Member Function Documentation

◆ close()

void pcpp::SnoopFileReaderDevice::close ( )
virtual

Close the snoop file

Reimplemented from pcpp::IFileDevice.

◆ getLinkLayerType()

LinkLayerType pcpp::SnoopFileReaderDevice::getLinkLayerType ( ) const
inline
Returns
The link layer type of this file

◆ getNextPacket()

bool pcpp::SnoopFileReaderDevice::getNextPacket ( RawPacket rawPacket)
virtual

Read the next packet from the file. Before using this method please verify the file is opened using open()

Parameters
[out]rawPacketA reference for an empty RawPacket where the packet will be written
Returns
True if a packet was read successfully. False will be returned if the file isn't opened (also, an error log will be printed) or if reached end-of-file

Implements pcpp::IFileReaderDevice.

◆ getStatistics()

void pcpp::SnoopFileReaderDevice::getStatistics ( PcapStats stats) const
virtual

Get statistics of packets read so far. In the PcapStats struct, only the packetsRecv member is relevant. The rest of the members will contain 0

Parameters
[out]statsThe stats struct where stats are returned

Implements pcpp::IPcapDevice.

◆ open()

bool pcpp::SnoopFileReaderDevice::open ( )
virtual

Open the file name which path was specified in the constructor in a read-only mode

Returns
True if file was opened successfully or if file is already opened. False if opening the file failed for some reason (for example: file path does not exist)

Implements pcpp::IDevice.