src: Updating code to compile with the latest ndn-cxx library
This commit includes updates against the latest Face API and replaces
uses of deprecated methods.
Change-Id: I33ad398d26f8faf9f9627ff329ce0936e0911ab2
diff --git a/rib/rib-manager.cpp b/rib/rib-manager.cpp
index f4fc9c8..f485c18 100644
--- a/rib/rib-manager.cpp
+++ b/rib/rib-manager.cpp
@@ -59,7 +59,7 @@
RibManager::RibManager()
: m_face(getGlobalIoService())
- , m_nfdController(new ndn::nfd::Controller(m_face))
+ , m_nfdController(m_face)
, m_localhostValidator(m_face)
, m_localhopValidator(m_face)
, m_faceMonitor(m_face)
@@ -76,17 +76,27 @@
BOOST_ASSERT(COMMAND_PREFIX.size() == REMOTE_COMMAND_PREFIX.size());
NFD_LOG_INFO("Setting interest filter on: " << COMMAND_PREFIX);
- m_face.setController(m_nfdController);
- m_face.setInterestFilter(COMMAND_PREFIX,
- bind(&RibManager::onLocalhostRequest, this, _2),
- bind(&RibManager::setInterestFilterFailed, this, _1, _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),
- bind(&RibManager::setInterestFilterFailed, this, _1, _2));
+ bind(&RibManager::onLocalhopRequest, this, _2));
}
NFD_LOG_INFO("Start monitoring face create/destroy events");
@@ -122,12 +132,6 @@
}
void
-RibManager::setInterestFilterFailed(const Name& name, const std::string& msg)
-{
- throw Error("Error in setting interest filter (" + name.toUri() + "): " + msg);
-}
-
-void
RibManager::sendResponse(const Name& name,
const ControlResponse& response)
{
@@ -229,7 +233,7 @@
// Rib tree, then nrd will generate fib updates based on flags and then
// will add next hops one by one..
m_managedRib.insert(ribEntry);
- m_nfdController->start<ndn::nfd::FibAddNextHopCommand>(
+ m_nfdController.start<ndn::nfd::FibAddNextHopCommand>(
ControlParameters()
.setName(ribEntry.name)
.setFaceId(ribEntry.faceId)
@@ -258,7 +262,7 @@
NFD_LOG_TRACE("unregister prefix: " << ribEntry);
- m_nfdController->start<ndn::nfd::FibRemoveNextHopCommand>(
+ m_nfdController.start<ndn::nfd::FibRemoveNextHopCommand>(
ControlParameters()
.setName(ribEntry.name)
.setFaceId(ribEntry.faceId),
@@ -372,6 +376,30 @@
}
void
+RibManager::onNrdCommandPrefixAddNextHopSuccess(const Name& prefix)
+{
+ NFD_LOG_DEBUG("Successfully registered " + prefix.toUri() + " with NFD");
+}
+
+void
+RibManager::onNrdCommandPrefixAddNextHopError(const Name& name, const std::string& msg)
+{
+ throw Error("Error in setting interest filter (" + name.toUri() + "): " + msg);
+}
+
+void
+RibManager::onAddNextHopSuccess(const Name& prefix)
+{
+ NFD_LOG_DEBUG("Successfully registered " + prefix.toUri() + " with NFD");
+}
+
+void
+RibManager::onAddNextHopError(const Name& name, const std::string& msg)
+{
+ throw Error("Error in setting interest filter (" + name.toUri() + "): " + msg);
+}
+
+void
RibManager::onControlHeaderSuccess()
{
NFD_LOG_DEBUG("Local control header enabled");
@@ -389,7 +417,7 @@
void
RibManager::enableLocalControlHeader()
{
- m_nfdController->start<ndn::nfd::FaceEnableLocalControlCommand>(
+ m_nfdController.start<ndn::nfd::FaceEnableLocalControlCommand>(
ControlParameters()
.setLocalControlFeature(ndn::nfd::LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID),
bind(&RibManager::onControlHeaderSuccess, this),
diff --git a/rib/rib-manager.hpp b/rib/rib-manager.hpp
index ef38ae1..1407fb2 100644
--- a/rib/rib-manager.hpp
+++ b/rib/rib-manager.hpp
@@ -120,14 +120,22 @@
const RibEntry& ribEntry);
void
+ onNrdCommandPrefixAddNextHopSuccess(const Name& prefix);
+
+ void
+ onNrdCommandPrefixAddNextHopError(const Name& name, const std::string& msg);
+
+ void
+ onAddNextHopSuccess(const Name& prefix);
+
+ void
+ onAddNextHopError(const Name& name, const std::string& msg);
+
+ void
onControlHeaderSuccess();
void
onControlHeaderError(uint32_t code, const std::string& reason);
-
- void
- setInterestFilterFailed(const Name& name, const std::string& msg);
-
static bool
extractParameters(const Name::Component& parameterComponent,
ControlParameters& extractedParameters);
@@ -142,7 +150,7 @@
private:
Rib m_managedRib;
ndn::Face m_face;
- ndn::shared_ptr<ndn::nfd::Controller> m_nfdController;
+ ndn::nfd::Controller m_nfdController;
ndn::KeyChain m_keyChain;
ndn::ValidatorConfig m_localhostValidator;
ndn::ValidatorConfig m_localhopValidator;