bug 1046: DSDV: NULL callback
authorTom Henderson <tomh@tomh.org>
Wed, 17 Aug 2011 16:50:38 -0700
changeset 7444 075e6cbaa9d9
parent 7443 32635b529440
child 7445 13f0b82f19e7
bug 1046: DSDV: NULL callback
src/dsdv/model/dsdv-routing-protocol.cc
--- a/src/dsdv/model/dsdv-routing-protocol.cc	Wed Aug 17 12:52:06 2011 -0400
+++ b/src/dsdv/model/dsdv-routing-protocol.cc	Wed Aug 17 16:50:38 2011 -0700
@@ -368,6 +368,12 @@
   Ipv4Address dst = header.GetDestination ();
   Ipv4Address origin = header.GetSource ();
 
+  // DSDV is not a multicast routing protocol
+  if (dst.IsMulticast ())
+    {
+      return false;
+    }
+
   // Deferred route request
   if (EnableBuffering == true && idev == m_lo)
     {
@@ -396,9 +402,18 @@
         {
           if (dst == iface.GetBroadcast () || dst.IsBroadcast ())
             {
-              NS_LOG_LOGIC ("Broadcast local delivery to " << iface.GetLocal ());
               Ptr<Packet> packet = p->Copy ();
-              lcb (p,header,iif);
+              if (lcb.IsNull () == false)
+                {
+                  NS_LOG_LOGIC ("Broadcast local delivery to " << iface.GetLocal ());
+                  lcb (p, header, iif);
+                  // Fall through to additional processing
+                }
+              else
+                {
+                  NS_LOG_ERROR ("Unable to deliver packet locally due to null callback " << p->GetUid () << " from " << origin);
+                  ecb (p, header, Socket::ERROR_NOROUTETOHOST);
+                }
               if (header.GetTtl () > 1)
                 {
                   NS_LOG_LOGIC ("Forward broadcast. TTL " << (uint16_t) header.GetTtl ());
@@ -420,8 +435,16 @@
 
   if (m_ipv4->IsDestinationAddress (dst, iif))
     {
-      NS_LOG_LOGIC ("Unicast local delivery to " << dst);
-      lcb (p, header, iif);
+      if (lcb.IsNull () == false)
+        {
+          NS_LOG_LOGIC ("Unicast local delivery to " << dst);
+          lcb (p, header, iif);
+        }
+      else
+        {
+          NS_LOG_ERROR ("Unable to deliver packet locally due to null callback " << p->GetUid () << " from " << origin);
+          ecb (p, header, Socket::ERROR_NOROUTETOHOST);
+        }
       return true;
     }
   RoutingTableEntry toDst;