Ipv4Endpoint: Add 2 tests to verify the existence of the callback before calling it.
authorfrederic.urbani@inria.fr
Wed, 09 Jan 2013 14:13:15 +0100
changeset 921755055ecdbd47
parent 9216 a777dcd2f0bf
child 9218 2b1da90eb6a7
Ipv4Endpoint: Add 2 tests to verify the existence of the callback before calling it.
src/internet/model/ipv4-end-point.cc
     1.1 --- a/src/internet/model/ipv4-end-point.cc	Wed Jan 09 13:45:23 2013 +0100
     1.2 +++ b/src/internet/model/ipv4-end-point.cc	Wed Jan 09 14:13:15 2013 +0100
     1.3 @@ -123,7 +123,10 @@
     1.4  Ipv4EndPoint::DoForwardUp (Ptr<Packet> p, const Ipv4Header& header, uint16_t sport,
     1.5                             Ptr<Ipv4Interface> incomingInterface)
     1.6  {
     1.7 -  m_rxCallback (p, header, sport, incomingInterface);
     1.8 +  if (!m_rxCallback.IsNull ())
     1.9 +    {
    1.10 +      m_rxCallback (p, header, sport, incomingInterface);
    1.11 +    }
    1.12  }
    1.13  
    1.14  void 
    1.15 @@ -144,7 +147,10 @@
    1.16                               uint8_t icmpType, uint8_t icmpCode,
    1.17                               uint32_t icmpInfo)
    1.18  {
    1.19 -  m_icmpCallback (icmpSource,icmpTtl,icmpType,icmpCode,icmpInfo);
    1.20 +  if (!m_icmpCallback.IsNull ())
    1.21 +    {
    1.22 +      m_icmpCallback (icmpSource,icmpTtl,icmpType,icmpCode,icmpInfo);
    1.23 +    }
    1.24  }
    1.25  
    1.26  } // namespace ns3