Switch to Face::getIoContext() and simplify some code
Change-Id: Iba49171f6e59ead02283e8f975219ab97fcbeb00
diff --git a/src/hello-protocol.cpp b/src/hello-protocol.cpp
index ec03da7..49722fe 100644
--- a/src/hello-protocol.cpp
+++ b/src/hello-protocol.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, The University of Memphis,
+ * Copyright (c) 2014-2023, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -34,7 +34,7 @@
ConfParameter& confParam, RoutingTable& routingTable,
Lsdb& lsdb)
: m_face(face)
- , m_scheduler(m_face.getIoService())
+ , m_scheduler(m_face.getIoContext())
, m_keyChain(keyChain)
, m_signingInfo(confParam.getSigningInfo())
, m_confParam(confParam)
@@ -72,8 +72,7 @@
interest.setCanBePrefix(true);
m_face.expressInterest(interest,
std::bind(&HelloProtocol::onContent, this, _1, _2),
- [this, seconds] (const ndn::Interest& interest, const ndn::lp::Nack& nack)
- {
+ [this, seconds] (const auto& interest, const auto& nack) {
NDN_LOG_TRACE("Received Nack with reason: " << nack.getReason());
NDN_LOG_TRACE("Will treat as timeout in " << 2 * seconds << " seconds");
m_scheduler.schedule(ndn::time::seconds(2 * seconds),
@@ -89,7 +88,6 @@
HelloProtocol::sendHelloInterest(const ndn::Name& neighbor)
{
auto adjacent = m_adjacencyList.findAdjacent(neighbor);
-
if (adjacent == m_adjacencyList.end()) {
return;
}
@@ -119,10 +117,10 @@
// increment RCV_HELLO_INTEREST
hpIncrementSignal(Statistics::PacketType::RCV_HELLO_INTEREST);
- NLSR_LOG_DEBUG("Interest Received for Name: " << interestName);
+ NLSR_LOG_DEBUG("Interest received for Name: " << interestName);
if (interestName.get(-2).toUri() != INFO_COMPONENT) {
- NLSR_LOG_DEBUG("INFO_COMPONENT not found or interestName: " << interestName
- << " does not match expression");
+ NLSR_LOG_DEBUG("INFO_COMPONENT not found or Interest Name " << interestName
+ << " does not match expression");
return;
}
@@ -130,9 +128,9 @@
neighbor.wireDecode(interestName.get(-1).blockFromValue());
NLSR_LOG_DEBUG("Neighbor: " << neighbor);
if (m_adjacencyList.isNeighbor(neighbor)) {
- std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>();
+ auto data = std::make_shared<ndn::Data>();
data->setName(ndn::Name(interest.getName()).appendVersion());
- data->setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec
+ data->setFreshnessPeriod(10_s);
data->setContent(ndn::make_span(reinterpret_cast<const uint8_t*>(INFO_COMPONENT.data()),
INFO_COMPONENT.size()));
@@ -233,8 +231,8 @@
m_adjacencyList.setTimedOutInterestCount(neighbor, 0);
Adjacent::Status newStatus = m_adjacencyList.getStatusOfNeighbor(neighbor);
- NLSR_LOG_DEBUG("Neighbor : " << neighbor);
- NLSR_LOG_DEBUG("Old Status: " << oldStatus << " New Status: " << newStatus);
+ NLSR_LOG_DEBUG("Neighbor: " << neighbor);
+ NLSR_LOG_DEBUG("Old Status: " << oldStatus << ", New Status: " << newStatus);
// change in Adjacency list
if ((oldStatus - newStatus) != 0) {
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
@@ -254,7 +252,7 @@
HelloProtocol::onContentValidationFailed(const ndn::Data& data,
const ndn::security::ValidationError& ve)
{
- NLSR_LOG_DEBUG("Validation Error: " << ve);
+ NLSR_LOG_DEBUG("Validation error: " << ve);
}
} // namespace nlsr