PcapPlusPlus  21.05
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  vxlan_header* getVxlanHeader() const { return (vxlan_header*)m_Data; }
101 
105  uint32_t getVNI() const;
106 
111  void setVNI(uint32_t vni);
112 
117  static bool isVxlanPort(uint16_t port) { return port == 4789; }
118 
119 
120  // implement abstract methods
121 
125  void parseNextLayer();
126 
130  size_t getHeaderLen() const { return sizeof(vxlan_header); }
131 
136 
137  std::string toString() const;
138 
140 
141  };
142 
143 }
144 
145 #endif // PACKETPP_VXLAN_LAYER
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:253
uint16_t reserved6_8
Definition: VxlanLayer.h:20
uint32_t pad
Definition: VxlanLayer.h:64
vxlan_header * getVxlanHeader() const
Definition: VxlanLayer.h:100
uint16_t dontLearnFlag
Definition: VxlanLayer.h:34
Definition: ProtocolType.h:258
Definition: Layer.h:70
uint16_t reserved11_12
Definition: VxlanLayer.h:32
Definition: Packet.h:26
size_t getHeaderLen() const
Definition: VxlanLayer.h:130
uint16_t vniPresentFlag
Definition: VxlanLayer.h:22
uint16_t reserved14_16
Definition: VxlanLayer.h:28
void computeCalculateFields()
Definition: VxlanLayer.h:135
uint16_t gbpFlag
Definition: VxlanLayer.h:26
Definition: VxlanLayer.h:16
uint16_t reserved9
Definition: VxlanLayer.h:36
uint16_t reserved2_4
Definition: VxlanLayer.h:24
uint32_t vni
Definition: VxlanLayer.h:62
VxlanLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: VxlanLayer.h:82
uint16_t policyAppliedFlag
Definition: VxlanLayer.h:30
const ProtocolType VXLAN
Definition: ProtocolType.h:178
Definition: VxlanLayer.h:73
uint16_t groupPolicyID
Definition: VxlanLayer.h:59
static bool isVxlanPort(uint16_t port)
Definition: VxlanLayer.h:117
OsiModelLayer getOsiModelLayer() const
Definition: VxlanLayer.h:139