PcapPlusPlus
pcpp::ArpLayer Class Reference

#include <ArpLayer.h>

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

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 ()
 
MacAddress getSenderMacAddress ()
 
MacAddress getTargetMacAddress ()
 
IPv4Address getSenderIpAddr ()
 
IPv4Address getTargetIpAddr ()
 
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 ARP protocol layer. Currently only IPv4 ARP messages are supported

Constructor & Destructor Documentation

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

void pcpp::ArpLayer::computeCalculateFields ( )
virtual

Calculate the following fields:

Implements pcpp::Layer.

arphdr* pcpp::ArpLayer::getArpHeader ( )
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
size_t pcpp::ArpLayer::getHeaderLen ( )
inlinevirtual
Returns
The size of arphdr

Implements pcpp::Layer.

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

Implements pcpp::Layer.

IPv4Address pcpp::ArpLayer::getSenderIpAddr ( )
inline

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

Returns
An IPv4Address containing the sender protocol address (SPA)
MacAddress pcpp::ArpLayer::getSenderMacAddress ( )
inline

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

Returns
A MacAddress containing the sender hardware address (SHA)
IPv4Address pcpp::ArpLayer::getTargetIpAddr ( )
inline

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

Returns
An IPv4Address containing the target protocol address (TPA)
MacAddress pcpp::ArpLayer::getTargetMacAddress ( )
inline

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

Returns
A MacAddress containing the target hardware address (THA)
void pcpp::ArpLayer::parseNextLayer ( )
inlinevirtual

Does nothing for this layer (ArpLayer is always last)

Implements pcpp::Layer.

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

Implements pcpp::Layer.