PcapPlusPlus  21.05
pcpp::TcpFlagsFilter Class Reference

#include <PcapFilter.h>

Inheritance diagram for pcpp::TcpFlagsFilter:
pcpp::GeneralFilter

Public Types

enum  TcpFlags {
  tcpFin = 1, tcpSyn = 2, tcpRst = 4, tcpPush = 8,
  tcpAck = 16, tcpUrg = 32
}
 
enum  MatchOptions { MatchAll, MatchOneAtLeast }
 

Public Member Functions

 TcpFlagsFilter (uint8_t tcpFlagBitMask, MatchOptions matchOption)
 
void setTcpFlagsBitMask (uint8_t tcpFlagBitMask, MatchOptions matchOption)
 
void parseToString (std::string &result)
 
- Public Member Functions inherited from pcpp::GeneralFilter
bool matchPacketWithFilter (RawPacket *rawPacket)
 
virtual ~GeneralFilter ()
 

Detailed Description

A class for filtering only TCP packets which certain TCP flags are set in them
For deeper understanding of the filter concept please refer to PcapFilter.h

Member Enumeration Documentation

◆ MatchOptions

An enum for representing 2 type of matches: match only packets that contain all flags defined in the filter or match packets that contain at least one of the flags defined in the filter

Enumerator
MatchAll 

Match only packets that contain all flags defined in the filter

MatchOneAtLeast 

Match packets that contain at least one of the flags defined in the filter

◆ TcpFlags

An enum of all TCP flags that can be use in the filter

Enumerator
tcpFin 

TCP FIN flag

tcpSyn 

TCP SYN flag

tcpRst 

TCP RST flag

tcpPush 

TCP PSH flag

tcpAck 

TCP ACK flag

tcpUrg 

TCP URG flag

Constructor & Destructor Documentation

◆ TcpFlagsFilter()

pcpp::TcpFlagsFilter::TcpFlagsFilter ( uint8_t  tcpFlagBitMask,
MatchOptions  matchOption 
)
inline

A constructor that gets a 1-byte bitmask containing all TCP flags participating in the filter and the match option, and creates the filter

Parameters
[in]tcpFlagBitMaskA 1-byte bitmask containing all TCP flags participating in the filter. This parameter can contain the following value for example: TcpFlagsFilter::tcpSyn | TcpFlagsFilter::tcpAck | TcpFlagsFilter::tcpUrg
[in]matchOptionThe match option: TcpFlagsFilter::MatchAll or TcpFlagsFilter::MatchOneAtLeast

Member Function Documentation

◆ parseToString()

void pcpp::TcpFlagsFilter::parseToString ( std::string &  result)
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

Implements pcpp::GeneralFilter.

◆ setTcpFlagsBitMask()

void pcpp::TcpFlagsFilter::setTcpFlagsBitMask ( uint8_t  tcpFlagBitMask,
MatchOptions  matchOption 
)
inline

Set the TCP flags and the match option

Parameters
[in]tcpFlagBitMaskA 1-byte bitmask containing all TCP flags participating in the filter. This parameter can contain the following value for example: TcpFlagsFilter::tcpSyn | TcpFlagsFilter::tcpAck | TcpFlagsFilter::tcpUrg
[in]matchOptionThe match option: TcpFlagsFilter::MatchAll or TcpFlagsFilter::MatchOneAtLeast