PcapPlusPlus  Next
pcpp::PacketParseOptions Struct Reference

Options struct for configuring packet parsing behavior. More...

#include <Packet.h>

Public Attributes

ProtocolTypeFamily parseUntilProtocol = UnknownProtocol
 Defines the protocol type up to and including which the packet should be parsed (inclusive). More...
 
OsiModelLayer parseUntilLayer = OsiModelLayerUnknown
 Defines an OSI model layer up to and including which the packet should be parsed (inclusive). More...
 

Detailed Description

Options struct for configuring packet parsing behavior.

The parsing options are combined. If multiple stop conditions are specified, parsing stops as soon as any condition is met.

Member Data Documentation

◆ parseUntilLayer

OsiModelLayer pcpp::PacketParseOptions::parseUntilLayer = OsiModelLayerUnknown

Defines an OSI model layer up to and including which the packet should be parsed (inclusive).

For large packets where only the lower layers are of interest, this option can be used to limit the parsing procedure to the desired OSI layer. The packet is parsed until all layers belonging to the specified OSI layer are consumed. Layers beyond that are ignored, which can improve performance and reduce memory usage.

◆ parseUntilProtocol

ProtocolTypeFamily pcpp::PacketParseOptions::parseUntilProtocol = UnknownProtocol

Defines the protocol type up to and including which the packet should be parsed (inclusive).

For large packets where only the lower layers are of interest, this option can be used to limit the parsing procedure to the desired protocol. The packet is parsed until the specified protocol is reached and consumed. Layers beyond this protocol are not parsed, which can improve performance and reduce memory usage.

Remarks
If multiple consecutive layers of the same protocol type exist, parsing stops after exhausting the first contiguous sequence of that protocol type. This matters for protocols that may appear multiple times in succession within a packet (e.g. BgpLayer).