src: Changing prefix registration's flag and FaceMonitor
Refs: #1841 #1843
Change-Id: I7ab74d529cf6f9f54ec1db1415f54f36f2229723
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index b99d7a2..7a8e98b 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -82,7 +82,8 @@
if (isPrefixUpdatable(it->getName())) {
registerPrefix(it->getName(), nhit->getConnectingFaceUri(),
std::ceil(nhit->getRouteCost()),
- ndn::time::seconds(m_refreshTime + GRACE_PERIOD), 0);
+ ndn::time::seconds(m_refreshTime + GRACE_PERIOD),
+ ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
}
}
// increase sequence number and schedule refresh again
@@ -138,7 +139,8 @@
if (isPrefixUpdatable(name)) {
registerPrefix(name, nhit->getConnectingFaceUri(),
std::ceil(nhit->getRouteCost()),
- ndn::time::seconds(m_refreshTime + GRACE_PERIOD), 0);
+ ndn::time::seconds(m_refreshTime + GRACE_PERIOD),
+ ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
}
}
newEntry.getNexthopList().sort();
@@ -162,7 +164,8 @@
if (isPrefixUpdatable(name)) {
registerPrefix(name, nhit->getConnectingFaceUri(),
std::ceil(nhit->getRouteCost()),
- ndn::time::seconds(m_refreshTime + GRACE_PERIOD), 0);
+ ndn::time::seconds(m_refreshTime + GRACE_PERIOD),
+ ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
}
removeHop(it->getNexthopList(), nhit->getConnectingFaceUri(), name);
it->getNexthopList().reset();
@@ -175,7 +178,8 @@
if (isPrefixUpdatable(name)) {
registerPrefix(name, nhit->getConnectingFaceUri(),
std::ceil(nhit->getRouteCost()),
- ndn::time::seconds(m_refreshTime + GRACE_PERIOD), 0);
+ ndn::time::seconds(m_refreshTime + GRACE_PERIOD),
+ ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
}
}
}
@@ -292,14 +296,22 @@
void
Fib::registerPrefix(const ndn::Name& namePrefix, const std::string& faceUri,
uint64_t faceCost, const ndn::time::milliseconds& timeout,
- uint8_t times)
+ uint64_t flags, uint8_t times)
{
uint64_t faceId = m_nlsr.getAdjacencyList().getFaceId(faceUri);
if (faceId != 0) {
+ ndn::nfd::ControlParameters faceParameters;
+ faceParameters
+ .setName(namePrefix)
+ .setFaceId(faceId)
+ .setFlags(flags)
+ .setCost(faceCost)
+ .setExpirationPeriod(timeout)
+ .setOrigin(128);
+
_LOG_DEBUG("Registering prefix: " << namePrefix << " Face Uri: " << faceUri
<< " Face Id: " << faceId);
- registerPrefixInNfd(namePrefix, faceId,
- faceCost, timeout, faceUri, times);
+ registerPrefixInNfd(faceParameters, faceUri, times);
}
else {
_LOG_DEBUG("Error: No Face Id for face uri: " << faceUri);
@@ -311,58 +323,56 @@
const std::string& faceUri,
uint64_t faceCost,
const ndn::time::milliseconds& timeout,
+ uint64_t flags,
uint8_t times,
const CommandSucceedCallback& onSuccess,
const CommandFailCallback& onFailure)
{
- createFace(faceUri,
- ndn::bind(&Fib::registerPrefixInNfd, this,_1,
- namePrefix, faceCost,
- timeout, times, onSuccess, onFailure),
- onFailure);
-}
-
-void
-Fib::registerPrefixInNfd(const ndn::Name& namePrefix,
- uint64_t faceId,
- uint64_t faceCost,
- const ndn::time::milliseconds& timeout,
- const std::string& faceUri,
- uint8_t times)
-{
- ndn::nfd::ControlParameters controlParameters;
- controlParameters
+ ndn::nfd::ControlParameters parameters;
+ parameters
.setName(namePrefix)
- .setFaceId(faceId)
+ .setFlags(flags)
.setCost(faceCost)
.setExpirationPeriod(timeout)
.setOrigin(128);
- m_controller.start<ndn::nfd::RibRegisterCommand>(controlParameters,
+ createFace(faceUri,
+ ndn::bind(&Fib::registerPrefixInNfd, this,_1,
+ parameters,
+ times, onSuccess, onFailure),
+ onFailure);
+}
+
+void
+Fib::registerPrefixInNfd(ndn::nfd::ControlParameters& parameters,
+ const std::string& faceUri,
+ uint8_t times)
+{
+ m_controller.start<ndn::nfd::RibRegisterCommand>(parameters,
ndn::bind(&Fib::onRegistration, this, _1,
"Successful in name registration",
faceUri),
ndn::bind(&Fib::onRegistrationFailure,
this, _1, _2,
"Failed in name registration",
- namePrefix, faceUri, faceCost,
- timeout, times));
+ parameters,
+ faceUri, times));
}
void
Fib::registerPrefixInNfd(const ndn::nfd::ControlParameters& faceCreateResult,
- const ndn::Name& namePrefix, uint64_t faceCost,
- const ndn::time::milliseconds& timeout,
+ const ndn::nfd::ControlParameters& parameters,
uint8_t times,
const CommandSucceedCallback& onSuccess,
const CommandFailCallback& onFailure)
{
ndn::nfd::ControlParameters controlParameters;
controlParameters
- .setName(namePrefix)
+ .setName(parameters.getName())
.setFaceId(faceCreateResult.getFaceId())
- .setCost(faceCost)
- .setExpirationPeriod(timeout)
+ .setCost(parameters.getCost())
+ .setFlags(parameters.getFlags())
+ .setExpirationPeriod(parameters.getExpirationPeriod())
.setOrigin(128);
m_controller.start<ndn::nfd::RibRegisterCommand>(controlParameters,
onSuccess,
@@ -416,7 +426,6 @@
m_faceMap.writeLog();
}
-
void
Fib::onUnregistration(const ndn::nfd::ControlParameters& commandSuccessResult,
const std::string& message)
@@ -428,15 +437,18 @@
void
Fib::onRegistrationFailure(uint32_t code, const std::string& error,
const std::string& message,
- const ndn::Name& namePrefix, const std::string& faceUri,
- uint64_t faceCost, const ndn::time::milliseconds& timeout,
+ const ndn::nfd::ControlParameters& parameters,
+ const std::string& faceUri,
uint8_t times)
{
_LOG_DEBUG(message << ": " << error << " (code: " << code << ")");
- _LOG_DEBUG("Prefix: " << namePrefix << " failed for: " << times);
+ _LOG_DEBUG("Prefix: " << parameters.getName() << " failed for: " << times);
if (times < 3) {
_LOG_DEBUG("Trying to register again...");
- registerPrefix(namePrefix, faceUri, faceCost, timeout, times+1);
+ registerPrefix(parameters.getName(), faceUri,
+ parameters.getCost(),
+ parameters.getExpirationPeriod(),
+ parameters.getFlags(), times+1);
}
else {
_LOG_DEBUG("Registration trial given up");