diff --git a/src/internet-stack/arp-l3-protocol.cc b/src/internet-stack/arp-l3-protocol.cc index f98f9f2ad..da46e9c3b 100644 --- a/src/internet-stack/arp-l3-protocol.cc +++ b/src/internet-stack/arp-l3-protocol.cc @@ -186,7 +186,7 @@ ArpL3Protocol::Receive(Ptr device, Ptr p, uint16_t prot found = true; NS_LOG_LOGIC ("node="<GetId () <<", got request from " << arp.GetSourceIpv4Address () << " -- send reply"); - SendArpReply (cache, arp.GetSourceIpv4Address (), + SendArpReply (cache, arp.GetDestinationIpv4Address (), arp.GetSourceIpv4Address (), arp.GetSourceHardwareAddress ()); break; } @@ -338,26 +338,16 @@ ArpL3Protocol::SendArpRequest (Ptr cache, Ipv4Address to) } void -ArpL3Protocol::SendArpReply (Ptr cache, Ipv4Address toIp, Address toMac) +ArpL3Protocol::SendArpReply (Ptr cache, Ipv4Address myIp, Ipv4Address toIp, Address toMac) { NS_LOG_FUNCTION (this << cache << toIp << toMac); ArpHeader arp; - // need to pick a source address; use routing implementation to select - Ptr ipv4 = m_node->GetObject (); - int32_t interface = ipv4->GetInterfaceForDevice (cache->GetDevice ()); - NS_ASSERT (interface >= 0); - Ipv4Header header; - header.SetDestination (toIp); - Socket::SocketErrno errno_; - Ptr packet = Create (); - Ptr route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, interface, errno_); - NS_ASSERT (route != 0); NS_LOG_LOGIC ("ARP: sending reply from node "<GetId ()<< "|| src: " << cache->GetDevice ()->GetAddress () << - " / " << route->GetSource () << + " / " << myIp << " || dst: " << toMac << " / " << toIp); - arp.SetReply (cache->GetDevice ()->GetAddress (), - route->GetSource (), toMac, toIp); + arp.SetReply (cache->GetDevice ()->GetAddress (), myIp, toMac, toIp); + Ptr packet = Create (); packet->AddHeader (arp); cache->GetDevice ()->Send (packet, toMac, PROT_NUMBER); } diff --git a/src/internet-stack/arp-l3-protocol.h b/src/internet-stack/arp-l3-protocol.h index 7910d593a..1256e8c40 100644 --- a/src/internet-stack/arp-l3-protocol.h +++ b/src/internet-stack/arp-l3-protocol.h @@ -87,7 +87,7 @@ private: typedef std::list > CacheList; Ptr FindCache (Ptr device); void SendArpRequest (Ptrcache, Ipv4Address to); - void SendArpReply (Ptr cache, Ipv4Address toIp, Address toMac); + void SendArpReply (Ptr cache, Ipv4Address myIp, Ipv4Address toIp, Address toMac); CacheList m_cacheList; Ptr m_node; TracedCallback > m_dropTrace;