src/internet-stack/ipv4-l3-protocol.cc
changeset 5984 7a60b058e7b4
parent 5977 288416b082a4
child 6047 09841960107d
--- a/src/internet-stack/ipv4-l3-protocol.cc	Tue Feb 09 15:26:41 2010 +0000
+++ b/src/internet-stack/ipv4-l3-protocol.cc	Tue Feb 09 22:03:57 2010 -0800
@@ -482,6 +482,7 @@
       socket->ForwardUp (packet, ipHeader, device);
     }
 
+  NS_ASSERT_MSG (m_routingProtocol != 0, "Need a routing protocol object to process packets");
   m_routingProtocol->RouteInput (packet, ipHeader, device, 
     MakeCallback (&Ipv4L3Protocol::IpForward, this),
     MakeCallback (&Ipv4L3Protocol::IpMulticastForward, this),
@@ -609,7 +610,15 @@
   Socket::SocketErrno errno_; 
   Ptr<NetDevice> oif (0); // unused for now
   ipHeader = BuildHeader (source, destination, protocol, packet->GetSize (), ttl, mayFragment);
-  Ptr<Ipv4Route> newRoute = m_routingProtocol->RouteOutput (packet, ipHeader, oif, errno_);
+  Ptr<Ipv4Route> newRoute;
+  if (m_routingProtocol != 0)
+    {
+      newRoute = m_routingProtocol->RouteOutput (packet, ipHeader, oif, errno_);
+    }
+  else
+    {
+      NS_LOG_ERROR ("Ipv4L3Protocol::Send: m_routingProtocol == 0");
+    }
   if (newRoute)
     {
       int32_t interface = GetInterfaceForDevice (newRoute->GetOutputDevice ());