src/internet-stack/arp-l3-protocol.cc
changeset 4696 5ef92ccda11a
parent 4669 8aaa5e83939e
child 4764 e90e1ef585b0
child 5671 b1fce73037f8
     1.1 --- a/src/internet-stack/arp-l3-protocol.cc	Tue Jul 07 21:18:01 2009 +0200
     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  }