21 #include "ns3/assert.h"
22 #include "ns3/address-utils.h"
23 #include "arp-header.h"
30 NS_OBJECT_ENSURE_REGISTERED (ArpHeader);
33 ArpHeader::SetRequest (Address sourceHardwareAddress,
34 Ipv4Address sourceProtocolAddress,
35 Address destinationHardwareAddress,
36 Ipv4Address destinationProtocolAddress)
38 NS_LOG_FUNCTION (
this << sourceHardwareAddress << sourceProtocolAddress << destinationHardwareAddress << destinationProtocolAddress);
39 m_type = ARP_TYPE_REQUEST;
40 m_macSource = sourceHardwareAddress;
41 m_macDest = destinationHardwareAddress;
42 m_ipv4Source = sourceProtocolAddress;
43 m_ipv4Dest = destinationProtocolAddress;
46 ArpHeader::SetReply (Address sourceHardwareAddress,
47 Ipv4Address sourceProtocolAddress,
48 Address destinationHardwareAddress,
49 Ipv4Address destinationProtocolAddress)
51 NS_LOG_FUNCTION (
this << sourceHardwareAddress << sourceProtocolAddress << destinationHardwareAddress << destinationProtocolAddress);
52 m_type = ARP_TYPE_REPLY;
53 m_macSource = sourceHardwareAddress;
54 m_macDest = destinationHardwareAddress;
55 m_ipv4Source = sourceProtocolAddress;
56 m_ipv4Dest = destinationProtocolAddress;
59 ArpHeader::IsRequest (
void)
const
62 return (m_type == ARP_TYPE_REQUEST) ?
true :
false;
65 ArpHeader::IsReply (
void)
const
68 return (m_type == ARP_TYPE_REPLY) ?
true :
false;
71 ArpHeader::GetSourceHardwareAddress (
void)
77 ArpHeader::GetDestinationHardwareAddress (
void)
83 ArpHeader::GetSourceIpv4Address (
void)
89 ArpHeader::GetDestinationIpv4Address (
void)
97 ArpHeader::GetTypeId (
void)
99 static TypeId tid = TypeId (
"ns3::ArpHeader")
100 .SetParent<Header> ()
101 .AddConstructor<ArpHeader> ()
118 <<
"source mac: " << m_macSource <<
" "
119 <<
"source ipv4: " << m_ipv4Source <<
" "
120 <<
"dest ipv4: " << m_ipv4Dest
127 <<
"source mac: " << m_macSource <<
" "
128 <<
"source ipv4: " << m_ipv4Source <<
" "
129 <<
"dest mac: " << m_macDest <<
" "
130 <<
"dest ipv4: " <<m_ipv4Dest
141 uint32_t length = 16;
161 WriteTo (i, m_macSource);
162 WriteTo (i, m_ipv4Source);
163 WriteTo (i, m_macDest);
164 WriteTo (i, m_ipv4Dest);
174 uint32_t hardwareAddressLen = i.
ReadU8 ();
175 uint32_t protocolAddressLen = i.
ReadU8 ();
183 if (protocolType != 0x800 || protocolAddressLen != 4)
189 ReadFrom (i, m_macSource, hardwareAddressLen);
190 ReadFrom (i, m_ipv4Source);
191 ReadFrom (i, m_macDest, hardwareAddressLen);
192 ReadFrom (i, m_ipv4Dest);
#define NS_LOG_FUNCTION(parameters)
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
iterator in a Buffer instance
void WriteHtonU16(uint16_t data)
uint8_t GetLength(void) const
void WriteU8(uint8_t data)
uint16_t ReadNtohU16(void)