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
diff --git a/src/hello-protocol.hpp b/src/hello-protocol.hpp
index 063e6a8..b1ccd56 100644
--- a/src/hello-protocol.hpp
+++ b/src/hello-protocol.hpp
@@ -68,7 +68,8 @@
const std::string& msg);
void
- onRegistrationFailure(uint32_t code, const std::string& error);
+ onRegistrationFailure(uint32_t code, const std::string& error,
+ const ndn::Name& name);
void
onRegistrationSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index 5076f5e..c5aea44 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -752,8 +752,10 @@
Lsdb::expressInterest(const ndn::Name& interestName, uint32_t interestLifeTime,
uint32_t timeoutCount)
{
- _LOG_DEBUG("Expressing Interest for LSA(name): " << interestName);
ndn::Interest interest(interestName);
+ uint64_t interestedLsSeqNo = interestName[-1].toNumber();
+ _LOG_DEBUG("Expressing Interest for LSA(name): " << interestName <<
+ " Seq number: " << interestedLsSeqNo );
interest.setInterestLifetime(ndn::time::seconds(interestLifeTime));
interest.setMustBeFresh(true);
m_nlsr.getNlsrFace().expressInterest(interest,
@@ -779,6 +781,7 @@
interest.getName().size() - lsaPosition - 3));
interestedLsType = intName[-2].toUri();
interestedLsSeqNo = intName[-1].toNumber();
+ _LOG_DEBUG("LSA sequence number from interest: " << interestedLsSeqNo);
if (interestedLsType == "name") {
processInterestForNameLsa(interest,
origRouter.append(interestedLsType),
@@ -811,7 +814,10 @@
data->setFreshnessPeriod(ndn::time::seconds(10));
data->setContent(reinterpret_cast<const uint8_t*>(content.c_str()), content.size());
m_nlsr.getKeyChain().sign(*data, m_nlsr.getDefaultCertName());
+ ndn::SignatureSha256WithRsa signature(data->getSignature());
+ ndn::Name signingCertName = signature.getKeyLocator().getName();
_LOG_DEBUG("Sending data for LSA(name): " << interest.getName());
+ _LOG_DEBUG("Data signed with: " << signingCertName);
m_nlsr.getNlsrFace().put(*data);
}
@@ -860,6 +866,12 @@
void
Lsdb::onContent(const ndn::Interest& interest, const ndn::Data& data)
{
+ _LOG_DEBUG("Received data for LSA(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(&Lsdb::onContentValidated, this, _1),
ndn::bind(&Lsdb::onContentValidationFailed, this, _1, _2));
@@ -870,7 +882,7 @@
Lsdb::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
{
const ndn::Name& dataName = data->getName();
- _LOG_DEBUG("Data received for LSA(name): " << dataName);
+ _LOG_DEBUG("Data validation successful for LSA(name): " << dataName);
string dataContent(reinterpret_cast<const char*>(data->getContent().value()));
string chkString("LSA");
int32_t lsaPosition = util::getNameComponentPosition(dataName, chkString);