|
186 |
found = true; |
186 |
found = true; |
187 |
NS_LOG_LOGIC ("node="<<m_node->GetId () <<", got request from " << |
187 |
NS_LOG_LOGIC ("node="<<m_node->GetId () <<", got request from " << |
188 |
arp.GetSourceIpv4Address () << " -- send reply"); |
188 |
arp.GetSourceIpv4Address () << " -- send reply"); |
189 |
SendArpReply (cache, arp.GetSourceIpv4Address (), |
189 |
SendArpReply (cache, arp.GetDestinationIpv4Address (), arp.GetSourceIpv4Address (), |
190 |
arp.GetSourceHardwareAddress ()); |
190 |
arp.GetSourceHardwareAddress ()); |
191 |
break; |
191 |
break; |
192 |
} |
192 |
} |
|
338 |
} |
338 |
} |
339 |
|
339 |
|
340 |
void |
340 |
void |
341 |
ArpL3Protocol::SendArpReply (Ptr<const ArpCache> cache, Ipv4Address toIp, Address toMac) |
341 |
ArpL3Protocol::SendArpReply (Ptr<const ArpCache> cache, Ipv4Address myIp, Ipv4Address toIp, Address toMac) |
342 |
{ |
342 |
{ |
343 |
NS_LOG_FUNCTION (this << cache << toIp << toMac); |
343 |
NS_LOG_FUNCTION (this << cache << toIp << toMac); |
344 |
ArpHeader arp; |
344 |
ArpHeader arp; |
345 |
// need to pick a source address; use routing implementation to select |
|
|
346 |
Ptr<Ipv4L3Protocol> ipv4 = m_node->GetObject<Ipv4L3Protocol> (); |
347 |
int32_t interface = ipv4->GetInterfaceForDevice (cache->GetDevice ()); |
348 |
NS_ASSERT (interface >= 0); |
349 |
Ipv4Header header; |
350 |
header.SetDestination (toIp); |
351 |
Socket::SocketErrno errno_; |
352 |
Ptr<Packet> packet = Create<Packet> (); |
353 |
Ptr<Ipv4Route> route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, interface, errno_); |
354 |
NS_ASSERT (route != 0); |
355 |
NS_LOG_LOGIC ("ARP: sending reply from node "<<m_node->GetId ()<< |
345 |
NS_LOG_LOGIC ("ARP: sending reply from node "<<m_node->GetId ()<< |
356 |
"|| src: " << cache->GetDevice ()->GetAddress () << |
346 |
"|| src: " << cache->GetDevice ()->GetAddress () << |
357 |
" / " << route->GetSource () << |
347 |
" / " << myIp << |
358 |
" || dst: " << toMac << " / " << toIp); |
348 |
" || dst: " << toMac << " / " << toIp); |
359 |
arp.SetReply (cache->GetDevice ()->GetAddress (), |
349 |
arp.SetReply (cache->GetDevice ()->GetAddress (), myIp, toMac, toIp); |
360 |
route->GetSource (), toMac, toIp); |
350 |
Ptr<Packet> packet = Create<Packet> (); |
361 |
packet->AddHeader (arp); |
351 |
packet->AddHeader (arp); |
362 |
cache->GetDevice ()->Send (packet, toMac, PROT_NUMBER); |
352 |
cache->GetDevice ()->Send (packet, toMac, PROT_NUMBER); |
363 |
} |
353 |
} |