PcapPlusPlus  21.05
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 () const
 
void setTTL (uint8_t ttl)
 
bool isBottomOfStack () const
 
void setBottomOfStack (bool val)
 
uint8_t getExperimentalUseValue () const
 
bool setExperimentalUseValue (uint8_t val)
 
uint32_t getMplsLabel () const
 
bool setMplsLabel (uint32_t label)
 
void parseNextLayer ()
 
size_t getHeaderLen () const
 
void computeCalculateFields ()
 
std::string toString () 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
 

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 ( ) const
Returns
The exp value (3 bits) of the MPLS label

◆ getHeaderLen()

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

Implements pcpp::Layer.

◆ getMplsLabel()

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

◆ getOsiModelLayer()

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

Implements pcpp::Layer.

◆ getTTL()

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

◆ isBottomOfStack()

bool pcpp::MplsLayer::isBottomOfStack ( ) const

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 ( ) const
virtual
Returns
A string representation of the layer most important data (should look like the layer description in Wireshark)

Implements pcpp::Layer.