PcapPlusPlus
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  inline mpls_header* getMplsHeader() { 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  inline uint8_t getTTL() { return getMplsHeader()->ttl; }
58 
63  inline void setTTL(uint8_t ttl) { getMplsHeader()->ttl = ttl; }
64 
69  bool isBottomOfStack();
70 
75  void setBottomOfStack(bool val);
76 
80  uint8_t getExperimentalUseValue();
81 
87  bool setExperimentalUseValue(uint8_t val);
88 
92  uint32_t getMplsLabel();
93 
99  bool setMplsLabel(uint32_t label);
100 
101  // implement abstract methods
102 
106  void parseNextLayer();
107 
111  inline size_t getHeaderLen() { return sizeof(mpls_header); }
112 
117  void computeCalculateFields();
118 
119  std::string toString();
120 
122  };
123 
124 } // namespace pcpp
125 
126 #endif /* PACKETPP_MPLS_LAYER */
void setTTL(uint8_t ttl)
Definition: MplsLayer.h:63
uint8_t getExperimentalUseValue()
MplsLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: MplsLayer.h:41
void setBottomOfStack(bool val)
Definition: Packet.h:26
The main namespace for the PcapPlusPlus lib.
bool setMplsLabel(uint32_t label)
OsiModelLayer getOsiModelLayer()
Definition: MplsLayer.h:121
OsiModelLayer
Definition: ProtocolType.h:208
bool isBottomOfStack()
void computeCalculateFields()
Definition: MplsLayer.h:19
Definition: ProtocolType.h:106
void parseNextLayer()
bool setExperimentalUseValue(uint8_t val)
uint32_t getMplsLabel()
Definition: Layer.h:70
size_t getHeaderLen()
Definition: MplsLayer.h:111
Definition: ProtocolType.h:215
uint8_t getTTL()
Definition: MplsLayer.h:57
std::string toString()