PcapPlusPlus  Next
pcpp::IFileDevice Class Reference

#include <PcapFileDevice.h>

Inheritance diagram for pcpp::IFileDevice:
pcpp::IFilterableDevice pcpp::IPcapStatisticsProvider pcpp::IDevice pcpp::IFileReaderDevice pcpp::IFileWriterDevice pcpp::PcapFileReaderDevice pcpp::PcapNgFileReaderDevice pcpp::SnoopFileReaderDevice pcpp::PcapFileWriterDevice pcpp::PcapNgFileWriterDevice

Public Member Functions

std::string getFileName () const
 
void getStatistics (PcapStats &stats) const override
 Get the statistics for this device. More...
 
- Public Member Functions inherited from pcpp::IFilterableDevice
bool setFilter (GeneralFilter &filter)
 
bool setFilter (std::string const &filterAsString)
 
bool clearFilter ()
 
- Public Member Functions inherited from pcpp::IDevice
virtual bool open ()=0
 
virtual void close ()=0
 Close the device.
 
virtual bool isOpened () const =0
 
- Public Member Functions inherited from pcpp::IPcapStatisticsProvider
PcapStats getStatistics () const
 Get statistics from the device. More...
 

Protected Member Functions

bool doUpdateFilter (std::string const *filterAsString) override
 Updates the filter on the device with a BPF string. More...
 
void reportPacketProcessed (uint64_t numPackets=1)
 Report that packets were processed (read or written, depending on the device type). More...
 
void reportPacketDropped (uint64_t numPackets=1)
 Report that packets were dropped (not read or not written, depending on the device type). More...
 
void resetStatisticCounters ()
 Reset the internal statistic counters to zero.
 

Detailed Description

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

Member Function Documentation

◆ doUpdateFilter()

bool pcpp::IFileDevice::doUpdateFilter ( std::string const *  filterAsString)
overrideprotectedvirtual

Updates the filter on the device with a BPF string.

Only packets that match the filter should be processed by the device after this method is called. A nullptr should disable any existing filter on the device.

Parameters
filterAsStringA pointer to a string representing the filter in BPF syntax (http://biot.com/capstats/bpf.html).
Returns
True if the operation was successful, false otherwise.

Implements pcpp::IFilterableDevice.

◆ getFileName()

std::string pcpp::IFileDevice::getFileName ( ) const
Returns
The name of the file

◆ getStatistics()

void pcpp::IFileDevice::getStatistics ( PcapStats stats) const
overridevirtual

Get the statistics for this device.

The PcapStats structure will hold the following:

  • packetsRecv: Number of packets processed (read or written, depending on the device type)
  • packetsDrop: Number of packets dropped (not read or not written, depending on the device type)
  • packetsDropByInterface: Not supported for file devices, will always be 0
Parameters
[out]statsThe stats object to fill in.

Implements pcpp::IPcapStatisticsProvider.

◆ reportPacketDropped()

void pcpp::IFileDevice::reportPacketDropped ( uint64_t  numPackets = 1)
inlineprotected

Report that packets were dropped (not read or not written, depending on the device type).

Parameters
numPacketsThe number of packets dropped. Default is 1.

◆ reportPacketProcessed()

void pcpp::IFileDevice::reportPacketProcessed ( uint64_t  numPackets = 1)
inlineprotected

Report that packets were processed (read or written, depending on the device type).

Parameters
numPacketsThe number of packets processed. Default is 1.