PcapPlusPlus  Next
pcpp::GeneralFilter Class Referenceabstract

#include <PcapFilter.h>

Inheritance diagram for pcpp::GeneralFilter:
pcpp::ArpFilter pcpp::BPFStringFilter pcpp::CompositeFilter pcpp::EtherTypeFilter pcpp::IFilterWithDirection pcpp::IFilterWithOperator pcpp::NotFilter pcpp::ProtoFilter pcpp::TcpFlagsFilter pcpp::VlanFilter

Public Member Functions

virtual ~GeneralFilter ()=default
 Virtual destructor, frees the bpf program.
 
virtual void parseToString (std::string &result) const =0
 
bool matchPacketWithFilter (RawPacket *rawPacket) const
 
bool matches (RawPacket const &rawPacket) const
 Match a raw packet against the filter. More...
 

Protected Member Functions

bool cacheFilter () const
 Parse the filter and cache the compiled BPF program. More...
 
void invalidateCache () const
 Invalidate the cached BPF program. This method should be called whenever the filter changes.
 

Detailed Description

The base class for all filter classes. This class is virtual and abstract, hence cannot be instantiated.

For deeper understanding of the filter concept please refer to PcapFilter.h

Member Function Documentation

◆ cacheFilter()

bool pcpp::GeneralFilter::cacheFilter ( ) const
protected

Parse the filter and cache the compiled BPF program.

Returns
True if the filter was successfully parsed and cached, false otherwise.

◆ matches()

bool pcpp::GeneralFilter::matches ( RawPacket const &  rawPacket) const

Match a raw packet against the filter.

Parameters
rawPacketThe raw packet to match against.
Returns
True if the filter matches (or if it's empty). False otherwise.

◆ matchPacketWithFilter()

bool pcpp::GeneralFilter::matchPacketWithFilter ( RawPacket rawPacket) const

Match a raw packet with a given BPF filter.

Parameters
[in]rawPacketA pointer to the raw packet to match the BPF filter with
Returns
True if a raw packet matches the BPF filter or false otherwise
Deprecated:
This method is deprecated, use matches(...) overload instead.

◆ parseToString()

virtual void pcpp::GeneralFilter::parseToString ( std::string &  result) const
pure virtual

A method that parses the class instance into BPF string format

Parameters
[out]resultAn empty string that the parsing will be written into. If the string isn't empty, its content will be overridden

Implemented in pcpp::UdpLengthFilter, pcpp::TcpWindowSizeFilter, pcpp::TcpFlagsFilter, pcpp::VlanFilter, pcpp::ArpFilter, pcpp::ProtoFilter, pcpp::NotFilter, pcpp::CompositeLogicFilter< op >, pcpp::EtherTypeFilter, pcpp::MacAddressFilter, pcpp::PortRangeFilter, pcpp::PortFilter, pcpp::IPv4TotalLengthFilter, pcpp::IPv4IDFilter, pcpp::IPFilter, and pcpp::BPFStringFilter.