PcapPlusPlus  Next
pcpp::ProtoFilter Class Reference

#include <PcapFilter.h>

Inheritance diagram for pcpp::ProtoFilter:
pcpp::GeneralFilter

Public Member Functions

 ProtoFilter (ProtocolType proto)
 
 ProtoFilter (ProtocolTypeFamily protoFamily)
 
void parseToString (std::string &result) const override
 
void setProto (ProtocolType proto)
 
void setProto (ProtocolTypeFamily protoFamily)
 
- Public Member Functions inherited from pcpp::GeneralFilter
virtual ~GeneralFilter ()=default
 Virtual destructor, frees the bpf program.
 
bool matchPacketWithFilter (RawPacket *rawPacket) const
 
bool matches (RawPacket const &rawPacket) const
 Match a raw packet against the filter. More...
 

Additional Inherited Members

- Protected Member Functions inherited from pcpp::GeneralFilter
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

A class for filtering traffic by protocol. Notice not all protocols are supported, only the following protocol are supported: TCP, UDP, ICMP, VLAN, IPv4, IPv6, ARP, Ethernet. In addition, the following protocol families are supported: GRE (distinguish between GREv0 and GREv1 is not supported), IGMP (distinguish between IGMPv1, IGMPv2 and IGMPv3 is not supported).

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

Constructor & Destructor Documentation

◆ ProtoFilter() [1/2]

pcpp::ProtoFilter::ProtoFilter ( ProtocolType  proto)
inlineexplicit

A constructor that gets a protocol and creates the filter

Parameters
[in]protoThe protocol to filter, only packets matching this protocol will be received. Please note not all protocols are supported. List of supported protocols is found in the class description

◆ ProtoFilter() [2/2]

pcpp::ProtoFilter::ProtoFilter ( ProtocolTypeFamily  protoFamily)
inlineexplicit

A constructor that gets a protocol family and creates the filter

Parameters
[in]protoFamilyThe protocol family to filter, only packets matching this protocol will be received. Please note not all protocols are supported. List of supported protocols is found in the class description

Member Function Documentation

◆ parseToString()

void pcpp::ProtoFilter::parseToString ( std::string &  result) const
overridevirtual

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

Implements pcpp::GeneralFilter.

◆ setProto() [1/2]

void pcpp::ProtoFilter::setProto ( ProtocolType  proto)
inline

Set the protocol to filter with

Parameters
[in]protoThe protocol to filter, only packets matching this protocol will be received. Please note not all protocol families are supported. List of supported protocols is found in the class description

◆ setProto() [2/2]

void pcpp::ProtoFilter::setProto ( ProtocolTypeFamily  protoFamily)
inline

Set the protocol family to filter with

Parameters
[in]protoFamilyThe protocol family to filter, only packets matching this protocol will be received. Please note not all protocol families are supported. List of supported protocols is found in the class description