PcapPlusPlus  24.09
VlanLayer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Layer.h"
4 #include "EthLayer.h"
5 
7 
12 namespace pcpp
13 {
14 
19 #pragma pack(push, 1)
20  struct vlan_header
21  {
31  uint16_t vlan;
33  uint16_t etherType;
34  };
35 #pragma pack(pop)
36 
41  class VlanLayer : public Layer
42  {
43  public:
50  VlanLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet)
51  : Layer(data, dataLen, prevLayer, packet, VLAN)
52  {}
53 
62  VlanLayer(const uint16_t vlanID, bool cfi, uint8_t priority, uint16_t etherType = 0);
63 
64  ~VlanLayer()
65  {}
66 
73  {
74  return (vlan_header*)m_Data;
75  }
76 
83  uint16_t getVlanID() const;
84 
89  uint8_t getCFI() const;
90 
95  uint8_t getPriority() const;
96 
103  void setVlanID(uint16_t id);
104 
110  void setCFI(bool cfi);
111 
117  void setPriority(uint8_t priority);
118 
119  // implement abstract methods
120 
126 
130  size_t getHeaderLen() const
131  {
132  return sizeof(vlan_header);
133  }
134 
139 
140  std::string toString() const;
141 
143  {
144  return OsiModelDataLinkLayer;
145  }
146  };
147 
148 } // namespace pcpp
Definition: Layer.h:70
Definition: Packet.h:27
Definition: VlanLayer.h:42
void parseNextLayer()
uint8_t getCFI() const
OsiModelLayer getOsiModelLayer() const
Definition: VlanLayer.h:142
uint16_t getVlanID() const
size_t getHeaderLen() const
Definition: VlanLayer.h:130
VlanLayer(const uint16_t vlanID, bool cfi, uint8_t priority, uint16_t etherType=0)
std::string toString() const
uint8_t getPriority() const
VlanLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: VlanLayer.h:50
vlan_header * getVlanHeader() const
Definition: VlanLayer.h:72
void setPriority(uint8_t priority)
void computeCalculateFields()
void setCFI(bool cfi)
void setVlanID(uint16_t id)
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:354
@ OsiModelDataLinkLayer
Definition: ProtocolType.h:358
const ProtocolType VLAN
Definition: ProtocolType.h:83
Definition: VlanLayer.h:21
uint16_t etherType
Definition: VlanLayer.h:33
uint16_t vlan
Definition: VlanLayer.h:31