model: Extending FIB and PIT interface to include Find call to search for exact match of FIB and PIT entry
diff --git a/model/fib/ndn-fib-impl.cc b/model/fib/ndn-fib-impl.cc
index 1e0f04f..218502b 100644
--- a/model/fib/ndn-fib-impl.cc
+++ b/model/fib/ndn-fib-impl.cc
@@ -83,6 +83,17 @@
return item->payload ();
}
+Ptr<fib::Entry>
+FibImpl::Find (const Name &prefix)
+{
+ super::iterator item = super::find_exact (prefix);
+
+ if (item == super::end ())
+ return 0;
+ else
+ return item->payload ();
+}
+
Ptr<Entry>
FibImpl::Add (const Name &prefix, Ptr<Face> face, int32_t metric)
diff --git a/model/fib/ndn-fib-impl.h b/model/fib/ndn-fib-impl.h
index 0755b35..57d7d50 100644
--- a/model/fib/ndn-fib-impl.h
+++ b/model/fib/ndn-fib-impl.h
@@ -87,6 +87,9 @@
virtual Ptr<Entry>
LongestPrefixMatch (const Interest &interest);
+
+ virtual Ptr<fib::Entry>
+ Find (const Name &prefix);
virtual Ptr<Entry>
Add (const Name &prefix, Ptr<Face> face, int32_t metric);
diff --git a/model/fib/ndn-fib.h b/model/fib/ndn-fib.h
index 6e21214..490cdfd 100644
--- a/model/fib/ndn-fib.h
+++ b/model/fib/ndn-fib.h
@@ -65,6 +65,15 @@
*/
virtual Ptr<fib::Entry>
LongestPrefixMatch (const Interest &interest) = 0;
+
+ /**
+ * @brief Get FIB entry for the prefix (exact match)
+ *
+ * @param prefix Name for FIB entry
+ * @returns If entry is found, a valid iterator (Ptr<fib::Entry>) will be returned. Otherwise End () (==0)
+ */
+ virtual Ptr<fib::Entry>
+ Find (const Name &prefix) = 0;
/**
* \brief Add or update FIB entry
diff --git a/model/pit/ndn-pit-impl.cc b/model/pit/ndn-pit-impl.cc
index 3a61c09..777ab39 100644
--- a/model/pit/ndn-pit-impl.cc
+++ b/model/pit/ndn-pit-impl.cc
@@ -213,6 +213,19 @@
template<class Policy>
Ptr<Entry>
+PitImpl<Policy>::Find (const Name &prefix)
+{
+ typename super::iterator item = super::find_exact (prefix);
+
+ if (item == super::end ())
+ return 0;
+ else
+ return item->payload ();
+}
+
+
+template<class Policy>
+Ptr<Entry>
PitImpl<Policy>::Create (Ptr<const Interest> header)
{
NS_LOG_DEBUG (header->GetName ());
diff --git a/model/pit/ndn-pit-impl.h b/model/pit/ndn-pit-impl.h
index f3e49f9..66ff69b 100644
--- a/model/pit/ndn-pit-impl.h
+++ b/model/pit/ndn-pit-impl.h
@@ -81,6 +81,9 @@
Lookup (const Interest &header);
virtual Ptr<Entry>
+ Find (const Name &prefix);
+
+ virtual Ptr<Entry>
Create (Ptr<const Interest> header);
virtual void
diff --git a/model/pit/ndn-pit.h b/model/pit/ndn-pit.h
index 186f8c4..dd237c1 100644
--- a/model/pit/ndn-pit.h
+++ b/model/pit/ndn-pit.h
@@ -89,6 +89,15 @@
Lookup (const Interest &header) = 0;
/**
+ * @brief Get PIT entry for the prefix (exact match)
+ *
+ * @param prefix Name for PIT entry
+ * @returns If entry is found, a valid iterator (Ptr<pit::Entry>) will be returned. Otherwise End () (==0)
+ */
+ virtual Ptr<pit::Entry>
+ Find (const Name &prefix) = 0;
+
+ /**
* @brief Creates a PIT entry for the given interest
* @param header parsed interest header
* @returns iterator to Pit entry. If record could not be created (e.g., limit reached),