bug 1643 - NdiscCache creation and existence checks

This commit is contained in:
Tommaso Pecorella
2013-04-20 00:11:33 +02:00
parent 77b0af3971
commit 32f00291e7
2 changed files with 18 additions and 3 deletions

View File

@@ -1231,8 +1231,16 @@ bool Icmpv6L4Protocol::Lookup (Ipv6Address dst, Ptr<NetDevice> device, Ptr<Ndisc
/* 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 @@ bool Icmpv6L4Protocol::Lookup (Ptr<Packet> p, Ipv6Address dst, Ptr<NetDevice> de
/* try to find the cache */
cache = FindCache (device);
}
if (!cache)
{
return false;
}
NdiscCache::Entry* entry = cache->Lookup (dst);
if (entry)

View File

@@ -103,7 +103,10 @@ void Ipv6Interface::DoSetup ()
}
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)