src: Update info message name
Changed "info" component to "INFO" and added "NLSR" component
so now info interest is of form /<neighbor>/NLSR/INFO/<router>
Change-Id: I8458fd7f911d660ffeee7e8e928d25ce3259c01b
diff --git a/src/hello-protocol.cpp b/src/hello-protocol.cpp
index ce1f391..1cd86ae 100644
--- a/src/hello-protocol.cpp
+++ b/src/hello-protocol.cpp
@@ -30,7 +30,8 @@
INIT_LOGGER("HelloProtocol");
-const std::string HelloProtocol::INFO_COMPONENT="info";
+const std::string HelloProtocol::INFO_COMPONENT = "INFO";
+const std::string HelloProtocol::NLSR_COMPONENT = "NLSR";
void
HelloProtocol::expressInterest(const ndn::Name& interestName, uint32_t seconds)
@@ -53,7 +54,9 @@
std::list<Adjacent> adjList = m_nlsr.getAdjacencyList().getAdjList();
for (std::list<Adjacent>::iterator it = adjList.begin(); it != adjList.end();
++it) {
+ /* interest name: /<neighbor>/NLSR/INFO/<router> */
ndn::Name interestName = (*it).getName() ;
+ interestName.append(NLSR_COMPONENT);
interestName.append(INFO_COMPONENT);
interestName.append(m_nlsr.getConfParameter().getRouterPrefix().wireEncode());
expressInterest(interestName,
@@ -74,6 +77,7 @@
HelloProtocol::processInterest(const ndn::Name& name,
const ndn::Interest& interest)
{
+ /* interest name: /<neighbor>/NLSR/INFO/<router> */
const ndn::Name interestName = interest.getName();
_LOG_DEBUG("Interest Received for Name: " << interestName);
if (interestName.get(-2).toUri() != INFO_COMPONENT) {
@@ -92,7 +96,9 @@
m_nlsr.getNlsrFace().put(data);
int status = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
if (status == 0) {
+ /* interest name: /<neighbor>/NLSR/INFO/<router> */
ndn::Name interestName(neighbor);
+ interestName.append(NLSR_COMPONENT);
interestName.append(INFO_COMPONENT);
interestName.append(m_nlsr.getConfParameter().getRouterPrefix().wireEncode());
expressInterest(interestName,
@@ -104,12 +110,13 @@
void
HelloProtocol::processInterestTimedOut(const ndn::Interest& interest)
{
+ /* interest name: /<neighbor>/NLSR/INFO/<router> */
const ndn::Name interestName(interest.getName());
_LOG_DEBUG("Interest timed out for Name: " << interestName);
if (interestName.get(-2).toUri() != INFO_COMPONENT) {
return;
}
- ndn::Name neighbor = interestName.getPrefix(-2);
+ ndn::Name neighbor = interestName.getPrefix(-3);
_LOG_DEBUG("Neighbor: " << neighbor);
m_nlsr.getAdjacencyList().incrementTimedOutInterestCount(neighbor);
int status = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
@@ -118,7 +125,9 @@
_LOG_DEBUG("Status: " << status);
_LOG_DEBUG("Info Interest Timed out: " << infoIntTimedOutCount);
if ((infoIntTimedOutCount < m_nlsr.getConfParameter().getInterestRetryNumber())) {
+ /* interest name: /<neighbor>/NLSR/INFO/<router> */
ndn::Name interestName(neighbor);
+ interestName.append(NLSR_COMPONENT);
interestName.append(INFO_COMPONENT);
interestName.append(m_nlsr.getConfParameter().getRouterPrefix().wireEncode());
expressInterest(interestName,
@@ -151,10 +160,11 @@
void
HelloProtocol::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
{
+ /* data name: /<neighbor>/NLSR/INFO/<router>/<version> */
ndn::Name dataName = data->getName();
_LOG_DEBUG("Data received for name: " << dataName);
if (dataName.get(-3).toUri() == INFO_COMPONENT) {
- ndn::Name neighbor = dataName.getPrefix(-3);
+ ndn::Name neighbor = dataName.getPrefix(-4);
int oldStatus = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
m_nlsr.getAdjacencyList().setStatusOfNeighbor(neighbor, 1);
m_nlsr.getAdjacencyList().setTimedOutInterestCount(neighbor, 0);
diff --git a/src/hello-protocol.hpp b/src/hello-protocol.hpp
index ac0433a..5f1cc7d 100644
--- a/src/hello-protocol.hpp
+++ b/src/hello-protocol.hpp
@@ -70,6 +70,7 @@
private:
Nlsr& m_nlsr;
static const std::string INFO_COMPONENT;
+ static const std::string NLSR_COMPONENT;
};
} //namespace nlsr