From 48079b1184f1fb4ae13955f65ae74ceb463983dc Mon Sep 17 00:00:00 2001 From: "Saswat K. Mishra" Date: Tue, 8 Sep 2015 21:22:49 +0530 Subject: [PATCH 1/2] added support for Ipv6 ndisc cache permanent entries added new state PERMANENT new method MarkPermanent () and IsPermanent () moidified Icmpv6L4Protocol::Lookup () to consider new Permanent entries modified NdiscCache::PrintCache () to consider new permanent entries as well as default case for unknown entry type --- src/internet/model/icmpv6-l4-protocol.cc | 4 ++-- src/internet/model/ndisc-cache.cc | 22 +++++++++++++++++++++- src/internet/model/ndisc-cache.h | 14 +++++++++++++- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/internet/model/icmpv6-l4-protocol.cc b/src/internet/model/icmpv6-l4-protocol.cc index a156db7..d7b8ab2 100644 --- a/src/internet/model/icmpv6-l4-protocol.cc +++ b/src/internet/model/icmpv6-l4-protocol.cc @@ -1295,7 +1295,7 @@ bool Icmpv6L4Protocol::Lookup (Ipv6Address dst, Ptr device, PtrLookup (dst); if (entry) { - if (entry->IsReachable () || entry->IsDelay ()) + if (entry->IsReachable () || entry->IsDelay () || entry->IsPermanent ()) { *hardwareDestination = entry->GetMacAddress (); return true; @@ -1329,7 +1329,7 @@ bool Icmpv6L4Protocol::Lookup (Ptr p, Ipv6Address dst, Ptr de NdiscCache::Entry* entry = cache->Lookup (dst); if (entry) { - if (entry->IsReachable () || entry->IsDelay ()) + if (entry->IsReachable () || entry->IsDelay () || entry->IsPermanent ()) { /* XXX check reachability time */ /* send packet */ diff --git a/src/internet/model/ndisc-cache.cc b/src/internet/model/ndisc-cache.cc index 5a9dc0c..b379b23 100644 --- a/src/internet/model/ndisc-cache.cc +++ b/src/internet/model/ndisc-cache.cc @@ -187,10 +187,18 @@ void NdiscCache::PrintNdiscCache (Ptr stream) { *os << " PROBE\n"; } - else + else if (i->second->IsStale ()) { *os << " STALE\n"; } + else if (i->second->IsPermanent ()) + { + *os << " PERMANENT\n"; + } + else + { + NS_FATAL_ERROR ("Test for possibly unreachable code-- please file a bug report, with a test case, if this is ever hit"); + } } } @@ -495,6 +503,12 @@ void NdiscCache::Entry::MarkDelay () m_state = DELAY; } +void NdiscCache::Entry::MarkPermanent () +{ + NS_LOG_FUNCTION_NOARGS (); + m_state = PERMANENT; +} + bool NdiscCache::Entry::IsStale () const { NS_LOG_FUNCTION_NOARGS (); @@ -525,6 +539,12 @@ bool NdiscCache::Entry::IsProbe () const return (m_state == PROBE); } +bool NdiscCache::Entry::IsPermanent () const +{ + NS_LOG_FUNCTION_NOARGS (); + return (m_state == PERMANENT); +} + Address NdiscCache::Entry::GetMacAddress () const { NS_LOG_FUNCTION_NOARGS (); diff --git a/src/internet/model/ndisc-cache.h b/src/internet/model/ndisc-cache.h index 81eca93..951e02a 100644 --- a/src/internet/model/ndisc-cache.h +++ b/src/internet/model/ndisc-cache.h @@ -185,6 +185,11 @@ public: void MarkDelay (); /** + * \brief Change the state to this entry to PERMANENT. + */ + void MarkPermanent (); + + /** * \brief Add a packet (or replace old value) in the queue. * \param p packet to add */ @@ -226,6 +231,12 @@ public: bool IsProbe () const; /** + * \brief Is the entry PERMANENT + * \return true if the entry is in PERMANENT state, false otherwise + */ + bool IsPermanent () const; + + /** * \brief Get the MAC address of this entry. * \return the L2 address */ @@ -328,7 +339,8 @@ private: REACHABLE, /**< Mapping exists between IPv6 and L2 addresses */ STALE, /**< Mapping is stale */ DELAY, /**< Try to wait contact from remote host */ - PROBE /**< Try to contact IPv6 address to know again its L2 address */ + PROBE, /**< Try to contact IPv6 address to know again its L2 address */ + PERMANENT /**< Permanent Mapping exists between IPv6 and L2 addresses */ }; /** -- 2.1.0 From dc1cb3d495581c5b8de750c535e1b0cb818223ec Mon Sep 17 00:00:00 2001 From: "Saswat K. Mishra" Date: Wed, 16 Sep 2015 23:40:12 +0530 Subject: [PATCH 2/2] modified a few places where permanet entries were being igonred --- src/internet/model/icmpv6-l4-protocol.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/internet/model/icmpv6-l4-protocol.cc b/src/internet/model/icmpv6-l4-protocol.cc index d7b8ab2..37a4840 100644 --- a/src/internet/model/icmpv6-l4-protocol.cc +++ b/src/internet/model/icmpv6-l4-protocol.cc @@ -401,7 +401,7 @@ void Icmpv6L4Protocol::ReceiveLLA (Icmpv6OptionLinkLayerAddress lla, Ipv6Address } else { - if (!entry->IsReachable ()) + if (!entry->IsReachable () || !entry->IsPermanent ()) { entry->StopNudTimer (); waiting = entry->MarkReachable (lla.GetAddress ()); @@ -708,7 +708,7 @@ void Icmpv6L4Protocol::HandleNA (Ptr packet, Ipv6Address const &src, Ipv if (naHeader.GetFlagS ()) { - if (!entry->IsReachable ()) + if (!entry->IsReachable () || !entry->IsPermanent ()) { if (entry->IsProbe ()) { -- 2.1.0