A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
arp-header.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8
9#ifndef ARP_HEADER_H
10#define ARP_HEADER_H
11
12#include "ns3/address.h"
13#include "ns3/header.h"
14#include "ns3/ipv4-address.h"
15
16#include <string>
17
18namespace ns3
19{
20/**
21 * \ingroup arp
22 * \brief The packet header for an ARP packet
23 */
24class ArpHeader : public Header
25{
26 public:
27 /**
28 * \brief Set the ARP request parameters
29 * \param sourceHardwareAddress the source hardware address
30 * \param sourceProtocolAddress the source IP address
31 * \param destinationHardwareAddress the destination hardware address (usually the
32 * broadcast address)
33 * \param destinationProtocolAddress the destination IP address
34 */
35 void SetRequest(Address sourceHardwareAddress,
36 Ipv4Address sourceProtocolAddress,
37 Address destinationHardwareAddress,
38 Ipv4Address destinationProtocolAddress);
39 /**
40 * \brief Set the ARP reply parameters
41 * \param sourceHardwareAddress the source hardware address
42 * \param sourceProtocolAddress the source IP address
43 * \param destinationHardwareAddress the destination hardware address (usually the
44 * broadcast address)
45 * \param destinationProtocolAddress the destination IP address
46 */
47 void SetReply(Address sourceHardwareAddress,
48 Ipv4Address sourceProtocolAddress,
49 Address destinationHardwareAddress,
50 Ipv4Address destinationProtocolAddress);
51
52 /**
53 * \brief Check if the ARP is a request
54 * \returns true if it is a request
55 */
56 bool IsRequest() const;
57
58 /**
59 * \brief Check if the ARP is a reply
60 * \returns true if it is a reply
61 */
62 bool IsReply() const;
63
64 /**
65 * \brief Returns the source hardware address
66 * \returns the source hardware address
67 */
69
70 /**
71 * \brief Returns the destination hardware address
72 * \returns the destination hardware address
73 */
75
76 /**
77 * \brief Returns the source IP address
78 * \returns the source IP address
79 */
81
82 /**
83 * \brief Returns the destination IP address
84 * \returns the destination IP address
85 */
87
88 /**
89 * \brief Get the type ID.
90 * \return the object TypeId
91 */
92 static TypeId GetTypeId();
93 TypeId GetInstanceTypeId() const override;
94 void Print(std::ostream& os) const override;
95 uint32_t GetSerializedSize() const override;
96 void Serialize(Buffer::Iterator start) const override;
98
99 /**
100 * \brief Enumeration listing the possible ARP types
101 */
107
108 uint16_t m_type; //!< type of the ICMP (ARP_TYPE_REQUEST)
109 Address m_macSource; //!< hardware source address
110 Address m_macDest; //!< hardware destination address
111 Ipv4Address m_ipv4Source; //!< IP source address
112 Ipv4Address m_ipv4Dest; //!< IP destination address
113};
114
115} // namespace ns3
116
117#endif /* ARP_HEADER_H */
a polymophic address class
Definition address.h:90
The packet header for an ARP packet.
Definition arp-header.h:25
uint32_t Deserialize(Buffer::Iterator start) override
Address m_macSource
hardware source address
Definition arp-header.h:109
void Print(std::ostream &os) const override
void SetReply(Address sourceHardwareAddress, Ipv4Address sourceProtocolAddress, Address destinationHardwareAddress, Ipv4Address destinationProtocolAddress)
Set the ARP reply parameters.
Definition arp-header.cc:38
bool IsReply() const
Check if the ARP is a reply.
Definition arp-header.cc:60
bool IsRequest() const
Check if the ARP is a request.
Definition arp-header.cc:53
Address GetDestinationHardwareAddress() const
Returns the destination hardware address.
Definition arp-header.cc:74
uint16_t m_type
type of the ICMP (ARP_TYPE_REQUEST)
Definition arp-header.h:108
ArpType_e
Enumeration listing the possible ARP types.
Definition arp-header.h:103
Ipv4Address GetDestinationIpv4Address() const
Returns the destination IP address.
Definition arp-header.cc:88
void SetRequest(Address sourceHardwareAddress, Ipv4Address sourceProtocolAddress, Address destinationHardwareAddress, Ipv4Address destinationProtocolAddress)
Set the ARP request parameters.
Definition arp-header.cc:23
Address m_macDest
hardware destination address
Definition arp-header.h:110
void Serialize(Buffer::Iterator start) const override
Ipv4Address m_ipv4Dest
IP destination address.
Definition arp-header.h:112
Ipv4Address GetSourceIpv4Address() const
Returns the source IP address.
Definition arp-header.cc:81
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
static TypeId GetTypeId()
Get the type ID.
Definition arp-header.cc:95
Ipv4Address m_ipv4Source
IP source address.
Definition arp-header.h:111
uint32_t GetSerializedSize() const override
Address GetSourceHardwareAddress() const
Returns the source hardware address.
Definition arp-header.cc:67
iterator in a Buffer instance
Definition buffer.h:89
Protocol header serialization and deserialization.
Definition header.h:33
Ipv4 addresses are stored in host order in this class.
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.