bug 1046: Check AODV LocalDeliver callback before using it
authorTom Henderson <tomh@tomh.org>
Fri, 15 Apr 2011 15:45:50 -0700
changeset 7030 c3c23b4f49be
parent 7029 0df1e57ac40a
child 7031 d15eb12117e5
bug 1046: Check AODV LocalDeliver callback before using it
RELEASE_NOTES
src/aodv/model/aodv-routing-protocol.cc
--- a/RELEASE_NOTES	Fri Apr 15 13:05:52 2011 -0700
+++ b/RELEASE_NOTES	Fri Apr 15 15:45:50 2011 -0700
@@ -30,6 +30,7 @@
    - Fixed the UanPhyGen::IsStateBusy method, error with logical OR
    - CsmaNetDevice ReceiveErrorModel was not dropping the packet
    - bug 1064 - Correct Friis propagation loss equation in spectrum module
+   - bug 1046 - Check Aodv LocalDeliver callback before using it
 
 Known issues
 ------------
--- a/src/aodv/model/aodv-routing-protocol.cc	Fri Apr 15 13:05:52 2011 -0700
+++ b/src/aodv/model/aodv-routing-protocol.cc	Fri Apr 15 15:45:50 2011 -0700
@@ -385,6 +385,12 @@
   if (IsMyOwnAddress (origin))
     return true;
 
+  // AODV is not a multicast routing protocol
+  if (dst.IsMulticast ())
+    {
+      return false; 
+    }
+
   // Broadcast local delivery/forwarding
   for (std::map<Ptr<Socket> , Ipv4InterfaceAddress>::const_iterator j =
       m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j)
@@ -399,9 +405,18 @@
                 return true;
               }
             UpdateRouteLifeTime (origin, ActiveRouteTimeout);
-            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 (!EnableBroadcast)
               {
                 return true;
@@ -438,8 +453,16 @@
           UpdateRouteLifeTime (toOrigin.GetNextHop (), ActiveRouteTimeout);
           m_nb.Update (toOrigin.GetNextHop (), ActiveRouteTimeout);
         }
-      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;
     }