PcapPlusPlus  20.08
MplsLayer.h
Go to the documentation of this file.
1 #ifndef PACKETPP_MPLS_LAYER
2 #define PACKETPP_MPLS_LAYER
3 
4 #include "Layer.h"
5 
7 
12 namespace pcpp
13 {
14 
19  class MplsLayer : public Layer
20  {
21  private:
22 
23  #pragma pack(push, 1)
24  struct mpls_header
25  {
26  uint16_t hiLabel;
27  uint8_t misc;
28  uint8_t ttl;
29  };
30  #pragma pack(pop)
31 
32  mpls_header* getMplsHeader() const { return (mpls_header*)m_Data; }
33 
34  public:
41  MplsLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet) : Layer(data, dataLen, prevLayer, packet) { m_Protocol = MPLS; }
42 
50  MplsLayer(uint32_t mplsLabel, uint8_t ttl, uint8_t expermentalUseValue, bool bottomOfStack);
51 
52  virtual ~MplsLayer() {}
53 
57  uint8_t getTTL() const { return getMplsHeader()->ttl; }
58 
63  void setTTL(uint8_t ttl) { getMplsHeader()->ttl = ttl; }
64 
69  bool isBottomOfStack() const;
70 
75  void setBottomOfStack(bool val);
76 
80  uint8_t getExperimentalUseValue() const;
81 
87  bool setExperimentalUseValue(uint8_t val);
88 
92  uint32_t getMplsLabel() const;
93 
99  bool setMplsLabel(uint32_t label);
100 
101  // implement abstract methods
102 
106  void parseNextLayer();
107 
111  size_t getHeaderLen() const { return sizeof(mpls_header); }
112 
117  void computeCalculateFields();
118 
119  std::string toString() const;
120 
122  };
123 
124 } // namespace pcpp
125 
126 #endif /* PACKETPP_MPLS_LAYER */
pcpp::MplsLayer::getOsiModelLayer
OsiModelLayer getOsiModelLayer() const
Definition: MplsLayer.h:121
pcpp::OsiModelLayer
OsiModelLayer
Definition: ProtocolType.h:233
pcpp::MplsLayer
Definition: MplsLayer.h:19
pcpp::Packet
Definition: Packet.h:26
pcpp::MplsLayer::getExperimentalUseValue
uint8_t getExperimentalUseValue() const
pcpp::MplsLayer::setBottomOfStack
void setBottomOfStack(bool val)
Layer.h
pcpp::MplsLayer::setTTL
void setTTL(uint8_t ttl)
Definition: MplsLayer.h:63
pcpp::MplsLayer::isBottomOfStack
bool isBottomOfStack() const
pcpp::OsiModelNetworkLayer
@ OsiModelNetworkLayer
Definition: ProtocolType.h:240
pcpp::MplsLayer::setExperimentalUseValue
bool setExperimentalUseValue(uint8_t val)
pcpp::MplsLayer::getTTL
uint8_t getTTL() const
Definition: MplsLayer.h:57
pcpp::MPLS
const ProtocolType MPLS
Definition: ProtocolType.h:108
pcpp
The main namespace for the PcapPlusPlus lib.
pcpp::Layer
Definition: Layer.h:70
pcpp::MplsLayer::MplsLayer
MplsLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: MplsLayer.h:41
pcpp::MplsLayer::getHeaderLen
size_t getHeaderLen() const
Definition: MplsLayer.h:111
pcpp::MplsLayer::setMplsLabel
bool setMplsLabel(uint32_t label)
pcpp::MplsLayer::computeCalculateFields
void computeCalculateFields()
pcpp::MplsLayer::toString
std::string toString() const
pcpp::MplsLayer::getMplsLabel
uint32_t getMplsLabel() const
pcpp::MplsLayer::parseNextLayer
void parseNextLayer()