PcapPlusPlus
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  inline vlan_header* getVlanHeader() { return (vlan_header*)m_Data; }
72 
79  uint16_t getVlanID();
80 
85  uint8_t getCFI();
86 
91  uint8_t getPriority();
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  inline size_t getHeaderLen() { return sizeof(vlan_header); }
126 
131 
132  std::string toString();
133 
135  };
136 
137 } // namespace pcpp
138 
139 #endif /* PACKETPP_VLAN_LAYER */
size_t getHeaderLen()
Definition: VlanLayer.h:125
void setCFI(bool cfi)
Definition: ProtocolType.h:218
void parseNextLayer()
uint8_t getPriority()
std::string toString()
void setVlanID(uint16_t id)
vlan_header * getVlanHeader()
Definition: VlanLayer.h:71
VlanLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: VlanLayer.h:54
uint16_t vlan
Definition: VlanLayer.h:34
Definition: Layer.h:70
void setPriority(uint8_t priority)
void computeCalculateFields()
Definition: VlanLayer.h:130
Definition: Packet.h:26
OsiModelLayer
Definition: ProtocolType.h:213
Definition: VlanLayer.h:45
Definition: ProtocolType.h:76
Definition: VlanLayer.h:24
uint16_t etherType
Definition: VlanLayer.h:36
uint8_t getCFI()
The main namespace for the PcapPlusPlus lib.
OsiModelLayer getOsiModelLayer()
Definition: VlanLayer.h:134
uint16_t getVlanID()