Mathieu's patch: Avoid stack explosion (bug 417)
authorRaj Bhattacharjea <raj.b@gatech.edu>
Sat, 13 Dec 2008 23:26:01 -0500
changeset 4022142c13a3975f
parent 4021 f8a5d0a63f4e
child 4023 d320dea20aca
Mathieu's patch: Avoid stack explosion (bug 417)
src/internet-stack/ipv4-end-point.cc
src/internet-stack/ipv4-end-point.h
     1.1 --- a/src/internet-stack/ipv4-end-point.cc	Sat Dec 13 14:13:37 2008 -0800
     1.2 +++ b/src/internet-stack/ipv4-end-point.cc	Sat Dec 13 23:26:01 2008 -0500
     1.3 @@ -21,6 +21,7 @@
     1.4  #include "ipv4-end-point.h"
     1.5  #include "ns3/packet.h"
     1.6  #include "ns3/log.h"
     1.7 +#include "ns3/simulator.h"
     1.8  
     1.9  NS_LOG_COMPONENT_DEFINE ("Ipv4EndPoint");
    1.10  
    1.11 @@ -95,9 +96,14 @@
    1.12  Ipv4EndPoint::ForwardUp (Ptr<Packet> p, Ipv4Address saddr, uint16_t sport)
    1.13  {
    1.14    if (!m_rxCallback.IsNull ())
    1.15 -  {
    1.16 -    m_rxCallback (p, saddr, sport);
    1.17 -  }
    1.18 +    {
    1.19 +      Simulator::ScheduleNow (&Ipv4EndPoint::DoForwardUp, this, p, saddr, sport);
    1.20 +    }
    1.21 +}
    1.22 +void 
    1.23 +Ipv4EndPoint::DoForwardUp (Ptr<Packet> p, Ipv4Address saddr, uint16_t sport)
    1.24 +{
    1.25 +  m_rxCallback (p, saddr, sport);
    1.26  }
    1.27  
    1.28  void 
    1.29 @@ -109,8 +115,16 @@
    1.30                     (uint32_t)icmpCode << icmpInfo);
    1.31    if (!m_icmpCallback.IsNull ())
    1.32      {
    1.33 -      m_icmpCallback (icmpSource,icmpTtl,icmpType,icmpCode,icmpInfo);
    1.34 +      Simulator::ScheduleNow (&Ipv4EndPoint::DoForwardIcmp, this, 
    1.35 +                              icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
    1.36      }
    1.37  }
    1.38 +void 
    1.39 +Ipv4EndPoint::DoForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, 
    1.40 +                             uint8_t icmpType, uint8_t icmpCode,
    1.41 +                             uint32_t icmpInfo)
    1.42 +{
    1.43 +  m_icmpCallback (icmpSource,icmpTtl,icmpType,icmpCode,icmpInfo);
    1.44 +}
    1.45  
    1.46  }; // namespace ns3
     2.1 --- a/src/internet-stack/ipv4-end-point.h	Sat Dec 13 14:13:37 2008 -0800
     2.2 +++ b/src/internet-stack/ipv4-end-point.h	Sat Dec 13 23:26:01 2008 -0500
     2.3 @@ -69,6 +69,10 @@
     2.4                      uint32_t icmpInfo);
     2.5  
     2.6  private:
     2.7 +  void DoForwardUp (Ptr<Packet> p, Ipv4Address saddr, uint16_t sport);
     2.8 +  void DoForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, 
     2.9 +                      uint8_t icmpType, uint8_t icmpCode,
    2.10 +                      uint32_t icmpInfo);
    2.11    Ipv4Address m_localAddr;
    2.12    uint16_t m_localPort;
    2.13    Ipv4Address m_peerAddr;