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

(-)a/src/internet-stack/arp-l3-protocol.cc (-4 / +4 lines)
 Lines 318-324    Link Here 
318
  Ipv4Header header;
318
  Ipv4Header header;
319
  header.SetDestination (to);
319
  header.SetDestination (to);
320
  Socket::SocketErrno errno_;
320
  Socket::SocketErrno errno_;
321
  Ptr<Ipv4Route> route = ipv4->GetRoutingProtocol ()->RouteOutput (header, interface, errno_);
321
  Ptr<Packet> packet = Create<Packet> ();
322
  Ptr<Ipv4Route> route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, interface, errno_);
322
  NS_ASSERT (route != 0);
323
  NS_ASSERT (route != 0);
323
  NS_LOG_LOGIC ("ARP: sending request from node "<<m_node->GetId ()<<
324
  NS_LOG_LOGIC ("ARP: sending request from node "<<m_node->GetId ()<<
324
            " || src: " << cache->GetDevice ()->GetAddress () <<
325
            " || src: " << cache->GetDevice ()->GetAddress () <<
 Lines 329-335    Link Here 
329
		  route->GetSource (),
330
		  route->GetSource (),
330
                  cache->GetDevice ()->GetBroadcast (),
331
                  cache->GetDevice ()->GetBroadcast (),
331
                  to);
332
                  to);
332
  Ptr<Packet> packet = Create<Packet> ();
333
  packet->AddHeader (arp);
333
  packet->AddHeader (arp);
334
  cache->GetDevice ()->Send (packet, cache->GetDevice ()->GetBroadcast (), PROT_NUMBER);
334
  cache->GetDevice ()->Send (packet, cache->GetDevice ()->GetBroadcast (), PROT_NUMBER);
335
}
335
}
 Lines 346-352    Link Here 
346
  Ipv4Header header;
346
  Ipv4Header header;
347
  header.SetDestination (toIp);
347
  header.SetDestination (toIp);
348
  Socket::SocketErrno errno_;
348
  Socket::SocketErrno errno_;
349
  Ptr<Ipv4Route> route = ipv4->GetRoutingProtocol ()->RouteOutput (header, interface, errno_);
349
  Ptr<Packet> packet = Create<Packet> ();
350
  Ptr<Ipv4Route> route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, interface, errno_);
350
  NS_ASSERT (route != 0);
351
  NS_ASSERT (route != 0);
351
  NS_LOG_LOGIC ("ARP: sending reply from node "<<m_node->GetId ()<<
352
  NS_LOG_LOGIC ("ARP: sending reply from node "<<m_node->GetId ()<<
352
            "|| src: " << cache->GetDevice ()->GetAddress () << 
353
            "|| src: " << cache->GetDevice ()->GetAddress () << 
 Lines 354-360    Link Here 
354
            " || dst: " << toMac << " / " << toIp);
355
            " || dst: " << toMac << " / " << toIp);
355
  arp.SetReply (cache->GetDevice ()->GetAddress (),
356
  arp.SetReply (cache->GetDevice ()->GetAddress (),
356
                route->GetSource (), toMac, toIp);
357
                route->GetSource (), toMac, toIp);
357
  Ptr<Packet> packet = Create<Packet> ();
358
  packet->AddHeader (arp);
358
  packet->AddHeader (arp);
359
  cache->GetDevice ()->Send (packet, toMac, PROT_NUMBER);
359
  cache->GetDevice ()->Send (packet, toMac, PROT_NUMBER);
360
}
360
}
(-)a/src/internet-stack/icmpv4-l4-protocol.cc (-1 / +1 lines)
 Lines 84-90    Link Here 
84
  Socket::SocketErrno errno_;
84
  Socket::SocketErrno errno_;
85
  Ptr<Ipv4Route> route;
85
  Ptr<Ipv4Route> route;
86
  uint32_t oif = 0; //specify non-zero if bound to a source address
86
  uint32_t oif = 0; //specify non-zero if bound to a source address
