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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19
20#ifndef ARP_HEADER_H
21#define ARP_HEADER_H
22
23#include "ns3/address.h"
24#include "ns3/header.h"
25#include "ns3/ipv4-address.h"
26
27#include <string>
28
29namespace ns3
30{
31/**
32 * \ingroup arp
33 * \brief The packet header for an ARP packet
34 */
35class ArpHeader : public Header
36{
37 public:
38 /**
39 * \brief Set the ARP request parameters
40 * \param sourceHardwareAddress the source hardware address
41 * \param sourceProtocolAddress the source IP address
42 * \param destinationHardwareAddress the destination hardware address (usually the
43 * broadcast address)
44 * \param destinationProtocolAddress the destination IP address
45 */
46 void SetRequest(Address sourceHardwareAddress,
47 Ipv4Address sourceProtocolAddress,
48 Address destinationHardwareAddress,
49 Ipv4Address destinationProtocolAddress);
50 /**
51 * \brief Set the ARP reply parameters
52 * \param sourceHardwareAddress the source hardware address
53 * \param sourceProtocolAddress the source IP address
54 * \param destinationHardwareAddress the destination hardware address (usually the
55 * broadcast address)
56 * \param destinationProtocolAddress the destination IP address
57 */
58 void SetReply(Address sourceHardwareAddress,
59 Ipv4Address sourceProtocolAddress,
60 Address destinationHardwareAddress,
61 Ipv4Address destinationProtocolAddress);
62
63 /**
64 * \brief Check if the ARP is a request
65 * \returns true if it is a request
66 */
67 bool IsRequest() const;
68
69 /**
70 * \brief Check if the ARP is a reply
71 * \returns true if it is a reply
72 */
73 bool IsReply() const;
74
75 /**
76 * \brief Returns the source hardware address
77 * \returns the source hardware address
78 */
80
81 /**
82 * \brief Returns the destination hardware address
83 * \returns the destination hardware address
84 */
86
87 /**
88 * \brief Returns the source IP address
89 * \returns the source IP address
90 */
92
93 /**
94 * \brief Returns the destination IP address
95 * \returns the destination IP address
96 */
98
99 /**
100 * \brief Get the type ID.
101 * \return the object TypeId
102 */
103 static TypeId GetTypeId();
104 TypeId GetInstanceTypeId() const override;
105 void Print(std::ostream& os) const override;
106 uint32_t GetSerializedSize() const override;
107 void Serialize(Buffer::Iterator start) const override;
108 uint32_t Deserialize(Buffer::Iterator start) override;
109
110 /**
111 * \brief Enumeration listing the possible ARP types
112 */
114 {
117 };
118
119 uint16_t m_type; //!< type of the ICMP (ARP_TYPE_REQUEST)
120 Address m_macSource; //!< hardware source address
121 Address m_macDest; //!< hardware destination address
122 Ipv4Address m_ipv4Source; //!< IP source address
123 Ipv4Address m_ipv4Dest; //!< IP destination address
124};
125
126} // namespace ns3
127
128#endif /* ARP_HEADER_H */
a polymophic address class
Definition: address.h:101
The packet header for an ARP packet.
Definition: arp-header.h:36
uint32_t Deserialize(Buffer::Iterator start) override
Definition: arp-header.cc:179
Address m_macSource
hardware source address
Definition: arp-header.h:120
void Print(std::ostream &os) const override
Definition: arp-header.cc:123
void SetReply(Address sourceHardwareAddress, Ipv4Address sourceProtocolAddress, Address destinationHardwareAddress, Ipv4Address destinationProtocolAddress)
Set the ARP reply parameters.
Definition: arp-header.cc:49
bool IsReply() const
Check if the ARP is a reply.
Definition: arp-header.cc:71
bool IsRequest() const
Check if the ARP is a request.
Definition: arp-header.cc:64
Address GetDestinationHardwareAddress() const
Returns the destination hardware address.
Definition: arp-header.cc:85
uint16_t m_type
type of the ICMP (ARP_TYPE_REQUEST)
Definition: arp-header.h:119
ArpType_e
Enumeration listing the possible ARP types.
Definition: arp-header.h:114
Ipv4Address GetDestinationIpv4Address() const
Returns the destination IP address.
Definition: arp-header.cc:99
void SetRequest(Address sourceHardwareAddress, Ipv4Address sourceProtocolAddress, Address destinationHardwareAddress, Ipv4Address destinationProtocolAddress)
Set the ARP request parameters.
Definition: arp-header.cc:34
Address m_macDest
hardware destination address
Definition: arp-header.h:121
void Serialize(Buffer::Iterator start) const override
Definition: arp-header.cc:159
Ipv4Address m_ipv4Dest
IP destination address.
Definition: arp-header.h:123
Ipv4Address GetSourceIpv4Address() const
Returns the source IP address.
Definition: arp-header.cc:92
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: arp-header.cc:116
static TypeId GetTypeId()
Get the type ID.
Definition: arp-header.cc:106
Ipv4Address m_ipv4Source
IP source address.
Definition: arp-header.h:122
uint32_t GetSerializedSize() const override
Definition: arp-header.cc:145
Address GetSourceHardwareAddress() const
Returns the source hardware address.
Definition: arp-header.cc:78
iterator in a Buffer instance
Definition: buffer.h:100
Protocol header serialization and deserialization.
Definition: header.h:44
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.