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
This commit is contained in:
Davide Pesavento committed 2021-07-02 00:21:05 -04:00
1 parent a103334b1c
commit 412c982a63
68 files changed
+400 -419

No files matched your search

+1 -6
View File
@@ -59,8 +59,6 @@
#include <vector>
#include <ndn-cxx/data.hpp>
#include <ndn-cxx/delegation.hpp>
#include <ndn-cxx/delegation-list.hpp>
#include <ndn-cxx/interest.hpp>
#include <ndn-cxx/name.hpp>
#include <ndn-cxx/encoding/block.hpp>
@@ -68,6 +66,7 @@
#include <ndn-cxx/net/face-uri.hpp>
#include <ndn-cxx/util/backports.hpp>
#include <ndn-cxx/util/exception.hpp>
#include <ndn-cxx/util/optional.hpp>
#include <ndn-cxx/util/scheduler.hpp>
#include <ndn-cxx/util/signal.hpp>
#include <ndn-cxx/util/time.hpp>
@@ -94,8 +93,6 @@ using std::static_pointer_cast;
using std::dynamic_pointer_cast;
using std::const_pointer_cast;
using std::bind;
using namespace std::string_literals;
using ndn::optional;
@@ -104,8 +101,6 @@ using ndn::to_string;
using ndn::Block;
using ndn::Data;
using ndn::Delegation;
using ndn::DelegationList;
using ndn::FaceUri;
using ndn::Interest;
using ndn::Name;
+4 -2
View File
@@ -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 @@ FaceSystem::hasFactoryForScheme(const std::string& scheme) const
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
+22 -22
View File
@@ -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 @@ GenericLinkService::GenericLinkService(const GenericLinkService::Options& option
, 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 @@ GenericLinkService::sendLpPacket(lp::Packet&& pkt)
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 @@ GenericLinkService::sendNetPacket(lp::Packet&& pkt, bool isInterest)
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 @@ GenericLinkService::checkCongestionLevel(lp::Packet& pkt)
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 @@ GenericLinkService::checkCongestionLevel(lp::Packet& pkt)
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 @@ GenericLinkService::doReceivePacket(const Block& packet, const EndpointId& endpo
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 @@ GenericLinkService::doReceivePacket(const Block& packet, const EndpointId& endpo
}
}
catch (const tlv::Error& e) {
++this->nInLpInvalid;
++nInLpInvalid;
NFD_LOG_FACE_WARN("packet parse error (" << e.what() << "): DROP");
}
}
@@ -344,13 +344,13 @@ GenericLinkService::decodeNetPacket(const Block& netPkt, const lp::Packet& first
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 @@ GenericLinkService::decodeInterest(const Block& netPkt, const lp::Packet& firstP
}
if (firstPkt.has<lp::CachePolicyField>()) {
++this->nInNetInvalid;
++nInNetInvalid;
NFD_LOG_FACE_WARN("received CachePolicy with Interest: DROP");
return;
}
@@ -399,7 +399,7 @@ GenericLinkService::decodeInterest(const Block& netPkt, const lp::Packet& firstP
}
if (firstPkt.has<lp::PrefixAnnouncementField>()) {
++this->nInNetInvalid;
++nInNetInvalid;
NFD_LOG_FACE_WARN("received PrefixAnnouncement with Interest: DROP");
return;
}
@@ -421,13 +421,13 @@ GenericLinkService::decodeData(const Block& netPkt, const lp::Packet& firstPkt,
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 @@ GenericLinkService::decodeData(const Block& netPkt, const lp::Packet& firstPkt,
}
if (firstPkt.has<lp::NonDiscoveryField>()) {
++this->nInNetInvalid;
++nInNetInvalid;
NFD_LOG_FACE_WARN("received NonDiscovery with Data: DROP");
return;
}
@@ -476,13 +476,13 @@ GenericLinkService::decodeNack(const Block& netPkt, const lp::Packet& firstPkt,
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 @@ GenericLinkService::decodeNack(const Block& netPkt, const lp::Packet& firstPkt,
}
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;
}
+9 -5
View File
@@ -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 @@ doesNetifMatchRule(const ndn::net::NetworkInterface& netif, const std::string& r
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 @@ doesAddressMatchRule(const boost::asio::ip::address& address, const std::string&
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
+4 -3
View File
@@ -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 @@ TcpFactory::createChannel(const tcp::Endpoint& endpoint)
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;
}
+1 -1
View File
@@ -434,7 +434,7 @@ UdpFactory::applyMcastConfigToNetif(const shared_ptr<const net::NetworkInterface
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 {};
}
+6 -6
View File
@@ -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 @@ WebSocketChannel::WebSocketChannel(const websocket::Endpoint& localEndpoint)
}
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);
+4 -4
View File
@@ -84,7 +84,7 @@ findDuplicateNonce(const pit::Entry& pitEntry, Interest::Nonce nonce, const Face
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 @@ hasPendingOutRecords(const pit::Entry& pitEntry)
});
}
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 @@ findEligibleNextHopWithEarliestOutRecord(const Face& inFace, const Interest& int
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 @@ isNextHopEligible(const Face& inFace, const Interest& interest,
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();
+6 -4
View File
@@ -40,7 +40,7 @@ namespace nfd {
NFD_LOG_INIT(Forwarder);
const std::string CFGSEC_FORWARDER = "forwarder";
const std::string CFG_FORWARDER = "forwarder";
static Name
getDefaultStrategyName()
@@ -607,7 +607,9 @@ Forwarder::insertDeadNonceList(pit::Entry& pitEntry, const Face* upstream)
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 @@ Forwarder::processConfig(const ConfigSection& configSection, bool isDryRun, cons
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));
}
}
+4 -4
View File
@@ -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 @@ RetxSuppressionFixed::decidePerPitEntry(pit::Entry& pitEntry) const
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;
}
+4 -4
View File
@@ -291,13 +291,13 @@ Strategy::lookupFib(const pit::Entry& pitEntry) const
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 @@ Strategy::lookupFib(const pit::Entry& pitEntry) const
}
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;
}
+13 -11
View File
@@ -82,15 +82,15 @@ public:
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 @@ private:
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 @@ private:
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
+3 -2
View File
@@ -107,8 +107,9 @@ CommandAuthenticator::CommandAuthenticator() = default;
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
+4 -4
View File
@@ -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 @@ CsManager::CsManager(Cs& cs, const ForwarderCounters& fwCounters,
, 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
+12 -9
View File
@@ -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 @@ FaceManager::FaceManager(FaceSystem& faceSystem,
, 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 @@ copyFaceProperties(const Face& face, T& to)
}
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)));
}
+4 -4
View File
@@ -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 @@ FibManager::FibManager(Fib& fib, const FaceTable& faceTable,
, 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
+1 -1
View File
@@ -35,7 +35,7 @@ ForwarderStatusManager::ForwarderStatusManager(Forwarder& forwarder, Dispatcher&
, 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
+4 -3
View File
@@ -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 @@ ManagerBase::registerNotificationStream(const std::string& verb)
}
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 @@ ManagerBase::handleCommand(shared_ptr<ControlCommand> command,
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*>(&params) != nullptr);
+7 -7
View File
@@ -97,10 +97,10 @@ NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED: // helpers
* 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 @@ NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
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 @@ private:
};
template<typename Command>
inline void
void
ManagerBase::registerCommandHandler(const std::string& verb,
const ControlCommandHandler& handler)
{
@@ -157,8 +157,8 @@ ManagerBase::registerCommandHandler(const std::string& verb,
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
+12 -12
View File
@@ -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 @@ RibManager::RibManager(rib::Rib& rib, ndn::Face& face, ndn::KeyChain& keyChain,
, 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 @@ RibManager::registerWithNfd()
}
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 @@ RibManager::registerEntry(const Name& topPrefix, const Interest& interest,
}
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 @@ RibManager::unregisterEntry(const Name& topPrefix, const Interest& interest,
}
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 @@ RibManager::setFaceForSelfRegistration(const Interest& request, ControlParameter
}
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 @@ RibManager::makeAuthorization(const std::string& verb)
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 @@ RibManager::fetchActiveFaces()
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());
}
+4 -4
View File
@@ -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 @@ StrategyChoiceManager::StrategyChoiceManager(StrategyChoice& strategyChoice,
, 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
+6 -5
View File
@@ -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 @@ TablesConfigSection::TablesConfigSection(Forwarder& forwarder)
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 @@ TablesConfigSection::ensureConfigured()
}
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");
+2 -5
View File
@@ -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 @@ public:
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 @@ private:
processNetworkRegionSection(const ConfigSection& section, bool isDryRun);
private:
static const size_t DEFAULT_CS_MAX_PACKETS;
Forwarder& m_forwarder;
bool m_isConfigured;
};
+18 -22
View File
@@ -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 @@ FibUpdater::computeUpdatesForRegistration(const RibUpdate& update)
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 @@ FibUpdater::computeUpdatesForRegistration(const RibUpdate& update)
// 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 @@ FibUpdater::computeUpdatesForUnregistration(const RibUpdate& update)
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 @@ FibUpdater::sendAddNextHopUpdate(const FibUpdate& update,
.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 @@ FibUpdater::sendRemoveNextHopUpdate(const FibUpdate& update,
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 @@ FibUpdater::onUpdateSuccess(const FibUpdate update,
}
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 @@ FibUpdater::onUpdateError(const FibUpdate update,
}
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 @@ FibUpdater::createFibUpdatesForNewRibEntry(const Name& name, const Route& route,
// 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 @@ FibUpdater::createFibUpdatesForUpdatedRoute(const RibEntry& entry, const Route&
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 @@ FibUpdater::createFibUpdatesForErasedRoute(const RibEntry& entry, const Route& r
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);
+3 -3
View File
@@ -149,7 +149,7 @@ NFD_PROTECTED_WITH_TESTS_ELSE_PRIVATE:
* 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 @@ NFD_PROTECTED_WITH_TESTS_ELSE_PRIVATE:
* 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 @@ private:
* 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
*/
@@ -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 @@ NfdRibReadvertiseDestination::NfdRibReadvertiseDestination(ndn::nfd::Controller&
, 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 @@ NfdRibReadvertiseDestination::advertise(const nfd::rib::ReadvertisedRoute& rr,
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 @@ NfdRibReadvertiseDestination::withdraw(const nfd::rib::ReadvertisedRoute& rr,
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
@@ -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 @@ public:
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 @@ public:
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;
+20 -14
View File
@@ -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 @@ namespace rib {
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 @@ RibEntry::insertRoute(const Route& route)
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 @@ RibEntry::addInheritedRoute(const Route& route)
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 @@ RibEntry::getPrefixAnnouncement(time::milliseconds minExpiration,
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 @@ RibEntry::getPrefixAnnouncement(time::milliseconds minExpiration,
}
}
else {
entryExpiry = time::steady_clock::TimePoint::max();
entryExpiry = time::steady_clock::time_point::max();
}
}
+2 -2
View File
@@ -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 @@ public:
eraseRoute(RouteList::iterator route);
bool
hasFaceId(const uint64_t faceId) const;
hasFaceId(uint64_t faceId) const;
const RouteList&
getRoutes() const;
+3 -3
View File
@@ -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 @@ Rib::sendBatchFromQueue()
// 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);
}
+5 -5
View File
@@ -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 @@ namespace rib {
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)
+3 -15
View File
@@ -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 @@ public:
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 @@ public:
* 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 @@ operator!=(const Route& lhs, const Route& rhs)
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);
+9 -7
View File
@@ -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 @@ NFD_LOG_INIT(RibService);
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 @@ Service::Service(ndn::KeyChain& keyChain, shared_ptr<ndn::Transport> localNfdTra
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 @@ Service::checkConfig(const ConfigSection& section, const std::string& filename)
// 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 @@ Service::applyConfig(const ConfigSection& section, const std::string& filename)
}
}
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));
}
}
+3 -3
View File
@@ -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;
}
+4 -2
View File
@@ -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 @@ public:
* 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
+6 -6
View File
@@ -106,8 +106,8 @@ public:
DummyAllSubscriber(ConfigFile& config, bool expectDryRun = false)
: DummySubscriber(config, CONFIG_N_A_SECTIONS, CONFIG_N_B_SECTIONS, expectDryRun)
{
config.addSectionHandler("a", bind(&DummySubscriber::onA, this, _1, _2));
config.addSectionHandler("b", bind(&DummySubscriber::onB, this, _1, _2));
config.addSectionHandler("a", std::bind(&DummySubscriber::onA, this, _1, _2));
config.addSectionHandler("b", std::bind(&DummySubscriber::onB, this, _1, _2));
}
};
@@ -121,10 +121,10 @@ public:
expectDryRun)
{
if (sectionName == "a") {
config.addSectionHandler(sectionName, bind(&DummySubscriber::onA, this, _1, _2));
config.addSectionHandler(sectionName, std::bind(&DummySubscriber::onA, this, _1, _2));
}
else if (sectionName == "b") {
config.addSectionHandler(sectionName, bind(&DummySubscriber::onB, this, _1, _2));
config.addSectionHandler(sectionName, std::bind(&DummySubscriber::onB, this, _1, _2));
}
else {
BOOST_FAIL("Test setup error: Unexpected section name '" << sectionName << "'");
@@ -304,8 +304,8 @@ BOOST_FIXTURE_TEST_CASE(UncoveredSections, MissingCallbackFixture)
ConfigFile file;
BOOST_REQUIRE_THROW(file.parse(CONFIG, false, "dummy-config"), ConfigFile::Error);
ConfigFile permissiveFile(bind(&MissingCallbackFixture::checkMissingHandler,
this, _1, _2, _3, _4));
ConfigFile permissiveFile(std::bind(&MissingCallbackFixture::checkMissingHandler,
this, _1, _2, _3, _4));
DummyOneSubscriber subA(permissiveFile, "a");
BOOST_REQUIRE_NO_THROW(permissiveFile.parse(CONFIG, false, "dummy-config"));
+4 -4
View File
@@ -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,
@@ -101,9 +101,9 @@ BOOST_AUTO_TEST_CASE(LinkServiceSendReceive)
size_t nReceivedInterests = 0;
size_t nReceivedData = 0;
size_t nReceivedNacks = 0;
face1->afterReceiveInterest.connect(bind([&nReceivedInterests] { ++nReceivedInterests; }));
face1->afterReceiveData.connect(bind([&nReceivedData] { ++nReceivedData; }));
face1->afterReceiveNack.connect(bind([&nReceivedNacks] { ++nReceivedNacks; }));
face1->afterReceiveInterest.connect([&] (auto&&...) { ++nReceivedInterests; });
face1->afterReceiveData.connect([&] (auto&&...) { ++nReceivedData; });
face1->afterReceiveNack.connect([&] (auto&&...) { ++nReceivedNacks; });
for (size_t i = 0; i < nInInterests; ++i) {
face1->receiveInterest(*makeInterest("/JSQdqward4"), 0);
+13 -13
View File
@@ -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,
@@ -87,9 +87,9 @@ BOOST_AUTO_TEST_CASE(ReceiveInterestTimeout)
bool hasTimeout = false;
clientFace->expressInterest(*interest,
bind([] { BOOST_ERROR("unexpected Data"); }),
bind([] { BOOST_ERROR("unexpected Nack"); }),
bind([&hasTimeout] { hasTimeout = true; }));
[] (auto&&...) { BOOST_ERROR("unexpected Data"); },
[] (auto&&...) { BOOST_ERROR("unexpected Nack"); },
[&] (auto&&...) { hasTimeout = true; });
this->advanceClocks(1_ms, 10);
BOOST_REQUIRE_EQUAL(receivedInterests.size(), 1);
@@ -106,12 +106,12 @@ BOOST_AUTO_TEST_CASE(ReceiveInterestSendData)
bool hasReceivedData = false;
clientFace->expressInterest(*interest,
[&hasReceivedData] (const Interest&, const Data& data) {
[&] (const Interest&, const Data& data) {
hasReceivedData = true;
BOOST_CHECK_EQUAL(data.getName(), "/PQstEJGdL/aI7oCrDXNX");
},
bind([] { BOOST_ERROR("unexpected Nack"); }),
bind([] { BOOST_ERROR("unexpected timeout"); }));
[] (auto&&...) { BOOST_ERROR("unexpected Nack"); },
[] (auto&&...) { BOOST_ERROR("unexpected timeout"); });
this->advanceClocks(1_ms, 10);
BOOST_REQUIRE_EQUAL(receivedInterests.size(), 1);
@@ -129,12 +129,12 @@ BOOST_AUTO_TEST_CASE(ReceiveInterestSendNack)
bool hasReceivedNack = false;
clientFace->expressInterest(*interest,
bind([] { BOOST_ERROR("unexpected Data"); }),
[&hasReceivedNack] (const Interest&, const lp::Nack& nack) {
[] (auto&&...) { BOOST_ERROR("unexpected Data"); },
[&] (const Interest&, const lp::Nack& nack) {
hasReceivedNack = true;
BOOST_CHECK_EQUAL(nack.getReason(), lp::NackReason::NO_ROUTE);
},
bind([] { BOOST_ERROR("unexpected timeout"); }));
[] (auto&&...) { BOOST_ERROR("unexpected timeout"); });
this->advanceClocks(1_ms, 10);
BOOST_REQUIRE_EQUAL(receivedInterests.size(), 1);
@@ -197,9 +197,9 @@ BOOST_AUTO_TEST_CASE(CloseForwarderFace)
bool hasTimeout = false;
clientFace->expressInterest(*interest,
bind([] { BOOST_ERROR("unexpected Data"); }),
bind([] { BOOST_ERROR("unexpected Nack"); }),
bind([&hasTimeout] { hasTimeout = true; }));
[] (auto&&...) { BOOST_ERROR("unexpected Data"); },
[] (auto&&...) { BOOST_ERROR("unexpected Nack"); },
[&] (auto&&...) { hasTimeout = true; });
BOOST_CHECK_NO_THROW(this->advanceClocks(1_ms, 200));
BOOST_CHECK_EQUAL(receivedInterests.size(), 0);
+4 -4
View File
@@ -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,
@@ -458,10 +458,10 @@ BOOST_FIXTURE_TEST_CASE(CreateFaceTimeout, CreateFaceTimeoutFixture)
{
createChannel("0.0.0.0", "20070");
factory.createFace({FaceUri("tcp4://192.0.2.1:20070"), {}, {}},
bind(&CreateFaceTimeoutFixture::onFaceCreated, this, _1),
bind(&CreateFaceTimeoutFixture::onConnectFailed, this, _2));
std::bind(&CreateFaceTimeoutFixture::onFaceCreated, this, _1),
std::bind(&CreateFaceTimeoutFixture::onConnectFailed, this, _2));
BOOST_REQUIRE_EQUAL(limitedIo.run(1, 10_s), LimitedIo::EXCEED_OPS);
BOOST_CHECK_EQUAL(limitedIo.run(1, 10_s), LimitedIo::EXCEED_OPS);
BOOST_CHECK(face == nullptr);
}
+14 -17
View File
@@ -38,7 +38,8 @@ class WebSocketChannelFixture : public ChannelFixture<WebSocketChannel, websocke
{
protected:
shared_ptr<WebSocketChannel>
makeChannel(const boost::asio::ip::address& addr, uint16_t port = 0, optional<size_t> mtu = nullopt) final
makeChannel(const boost::asio::ip::address& addr, uint16_t port = 0,
optional<size_t> mtu = nullopt) final
{
if (port == 0)
port = getNextPort();
@@ -55,7 +56,7 @@ protected:
listenerChannel = makeChannel(addr, 20030);
listenerChannel->setPingInterval(pingInterval);
listenerChannel->setPongTimeout(pongTimeout);
listenerChannel->listen(bind(&WebSocketChannelFixture::listenerOnFaceCreated, this, _1));
listenerChannel->listen(std::bind(&WebSocketChannelFixture::listenerOnFaceCreated, this, _1));
}
void
@@ -65,9 +66,9 @@ protected:
client.clear_error_channels(websocketpp::log::elevel::all);
client.init_asio(&g_io);
client.set_open_handler(bind(&WebSocketChannelFixture::clientHandleOpen, this, _1));
client.set_message_handler(bind(&WebSocketChannelFixture::clientHandleMessage, this, _1, _2));
client.set_ping_handler(bind(&WebSocketChannelFixture::clientHandlePing, this, _1, _2));
client.set_open_handler(std::bind(&WebSocketChannelFixture::clientHandleOpen, this, _1));
client.set_message_handler(std::bind(&WebSocketChannelFixture::clientHandleMessage, this, _1, _2));
client.set_ping_handler(std::bind(&WebSocketChannelFixture::clientHandlePing, this, _1, _2));
websocketpp::lib::error_code ec;
auto con = client.get_connection(FaceUri(listenerEp, "ws").toString(), ec);
@@ -100,19 +101,15 @@ private:
listenerOnFaceCreated(const shared_ptr<Face>& newFace)
{
BOOST_REQUIRE(newFace != nullptr);
newFace->afterReceiveInterest.connect(bind(&WebSocketChannelFixture::faceAfterReceiveInterest, this, _1));
newFace->afterReceiveInterest.connect([this] (const auto& interest, const auto&) {
faceReceivedInterests.push_back(interest);
limitedIo.afterOp();
});
connectFaceClosedSignal(*newFace, [this] { limitedIo.afterOp(); });
listenerFaces.push_back(newFace);
limitedIo.afterOp();
}
void
faceAfterReceiveInterest(const Interest& interest)
{
faceReceivedInterests.push_back(interest);
limitedIo.afterOp();
}
void
clientHandleOpen(websocketpp::connection_hdl hdl)
{
@@ -131,8 +128,8 @@ private:
clientHandlePing(websocketpp::connection_hdl, std::string)
{
auto now = time::steady_clock::now();
if (m_prevPingRecvTime != time::steady_clock::TimePoint()) {
measuredPingInterval = now - m_prevPingRecvTime;
if (m_prevPingRecvTime != time::steady_clock::time_point()) {
measuredPingIntervals.push_back(now - m_prevPingRecvTime);
}
m_prevPingRecvTime = now;
@@ -147,13 +144,13 @@ protected:
websocketpp::connection_hdl clientHandle;
std::vector<std::string> clientReceivedMessages;
time::steady_clock::Duration measuredPingInterval;
std::vector<time::nanoseconds> measuredPingIntervals;
// set clientShouldPong to false to disable the pong response,
// which will eventually cause a timeout in listenerChannel
bool clientShouldPong = true;
private:
time::steady_clock::TimePoint m_prevPingRecvTime;
time::steady_clock::time_point m_prevPingRecvTime;
};
} // namespace tests
+10 -6
View File
@@ -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,
@@ -175,13 +175,17 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SetPingInterval, F, AddressFamilies)
{
auto address = getTestIp(F::value, AddressScope::Loopback);
SKIP_IF_IP_UNAVAILABLE(address);
const auto pingInterval = 1200_ms;
const auto pingInterval = 1500_ms;
this->initialize(address, pingInterval);
BOOST_CHECK_EQUAL(limitedIo.run(2, // clientHandlePing
pingInterval * 3), LimitedIo::EXCEED_OPS);
BOOST_CHECK_LE(measuredPingInterval, pingInterval * 1.1);
BOOST_CHECK_GE(measuredPingInterval, pingInterval * 0.9);
BOOST_CHECK_EQUAL(limitedIo.run(5, // clientHandlePing
5 * pingInterval + 1_s), LimitedIo::EXCEED_OPS);
BOOST_CHECK_EQUAL(measuredPingIntervals.size(), 4);
auto avgPingInterval = std::accumulate(measuredPingIntervals.begin(), measuredPingIntervals.end(), 0_ns);
avgPingInterval /= measuredPingIntervals.size();
BOOST_CHECK_LE(avgPingInterval, pingInterval * 1.1);
BOOST_CHECK_GE(avgPingInterval, pingInterval * 0.9);
}
BOOST_AUTO_TEST_CASE_TEMPLATE(SetPongTimeOut, F, AddressFamilies)
@@ -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,
@@ -62,11 +62,11 @@ protected:
server.clear_error_channels(websocketpp::log::elevel::all);
server.init_asio(&g_io);
server.set_open_handler(bind(&WebSocketTransportFixture::serverHandleOpen, this, _1));
server.set_close_handler(bind(&WebSocketTransportFixture::serverHandleClose, this));
server.set_message_handler(bind(&WebSocketTransportFixture::serverHandleMessage, this, _2));
server.set_pong_handler(bind(&WebSocketTransportFixture::serverHandlePong, this));
server.set_pong_timeout_handler(bind(&WebSocketTransportFixture::serverHandlePongTimeout, this));
server.set_open_handler(std::bind(&WebSocketTransportFixture::serverHandleOpen, this, _1));
server.set_close_handler(std::bind(&WebSocketTransportFixture::serverHandleClose, this));
server.set_message_handler(std::bind(&WebSocketTransportFixture::serverHandleMessage, this, _2));
server.set_pong_handler(std::bind(&WebSocketTransportFixture::serverHandlePong, this));
server.set_pong_timeout_handler(std::bind(&WebSocketTransportFixture::serverHandlePongTimeout, this));
server.set_pong_timeout(pongTimeout.count());
server.set_reuse_addr(true);
@@ -84,9 +84,9 @@ protected:
client.clear_error_channels(websocketpp::log::elevel::all);
client.init_asio(&g_io);
client.set_open_handler(bind(&WebSocketTransportFixture::clientHandleOpen, this, _1));
client.set_message_handler(bind(&WebSocketTransportFixture::clientHandleMessage, this, _2));
client.set_ping_handler(bind(&WebSocketTransportFixture::clientHandlePing, this));
client.set_open_handler(std::bind(&WebSocketTransportFixture::clientHandleOpen, this, _1));
client.set_message_handler(std::bind(&WebSocketTransportFixture::clientHandleMessage, this, _2));
client.set_ping_handler(std::bind(&WebSocketTransportFixture::clientHandlePing, this));
websocketpp::lib::error_code ec;
auto con = client.get_connection(uri, ec);
+6 -6
View File
@@ -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,
@@ -315,7 +315,7 @@ BOOST_AUTO_TEST_CASE(PacketLoss)
shared_ptr<Interest> interest1 = makeInterest("ndn:/laptops/A/1");
bool hasData1 = false;
consumer->getClientFace().expressInterest(*interest1,
bind([&hasData1] { hasData1 = true; }),
[&] (auto&&...) { hasData1 = true; },
nullptr, nullptr);
this->advanceClocks(5_ms, 1_s);
BOOST_CHECK_EQUAL(hasData1, true);
@@ -324,9 +324,9 @@ BOOST_AUTO_TEST_CASE(PacketLoss)
shared_ptr<Interest> interest2a = makeInterest("ndn:/laptops/A/2");
bool hasData2a = false, hasTimeout2a = false;
consumer->getClientFace().expressInterest(*interest2a,
bind([&hasData2a] { hasData2a = true; }),
[&] (auto&&...) { hasData2a = true; },
nullptr,
bind([&hasTimeout2a] { hasTimeout2a = true; }));
[&] (auto&&...) { hasTimeout2a = true; });
producerA->fail();
this->advanceClocks(5_ms, 60_ms);
BOOST_CHECK_EQUAL(hasData2a, false);
@@ -336,7 +336,7 @@ BOOST_AUTO_TEST_CASE(PacketLoss)
shared_ptr<Interest> interest2b = makeInterest("ndn:/laptops/A/2");
bool hasData2b = false;
consumer->getClientFace().expressInterest(*interest2b,
bind([&hasData2b] { hasData2b = true; }),
[&] (auto&&...) { hasData2b = true; },
nullptr, nullptr);
producerA->recover();
this->advanceClocks(5_ms, 1_s);
@@ -346,7 +346,7 @@ BOOST_AUTO_TEST_CASE(PacketLoss)
shared_ptr<Interest> interest2c = makeInterest("ndn:/laptops/A/2");
bool hasData2c = false;
consumer->getClientFace().expressInterest(*interest2c,
bind([&hasData2c] { hasData2c = true; }),
[&] (auto&&...) { hasData2c = true; },
nullptr, nullptr);
this->advanceClocks(5_ms, 1_s);
BOOST_CHECK_EQUAL(hasData2c, true);
+1 -1
View File
@@ -190,7 +190,7 @@ BOOST_FIXTURE_TEST_CASE(GetLastOutgoing, GlobalIoTimeFixture)
auto interest = makeInterest("ndn:/c1I7QCtc");
pit::Entry entry(*interest);
time::steady_clock::TimePoint before = time::steady_clock::now();
auto before = time::steady_clock::now();
entry.insertOrUpdateOutRecord(*face1, *interest);
this->advanceClocks(1_s);
+1 -1
View File
@@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE(Forward)
// more often than DEFAULT_MIN_RETX_INTERVAL
scheduler::EventId retxFrom4Evt;
size_t nSentLast = strategy.sendInterestHistory.size();
time::steady_clock::TimePoint timeSentLast = time::steady_clock::now();
auto timeSentLast = time::steady_clock::now();
std::function<void()> periodicalRetxFrom4; // let periodicalRetxFrom4 lambda capture itself
periodicalRetxFrom4 = [&] {
pitEntry->insertOrUpdateInRecord(*face4, *interest);
+7 -7
View File
@@ -114,8 +114,8 @@ public:
shared_ptr<TopologyLink> linkAH, linkHT, linkTP, linkHC, linkCS, linkSQ;
shared_ptr<TopologyAppLink> consumerA, producerP, producerQ;
Delegation delTelia = {10, "/telia/terabits"};
Delegation delUcla = {20, "/ucla/cs"};
ndn::Delegation delTelia = {10, "/telia/terabits"};
ndn::Delegation delUcla = {20, "/ucla/cs"};
};
BOOST_FIXTURE_TEST_SUITE(NdnsimTeliaUclaTopology, NdnsimTeliaUclaTopologyFixture)
@@ -128,12 +128,12 @@ BOOST_AUTO_TEST_CASE(FetchTelia)
// A forwards Interest according to default route, no change to forwarding hint
BOOST_CHECK_EQUAL(linkAH->getFace(nodeA).getCounters().nOutInterests, 1);
const Interest& interestAH = topo.getPcap(linkAH->getFace(nodeA)).sentInterests.at(0);
BOOST_CHECK_EQUAL(interestAH.getForwardingHint(), DelegationList({delTelia, delUcla}));
BOOST_CHECK_EQUAL(interestAH.getForwardingHint(), ndn::DelegationList({delTelia, delUcla}));
// H prefers T, no change to forwarding hint
BOOST_CHECK_EQUAL(linkHT->getFace(nodeH).getCounters().nOutInterests, 1);
const Interest& interestHT = topo.getPcap(linkHT->getFace(nodeH)).sentInterests.at(0);
BOOST_CHECK_EQUAL(interestHT.getForwardingHint(), DelegationList({delTelia, delUcla}));
BOOST_CHECK_EQUAL(interestHT.getForwardingHint(), ndn::DelegationList({delTelia, delUcla}));
// T forwards to P, forwarding hint stripped when Interest reaches producer region
BOOST_CHECK_EQUAL(linkTP->getFace(nodeT).getCounters().nOutInterests, 1);
@@ -157,17 +157,17 @@ BOOST_AUTO_TEST_CASE(FetchUcla)
// A forwards Interest according to default route, no change to forwarding hint
BOOST_CHECK_EQUAL(linkAH->getFace(nodeA).getCounters().nOutInterests, 1);
const Interest& interestAH = topo.getPcap(linkAH->getFace(nodeA)).sentInterests.at(0);
BOOST_CHECK_EQUAL(interestAH.getForwardingHint(), DelegationList({delTelia, delUcla}));
BOOST_CHECK_EQUAL(interestAH.getForwardingHint(), ndn::DelegationList({delTelia, delUcla}));
// H forwards to C, no change to forwarding hint
BOOST_CHECK_EQUAL(linkHC->getFace(nodeH).getCounters().nOutInterests, 1);
const Interest& interestHC = topo.getPcap(linkHC->getFace(nodeH)).sentInterests.at(0);
BOOST_CHECK_EQUAL(interestHC.getForwardingHint(), DelegationList({delTelia, delUcla}));
BOOST_CHECK_EQUAL(interestHC.getForwardingHint(), ndn::DelegationList({delTelia, delUcla}));
// C forwards to S, no change to forwarding hint
BOOST_CHECK_EQUAL(linkCS->getFace(nodeC).getCounters().nOutInterests, 1);
const Interest& interestCS = topo.getPcap(linkCS->getFace(nodeC)).sentInterests.at(0);
BOOST_CHECK_EQUAL(interestCS.getForwardingHint(), DelegationList({delTelia, delUcla}));
BOOST_CHECK_EQUAL(interestCS.getForwardingHint(), ndn::DelegationList({delTelia, delUcla}));
// S forwards to Q, forwarding hint stripped when Interest reaches producer region
BOOST_CHECK_EQUAL(linkSQ->getFace(nodeS).getCounters().nOutInterests, 1);
+1 -1
View File
@@ -176,7 +176,7 @@ BOOST_AUTO_TEST_CASE(Forward2)
// more often than DEFAULT_MIN_RETX_INTERVAL
scheduler::EventId retxFrom4Evt;
size_t nSentLast = strategy.sendInterestHistory.size();
time::steady_clock::TimePoint timeSentLast = time::steady_clock::now();
auto timeSentLast = time::steady_clock::now();
std::function<void()> periodicalRetxFrom4; // let periodicalRetxFrom4 lambda capture itself
periodicalRetxFrom4 = [&] {
pitEntry->insertOrUpdateInRecord(*face3, *interest);
+4 -4
View File
@@ -261,11 +261,11 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(LiveDeadlock,
ndn::Face& appD = topo.addAppFace("D", nodeD)->getClientFace();
int nNacksA = 0, nNacksD = 0;
appA.expressInterest(*makeInterest("/P/1"), nullptr, bind([&nNacksA] { ++nNacksA; }), nullptr);
appD.expressInterest(*makeInterest("/P/1"), nullptr, bind([&nNacksD] { ++nNacksD; }), nullptr);
appA.expressInterest(*makeInterest("/P/1"), nullptr, [&] (auto&&...) { ++nNacksA; }, nullptr);
appD.expressInterest(*makeInterest("/P/1"), nullptr, [&] (auto&&...) { ++nNacksD; }, nullptr);
this->advanceClocks(1_ms, 5_ms);
appA.expressInterest(*makeInterest("/P/1"), nullptr, bind([&nNacksA] { ++nNacksA; }), nullptr);
appD.expressInterest(*makeInterest("/P/1"), nullptr, bind([&nNacksD] { ++nNacksD; }), nullptr);
appA.expressInterest(*makeInterest("/P/1"), nullptr, [&] (auto&&...) { ++nNacksA; }, nullptr);
appD.expressInterest(*makeInterest("/P/1"), nullptr, [&] (auto&&...) { ++nNacksD; }, nullptr);
this->advanceClocks(1_ms, 100_ms);
// As long as at least one Nack arrives at each client, strategy behavior is correct.
+2 -2
View File
@@ -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,
@@ -242,7 +242,7 @@ public:
/** \brief captured packet timestamp tag
*/
using TopologyPcapTimestamp = ndn::SimpleTag<time::steady_clock::TimePoint, 0>;
using TopologyPcapTimestamp = ndn::SimpleTag<time::steady_clock::time_point, 0>;
/** \brief builds a topology for forwarding tests
*/
@@ -58,8 +58,8 @@ protected:
tribool isFound = indeterminate;
cs.find(Interest(data.getFullName()),
bind([&] { isFound = true; }),
bind([&] { isFound = false; }));
[&] (auto&&...) { isFound = true; },
[&] (auto&&...) { isFound = false; });
this->advanceClocks(1_ms);
BOOST_REQUIRE(!indeterminate(isFound));
+2 -2
View File
@@ -88,7 +88,7 @@ BOOST_FIXTURE_TEST_SUITE(TestManagerBase, ManagerBaseFixture)
BOOST_AUTO_TEST_CASE(RegisterCommandHandler)
{
bool wasCommandHandlerCalled = false;
auto handler = bind([&] { wasCommandHandlerCalled = true; });
auto handler = [&] (auto&&...) { wasCommandHandlerCalled = true; };
m_manager.registerCommandHandler<TestCommandVoidParameters>("test-void", handler);
m_manager.registerCommandHandler<TestCommandRequireName>("test-require-name", handler);
@@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE(RegisterCommandHandler)
BOOST_AUTO_TEST_CASE(RegisterStatusDataset)
{
bool isStatusDatasetCalled = false;
auto handler = bind([&] { isStatusDatasetCalled = true; });
auto handler = [&] (auto&&...) { isStatusDatasetCalled = true; };
m_manager.registerStatusDatasetHandler("test-status", handler);
setTopPrefix();
@@ -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,
@@ -104,7 +104,7 @@ public:
public:
struct HistoryEntry
{
time::steady_clock::TimePoint timestamp;
time::steady_clock::time_point timestamp;
Name prefix;
};
@@ -248,7 +248,7 @@ BOOST_AUTO_TEST_CASE(AdvertiseRetryInterval)
BOOST_REQUIRE_GT(destination->advertiseHistory.size(), 2);
// destination->advertise keeps failing, so interval should increase
using FloatInterval = time::duration<float, time::steady_clock::Duration::period>;
using FloatInterval = time::duration<float, time::steady_clock::duration::period>;
FloatInterval initialInterval = destination->advertiseHistory[1].timestamp -
destination->advertiseHistory[0].timestamp;
FloatInterval lastInterval = initialInterval;
+2 -2
View File
@@ -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,
@@ -87,7 +87,7 @@ makeSimpleRoute(uint64_t faceId)
}
static Route
makeSimpleRoute(uint64_t faceId, time::steady_clock::Duration expiration)
makeSimpleRoute(uint64_t faceId, time::nanoseconds expiration)
{
Route route = makeSimpleRoute(faceId);
route.expires = time::steady_clock::now() + expiration;
+2 -2
View File
@@ -80,10 +80,10 @@ protected:
std::memcpy(&found, content.value(), sizeof(found));
check(found);
},
bind([&] {
[&] (auto&&...) {
hasResult = true;
check(0);
}));
});
// current Cs::find implementation is synchronous
BOOST_CHECK(hasResult);
@@ -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,
@@ -36,7 +36,7 @@ BOOST_FIXTURE_TEST_SUITE(TestNetworkRegionTable, GlobalIoFixture)
BOOST_AUTO_TEST_CASE(InProducerRegion)
{
DelegationList fh{{10, "/telia/terabits"}, {20, "/ucla/cs"}};
ndn::DelegationList fh{{10, "/telia/terabits"}, {20, "/ucla/cs"}};
NetworkRegionTable nrt1;
nrt1.insert("/verizon");
+2 -2
View File
@@ -78,11 +78,11 @@ protected:
void
find(const Interest& interest)
{
cs.find(interest, bind([]{}), bind([]{}));
cs.find(interest, [] (auto&&...) {}, [] (auto&&...) {});
}
protected:
typedef std::function<Name(size_t)> NameGenerator;
using NameGenerator = std::function<Name (size_t)>;
class SimpleNameGenerator
{
+12 -13
View File
@@ -43,14 +43,13 @@ namespace tests {
class FaceBenchmark
{
public:
explicit
FaceBenchmark(const char* configFileName)
: m_terminationSignalSet{getGlobalIoService()}
: m_terminationSignalSet{getGlobalIoService(), SIGINT, SIGTERM}
, m_tcpChannel{tcp::Endpoint{boost::asio::ip::tcp::v4(), 6363}, false,
bind([] { return ndn::nfd::FACE_SCOPE_NON_LOCAL; })}
[] (auto&&...) { return ndn::nfd::FACE_SCOPE_NON_LOCAL; }}
, m_udpChannel{udp::Endpoint{boost::asio::ip::udp::v4(), 6363}, 10_min, false, ndn::MAX_NDN_PACKET_SIZE}
{
m_terminationSignalSet.add(SIGINT);
m_terminationSignalSet.add(SIGTERM);
m_terminationSignalSet.async_wait([] (const auto& error, int) {
if (!error)
getGlobalIoService().stop();
@@ -58,12 +57,12 @@ public:
parseConfig(configFileName);
m_tcpChannel.listen(bind(&FaceBenchmark::onLeftFaceCreated, this, _1),
bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
m_tcpChannel.listen(std::bind(&FaceBenchmark::onLeftFaceCreated, this, _1),
std::bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
std::clog << "Listening on " << m_tcpChannel.getUri() << std::endl;
m_udpChannel.listen(bind(&FaceBenchmark::onLeftFaceCreated, this, _1),
bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
m_udpChannel.listen(std::bind(&FaceBenchmark::onLeftFaceCreated, this, _1),
std::bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
std::clog << "Listening on " << m_udpChannel.getUri() << std::endl;
}
@@ -86,7 +85,7 @@ private:
std::clog << "Unsupported protocol '" << uriR.getScheme() << "'" << std::endl;
}
else {
m_faceUris.push_back(std::make_pair(uriL, uriR));
m_faceUris.emplace_back(uriL, uriR);
}
}
@@ -125,13 +124,13 @@ private:
auto port = boost::lexical_cast<uint16_t>(uriR.getPort());
if (uriR.getScheme() == "tcp4") {
m_tcpChannel.connect(tcp::Endpoint(addr, port), {},
bind(&FaceBenchmark::onRightFaceCreated, this, faceL, _1),
bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
std::bind(&FaceBenchmark::onRightFaceCreated, this, faceL, _1),
std::bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
}
else if (uriR.getScheme() == "udp4") {
m_udpChannel.connect(udp::Endpoint(addr, port), {},
bind(&FaceBenchmark::onRightFaceCreated, this, faceL, _1),
bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
std::bind(&FaceBenchmark::onRightFaceCreated, this, faceL, _1),
std::bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
}
}
+2 -2
View File
@@ -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,
@@ -50,7 +50,7 @@ class MockNfdMgmtFixture : public IoFixture, public KeyChainFixture
protected:
MockNfdMgmtFixture()
: face(m_io, m_keyChain,
{true, false, bind(&MockNfdMgmtFixture::processEventsOverride, this, _1)})
{true, false, std::bind(&MockNfdMgmtFixture::processEventsOverride, this, _1)})
{
face.onSendInterest.connect([this] (const Interest& interest) {
if (processInterest) {
+8 -4
View File
@@ -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,
@@ -67,7 +67,9 @@ Program::enableHubData(const FaceUri& hubFaceUri)
m_face.put(*data);
}
},
bind(&Program::handlePrefixRegistrationFailure, this, _1, _2));
[this] (auto&&... args) {
handlePrefixRegistrationFailure(std::forward<decltype(args)>(args)...);
});
}
void
@@ -84,8 +86,10 @@ Program::enableRoutablePrefixesDataset(const std::vector<Name>& routablePrefixes
m_dispatcher.addTopPrefix(ROUTABLE_PREFIXES_DATA_PREFIX, false);
m_face.registerPrefix(Name(ROUTABLE_PREFIXES_DATA_PREFIX).append(ROUTABLE_PREFIXES_DATA_SUFFIX),
nullptr,
bind(&Program::handlePrefixRegistrationFailure, this, _1, _2));
nullptr,
[this] (auto&&... args) {
handlePrefixRegistrationFailure(std::forward<decltype(args)>(args)...);
});
}
void
+14 -16
View File
@@ -34,7 +34,6 @@ namespace tools {
namespace autoconfig {
using nfd::ControlParameters;
using nfd::ControlResponse;
const Name HUB_DISCOVERY_PREFIX("/localhop/ndn-autoconf/hub");
const uint64_t HUB_DISCOVERY_ROUTE_COST(1);
@@ -55,9 +54,9 @@ MulticastDiscovery::doStart()
m_controller.fetch<nfd::FaceQueryDataset>(
filter,
bind(&MulticastDiscovery::registerHubDiscoveryPrefix, this, _1),
[this] (const auto& dataset) { registerHubDiscoveryPrefix(dataset); },
[this] (uint32_t code, const std::string& reason) {
this->fail("Error " + to_string(code) + " when querying multi-access faces: " + reason);
fail("Error " + to_string(code) + " when querying multi-access faces: " + reason);
});
}
@@ -65,7 +64,7 @@ void
MulticastDiscovery::registerHubDiscoveryPrefix(const std::vector<nfd::FaceStatus>& dataset)
{
if (dataset.empty()) {
this->fail("No multi-access faces available");
fail("No multi-access faces available");
return;
}
@@ -82,11 +81,11 @@ MulticastDiscovery::registerHubDiscoveryPrefix(const std::vector<nfd::FaceStatus
m_controller.start<nfd::RibRegisterCommand>(
parameters,
[this] (const ControlParameters&) {
[this] (const auto&) {
++m_nRegSuccess;
afterReg();
},
[this, faceStatus] (const ControlResponse& resp) {
[this, faceStatus] (const auto& resp) {
std::cerr << "Error " << resp.getCode() << " when registering hub discovery prefix "
<< "for face " << faceStatus.getFaceId() << " (" << faceStatus.getRemoteUri()
<< "): " << resp.getText() << std::endl;
@@ -103,10 +102,10 @@ MulticastDiscovery::afterReg()
return; // continue waiting
}
if (m_nRegSuccess > 0) {
this->setStrategy();
setStrategy();
}
else {
this->fail("Cannot register hub discovery prefix for any face");
fail("Cannot register hub discovery prefix for any face");
}
}
@@ -119,10 +118,9 @@ MulticastDiscovery::setStrategy()
m_controller.start<nfd::StrategyChoiceSetCommand>(
parameters,
bind(&MulticastDiscovery::requestHubData, this),
[this] (const ControlResponse& resp) {
this->fail("Error " + to_string(resp.getCode()) + " when setting multicast strategy: " +
resp.getText());
[this] (const auto&) { requestHubData(); },
[this] (const auto& resp) {
fail("Error " + to_string(resp.getCode()) + " when setting multicast strategy: " + resp.getText());
});
}
@@ -141,17 +139,17 @@ MulticastDiscovery::requestHubData()
auto i = content.find(tlv::nfd::Uri);
if (i == content.elements_end()) {
this->fail("Malformed hub Data: missing Uri element");
fail("Malformed hub Data: missing Uri element");
return;
}
this->provideHubFaceUri(std::string(reinterpret_cast<const char*>(i->value()), i->value_size()));
provideHubFaceUri(std::string(reinterpret_cast<const char*>(i->value()), i->value_size()));
},
[this] (const Interest&, const lp::Nack& nack) {
this->fail("Nack-" + boost::lexical_cast<std::string>(nack.getReason()) + " when retrieving hub Data");
fail("Nack-" + boost::lexical_cast<std::string>(nack.getReason()) + " when retrieving hub Data");
},
[this] (const Interest&) {
this->fail("Timeout when retrieving hub Data");
fail("Timeout when retrieving hub Data");
});
}
+5 -5
View File
@@ -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,
@@ -52,16 +52,16 @@ void
Procedure::initialize(const Options& options)
{
BOOST_ASSERT(m_stages.empty());
this->makeStages(options);
makeStages(options);
BOOST_ASSERT(!m_stages.empty());
for (size_t i = 0; i < m_stages.size(); ++i) {
m_stages[i]->onSuccess.connect(bind(&Procedure::connect, this, _1));
m_stages[i]->onSuccess.connect([this] (const auto& uri) { connect(uri); });
if (i + 1 < m_stages.size()) {
m_stages[i]->onFailure.connect([=] (const std::string&) { m_stages[i + 1]->start(); });
m_stages[i]->onFailure.connect([=] (const auto&) { m_stages[i + 1]->start(); });
}
else {
m_stages[i]->onFailure.connect([=] (const std::string&) { this->onComplete(false); });
m_stages[i]->onFailure.connect([=] (const auto&) { onComplete(false); });
}
}
}
+9 -15
View File
@@ -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,
@@ -90,7 +90,7 @@ public:
isBlacklisted(const boost::asio::ip::address& address) const
{
return std::any_of(m_blackList.begin(), m_blackList.end(),
bind(&Network::doesContain, _1, address));
std::bind(&Network::doesContain, _1, address));
}
/**
@@ -100,7 +100,7 @@ public:
isWhitelisted(const boost::asio::ip::address& address) const
{
return std::any_of(m_whiteList.begin(), m_whiteList.end(),
bind(&Network::doesContain, _1, address));
std::bind(&Network::doesContain, _1, address));
}
void
@@ -114,8 +114,8 @@ public:
.setOrigin(nfd::ROUTE_ORIGIN_AUTOREG)
.setCost(m_cost)
.setExpirationPeriod(time::milliseconds::max()),
bind(&AutoregServer::onRegisterCommandSuccess, this, faceId, prefix),
bind(&AutoregServer::onRegisterCommandFailure, this, faceId, prefix, _1));
std::bind(&AutoregServer::onRegisterCommandSuccess, this, faceId, prefix),
std::bind(&AutoregServer::onRegisterCommandFailure, this, faceId, prefix, _1));
}
}
@@ -154,12 +154,6 @@ public:
}
}
void
signalHandler()
{
m_face.shutdown();
}
static void
usage(std::ostream& os,
const boost::program_options::options_description& desc,
@@ -194,11 +188,11 @@ public:
std::cout << " " << network << std::endl;
}
m_faceMonitor.onNotification.connect(bind(&AutoregServer::onNotification, this, _1));
m_faceMonitor.onNotification.connect(std::bind(&AutoregServer::onNotification, this, _1));
m_faceMonitor.start();
boost::asio::signal_set signalSet(m_face.getIoService(), SIGINT, SIGTERM);
signalSet.async_wait(bind(&AutoregServer::signalHandler, this));
signalSet.async_wait([this] (auto&&...) { m_face.shutdown(); });
m_face.processEvents();
}
@@ -207,13 +201,13 @@ public:
startFetchingFaceStatusDataset()
{
m_controller.fetch<nfd::FaceDataset>(
[this] (const std::vector<nfd::FaceStatus>& faces) {
[this] (const auto& faces) {
for (const auto& faceStatus : faces) {
registerPrefixesIfNeeded(faceStatus.getFaceId(), FaceUri(faceStatus.getRemoteUri()),
faceStatus.getFacePersistency());
}
},
[] (uint32_t code, const std::string& reason) {});
[] (auto&&...) {});
}
int
+2 -1
View File
@@ -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,
@@ -30,6 +30,7 @@
#include "status-report.hpp"
#include <ndn-cxx/encoding/nfd-constants.hpp>
#include <ndn-cxx/util/any.hpp>
#include <boost/logic/tribool.hpp>
+2 -2
View File
@@ -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,
@@ -236,7 +236,7 @@ FaceModule::create(ExecuteContext& ctx)
if (isChangingParams) {
ctx.controller.start<ndn::nfd::FaceUpdateCommand>(
params,
bind(updateFace, respParams, _1),
[=, &updateFace] (const auto& cp) { updateFace(respParams, cp); },
ctx.makeCommandFailureHandler("updating face"),
ctx.makeCommandOptions());
}
+4 -4
View File
@@ -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,
@@ -110,9 +110,9 @@ formatDuration(time::nanoseconds d)
}
std::string
formatTimestamp(time::system_clock::TimePoint t)
formatTimestamp(time::system_clock::time_point t)
{
return time::toString(t, "%Y-%m-%dT%H:%M:%S%F");
return time::toIsoExtendedString(t);
}
} // namespace xml
@@ -199,7 +199,7 @@ operator<<(std::ostream& os, YesNo v)
}
std::string
formatTimestamp(time::system_clock::TimePoint t)
formatTimestamp(time::system_clock::time_point t)
{
return time::toIsoString(t);
}
+3 -3
View File
@@ -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,
@@ -73,7 +73,7 @@ formatDuration(time::nanoseconds d);
* Definition of this format: https://www.w3.org/TR/xmlschema11-2/#dateTime
*/
std::string
formatTimestamp(time::system_clock::TimePoint t);
formatTimestamp(time::system_clock::time_point t);
} // namespace xml
@@ -262,7 +262,7 @@ formatDuration(time::nanoseconds d, bool isLong = false)
}
std::string
formatTimestamp(time::system_clock::TimePoint t);
formatTimestamp(time::system_clock::time_point t);
} // namespace text
+2 -2
View File
@@ -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,
@@ -46,7 +46,7 @@ ForwarderGeneralModule::fetchStatus(Controller& controller,
onFailure, options);
}
static time::system_clock::Duration
static auto
calculateUptime(const ForwarderStatus& status)
{
return status.getCurrentTimestamp() - status.getStartTimestamp();
+9 -5
View File
@@ -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,
@@ -128,25 +128,29 @@ registerStatusCommands(CommandParser& parser)
CommandDefinition defStatusShow("status", "show");
defStatusShow
.setTitle("print general status");
parser.addCommand(defStatusShow, bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantForwarderGeneral));
parser.addCommand(defStatusShow,
std::bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantForwarderGeneral));
parser.addAlias("status", "show", "");
CommandDefinition defChannelList("channel", "list");
defChannelList
.setTitle("print channel list");
parser.addCommand(defChannelList, bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantChannels));
parser.addCommand(defChannelList,
std::bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantChannels));
parser.addAlias("channel", "list", "");
CommandDefinition defFibList("fib", "list");
defFibList
.setTitle("print FIB entries");
parser.addCommand(defFibList, bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantFib));
parser.addCommand(defFibList,
std::bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantFib));
parser.addAlias("fib", "list", "");
CommandDefinition defCsInfo("cs", "info");
defCsInfo
.setTitle("print CS information");
parser.addCommand(defCsInfo, bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantCs));
parser.addCommand(defCsInfo,
std::bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantCs));
parser.addAlias("cs", "info", "");
}