PcapPlusPlus
19.12
|
#include <GreLayer.h>
Public Member Functions | |
GREv0Layer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet) | |
GREv0Layer () | |
gre_basic_header * | getGreHeader () const |
bool | getChecksum (uint16_t &checksum) |
bool | setChecksum (uint16_t checksum) |
bool | unsetChecksum () |
bool | getOffset (uint16_t &offset) const |
bool | getKey (uint32_t &key) const |
bool | setKey (uint32_t key) |
bool | unsetKey () |
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 () |
Layer * | getNextLayer () const |
Layer * | getPrevLayer () 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) |
Represents a GRE version 0 protocol. Limitation: currently this layer doesn't support GRE routing information parsing and editing. So if a GREv0 packet includes routing information it won't be parse correctly. I didn't add it because of lack of time, but if you need it please tell me and I'll add it
|
inline |
A constructor that creates the layer from an existing packet raw data
[in] | data | A pointer to the raw data |
[in] | dataLen | Size of the data in bytes |
[in] | prevLayer | A pointer to the previous layer |
[in] | packet | A pointer to the Packet instance where layer will be stored in |
pcpp::GREv0Layer::GREv0Layer | ( | ) |
A constructor that creates a new GREv0 header and allocates the data
|
virtual |
Calculate the following fields:
Implements pcpp::Layer.
bool pcpp::GREv0Layer::getChecksum | ( | uint16_t & | checksum | ) |
Get checksum value if field exists in layer
[out] | checksum | The returned checksum value if exists in layer. Else remain unchanged |
|
inline |
Get a pointer to the basic GRE header containing only 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 setChecksum(), unsetChecksum(), etc.) may result to wrong calculation of header length and really weird bugs. Please avoid doing so
bool pcpp::GREv0Layer::getKey | ( | uint32_t & | key | ) | const |
Get key value if field exists in layer
[out] | key | The returned key value if exists in layer. Else remain unchanged |
bool pcpp::GREv0Layer::getOffset | ( | uint16_t & | offset | ) | const |
Get offset value if field exists in layer. Notice there is no setOffset() method as GRE routing information isn't supported yet (see comment on class description)
[out] | offset | The returned offset value if exists in layer. Else remain unchanged |
bool pcpp::GREv0Layer::setChecksum | ( | uint16_t | checksum | ) |
Set checksum value. If checksum or offset fields already exist (gre_basic_header::checksumBit or gre_basic_header::routingBit are set) then only the new value is set. If both fields don't exist a new 4-byte value will be added to the layer, gre_basic_header::checksumBit will be set (gre_basic_header::routingBit will remain unset), the new checksum value will be set and offset value will be set to 0. The reason both fields are added is that GREv0 protocol states both of them or none of them should exist on packet (even if only one of the bits are set)
[in] | checksum | The checksum value to set |
bool pcpp::GREv0Layer::setKey | ( | uint32_t | key | ) |
Set key value. If field already exists (gre_basic_header::keyBit is set) then only the new value is set. If field doesn't exist it will be added to the layer, gre_basic_header::keyBit will be set and the new value will be set
[in] | key | The key value to set |
|
virtual |
Implements pcpp::Layer.
bool pcpp::GREv0Layer::unsetChecksum | ( | ) |
Unset checksum and possibly remove it from the layer. It will be removed from the layer only if gre_basic_header::routingBit is not set as well. Otherwise checksum field will remain on packet with value of 0
bool pcpp::GREv0Layer::unsetKey | ( | ) |
Unset key and remove it from the layer