41 static_assert(
sizeof(
arphdr) == 28,
"arphdr size is not 28 bytes");
75 : senderMacAddr(senderMacAddress), senderIpAddr(senderIPAddress), targetIpAddr(targetIPAddress) {};
97 : senderMacAddr(senderMacAddress), senderIpAddr(senderIPAddress), targetMacAddr(targetMacAddress),
98 targetIpAddr(targetIPAddress) {};
120 : senderMacAddr(senderMacAddress), senderIpAddr(senderIPAddress) {};
138 : senderMacAddr(senderMacAddress), senderIpAddr(senderIPAddress) {};
152 :
Layer(data, dataLen, prevLayer, packet,
ARP)
154 m_DataLen =
sizeof(
arphdr);
176 PCPP_DEPRECATED(
"This constructor has been deprecated. Please use one of the other overloads.")
203 return reinterpret_cast<arphdr*
>(m_Data);
281 return canReinterpretAs<arphdr>(data, dataLen);
290 static std::vector<FieldDescriptor>
all()
297 std::copy(extra.begin(), extra.end(), std::back_inserter(result));
Definition: ArpLayer.h:144
ArpOpcode getOpcode() const
void serializeLayer(ObjectScope &serializer) const override
ArpMessageType getMessageType() const
Attempts to determine the ARP message type based on the header signature.
arphdr * getArpHeader() const
Definition: ArpLayer.h:201
IPv4Address getTargetIpAddr() const
Definition: ArpLayer.h:234
void parseNextLayer() override
Does nothing for this layer (ArpLayer is always last)
Definition: ArpLayer.h:242
bool isReply() const
Is this packet an ARP reply?
size_t getHeaderLen() const override
Definition: ArpLayer.h:246
MacAddress getTargetMacAddress() const
Definition: ArpLayer.h:220
void computeCalculateFields() override
bool isRequest() const
Is this packet an ARP request?
ArpLayer(ArpOpcode opCode, const MacAddress &senderMacAddr, const IPv4Address &senderIpAddr, const MacAddress &targetMacAddr, const IPv4Address &targetIpAddr)
A constructor that creates an ARP header.
IPv4Address getSenderIpAddr() const
Definition: ArpLayer.h:227
std::string toString() const override
ArpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: ArpLayer.h:151
OsiModelLayer getOsiModelLayer() const override
Definition: ArpLayer.h:270
static bool isDataValid(const uint8_t *data, size_t dataLen)
Definition: ArpLayer.h:279
MacAddress getSenderMacAddress() const
Definition: ArpLayer.h:213
Definition: IpAddress.h:30
Definition: MacAddress.h:24
Definition: Serializers.h:230
const ProtocolType ARP
ARP protocol.
Definition: ProtocolType.h:75
The main namespace for the PcapPlusPlus lib.
Definition: AssertionUtils.h:19
ArpOpcode
An enum for ARP message type.
Definition: ArpLayer.h:45
@ ARP_REQUEST
ARP request.
Definition: ArpLayer.h:46
@ ARP_REPLY
ARP reply (response)
Definition: ArpLayer.h:47
OsiModelLayer
An enum representing OSI model layers.
Definition: ProtocolType.h:420
@ PCPP_DEPRECATED
Deprecated typo, use OsiModelSessionLayer instead.
Definition: ProtocolType.h:432
@ OsiModelNetworkLayer
Network layer (layer 3)
Definition: ProtocolType.h:426
ArpMessageType
An enum representing the ARP message type.
Definition: ArpLayer.h:52
@ GratuitousRequest
Gratuitous ARP request.
@ GratuitousReply
Gratuitous ARP reply.
@ Unknown
Unknown ARP message type.
Definition: ArpLayer.h:288
static const FieldDescriptor TargetMacAddress
Field descriptor for the target hardware (MAC) address, written as a string.
Definition: ArpLayer.h:308
static std::vector< FieldDescriptor > all()
Definition: ArpLayer.h:290
static const FieldDescriptor MessageType
Field descriptor for the ARP message type, written as a string.
Definition: ArpLayer.h:317
static const FieldDescriptor HardwareType
Field descriptor for the hardware type (e.g. 1 for Ethernet), written as a number in host byte order.
Definition: ArpLayer.h:321
static const FieldDescriptor TargetIpAddress
Field descriptor for the target protocol (IP) address, written as a string.
Definition: ArpLayer.h:314
static const FieldDescriptor ProtocolSize
Field descriptor for the protocol address length in bytes (e.g. 4 for IPv4).
Definition: ArpLayer.h:331
static const FieldDescriptor OpCode
Field descriptor for the ARP opcode, written as a string.
Definition: ArpLayer.h:302
static const FieldDescriptor SenderMacAddress
Field descriptor for the sender hardware (MAC) address, written as a string.
Definition: ArpLayer.h:305
static const FieldDescriptor SenderIpAddress
Field descriptor for the sender protocol (IP) address, written as a string.
Definition: ArpLayer.h:311
static const FieldDescriptor HardwareSize
Field descriptor for the hardware address length in bytes (e.g. 6 for Ethernet).
Definition: ArpLayer.h:324
static const FieldDescriptor ProtocolType
Field descriptor for the protocol type, i.e. the EtherType of the protocol being resolved (e....
Definition: ArpLayer.h:328
A struct representing the build data for an ARP reply.
Definition: ArpLayer.h:83
ArpReply(MacAddress const &senderMacAddress, IPv4Address const &senderIPAddress, MacAddress const &targetMacAddress, IPv4Address const &targetIPAddress)
Construct a new Arp Reply object.
Definition: ArpLayer.h:95
A struct representing the build data for an ARP request.
Definition: ArpLayer.h:64
ArpRequest(MacAddress const &senderMacAddress, IPv4Address const &senderIPAddress, IPv4Address const &targetIPAddress)
Construct a new Arp Request object.
Definition: ArpLayer.h:73
Definition: Serializers.h:18
A struct representing the build data a gratuitous ARP reply.
Definition: ArpLayer.h:128
GratuitousArpReply(MacAddress const &senderMacAddress, IPv4Address const &senderIPAddress)
Construct a new Gratuitous Arp Reply object.
Definition: ArpLayer.h:137
A struct representing the build data for a gratuitous ARP request.
Definition: ArpLayer.h:110
GratuitousArpRequest(MacAddress const &senderMacAddress, IPv4Address const &senderIPAddress)
Construct a new Gratuitous Arp Request object.
Definition: ArpLayer.h:119
static std::vector< FieldDescriptor > all()
Definition: Layer.h:214
Definition: ArpLayer.h:18
uint32_t targetIpAddr
Target protocol address (TPA)
Definition: ArpLayer.h:38
uint8_t protocolSize
Definition: ArpLayer.h:27
uint16_t opcode
Definition: ArpLayer.h:30
uint16_t hardwareType
Hardware type (HTYPE)
Definition: ArpLayer.h:20
uint8_t targetMacAddr[6]
Target hardware address (THA)
Definition: ArpLayer.h:36
uint32_t senderIpAddr
Sender protocol address (SPA)
Definition: ArpLayer.h:34
uint8_t hardwareSize
Hardware address length (HLEN). For IPv4, this has the value 0x0800.
Definition: ArpLayer.h:24
uint8_t senderMacAddr[6]
Sender hardware address (SHA)
Definition: ArpLayer.h:32
uint16_t protocolType
Protocol type (PTYPE). The permitted PTYPE values share a numbering space with those for EtherType.
Definition: ArpLayer.h:22