PcapPlusPlus
pcpp::PacketTrailerLayer Class Reference

#include <PacketTrailerLayer.h>

Inheritance diagram for pcpp::PacketTrailerLayer:
pcpp::Layer pcpp::IDataContainer

Public Member Functions

 PacketTrailerLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
uint8_t * getTrailerData ()
 
std::string getTrailerDataAsHexString ()
 
size_t getTrailerLen ()
 
void parseNextLayer ()
 
size_t getHeaderLen ()
 
void computeCalculateFields ()
 
std::string toString ()
 
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)
 

Detailed Description

A class for representing packet tailer (a.k.a footer or padding) which refers to supplemental data placed at the end of a block of data being stored or transmitted, which may contain information for the handling of the data block, or just mark its end (taken from Wikipedia: https://en.wikipedia.org/wiki/Trailer_(computing) )

There are various reasons for adding a packet trailer, one of the most famous is FCS (Frame check sequence) which refers to the extra error-detecting code added to a frame. Another usage is padding which means adding data to reach a minimum required packet length.

Although this layer inherits from the Layer class, it is not a standard layer in the sense that it can't be constructed by the user. This layer may be only be constructed in the Packet class, in the process of parsing the packet and creating the layers; if at the end of the parsing process there is data left that is not allocated to any layer, it's assumed to be the packet trailer and an instance of this class is created. This means this layer can only exist as the last layer in a packet, if a packet trailer indeed exists.

No layer can be added by the user after this layer (trying to do that will result with an error).

This layer can be removed by the user or extended/shortened, as any layer.

It also contains method to extract the trailer data

Constructor & Destructor Documentation

◆ PacketTrailerLayer()

pcpp::PacketTrailerLayer::PacketTrailerLayer ( 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

Member Function Documentation

◆ computeCalculateFields()

void pcpp::PacketTrailerLayer::computeCalculateFields ( )
inlinevirtual

Does nothing for this layer

Implements pcpp::Layer.

◆ getHeaderLen()

size_t pcpp::PacketTrailerLayer::getHeaderLen ( )
inlinevirtual
Returns
trailer data length in bytes

Implements pcpp::Layer.

◆ getOsiModelLayer()

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

Implements pcpp::Layer.

◆ getTrailerData()

uint8_t* pcpp::PacketTrailerLayer::getTrailerData ( )
inline

Get a pointer to the trailer data

Returns
A pointer to the trailer data

◆ getTrailerDataAsHexString()

std::string pcpp::PacketTrailerLayer::getTrailerDataAsHexString ( )
Returns
Trailer data as hex string

◆ getTrailerLen()

size_t pcpp::PacketTrailerLayer::getTrailerLen ( )
inline

Get the trailer data length

Returns
The trailer data length in bytes

◆ parseNextLayer()

void pcpp::PacketTrailerLayer::parseNextLayer ( )
inlinevirtual

Does nothing for this layer (PacketTrailerLayer is always last)

Implements pcpp::Layer.

◆ toString()

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

Implements pcpp::Layer.