Reduce usage of std::bind()
C++14 lambdas are easier to read, easier to debug,
and can usually be better optimized by the compiler.
Change-Id: I294f275904f91942a8de946fe63e77078a7608a6
diff --git a/daemon/face/face-system.cpp b/daemon/face/face-system.cpp
index 5601057..79cb436 100644
--- a/daemon/face/face-system.cpp
+++ b/daemon/face/face-system.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -94,7 +94,9 @@
void
FaceSystem::setConfigFile(ConfigFile& configFile)
{
- configFile.addSectionHandler(CFGSEC_FACESYSTEM, bind(&FaceSystem::processConfig, this, _1, _2, _3));
+ configFile.addSectionHandler(CFGSEC_FACESYSTEM, [this] (auto&&... args) {
+ processConfig(std::forward<decltype(args)>(args)...);
+ });
}
void
diff --git a/daemon/face/generic-link-service.cpp b/daemon/face/generic-link-service.cpp
index 819a91a..5ed4ac2 100644
--- a/daemon/face/generic-link-service.cpp
+++ b/daemon/face/generic-link-service.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -45,11 +45,11 @@
, m_reassembler(m_options.reassemblerOptions, this)
, m_reliability(m_options.reliabilityOptions, this)
, m_lastSeqNo(-2)
- , m_nextMarkTime(time::steady_clock::TimePoint::max())
+ , m_nextMarkTime(time::steady_clock::time_point::max())
, m_nMarkedSinceInMarkingState(0)
{
- m_reassembler.beforeTimeout.connect([this] (auto...) { ++this->nReassemblyTimeouts; });
- m_reliability.onDroppedInterest.connect([this] (const auto& i) { this->notifyDroppedInterest(i); });
+ m_reassembler.beforeTimeout.connect([this] (auto&&...) { ++nReassemblyTimeouts; });
+ m_reliability.onDroppedInterest.connect([this] (const auto& i) { notifyDroppedInterest(i); });
nReassembling.observe(&m_reassembler);
}
@@ -105,7 +105,7 @@
auto block = pkt.wireEncode();
if (mtu != MTU_UNLIMITED && block.size() > static_cast<size_t>(mtu)) {
- ++this->nOutOverMtu;
+ ++nOutOverMtu;
NFD_LOG_FACE_WARN("attempted to send packet over MTU limit");
return;
}
@@ -207,7 +207,7 @@
std::tie(isOk, frags) = m_fragmenter.fragmentPacket(pkt, mtu);
if (!isOk) {
// fragmentation failed (warning is logged by LpFragmenter)
- ++this->nFragmentationErrors;
+ ++nFragmentationErrors;
return;
}
}
@@ -261,7 +261,7 @@
if (static_cast<size_t>(sendQueueLength) > m_options.defaultCongestionThreshold) {
const auto now = time::steady_clock::now();
- if (m_nextMarkTime == time::steady_clock::TimePoint::max()) {
+ if (m_nextMarkTime == time::steady_clock::time_point::max()) {
m_nextMarkTime = now + m_options.baseCongestionMarkingInterval;
}
// Mark packet if sendQueue stays above target for one interval
@@ -279,10 +279,10 @@
m_nextMarkTime += interval;
}
}
- else if (m_nextMarkTime != time::steady_clock::TimePoint::max()) {
+ else if (m_nextMarkTime != time::steady_clock::time_point::max()) {
// Congestion incident has ended, so reset
NFD_LOG_FACE_DEBUG("Send queue length dropped below congestion threshold");
- m_nextMarkTime = time::steady_clock::TimePoint::max();
+ m_nextMarkTime = time::steady_clock::time_point::max();
m_nMarkedSinceInMarkingState = 0;
}
}
@@ -296,7 +296,7 @@
if (m_options.reliabilityOptions.isEnabled) {
if (!m_reliability.processIncomingPacket(pkt)) {
NFD_LOG_FACE_TRACE("received duplicate fragment: DROP");
- ++this->nDuplicateSequence;
+ ++nDuplicateSequence;
return;
}
}
@@ -321,7 +321,7 @@
}
}
catch (const tlv::Error& e) {
- ++this->nInLpInvalid;
+ ++nInLpInvalid;
NFD_LOG_FACE_WARN("packet parse error (" << e.what() << "): DROP");
}
}
@@ -344,13 +344,13 @@
this->decodeData(netPkt, firstPkt, endpointId);
break;
default:
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("unrecognized network-layer packet TLV-TYPE " << netPkt.type() << ": DROP");
return;
}
}
catch (const tlv::Error& e) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("packet parse error (" << e.what() << "): DROP");
}
}
@@ -376,7 +376,7 @@
}
if (firstPkt.has<lp::CachePolicyField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received CachePolicy with Interest: DROP");
return;
}
@@ -399,7 +399,7 @@
}
if (firstPkt.has<lp::PrefixAnnouncementField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received PrefixAnnouncement with Interest: DROP");
return;
}
@@ -421,13 +421,13 @@
auto data = make_shared<Data>(netPkt);
if (firstPkt.has<lp::NackField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received Nack with Data: DROP");
return;
}
if (firstPkt.has<lp::NextHopFaceIdField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received NextHopFaceId with Data: DROP");
return;
}
@@ -448,7 +448,7 @@
}
if (firstPkt.has<lp::NonDiscoveryField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received NonDiscovery with Data: DROP");
return;
}
@@ -476,13 +476,13 @@
nack.setHeader(firstPkt.get<lp::NackField>());
if (firstPkt.has<lp::NextHopFaceIdField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received NextHopFaceId with Nack: DROP");
return;
}
if (firstPkt.has<lp::CachePolicyField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received CachePolicy with Nack: DROP");
return;
}
@@ -496,13 +496,13 @@
}
if (firstPkt.has<lp::NonDiscoveryField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received NonDiscovery with Nack: DROP");
return;
}
if (firstPkt.has<lp::PrefixAnnouncementField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received PrefixAnnouncement with Nack: DROP");
return;
}
diff --git a/daemon/face/network-predicate.cpp b/daemon/face/network-predicate.cpp
index 31a2cf8..07de63c 100644
--- a/daemon/face/network-predicate.cpp
+++ b/daemon/face/network-predicate.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -198,8 +198,10 @@
bool
NetworkInterfacePredicate::operator()(const ndn::net::NetworkInterface& netif) const
{
- return std::any_of(m_whitelist.begin(), m_whitelist.end(), bind(&doesNetifMatchRule, std::cref(netif), _1)) &&
- std::none_of(m_blacklist.begin(), m_blacklist.end(), bind(&doesNetifMatchRule, std::cref(netif), _1));
+ return std::any_of(m_whitelist.begin(), m_whitelist.end(),
+ [&netif] (const auto& rule) { return doesNetifMatchRule(netif, rule); }) &&
+ std::none_of(m_blacklist.begin(), m_blacklist.end(),
+ [&netif] (const auto& rule) { return doesNetifMatchRule(netif, rule); });
}
static bool
@@ -219,8 +221,10 @@
bool
IpAddressPredicate::operator()(const boost::asio::ip::address& address) const
{
- return std::any_of(m_whitelist.begin(), m_whitelist.end(), bind(&doesAddressMatchRule, std::cref(address), _1)) &&
- std::none_of(m_blacklist.begin(), m_blacklist.end(), bind(&doesAddressMatchRule, std::cref(address), _1));
+ return std::any_of(m_whitelist.begin(), m_whitelist.end(),
+ [&address] (const auto& rule) { return doesAddressMatchRule(address, rule); }) &&
+ std::none_of(m_blacklist.begin(), m_blacklist.end(),
+ [&address] (const auto& rule) { return doesAddressMatchRule(address, rule); });
}
} // namespace face
diff --git a/daemon/face/tcp-factory.cpp b/daemon/face/tcp-factory.cpp
index f45d786..89e34d5 100644
--- a/daemon/face/tcp-factory.cpp
+++ b/daemon/face/tcp-factory.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -200,8 +200,9 @@
if (it != m_channels.end())
return it->second;
- auto channel = make_shared<TcpChannel>(endpoint, m_wantCongestionMarking,
- bind(&TcpFactory::determineFaceScopeFromAddresses, this, _1, _2));
+ auto channel = make_shared<TcpChannel>(endpoint, m_wantCongestionMarking, [this] (auto&&... args) {
+ return determineFaceScopeFromAddresses(std::forward<decltype(args)>(args)...);
+ });
m_channels[endpoint] = channel;
return channel;
}
diff --git a/daemon/face/udp-factory.cpp b/daemon/face/udp-factory.cpp
index 9eabd42..8f7f77c 100644
--- a/daemon/face/udp-factory.cpp
+++ b/daemon/face/udp-factory.cpp
@@ -434,7 +434,7 @@
NFD_LOG_DEBUG("Not creating multicast faces on " << netif->getName() << ": no viable IP address");
// keep an eye on new addresses
m_netifConns[netif->getIndex()].addrAddConn =
- netif->onAddressAdded.connect([=] (auto...) { this->applyMcastConfigToNetif(netif); });
+ netif->onAddressAdded.connect([=] (auto&&...) { this->applyMcastConfigToNetif(netif); });
return {};
}
diff --git a/daemon/face/websocket-channel.cpp b/daemon/face/websocket-channel.cpp
index 13f6f38..957c9ad 100644
--- a/daemon/face/websocket-channel.cpp
+++ b/daemon/face/websocket-channel.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -53,13 +53,13 @@
}
return websocketpp::lib::error_code{};
});
- m_server.set_open_handler(bind(&WebSocketChannel::handleOpen, this, _1));
- m_server.set_close_handler(bind(&WebSocketChannel::handleClose, this, _1));
- m_server.set_message_handler(bind(&WebSocketChannel::handleMessage, this, _1, _2));
+ m_server.set_open_handler(std::bind(&WebSocketChannel::handleOpen, this, _1));
+ m_server.set_close_handler(std::bind(&WebSocketChannel::handleClose, this, _1));
+ m_server.set_message_handler(std::bind(&WebSocketChannel::handleMessage, this, _1, _2));
// Detect disconnections using ping-pong messages
- m_server.set_pong_handler(bind(&WebSocketChannel::handlePong, this, _1));
- m_server.set_pong_timeout_handler(bind(&WebSocketChannel::handlePongTimeout, this, _1));
+ m_server.set_pong_handler(std::bind(&WebSocketChannel::handlePong, this, _1));
+ m_server.set_pong_timeout_handler(std::bind(&WebSocketChannel::handlePongTimeout, this, _1));
// Always set SO_REUSEADDR flag
m_server.set_reuse_addr(true);
diff --git a/daemon/fw/algorithm.cpp b/daemon/fw/algorithm.cpp
index a5d692f..a4d864b 100644
--- a/daemon/fw/algorithm.cpp
+++ b/daemon/fw/algorithm.cpp
@@ -84,7 +84,7 @@
bool
hasPendingOutRecords(const pit::Entry& pitEntry)
{
- time::steady_clock::TimePoint now = time::steady_clock::now();
+ auto now = time::steady_clock::now();
return std::any_of(pitEntry.out_begin(), pitEntry.out_end(),
[&now] (const pit::OutRecord& outRecord) {
return outRecord.getExpiry() >= now &&
@@ -92,7 +92,7 @@
});
}
-time::steady_clock::TimePoint
+time::steady_clock::time_point
getLastOutgoing(const pit::Entry& pitEntry)
{
pit::OutRecordCollection::const_iterator lastOutgoing = std::max_element(
@@ -111,7 +111,7 @@
const shared_ptr<pit::Entry>& pitEntry)
{
auto found = nexthops.end();
- auto earliestRenewed = time::steady_clock::TimePoint::max();
+ auto earliestRenewed = time::steady_clock::time_point::max();
for (auto it = nexthops.begin(); it != nexthops.end(); ++it) {
if (!isNextHopEligible(inFace, interest, *it, pitEntry))
@@ -132,7 +132,7 @@
const fib::NextHop& nexthop,
const shared_ptr<pit::Entry>& pitEntry,
bool wantUnused,
- time::steady_clock::TimePoint now)
+ time::steady_clock::time_point now)
{
const Face& outFace = nexthop.getFace();
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index 3683734..d984f0c 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -40,7 +40,7 @@
NFD_LOG_INIT(Forwarder);
-const std::string CFGSEC_FORWARDER = "forwarder";
+const std::string CFG_FORWARDER = "forwarder";
static Name
getDefaultStrategyName()
@@ -607,7 +607,9 @@
void
Forwarder::setConfigFile(ConfigFile& configFile)
{
- configFile.addSectionHandler(CFGSEC_FORWARDER, bind(&Forwarder::processConfig, this, _1, _2, _3));
+ configFile.addSectionHandler(CFG_FORWARDER, [this] (auto&&... args) {
+ processConfig(std::forward<decltype(args)>(args)...);
+ });
}
void
@@ -618,10 +620,10 @@
for (const auto& pair : configSection) {
const std::string& key = pair.first;
if (key == "default_hop_limit") {
- config.defaultHopLimit = ConfigFile::parseNumber<uint8_t>(pair, CFGSEC_FORWARDER);
+ config.defaultHopLimit = ConfigFile::parseNumber<uint8_t>(pair, CFG_FORWARDER);
}
else {
- NDN_THROW(ConfigFile::Error("Unrecognized option " + CFGSEC_FORWARDER + "." + key));
+ NDN_THROW(ConfigFile::Error("Unrecognized option " + CFG_FORWARDER + "." + key));
}
}
diff --git a/daemon/fw/retx-suppression-fixed.cpp b/daemon/fw/retx-suppression-fixed.cpp
index dddd742..50ade91 100644
--- a/daemon/fw/retx-suppression-fixed.cpp
+++ b/daemon/fw/retx-suppression-fixed.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -44,9 +44,9 @@
return RetxSuppressionResult::NEW;
}
- time::steady_clock::TimePoint lastOutgoing = getLastOutgoing(pitEntry);
- time::steady_clock::TimePoint now = time::steady_clock::now();
- time::steady_clock::Duration sinceLastOutgoing = now - lastOutgoing;
+ auto lastOutgoing = getLastOutgoing(pitEntry);
+ auto now = time::steady_clock::now();
+ auto sinceLastOutgoing = now - lastOutgoing;
bool shouldSuppress = sinceLastOutgoing < m_minRetxInterval;
return shouldSuppress ? RetxSuppressionResult::SUPPRESS : RetxSuppressionResult::FORWARD;
}
diff --git a/daemon/fw/strategy.cpp b/daemon/fw/strategy.cpp
index 9cfb3be..8762e24 100644
--- a/daemon/fw/strategy.cpp
+++ b/daemon/fw/strategy.cpp
@@ -291,13 +291,13 @@
return fibEntry;
}
- const DelegationList& fh = interest.getForwardingHint();
+ const auto& fh = interest.getForwardingHint();
// Forwarding hint should have been stripped by incoming Interest pipeline when reaching producer region
BOOST_ASSERT(!m_forwarder.getNetworkRegionTable().isInProducerRegion(fh));
const fib::Entry* fibEntry = nullptr;
- for (const Delegation& del : fh) {
- fibEntry = &fib.findLongestPrefixMatch(del.name);
+ for (const auto& delegation : fh) {
+ fibEntry = &fib.findLongestPrefixMatch(delegation.name);
if (fibEntry->hasNextHops()) {
if (fibEntry->getPrefix().size() == 0) {
// in consumer region, return the default route
@@ -305,7 +305,7 @@
}
else {
// in default-free zone, use the first delegation that finds a FIB entry
- NFD_LOG_TRACE("lookupFib delegation=" << del.name << " found=" << fibEntry->getPrefix());
+ NFD_LOG_TRACE("lookupFib delegation=" << delegation.name << " found=" << fibEntry->getPrefix());
}
return *fibEntry;
}
diff --git a/daemon/main.cpp b/daemon/main.cpp
index 1b529fb..6d29646 100644
--- a/daemon/main.cpp
+++ b/daemon/main.cpp
@@ -82,15 +82,15 @@
NfdRunner(const std::string& configFile)
: m_nfd(configFile, m_nfdKeyChain)
, m_configFile(configFile)
- , m_terminationSignalSet(getGlobalIoService())
- , m_reloadSignalSet(getGlobalIoService())
+ , m_terminateSignals(getGlobalIoService(), SIGINT, SIGTERM)
+ , m_reloadSignals(getGlobalIoService(), SIGHUP)
{
- m_terminationSignalSet.add(SIGINT);
- m_terminationSignalSet.add(SIGTERM);
- m_terminationSignalSet.async_wait(bind(&NfdRunner::terminate, this, _1, _2));
-
- m_reloadSignalSet.add(SIGHUP);
- m_reloadSignalSet.async_wait(bind(&NfdRunner::reload, this, _1, _2));
+ m_terminateSignals.async_wait([this] (auto&&... args) {
+ terminate(std::forward<decltype(args)>(args)...);
+ });
+ m_reloadSignals.async_wait([this] (auto&&... args) {
+ reload(std::forward<decltype(args)>(args)...);
+ });
}
void
@@ -210,7 +210,9 @@
m_nfd.reloadConfigFile();
systemdNotify("READY=1");
- m_reloadSignalSet.async_wait(bind(&NfdRunner::reload, this, _1, _2));
+ m_reloadSignals.async_wait([this] (auto&&... args) {
+ reload(std::forward<decltype(args)>(args)...);
+ });
}
private:
@@ -218,8 +220,8 @@
Nfd m_nfd;
std::string m_configFile;
- boost::asio::signal_set m_terminationSignalSet;
- boost::asio::signal_set m_reloadSignalSet;
+ boost::asio::signal_set m_terminateSignals;
+ boost::asio::signal_set m_reloadSignals;
};
static void
diff --git a/daemon/mgmt/command-authenticator.cpp b/daemon/mgmt/command-authenticator.cpp
index 2196889..7c3cb23 100644
--- a/daemon/mgmt/command-authenticator.cpp
+++ b/daemon/mgmt/command-authenticator.cpp
@@ -107,8 +107,9 @@
void
CommandAuthenticator::setConfigFile(ConfigFile& configFile)
{
- configFile.addSectionHandler("authorizations",
- bind(&CommandAuthenticator::processConfig, this, _1, _2, _3));
+ configFile.addSectionHandler("authorizations", [this] (auto&&... args) {
+ processConfig(std::forward<decltype(args)>(args)...);
+ });
}
void
diff --git a/daemon/mgmt/cs-manager.cpp b/daemon/mgmt/cs-manager.cpp
index 50c3001..eaf2cda 100644
--- a/daemon/mgmt/cs-manager.cpp
+++ b/daemon/mgmt/cs-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -40,11 +40,11 @@
, m_fwCounters(fwCounters)
{
registerCommandHandler<ndn::nfd::CsConfigCommand>("config",
- bind(&CsManager::changeConfig, this, _4, _5));
+ std::bind(&CsManager::changeConfig, this, _4, _5));
registerCommandHandler<ndn::nfd::CsEraseCommand>("erase",
- bind(&CsManager::erase, this, _4, _5));
+ std::bind(&CsManager::erase, this, _4, _5));
- registerStatusDatasetHandler("info", bind(&CsManager::serveInfo, this, _1, _2, _3));
+ registerStatusDatasetHandler("info", std::bind(&CsManager::serveInfo, this, _1, _2, _3));
}
void
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index a6ff3df..1d38f43 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -47,14 +47,17 @@
, m_faceTable(faceSystem.getFaceTable())
{
// register handlers for ControlCommand
- registerCommandHandler<ndn::nfd::FaceCreateCommand>("create", bind(&FaceManager::createFace, this, _4, _5));
- registerCommandHandler<ndn::nfd::FaceUpdateCommand>("update", bind(&FaceManager::updateFace, this, _3, _4, _5));
- registerCommandHandler<ndn::nfd::FaceDestroyCommand>("destroy", bind(&FaceManager::destroyFace, this, _4, _5));
+ registerCommandHandler<ndn::nfd::FaceCreateCommand>("create",
+ std::bind(&FaceManager::createFace, this, _4, _5));
+ registerCommandHandler<ndn::nfd::FaceUpdateCommand>("update",
+ std::bind(&FaceManager::updateFace, this, _3, _4, _5));
+ registerCommandHandler<ndn::nfd::FaceDestroyCommand>("destroy",
+ std::bind(&FaceManager::destroyFace, this, _4, _5));
// register handlers for StatusDataset
- registerStatusDatasetHandler("list", bind(&FaceManager::listFaces, this, _3));
- registerStatusDatasetHandler("channels", bind(&FaceManager::listChannels, this, _3));
- registerStatusDatasetHandler("query", bind(&FaceManager::queryFaces, this, _2, _3));
+ registerStatusDatasetHandler("list", std::bind(&FaceManager::listFaces, this, _3));
+ registerStatusDatasetHandler("channels", std::bind(&FaceManager::listChannels, this, _3));
+ registerStatusDatasetHandler("query", std::bind(&FaceManager::queryFaces, this, _2, _3));
// register notification stream
m_postNotification = registerNotificationStream("events");
@@ -359,13 +362,13 @@
}
static ndn::nfd::FaceStatus
-makeFaceStatus(const Face& face, const time::steady_clock::TimePoint& now)
+makeFaceStatus(const Face& face, const time::steady_clock::time_point& now)
{
ndn::nfd::FaceStatus status;
copyFaceProperties(face, status);
auto expirationTime = face.getExpirationTime();
- if (expirationTime != time::steady_clock::TimePoint::max()) {
+ if (expirationTime != time::steady_clock::time_point::max()) {
status.setExpirationPeriod(std::max(0_ms,
time::duration_cast<time::milliseconds>(expirationTime - now)));
}
diff --git a/daemon/mgmt/fib-manager.cpp b/daemon/mgmt/fib-manager.cpp
index c048da5..f8a99d8 100644
--- a/daemon/mgmt/fib-manager.cpp
+++ b/daemon/mgmt/fib-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -45,11 +45,11 @@
, m_faceTable(faceTable)
{
registerCommandHandler<ndn::nfd::FibAddNextHopCommand>("add-nexthop",
- bind(&FibManager::addNextHop, this, _2, _3, _4, _5));
+ std::bind(&FibManager::addNextHop, this, _2, _3, _4, _5));
registerCommandHandler<ndn::nfd::FibRemoveNextHopCommand>("remove-nexthop",
- bind(&FibManager::removeNextHop, this, _2, _3, _4, _5));
+ std::bind(&FibManager::removeNextHop, this, _2, _3, _4, _5));
- registerStatusDatasetHandler("list", bind(&FibManager::listEntries, this, _1, _2, _3));
+ registerStatusDatasetHandler("list", std::bind(&FibManager::listEntries, this, _1, _2, _3));
}
void
diff --git a/daemon/mgmt/forwarder-status-manager.cpp b/daemon/mgmt/forwarder-status-manager.cpp
index 5d4cb4d..818d054 100644
--- a/daemon/mgmt/forwarder-status-manager.cpp
+++ b/daemon/mgmt/forwarder-status-manager.cpp
@@ -35,7 +35,7 @@
, m_startTimestamp(time::system_clock::now())
{
m_dispatcher.addStatusDataset("status/general", ndn::mgmt::makeAcceptAllAuthorization(),
- bind(&ForwarderStatusManager::listGeneralStatus, this, _1, _2, _3));
+ std::bind(&ForwarderStatusManager::listGeneralStatus, this, _1, _2, _3));
}
ndn::nfd::ForwarderStatus
diff --git a/daemon/mgmt/manager-base.cpp b/daemon/mgmt/manager-base.cpp
index 49f5b8b..a39bbd6 100644
--- a/daemon/mgmt/manager-base.cpp
+++ b/daemon/mgmt/manager-base.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -59,7 +59,8 @@
}
void
-ManagerBase::extractRequester(const Interest& interest, ndn::mgmt::AcceptContinuation accept)
+ManagerBase::extractRequester(const Interest& interest,
+ const ndn::mgmt::AcceptContinuation& accept)
{
const Name& interestName = interest.getName();
@@ -103,7 +104,7 @@
const ControlCommandHandler& handler,
const Name& prefix, const Interest& interest,
const ndn::mgmt::ControlParameters& params,
- ndn::mgmt::CommandContinuation done)
+ const ndn::mgmt::CommandContinuation& done)
{
BOOST_ASSERT(dynamic_cast<const ControlParameters*>(¶ms) != nullptr);
diff --git a/daemon/mgmt/manager-base.hpp b/daemon/mgmt/manager-base.hpp
index e061217..eeb55f5 100644
--- a/daemon/mgmt/manager-base.hpp
+++ b/daemon/mgmt/manager-base.hpp
@@ -97,10 +97,10 @@
* This is called after the signature has been validated.
*
* @param interest a request for ControlCommand
- * @param accept callback of successful validation, takes the requester string as a argument
+ * @param accept callback of successful validation, takes the requester string as argument
*/
- void
- extractRequester(const Interest& interest, ndn::mgmt::AcceptContinuation accept);
+ static void
+ extractRequester(const Interest& interest, const ndn::mgmt::AcceptContinuation& accept);
NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
/**
@@ -127,7 +127,7 @@
const ControlCommandHandler& handler,
const Name& prefix, const Interest& interest,
const ndn::mgmt::ControlParameters& params,
- ndn::mgmt::CommandContinuation done);
+ const ndn::mgmt::CommandContinuation& done);
/**
* @brief Generates the relative prefix for a handler by appending the verb name to the module name.
@@ -148,7 +148,7 @@
};
template<typename Command>
-inline void
+void
ManagerBase::registerCommandHandler(const std::string& verb,
const ControlCommandHandler& handler)
{
@@ -157,8 +157,8 @@
m_dispatcher.addControlCommand<ControlParameters>(
makeRelPrefix(verb),
makeAuthorization(verb),
- bind(&ManagerBase::validateParameters, std::cref(*command), _1),
- bind(&ManagerBase::handleCommand, command, handler, _1, _2, _3, _4));
+ [=] (const auto& params) { return validateParameters(*command, params); },
+ [=] (auto&&... args) { handleCommand(command, handler, std::forward<decltype(args)>(args)...); });
}
} // namespace nfd
diff --git a/daemon/mgmt/rib-manager.cpp b/daemon/mgmt/rib-manager.cpp
index 68b061e..4e444bf 100644
--- a/daemon/mgmt/rib-manager.cpp
+++ b/daemon/mgmt/rib-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -62,11 +62,11 @@
, m_isLocalhopEnabled(false)
{
registerCommandHandler<ndn::nfd::RibRegisterCommand>("register",
- bind(&RibManager::registerEntry, this, _2, _3, _4, _5));
+ std::bind(&RibManager::registerEntry, this, _2, _3, _4, _5));
registerCommandHandler<ndn::nfd::RibUnregisterCommand>("unregister",
- bind(&RibManager::unregisterEntry, this, _2, _3, _4, _5));
+ std::bind(&RibManager::unregisterEntry, this, _2, _3, _4, _5));
- registerStatusDatasetHandler("list", bind(&RibManager::listEntries, this, _1, _2, _3));
+ registerStatusDatasetHandler("list", std::bind(&RibManager::listEntries, this, _1, _2, _3));
}
void
@@ -104,7 +104,7 @@
}
NFD_LOG_INFO("Start monitoring face create/destroy events");
- m_faceMonitor.onNotification.connect(bind(&RibManager::onNotification, this, _1));
+ m_faceMonitor.onNotification.connect([this] (const auto& notif) { onNotification(notif); });
m_faceMonitor.start();
scheduleActiveFaceFetch(ACTIVE_FACE_FETCH_INTERVAL);
@@ -248,7 +248,7 @@
}
void
-RibManager::unregisterEntry(const Name& topPrefix, const Interest& interest,
+RibManager::unregisterEntry(const Name&, const Interest& interest,
ControlParameters parameters,
const ndn::mgmt::CommandContinuation& done)
{
@@ -265,7 +265,7 @@
}
void
-RibManager::listEntries(const Name& topPrefix, const Interest& interest,
+RibManager::listEntries(const Name&, const Interest& interest,
ndn::mgmt::StatusDatasetContext& context)
{
auto now = time::steady_clock::now();
@@ -304,7 +304,7 @@
}
ndn::mgmt::Authorization
-RibManager::makeAuthorization(const std::string& verb)
+RibManager::makeAuthorization(const std::string&)
{
return [this] (const Name& prefix, const Interest& interest,
const ndn::mgmt::ControlParameters* params,
@@ -316,8 +316,8 @@
auto& validator = prefix == LOCALHOST_TOP_PREFIX ? m_localhostValidator : m_localhopValidator;
validator.validate(interest,
- bind([&interest, this, accept] { extractRequester(interest, accept); }),
- bind([reject] { reject(ndn::mgmt::RejectReply::STATUS403); }));
+ [&interest, accept] (auto&&...) { extractRequester(interest, accept); },
+ [reject] (auto&&...) { reject(ndn::mgmt::RejectReply::STATUS403); });
};
}
@@ -429,8 +429,8 @@
NFD_LOG_DEBUG("Fetching active faces");
m_nfdController.fetch<ndn::nfd::FaceDataset>(
- bind(&RibManager::removeInvalidFaces, this, _1),
- bind(&RibManager::onFetchActiveFacesFailure, this, _1, _2),
+ std::bind(&RibManager::removeInvalidFaces, this, _1),
+ std::bind(&RibManager::onFetchActiveFacesFailure, this, _1, _2),
ndn::nfd::CommandOptions());
}
diff --git a/daemon/mgmt/strategy-choice-manager.cpp b/daemon/mgmt/strategy-choice-manager.cpp
index 169ce2e..9be09d2 100644
--- a/daemon/mgmt/strategy-choice-manager.cpp
+++ b/daemon/mgmt/strategy-choice-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -41,12 +41,12 @@
, m_table(strategyChoice)
{
registerCommandHandler<ndn::nfd::StrategyChoiceSetCommand>("set",
- bind(&StrategyChoiceManager::setStrategy, this, _4, _5));
+ std::bind(&StrategyChoiceManager::setStrategy, this, _4, _5));
registerCommandHandler<ndn::nfd::StrategyChoiceUnsetCommand>("unset",
- bind(&StrategyChoiceManager::unsetStrategy, this, _4, _5));
+ std::bind(&StrategyChoiceManager::unsetStrategy, this, _4, _5));
registerStatusDatasetHandler("list",
- bind(&StrategyChoiceManager::listChoices, this, _3));
+ std::bind(&StrategyChoiceManager::listChoices, this, _3));
}
void
diff --git a/daemon/mgmt/tables-config-section.cpp b/daemon/mgmt/tables-config-section.cpp
index e5383a4..f6adced 100644
--- a/daemon/mgmt/tables-config-section.cpp
+++ b/daemon/mgmt/tables-config-section.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,7 +28,7 @@
namespace nfd {
-const size_t TablesConfigSection::DEFAULT_CS_MAX_PACKETS = 65536;
+const size_t DEFAULT_CS_MAX_PACKETS = 65536;
TablesConfigSection::TablesConfigSection(Forwarder& forwarder)
: m_forwarder(forwarder)
@@ -39,8 +39,9 @@
void
TablesConfigSection::setConfigFile(ConfigFile& configFile)
{
- configFile.addSectionHandler("tables",
- bind(&TablesConfigSection::processConfig, this, _1, _2));
+ configFile.addSectionHandler("tables", [this] (auto&&... args) {
+ processConfig(std::forward<decltype(args)>(args)...);
+ });
}
void
@@ -58,7 +59,7 @@
}
void
-TablesConfigSection::processConfig(const ConfigSection& section, bool isDryRun)
+TablesConfigSection::processConfig(const ConfigSection& section, bool isDryRun, const std::string&)
{
size_t nCsMaxPackets = DEFAULT_CS_MAX_PACKETS;
OptionalConfigSection csMaxPacketsNode = section.get_child_optional("cs_max_packets");
diff --git a/daemon/mgmt/tables-config-section.hpp b/daemon/mgmt/tables-config-section.hpp
index c2cfec5..f551b78 100644
--- a/daemon/mgmt/tables-config-section.hpp
+++ b/daemon/mgmt/tables-config-section.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -83,7 +83,7 @@
private:
void
- processConfig(const ConfigSection& section, bool isDryRun);
+ processConfig(const ConfigSection& section, bool isDryRun, const std::string& filename);
void
processStrategyChoiceSection(const ConfigSection& section, bool isDryRun);
@@ -92,10 +92,7 @@
processNetworkRegionSection(const ConfigSection& section, bool isDryRun);
private:
- static const size_t DEFAULT_CS_MAX_PACKETS;
-
Forwarder& m_forwarder;
-
bool m_isConfigured;
};
diff --git a/daemon/rib/fib-updater.cpp b/daemon/rib/fib-updater.cpp
index 6e600e4..5208e61 100644
--- a/daemon/rib/fib-updater.cpp
+++ b/daemon/rib/fib-updater.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -95,13 +95,13 @@
const Name& prefix = update.getName();
const Route& route = update.getRoute();
- Rib::const_iterator it = m_rib.find(prefix);
+ auto it = m_rib.find(prefix);
// Name prefix exists
if (it != m_rib.end()) {
shared_ptr<const RibEntry> entry(it->second);
- RibEntry::const_iterator existingRoute = entry->findRoute(route);
+ auto existingRoute = entry->findRoute(route);
// Route will be new
if (existingRoute == entry->end()) {
@@ -114,8 +114,7 @@
// Route already exists
RibEntry entryCopy = *entry;
- Route& routeToUpdate = *(entryCopy.findRoute(route));
-
+ Route& routeToUpdate = *entryCopy.findRoute(route);
routeToUpdate.flags = route.flags;
routeToUpdate.cost = route.cost;
routeToUpdate.expires = route.expires;
@@ -149,16 +148,14 @@
const Name& prefix = update.getName();
const Route& route = update.getRoute();
- Rib::const_iterator ribIt = m_rib.find(prefix);
+ auto ribIt = m_rib.find(prefix);
// Name prefix exists
if (ribIt != m_rib.end()) {
shared_ptr<const RibEntry> entry(ribIt->second);
-
const bool hadCapture = entry->hasCapture();
- RibEntry::const_iterator existing = entry->findRoute(route);
-
+ auto existing = entry->findRoute(route);
if (existing != entry->end()) {
RibEntry temp = *entry;
@@ -240,8 +237,8 @@
.setName(update.name)
.setFaceId(update.faceId)
.setCost(update.cost),
- bind(&FibUpdater::onUpdateSuccess, this, update, onSuccess, onFailure),
- bind(&FibUpdater::onUpdateError, this, update, onSuccess, onFailure, _1, nTimeouts));
+ [=] (const auto&) { onUpdateSuccess(update, onSuccess, onFailure); },
+ [=] (const auto& resp) { onUpdateError(update, onSuccess, onFailure, resp, nTimeouts); });
}
void
@@ -254,12 +251,12 @@
ControlParameters()
.setName(update.name)
.setFaceId(update.faceId),
- bind(&FibUpdater::onUpdateSuccess, this, update, onSuccess, onFailure),
- bind(&FibUpdater::onUpdateError, this, update, onSuccess, onFailure, _1, nTimeouts));
+ [=] (const auto&) { onUpdateSuccess(update, onSuccess, onFailure); },
+ [=] (const auto& resp) { onUpdateError(update, onSuccess, onFailure, resp, nTimeouts); });
}
void
-FibUpdater::onUpdateSuccess(const FibUpdate update,
+FibUpdater::onUpdateSuccess(const FibUpdate& update,
const FibUpdateSuccessCallback& onSuccess,
const FibUpdateFailureCallback& onFailure)
{
@@ -280,7 +277,7 @@
}
void
-FibUpdater::onUpdateError(const FibUpdate update,
+FibUpdater::onUpdateError(const FibUpdate& update,
const FibUpdateSuccessCallback& onSuccess,
const FibUpdateFailureCallback& onFailure,
const ndn::nfd::ControlResponse& response, uint32_t nTimeouts)
@@ -310,14 +307,13 @@
}
void
-FibUpdater::addFibUpdate(FibUpdate update)
+FibUpdater::addFibUpdate(const FibUpdate& update)
{
FibUpdateList& updates = (update.faceId == m_batchFaceId) ? m_updatesForBatchFaceId :
m_updatesForNonBatchFaceId;
- // If an update with the same name and route already exists,
- // replace it
- FibUpdateList::iterator it = std::find_if(updates.begin(), updates.end(),
+ // If an update with the same name and route already exists, replace it
+ auto it = std::find_if(updates.begin(), updates.end(),
[&update] (const FibUpdate& other) {
return update.name == other.name && update.faceId == other.faceId;
});
@@ -400,7 +396,7 @@
// If there is an ancestor route which is the same as the new route, replace it
// with the new route
- Rib::RouteSet::iterator it = ancestorRoutes.find(route);
+ auto it = ancestorRoutes.find(route);
// There is a route that needs to be overwritten, erase and then replace
if (it != ancestorRoutes.end()) {
@@ -525,7 +521,7 @@
else {
// Look for an ancestor that was blocked previously
const Rib::RouteSet ancestorRoutes = m_rib.getAncestorRoutes(entry);
- Rib::RouteSet::iterator it = ancestorRoutes.find(route);
+ auto it = ancestorRoutes.find(route);
// If an ancestor is found, add it to children
if (it != ancestorRoutes.end()) {
@@ -616,7 +612,7 @@
if (!entry.hasCapture() && entry.getNRoutes() != 0) {
// If there is an ancestor route which is the same as the erased route, add that route
// to the current entry
- Rib::RouteSet::iterator it = ancestorRoutes.find(route);
+ auto it = ancestorRoutes.find(route);
if (it != ancestorRoutes.end()) {
addInheritedRoute(entry.getName(), *it);
diff --git a/daemon/rib/fib-updater.hpp b/daemon/rib/fib-updater.hpp
index 52f3d74..d43f50a 100644
--- a/daemon/rib/fib-updater.hpp
+++ b/daemon/rib/fib-updater.hpp
@@ -149,7 +149,7 @@
* the FIB update process is considered a success.
*/
void
- onUpdateSuccess(const FibUpdate update,
+ onUpdateSuccess(const FibUpdate& update,
const FibUpdateSuccessCallback& onSuccess,
const FibUpdateFailureCallback& onFailure);
@@ -169,7 +169,7 @@
* Otherwise, a non-recoverable error has occurred and an exception is thrown.
*/
void
- onUpdateError(const FibUpdate update,
+ onUpdateError(const FibUpdate& update,
const FibUpdateSuccessCallback& onSuccess,
const FibUpdateFailureCallback& onFailure,
const ndn::nfd::ControlResponse& response, uint32_t nTimeouts);
@@ -183,7 +183,7 @@
* Otherwise, the update is added to m_updatesForBatchNonFaceId.
*/
void
- addFibUpdate(const FibUpdate update);
+ addFibUpdate(const FibUpdate& update);
/** \brief creates records of the passed routes added to the entry and creates FIB updates
*/
diff --git a/daemon/rib/readvertise/nfd-rib-readvertise-destination.cpp b/daemon/rib/readvertise/nfd-rib-readvertise-destination.cpp
index a76aaed..0592040 100644
--- a/daemon/rib/readvertise/nfd-rib-readvertise-destination.cpp
+++ b/daemon/rib/readvertise/nfd-rib-readvertise-destination.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -44,10 +44,17 @@
, m_commandOptions(options)
, m_controlParameters(parameters)
{
- m_ribInsertConn = rib.afterInsertEntry.connect(
- std::bind(&NfdRibReadvertiseDestination::handleRibInsert, this, _1));
- m_ribEraseConn = rib.afterEraseEntry.connect(
- std::bind(&NfdRibReadvertiseDestination::handleRibErase, this, _1));
+ m_ribInsertConn = rib.afterInsertEntry.connect([this] (const Name& name) {
+ if (name.isPrefixOf(m_commandOptions.getPrefix())) {
+ setAvailability(true);
+ }
+ });
+
+ m_ribEraseConn = rib.afterEraseEntry.connect([this] (const Name& name) {
+ if (name.isPrefixOf(m_commandOptions.getPrefix())) {
+ setAvailability(false);
+ }
+ });
}
void
@@ -59,7 +66,7 @@
m_controller.start<ndn::nfd::RibRegisterCommand>(
getControlParameters().setName(rr.prefix),
- [=] (const ControlParameters& cp) { successCb(); },
+ [=] (const ControlParameters&) { successCb(); },
[=] (const ControlResponse& cr) { failureCb(cr.getText()); },
getCommandOptions().setSigningInfo(rr.signer));
}
@@ -73,38 +80,10 @@
m_controller.start<ndn::nfd::RibUnregisterCommand>(
getControlParameters().setName(rr.prefix),
- [=] (const ControlParameters& cp) { successCb(); },
+ [=] (const ControlParameters&) { successCb(); },
[=] (const ControlResponse& cr) { failureCb(cr.getText()); },
getCommandOptions().setSigningInfo(rr.signer));
}
-ndn::nfd::ControlParameters
-NfdRibReadvertiseDestination::getControlParameters()
-{
- return m_controlParameters;
-}
-
-ndn::nfd::CommandOptions
-NfdRibReadvertiseDestination::getCommandOptions()
-{
- return m_commandOptions;
-}
-
-void
-NfdRibReadvertiseDestination::handleRibInsert(const ndn::Name& name)
-{
- if (name.isPrefixOf(m_commandOptions.getPrefix())) {
- setAvailability(true);
- }
-}
-
-void
-NfdRibReadvertiseDestination::handleRibErase(const ndn::Name& name)
-{
- if (name.isPrefixOf(m_commandOptions.getPrefix())) {
- setAvailability(false);
- }
-}
-
} // namespace rib
} // namespace nfd
diff --git a/daemon/rib/readvertise/nfd-rib-readvertise-destination.hpp b/daemon/rib/readvertise/nfd-rib-readvertise-destination.hpp
index 9c5bce6..0f61669 100644
--- a/daemon/rib/readvertise/nfd-rib-readvertise-destination.hpp
+++ b/daemon/rib/readvertise/nfd-rib-readvertise-destination.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -45,8 +45,7 @@
Rib& rib,
const ndn::nfd::CommandOptions& options = ndn::nfd::CommandOptions(),
const ndn::nfd::ControlParameters& parameters =
- ndn::nfd::ControlParameters()
- .setOrigin(ndn::nfd::ROUTE_ORIGIN_CLIENT));
+ ndn::nfd::ControlParameters().setOrigin(ndn::nfd::ROUTE_ORIGIN_CLIENT));
/** \brief add a name prefix into NFD RIB
*/
@@ -64,17 +63,16 @@
protected:
ndn::nfd::ControlParameters
- getControlParameters();
+ getControlParameters() const
+ {
+ return m_controlParameters;
+ }
ndn::nfd::CommandOptions
- getCommandOptions();
-
-private:
- void
- handleRibInsert(const Name& name);
-
- void
- handleRibErase(const Name& name);
+ getCommandOptions() const
+ {
+ return m_commandOptions;
+ }
private:
ndn::nfd::Controller& m_controller;
diff --git a/daemon/rib/rib-entry.cpp b/daemon/rib/rib-entry.cpp
index 7385d16..6acae09 100644
--- a/daemon/rib/rib-entry.cpp
+++ b/daemon/rib/rib-entry.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -33,22 +33,30 @@
NFD_LOG_INIT(RibEntry);
+static bool
+compareFaceIdAndOrigin(const Route& lhs, const Route& rhs)
+{
+ return lhs.faceId == rhs.faceId && lhs.origin == rhs.origin;
+}
+
RibEntry::RouteList::iterator
RibEntry::findRoute(const Route& route)
{
- return std::find_if(begin(), end(), bind(&compareFaceIdAndOrigin, _1, route));
+ return std::find_if(begin(), end(),
+ [&] (const auto& r) { return compareFaceIdAndOrigin(r, route); });
}
RibEntry::RouteList::const_iterator
RibEntry::findRoute(const Route& route) const
{
- return std::find_if(begin(), end(), bind(&compareFaceIdAndOrigin, _1, route));
+ return std::find_if(begin(), end(),
+ [&] (const auto& r) { return compareFaceIdAndOrigin(r, route); });
}
std::pair<RibEntry::iterator, bool>
RibEntry::insertRoute(const Route& route)
{
- iterator it = findRoute(route);
+ auto it = findRoute(route);
if (it == end()) {
if (route.flags & ndn::nfd::ROUTE_FLAG_CAPTURE) {
@@ -65,23 +73,21 @@
void
RibEntry::eraseRoute(const Route& route)
{
- RibEntry::iterator it = findRoute(route);
+ auto it = findRoute(route);
eraseRoute(it);
}
bool
RibEntry::hasRoute(const Route& route)
{
- RibEntry::const_iterator it = findRoute(route);
-
+ auto it = findRoute(route);
return it != end();
}
bool
-RibEntry::hasFaceId(const uint64_t faceId) const
+RibEntry::hasFaceId(uint64_t faceId) const
{
- RibEntry::const_iterator it = std::find_if(begin(), end(), bind(&compareFaceId, _1, faceId));
-
+ auto it = std::find_if(begin(), end(), [faceId] (const auto& r) { return r.faceId == faceId; });
return it != end();
}
@@ -134,14 +140,14 @@
void
RibEntry::removeInheritedRoute(const Route& route)
{
- m_inheritedRoutes.remove_if(bind(&compareFaceId, _1, route.faceId));
+ m_inheritedRoutes.remove_if([id = route.faceId] (const auto& r) { return r.faceId == id; });
}
RibEntry::RouteList::const_iterator
RibEntry::findInheritedRoute(const Route& route) const
{
return std::find_if(m_inheritedRoutes.begin(), m_inheritedRoutes.end(),
- bind(&compareFaceId, _1, route.faceId));
+ [id = route.faceId] (const auto& r) { return r.faceId == id; });
}
bool
@@ -243,7 +249,7 @@
time::milliseconds maxExpiration) const
{
const Route* bestAnnRoute = nullptr;
- auto entryExpiry = time::steady_clock::TimePoint::min();
+ auto entryExpiry = time::steady_clock::time_point::min();
for (const Route& route : *this) {
if (route.expires) {
@@ -255,7 +261,7 @@
}
}
else {
- entryExpiry = time::steady_clock::TimePoint::max();
+ entryExpiry = time::steady_clock::time_point::max();
}
}
diff --git a/daemon/rib/rib-entry.hpp b/daemon/rib/rib-entry.hpp
index 45d5a87..03cfc8c 100644
--- a/daemon/rib/rib-entry.hpp
+++ b/daemon/rib/rib-entry.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -94,7 +94,7 @@
eraseRoute(RouteList::iterator route);
bool
- hasFaceId(const uint64_t faceId) const;
+ hasFaceId(uint64_t faceId) const;
const RouteList&
getRoutes() const;
diff --git a/daemon/rib/rib.cpp b/daemon/rib/rib.cpp
index 2d1db7f..a81e77a 100644
--- a/daemon/rib/rib.cpp
+++ b/daemon/rib/rib.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -426,8 +426,8 @@
// Until task #1698, each RibUpdateBatch contains exactly one RIB update
BOOST_ASSERT(batch.size() == 1);
- auto fibSuccessCb = bind(&Rib::onFibUpdateSuccess, this, batch, _1, item.managerSuccessCallback);
- auto fibFailureCb = bind(&Rib::onFibUpdateFailure, this, item.managerFailureCallback, _1, _2);
+ auto fibSuccessCb = std::bind(&Rib::onFibUpdateSuccess, this, batch, _1, item.managerSuccessCallback);
+ auto fibFailureCb = std::bind(&Rib::onFibUpdateFailure, this, item.managerFailureCallback, _1, _2);
m_fibUpdater->computeAndSendFibUpdates(batch, fibSuccessCb, fibFailureCb);
}
diff --git a/daemon/rib/route.cpp b/daemon/rib/route.cpp
index 04999bb..99d80e5 100644
--- a/daemon/rib/route.cpp
+++ b/daemon/rib/route.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -31,21 +31,21 @@
const uint64_t PA_ROUTE_COST = 2048; ///< cost of route created by prefix announcement
-static time::steady_clock::TimePoint
+static time::steady_clock::time_point
computeExpiration(const ndn::PrefixAnnouncement& ann)
{
- time::steady_clock::Duration validityEnd = time::steady_clock::Duration::max();
+ auto validityEnd = time::steady_clock::duration::max();
if (ann.getValidityPeriod()) {
auto now = time::system_clock::now();
if (!ann.getValidityPeriod()->isValid(now)) {
- validityEnd = time::steady_clock::Duration::zero();
+ validityEnd = time::steady_clock::duration::zero();
}
else {
validityEnd = ann.getValidityPeriod()->getPeriod().second - now;
}
}
return time::steady_clock::now() +
- std::min(validityEnd, time::duration_cast<time::steady_clock::Duration>(ann.getExpiration()));
+ std::min(validityEnd, time::duration_cast<time::steady_clock::duration>(ann.getExpiration()));
}
Route::Route(const ndn::PrefixAnnouncement& ann, uint64_t faceId)
diff --git a/daemon/rib/route.hpp b/daemon/rib/route.hpp
index 92df470..18df250 100644
--- a/daemon/rib/route.hpp
+++ b/daemon/rib/route.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -82,7 +82,7 @@
ndn::nfd::RouteOrigin origin = ndn::nfd::ROUTE_ORIGIN_APP;
uint64_t cost = 0;
std::underlying_type_t<ndn::nfd::RouteFlags> flags = ndn::nfd::ROUTE_FLAGS_NONE;
- optional<time::steady_clock::TimePoint> expires;
+ optional<time::steady_clock::time_point> expires;
/** \brief The prefix announcement that caused the creation of this route.
*
@@ -98,7 +98,7 @@
* not yet valid or has expired. In this case, the exact value of this field does not matter.
* If this field is after the current time, it indicates when the prefix announcement expires.
*/
- time::steady_clock::TimePoint annExpires;
+ time::steady_clock::time_point annExpires;
private:
scheduler::EventId m_expirationEvent;
@@ -113,18 +113,6 @@
return !(lhs == rhs);
}
-inline bool
-compareFaceIdAndOrigin(const Route& lhs, const Route& rhs)
-{
- return (lhs.faceId == rhs.faceId && lhs.origin == rhs.origin);
-}
-
-inline bool
-compareFaceId(const Route& route, const uint64_t faceId)
-{
- return (route.faceId == faceId);
-}
-
std::ostream&
operator<<(std::ostream& os, const Route& route);
diff --git a/daemon/rib/service.cpp b/daemon/rib/service.cpp
index 596fa27..0c674b3 100644
--- a/daemon/rib/service.cpp
+++ b/daemon/rib/service.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -45,7 +45,7 @@
Service* Service::s_instance = nullptr;
-const std::string CFG_SECTION = "rib";
+const std::string CFG_RIB = "rib";
const std::string CFG_LOCALHOST_SECURITY = "localhost_security";
const std::string CFG_LOCALHOP_SECURITY = "localhop_security";
const std::string CFG_PA_VALIDATION = "prefix_announcement_validation";
@@ -126,7 +126,9 @@
s_instance = this;
ConfigFile config(ConfigFile::ignoreUnknownSection);
- config.addSectionHandler(CFG_SECTION, bind(&Service::processConfig, this, _1, _2, _3));
+ config.addSectionHandler(CFG_RIB, [this] (auto&&... args) {
+ processConfig(std::forward<decltype(args)>(args)...);
+ });
configParse(config, true);
configParse(config, false);
@@ -185,10 +187,10 @@
// AutoPrefixPropagator does not support config dry-run
}
else if (key == CFG_READVERTISE_NLSR) {
- ConfigFile::parseYesNo(item, CFG_SECTION + "." + CFG_READVERTISE_NLSR);
+ ConfigFile::parseYesNo(item, CFG_RIB + "." + CFG_READVERTISE_NLSR);
}
else {
- NDN_THROW(ConfigFile::Error("Unrecognized option " + CFG_SECTION + "." + key));
+ NDN_THROW(ConfigFile::Error("Unrecognized option " + CFG_RIB + "." + key));
}
}
@@ -239,10 +241,10 @@
}
}
else if (key == CFG_READVERTISE_NLSR) {
- wantReadvertiseNlsr = ConfigFile::parseYesNo(item, CFG_SECTION + "." + CFG_READVERTISE_NLSR);
+ wantReadvertiseNlsr = ConfigFile::parseYesNo(item, CFG_RIB + "." + CFG_READVERTISE_NLSR);
}
else {
- NDN_THROW(ConfigFile::Error("Unrecognized option " + CFG_SECTION + "." + key));
+ NDN_THROW(ConfigFile::Error("Unrecognized option " + CFG_RIB + "." + key));
}
}
diff --git a/daemon/table/network-region-table.cpp b/daemon/table/network-region-table.cpp
index c7e9cea..4ede386 100644
--- a/daemon/table/network-region-table.cpp
+++ b/daemon/table/network-region-table.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,10 +28,10 @@
namespace nfd {
bool
-NetworkRegionTable::isInProducerRegion(const DelegationList& forwardingHint) const
+NetworkRegionTable::isInProducerRegion(const ndn::DelegationList& forwardingHint) const
{
for (const Name& regionName : *this) {
- for (const Delegation& delegation : forwardingHint) {
+ for (const auto& delegation : forwardingHint) {
if (delegation.name.isPrefixOf(regionName)) {
return true;
}
diff --git a/daemon/table/network-region-table.hpp b/daemon/table/network-region-table.hpp
index 22da902..e531a45 100644
--- a/daemon/table/network-region-table.hpp
+++ b/daemon/table/network-region-table.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,6 +28,8 @@
#include "core/common.hpp"
+#include <ndn-cxx/delegation-list.hpp>
+
namespace nfd {
/** \brief stores a collection of producer region names
@@ -50,7 +52,7 @@
* otherwise, the Interest should be forwarded according to the forwarding hint.
*/
bool
- isInProducerRegion(const DelegationList& forwardingHint) const;
+ isInProducerRegion(const ndn::DelegationList& forwardingHint) const;
};
} // namespace nfd