table: added findExactMatch and remove methods to Fib
Added methods required to implement remaining FIB
management commands.
refs: #1223
Change-Id: Idf27a60a19286ab1d5712bbc00cca7f41092807b
diff --git a/daemon/table/fib.cpp b/daemon/table/fib.cpp
index 532ad97..7a3295a 100644
--- a/daemon/table/fib.cpp
+++ b/daemon/table/fib.cpp
@@ -35,7 +35,7 @@
m_table.begin(), m_table.end(),
bind(&predicate_FibEntry_eq_Name, _1, prefix));
if (it != m_table.end()) return std::make_pair(*it, false);
-
+
shared_ptr<fib::Entry> entry = make_shared<fib::Entry>(prefix);
m_table.push_back(entry);
return std::make_pair(entry, true);
@@ -54,12 +54,32 @@
shared_ptr<fib::Entry>
Fib::findLongestPrefixMatch(const Name& prefix) const
{
- shared_ptr<fib::Entry> bestMatch =
+ shared_ptr<fib::Entry> bestMatch =
std::accumulate(m_table.begin(), m_table.end(), m_rootEntry,
bind(&accumulate_FibEntry_longestPrefixMatch, _1, _2, prefix));
return bestMatch;
}
+shared_ptr<fib::Entry>
+Fib::findExactMatch(const Name& prefix) const
+{
+ std::list<shared_ptr<fib::Entry> >::const_iterator it =
+ std::find_if(m_table.begin(), m_table.end(),
+ bind(&predicate_FibEntry_eq_Name, _1, prefix));
+
+ if (it != m_table.end())
+ {
+ return *it;
+ }
+ return shared_ptr<fib::Entry>();
+}
+
+void
+Fib::remove(const Name& prefix)
+{
+ m_table.remove_if(bind(&predicate_FibEntry_eq_Name, _1, prefix));
+}
+
static inline void
FibEntry_removeNextHop(shared_ptr<fib::Entry> entry,
shared_ptr<Face> face)