PcapPlusPlus  23.09
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 experimentalUseValue, 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 */
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:333
bool setExperimentalUseValue(uint8_t val)
MplsLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: MplsLayer.h:41
std::string toString() const
Definition: Layer.h:70
Definition: Packet.h:26
uint8_t getTTL() const
Definition: MplsLayer.h:57
size_t getHeaderLen() const
Definition: MplsLayer.h:111
bool setMplsLabel(uint32_t label)
void computeCalculateFields()
Definition: ProtocolType.h:340
void setBottomOfStack(bool val)
uint32_t getMplsLabel() const
const ProtocolType MPLS
Definition: ProtocolType.h:108
void parseNextLayer()
OsiModelLayer getOsiModelLayer() const
Definition: MplsLayer.h:121
uint8_t getExperimentalUseValue() const
Definition: MplsLayer.h:19
bool isBottomOfStack() const
void setTTL(uint8_t ttl)
Definition: MplsLayer.h:63