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 ()
bool getAcknowledgmentNum (uint32_t &ackNum)
bool setAcknowledgmentNum (uint32_t ackNum)
bool unsetAcknowledgmentNum ()
void computeCalculateFields ()
std::string toString ()
- Public Member Functions inherited from pcpp::GreLayer
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)

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

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

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

[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
pcpp::GREv1Layer::GREv1Layer ( uint16_t  callID)

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

[in]callIDThe call ID to set

Member Function Documentation

void pcpp::GREv1Layer::computeCalculateFields ( )

Calculate the following fields:

Implements pcpp::Layer.

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

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

[out]ackNumThe returned ack number value if exists in layer. Else remain unchanged
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
gre1_header* pcpp::GREv1Layer::getGreHeader ( )

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

A pointer to the gre1_header
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

[in]ackNumThe ack number value to set
True if managed to set the value successfully, or false otherwise (if couldn't extend the layer)
std::string pcpp::GREv1Layer::toString ( )
A string representation of the layer most important data (should look like the layer description in Wireshark)

Implements pcpp::Layer.

bool pcpp::GREv1Layer::unsetAcknowledgmentNum ( )

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

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