nlsr: discover Faces from NFD
refs: #2954
Change-Id: I072972d88bce0e1012e96f33577657048b7df1e1
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index 73cde75..49ce647 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -209,37 +209,6 @@
}
void
-Fib::createFace(const std::string& faceUri,
- const CommandSucceedCallback& onSuccess,
- const CommandFailCallback& onFailure)
-{
- m_faceController.createFace(faceUri, onSuccess, onFailure);
-}
-
-void
-Fib::destroyFace(const std::string& faceUri,
- const CommandSucceedCallback& onSuccess,
- const CommandFailCallback& onFailure)
-{
- createFace(faceUri,
- std::bind(&Fib::destroyFaceInNfd, this, _1, onSuccess, onFailure),
- onFailure);
-}
-
-void
-Fib::destroyFaceInNfd(const ndn::nfd::ControlParameters& faceDestroyResult,
- const CommandSucceedCallback& onSuccess,
- const CommandFailCallback& onFailure)
-{
- ndn::nfd::ControlParameters faceParameters;
- faceParameters
- .setFaceId(faceDestroyResult.getFaceId());
- m_controller.start<ndn::nfd::FaceDestroyCommand>(faceParameters,
- onSuccess,
- onFailure);
-}
-
-void
Fib::registerPrefix(const ndn::Name& namePrefix, const std::string& faceUri,
uint64_t faceCost, const ndn::time::milliseconds& timeout,
uint64_t flags, uint8_t times)
@@ -264,35 +233,6 @@
}
}
-typedef void(Fib::*RegisterPrefixCallback)(const ndn::nfd::ControlParameters&,
- const ndn::nfd::ControlParameters&, uint8_t,
- const CommandSucceedCallback&,
- const CommandFailCallback&);
-
-void
-Fib::registerPrefix(const ndn::Name& namePrefix,
- const std::string& faceUri,
- uint64_t faceCost,
- const ndn::time::milliseconds& timeout,
- uint64_t flags,
- uint8_t times,
- const CommandSucceedCallback& onSuccess,
- const CommandFailCallback& onFailure)
-
-{
- ndn::nfd::ControlParameters parameters;
- parameters
- .setName(namePrefix)
- .setFlags(flags)
- .setCost(faceCost)
- .setExpirationPeriod(timeout)
- .setOrigin(ndn::nfd::ROUTE_ORIGIN_NLSR);
- createFace(faceUri,
- std::bind(static_cast<RegisterPrefixCallback>(&Fib::registerPrefixInNfd),
- this, _1, parameters, times, onSuccess, onFailure),
- onFailure);
-}
-
void
Fib::registerPrefixInNfd(ndn::nfd::ControlParameters& parameters,
const std::string& faceUri,
@@ -304,33 +244,13 @@
"Successful in name registration",
faceUri),
std::bind(&Fib::onRegistrationFailure,
- this, _1,
+ this, _1,
"Failed in name registration",
parameters,
faceUri, times));
}
void
-Fib::registerPrefixInNfd(const ndn::nfd::ControlParameters& faceCreateResult,
- const ndn::nfd::ControlParameters& parameters,
- uint8_t times,
- const CommandSucceedCallback& onSuccess,
- const CommandFailCallback& onFailure)
-{
- ndn::nfd::ControlParameters controlParameters;
- controlParameters
- .setName(parameters.getName())
- .setFaceId(faceCreateResult.getFaceId())
- .setCost(parameters.getCost())
- .setFlags(parameters.getFlags())
- .setExpirationPeriod(parameters.getExpirationPeriod())
- .setOrigin(ndn::nfd::ROUTE_ORIGIN_NLSR);
- m_controller.start<ndn::nfd::RibRegisterCommand>(controlParameters,
- onSuccess,
- onFailure);
-}
-
-void
Fib::unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri)
{
uint32_t faceId = m_faceMap.getFaceId(faceUri);
@@ -374,6 +294,9 @@
_LOG_DEBUG("Register successful Prefix: " << commandSuccessResult.getName() <<
" Face Uri: " << faceUri);
+ // Update the adjacency list with the new Face ID
+ m_adjacencyList.findAdjacent(faceUri)->setFaceId(commandSuccessResult.getFaceId());
+ // Update the fast-access FaceMap with the new Face ID, too
m_faceMap.update(faceUri, commandSuccessResult.getFaceId());
m_faceMap.writeLog();
}
diff --git a/src/route/fib.hpp b/src/route/fib.hpp
index 10aa4fa..2705e47 100644
--- a/src/route/fib.hpp
+++ b/src/route/fib.hpp
@@ -26,15 +26,12 @@
#include "face-map.hpp"
#include "fib-entry.hpp"
#include "test-access-control.hpp"
-#include "utility/face-controller.hpp"
#include <ndn-cxx/mgmt/nfd/controller.hpp>
#include <ndn-cxx/util/time.hpp>
namespace nlsr {
-typedef ndn::nfd::Controller::CommandSucceedCallback CommandSucceedCallback;
-typedef ndn::nfd::Controller::CommandFailCallback CommandFailCallback;
typedef std::function<void(FibEntry&)> afterRefreshCallback;
class AdjacencyList;
@@ -49,7 +46,6 @@
: m_scheduler(scheduler)
, m_refreshTime(0)
, m_controller(face, keyChain)
- , m_faceController(face.getIoService(), m_controller)
, m_adjacencyList(adjacencyList)
, m_confParameter(conf)
{
@@ -82,26 +78,11 @@
uint8_t times);
void
- registerPrefix(const ndn::Name& namePrefix,
- const std::string& faceUri,
- uint64_t faceCost,
- const ndn::time::milliseconds& timeout,
- uint64_t flags,
- uint8_t times,
- const CommandSucceedCallback& onSuccess,
- const CommandFailCallback& onFailure);
-
- void
setStrategy(const ndn::Name& name, const std::string& strategy, uint32_t count);
void
writeLog();
- void
- destroyFace(const std::string& faceUri,
- const CommandSucceedCallback& onSuccess,
- const CommandFailCallback& onFailure);
-
private:
bool
isPrefixUpdatable(const ndn::Name& name);
@@ -113,28 +94,11 @@
getNumberOfFacesForName(NexthopList& nextHopList);
void
- createFace(const std::string& faceUri,
- const CommandSucceedCallback& onSuccess,
- const CommandFailCallback& onFailure);
-
- void
registerPrefixInNfd(ndn::nfd::ControlParameters& parameters,
const std::string& faceUri,
uint8_t times);
void
- registerPrefixInNfd(const ndn::nfd::ControlParameters& faceCreateResult,
- const ndn::nfd::ControlParameters& parameters,
- uint8_t times,
- const CommandSucceedCallback& onSuccess,
- const CommandFailCallback& onFailure);
-
- void
- destroyFaceInNfd(const ndn::nfd::ControlParameters& faceDestroyResult,
- const CommandSucceedCallback& onSuccess,
- const CommandFailCallback& onFailure);
-
- void
unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri);
void
@@ -184,7 +148,6 @@
ndn::Scheduler& m_scheduler;
int32_t m_refreshTime;
ndn::nfd::Controller m_controller;
- util::FaceController m_faceController;
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
FaceMap m_faceMap;