PcapPlusPlus
pcpp::MplsLayer Class Reference

#include <MplsLayer.h>

Inheritance diagram for pcpp::MplsLayer:
pcpp::Layer pcpp::IDataContainer

Public Member Functions

 MplsLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 MplsLayer (uint32_t mplsLabel, uint8_t ttl, uint8_t expermentalUseValue, bool bottomOfStack)
 
uint8_t getTTL ()
 
void setTTL (uint8_t ttl)
 
bool isBottomOfStack ()
 
void setBottomOfStack (bool val)
 
uint8_t getExperimentalUseValue ()
 
bool setExperimentalUseValue (uint8_t val)
 
uint32_t getMplsLabel ()
 
bool setMplsLabel (uint32_t label)
 
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

Represents a MPLS (Multi-Protocol Label Switching) layer

Constructor & Destructor Documentation

◆ MplsLayer() [1/2]

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

◆ MplsLayer() [2/2]

pcpp::MplsLayer::MplsLayer ( uint32_t  mplsLabel,
uint8_t  ttl,
uint8_t  expermentalUseValue,
bool  bottomOfStack 
)

A constructor that allocates a new MPLS header

Parameters
[in]mplsLabelMPLS label
[in]ttlTime-to-leave value
[in]expermentalUseValueExperimental use value
[in]bottomOfStackBottom-of-stack value which indicate whether the next layer will also be a MPLS label or not

Member Function Documentation

◆ computeCalculateFields()

void pcpp::MplsLayer::computeCalculateFields ( )
virtual

Set/unset the bottom-of-stack bit according to next layer: if it's a MPLS layer then bottom-of-stack will be unset. If it's not a MPLS layer this bit will be set

Implements pcpp::Layer.

◆ getExperimentalUseValue()

uint8_t pcpp::MplsLayer::getExperimentalUseValue ( )
Returns
The exp value (3 bits) of the MPLS label

◆ getHeaderLen()

size_t pcpp::MplsLayer::getHeaderLen ( )
inlinevirtual
Returns
Size of MPLS header (4 bytes)

Implements pcpp::Layer.

◆ getMplsLabel()

uint32_t pcpp::MplsLayer::getMplsLabel ( )
Returns
The MPLS label value (20 bits)

◆ getOsiModelLayer()

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

Implements pcpp::Layer.

◆ getTTL()

uint8_t pcpp::MplsLayer::getTTL ( )
inline
Returns
TTL value of the MPLS header

◆ isBottomOfStack()

bool pcpp::MplsLayer::isBottomOfStack ( )

Get an indication whether the next layer is also be a MPLS label or not

Returns
True if it's the last MPLS layer, false otherwise

◆ parseNextLayer()

void pcpp::MplsLayer::parseNextLayer ( )
virtual

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

Implements pcpp::Layer.

◆ setBottomOfStack()

void pcpp::MplsLayer::setBottomOfStack ( bool  val)

Set the bottom-of-stack bit in the MPLS label

Parameters
[in]valSet or unset the bit

◆ setExperimentalUseValue()

bool pcpp::MplsLayer::setExperimentalUseValue ( uint8_t  val)

Set the exp value (3 bits) of the MPLS label

Parameters
[in]valThe exp value to set. val must be a valid number meaning between 0 and 7 (inclusive)
Returns
True if exp value was set successfully or false if val has invalid value

◆ setMplsLabel()

bool pcpp::MplsLayer::setMplsLabel ( uint32_t  label)

Set the MPLS label (20 bits)

Parameters
[in]labelThe label to set. label must be a valid number meaning between 0 and 0xFFFFF (inclusive)
Returns
True if label was set successfully or false if label has invalid value

◆ setTTL()

void pcpp::MplsLayer::setTTL ( uint8_t  ttl)
inline

Set the TTL value

Parameters
[in]ttlThe TTL value to set

◆ toString()

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

Implements pcpp::Layer.