build: switch to C++17
Change-Id: Id6217b5c993f3e4726e89773128b565e5f136bb6
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index f3be6e7..0bf48cc 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -135,7 +135,7 @@
"""
def getGeneralFlags(self, conf):
flags = super(GccBasicFlags, self).getGeneralFlags(conf)
- flags['CXXFLAGS'] += ['-std=c++14']
+ flags['CXXFLAGS'] += ['-std=c++17']
if Utils.unversioned_sys_platform() == 'linux':
flags['LINKFLAGS'] += ['-fuse-ld=gold']
elif Utils.unversioned_sys_platform() == 'freebsd':
diff --git a/README.md b/README.md
index f7cc977..94dabe6 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
[![CI](https://github.com/named-data/ndn-tools/actions/workflows/ci.yml/badge.svg)](https://github.com/named-data/ndn-tools/actions/workflows/ci.yml)
[![Docs](https://github.com/named-data/ndn-tools/actions/workflows/docs.yml/badge.svg)](https://github.com/named-data/ndn-tools/actions/workflows/docs.yml)
-![Language](https://img.shields.io/badge/C%2B%2B-14-blue)
+![Language](https://img.shields.io/badge/C%2B%2B-17-blue)
![Latest version](https://img.shields.io/github/v/tag/named-data/ndn-tools?label=Latest%20version)
**ndn-tools** is a collection of basic tools for [Named Data Networking](https://named-data.net/).
diff --git a/core/common.hpp b/core/common.hpp
index 34da654..614dd4e 100644
--- a/core/common.hpp
+++ b/core/common.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -46,6 +46,7 @@
#include <memory>
#include <stdexcept>
#include <string>
+#include <string_view>
#include <utility>
#include <vector>
diff --git a/core/version.cpp.in b/core/version.cpp.in
index 8abef00..04fd901 100644
--- a/core/version.cpp.in
+++ b/core/version.cpp.in
@@ -19,10 +19,8 @@
#include "core/version.hpp"
-namespace ndn {
-namespace tools {
+namespace ndn::tools {
const char VERSION[] = "@VERSION_BUILD@";
-} // namespace tools
-} // namespace ndn
+} // namespace ndn::tools
diff --git a/core/version.hpp b/core/version.hpp
index 03058f6..2a20a1a 100644
--- a/core/version.hpp
+++ b/core/version.hpp
@@ -22,15 +22,13 @@
#include "core/common.hpp"
-namespace ndn {
-namespace tools {
+namespace ndn::tools {
/**
* \brief The version of ndn-tools.
*/
extern const char VERSION[];
-} // namespace tools
-} // namespace ndn
+} // namespace ndn::tools
#endif // NDN_TOOLS_CORE_VERSION_HPP
diff --git a/tests/chunks/consumer.t.cpp b/tests/chunks/consumer.t.cpp
index 205cfb3..e5a584f 100644
--- a/tests/chunks/consumer.t.cpp
+++ b/tests/chunks/consumer.t.cpp
@@ -39,9 +39,7 @@
#include <boost/test/output_test_stream.hpp>
#endif
-namespace ndn {
-namespace chunks {
-namespace tests {
+namespace ndn::chunks::tests {
using namespace ndn::tests;
using boost::test_tools::output_test_stream;
@@ -175,6 +173,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestConsumer
BOOST_AUTO_TEST_SUITE_END() // Chunks
-} // namespace tests
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks::tests
diff --git a/tests/chunks/discover-version.t.cpp b/tests/chunks/discover-version.t.cpp
index 79315cc..7d18886 100644
--- a/tests/chunks/discover-version.t.cpp
+++ b/tests/chunks/discover-version.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2020, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -32,9 +32,7 @@
#include <ndn-cxx/metadata-object.hpp>
#include <ndn-cxx/util/dummy-client-face.hpp>
-namespace ndn {
-namespace chunks {
-namespace tests {
+namespace ndn::chunks::tests {
using namespace ndn::tests;
@@ -215,6 +213,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestDiscoverVersion
BOOST_AUTO_TEST_SUITE_END() // Chunks
-} // namespace tests
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks::tests
diff --git a/tests/chunks/pipeline-interests-aimd.t.cpp b/tests/chunks/pipeline-interests-aimd.t.cpp
index feed933..0946021 100644
--- a/tests/chunks/pipeline-interests-aimd.t.cpp
+++ b/tests/chunks/pipeline-interests-aimd.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2020, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -29,17 +29,14 @@
#include "pipeline-interests-fixture.hpp"
-namespace ndn {
-namespace chunks {
-namespace tests {
+namespace ndn::chunks::tests {
using namespace ndn::tests;
class PipelineInterestAimdFixture : public PipelineInterestsFixture
{
-public:
+protected:
PipelineInterestAimdFixture()
- : rttEstimator(makeRttEstimatorOptions())
{
opt.isQuiet = true;
createPipeline();
@@ -70,7 +67,7 @@
protected:
Options opt;
- RttEstimatorWithStats rttEstimator;
+ RttEstimatorWithStats rttEstimator{makeRttEstimatorOptions()};
PipelineInterestsAdaptive* pipeline;
static constexpr double MARGIN = 0.001;
};
@@ -596,6 +593,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestPipelineInterestsAimd
BOOST_AUTO_TEST_SUITE_END() // Chunks
-} // namespace tests
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks::tests
diff --git a/tests/chunks/pipeline-interests-cubic.t.cpp b/tests/chunks/pipeline-interests-cubic.t.cpp
index fc53343..9934d9f 100644
--- a/tests/chunks/pipeline-interests-cubic.t.cpp
+++ b/tests/chunks/pipeline-interests-cubic.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2020, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -29,17 +29,14 @@
#include "pipeline-interests-fixture.hpp"
-namespace ndn {
-namespace chunks {
-namespace tests {
+namespace ndn::chunks::tests {
using namespace ndn::tests;
class PipelineInterestCubicFixture : public PipelineInterestsFixture
{
-public:
+protected:
PipelineInterestCubicFixture()
- : rttEstimator(makeRttEstimatorOptions())
{
opt.isQuiet = true;
createPipeline();
@@ -70,7 +67,7 @@
protected:
Options opt;
- RttEstimatorWithStats rttEstimator;
+ RttEstimatorWithStats rttEstimator{makeRttEstimatorOptions()};
PipelineInterestsCubic* pipeline;
static constexpr double MARGIN = 0.001;
};
@@ -562,6 +559,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestPipelineInterestsCubic
BOOST_AUTO_TEST_SUITE_END() // Chunks
-} // namespace tests
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks::tests
diff --git a/tests/chunks/pipeline-interests-fixed.t.cpp b/tests/chunks/pipeline-interests-fixed.t.cpp
index 872fe4e..b4f9723 100644
--- a/tests/chunks/pipeline-interests-fixed.t.cpp
+++ b/tests/chunks/pipeline-interests-fixed.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2020, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -29,9 +29,7 @@
#include "pipeline-interests-fixture.hpp"
-namespace ndn {
-namespace chunks {
-namespace tests {
+namespace ndn::chunks::tests {
class PipelineInterestFixedFixture : public PipelineInterestsFixture
{
@@ -298,6 +296,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestPipelineInterests
BOOST_AUTO_TEST_SUITE_END() // Chunks
-} // namespace tests
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks::tests
diff --git a/tests/chunks/pipeline-interests-fixture.hpp b/tests/chunks/pipeline-interests-fixture.hpp
index 643047a..ddfc82b 100644
--- a/tests/chunks/pipeline-interests-fixture.hpp
+++ b/tests/chunks/pipeline-interests-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2020, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -36,9 +36,7 @@
#include <ndn-cxx/util/dummy-client-face.hpp>
-namespace ndn {
-namespace chunks {
-namespace tests {
+namespace ndn::chunks::tests {
using namespace ndn::tests;
@@ -88,8 +86,6 @@
unique_ptr<PipelineInterests> m_pipeline;
};
-} // namespace tests
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks::tests
#endif // NDN_TOOLS_TESTS_CHUNKS_PIPELINE_INTERESTS_FIXTURE_HPP
diff --git a/tests/chunks/producer.t.cpp b/tests/chunks/producer.t.cpp
index ef53422..a4a280b 100644
--- a/tests/chunks/producer.t.cpp
+++ b/tests/chunks/producer.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -37,9 +37,7 @@
#include <cmath>
#include <sstream>
-namespace ndn {
-namespace chunks {
-namespace tests {
+namespace ndn::chunks::tests {
using namespace ndn::tests;
@@ -222,6 +220,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestProducer
BOOST_AUTO_TEST_SUITE_END() // Chunks
-} // namespace tests
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks::tests
diff --git a/tests/clock-fixture.cpp b/tests/clock-fixture.cpp
index 564f128..f138bda 100644
--- a/tests/clock-fixture.cpp
+++ b/tests/clock-fixture.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -25,8 +25,7 @@
#include "tests/clock-fixture.hpp"
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
ClockFixture::ClockFixture()
: m_steadyClock(make_shared<time::UnitTestSteadyClock>())
@@ -56,5 +55,4 @@
}
}
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/clock-fixture.hpp b/tests/clock-fixture.hpp
index f05babe..27bf167 100644
--- a/tests/clock-fixture.hpp
+++ b/tests/clock-fixture.hpp
@@ -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-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,8 +28,7 @@
#include <ndn-cxx/util/time-unit-test-clock.hpp>
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
/** \brief A test fixture that overrides steady clock and system clock.
*/
@@ -83,7 +82,6 @@
shared_ptr<time::UnitTestSystemClock> m_systemClock;
};
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
#endif // NDN_TOOLS_TESTS_CLOCK_FIXTURE_HPP
diff --git a/tests/dump/ndndump.t.cpp b/tests/dump/ndndump.t.cpp
index 217dc10..263691e 100644
--- a/tests/dump/ndndump.t.cpp
+++ b/tests/dump/ndndump.t.cpp
@@ -39,9 +39,7 @@
#include <ndn-cxx/lp/packet.hpp>
#include <ndn-cxx/net/ethernet.hpp>
-namespace ndn {
-namespace dump {
-namespace tests {
+namespace ndn::dump::tests {
namespace endian = boost::endian;
using namespace ndn::tests;
@@ -157,15 +155,11 @@
NdnDump dump;
boost::test_tools::output_test_stream output;
- static const uint16_t s_ethertypeNdn;
- static const uint16_t s_ethertypeIp4;
- static const uint16_t s_ethertypeIp6;
+ static inline const uint16_t s_ethertypeNdn = endian::native_to_big(ethernet::ETHERTYPE_NDN);
+ static inline const uint16_t s_ethertypeIp4 = endian::native_to_big(uint16_t(ETHERTYPE_IP));
+ static inline const uint16_t s_ethertypeIp6 = endian::native_to_big(uint16_t(ETHERTYPE_IPV6));
};
-const uint16_t NdnDumpFixture::s_ethertypeNdn = endian::native_to_big(ethernet::ETHERTYPE_NDN);
-const uint16_t NdnDumpFixture::s_ethertypeIp4 = endian::native_to_big(uint16_t(ETHERTYPE_IP));
-const uint16_t NdnDumpFixture::s_ethertypeIp6 = endian::native_to_big(uint16_t(ETHERTYPE_IPV6));
-
BOOST_AUTO_TEST_SUITE(Dump)
BOOST_FIXTURE_TEST_SUITE(TestNdnDump, NdnDumpFixture)
@@ -500,6 +494,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestNdnDump
BOOST_AUTO_TEST_SUITE_END() // Dump
-} // namespace tests
-} // namespace dump
-} // namespace ndn
+} // namespace ndn::dump::tests
diff --git a/tests/global-configuration.cpp b/tests/global-configuration.cpp
index f0c136a..49a330c 100644
--- a/tests/global-configuration.cpp
+++ b/tests/global-configuration.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -25,8 +25,7 @@
#include <fstream>
#include <stdlib.h>
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
class GlobalConfiguration
{
@@ -68,5 +67,4 @@
BOOST_GLOBAL_FIXTURE(GlobalConfiguration)
#endif
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/io-fixture.hpp b/tests/io-fixture.hpp
index 881065c..71b098a 100644
--- a/tests/io-fixture.hpp
+++ b/tests/io-fixture.hpp
@@ -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-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -30,8 +30,7 @@
#include <boost/asio/io_service.hpp>
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
class IoFixture : public ClockFixture
{
@@ -53,7 +52,6 @@
boost::asio::io_service m_io;
};
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
#endif // NDN_TOOLS_TESTS_IO_FIXTURE_HPP
diff --git a/tests/key-chain-fixture.cpp b/tests/key-chain-fixture.cpp
index 283c7bc..59098d7 100644
--- a/tests/key-chain-fixture.cpp
+++ b/tests/key-chain-fixture.cpp
@@ -23,8 +23,7 @@
#include <boost/filesystem.hpp>
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
using namespace ndn::security;
@@ -113,5 +112,4 @@
return saveIdentityCert(id, filename);
}
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/key-chain-fixture.hpp b/tests/key-chain-fixture.hpp
index f86de19..8c09170 100644
--- a/tests/key-chain-fixture.hpp
+++ b/tests/key-chain-fixture.hpp
@@ -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-2022, Regents of the University of California.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -23,8 +23,7 @@
#include <ndn-cxx/security/key-chain.hpp>
#include <ndn-cxx/security/signing-helpers.hpp>
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
/**
* @brief A fixture providing an in-memory KeyChain.
@@ -87,7 +86,6 @@
std::vector<std::string> m_certFiles;
};
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
#endif // NDN_TOOLS_TESTS_KEY_CHAIN_FIXTURE_HPP
diff --git a/tests/peek/ndnpeek.t.cpp b/tests/peek/ndnpeek.t.cpp
index dfb8768..b9631f7 100644
--- a/tests/peek/ndnpeek.t.cpp
+++ b/tests/peek/ndnpeek.t.cpp
@@ -31,9 +31,7 @@
#include <boost/test/output_test_stream.hpp>
#endif
-namespace ndn {
-namespace peek {
-namespace tests {
+namespace ndn::peek::tests {
using namespace ndn::tests;
using boost::test_tools::output_test_stream;
@@ -324,6 +322,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestNdnPeek
BOOST_AUTO_TEST_SUITE_END() // Peek
-} // namespace tests
-} // namespace peek
-} // namespace ndn
+} // namespace ndn::peek::tests
diff --git a/tests/peek/ndnpoke.t.cpp b/tests/peek/ndnpoke.t.cpp
index 617b516..14fe305 100644
--- a/tests/peek/ndnpoke.t.cpp
+++ b/tests/peek/ndnpoke.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -31,9 +31,7 @@
#include <ndn-cxx/util/dummy-client-face.hpp>
-namespace ndn {
-namespace peek {
-namespace tests {
+namespace ndn::peek::tests {
using namespace ndn::tests;
@@ -256,6 +254,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestNdnPoke
BOOST_AUTO_TEST_SUITE_END() // Peek
-} // namespace tests
-} // namespace peek
-} // namespace ndn
+} // namespace ndn::peek::tests
diff --git a/tests/ping/client/ping.t.cpp b/tests/ping/client/ping.t.cpp
index a0eb163..a008271 100644
--- a/tests/ping/client/ping.t.cpp
+++ b/tests/ping/client/ping.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Arizona Board of Regents.
+ * Copyright (c) 2014-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -24,10 +24,7 @@
#include <ndn-cxx/util/dummy-client-face.hpp>
-namespace ndn {
-namespace ping {
-namespace client {
-namespace tests {
+namespace ndn::ping::client::tests {
using namespace ndn::tests;
@@ -96,7 +93,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestClient
BOOST_AUTO_TEST_SUITE_END() // Ping
-} // namespace tests
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client::tests
diff --git a/tests/ping/client/statistics-collector.t.cpp b/tests/ping/client/statistics-collector.t.cpp
index 270c576..9d5423a 100644
--- a/tests/ping/client/statistics-collector.t.cpp
+++ b/tests/ping/client/statistics-collector.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Arizona Board of Regents.
+/*
+ * Copyright (c) 2014-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -20,46 +20,34 @@
#include "tools/ping/client/statistics-collector.hpp"
#include "tests/test-common.hpp"
+
#include <ndn-cxx/util/dummy-client-face.hpp>
-namespace ndn {
-namespace ping {
-namespace client {
-namespace tests {
-
-using namespace ndn::tests;
+namespace ndn::ping::client::tests {
class StatisticsCollectorFixture
{
-protected:
- StatisticsCollectorFixture()
- : pingOptions(makeOptions())
- , pingProgram(face, pingOptions)
- , sc(pingProgram, pingOptions)
- {
- }
-
private:
static Options
makeOptions()
{
Options opt;
- opt.prefix = "ndn:/ping-prefix";
+ opt.prefix = "/ping-prefix";
opt.shouldAllowStaleData = false;
opt.shouldGenerateRandomSeq = false;
opt.shouldPrintTimestamp = false;
opt.nPings = 5;
- opt.interval = time::milliseconds(100);
- opt.timeout = time::milliseconds(2000);
+ opt.interval = 100_ms;
+ opt.timeout = 2_s;
opt.startSeq = 1;
return opt;
}
protected:
util::DummyClientFace face;
- Options pingOptions;
- Ping pingProgram;
- StatisticsCollector sc;
+ Options pingOptions{makeOptions()};
+ Ping pingProgram{face, pingOptions};
+ StatisticsCollector sc{pingProgram, pingOptions};
};
BOOST_AUTO_TEST_SUITE(Ping)
@@ -211,7 +199,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestStatisticsCollector
BOOST_AUTO_TEST_SUITE_END() // Ping
-} // namespace tests
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client::tests
diff --git a/tests/ping/integrated.t.cpp b/tests/ping/integrated.t.cpp
index eafc52b..0b95ba3 100644
--- a/tests/ping/integrated.t.cpp
+++ b/tests/ping/integrated.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2020, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -26,53 +26,60 @@
#include <ndn-cxx/util/dummy-client-face.hpp>
-namespace ndn {
-namespace ping {
-namespace tests {
+namespace ndn::ping::tests {
using namespace ndn::tests;
class PingIntegratedFixture : public IoFixture, public KeyChainFixture
{
-public:
+protected:
PingIntegratedFixture()
- : serverFace(m_io, m_keyChain, {false, true})
- , clientFace(m_io, m_keyChain, {false, true})
- , wantLoss(false)
{
- serverFace.onSendInterest.connect([this] (const Interest& interest) {
- m_io.post([=] { if (!wantLoss) { clientFace.receive(interest); } });
+ serverFace.onSendInterest.connect([this] (const auto& interest) {
+ receive(clientFace, interest);
});
- clientFace.onSendInterest.connect([this] (const Interest& interest) {
- m_io.post([=] { if (!wantLoss) { serverFace.receive(interest); } });
+ clientFace.onSendInterest.connect([this] (const auto& interest) {
+ receive(serverFace, interest);
});
- serverFace.onSendData.connect([this] (const Data& data) {
- m_io.post([=] { if (!wantLoss) { clientFace.receive(data); } });
+ serverFace.onSendData.connect([this] (const auto& data) {
+ receive(clientFace, data);
});
- clientFace.onSendData.connect([this] (const Data& data) {
- m_io.post([=] { if (!wantLoss) { serverFace.receive(data); } });
+ clientFace.onSendData.connect([this] (const auto& data) {
+ receive(serverFace, data);
});
}
- void onFinish()
+ template<typename Packet>
+ void
+ receive(util::DummyClientFace& face, const Packet& pkt)
+ {
+ m_io.post([=, &face] {
+ if (!wantLoss) {
+ face.receive(pkt);
+ }
+ });
+ }
+
+ void
+ onFinish()
{
serverFace.shutdown();
clientFace.shutdown();
m_io.stop();
}
-public:
- util::DummyClientFace serverFace;
- util::DummyClientFace clientFace;
+protected:
+ util::DummyClientFace serverFace{m_io, m_keyChain, {false, true}};
+ util::DummyClientFace clientFace{m_io, m_keyChain, {false, true}};
std::unique_ptr<server::PingServer> server;
std::unique_ptr<client::Ping> client;
- bool wantLoss;
+ bool wantLoss = false;
};
BOOST_AUTO_TEST_SUITE(Ping)
-BOOST_AUTO_TEST_SUITE(TestIntegrated)
+BOOST_FIXTURE_TEST_SUITE(TestIntegrated, PingIntegratedFixture)
-BOOST_FIXTURE_TEST_CASE(Normal, PingIntegratedFixture)
+BOOST_AUTO_TEST_CASE(Normal)
{
server::Options serverOpts;
serverOpts.prefix = "ndn:/test-prefix";
@@ -103,7 +110,7 @@
BOOST_CHECK_EQUAL(4, server->getNPings());
}
-BOOST_FIXTURE_TEST_CASE(Timeout, PingIntegratedFixture)
+BOOST_AUTO_TEST_CASE(Timeout)
{
wantLoss = true;
@@ -139,6 +146,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestIntegrated
BOOST_AUTO_TEST_SUITE_END() // Ping
-} // namespace tests
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::tests
diff --git a/tests/ping/server/ping-server.t.cpp b/tests/ping/server/ping-server.t.cpp
index e01d3d7..b5c9948 100644
--- a/tests/ping/server/ping-server.t.cpp
+++ b/tests/ping/server/ping-server.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Arizona Board of Regents.
+ * Copyright (c) 2014-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -25,26 +25,13 @@
#include <ndn-cxx/util/dummy-client-face.hpp>
-namespace ndn {
-namespace ping {
-namespace server {
-namespace tests {
+namespace ndn::ping::server::tests {
using namespace ndn::tests;
-BOOST_AUTO_TEST_SUITE(Ping)
-BOOST_AUTO_TEST_SUITE(TestServer)
-
class PingServerFixture : public IoFixture, public KeyChainFixture
{
protected:
- PingServerFixture()
- : face(m_io, m_keyChain, {false, true})
- , pingOptions(makeOptions())
- , pingServer(face, m_keyChain, pingOptions)
- {
- }
-
Interest
makePingInterest(int seq) const
{
@@ -53,7 +40,6 @@
.append(to_string(seq));
return Interest(name)
- .setCanBePrefix(false)
.setMustBeFresh(true)
.setInterestLifetime(2_s);
}
@@ -73,11 +59,14 @@
}
protected:
- util::DummyClientFace face;
- Options pingOptions;
- PingServer pingServer;
+ util::DummyClientFace face{m_io, m_keyChain, {false, true}};
+ Options pingOptions{makeOptions()};
+ PingServer pingServer{face, m_keyChain, pingOptions};
};
+BOOST_AUTO_TEST_SUITE(Ping)
+BOOST_AUTO_TEST_SUITE(TestServer)
+
BOOST_FIXTURE_TEST_CASE(Receive, PingServerFixture)
{
BOOST_TEST(pingServer.getNPings() == 0);
@@ -96,7 +85,4 @@
BOOST_AUTO_TEST_SUITE_END() // TestServer
BOOST_AUTO_TEST_SUITE_END() // Ping
-} // namespace tests
-} // namespace server
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::server::tests
diff --git a/tests/test-case.t.cpp.sample b/tests/test-case.t.cpp.sample
index 8f6584b..a2f74c1 100644
--- a/tests/test-case.t.cpp.sample
+++ b/tests/test-case.t.cpp.sample
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020 Arizona Board of Regents.
+ * Copyright (c) 2014-2022 Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -26,15 +26,14 @@
#include "tests/io-fixture.hpp" // optional, for IoFixture
//#include "tests/key-chain-fixture.hpp" // optional, for KeyChainFixture
-namespace ndn {
-namespace tool_name {
-namespace tests {
// Unit tests should go inside the ndn::tool_name::tests namespace.
+namespace ndn::tool_name::tests {
// Common fixtures in ndn::tests can be imported if needed.
using namespace ndn::tests;
-// See https://redmine.named-data.net/projects/nfd/wiki/UnitTesting for a guide on how to name a test suite.
+// See https://redmine.named-data.net/projects/nfd/wiki/UnitTesting
+// for a guide on how to name a test suite.
BOOST_AUTO_TEST_SUITE(TestSkeleton)
BOOST_AUTO_TEST_CASE(Test1)
@@ -55,8 +54,6 @@
advanceClocks(500_ms);
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestSkeleton
-} // namespace tests
-} // namespace tool_name
-} // namespace ndn
+} // namespace ndn::tool_name::tests
diff --git a/tests/test-common.cpp b/tests/test-common.cpp
index 98fa188..6a994b0 100644
--- a/tests/test-common.cpp
+++ b/tests/test-common.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -25,8 +25,7 @@
#include "tests/test-common.hpp"
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
shared_ptr<Interest>
makeInterest(const Name& name, bool canBePrefix, optional<time::milliseconds> lifetime,
@@ -65,5 +64,4 @@
return nack;
}
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
diff --git a/tests/test-common.hpp b/tests/test-common.hpp
index 5fa2a8d..5ff903a 100644
--- a/tests/test-common.hpp
+++ b/tests/test-common.hpp
@@ -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-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -29,8 +29,7 @@
#include "core/common.hpp"
#include "tests/boost-test.hpp"
-namespace ndn {
-namespace tests {
+namespace ndn::tests {
/**
* \brief Create an Interest
@@ -85,7 +84,6 @@
pkt.setName(name);
}
-} // namespace tests
-} // namespace ndn
+} // namespace ndn::tests
#endif // NDN_TOOLS_TESTS_TEST_COMMON_HPP
diff --git a/tools/chunks/catchunks/consumer.cpp b/tools/chunks/catchunks/consumer.cpp
index ac83227..a1c2edf 100644
--- a/tools/chunks/catchunks/consumer.cpp
+++ b/tools/chunks/catchunks/consumer.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -27,8 +27,7 @@
#include "consumer.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
Consumer::Consumer(security::Validator& validator, std::ostream& os)
: m_validator(validator)
@@ -86,5 +85,4 @@
}
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/consumer.hpp b/tools/chunks/catchunks/consumer.hpp
index a2151a9..8423ace 100644
--- a/tools/chunks/catchunks/consumer.hpp
+++ b/tools/chunks/catchunks/consumer.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -36,8 +36,7 @@
#include <map>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
/**
* @brief Segmented version consumer
@@ -100,7 +99,6 @@
std::map<uint64_t, shared_ptr<const Data>> m_bufferedData;
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_CONSUMER_HPP
diff --git a/tools/chunks/catchunks/data-fetcher.cpp b/tools/chunks/catchunks/data-fetcher.cpp
index baed34f..2e5fc9e 100644
--- a/tools/chunks/catchunks/data-fetcher.cpp
+++ b/tools/chunks/catchunks/data-fetcher.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -28,11 +28,7 @@
#include <cmath>
-namespace ndn {
-namespace chunks {
-
-const int DataFetcher::MAX_RETRIES_INFINITE = -1;
-const time::milliseconds DataFetcher::MAX_CONGESTION_BACKOFF_TIME = time::seconds(10);
+namespace ndn::chunks {
shared_ptr<DataFetcher>
DataFetcher::fetch(Face& face, const Interest& interest, int maxNackRetries, int maxTimeoutRetries,
@@ -60,12 +56,7 @@
, m_onTimeout(std::move(onTimeout))
, m_maxNackRetries(maxNackRetries)
, m_maxTimeoutRetries(maxTimeoutRetries)
- , m_nNacks(0)
- , m_nTimeouts(0)
- , m_nCongestionRetries(0)
, m_isVerbose(isVerbose)
- , m_isStopped(false)
- , m_hasError(false)
{
BOOST_ASSERT(m_onData != nullptr);
}
@@ -177,5 +168,4 @@
}
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/data-fetcher.hpp b/tools/chunks/catchunks/data-fetcher.hpp
index 53e32c0..c51d577 100644
--- a/tools/chunks/catchunks/data-fetcher.hpp
+++ b/tools/chunks/catchunks/data-fetcher.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -29,11 +29,10 @@
#include "core/common.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
/**
- * @brief fetch data for a given interest and handle timeout or nack error with retries
+ * @brief Fetch data for a given interest and handle timeout or nack error with retries.
*
* To instantiate a DataFetcher you need to use the static method fetch, this will also express the
* interest. After a timeout or nack is received, the same interest with a different nonce will be
@@ -53,12 +52,12 @@
* @brief means that there is no maximum number of retries,
* i.e. fetching must be retried indefinitely
*/
- static const int MAX_RETRIES_INFINITE;
+ static constexpr int MAX_RETRIES_INFINITE = -1;
/**
* @brief ceiling value for backoff time used in congestion handling
*/
- static const time::milliseconds MAX_CONGESTION_BACKOFF_TIME;
+ static constexpr time::milliseconds MAX_CONGESTION_BACKOFF_TIME = 10_s;
using FailureCallback = std::function<void(const Interest& interest, const std::string& reason)>;
@@ -117,16 +116,15 @@
int m_maxNackRetries;
int m_maxTimeoutRetries;
- int m_nNacks;
- int m_nTimeouts;
- uint32_t m_nCongestionRetries;
+ int m_nNacks = 0;
+ int m_nTimeouts = 0;
+ uint32_t m_nCongestionRetries = 0;
- bool m_isVerbose;
- bool m_isStopped;
- bool m_hasError;
+ bool m_isVerbose = false;
+ bool m_isStopped = false;
+ bool m_hasError = false;
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_DATA_FETCHER_HPP
diff --git a/tools/chunks/catchunks/discover-version.cpp b/tools/chunks/catchunks/discover-version.cpp
index e35fc21..5eae250 100644
--- a/tools/chunks/catchunks/discover-version.cpp
+++ b/tools/chunks/catchunks/discover-version.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -31,8 +31,7 @@
#include <ndn-cxx/metadata-object.hpp>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
DiscoverVersion::DiscoverVersion(Face& face, const Name& prefix, const Options& options)
: m_face(face)
@@ -93,5 +92,4 @@
onDiscoverySuccess(mobject.getVersionedName());
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/discover-version.hpp b/tools/chunks/catchunks/discover-version.hpp
index 62a5e42..6a05727 100644
--- a/tools/chunks/catchunks/discover-version.hpp
+++ b/tools/chunks/catchunks/discover-version.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -33,8 +33,7 @@
#include <ndn-cxx/util/signal.hpp>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
class DataFetcher;
@@ -73,7 +72,6 @@
shared_ptr<DataFetcher> m_fetcher;
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_DISCOVER_VERSION_HPP
diff --git a/tools/chunks/catchunks/main.cpp b/tools/chunks/catchunks/main.cpp
index 59ea8d8..e89d904 100644
--- a/tools/chunks/catchunks/main.cpp
+++ b/tools/chunks/catchunks/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -45,8 +45,7 @@
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
namespace po = boost::program_options;
@@ -309,8 +308,7 @@
return 0;
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
int
main(int argc, char* argv[])
diff --git a/tools/chunks/catchunks/options.hpp b/tools/chunks/catchunks/options.hpp
index fbca964..c93e9c2 100644
--- a/tools/chunks/catchunks/options.hpp
+++ b/tools/chunks/catchunks/options.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -29,8 +29,7 @@
#include "core/common.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
struct Options : noncopyable
{
@@ -62,7 +61,6 @@
bool enableFastConv = false; ///< use cubic fast convergence
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_OPTIONS_HPP
diff --git a/tools/chunks/catchunks/pipeline-interests-adaptive.cpp b/tools/chunks/catchunks/pipeline-interests-adaptive.cpp
index 595dcdc..3b3e0cd 100644
--- a/tools/chunks/catchunks/pipeline-interests-adaptive.cpp
+++ b/tools/chunks/catchunks/pipeline-interests-adaptive.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -32,8 +32,7 @@
#include <cmath>
#include <iomanip>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
constexpr double PipelineInterestsAdaptive::MIN_SSTHRESH;
@@ -45,19 +44,6 @@
, m_ssthresh(m_options.initSsthresh)
, m_rttEstimator(rttEstimator)
, m_scheduler(m_face.getIoService())
- , m_highData(0)
- , m_highInterest(0)
- , m_recPoint(0)
- , m_nInFlight(0)
- , m_nLossDecr(0)
- , m_nMarkDecr(0)
- , m_nTimeouts(0)
- , m_nSkippedRetx(0)
- , m_nRetransmitted(0)
- , m_nCongMarks(0)
- , m_nSent(0)
- , m_hasFailure(false)
- , m_failedSegNo(0)
{
}
@@ -139,7 +125,7 @@
if (isRetransmission) {
// keep track of retx count for this segment
auto ret = m_retxCount.emplace(segNo, 1);
- if (ret.second == false) { // not the first retransmission
+ if (!ret.second) { // not the first retransmission
m_retxCount[segNo] += 1;
if (m_options.maxRetriesOnTimeoutOrNack != DataFetcher::MAX_RETRIES_INFINITE &&
m_retxCount[segNo] > m_options.maxRetriesOnTimeoutOrNack) {
@@ -157,7 +143,6 @@
auto interest = Interest()
.setName(Name(m_prefix).appendSegment(segNo))
- .setCanBePrefix(false)
.setMustBeFresh(m_options.mustBeFresh)
.setInterestLifetime(m_options.interestLifetime);
@@ -471,5 +456,4 @@
return os;
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/pipeline-interests-adaptive.hpp b/tools/chunks/catchunks/pipeline-interests-adaptive.hpp
index 596c70e..15e4dcf 100644
--- a/tools/chunks/catchunks/pipeline-interests-adaptive.hpp
+++ b/tools/chunks/catchunks/pipeline-interests-adaptive.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -37,8 +37,7 @@
#include <queue>
#include <unordered_map>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
using util::RttEstimatorWithStats;
@@ -199,20 +198,20 @@
Scheduler m_scheduler;
scheduler::ScopedEventId m_checkRtoEvent;
- uint64_t m_highData; ///< the highest segment number of the Data packet the consumer has received so far
- uint64_t m_highInterest; ///< the highest segment number of the Interests the consumer has sent so far
- uint64_t m_recPoint; ///< the value of m_highInterest when a packet loss event occurred,
- ///< it remains fixed until the next packet loss event happens
+ uint64_t m_highData = 0; ///< the highest segment number of the Data packet the consumer has received so far
+ uint64_t m_highInterest = 0; ///< the highest segment number of the Interests the consumer has sent so far
+ uint64_t m_recPoint = 0; ///< the value of m_highInterest when a packet loss event occurred,
+ ///< it remains fixed until the next packet loss event happens
- int64_t m_nInFlight; ///< # of segments in flight
- int64_t m_nLossDecr; ///< # of window decreases caused by packet loss
- int64_t m_nMarkDecr; ///< # of window decreases caused by congestion marks
- int64_t m_nTimeouts; ///< # of timed out segments
- int64_t m_nSkippedRetx; ///< # of segments queued for retransmission but received before the
- ///< retransmission occurred
- int64_t m_nRetransmitted; ///< # of retransmitted segments
- int64_t m_nCongMarks; ///< # of data packets with congestion mark
- int64_t m_nSent; ///< # of interest packets sent out (including retransmissions)
+ int64_t m_nInFlight = 0; ///< # of segments in flight
+ int64_t m_nLossDecr = 0; ///< # of window decreases caused by packet loss
+ int64_t m_nMarkDecr = 0; ///< # of window decreases caused by congestion marks
+ int64_t m_nTimeouts = 0; ///< # of timed out segments
+ int64_t m_nSkippedRetx = 0; ///< # of segments queued for retransmission but received before the
+ ///< retransmission occurred
+ int64_t m_nRetransmitted = 0; ///< # of retransmitted segments
+ int64_t m_nCongMarks = 0; ///< # of data packets with congestion mark
+ int64_t m_nSent = 0; ///< # of interest packets sent out (including retransmissions)
std::unordered_map<uint64_t, SegmentInfo> m_segmentInfo; ///< keeps all the internal information
///< on sent but not acked segments
@@ -221,12 +220,11 @@
///< timeout/nack retries, the pipeline will be aborted
std::queue<uint64_t> m_retxQueue;
- bool m_hasFailure;
- uint64_t m_failedSegNo;
+ bool m_hasFailure = false;
+ uint64_t m_failedSegNo = 0;
std::string m_failureReason;
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_PIPELINE_INTERESTS_ADAPTIVE_HPP
diff --git a/tools/chunks/catchunks/pipeline-interests-aimd.cpp b/tools/chunks/catchunks/pipeline-interests-aimd.cpp
index 667bd9e..4d84fdd 100644
--- a/tools/chunks/catchunks/pipeline-interests-aimd.cpp
+++ b/tools/chunks/catchunks/pipeline-interests-aimd.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -30,8 +30,7 @@
#include <cmath>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
PipelineInterestsAimd::PipelineInterestsAimd(Face& face, RttEstimatorWithStats& rttEstimator,
const Options& opts)
@@ -65,5 +64,4 @@
emitSignal(afterCwndChange, time::steady_clock::now() - getStartTime(), m_cwnd);
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/pipeline-interests-aimd.hpp b/tools/chunks/catchunks/pipeline-interests-aimd.hpp
index f76163e..1792f95 100644
--- a/tools/chunks/catchunks/pipeline-interests-aimd.hpp
+++ b/tools/chunks/catchunks/pipeline-interests-aimd.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -31,8 +31,7 @@
#include "pipeline-interests-adaptive.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
/**
* @brief Implements AIMD window increase and decrease.
@@ -50,7 +49,6 @@
decreaseWindow() final;
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_PIPELINE_INTERESTS_AIMD_HPP
diff --git a/tools/chunks/catchunks/pipeline-interests-cubic.cpp b/tools/chunks/catchunks/pipeline-interests-cubic.cpp
index 74aab0c..5eaf411 100644
--- a/tools/chunks/catchunks/pipeline-interests-cubic.cpp
+++ b/tools/chunks/catchunks/pipeline-interests-cubic.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -27,8 +27,7 @@
#include <cmath>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
constexpr double CUBIC_C = 0.4;
@@ -111,5 +110,4 @@
emitSignal(afterCwndChange, time::steady_clock::now() - getStartTime(), m_cwnd);
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/pipeline-interests-cubic.hpp b/tools/chunks/catchunks/pipeline-interests-cubic.hpp
index daa59eb..87b4824 100644
--- a/tools/chunks/catchunks/pipeline-interests-cubic.hpp
+++ b/tools/chunks/catchunks/pipeline-interests-cubic.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -28,8 +28,7 @@
#include "pipeline-interests-adaptive.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
/**
* @brief Implements Cubic window increase and decrease.
@@ -55,7 +54,6 @@
time::steady_clock::time_point m_lastDecrease; ///< time of last window decrease
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_PIPELINE_INTERESTS_CUBIC_HPP
diff --git a/tools/chunks/catchunks/pipeline-interests-fixed.cpp b/tools/chunks/catchunks/pipeline-interests-fixed.cpp
index 7fab8e3..a80ca5e 100644
--- a/tools/chunks/catchunks/pipeline-interests-fixed.cpp
+++ b/tools/chunks/catchunks/pipeline-interests-fixed.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -30,8 +30,7 @@
#include "pipeline-interests-fixed.hpp"
#include "data-fetcher.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
PipelineInterestsFixed::PipelineInterestsFixed(Face& face, const Options& opts)
: PipelineInterests(face, opts)
@@ -83,7 +82,6 @@
auto interest = Interest()
.setName(Name(m_prefix).appendSegment(nextSegmentNo))
- .setCanBePrefix(false)
.setMustBeFresh(m_options.mustBeFresh)
.setInterestLifetime(m_options.interestLifetime);
@@ -194,5 +192,4 @@
}
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/pipeline-interests-fixed.hpp b/tools/chunks/catchunks/pipeline-interests-fixed.hpp
index b21575e..a317ad2 100644
--- a/tools/chunks/catchunks/pipeline-interests-fixed.hpp
+++ b/tools/chunks/catchunks/pipeline-interests-fixed.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -32,8 +32,7 @@
#include "pipeline-interests.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
class DataFetcher;
@@ -91,7 +90,6 @@
bool m_hasFailure = false;
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_PIPELINE_INTERESTS_FIXED_HPP
diff --git a/tools/chunks/catchunks/pipeline-interests.cpp b/tools/chunks/catchunks/pipeline-interests.cpp
index 9f2e3b5..218df28 100644
--- a/tools/chunks/catchunks/pipeline-interests.cpp
+++ b/tools/chunks/catchunks/pipeline-interests.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -33,18 +33,11 @@
#include <boost/asio/io_service.hpp>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
PipelineInterests::PipelineInterests(Face& face, const Options& opts)
: m_options(opts)
, m_face(face)
- , m_hasFinalBlockId(false)
- , m_lastSegmentNo(0)
- , m_nReceived(0)
- , m_receivedSize(0)
- , m_nextSegmentNo(0)
- , m_isStopping(false)
{
}
@@ -160,5 +153,4 @@
return "";
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/pipeline-interests.hpp b/tools/chunks/catchunks/pipeline-interests.hpp
index 9fc3389..ea52d2f 100644
--- a/tools/chunks/catchunks/pipeline-interests.hpp
+++ b/tools/chunks/catchunks/pipeline-interests.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -33,8 +33,7 @@
#include "options.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
/**
* @brief Service for retrieving Data via an Interest pipeline
@@ -46,7 +45,7 @@
* No guarantees are made as to the order in which segments are fetched or callbacks are invoked,
* i.e. out-of-order delivery is possible.
*/
-class PipelineInterests
+class PipelineInterests : noncopyable
{
public:
/**
@@ -96,7 +95,7 @@
* @brief check if the transfer is complete
* @return true if all segments have been received, false otherwise
*/
- bool
+ [[nodiscard]] bool
allSegmentsReceived() const;
/**
@@ -157,17 +156,17 @@
Name m_prefix;
PUBLIC_WITH_TESTS_ELSE_PROTECTED:
- bool m_hasFinalBlockId; ///< true if the last segment number is known
- uint64_t m_lastSegmentNo; ///< valid only if m_hasFinalBlockId == true
- int64_t m_nReceived; ///< number of segments received
- size_t m_receivedSize; ///< size of received data in bytes
+ bool m_hasFinalBlockId = false; ///< true if the last segment number is known
+ uint64_t m_lastSegmentNo = 0; ///< valid only if m_hasFinalBlockId == true
+ int64_t m_nReceived = 0; ///< number of segments received
+ size_t m_receivedSize = 0; ///< size of received data in bytes
private:
DataCallback m_onData;
FailureCallback m_onFailure;
- uint64_t m_nextSegmentNo;
+ uint64_t m_nextSegmentNo = 0;
time::steady_clock::time_point m_startTime;
- bool m_isStopping;
+ bool m_isStopping = false;
};
template<typename Packet>
@@ -177,7 +176,6 @@
return packet.getName().at(-1).toSegment();
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_PIPELINE_INTERESTS_HPP
diff --git a/tools/chunks/catchunks/statistics-collector.cpp b/tools/chunks/catchunks/statistics-collector.cpp
index 91af79d..2e303c9 100644
--- a/tools/chunks/catchunks/statistics-collector.cpp
+++ b/tools/chunks/catchunks/statistics-collector.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -24,8 +24,7 @@
#include "statistics-collector.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
StatisticsCollector::StatisticsCollector(PipelineInterestsAdaptive& pipeline,
std::ostream& osCwnd, std::ostream& osRtt)
@@ -48,5 +47,4 @@
});
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/statistics-collector.hpp b/tools/chunks/catchunks/statistics-collector.hpp
index bc57f00..95abbae 100644
--- a/tools/chunks/catchunks/statistics-collector.hpp
+++ b/tools/chunks/catchunks/statistics-collector.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -27,8 +27,7 @@
#include "pipeline-interests-adaptive.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
/**
* @brief Statistics collector for Adaptive pipelines
@@ -44,7 +43,6 @@
std::ostream& m_osRtt;
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_STATISTICS_COLLECTOR_HPP
diff --git a/tools/chunks/putchunks/main.cpp b/tools/chunks/putchunks/main.cpp
index de338f3..8969e06 100644
--- a/tools/chunks/putchunks/main.cpp
+++ b/tools/chunks/putchunks/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -34,13 +34,12 @@
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
namespace po = boost::program_options;
static void
-usage(std::ostream& os, const std::string& programName, const po::options_description& desc)
+usage(std::ostream& os, std::string_view programName, const po::options_description& desc)
{
os << "Usage: " << programName << " [options] ndn:/name\n"
<< "\n"
@@ -163,8 +162,7 @@
return 0;
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
int
main(int argc, char* argv[])
diff --git a/tools/chunks/putchunks/producer.cpp b/tools/chunks/putchunks/producer.cpp
index c353817..24565c0 100644
--- a/tools/chunks/putchunks/producer.cpp
+++ b/tools/chunks/putchunks/producer.cpp
@@ -32,8 +32,7 @@
#include <ndn-cxx/metadata-object.hpp>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
Producer::Producer(const Name& prefix, Face& face, KeyChain& keyChain, std::istream& is,
const Options& opts)
@@ -185,5 +184,4 @@
std::cerr << "Created " << m_store.size() << " chunks for prefix " << m_prefix << "\n";
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/putchunks/producer.hpp b/tools/chunks/putchunks/producer.hpp
index aad6245..7000bd7 100644
--- a/tools/chunks/putchunks/producer.hpp
+++ b/tools/chunks/putchunks/producer.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -32,8 +32,7 @@
#include "core/common.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
/**
* @brief Segmented & versioned data publisher
@@ -107,7 +106,6 @@
const Options m_options;
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_PUTCHUNKS_PRODUCER_HPP
diff --git a/tools/dissect/dissector.cpp b/tools/dissect/dissector.cpp
index dfc5c98..c612352 100644
--- a/tools/dissect/dissector.cpp
+++ b/tools/dissect/dissector.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2021, Regents of the University of California.
+ * Copyright (c) 2013-2022, Regents of the University of California.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -29,8 +29,7 @@
#include <ndn-cxx/encoding/tlv.hpp>
#include <ndn-cxx/name-component.hpp>
-namespace ndn {
-namespace dissect {
+namespace ndn::dissect {
Dissector::Dissector(std::istream& input, std::ostream& output, const Options& options)
: m_options(options)
@@ -74,7 +73,7 @@
}
}
-static const std::map<uint32_t, const char*> TLV_DICT = {
+static const std::map<uint32_t, std::string_view> TLV_DICT = {
{tlv::Interest , "Interest"},
{tlv::Data , "Data"},
{tlv::Name , "Name"},
@@ -185,5 +184,4 @@
m_branches.pop_back();
}
-} // namespace dissect
-} // namespace ndn
+} // namespace ndn::dissect
diff --git a/tools/dissect/dissector.hpp b/tools/dissect/dissector.hpp
index e408efe..6ab7087 100644
--- a/tools/dissect/dissector.hpp
+++ b/tools/dissect/dissector.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -24,8 +24,7 @@
#include <ndn-cxx/encoding/block.hpp>
-namespace ndn {
-namespace dissect {
+namespace ndn::dissect {
struct Options
{
@@ -59,7 +58,6 @@
std::vector<bool> m_branches;
};
-} // namespace dissect
-} // namespace ndn
+} // namespace ndn::dissect
#endif // NDN_TOOLS_DISSECT_DISSECTOR_HPP
diff --git a/tools/dissect/main.cpp b/tools/dissect/main.cpp
index bcb2339..1cb6546 100644
--- a/tools/dissect/main.cpp
+++ b/tools/dissect/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -26,13 +26,12 @@
#include <fstream>
-namespace ndn {
-namespace dissect {
+namespace ndn::dissect {
namespace po = boost::program_options;
static void
-usage(std::ostream& os, const std::string& programName, const po::options_description& options)
+usage(std::ostream& os, std::string_view programName, const po::options_description& options)
{
os << "Usage: " << programName << " [options] [input-file]\n"
<< "\n"
@@ -99,8 +98,7 @@
return 0;
}
-} // namespace dissect
-} // namespace ndn
+} // namespace ndn::dissect
int
main(int argc, char* argv[])
diff --git a/tools/dump/main.cpp b/tools/dump/main.cpp
index 49ea5b0..033ffc4 100644
--- a/tools/dump/main.cpp
+++ b/tools/dump/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2011-2021, Regents of the University of California.
+ * Copyright (c) 2011-2022, Regents of the University of California.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -28,15 +28,14 @@
#include <sstream>
-namespace ndn {
-namespace dump {
+namespace ndn::dump {
namespace po = boost::program_options;
static void
-usage(std::ostream& os, const std::string& appName, const po::options_description& options)
+usage(std::ostream& os, std::string_view progName, const po::options_description& options)
{
- os << "Usage: " << appName << " [options] [pcap-filter]\n"
+ os << "Usage: " << progName << " [options] [pcap-filter]\n"
<< "\n"
<< "Default pcap-filter:\n"
<< " '" << NdnDump::getDefaultPcapFilter() << "'\n"
@@ -142,8 +141,7 @@
return 0;
}
-} // namespace dump
-} // namespace ndn
+} // namespace ndn::dump
int
main(int argc, char* argv[])
diff --git a/tools/dump/ndndump.cpp b/tools/dump/ndndump.cpp
index cb1583f..4b28c63 100644
--- a/tools/dump/ndndump.cpp
+++ b/tools/dump/ndndump.cpp
@@ -39,8 +39,7 @@
#include <boost/endian/conversion.hpp>
-namespace ndn {
-namespace dump {
+namespace ndn::dump {
namespace endian = boost::endian;
@@ -517,9 +516,7 @@
}
out.addDelimiter();
- bool isOk = false;
- Block block;
- std::tie(isOk, block) = Block::fromBuffer({pkt, len});
+ auto [isOk, block] = Block::fromBuffer({pkt, len});
if (!isOk) {
// if packet is incomplete, we will not be able to process it
out << "NDN truncated packet, length " << len;
@@ -539,15 +536,12 @@
return true;
}
- Buffer::const_iterator begin, end;
- if (lpPacket.has<lp::FragmentField>()) {
- std::tie(begin, end) = lpPacket.get<lp::FragmentField>();
- }
- else {
+ if (!lpPacket.has<lp::FragmentField>()) {
out << " idle";
return true;
}
+ auto [begin, end] = lpPacket.get<lp::FragmentField>();
std::tie(isOk, netPacket) = Block::fromBuffer({begin, end});
if (!isOk) {
// if network packet is fragmented, we will not be able to process it
@@ -610,5 +604,4 @@
return std::regex_match(name.toUri(), *nameFilter);
}
-} // namespace dump
-} // namespace ndn
+} // namespace ndn::dump
diff --git a/tools/dump/ndndump.hpp b/tools/dump/ndndump.hpp
index 47a455a..9d786e7 100644
--- a/tools/dump/ndndump.hpp
+++ b/tools/dump/ndndump.hpp
@@ -37,8 +37,7 @@
#define UH_LEN len
#endif
-namespace ndn {
-namespace dump {
+namespace ndn::dump {
class OutputFormatter;
@@ -59,7 +58,7 @@
void
printPacket(const pcap_pkthdr* pkthdr, const uint8_t* payload) const;
- static constexpr const char*
+ static constexpr std::string_view
getDefaultPcapFilter() noexcept
{
return "(ether proto 0x8624) or (tcp port 6363) or (udp port 6363) or (udp port 56363)";
@@ -99,13 +98,13 @@
bool
printNdn(OutputFormatter& out, const uint8_t* pkt, size_t len) const;
- bool
+ [[nodiscard]] bool
matchesFilter(const Name& name) const;
public: // options
std::string interface;
std::string inputFile;
- std::string pcapFilter = getDefaultPcapFilter();
+ std::string pcapFilter{getDefaultPcapFilter()};
optional<std::regex> nameFilter;
bool wantPromisc = true;
bool wantTimestamp = true;
@@ -118,7 +117,6 @@
int m_dataLinkType = -1;
};
-} // namespace dump
-} // namespace ndn
+} // namespace ndn::dump
#endif // NDN_TOOLS_DUMP_NDNDUMP_HPP
diff --git a/tools/peek/ndnpeek/main.cpp b/tools/peek/ndnpeek/main.cpp
index 22523b7..0bfb677 100644
--- a/tools/peek/ndnpeek/main.cpp
+++ b/tools/peek/ndnpeek/main.cpp
@@ -41,13 +41,12 @@
#include <cstring>
#include <fstream>
-namespace ndn {
-namespace peek {
+namespace ndn::peek {
namespace po = boost::program_options;
static void
-usage(std::ostream& os, const std::string& program, const po::options_description& options)
+usage(std::ostream& os, std::string_view program, const po::options_description& options)
{
os << "Usage: " << program << " [options] /name\n"
<< "\n"
@@ -203,8 +202,7 @@
}
}
-} // namespace peek
-} // namespace ndn
+} // namespace ndn::peek
int
main(int argc, char* argv[])
diff --git a/tools/peek/ndnpeek/ndnpeek.cpp b/tools/peek/ndnpeek/ndnpeek.cpp
index 01fd6de..d58b92e 100644
--- a/tools/peek/ndnpeek/ndnpeek.cpp
+++ b/tools/peek/ndnpeek/ndnpeek.cpp
@@ -29,8 +29,7 @@
#include "ndnpeek.hpp"
-namespace ndn {
-namespace peek {
+namespace ndn::peek {
NdnPeek::NdnPeek(Face& face, const PeekOptions& options)
: m_options(options)
@@ -132,5 +131,4 @@
}
}
-} // namespace peek
-} // namespace ndn
+} // namespace ndn::peek
diff --git a/tools/peek/ndnpeek/ndnpeek.hpp b/tools/peek/ndnpeek/ndnpeek.hpp
index ce37712..eba1b1f 100644
--- a/tools/peek/ndnpeek/ndnpeek.hpp
+++ b/tools/peek/ndnpeek/ndnpeek.hpp
@@ -35,8 +35,7 @@
#include <ndn-cxx/link.hpp>
#include <ndn-cxx/util/scheduler.hpp>
-namespace ndn {
-namespace peek {
+namespace ndn::peek {
/**
* @brief options for NdnPeek
@@ -58,7 +57,7 @@
optional<time::milliseconds> timeout;
};
-class NdnPeek : boost::noncopyable
+class NdnPeek : noncopyable
{
public:
NdnPeek(Face& face, const PeekOptions& options);
@@ -119,7 +118,6 @@
Result m_result = Result::UNKNOWN;
};
-} // namespace peek
-} // namespace ndn
+} // namespace ndn::peek
#endif // NDN_TOOLS_NDNPEEK_NDNPEEK_HPP
diff --git a/tools/peek/ndnpoke/main.cpp b/tools/peek/ndnpoke/main.cpp
index f2a6830..a3e5ec2 100644
--- a/tools/peek/ndnpoke/main.cpp
+++ b/tools/peek/ndnpoke/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -33,13 +33,12 @@
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
-namespace ndn {
-namespace peek {
+namespace ndn::peek {
namespace po = boost::program_options;
static void
-usage(std::ostream& os, const std::string& program, const po::options_description& options)
+usage(std::ostream& os, std::string_view program, const po::options_description& options)
{
os << "Usage: " << program << " [options] /name\n"
<< "\n"
@@ -167,8 +166,7 @@
}
}
-} // namespace peek
-} // namespace ndn
+} // namespace ndn::peek
int
main(int argc, char* argv[])
diff --git a/tools/peek/ndnpoke/ndnpoke.cpp b/tools/peek/ndnpoke/ndnpoke.cpp
index d31a939..27feb17 100644
--- a/tools/peek/ndnpoke/ndnpoke.cpp
+++ b/tools/peek/ndnpoke/ndnpoke.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -30,8 +30,7 @@
#include <ndn-cxx/encoding/buffer-stream.hpp>
-namespace ndn {
-namespace peek {
+namespace ndn::peek {
NdnPoke::NdnPoke(Face& face, KeyChain& keyChain, std::istream& input, const PokeOptions& options)
: m_options(options)
@@ -123,11 +122,10 @@
}
void
-NdnPoke::onRegFailure(const std::string& reason)
+NdnPoke::onRegFailure(std::string_view reason)
{
m_result = Result::PREFIX_REG_FAIL;
std::cerr << "Prefix registration failure (" << reason << ")" << std::endl;
}
-} // namespace peek
-} // namespace ndn
+} // namespace ndn::peek
diff --git a/tools/peek/ndnpoke/ndnpoke.hpp b/tools/peek/ndnpoke/ndnpoke.hpp
index 5ffd8cf..16a3795 100644
--- a/tools/peek/ndnpoke/ndnpoke.hpp
+++ b/tools/peek/ndnpoke/ndnpoke.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -33,8 +33,7 @@
#include <ndn-cxx/util/scheduler.hpp>
-namespace ndn {
-namespace peek {
+namespace ndn::peek {
/**
* \brief options for NdnPoke
@@ -53,7 +52,7 @@
optional<time::milliseconds> timeout;
};
-class NdnPoke : boost::noncopyable
+class NdnPoke : noncopyable
{
public:
NdnPoke(Face& face, KeyChain& keyChain, std::istream& input, const PokeOptions& options);
@@ -93,7 +92,7 @@
onRegSuccess();
void
- onRegFailure(const std::string& reason);
+ onRegFailure(std::string_view reason);
private:
const PokeOptions m_options;
@@ -106,7 +105,6 @@
Result m_result = Result::UNKNOWN;
};
-} // namespace peek
-} // namespace ndn
+} // namespace ndn::peek
#endif // NDN_TOOLS_NDNPOKE_NDNPOKE_HPP
diff --git a/tools/ping/client/main.cpp b/tools/ping/client/main.cpp
index f49c972..a37a461 100644
--- a/tools/ping/client/main.cpp
+++ b/tools/ping/client/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Arizona Board of Regents.
+ * Copyright (c) 2014-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -32,9 +32,7 @@
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
class Runner : noncopyable
{
@@ -115,25 +113,7 @@
boost::asio::signal_set m_signalSetQuit;
};
-static time::milliseconds
-getMinimumPingInterval()
-{
- return time::milliseconds(1);
-}
-
-static time::milliseconds
-getDefaultPingInterval()
-{
- return time::milliseconds(1000);
-}
-
-static time::milliseconds
-getDefaultPingTimeoutThreshold()
-{
- return time::milliseconds(4000);
-}
-
-static void
+[[noreturn]] static void
usage(const boost::program_options::options_description& options)
{
std::cout << "Usage: ndnping [options] ndn:/name/prefix\n"
@@ -151,8 +131,8 @@
Options options;
options.shouldAllowStaleData = false;
options.nPings = -1;
- options.interval = time::milliseconds(getDefaultPingInterval());
- options.timeout = time::milliseconds(getDefaultPingTimeoutThreshold());
+ options.interval = 1_s;
+ options.timeout = 4_s;
options.startSeq = 0;
options.shouldGenerateRandomSeq = true;
options.shouldPrintTimestamp = false;
@@ -165,9 +145,9 @@
visibleOptDesc.add_options()
("help,h", "print this message and exit")
("version,V", "display version and exit")
- ("interval,i", po::value<time::milliseconds::rep>()->default_value(getDefaultPingInterval().count()),
+ ("interval,i", po::value<time::milliseconds::rep>()->default_value(options.interval.count()),
"ping interval, in milliseconds")
- ("timeout,o", po::value<time::milliseconds::rep>()->default_value(getDefaultPingTimeoutThreshold().count()),
+ ("timeout,o", po::value<time::milliseconds::rep>()->default_value(options.timeout.count()),
"ping timeout, in milliseconds")
("count,c", po::value<int>(&options.nPings), "number of pings to send (default = no limit)")
("start,n", po::value<uint64_t>(&options.startSeq),
@@ -212,9 +192,8 @@
}
options.interval = time::milliseconds(optVm["interval"].as<time::milliseconds::rep>());
- if (options.interval < getMinimumPingInterval()) {
- std::cerr << "ERROR: Specified ping interval is less than the minimum "
- << getMinimumPingInterval() << "\n";
+ if (options.interval < 1_ms) {
+ std::cerr << "ERROR: Specified ping interval is less than the minimum (1 ms)\n";
usage(visibleOptDesc);
}
@@ -258,9 +237,7 @@
return Runner(options).run();
}
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
int
main(int argc, char* argv[])
diff --git a/tools/ping/client/ping.cpp b/tools/ping/client/ping.cpp
index c52ed10..5ce8765 100644
--- a/tools/ping/client/ping.cpp
+++ b/tools/ping/client/ping.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Arizona Board of Regents.
+ * Copyright (c) 2014-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -25,15 +25,11 @@
#include <ndn-cxx/util/random.hpp>
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
Ping::Ping(Face& face, const Options& options)
: m_options(options)
- , m_nSent(0)
, m_nextSeq(options.startSeq)
- , m_nOutstanding(0)
, m_face(face)
, m_scheduler(m_face.getIoService())
{
@@ -60,7 +56,6 @@
BOOST_ASSERT((m_options.nPings < 0) || (m_nSent < m_options.nPings));
Interest interest(makePingName(m_nextSeq));
- interest.setCanBePrefix(false);
interest.setMustBeFresh(!m_options.shouldAllowStaleData);
interest.setInterestLifetime(m_options.timeout);
@@ -126,6 +121,4 @@
return name;
}
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
diff --git a/tools/ping/client/ping.hpp b/tools/ping/client/ping.hpp
index a44ca0c..f78d761 100644
--- a/tools/ping/client/ping.hpp
+++ b/tools/ping/client/ping.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -28,14 +28,12 @@
#include <ndn-cxx/util/signal.hpp>
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
-typedef time::duration<double, time::milliseconds::period> Rtt;
+using Rtt = time::duration<double, time::milliseconds::period>;
/**
- * @brief options for ndnping client
+ * @brief %Options for ndnping client.
*/
struct Options
{
@@ -144,16 +142,14 @@
private:
const Options& m_options;
- int m_nSent;
+ int m_nSent = 0;
uint64_t m_nextSeq;
- int m_nOutstanding;
+ int m_nOutstanding = 0;
Face& m_face;
Scheduler m_scheduler;
scheduler::ScopedEventId m_nextPingEvent;
};
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
#endif // NDN_TOOLS_PING_CLIENT_PING_HPP
diff --git a/tools/ping/client/statistics-collector.cpp b/tools/ping/client/statistics-collector.cpp
index 6c29405..0b6b39f 100644
--- a/tools/ping/client/statistics-collector.cpp
+++ b/tools/ping/client/statistics-collector.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -23,21 +23,11 @@
#include "statistics-collector.hpp"
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
StatisticsCollector::StatisticsCollector(Ping& ping, const Options& options)
: m_ping(ping)
, m_options(options)
- , m_nSent(0)
- , m_nReceived(0)
- , m_nNacked(0)
- , m_pingStartTime(time::steady_clock::now())
- , m_minRtt(std::numeric_limits<double>::max())
- , m_maxRtt(0.0)
- , m_sumRtt(0.0)
- , m_sumRttSquared(0.0)
{
m_ping.afterData.connect([this] (auto&&, Rtt rtt) { recordData(rtt); });
m_ping.afterNack.connect([this] (auto&&...) { recordNack(); });
@@ -153,6 +143,4 @@
return os;
}
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
diff --git a/tools/ping/client/statistics-collector.hpp b/tools/ping/client/statistics-collector.hpp
index 9622717..1810208 100644
--- a/tools/ping/client/statistics-collector.hpp
+++ b/tools/ping/client/statistics-collector.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -28,9 +28,7 @@
#include "ping.hpp"
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
/**
* @brief statistics data
@@ -52,6 +50,9 @@
std::ostream&
printSummary(std::ostream& os) const;
+
+ friend std::ostream&
+ operator<<(std::ostream& os, const Statistics& statistics);
};
/**
@@ -69,7 +70,7 @@
/**
* @brief Compute and return ping statistics as structure
*/
- Statistics
+ [[nodiscard]] Statistics
computeStatistics() const;
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
@@ -94,21 +95,16 @@
private:
Ping& m_ping;
const Options& m_options;
- int m_nSent;
- int m_nReceived;
- int m_nNacked;
- time::steady_clock::time_point m_pingStartTime;
- double m_minRtt;
- double m_maxRtt;
- double m_sumRtt;
- double m_sumRttSquared;
+ time::steady_clock::time_point m_pingStartTime = time::steady_clock::now();
+ int m_nSent = 0;
+ int m_nReceived = 0;
+ int m_nNacked = 0;
+ double m_minRtt = std::numeric_limits<double>::max();
+ double m_maxRtt = 0.0;
+ double m_sumRtt = 0.0;
+ double m_sumRttSquared = 0.0;
};
-std::ostream&
-operator<<(std::ostream& os, const Statistics& statistics);
-
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
#endif // NDN_TOOLS_PING_CLIENT_STATISTICS_COLLECTOR_HPP
diff --git a/tools/ping/client/tracer.cpp b/tools/ping/client/tracer.cpp
index 7db5085..7c16a4c 100644
--- a/tools/ping/client/tracer.cpp
+++ b/tools/ping/client/tracer.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -22,9 +22,7 @@
#include "tracer.hpp"
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
Tracer::Tracer(Ping& ping, const Options& options)
: m_options(options)
@@ -72,6 +70,4 @@
std::cerr << "ERROR: " << msg << "\n";
}
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
diff --git a/tools/ping/client/tracer.hpp b/tools/ping/client/tracer.hpp
index b6b4812..c2d375e 100644
--- a/tools/ping/client/tracer.hpp
+++ b/tools/ping/client/tracer.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -27,9 +27,7 @@
#include "ping.hpp"
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
/**
* @brief prints ping responses and timeouts
@@ -80,8 +78,6 @@
const Options& m_options;
};
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
#endif // NDN_TOOLS_PING_CLIENT_TRACER_HPP
diff --git a/tools/ping/server/main.cpp b/tools/ping/server/main.cpp
index e81125c..bf050da 100644
--- a/tools/ping/server/main.cpp
+++ b/tools/ping/server/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -31,9 +31,7 @@
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
-namespace ndn {
-namespace ping {
-namespace server {
+namespace ndn::ping::server {
namespace po = boost::program_options;
@@ -90,7 +88,7 @@
};
static void
-usage(std::ostream& os, const std::string& programName, const po::options_description& options)
+usage(std::ostream& os, std::string_view programName, const po::options_description& options)
{
os << "Usage: " << programName << " [options] <prefix>\n"
<< "\n"
@@ -187,9 +185,7 @@
return Runner(options).run();
}
-} // namespace server
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::server
int
main(int argc, char* argv[])
diff --git a/tools/ping/server/ping-server.cpp b/tools/ping/server/ping-server.cpp
index 5ceeb76..69093d3 100644
--- a/tools/ping/server/ping-server.cpp
+++ b/tools/ping/server/ping-server.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -24,15 +24,12 @@
#include <ndn-cxx/security/signing-helpers.hpp>
-namespace ndn {
-namespace ping {
-namespace server {
+namespace ndn::ping::server {
PingServer::PingServer(Face& face, KeyChain& keyChain, const Options& options)
: m_options(options)
, m_face(face)
, m_keyChain(keyChain)
- , m_nPings(0)
{
auto b = make_shared<Buffer>();
b->assign(m_options.payloadSize, 'a');
@@ -78,6 +75,4 @@
}
}
-} // namespace server
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::server
diff --git a/tools/ping/server/ping-server.hpp b/tools/ping/server/ping-server.hpp
index f13769c..e9127c0 100644
--- a/tools/ping/server/ping-server.hpp
+++ b/tools/ping/server/ping-server.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -27,9 +27,7 @@
#include <ndn-cxx/util/signal.hpp>
-namespace ndn {
-namespace ping {
-namespace server {
+namespace ndn::ping::server {
/**
* @brief Options for PingServer
@@ -105,13 +103,11 @@
const Options& m_options;
Face& m_face;
KeyChain& m_keyChain;
- size_t m_nPings;
+ size_t m_nPings = 0;
Block m_payload;
RegisteredPrefixHandle m_registeredPrefix;
};
-} // namespace server
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::server
#endif // NDN_TOOLS_PING_SERVER_PING_SERVER_HPP
diff --git a/tools/ping/server/tracer.cpp b/tools/ping/server/tracer.cpp
index c6b30b9..0a9df40 100644
--- a/tools/ping/server/tracer.cpp
+++ b/tools/ping/server/tracer.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -21,9 +21,7 @@
#include "tracer.hpp"
-namespace ndn {
-namespace ping {
-namespace server {
+namespace ndn::ping::server {
Tracer::Tracer(PingServer& pingServer, const Options& options)
: m_options(options)
@@ -38,6 +36,4 @@
}
}
-} // namespace server
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::server
diff --git a/tools/ping/server/tracer.hpp b/tools/ping/server/tracer.hpp
index a84b72e..e8aac85 100644
--- a/tools/ping/server/tracer.hpp
+++ b/tools/ping/server/tracer.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -26,9 +26,7 @@
#include "ping-server.hpp"
-namespace ndn {
-namespace ping {
-namespace server {
+namespace ndn::ping::server {
/**
* @brief Logs ping responses
@@ -42,8 +40,6 @@
const Options& m_options;
};
-} // namespace server
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::server
#endif // NDN_TOOLS_PING_SERVER_TRACER_HPP