PcapPlusPlus  22.11
VlanLayer.h
Go to the documentation of this file.
1 #ifndef PACKETPP_VLAN_LAYER
2 #define PACKETPP_VLAN_LAYER
3 
4 #include "Layer.h"
5 #include "EthLayer.h"
6 
8 
13 namespace pcpp
14 {
15 
20 #pragma pack(push, 1)
21  struct vlan_header
22  {
32  uint16_t vlan;
34  uint16_t etherType;
35  };
36 #pragma pack(pop)
37 
38 
43  class VlanLayer : public Layer
44  {
45  public:
52  VlanLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet) : Layer(data, dataLen, prevLayer, packet) { m_Protocol = VLAN; }
53 
61  VlanLayer(const uint16_t vlanID, bool cfi, uint8_t priority, uint16_t etherType = 0);
62 
63  ~VlanLayer() {}
64 
69  vlan_header* getVlanHeader() const { return (vlan_header*)m_Data; }
70 
77  uint16_t getVlanID() const;
78 
83  uint8_t getCFI() const;
84 
89  uint8_t getPriority() const;
90 
97  void setVlanID(uint16_t id);
98 
104  void setCFI(bool cfi);
105 
111  void setPriority(uint8_t priority);
112 
113  // implement abstract methods
114 
118  void parseNextLayer();
119 
123  size_t getHeaderLen() const { return sizeof(vlan_header); }
124 
128  void computeCalculateFields();
129 
130  std::string toString() const;
131 
133  };
134 
135 } // namespace pcpp
136 
137 #endif /* PACKETPP_VLAN_LAYER */
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:298
Definition: VlanLayer.h:21
Definition: ProtocolType.h:303
uint16_t vlan
Definition: VlanLayer.h:32
size_t getHeaderLen() const
Definition: VlanLayer.h:123
Definition: Layer.h:70
Definition: Packet.h:26
const ProtocolType VLAN
Definition: ProtocolType.h:78
uint16_t etherType
Definition: VlanLayer.h:34
vlan_header * getVlanHeader() const
Definition: VlanLayer.h:69
VlanLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: VlanLayer.h:52
OsiModelLayer getOsiModelLayer() const
Definition: VlanLayer.h:132
Definition: VlanLayer.h:43