PcapPlusPlus
pcpp::GreLayer Class Reference

#include <GreLayer.h>

Inheritance diagram for pcpp::GreLayer:
pcpp::Layer pcpp::IDataContainer pcpp::GREv0Layer pcpp::GREv1Layer

Public Member Functions

bool getSequenceNumber (uint32_t &seqNumber)
 
bool setSequenceNumber (uint32_t seqNumber)
 
bool unsetSequenceNumber ()
 
void parseNextLayer ()
 
size_t getHeaderLen ()
 
OsiModelLayer getOsiModelLayer ()
 
- Public Member Functions inherited from pcpp::Layer
virtual ~Layer ()
 
LayergetNextLayer ()
 
LayergetPrevLayer ()
 
ProtocolType getProtocol ()
 
uint8_t * getData ()
 
size_t getDataLen ()
 
uint8_t * getLayerPayload ()
 
size_t getLayerPayloadSize ()
 
bool isAllocatedToPacket ()
 
void copyData (uint8_t *toArr)
 
uint8_t * getDataPtr (size_t offset=0)
 
virtual void computeCalculateFields ()=0
 
virtual std::string toString ()=0
 

Static Public Member Functions

static ProtocolType getGREVersion (uint8_t *greData, size_t greDataLen)
 

Detailed Description

Abstract base class for GRE layers (GREv0Layer and GREv1Layer). Cannot be instantiated and contains common logic for derived classes

Member Function Documentation

◆ getGREVersion()

static ProtocolType pcpp::GreLayer::getGREVersion ( uint8_t *  greData,
size_t  greDataLen 
)
static

A static method that determines the GRE version of GRE layer raw data by looking at the gre_basic_header::version field

Parameters
[in]greDataGRE layer raw data
[in]greDataLenSize of raw data
Returns
GREv0 or GREv1 values if raw data is GREv0 or GREv1 (accordingly) or UnknownProtocol otherwise

◆ getHeaderLen()

size_t pcpp::GreLayer::getHeaderLen ( )
virtual
Returns
Size of GRE header (may change if optional fields are added or removed)

Implements pcpp::Layer.

◆ getOsiModelLayer()

OsiModelLayer pcpp::GreLayer::getOsiModelLayer ( )
inlinevirtual
Returns
The OSI Model layer this protocol belongs to

Implements pcpp::Layer.

◆ getSequenceNumber()

bool pcpp::GreLayer::getSequenceNumber ( uint32_t &  seqNumber)

Get sequence number value if field exists in layer

Parameters
[out]seqNumberThe returned sequence number value if exists in layer. Else remain unchanged
Returns
True if sequence number field exists in layer. In this case seqNumber will be filled with the value. Or false if sequence number field doesn't exist in layer

◆ parseNextLayer()

void pcpp::GreLayer::parseNextLayer ( )
virtual

Currently identifies the following next layers: IPv4Layer, IPv6Layer, VlanLayer, MplsLayer and PPP_PPTPLayer. Otherwise sets PayloadLayer

Implements pcpp::Layer.

◆ setSequenceNumber()

bool pcpp::GreLayer::setSequenceNumber ( uint32_t  seqNumber)

Set sequence number value. If field already exists (gre_basic_header::sequenceNumBit is set) then only the new value is set. If field doesn't exist it will be added to the layer, gre_basic_header::sequenceNumBit will be set and the new value will be set

Parameters
[in]seqNumberThe sequence number value to set
Returns
True if managed to set the value successfully, or false otherwise (if couldn't extend the layer)

◆ unsetSequenceNumber()

bool pcpp::GreLayer::unsetSequenceNumber ( )

Unset sequence number and remove it from the layer

Returns
True if managed to unset successfully or false (and error log) if sequence number wasn't set in the first place or if didn't manage to remove it from the layer