PcapPlusPlus  Next
pcpp::IFilterableDevice Class Referenceabstract

#include <Device.h>

Inheritance diagram for pcpp::IFilterableDevice:
pcpp::IDevice pcpp::IPcapDevice pcpp::PfRingDevice pcpp::IFileDevice pcpp::PcapLiveDevice pcpp::IFileReaderDevice pcpp::IFileWriterDevice pcpp::PcapRemoteDevice pcpp::WinPcapLiveDevice pcpp::PcapFileReaderDevice pcpp::PcapNgFileReaderDevice pcpp::SnoopFileReaderDevice pcpp::PcapFileWriterDevice pcpp::PcapNgFileWriterDevice

Public Member Functions

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
 

Protected Member Functions

virtual bool doUpdateFilter (std::string const *filterAsString)=0
 Updates the filter on the device with a BPF string. More...
 

Detailed Description

An abstract interface representing all devices that have BPF (Berkeley Packet Filter) filtering capabilities, meaning devices that can filter packets based on the BPF filtering syntax. This is an abstract class that cannot be instantiated

Member Function Documentation

◆ clearFilter()

bool pcpp::IFilterableDevice::clearFilter ( )
inline

Clear the filter currently set on the device

Returns
True if filter was removed successfully or if no filter was set, false otherwise

◆ doUpdateFilter()

virtual bool pcpp::IFilterableDevice::doUpdateFilter ( std::string const *  filterAsString)
protectedpure virtual

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.

Implemented in pcpp::PfRingDevice, pcpp::PcapNgFileWriterDevice, pcpp::IPcapDevice, and pcpp::PcapNgFileReaderDevice.

◆ setFilter() [1/2]

bool pcpp::IFilterableDevice::setFilter ( GeneralFilter filter)
inline

Set a filter for the device. When implemented by the device, only packets that match the filter will be received

Parameters
[in]filterThe filter to be set in PcapPlusPlus' GeneralFilter format
Returns
True if filter set successfully, false otherwise

◆ setFilter() [2/2]

bool pcpp::IFilterableDevice::setFilter ( std::string const &  filterAsString)
inline

Set a filter for the device. When implemented by the device, only packets that match the filter will be processed.

Parameters
[in]filterAsStringThe filter to be set in Berkeley Packet Filter (BPF) syntax (http://biot.com/capstats/bpf.html)
Returns
True if filter set successfully, false otherwise