fib: merged redundant functions
Change-Id: Iebec912fa7a3b8ab2cfe36835868dbdb068d7076
refs: #4105
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index 592b2bd..7e19100 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -78,18 +78,6 @@
void
Fib::update(const ndn::Name& name, NexthopList& allHops)
{
- FibEntry* entry = processUpdate(name, allHops);
- if (entry != nullptr && !entry->getRefreshEventId()) {
- scheduleEntryRefresh(*entry,
- [this] (FibEntry& fibEntry) {
- this->scheduleLoop(fibEntry);
- });
- }
-}
-
-FibEntry*
-Fib::processUpdate(const ndn::Name& name, NexthopList& allHops)
-{
_LOG_DEBUG("Fib::update called");
// Get the max possible faces which is the minumum of the configuration setting and
@@ -117,7 +105,7 @@
m_table.emplace(name, entry);
- return &m_table.find(name)->second;
+ entryIt = m_table.find(name);
}
// Existing FIB entry that may or may not have nextHops
else {
@@ -127,7 +115,7 @@
// Remove empty FIB entry
if (hopsToAdd.getSize() == 0) {
remove(name);
- return nullptr;
+ return;
}
FibEntry& entry = (entryIt->second);
@@ -151,7 +139,14 @@
// Increment sequence number
entry.setSeqNo(entry.getSeqNo() + 1);
- return &(m_table.find(name)->second);
+ entryIt = m_table.find(name);
+
+ }
+ if (entryIt != m_table.end() && !entryIt->second.getRefreshEventId()) {
+ scheduleEntryRefresh(entryIt->second,
+ [this] (FibEntry& entry) {
+ scheduleLoop(entry);
+ });
}
}
diff --git a/src/route/fib.hpp b/src/route/fib.hpp
index 5761a3d..8cf7aa4 100644
--- a/src/route/fib.hpp
+++ b/src/route/fib.hpp
@@ -211,12 +211,6 @@
const std::string& message);
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
- /*! \brief Internal portion of Fib::update.
- * \sa Fib::update
- */
- FibEntry*
- processUpdate(const ndn::Name& name, NexthopList& allHops);
-
/*! \brief Schedule a refresh event for an entry.
*
* Schedules a refresh event for an entry. In order to form a
diff --git a/tests/test-fib.cpp b/tests/test-fib.cpp
index 993a7a6..84642f1 100644
--- a/tests/test-fib.cpp
+++ b/tests/test-fib.cpp
@@ -19,11 +19,9 @@
*
**/
+#include "route/fib.hpp"
#include "test-common.hpp"
#include "control-commands.hpp"
-
-#include "route/fib.hpp"
-
#include "adjacency-list.hpp"
#include "conf-parameter.hpp"
@@ -107,7 +105,7 @@
hops.addNextHop(hop1);
hops.addNextHop(hop2);
- fib->processUpdate("/ndn/name", hops);
+ fib->update("/ndn/name", hops);
face->processEvents(ndn::time::milliseconds(-1));
// Should register faces 1 and 2 for /ndn/name
@@ -141,13 +139,13 @@
oldHops.addNextHop(hop1);
oldHops.addNextHop(hop2);
- fib->processUpdate("/ndn/name", oldHops);
+ fib->update("/ndn/name", oldHops);
face->processEvents(ndn::time::milliseconds(-1));
BOOST_REQUIRE_EQUAL(interests.size(), 2);
interests.clear();
- fib->processUpdate("/ndn/name", oldHops);
+ fib->update("/ndn/name", oldHops);
face->processEvents(ndn::time::milliseconds(-1));
// Should register face 1 and 2 for /ndn/name
@@ -180,7 +178,7 @@
oldHops.addNextHop(hop1);
oldHops.addNextHop(hop2);
- fib->processUpdate("/ndn/name", oldHops);
+ fib->update("/ndn/name", oldHops);
face->processEvents(ndn::time::milliseconds(-1));
BOOST_REQUIRE_EQUAL(interests.size(), 2);
@@ -188,7 +186,7 @@
NexthopList empty;
- fib->processUpdate("/ndn/name", empty);
+ fib->update("/ndn/name", empty);
face->processEvents(ndn::time::milliseconds(-1));
// Should unregister faces 1 and 2 for /ndn/name
@@ -223,7 +221,7 @@
hops.addNextHop(hop2);
hops.addNextHop(hop3);
- fib->processUpdate("/ndn/name", hops);
+ fib->update("/ndn/name", hops);
face->processEvents(ndn::time::milliseconds(-1));
// Should only register faces 1 and 2 for /ndn/name
@@ -256,7 +254,7 @@
hops.addNextHop(hop1);
hops.addNextHop(hop2);
- fib->processUpdate("/ndn/name", hops);
+ fib->update("/ndn/name", hops);
face->processEvents(ndn::time::milliseconds(-1));
// FIB
@@ -269,7 +267,7 @@
NextHop hop3(router3FaceUri, 5);
hops.addNextHop(hop3);
- fib->processUpdate("/ndn/name", hops);
+ fib->update("/ndn/name", hops);
face->processEvents(ndn::time::milliseconds(-1));
// To maintain a max 2 face requirement, face 3 should be registered and face 2 should be