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();
}