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 9217 55055ecdbd47
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
--- a/src/internet/model/ipv4-end-point.cc	Wed Jan 09 13:45:23 2013 +0100
+++ b/src/internet/model/ipv4-end-point.cc	Wed Jan 09 14:13:15 2013 +0100
@@ -123,7 +123,10 @@
 Ipv4EndPoint::DoForwardUp (Ptr<Packet> p, const Ipv4Header& header, uint16_t sport,
                            Ptr<Ipv4Interface> incomingInterface)
 {
-  m_rxCallback (p, header, sport, incomingInterface);
+  if (!m_rxCallback.IsNull ())
+    {
+      m_rxCallback (p, header, sport, incomingInterface);
+    }
 }
 
 void 
@@ -144,7 +147,10 @@
                              uint8_t icmpType, uint8_t icmpCode,
                              uint32_t icmpInfo)
 {
-  m_icmpCallback (icmpSource,icmpTtl,icmpType,icmpCode,icmpInfo);
+  if (!m_icmpCallback.IsNull ())
+    {
+      m_icmpCallback (icmpSource,icmpTtl,icmpType,icmpCode,icmpInfo);
+    }
 }
 
 } // namespace ns3