src: Fixing the unreachable faceUri issue
Refs: #1797
Change-Id: I002be1fcd54a0a443df93ed58dc01d335dba18ad
diff --git a/src/hello-protocol.cpp b/src/hello-protocol.cpp
index ad6709c..4fe528c 100644
--- a/src/hello-protocol.cpp
+++ b/src/hello-protocol.cpp
@@ -164,6 +164,12 @@
void
HelloProtocol::onContent(const ndn::Interest& interest, const ndn::Data& data)
{
+ _LOG_DEBUG("Received data for INFO(name): " << data.getName());
+ if (data.getSignature().hasKeyLocator()) {
+ if (data.getSignature().getKeyLocator().getType() == ndn::KeyLocator::KeyLocator_Name) {
+ _LOG_DEBUG("Data signed with: " << data.getSignature().getKeyLocator().getName());
+ }
+ }
m_nlsr.getValidator().validate(data,
ndn::bind(&HelloProtocol::onContentValidated, this, _1),
ndn::bind(&HelloProtocol::onContentValidationFailed,
@@ -175,7 +181,7 @@
{
/* data name: /<neighbor>/NLSR/INFO/<router>/<version> */
ndn::Name dataName = data->getName();
- _LOG_DEBUG("Data received for name: " << dataName);
+ _LOG_DEBUG("Data validation successful for INFO(name): " << dataName);
if (dataName.get(-3).toUri() == INFO_COMPONENT) {
ndn::Name neighbor = dataName.getPrefix(-4);
int oldStatus = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
@@ -217,7 +223,7 @@
ndn::bind(&HelloProtocol::onRegistrationSuccess,
this, _1, adjName),
ndn::bind(&HelloProtocol::onRegistrationFailure,
- this, _1, _2));
+ this, _1, _2, adjName));
m_nlsr.getFib().registerPrefix(m_nlsr.getConfParameter().getChronosyncPrefix(),
faceUri, linkCost, timeout);
m_nlsr.getFib().registerPrefix(m_nlsr.getConfParameter().getLsaPrefix(),
@@ -245,9 +251,38 @@
}
void
-HelloProtocol::onRegistrationFailure(uint32_t code, const std::string& error)
+HelloProtocol::onRegistrationFailure(uint32_t code, const std::string& error,
+ const ndn::Name& name)
{
_LOG_DEBUG(error << " (code: " << code << ")");
+ /*
+ * If NLSR can not create face for given faceUri then it will treat this
+ * failure as one INFO interest timed out. So that NLSR can move on with
+ * building Adj Lsa and calculate routing table. NLSR does not build Adj
+ * Lsa unless all the neighbors are ACTIVE or DEAD. For considering the
+ * missconfigured(link) neighbour dead this is required.
+ */
+ Adjacent *adjacent = m_nlsr.getAdjacencyList().findAdjacent(name);
+ if (adjacent != 0) {
+ adjacent->setInterestTimedOutNo(adjacent->getInterestTimedOutNo() + 1);
+ int status = adjacent->getStatus();
+ uint32_t infoIntTimedOutCount = adjacent->getInterestTimedOutNo();
+
+ if (infoIntTimedOutCount == m_nlsr.getConfParameter().getInterestRetryNumber()) {
+ if ( status == 1) {
+ adjacent->setStatus(0);
+ }
+ m_nlsr.incrementAdjBuildCount();
+ if (m_nlsr.getIsBuildAdjLsaSheduled() == false) {
+ _LOG_DEBUG("Scheduling scheduledAdjLsaBuild");
+ m_nlsr.setIsBuildAdjLsaSheduled(true);
+ // event here
+ m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
+ ndn::bind(&Lsdb::scheduledAdjLsaBuild,
+ &m_nlsr.getLsdb()));
+ }
+ }
+ }
}
} //namespace nlsr