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 */
pcpp::VlanLayer::getVlanHeader
vlan_header * getVlanHeader() const
Definition: VlanLayer.h:71
pcpp::OsiModelLayer
OsiModelLayer
Definition: ProtocolType.h:233
pcpp::VlanLayer::setCFI
void setCFI(bool cfi)
pcpp::Packet
Definition: Packet.h:26
pcpp::VlanLayer::parseNextLayer
void parseNextLayer()
pcpp::OsiModelDataLinkLayer
@ OsiModelDataLinkLayer
Definition: ProtocolType.h:238
pcpp::VlanLayer
Definition: VlanLayer.h:45
Layer.h
pcpp::VLAN
const ProtocolType VLAN
Definition: ProtocolType.h:78
pcpp::VlanLayer::computeCalculateFields
void computeCalculateFields()
Definition: VlanLayer.h:130
pcpp::VlanLayer::setPriority
void setPriority(uint8_t priority)
pcpp::VlanLayer::getPriority
uint8_t getPriority() const
pcpp::VlanLayer::getHeaderLen
size_t getHeaderLen() const
Definition: VlanLayer.h:125
pcpp::vlan_header::vlan
uint16_t vlan
Definition: VlanLayer.h:34
pcpp::vlan_header::etherType
uint16_t etherType
Definition: VlanLayer.h:36
pcpp::VlanLayer::setVlanID
void setVlanID(uint16_t id)
pcpp::vlan_header
Definition: VlanLayer.h:24
pcpp::VlanLayer::getVlanID
uint16_t getVlanID() const
pcpp::VlanLayer::toString
std::string toString() const
pcpp
The main namespace for the PcapPlusPlus lib.
pcpp::Layer
Definition: Layer.h:70
pcpp::VlanLayer::getOsiModelLayer
OsiModelLayer getOsiModelLayer() const
Definition: VlanLayer.h:134
EthLayer.h
pcpp::VlanLayer::getCFI
uint8_t getCFI() const
pcpp::VlanLayer::VlanLayer
VlanLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: VlanLayer.h:54