pcpp::PcapFileReaderDevice Class Reference

#include <PcapFileDevice.h>

Inheritance diagram for pcpp::PcapFileReaderDevice:
pcpp::IFileReaderDevice pcpp::IFileDevice pcpp::IPcapDevice

Public Member Functions

 PcapFileReaderDevice (const char *fileName)
virtual ~PcapFileReaderDevice ()
LinkLayerType getLinkLayerType ()
bool getNextPacket (RawPacket &rawPacket)
bool open ()
void getStatistics (pcap_stat &stats)
- Public Member Functions inherited from pcpp::IFileReaderDevice
virtual ~IFileReaderDevice ()
uint64_t getFileSize ()
int getNextPackets (RawPacketVector &packetVec, int numOfPacketsToRead=-1)
- Public Member Functions inherited from pcpp::IFileDevice
std::string getFileName ()
virtual void close ()
- Public Member Functions inherited from pcpp::IPcapDevice
bool isOpened ()
bool setFilter (GeneralFilter &filter)
virtual bool setFilter (std::string filterAsString)
void clearFilter ()

Additional Inherited Members

- Static Public Member Functions inherited from pcpp::IFileReaderDevice
static IFileReaderDevicegetReader (const char *fileName)
- Static Public Member Functions inherited from pcpp::IPcapDevice
static bool verifyFilter (std::string filterAsString)
static bool matchPakcetWithFilter (std::string filterAsString, RawPacket *rawPacket)
- Protected Member Functions inherited from pcpp::IFileReaderDevice
 IFileReaderDevice (const char *fileName)

Detailed Description

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

Constructor & Destructor Documentation

pcpp::PcapFileReaderDevice::PcapFileReaderDevice ( const char *  fileName)

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()

[in]fileNameThe full path of the file to read
virtual pcpp::PcapFileReaderDevice::~PcapFileReaderDevice ( )

A destructor for this class

Member Function Documentation

LinkLayerType pcpp::PcapFileReaderDevice::getLinkLayerType ( )
The link layer type of this file
bool pcpp::PcapFileReaderDevice::getNextPacket ( RawPacket rawPacket)

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

[out]rawPacketA reference for an empty RawPacket where the packet will be written
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.

void pcpp::PcapFileReaderDevice::getStatistics ( pcap_stat &  stats)

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

[out]statsThe stats struct where stats are returned

Implements pcpp::IPcapDevice.

bool pcpp::PcapFileReaderDevice::open ( )

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

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::IPcapDevice.