PcapPlusPlus
VxlanLayer.h
Go to the documentation of this file.
1 #ifndef PACKETPP_VXLAN_LAYER
2 #define PACKETPP_VXLAN_LAYER
3 
4 #include "Layer.h"
5 
7 
8 namespace pcpp
9 {
10 
15 #pragma pack(push, 1)
16  struct vxlan_header
17  {
18  #if(BYTE_ORDER == LITTLE_ENDIAN)
19 
20  uint16_t reserved6_8:3;
22  uint16_t vniPresentFlag:1;
24  uint16_t reserved2_4:3;
26  uint16_t gbpFlag:1;
28  uint16_t reserved14_16:3;
30  uint16_t policyAppliedFlag:1;
32  uint16_t reserved11_12:2;
34  uint16_t dontLearnFlag:1;
36  uint16_t reserved9:1;
37  #else
38 
39  uint16_t reserved9:1;
41  uint16_t dontLearnFlag:1;
43  uint16_t reserved11_12:2;
45  uint16_t policyAppliedFlag:1;
47  uint16_t reserved14_16:3;
49  uint16_t gbpFlag:1;
51  uint16_t reserved2_4:3;
53  uint16_t vniPresentFlag:1;
55  uint16_t reserved6_8:3;
56  #endif
57 
59  uint16_t groupPolicyID;
60 
62  uint32_t vni:24;
64  uint32_t pad:8;
65  };
66 #pragma pack(pop)
67 
68 
73  class VxlanLayer : public Layer
74  {
75  public:
82  VxlanLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet) : Layer(data, dataLen, prevLayer, packet) { m_Protocol = VXLAN; }
83 
92  VxlanLayer(uint32_t vni = 0, uint16_t groupPolicyID = 0, bool setGbpFlag = false, bool setPolicyAppliedFlag = false, bool setDontLearnFlag = false);
93 
94  ~VxlanLayer() {}
95 
100  inline vxlan_header* getVxlanHeader() { return (vxlan_header*)m_Data; }
101 
105  uint32_t getVNI();
106 
111  void setVNI(uint32_t vni);
112 
113 
114  // implement abstract methods
115 
119  void parseNextLayer();
120 
124  inline size_t getHeaderLen() { return sizeof(vxlan_header); }
125 
130 
131  std::string toString();
132 
134 
135  };
136 
137 }
138 
139 #endif // PACKETPP_VXLAN_LAYER
Definition: ProtocolType.h:176
uint16_t reserved14_16
Definition: VxlanLayer.h:28
uint16_t reserved6_8
Definition: VxlanLayer.h:20
void setVNI(uint32_t vni)
Definition: ProtocolType.h:218
uint32_t vni
Definition: VxlanLayer.h:62
uint16_t policyAppliedFlag
Definition: VxlanLayer.h:30
Definition: VxlanLayer.h:16
uint16_t reserved2_4
Definition: VxlanLayer.h:24
Definition: Layer.h:70
uint16_t groupPolicyID
Definition: VxlanLayer.h:59
std::string toString()
uint32_t pad
Definition: VxlanLayer.h:64
Definition: Packet.h:26
size_t getHeaderLen()
Definition: VxlanLayer.h:124
uint16_t dontLearnFlag
Definition: VxlanLayer.h:34
OsiModelLayer
Definition: ProtocolType.h:213
uint32_t getVNI()
VxlanLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: VxlanLayer.h:82
uint16_t reserved11_12
Definition: VxlanLayer.h:32
vxlan_header * getVxlanHeader()
Definition: VxlanLayer.h:100
Definition: VxlanLayer.h:73
uint16_t reserved9
Definition: VxlanLayer.h:36
OsiModelLayer getOsiModelLayer()
Definition: VxlanLayer.h:133
uint16_t gbpFlag
Definition: VxlanLayer.h:26
void computeCalculateFields()
Definition: VxlanLayer.h:129
uint16_t vniPresentFlag
Definition: VxlanLayer.h:22
The main namespace for the PcapPlusPlus lib.