PcapPlusPlus  21.05
pcpp::GREv1Layer Class Reference

#include <GreLayer.h>

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

Public Member Functions

 GREv1Layer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 GREv1Layer (uint16_t callID)
 
gre1_headergetGreHeader () const
 
bool getAcknowledgmentNum (uint32_t &ackNum) const
 
bool setAcknowledgmentNum (uint32_t ackNum)
 
bool unsetAcknowledgmentNum ()
 
void computeCalculateFields ()
 
std::string toString () const
 
- Public Member Functions inherited from pcpp::GreLayer
bool getSequenceNumber (uint32_t &seqNumber) const
 
bool setSequenceNumber (uint32_t seqNumber)
 
bool unsetSequenceNumber ()
 
void parseNextLayer ()
 
size_t getHeaderLen () const
 
OsiModelLayer getOsiModelLayer () const
 
- Public Member Functions inherited from pcpp::Layer
virtual ~Layer ()
 
LayergetNextLayer () const
 
LayergetPrevLayer () const
 
ProtocolType getProtocol () const
 
uint8_t * getData () const
 
size_t getDataLen () const
 
uint8_t * getLayerPayload () const
 
size_t getLayerPayloadSize () const
 
bool isAllocatedToPacket () const
 
void copyData (uint8_t *toArr) const
 
uint8_t * getDataPtr (size_t offset=0) const
 

Additional Inherited Members

- Static Public Member Functions inherited from pcpp::GreLayer
static ProtocolType getGREVersion (uint8_t *greData, size_t greDataLen)
 

Detailed Description

Represents a GRE version 1 protocol

Constructor & Destructor Documentation

◆ GREv1Layer() [1/2]

pcpp::GREv1Layer::GREv1Layer ( uint8_t *  data,
size_t  dataLen,
Layer prevLayer,
Packet packet 
)
inline

A constructor that creates the layer from an existing packet raw data

Parameters
[in]dataA pointer to the raw data
[in]dataLenSize of the data in bytes
[in]prevLayerA pointer to the previous layer
[in]packetA pointer to the Packet instance where layer will be stored in

◆ GREv1Layer() [2/2]

pcpp::GREv1Layer::GREv1Layer ( uint16_t  callID)

A constructor that creates a new GREv1 header and allocates the data

Parameters
[in]callIDThe call ID to set

Member Function Documentation

◆ computeCalculateFields()

void pcpp::GREv1Layer::computeCalculateFields ( )
virtual

Calculate the following fields:

Implements pcpp::Layer.

◆ getAcknowledgmentNum()

bool pcpp::GREv1Layer::getAcknowledgmentNum ( uint32_t &  ackNum) const

Get acknowledgment (ack) number value if field exists in layer

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

◆ getGreHeader()

gre1_header* pcpp::GREv1Layer::getGreHeader ( ) const
inline

Get a pointer to the basic GREv1 header containing all non-optional fields. Notice this points directly to the data, so every change will change the actual packet data. Also please notice that changing the set bits (gre_basic_header::strictSourceRouteBit, gre_basic_header::sequenceNumBit, gre_basic_header::keyBit, gre_basic_header::routingBit, gre_basic_header::checksumBit, gre_basic_header::ackSequenceNumBit) without using the proper set or unset methods (such as setAcknowledgmentNum(), unsetSequenceNumber(), etc.) may result to wrong calculation of header length or illegal GREv1 packet and to some really weird bugs. Please avoid doing so

Returns
A pointer to the gre1_header

◆ setAcknowledgmentNum()

bool pcpp::GREv1Layer::setAcknowledgmentNum ( uint32_t  ackNum)

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

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

◆ toString()

std::string pcpp::GREv1Layer::toString ( ) const
virtual
Returns
A string representation of the layer most important data (should look like the layer description in Wireshark)

Implements pcpp::Layer.

◆ unsetAcknowledgmentNum()

bool pcpp::GREv1Layer::unsetAcknowledgmentNum ( )

Unset acknowledgment (ack) number and remove it from the layer

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