PcapPlusPlus  23.09
pcpp::Sll2Layer Class Reference

#include <Sll2Layer.h>

Inheritance diagram for pcpp::Sll2Layer:
pcpp::Layer pcpp::IDataContainer

Public Member Functions

 Sll2Layer (uint8_t *data, size_t dataLen, Packet *packet)
 
 Sll2Layer (uint32_t interfaceIndex, uint16_t ARPHRDType, uint8_t packetType)
 
sll2_headergetSll2Header () const
 
uint16_t getProtocolType () const
 
void setProtocolType (uint16_t protocolType)
 
uint32_t getInterfaceIndex () const
 
void setInterfaceIndex (uint32_t interfaceIndex)
 
uint16_t getArphrdType () const
 
void setArphrdType (uint16_t arphrdType)
 
uint8_t getPacketType () const
 
void setPacketType (uint8_t packetType)
 
uint8_t getLinkLayerAddrLen () const
 
const uint8_t * getLinkLayerAddr () const
 
bool setLinkLayerAddr (const uint8_t *addr, size_t addrLength)
 
MacAddress getLinkLayerAsMacAddress ()
 
bool setMacAddressAsLinkLayer (const MacAddress &macAddr)
 
void parseNextLayer ()
 
void computeCalculateFields ()
 
size_t getHeaderLen () const
 
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 SLL2 (Linux cooked capture) protocol layer

Constructor & Destructor Documentation

◆ Sll2Layer() [1/2]

pcpp::Sll2Layer::Sll2Layer ( 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_header)
[in]dataLenSize of the data in bytes
[in]packetA pointer to the Packet instance where layer will be stored in

◆ Sll2Layer() [2/2]

pcpp::Sll2Layer::Sll2Layer ( uint32_t  interfaceIndex,
uint16_t  ARPHRDType,
uint8_t  packetType 
)

A constructor that creates a new SLL2 header and allocates the data

Parameters
[in]interfaceIndexThe interface index
[in]ARPHRDTypeThe ARPHRD type
[in]packetTypeThe packet type

Member Function Documentation

◆ computeCalculateFields()

void pcpp::Sll2Layer::computeCalculateFields ( )
virtual

Calculate the next protocol type for known protocols: IPv4, IPv6, ARP, VLAN

Implements pcpp::Layer.

◆ getArphrdType()

uint16_t pcpp::Sll2Layer::getArphrdType ( ) const

Get arphrd type of this layer

Returns
arphrd type

◆ getHeaderLen()

size_t pcpp::Sll2Layer::getHeaderLen ( ) const
inlinevirtual
Returns
Size of sll2_header

Implements pcpp::Layer.

◆ getInterfaceIndex()

uint32_t pcpp::Sll2Layer::getInterfaceIndex ( ) const

Get interface index of this layer

Returns
interface index

◆ getLinkLayerAddr()

const uint8_t* pcpp::Sll2Layer::getLinkLayerAddr ( ) const

Get link layer address data pointer

Returns
link layer address data pointer

◆ getLinkLayerAddrLen()

uint8_t pcpp::Sll2Layer::getLinkLayerAddrLen ( ) const

Get link layer address length

Returns
link layer address length

◆ getLinkLayerAsMacAddress()

MacAddress pcpp::Sll2Layer::getLinkLayerAsMacAddress ( )

Get a MAC address in the link layer address field

Returns
return macAddress pointer was set successfully, null pointer if d MAC address isn't valid or if set failed

◆ getOsiModelLayer()

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

Implements pcpp::Layer.

◆ getPacketType()

uint8_t pcpp::Sll2Layer::getPacketType ( ) const

Get packet type of this layer

Returns
packet type

◆ getProtocolType()

uint16_t pcpp::Sll2Layer::getProtocolType ( ) const

Get a protocol type of this layer

Returns
protocol type

◆ getSll2Header()

sll2_header* pcpp::Sll2Layer::getSll2Header ( ) const
inline

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

Returns
A pointer to the sll2_header

◆ isDataValid()

static bool pcpp::Sll2Layer::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::Sll2Layer::parseNextLayer ( )
virtual

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

Implements pcpp::Layer.

◆ setArphrdType()

void pcpp::Sll2Layer::setArphrdType ( uint16_t  arphrdType)

Set arphrd type of this layer

Parameters
[in]arphrdTypearphrd type to set

◆ setInterfaceIndex()

void pcpp::Sll2Layer::setInterfaceIndex ( uint32_t  interfaceIndex)

Set interface index of this layer

Parameters
[in]interfaceIndexinterface index to set

◆ setLinkLayerAddr()

bool pcpp::Sll2Layer::setLinkLayerAddr ( const uint8_t *  addr,
size_t  addrLength 
)

A setter for the link layer address field

Parameters
[in]addrThe address to set. Memory will be copied to packet
[in]addrLengthAddress length, must be lower or equal to 8 (which is max length for SLL2 address)
Returns
True if address was set successfully, or false of addrLength is out of bounds (0 or larger than 8)

◆ setMacAddressAsLinkLayer()

bool pcpp::Sll2Layer::setMacAddressAsLinkLayer ( const MacAddress macAddr)

Set a MAC address in the link layer address field

Parameters
[in]macAddrMAC address to set
Returns
True if address was set successfully, false if MAC address isn't valid or if set failed

◆ setPacketType()

void pcpp::Sll2Layer::setPacketType ( uint8_t  packetType)

Set packet type of this layer

Parameters
[in]packetTypepacket type to set

◆ setProtocolType()

void pcpp::Sll2Layer::setProtocolType ( uint16_t  protocolType)

Set protocol type of this layer

Parameters
[in]protocolTypetype to set

◆ toString()

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

Implements pcpp::Layer.