PcapPlusPlus  22.11
pcpp::ArpLayer Class Reference

#include <ArpLayer.h>

Inheritance diagram for pcpp::ArpLayer:
pcpp::Layer pcpp::IDataContainer

Public Member Functions

 ArpLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 ArpLayer (ArpOpcode opCode, const MacAddress &senderMacAddr, const MacAddress &targetMacAddr, const IPv4Address &senderIpAddr, const IPv4Address &targetIpAddr)
 
arphdrgetArpHeader () const
 
MacAddress getSenderMacAddress () const
 
MacAddress getTargetMacAddress () const
 
IPv4Address getSenderIpAddr () const
 
IPv4Address getTargetIpAddr () const
 
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 ARP protocol layer. Currently only IPv4 ARP messages are supported

Constructor & Destructor Documentation

◆ ArpLayer() [1/2]

pcpp::ArpLayer::ArpLayer ( 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 arphdr)
[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

◆ ArpLayer() [2/2]

pcpp::ArpLayer::ArpLayer ( ArpOpcode  opCode,
const MacAddress senderMacAddr,
const MacAddress targetMacAddr,
const IPv4Address senderIpAddr,
const IPv4Address targetIpAddr 
)

A constructor that allocates a new ARP header

Parameters
[in]opCodeARP message type (ARP request or ARP reply)
[in]senderMacAddrThe sender MAC address (will be put in arphdr::senderMacAddr)
[in]targetMacAddrThe target MAC address (will be put in arphdr::targetMacAddr)
[in]senderIpAddrThe sender IP address (will be put in arphdr::senderIpAddr)
[in]targetIpAddrThe target IP address (will be put in arphdr::targetIpAddr)

Member Function Documentation

◆ computeCalculateFields()

void pcpp::ArpLayer::computeCalculateFields ( )
virtual

Calculate the following fields:

Implements pcpp::Layer.

◆ getArpHeader()

arphdr* pcpp::ArpLayer::getArpHeader ( ) const
inline

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

Returns
A pointer to the arphdr

◆ getHeaderLen()

size_t pcpp::ArpLayer::getHeaderLen ( ) const
inlinevirtual
Returns
The size of arphdr

Implements pcpp::Layer.

◆ getOsiModelLayer()

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

Implements pcpp::Layer.

◆ getSenderIpAddr()

IPv4Address pcpp::ArpLayer::getSenderIpAddr ( ) const
inline

Get the sender protocol address (SPA) in the form of IPv4Address

Returns
An IPv4Address containing the sender protocol address (SPA)

◆ getSenderMacAddress()

MacAddress pcpp::ArpLayer::getSenderMacAddress ( ) const
inline

Get the sender hardware address (SHA) in the form of MacAddress

Returns
A MacAddress containing the sender hardware address (SHA)

◆ getTargetIpAddr()

IPv4Address pcpp::ArpLayer::getTargetIpAddr ( ) const
inline

Get the target protocol address (TPA) in the form of IPv4Address

Returns
An IPv4Address containing the target protocol address (TPA)

◆ getTargetMacAddress()

MacAddress pcpp::ArpLayer::getTargetMacAddress ( ) const
inline

Get the target hardware address (THA) in the form of MacAddress

Returns
A MacAddress containing the target hardware address (THA)

◆ parseNextLayer()

void pcpp::ArpLayer::parseNextLayer ( )
inlinevirtual

Does nothing for this layer (ArpLayer is always last)

Implements pcpp::Layer.

◆ toString()

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

Implements pcpp::Layer.