PcapPlusPlus  Next
pcpp::IPcapDevice Class Reference

#include <PcapDevice.h>

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

Static Public Member Functions

static std::string getPcapLibVersionInfo ()
 
static bool matchPacketWithFilter (GeneralFilter &filter, RawPacket *rawPacket)
 

Protected Member Functions

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

Additional Inherited Members

- 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...
 
virtual void getStatistics (PcapStats &stats) const =0
 

Detailed Description

An abstract class representing all libpcap-based packet capturing devices: files, libPcap, WinPcap/Npcap and RemoteCapture. This class is abstract and cannot be instantiated

Member Function Documentation

◆ doUpdateFilter()

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

Reimplemented in pcpp::PcapNgFileWriterDevice, and pcpp::PcapNgFileReaderDevice.

◆ getPcapLibVersionInfo()

static std::string pcpp::IPcapDevice::getPcapLibVersionInfo ( )
static

A static method for retrieving pcap lib (libpcap/WinPcap/etc.) version information. This method is actually a wrapper for pcap_lib_version()

Returns
A string containing the pcap lib version information

◆ matchPacketWithFilter()

static bool pcpp::IPcapDevice::matchPacketWithFilter ( GeneralFilter filter,
RawPacket rawPacket 
)
static

Match a raw packet with a given BPF filter. Notice this method is static which means you don't need any device instance in order to perform this match

Parameters
[in]filterA filter class to test against
[in]rawPacketA pointer to the raw packet to match the filter with
Returns
True if raw packet matches the filter or false otherwise
Deprecated:
This method is deprecated, use GeneralFilter::matches(...) method directly.