PcapPlusPlus  24.09
pcpp::WakeOnLanLayer Class Reference

#include <WakeOnLanLayer.h>

Inheritance diagram for pcpp::WakeOnLanLayer:
pcpp::Layer pcpp::IDataContainer

Classes

struct  wol_header
 

Public Member Functions

 WakeOnLanLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 WakeOnLanLayer (const pcpp::MacAddress &targetAddr)
 
 WakeOnLanLayer (const pcpp::MacAddress &targetAddr, uint8_t *password, uint8_t len)
 
 WakeOnLanLayer (const pcpp::MacAddress &targetAddr, const pcpp::MacAddress &password)
 
 WakeOnLanLayer (const pcpp::MacAddress &targetAddr, const IPv4Address &password)
 
wol_headergetWakeOnLanHeader () const
 
pcpp::MacAddress getTargetAddr () const
 
void setTargetAddr (const pcpp::MacAddress &targetAddr)
 
std::string getPassword () const
 
bool setPassword (const uint8_t *password, uint8_t len)
 
bool setPassword (const std::string &password)
 
bool setPassword (const MacAddress &addr)
 
bool setPassword (const IPv4Address &addr)
 
void parseNextLayer ()
 Parses the next layer. Wake on LAN is the always last so does nothing for this layer.
 
size_t getHeaderLen () const
 
void computeCalculateFields ()
 Does nothing for this layer.
 
OsiModelLayer getOsiModelLayer () const
 
std::string toString () const
 
- Public Member Functions inherited from pcpp::Layer
virtual ~Layer ()
 
LayergetNextLayer () const
 
LayergetPrevLayer () const
 
ProtocolType getProtocol () const
 
bool isMemberOfProtocolFamily (ProtocolTypeFamily protocolTypeFamily) 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 isWakeOnLanPort (uint16_t port)
 
static bool isDataValid (const uint8_t *data, size_t dataSize)
 

Detailed Description

Class for representing the Wake on LAN Layer

Constructor & Destructor Documentation

◆ WakeOnLanLayer() [1/5]

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

◆ WakeOnLanLayer() [2/5]

pcpp::WakeOnLanLayer::WakeOnLanLayer ( const pcpp::MacAddress targetAddr)
explicit

Construct a new Wake On Lan Layer with provided values

Parameters
[in]targetAddrTarget MAC address

◆ WakeOnLanLayer() [3/5]

pcpp::WakeOnLanLayer::WakeOnLanLayer ( const pcpp::MacAddress targetAddr,
uint8_t *  password,
uint8_t  len 
)

Construct a new Wake On Lan Layer with provided values

Parameters
[in]targetAddrTarget MAC address
[in]passwordPassword as array
[in]lenLength of the password array, length of the password should be less than 6 bytes

◆ WakeOnLanLayer() [4/5]

pcpp::WakeOnLanLayer::WakeOnLanLayer ( const pcpp::MacAddress targetAddr,
const pcpp::MacAddress password 
)

Construct a new Wake On Lan Layer with provided values

Parameters
[in]targetAddrTarget MAC address
[in]passwordPassword as MAC address

◆ WakeOnLanLayer() [5/5]

pcpp::WakeOnLanLayer::WakeOnLanLayer ( const pcpp::MacAddress targetAddr,
const IPv4Address password 
)

Construct a new Wake On Lan Layer with provided values

Parameters
[in]targetAddrTarget MAC address
[in]passwordPassword as IPv4 address

Member Function Documentation

◆ getHeaderLen()

size_t pcpp::WakeOnLanLayer::getHeaderLen ( ) const
inlinevirtual
Returns
Get the size of the layer

Implements pcpp::Layer.

◆ getOsiModelLayer()

OsiModelLayer pcpp::WakeOnLanLayer::getOsiModelLayer ( ) const
inlinevirtual
Returns
The OSI layer level of Wake on LAN (Data Link Layer)

Implements pcpp::Layer.

◆ getPassword()

std::string pcpp::WakeOnLanLayer::getPassword ( ) const

Get the password of the command

Returns
Returns the password if exists, empty string otherwise

◆ getTargetAddr()

pcpp::MacAddress pcpp::WakeOnLanLayer::getTargetAddr ( ) const

Get the target MAC address of the command

Returns
MAC address of the target

◆ getWakeOnLanHeader()

wol_header* pcpp::WakeOnLanLayer::getWakeOnLanHeader ( ) const
inline

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

Returns
A pointer to the wol_header

◆ isDataValid()

static bool pcpp::WakeOnLanLayer::isDataValid ( const uint8_t *  data,
size_t  dataSize 
)
static

A static method that takes a byte array and detects whether it is a Wake on LAN message

Parameters
[in]dataA byte array
[in]dataSizeThe byte array size (in bytes)
Returns
True if the data is identified as Wake on LAN message

◆ isWakeOnLanPort()

static bool pcpp::WakeOnLanLayer::isWakeOnLanPort ( uint16_t  port)
inlinestatic

A static method that checks whether the port is considered as Wake on LAN

Parameters
[in]portThe port number to be checked

◆ setPassword() [1/4]

bool pcpp::WakeOnLanLayer::setPassword ( const IPv4Address addr)

Set the password of the command

Parameters
addrPassword as IPv4 address
Returns
True if operation successful, false otherwise

◆ setPassword() [2/4]

bool pcpp::WakeOnLanLayer::setPassword ( const MacAddress addr)

Set the password of the command

Parameters
[in]addrPassword as MAC address
Returns
True if operation successful, false otherwise

◆ setPassword() [3/4]

bool pcpp::WakeOnLanLayer::setPassword ( const std::string &  password)

Set the password of the command

Parameters
[in]passwordPassword as string. Length of the password should be less than 6 bytes
Returns
True if operation successful, false otherwise

◆ setPassword() [4/4]

bool pcpp::WakeOnLanLayer::setPassword ( const uint8_t *  password,
uint8_t  len 
)

Set the password of the command

Parameters
[in]passwordPassword as array
[in]lenLength of the password array, length of the password should be less than 6 bytes
Returns
True if operation successful, false otherwise

◆ setTargetAddr()

void pcpp::WakeOnLanLayer::setTargetAddr ( const pcpp::MacAddress targetAddr)

Set the target MAC address

Parameters
[in]targetAddrMAC address of the target

◆ toString()

std::string pcpp::WakeOnLanLayer::toString ( ) const
virtual
Returns
Returns the protocol info as readable string

Implements pcpp::Layer.