PcapPlusPlus  20.08+
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 {
31  uint16_t vlan;
33  uint16_t etherType;
34  };
35 #pragma pack(pop)
36 
37 
42  class VlanLayer : public Layer
43  {
44  public:
51  VlanLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet) : Layer(data, dataLen, prevLayer, packet) { m_Protocol = VLAN; }
52 
60  VlanLayer(const uint16_t vlanID, bool cfi, uint8_t priority, uint16_t etherType);
61 
62  ~VlanLayer() {}
63 
68  vlan_header* getVlanHeader() const { return (vlan_header*)m_Data; }
69 
76  uint16_t getVlanID() const;
77 
82  uint8_t getCFI() const;
83 
88  uint8_t getPriority() const;
89 
96  void setVlanID(uint16_t id);
97 
103  void setCFI(bool cfi);
104 
110  void setPriority(uint8_t priority);
111 
112  // implement abstract methods
113 
117  void parseNextLayer();
118 
122  size_t getHeaderLen() const { return sizeof(vlan_header); }
123 
128 
129  std::string toString() const;
130 
132  };
133 
134 } // namespace pcpp
135 
136 #endif /* PACKETPP_VLAN_LAYER */
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:238
void computeCalculateFields()
Definition: VlanLayer.h:127
Definition: VlanLayer.h:21
Definition: ProtocolType.h:243
uint16_t vlan
Definition: VlanLayer.h:31
size_t getHeaderLen() const
Definition: VlanLayer.h:122
Definition: Layer.h:70
Definition: Packet.h:26
const ProtocolType VLAN
Definition: ProtocolType.h:78
uint16_t etherType
Definition: VlanLayer.h:33
vlan_header * getVlanHeader() const
Definition: VlanLayer.h:68
VlanLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: VlanLayer.h:51
OsiModelLayer getOsiModelLayer() const
Definition: VlanLayer.h:131
Definition: VlanLayer.h:42