PcapPlusPlus  19.12
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 
113 
114  // implement abstract methods
115 
119  void parseNextLayer();
120 
124  size_t getHeaderLen() const { return sizeof(vxlan_header); }
125 
130 
131  std::string toString() const;
132 
134 
135  };
136 
137 }
138 
139 #endif // PACKETPP_VXLAN_LAYER
pcpp::OsiModelLayer
OsiModelLayer
Definition: ProtocolType.h:224
pcpp::VXLAN
Definition: ProtocolType.h:176
pcpp::Packet
Definition: Packet.h:26
pcpp::VxlanLayer::parseNextLayer
void parseNextLayer()
pcpp::vxlan_header::policyAppliedFlag
uint16_t policyAppliedFlag
Definition: VxlanLayer.h:30
pcpp::OsiModelDataLinkLayer
Definition: ProtocolType.h:229
Layer.h
pcpp::VxlanLayer::getOsiModelLayer
OsiModelLayer getOsiModelLayer() const
Definition: VxlanLayer.h:133
pcpp::VxlanLayer::getVxlanHeader
vxlan_header * getVxlanHeader() const
Definition: VxlanLayer.h:100
pcpp::VxlanLayer
Definition: VxlanLayer.h:73
pcpp::vxlan_header
Definition: VxlanLayer.h:16
pcpp::vxlan_header::groupPolicyID
uint16_t groupPolicyID
Definition: VxlanLayer.h:59
pcpp::VxlanLayer::VxlanLayer
VxlanLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: VxlanLayer.h:82
pcpp::VxlanLayer::computeCalculateFields
void computeCalculateFields()
Definition: VxlanLayer.h:129
pcpp::vxlan_header::reserved6_8
uint16_t reserved6_8
Definition: VxlanLayer.h:20
pcpp::VxlanLayer::getHeaderLen
size_t getHeaderLen() const
Definition: VxlanLayer.h:124
pcpp::vxlan_header::pad
uint32_t pad
Definition: VxlanLayer.h:64
pcpp::vxlan_header::reserved11_12
uint16_t reserved11_12
Definition: VxlanLayer.h:32
pcpp::VxlanLayer::setVNI
void setVNI(uint32_t vni)
pcpp
The main namespace for the PcapPlusPlus lib.
pcpp::vxlan_header::vniPresentFlag
uint16_t vniPresentFlag
Definition: VxlanLayer.h:22
pcpp::vxlan_header::dontLearnFlag
uint16_t dontLearnFlag
Definition: VxlanLayer.h:34
pcpp::VxlanLayer::getVNI
uint32_t getVNI() const
pcpp::Layer
Definition: Layer.h:70
pcpp::vxlan_header::gbpFlag
uint16_t gbpFlag
Definition: VxlanLayer.h:26
pcpp::vxlan_header::reserved14_16
uint16_t reserved14_16
Definition: VxlanLayer.h:28
pcpp::vxlan_header::reserved9
uint16_t reserved9
Definition: VxlanLayer.h:36
pcpp::VxlanLayer::toString
std::string toString() const
pcpp::vxlan_header::vni
uint32_t vni
Definition: VxlanLayer.h:62
pcpp::vxlan_header::reserved2_4
uint16_t reserved2_4
Definition: VxlanLayer.h:24