View | Details | Raw Unified | Return to bug 606
Collapse All | Expand All

(-)a/src/internet-stack/arp-l3-protocol.cc (-15 / +5 lines)
 Lines 186-192    Link Here 
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
        } 
 Lines 338-363    Link Here 
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
}
(-)a/src/internet-stack/arp-l3-protocol.h (-1 / +1 lines)
 Lines 87-93    Link Here 
87
  typedef std::list<Ptr<ArpCache> > CacheList;
87
  typedef std::list<Ptr<ArpCache> > CacheList;
88
  Ptr<ArpCache> FindCache (Ptr<NetDevice> device);
88
  Ptr<ArpCache> FindCache (Ptr<NetDevice> device);
89
  void SendArpRequest (Ptr<const ArpCache>cache, Ipv4Address to);
89
  void SendArpRequest (Ptr<const ArpCache>cache, Ipv4Address to);
90
  void SendArpReply (Ptr<const ArpCache> cache, Ipv4Address toIp, Address toMac);
90
  void SendArpReply (Ptr<const ArpCache> cache, Ipv4Address myIp, Ipv4Address toIp, Address toMac);
91
  CacheList m_cacheList;
91
  CacheList m_cacheList;
92
  Ptr<Node> m_node;
92
  Ptr<Node> m_node;
93
  TracedCallback<Ptr<const Packet> > m_dropTrace;
93
  TracedCallback<Ptr<const Packet> > m_dropTrace;

Return to bug 606