PcapPlusPlus
VxlanLayer.h
1 #ifndef PACKETPP_VXLAN_LAYER
2 #define PACKETPP_VXLAN_LAYER
3 
4 #include <Layer.h>
5 
6 namespace pcpp
7 {
8 
13 #pragma pack(push, 1)
14  struct vxlan_header
15  {
16  #if(BYTE_ORDER == LITTLE_ENDIAN)
17 
18  uint16_t reserved6_8:3;
20  uint16_t vniPresentFlag:1;
22  uint16_t reserved2_4:3;
24  uint16_t gbpFlag:1;
26  uint16_t reserved14_16:3;
28  uint16_t policyAppliedFlag:1;
30  uint16_t reserved11_12:2;
32  uint16_t dontLearnFlag:1;
34  uint16_t reserved9:1;
35  #else
36 
37  uint16_t reserved9:1;
39  uint16_t dontLearnFlag:1;
41  uint16_t reserved11_12:2;
43  uint16_t policyAppliedFlag:1;
45  uint16_t reserved14_16:3;
47  uint16_t gbpFlag:1;
49  uint16_t reserved2_4:3;
51  uint16_t vniPresentFlag:1;
53  uint16_t reserved6_8:3;
54  #endif
55 
57  uint16_t groupPolicyID;
58 
60  uint32_t vni:24;
62  uint32_t pad:8;
63  };
64 #pragma pack(pop)
65 
66 
71  class VxlanLayer : public Layer
72  {
73  public:
80  VxlanLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet) : Layer(data, dataLen, prevLayer, packet) { m_Protocol = VXLAN; }
81 
90  VxlanLayer(uint32_t vni = 0, uint16_t groupPolicyID = 0, bool setGbpFlag = false, bool setPolicyAppliedFlag = false, bool setDontLearnFlag = false);
91 
92  ~VxlanLayer() {}
93 
98  inline vxlan_header* getVxlanHeader() { return (vxlan_header*)m_Data; }
99 
103  uint32_t getVNI();
104 
109  void setVNI(uint32_t vni);
110 
111 
112  // implement abstract methods
113 
117  void parseNextLayer();
118 
122  inline size_t getHeaderLen() { return sizeof(vxlan_header); }
123 
128 
129  std::string toString();
130 
132 
133  };
134 
135 }
136 
137 #endif // PACKETPP_VXLAN_LAYER
uint16_t reserved6_8
Definition: VxlanLayer.h:18
void setVNI(uint32_t vni)
uint32_t pad
Definition: VxlanLayer.h:62
uint32_t vni
Definition: VxlanLayer.h:60
uint16_t reserved14_16
Definition: VxlanLayer.h:26
vxlan_header * getVxlanHeader()
Definition: VxlanLayer.h:98
OsiModelLayer
Definition: ProtocolType.h:203
uint16_t vniPresentFlag
Definition: VxlanLayer.h:20
uint16_t dontLearnFlag
Definition: VxlanLayer.h:32
OsiModelLayer getOsiModelLayer()
Definition: VxlanLayer.h:131
Definition: Packet.h:26
VxlanLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: VxlanLayer.h:80
uint16_t gbpFlag
Definition: VxlanLayer.h:24
uint32_t getVNI()
uint16_t reserved11_12
Definition: VxlanLayer.h:30
void computeCalculateFields()
Definition: VxlanLayer.h:127
uint16_t reserved2_4
Definition: VxlanLayer.h:22
Definition: Layer.h:52
std::string toString()
size_t getHeaderLen()
Definition: VxlanLayer.h:122
Definition: ProtocolType.h:176
Definition: VxlanLayer.h:71
The main namespace for the PcapPlusPlus lib.
uint16_t groupPolicyID
Definition: VxlanLayer.h:57
uint16_t policyAppliedFlag
Definition: VxlanLayer.h:28
uint16_t reserved9
Definition: VxlanLayer.h:34
Definition: VxlanLayer.h:14
Definition: ProtocolType.h:208