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 #if defined(WIN32) || defined(WINx64)
7 #include <winsock2.h>
8 #endif
9 
11 
16 namespace pcpp
17 {
18 
23 #pragma pack(push, 1)
24  struct vlan_header {
34  uint16_t vlan;
36  uint16_t etherType;
37  };
38 #pragma pack(pop)
39 
40 
45  class VlanLayer : public Layer
46  {
47  public:
54  VlanLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet) : Layer(data, dataLen, prevLayer, packet) { m_Protocol = VLAN; }
55 
63  VlanLayer(const uint16_t vlanID, bool cfi, uint8_t priority, uint16_t etherType);
64 
65  ~VlanLayer() {}
66 
71  vlan_header* getVlanHeader() const { return (vlan_header*)m_Data; }
72 
79  uint16_t getVlanID() const;
80 
85  uint8_t getCFI() const;
86 
91  uint8_t getPriority() const;
92 
99  void setVlanID(uint16_t id);
100 
106  void setCFI(bool cfi);
107 
113  void setPriority(uint8_t priority);
114 
115  // implement abstract methods
116 
120  void parseNextLayer();
121 
125  size_t getHeaderLen() const { return sizeof(vlan_header); }
126 
131 
132  std::string toString() const;
133 
135  };
136 
137 } // namespace pcpp
138 
139 #endif /* PACKETPP_VLAN_LAYER */
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:233
void computeCalculateFields()
Definition: VlanLayer.h:130
Definition: VlanLayer.h:24
Definition: ProtocolType.h:238
uint16_t vlan
Definition: VlanLayer.h:34
size_t getHeaderLen() const
Definition: VlanLayer.h:125
Definition: Layer.h:70
Definition: Packet.h:26
const ProtocolType VLAN
Definition: ProtocolType.h:78
uint16_t etherType
Definition: VlanLayer.h:36
vlan_header * getVlanHeader() const
Definition: VlanLayer.h:71
VlanLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: VlanLayer.h:54
OsiModelLayer getOsiModelLayer() const
Definition: VlanLayer.h:134
Definition: VlanLayer.h:45