bug 1643 - NdiscCache creation and existence checks
authorTommaso Pecorella <tommaso.pecorella@unifi.it>
Sat, 20 Apr 2013 00:11:33 +0200
changeset 9760 858d18e11e11
parent 9759 2fca33f9a3a5
child 9761 32e15e895529
bug 1643 - NdiscCache creation and existence checks
src/internet/model/icmpv6-l4-protocol.cc
src/internet/model/ipv6-interface.cc
--- a/src/internet/model/icmpv6-l4-protocol.cc	Fri May 17 13:11:22 2013 +0200
+++ b/src/internet/model/icmpv6-l4-protocol.cc	Sat Apr 20 00:11:33 2013 +0200
@@ -1231,8 +1231,16 @@
       /* try to find the cache */
       cache = FindCache (device);
     }
-
-  return cache->Lookup (dst);
+  if (cache)
+    {
+      NdiscCache::Entry* entry = cache->Lookup (dst);
+      if (entry && !(entry->IsIncomplete() || entry->IsProbe()))
+        {
+          *hardwareDestination = entry->GetMacAddress ();
+          return true;
+        }
+    }
+  return false;
 }
 
 bool Icmpv6L4Protocol::Lookup (Ptr<Packet> p, Ipv6Address dst, Ptr<NetDevice> device, Ptr<NdiscCache> cache, Address* hardwareDestination)
@@ -1244,6 +1252,10 @@
       /* try to find the cache */
       cache = FindCache (device);
     }
+  if (!cache)
+    {
+      return false;
+    }
 
   NdiscCache::Entry* entry = cache->Lookup (dst);
   if (entry)
--- a/src/internet/model/ipv6-interface.cc	Fri May 17 13:11:22 2013 +0200
+++ b/src/internet/model/ipv6-interface.cc	Sat Apr 20 00:11:33 2013 +0200
@@ -103,7 +103,10 @@
     }
 
   Ptr<Icmpv6L4Protocol> icmpv6 = m_node->GetObject<Ipv6L3Protocol> ()->GetIcmpv6 ();
-  m_ndCache = icmpv6->CreateCache (m_device, this);
+  if (m_device->NeedsArp ())
+    {
+      m_ndCache = icmpv6->CreateCache (m_device, this);
+    }
 }
 
 void Ipv6Interface::SetNode (Ptr<Node> node)