PcapPlusPlus
pcpp::SllLayer Class Reference

#include <SllLayer.h>

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

Public Member Functions

 SllLayer (uint8_t *data, size_t dataLen, Packet *packet)
 
 SllLayer (uint16_t packetType, uint16_t ARPHRDType)
 
sll_headergetSllHeader ()
 
bool setLinkLayerAddr (uint8_t *addr, size_t addrLength)
 
bool setMacAddressAsLinkLayer (MacAddress macAddr)
 
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 an SLL (Linux cooked capture) protocol layer

Constructor & Destructor Documentation

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
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

void pcpp::SllLayer::computeCalculateFields ( )
virtual

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

Implements pcpp::Layer.

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

Implements pcpp::Layer.

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

Implements pcpp::Layer.

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

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

Implements pcpp::Layer.

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)
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
std::string pcpp::SllLayer::toString ( )
virtual
Returns
A string representation of the layer most important data (should look like the layer description in Wireshark)

Implements pcpp::Layer.