PcapPlusPlus  21.05
pcpp::EthDot3Layer Class Reference

#include <EthDot3Layer.h>

Inheritance diagram for pcpp::EthDot3Layer:
pcpp::Layer pcpp::IDataContainer

Public Member Functions

 EthDot3Layer (uint8_t *data, size_t dataLen, Packet *packet)
 
 EthDot3Layer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 EthDot3Layer (const MacAddress &sourceMac, const MacAddress &destMac, uint16_t length)
 
ether_dot3_headergetEthHeader () const
 
MacAddress getSourceMac () const
 
void setSourceMac (const MacAddress &sourceMac)
 
MacAddress getDestMac () const
 
void setDestMac (const MacAddress &destMac)
 
void parseNextLayer ()
 
size_t getHeaderLen () const
 
void computeCalculateFields ()
 
std::string toString () const
 
OsiModelLayer getOsiModelLayer () const
 
- Public Member Functions inherited from pcpp::Layer
virtual ~Layer ()
 
LayergetNextLayer () const
 
LayergetPrevLayer () const
 
ProtocolType getProtocol () const
 
uint8_t * getData () const
 
size_t getDataLen () const
 
uint8_t * getLayerPayload () const
 
size_t getLayerPayloadSize () const
 
bool isAllocatedToPacket () const
 
void copyData (uint8_t *toArr) const
 
uint8_t * getDataPtr (size_t offset=0) const
 

Static Public Member Functions

static bool isDataValid (const uint8_t *data, size_t dataLen)
 

Detailed Description

Represents an IEEE 802.3 Ethernet protocol layer

Constructor & Destructor Documentation

◆ EthDot3Layer() [1/3]

pcpp::EthDot3Layer::EthDot3Layer ( uint8_t *  data,
size_t  dataLen,
Packet packet 
)
inline

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

Parameters
[in]dataA pointer to the raw data (will be casted to ether_dot3_header)
[in]dataLenSize of the data in bytes
[in]packetA pointer to the Packet instance where layer will be stored in

◆ EthDot3Layer() [2/3]

pcpp::EthDot3Layer::EthDot3Layer ( 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 (will be casted to ether_header)
[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

◆ EthDot3Layer() [3/3]

pcpp::EthDot3Layer::EthDot3Layer ( const MacAddress sourceMac,
const MacAddress destMac,
uint16_t  length 
)

A constructor that creates a new IEEE 802.3 Ethernet header and allocates the data

Parameters
[in]sourceMacThe source MAC address
[in]destMacThe destination MAC address
[in]lengthThe frame length

Member Function Documentation

◆ computeCalculateFields()

void pcpp::EthDot3Layer::computeCalculateFields ( )
inlinevirtual

Does nothing for this layer

Implements pcpp::Layer.

◆ getDestMac()

MacAddress pcpp::EthDot3Layer::getDestMac ( ) const
inline

Get the destination MAC address

Returns
The destination MAC address

◆ getEthHeader()

ether_dot3_header* pcpp::EthDot3Layer::getEthHeader ( ) const
inline

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

Returns
A pointer to the ether_header

◆ getHeaderLen()

size_t pcpp::EthDot3Layer::getHeaderLen ( ) const
inlinevirtual
Returns
Size of ether_dot3_header

Implements pcpp::Layer.

◆ getOsiModelLayer()

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

Implements pcpp::Layer.

◆ getSourceMac()

MacAddress pcpp::EthDot3Layer::getSourceMac ( ) const
inline

Get the source MAC address

Returns
The source MAC address

◆ isDataValid()

static bool pcpp::EthDot3Layer::isDataValid ( const uint8_t *  data,
size_t  dataLen 
)
static

A static method that validates the input data

Parameters
[in]dataThe pointer to the beginning of a byte stream of an IEEE 802.3 Eth packet
[in]dataLenThe length of the byte stream
Returns
True if the data is valid and can represent an IEEE 802.3 Eth packet

◆ parseNextLayer()

void pcpp::EthDot3Layer::parseNextLayer ( )
virtual

Currently doesn't identify any particular layer (because LLC is not supported yet) so the payload will always be of type PayloadLayer.

Implements pcpp::Layer.

◆ setDestMac()

void pcpp::EthDot3Layer::setDestMac ( const MacAddress destMac)
inline

Set destination MAC address

Parameters
destMacDestination MAC to set

◆ setSourceMac()

void pcpp::EthDot3Layer::setSourceMac ( const MacAddress sourceMac)
inline

Set source MAC address

Parameters
sourceMacSource MAC to set

◆ toString()

std::string pcpp::EthDot3Layer::toString ( ) const
virtual
Returns
A string representation of the layer most important data (should look like the layer description in Wireshark)

Implements pcpp::Layer.