87
  route = ipv4->GetRoutingProtocol ()->RouteOutput (header, oif, errno_);
87
  route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_);
88
  if (route != 0)
88
  if (route != 0)
89
    {
89
    {
90
      NS_LOG_LOGIC ("Route exists");
90
      NS_LOG_LOGIC ("Route exists");
(-)a/src/internet-stack/ipv4-l3-protocol.cc (-1 / +1 lines)
 Lines 532-538    Link Here 
532
  Socket::SocketErrno errno_; 
532
  Socket::SocketErrno errno_; 
533
  uint32_t oif = 0; // unused for now
533
  uint32_t oif = 0; // unused for now
534
  ipHeader = BuildHeader (source, destination, protocol, packet->GetSize (), ttl, mayFragment);
534
  ipHeader = BuildHeader (source, destination, protocol, packet->GetSize (), ttl, mayFragment);
535
  Ptr<Ipv4Route> newRoute = m_routingProtocol->RouteOutput (ipHeader, oif, errno_);
535
  Ptr<Ipv4Route> newRoute = m_routingProtocol->RouteOutput (packet, ipHeader, oif, errno_);
536
  if (newRoute)
536
  if (newRoute)
537
    {
537
    {
538
      SendRealOut (newRoute, packet, ipHeader);
538
      SendRealOut (newRoute, packet, ipHeader);
(-)a/src/internet-stack/ipv4-raw-socket-impl.cc (-1 / +1 lines)
 Lines 178-184    Link Here 
178
      Ptr<Ipv4Route> route;
178
      Ptr<Ipv4Route> route;
179
      uint32_t oif = 0; //specify non-zero if bound to a source address
179
      uint32_t oif = 0; //specify non-zero if bound to a source address
180
      // TBD-- we could cache the route and just check its validity
180
      // TBD-- we could cache the route and just check its validity
181
      route = ipv4->GetRoutingProtocol ()->RouteOutput (header, oif, errno_);
181
      route = ipv4->GetRoutingProtocol ()->RouteOutput (p, header, oif, errno_);
182
      if (route != 0)
182
      if (route != 0)
183
        {
183
        {
184
          NS_LOG_LOGIC ("Route exists");
184
          NS_LOG_LOGIC ("Route exists");
(-)a/src/internet-stack/tcp-l4-protocol.cc (-2 / +2 lines)
 Lines 547-553    Link Here 
547
      Socket::SocketErrno errno_;
547
      Socket::SocketErrno errno_;
548
      Ptr<Ipv4Route> route;
548
      Ptr<Ipv4Route> route;
549
      uint32_t oif = 0; //specify non-zero if bound to a source address
549
      uint32_t oif = 0; //specify non-zero if bound to a source address
550
      route = ipv4->GetRoutingProtocol ()->RouteOutput (header, oif, errno_);
550
      route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_);
551
      ipv4->Send (packet, saddr, daddr, PROT_NUMBER, route);
551
      ipv4->Send (packet, saddr, daddr, PROT_NUMBER, route);
552
    }
552
    }
553
}
553
}
 Lines 585-591    Link Here 
585
      Socket::SocketErrno errno_;
585
      Socket::SocketErrno errno_;
586
      Ptr<Ipv4Route> route;
586
      Ptr<Ipv4Route> route;
587
      uint32_t oif = 0; //specify non-zero if bound to a source address
587
      uint32_t oif = 0; //specify non-zero if bound to a source address
588
      route = ipv4->GetRoutingProtocol ()->RouteOutput (header, oif, errno_);
588
      route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_);
589
      ipv4->Send (packet, saddr, daddr, PROT_NUMBER, route);
589
      ipv4->Send (packet, saddr, daddr, PROT_NUMBER, route);
590
    }
590
    }
591
  else
591
  else
(-)a/src/internet-stack/tcp-socket-impl.cc (-2 / +3 lines)
 Lines 354-360    Link Here 
354
      Ptr<Ipv4Route> route;
354
      Ptr<Ipv4Route> route;
