Route lookup removed in ARP request (see bug 606)
authorPavel Boyko <boyko@iitp.ru>
Thu Aug 06 10:23:12 2009 +0400 (2009-08-06)
changeset 46965ef92ccda11a
parent 4695 637b9cacd0b5
child 4697 6e048d6486d8
Route lookup removed in ARP request (see bug 606)
src/internet-stack/arp-l3-protocol.cc
src/internet-stack/arp-l3-protocol.h
     1.1 --- a/src/internet-stack/arp-l3-protocol.cc	Mon Jul 27 23:04:19 2009 -0700
     1.2 +++ b/src/internet-stack/arp-l3-protocol.cc	Thu Aug 06 10:23:12 2009 +0400
     1.3 @@ -186,7 +186,7 @@
     1.4            found = true;
     1.5            NS_LOG_LOGIC ("node="<<m_node->GetId () <<", got request from " << 
     1.6                  arp.GetSourceIpv4Address () << " -- send reply");
     1.7 -          SendArpReply (cache, arp.GetSourceIpv4Address (),
     1.8 +          SendArpReply (cache, arp.GetDestinationIpv4Address (), arp.GetSourceIpv4Address (),
     1.9                      arp.GetSourceHardwareAddress ());
    1.10            break;
    1.11          } 
    1.12 @@ -338,26 +338,16 @@
    1.13  }
    1.14  
    1.15  void
    1.16 -ArpL3Protocol::SendArpReply (Ptr<const ArpCache> cache, Ipv4Address toIp, Address toMac)
    1.17 +ArpL3Protocol::SendArpReply (Ptr<const ArpCache> cache, Ipv4Address myIp, Ipv4Address toIp, Address toMac)
    1.18  {
    1.19    NS_LOG_FUNCTION (this << cache << toIp << toMac);
    1.20    ArpHeader arp;
    1.21 -  // need to pick a source address; use routing implementation to select
    1.22 -  Ptr<Ipv4L3Protocol> ipv4 = m_node->GetObject<Ipv4L3Protocol> ();
    1.23 -  int32_t interface = ipv4->GetInterfaceForDevice (cache->GetDevice ());
    1.24 -  NS_ASSERT (interface >= 0);
    1.25 -  Ipv4Header header;
    1.26 -  header.SetDestination (toIp);
    1.27 -  Socket::SocketErrno errno_;
    1.28 -  Ptr<Packet> packet = Create<Packet> ();
    1.29 -  Ptr<Ipv4Route> route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, interface, errno_);
    1.30 -  NS_ASSERT (route != 0);
    1.31    NS_LOG_LOGIC ("ARP: sending reply from node "<<m_node->GetId ()<<
    1.32              "|| src: " << cache->GetDevice ()->GetAddress () << 
    1.33 -            " / " << route->GetSource () <<
    1.34 +            " / " << myIp <<
    1.35              " || dst: " << toMac << " / " << toIp);
    1.36 -  arp.SetReply (cache->GetDevice ()->GetAddress (),
    1.37 -                route->GetSource (), toMac, toIp);
    1.38 +  arp.SetReply (cache->GetDevice ()->GetAddress (), myIp, toMac, toIp);
    1.39 +  Ptr<Packet> packet = Create<Packet> ();
    1.40    packet->AddHeader (arp);
    1.41    cache->GetDevice ()->Send (packet, toMac, PROT_NUMBER);
    1.42  }
     2.1 --- a/src/internet-stack/arp-l3-protocol.h	Mon Jul 27 23:04:19 2009 -0700
     2.2 +++ b/src/internet-stack/arp-l3-protocol.h	Thu Aug 06 10:23:12 2009 +0400
     2.3 @@ -87,7 +87,7 @@
     2.4    typedef std::list<Ptr<ArpCache> > CacheList;
     2.5    Ptr<ArpCache> FindCache (Ptr<NetDevice> device);
     2.6    void SendArpRequest (Ptr<const ArpCache>cache, Ipv4Address to);
     2.7 -  void SendArpReply (Ptr<const ArpCache> cache, Ipv4Address toIp, Address toMac);
     2.8 +  void SendArpReply (Ptr<const ArpCache> cache, Ipv4Address myIp, Ipv4Address toIp, Address toMac);
     2.9    CacheList m_cacheList;
    2.10    Ptr<Node> m_node;
    2.11    TracedCallback<Ptr<const Packet> > m_dropTrace;