rib: fix FibAddNextHopCommand parameters
refs #1618
Change-Id: I6f8003bee785f0eaaadbf4fa3c5c8281a2cf48da
diff --git a/rib/rib-manager.cpp b/rib/rib-manager.cpp
index f485c18..a84d7f6 100644
--- a/rib/rib-manager.cpp
+++ b/rib/rib-manager.cpp
@@ -70,34 +70,32 @@
}
void
+RibManager::startListening(const Name& commandPrefix, const ndn::OnInterest& onRequest)
+{
+ NFD_LOG_INFO("Listening on: " << commandPrefix);
+
+ m_nfdController.start<ndn::nfd::FibAddNextHopCommand>(
+ ControlParameters()
+ .setName(commandPrefix)
+ .setFaceId(0),
+ bind(&RibManager::onNrdCommandPrefixAddNextHopSuccess, this, cref(commandPrefix)),
+ bind(&RibManager::onNrdCommandPrefixAddNextHopError, this, cref(commandPrefix), _2));
+
+ m_face.setInterestFilter(commandPrefix, onRequest);
+}
+
+void
RibManager::registerWithNfd()
{
//check whether the components of localhop and localhost prefixes are same
BOOST_ASSERT(COMMAND_PREFIX.size() == REMOTE_COMMAND_PREFIX.size());
- NFD_LOG_INFO("Setting interest filter on: " << COMMAND_PREFIX);
+ this->startListening(COMMAND_PREFIX, bind(&RibManager::onLocalhostRequest, this, _2));
- m_nfdController.start<ndn::nfd::FibAddNextHopCommand>(
- ControlParameters()
- .setName(COMMAND_PREFIX),
- bind(&RibManager::onNrdCommandPrefixAddNextHopSuccess, this, cref(COMMAND_PREFIX)),
- bind(&RibManager::onNrdCommandPrefixAddNextHopError, this, cref(COMMAND_PREFIX), _2));
-
- m_face.setInterestFilter(COMMAND_PREFIX, bind(&RibManager::onLocalhostRequest, this, _2));
-
- if (m_isLocalhopEnabled)
- {
- NFD_LOG_INFO("Setting interest filter on: " << REMOTE_COMMAND_PREFIX);
-
- m_nfdController.start<ndn::nfd::FibAddNextHopCommand>(
- ControlParameters()
- .setName(COMMAND_PREFIX),
- bind(&RibManager::onNrdCommandPrefixAddNextHopSuccess, this, cref(REMOTE_COMMAND_PREFIX)),
- bind(&RibManager::onNrdCommandPrefixAddNextHopError, this, cref(REMOTE_COMMAND_PREFIX), _2));
-
- m_face.setInterestFilter(REMOTE_COMMAND_PREFIX,
- bind(&RibManager::onLocalhopRequest, this, _2));
- }
+ if (m_isLocalhopEnabled) {
+ this->startListening(REMOTE_COMMAND_PREFIX,
+ bind(&RibManager::onLocalhopRequest, this, _2));
+ }
NFD_LOG_INFO("Start monitoring face create/destroy events");
m_faceMonitor.addSubscriber(bind(&RibManager::onNotification, this, _1));
diff --git a/rib/rib-manager.hpp b/rib/rib-manager.hpp
index 1407fb2..bcd43d7 100644
--- a/rib/rib-manager.hpp
+++ b/rib/rib-manager.hpp
@@ -74,6 +74,9 @@
const std::string& filename);
void
+ startListening(const Name& commandPrefix, const ndn::OnInterest& onRequest);
+
+ void
onLocalhopRequest(const Interest& request);
void