PcapPlusPlus  21.05
pcpp::SllLayer Class Reference

#include <SllLayer.h>

Inheritance diagram for pcpp::SllLayer:
pcpp::Layer pcpp::IDataContainer

Public Member Functions

 SllLayer (uint8_t *data, size_t dataLen, Packet *packet)
 
 SllLayer (uint16_t packetType, uint16_t ARPHRDType)
 
sll_headergetSllHeader () const
 
bool setLinkLayerAddr (uint8_t *addr, size_t addrLength)
 
bool setMacAddressAsLinkLayer (MacAddress macAddr)
 
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
 

Detailed Description

Represents an SLL (Linux cooked capture) protocol layer

Constructor & Destructor Documentation

◆ SllLayer() [1/2]

pcpp::SllLayer::SllLayer ( 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

◆ SllLayer() [2/2]

pcpp::SllLayer::SllLayer ( uint16_t  packetType,
uint16_t  ARPHRDType 
)

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

Parameters
[in]packetTypeThe packet type
[in]ARPHRDTypeThe ARPHRD type

Member Function Documentation

◆ computeCalculateFields()

void pcpp::SllLayer::computeCalculateFields ( )
virtual

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

Implements pcpp::Layer.

◆ getHeaderLen()

size_t pcpp::SllLayer::getHeaderLen ( ) const
inlinevirtual
Returns
Size of sll_header

Implements pcpp::Layer.

◆ getOsiModelLayer()

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

Implements pcpp::Layer.

◆ getSllHeader()

sll_header* pcpp::SllLayer::getSllHeader ( ) 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 sll_header

◆ parseNextLayer()

void pcpp::SllLayer::parseNextLayer ( )
virtual

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

Implements pcpp::Layer.

◆ setLinkLayerAddr()

bool pcpp::SllLayer::setLinkLayerAddr ( 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 SLL address)
Returns
True if address was set successfully, or false of addrLength is out of bounds (0 or larger than 8)

◆ setMacAddressAsLinkLayer()

bool pcpp::SllLayer::setMacAddressAsLinkLayer ( 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

◆ toString()

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

Implements pcpp::Layer.