355
      uint32_t oif = 0; //specify non-zero if bound to a source address
355
      uint32_t oif = 0; //specify non-zero if bound to a source address
356
      // XXX here, cache the route in the endpoint?
356
      // XXX here, cache the route in the endpoint?
357
      route = ipv4->GetRoutingProtocol ()->RouteOutput (header, oif, errno_);
357
      Ptr<Packet> packet = 0;
358
      route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_);
358
      if (route != 0)
359
      if (route != 0)
359
        {
360
        {
360
          NS_LOG_LOGIC ("Route exists");
361
          NS_LOG_LOGIC ("Route exists");
 Lines 855-861    Link Here 
855
            Ptr<Ipv4Route> route;
856
            Ptr<Ipv4Route> route;
856
            uint32_t oif = 0; //specify non-zero if bound to a source address
857
            uint32_t oif = 0; //specify non-zero if bound to a source address
857
            header.SetDestination (m_remoteAddress);
858
            header.SetDestination (m_remoteAddress);
858
            route = ipv4->GetRoutingProtocol ()->RouteOutput (header, oif, errno_);
859
            route = ipv4->GetRoutingProtocol ()->RouteOutput (p, header, oif, errno_);
859
            if (route != 0)
860
            if (route != 0)
860
              {
861
              {
861
                NS_LOG_LOGIC ("Route exists");
862
                NS_LOG_LOGIC ("Route exists");
(-)a/src/internet-stack/udp-socket-impl.cc (-1 / +1 lines)
 Lines 400-406    Link Here 
400
      Ptr<Ipv4Route> route;
400
      Ptr<Ipv4Route> route;
401
      uint32_t oif = 0; //specify non-zero if bound to a source address
401
      uint32_t oif = 0; //specify non-zero if bound to a source address
402
      // TBD-- we could cache the route and just check its validity
402
      // TBD-- we could cache the route and just check its validity
403
      route = ipv4->GetRoutingProtocol ()->RouteOutput (header, oif, errno_); 
403
      route = ipv4->GetRoutingProtocol ()->RouteOutput (p, header, oif, errno_); 
404
      if (route != 0)
404
      if (route != 0)
405
        {
405
        {
406
          NS_LOG_LOGIC ("Route exists");
406
          NS_LOG_LOGIC ("Route exists");
(-)a/src/node/ipv4-routing-protocol.h (-1 / +2 lines)
 Lines 60-65    Link Here 
60
   * packet to be forwarded, and is synchronous.  Can be used for
60
   * packet to be forwarded, and is synchronous.  Can be used for
61
   * multicast or unicast.  The Linux equivalent is ip_route_output()
61
   * multicast or unicast.  The Linux equivalent is ip_route_output()
62
   *
62
   *
63
   * \param p the generated packet
63
   * \param header input parameter (used to form key to search for the route)
64
   * \param header input parameter (used to form key to search for the route)
64
   * \param oif Output interface index.  May be zero, or may be bound via
65
   * \param oif Output interface index.  May be zero, or may be bound via
65
   *            socket options to a particular output interface.
66
   *            socket options to a particular output interface.
 Lines 67-73    Link Here 
67
   *
68
   *
68
   * \returns a code that indicates what happened in the lookup
69
   * \returns a code that indicates what happened in the lookup
69
   */
70
   */
70
  virtual Ptr<Ipv4Route> RouteOutput (const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr) = 0;
71
  virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr) = 0;
71
  
72
  
72
  /**
73
  /**
73
   * \brief Route an input packet (to be forwarded or locally delivered)
74
   * \brief Route an input packet (to be forwarded or locally delivered)
(-)a/src/routing/global-routing/ipv4-global-routing.cc (-1 / +1 lines)
 Lines 259-265    Link Here 
259
}
259
}
260
260
261
Ptr<Ipv4Route>
261
Ptr<Ipv4Route>
262
Ipv4GlobalRouting::RouteOutput (const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr)
262
Ipv4GlobalRouting::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr)
263
{      
263
{      
264
264
265
//
265
//
(-)a/src/routing/global-routing/ipv4-global-routing.h (-1 / +1 lines)
 Lines 80-86    Link Here 
80
  Ipv4GlobalRouting ();
80
  Ipv4GlobalRouting ();
81
  virtual ~Ipv4GlobalRouting ();
81
  virtual ~Ipv4GlobalRouting ();
82
82
83
  virtual Ptr<Ipv4Route> RouteOutput (const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr);
83
  virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr);
84
84
85
  virtual bool RouteInput  (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
85
  virtual bool RouteInput  (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
86
                             UnicastForwardCallback ucb, MulticastForwardCallback mcb,
86
                             UnicastForwardCallback ucb, MulticastForwardCallback mcb,
(-)a/src/routing/list-routing/ipv4-list-routing.cc (-4 / +4 lines)
 Lines 69-75    Link Here 
69
}
69
}
70
70
71
Ptr<Ipv4Route>
71
Ptr<Ipv4Route>
72
Ipv4ListRouting::RouteOutput (const Ipv4Header &header, uint32_t oif, enum Socket::SocketErrno &sockerr)
72
Ipv4ListRouting::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, uint32_t oif, enum Socket::SocketErrno &sockerr)
73
{
73
{
74
  NS_LOG_FUNCTION (this << header.GetDestination () << " " << header.GetSource () << " " << oif);
74
  NS_LOG_FUNCTION (this << header.GetDestination () << " " << header.GetSource () << " " << oif);
75
  Ptr<Ipv4Route> route;
75
  Ptr<Ipv4Route> route;
 Lines 79-85    Link Here 
79
    {
79
    {
80
      NS_LOG_LOGIC ("Checking protocol " << (*i).second->GetInstanceTypeId () << " with priority " << (*i).first);
80
      NS_LOG_LOGIC ("Checking protocol " << (*i).second->GetInstanceTypeId () << " with priority " << (*i).first);
81
      NS_LOG_LOGIC ("Requesting source address for destination " << header.GetDestination ());
81
      NS_LOG_LOGIC ("Requesting source address for destination " << header.GetDestination ());
82
      route = (*i).second->RouteOutput (header, oif, sockerr);
82
      route = (*i).second->RouteOutput (p, header, oif, sockerr);
83
      if (route)
83
      if (route)
84
        {
84
        {
85
          NS_LOG_LOGIC ("Found route " << route);
85
          NS_LOG_LOGIC ("Found route " << route);
 Lines 335-341    Link Here 
335
335
336
class Ipv4ARouting : public Ipv4RoutingProtocol {
336
class Ipv4ARouting : public Ipv4RoutingProtocol {
337
public:
337
public:
338
  Ptr<Ipv4Route> RouteOutput (const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr)  { return 0;}
338
  Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr)  { return 0;}
339
  bool RouteInput  (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
339
  bool RouteInput  (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
340
                             UnicastForwardCallback ucb, MulticastForwardCallback mcb,
340
                             UnicastForwardCallback ucb, MulticastForwardCallback mcb,
341
                             LocalDeliverCallback lcb, ErrorCallback ecb) {return false;}
341
                             LocalDeliverCallback lcb, ErrorCallback ecb) {return false;}
 Lines 348-354    Link Here 
348
348
349
class Ipv4BRouting : public Ipv4RoutingProtocol {
349
class Ipv4BRouting : public Ipv4RoutingProtocol {
350
public:
350
public:
351
  Ptr<Ipv4Route> RouteOutput (const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr)  { return 0;}
351
  Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr)  { return 0;}
352
  bool RouteInput  (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
352
  bool RouteInput  (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
353
                             UnicastForwardCallback ucb, MulticastForwardCallback mcb,
353
                             UnicastForwardCallback ucb, MulticastForwardCallback mcb,
354
                             LocalDeliverCallback lcb, ErrorCallback ecb) {return false;}
354
                             LocalDeliverCallback lcb, ErrorCallback ecb) {return false;}
(-)a/src/routing/list-routing/ipv4-list-routing.h (-1 / +1 lines)
 Lines 73-79    Link Here 
73
  virtual Ptr<Ipv4RoutingProtocol> GetRoutingProtocol (uint32_t index, int16_t& priority) const;
73
  virtual Ptr<Ipv4RoutingProtocol> GetRoutingProtocol (uint32_t index, int16_t& priority) const;
74
74
75
  // Below are from Ipv4RoutingProtocol
75
  // Below are from Ipv4RoutingProtocol
76
  virtual Ptr<Ipv4Route> RouteOutput (const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr);
76
  virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr);
77
77
78
  virtual bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
78
  virtual bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
79
                           UnicastForwardCallback ucb, MulticastForwardCallback mcb,
79
                           UnicastForwardCallback ucb, MulticastForwardCallback mcb,
(-)a/src/routing/olsr/olsr-routing-protocol.cc (-1 / +1 lines)
 Lines 2551-2557    Link Here 
2551
}
2551
}
2552
2552
2553
Ptr<Ipv4Route>
2553
Ptr<Ipv4Route>
2554
RoutingProtocol::RouteOutput (const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr)
2554
RoutingProtocol::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr)
2555
{  
2555
{  
2556
  NS_LOG_FUNCTION (this << " " << m_ipv4->GetObject<Node> ()->GetId() << " " << header.GetDestination () << " " << oif);
2556
  NS_LOG_FUNCTION (this << " " << m_ipv4->GetObject<Node> ()->GetId() << " " << header.GetDestination () << " " << oif);
2557
  // TBD:  oif is unused; can be used to restrict the outgoing interface
2557
  // TBD:  oif is unused; can be used to restrict the outgoing interface
(-)a/src/routing/olsr/olsr-routing-protocol.h (-1 / +1 lines)
 Lines 120-126    Link Here 
120
                      RoutingTableEntry &outEntry) const;
120
                      RoutingTableEntry &outEntry) const;
121
121
122
  // From Ipv4RoutingProtocol
122
  // From Ipv4RoutingProtocol
123
  virtual Ptr<Ipv4Route> RouteOutput (const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr);
123
  virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr);
124
   virtual bool RouteInput  (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
124
   virtual bool RouteInput  (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
125
                             UnicastForwardCallback ucb, MulticastForwardCallback mcb,
125
                             UnicastForwardCallback ucb, MulticastForwardCallback mcb,
126
                             LocalDeliverCallback lcb, ErrorCallback ecb);  
126
                             LocalDeliverCallback lcb, ErrorCallback ecb);  
(-)a/src/routing/static-routing/ipv4-static-routing.cc (-1 / +1 lines)
 Lines 437-443    Link Here 
437
}
437
}
438
438
439
Ptr<Ipv4Route> 
439
Ptr<Ipv4Route> 
440
Ipv4StaticRouting::RouteOutput (const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr)
440
Ipv4StaticRouting::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr)
441
{
441
{
442
  NS_LOG_FUNCTION (this << header << oif);
442
  NS_LOG_FUNCTION (this << header << oif);
443
  Ipv4Address destination = header.GetDestination ();
443
  Ipv4Address destination = header.GetDestination ();
(-)a/src/routing/static-routing/ipv4-static-routing.h (-1 / +1 lines)
 Lines 70-76    Link Here 
70
  Ipv4StaticRouting ();
70
  Ipv4StaticRouting ();
71
  virtual ~Ipv4StaticRouting ();
71
  virtual ~Ipv4StaticRouting ();
72
72
73
  virtual Ptr<Ipv4Route> RouteOutput (const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr);
73
  virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr);
74
74
75
  virtual bool RouteInput  (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
75
  virtual bool RouteInput  (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
76
                             UnicastForwardCallback ucb, MulticastForwardCallback mcb,
76
                             UnicastForwardCallback ucb, MulticastForwardCallback mcb,

Return to bug 592