PcapPlusPlus
pcpp::VlanLayer Class Reference

#include <VlanLayer.h>

Inheritance diagram for pcpp::VlanLayer:
pcpp::Layer

Public Member Functions

 VlanLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 VlanLayer (const uint16_t vlanID, bool cfi, uint8_t priority, uint16_t etherType)
 
vlan_headergetVlanHeader ()
 
uint16_t getVlanID ()
 
uint8_t getCFI ()
 
uint8_t getPriority ()
 
void setVlanID (uint16_t id)
 
void setCFI (bool cfi)
 
void setPriority (uint8_t priority)
 
void parseNextLayer ()
 
size_t getHeaderLen ()
 
void computeCalculateFields ()
 
std::string toString ()
 
OsiModelLayer getOsiModelLayer ()
 
- Public Member Functions inherited from pcpp::Layer
virtual ~Layer ()
 
LayergetNextLayer ()
 
LayergetPrevLayer ()
 
ProtocolType getProtocol ()
 
uint8_t * getData ()
 
size_t getDataLen ()
 
uint8_t * getLayerPayload ()
 
size_t getLayerPayloadSize ()
 
bool isAllocatedToPacket ()
 
void copyData (uint8_t *toArr)
 

Detailed Description

Represents a VLAN tunnel layer

Constructor & Destructor Documentation

pcpp::VlanLayer::VlanLayer ( uint8_t *  data,
size_t  dataLen,
Layer prevLayer,
Packet packet 
)
inline

A constructor that creates the layer from an existing packet raw data

Parameters
[in]dataA pointer to the raw data
[in]dataLenSize of the data in bytes
[in]prevLayerA pointer to the previous layer
[in]packetA pointer to the Packet instance where layer will be stored in
pcpp::VlanLayer::VlanLayer ( const uint16_t  vlanID,
bool  cfi,
uint8_t  priority,
uint16_t  etherType 
)

A constructor that allocates a new VLAN header

Parameters
[in]vlanIDVLAN ID
[in]cfiCFI value
[in]priorityPriority value
[in]etherTypeProtocol EtherType of the next layer

Member Function Documentation

void pcpp::VlanLayer::computeCalculateFields ( )
inlinevirtual

Does nothing for this layer

Implements pcpp::Layer.

uint8_t pcpp::VlanLayer::getCFI ( )
inline
Returns
The CFI bit value
Todo:
Verify it works in big endian machines as well
size_t pcpp::VlanLayer::getHeaderLen ( )
inlinevirtual
Returns
Size of vlan_header

Implements pcpp::Layer.

OsiModelLayer pcpp::VlanLayer::getOsiModelLayer ( )
inlinevirtual
Returns
The OSI Model layer this protocol belongs to

Implements pcpp::Layer.

uint8_t pcpp::VlanLayer::getPriority ( )
inline
Returns
The priority value
Todo:
Verify it works in big endian machines as well
vlan_header* pcpp::VlanLayer::getVlanHeader ( )
inline

Get a pointer to the VLAN header. Notice this points directly to the data, so every change will change the actual packet data

Returns
A pointer to the vlan_header
uint16_t pcpp::VlanLayer::getVlanID ( )
inline

Get the VLAN ID value. This method differs from vlan_header::vlanID because vlan_header::vlanID is 12 bits long in a 16 bit field. This methods extracts only the 12 bit relevant for the VLAN ID

Returns
VLAN ID value
Todo:
Verify it works in big endian machines as well
void pcpp::VlanLayer::parseNextLayer ( )
virtual

Currently identifies the following next layers: IPv4Layer, IPv6Layer, ArpLayer, VlanLayer, MplsLayer. Otherwise sets PayloadLayer

Implements pcpp::Layer.

void pcpp::VlanLayer::setCFI ( bool  cfi)
inline

Set CFI bit

Parameters
[in]cfiThe CFI bit to set
Todo:
Verify it works in big endian machines as well
void pcpp::VlanLayer::setPriority ( uint8_t  priority)
inline

Set priority value

Parameters
[in]priorityThe priority value to set
Todo:
Verify it works in big endian machines as well
void pcpp::VlanLayer::setVlanID ( uint16_t  id)
inline

Set VLAN ID. This method differs from setting vlan_header::vlanID because vlan_header::vlanID is 12 bits long in a 16 bit field. This methods sets only the 12 bit relevant for the VLAN ID

Parameters
[in]idThe VLAN ID to set
Todo:
Verify it works in big endian machines as well
std::string pcpp::VlanLayer::toString ( )
virtual
Returns
A string representation of the layer most important data (should look like the layer description in Wireshark)

Implements pcpp::Layer.