build: migrate to C++17
Change-Id: Ic9f09efd20b608bfcb713fd319834b2666cf6242
This commit is contained in:
1 parent
0c87b12458
commit
c1d0e8e34d
54 files changed
+353
-482
No files matched your search
@@ -136,7 +136,7 @@ class GccBasicFlags(CompilerFlags):
|
||||
"""
|
||||
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':
|
||||
|
||||
@@ -2,16 +2,12 @@
|
||||
|
||||
[](https://github.com/named-data/NLSR/actions/workflows/ci.yml)
|
||||
[](https://github.com/named-data/NLSR/actions/workflows/docs.yml)
|
||||

|
||||

|
||||

|
||||
|
||||
For complete documentation and more extensive information,
|
||||
please visit the [NLSR homepage](https://named-data.net/doc/NLSR/current/).
|
||||
|
||||
If you are new to the NDN software community, please read the
|
||||
[Contributor's Guide](https://github.com/named-data/.github/blob/master/CONTRIBUTING.md)
|
||||
to get started.
|
||||
|
||||
## Overview
|
||||
|
||||
NLSR is a routing protocol in NDN that populates NDN's Routing Information Base.
|
||||
@@ -35,19 +31,17 @@ fledged inter-domain routing protocol for NDN.
|
||||
|
||||
## Source releases
|
||||
|
||||
The source code and source-code installation instructions are always available at
|
||||
the following links:
|
||||
The source code and installation instructions are available at the following locations:
|
||||
|
||||
- [Installation](https://named-data.net/doc/NLSR/current/INSTALL.html)
|
||||
- [Getting Started with NLSR](https://named-data.net/doc/NLSR/current/GETTING-STARTED.html)
|
||||
- [GitHub NLSR repository](https://github.com/named-data/NLSR)
|
||||
|
||||
## Additional information
|
||||
## Additional resources
|
||||
|
||||
- [Contributor's Guide](https://github.com/named-data/.github/blob/master/CONTRIBUTING.md)
|
||||
- [NLSR Wiki](https://redmine.named-data.net/projects/nlsr/wiki/)
|
||||
- Feature requests and bug reports are welcome on our
|
||||
[NLSR on NDN Redmine](https://redmine.named-data.net/projects/nlsr/issues)
|
||||
- [NLSR Wiki](https://redmine.named-data.net/projects/nlsr/wiki)
|
||||
- [NLSR Issue Tracker](https://redmine.named-data.net/projects/nlsr/issues)
|
||||
- [NLSR Mailing List Sign Up](https://listserv.memphis.edu/scripts/wa.exe?GETPW1)
|
||||
- [NLSR Mailing List](https://listserv.memphis.edu/scripts/wa.exe?SUBED1=NLSR-HELP-L&A=1)
|
||||
- [NLSR Mailing List Archives](https://listserv.memphis.edu/scripts/wa.exe?A0=NLSR-HELP-L)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -32,8 +32,8 @@ namespace nlsr {
|
||||
class AdjacencyList
|
||||
{
|
||||
public:
|
||||
typedef std::list<Adjacent>::const_iterator const_iterator;
|
||||
typedef std::list<Adjacent>::iterator iterator;
|
||||
using const_iterator = std::list<Adjacent>::const_iterator;
|
||||
using iterator = std::list<Adjacent>::iterator;
|
||||
|
||||
bool
|
||||
insert(const Adjacent& adjacent);
|
||||
@@ -116,12 +116,8 @@ public:
|
||||
converted to Name and findAdjacent(Name) be used.
|
||||
So when faceUri is passed as string this will cause a compile error
|
||||
*/
|
||||
template <typename T = float> void
|
||||
findAdjacent(const std::string& faceUri)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(std::is_integral<T>::value,
|
||||
"Don't use std::string with findAdjacent!");
|
||||
}
|
||||
void
|
||||
findAdjacent(const std::string&) = delete;
|
||||
|
||||
uint64_t
|
||||
getFaceId(const ndn::FaceUri& faceUri);
|
||||
|
||||
+7
-10
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -26,9 +26,6 @@ namespace nlsr {
|
||||
|
||||
INIT_LOGGER(Adjacent);
|
||||
|
||||
const double Adjacent::DEFAULT_LINK_COST = 10.0;
|
||||
const double Adjacent::NON_ADJACENT_COST = -12345;
|
||||
|
||||
Adjacent::Adjacent()
|
||||
: m_name()
|
||||
, m_faceUri()
|
||||
@@ -86,14 +83,14 @@ Adjacent::wireEncode(ndn::EncodingImpl<TAG>& encoder) const
|
||||
{
|
||||
size_t totalLength = 0;
|
||||
|
||||
totalLength += prependDoubleBlock(encoder, ndn::tlv::nlsr::Cost, m_linkCost);
|
||||
totalLength += prependDoubleBlock(encoder, nlsr::tlv::Cost, m_linkCost);
|
||||
|
||||
totalLength += prependStringBlock(encoder, ndn::tlv::nlsr::Uri, m_faceUri.toString());
|
||||
totalLength += prependStringBlock(encoder, nlsr::tlv::Uri, m_faceUri.toString());
|
||||
|
||||
totalLength += m_name.wireEncode(encoder);
|
||||
|
||||
totalLength += encoder.prependVarNumber(totalLength);
|
||||
totalLength += encoder.prependVarNumber(ndn::tlv::nlsr::Adjacency);
|
||||
totalLength += encoder.prependVarNumber(nlsr::tlv::Adjacency);
|
||||
|
||||
return totalLength;
|
||||
}
|
||||
@@ -125,7 +122,7 @@ Adjacent::wireDecode(const ndn::Block& wire)
|
||||
|
||||
m_wire = wire;
|
||||
|
||||
if (m_wire.type() != ndn::tlv::nlsr::Adjacency) {
|
||||
if (m_wire.type() != nlsr::tlv::Adjacency) {
|
||||
NDN_THROW(Error("Adjacency", m_wire.type()));
|
||||
}
|
||||
|
||||
@@ -141,7 +138,7 @@ Adjacent::wireDecode(const ndn::Block& wire)
|
||||
NDN_THROW(Error("Missing required Name field"));
|
||||
}
|
||||
|
||||
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::Uri) {
|
||||
if (val != m_wire.elements_end() && val->type() == nlsr::tlv::Uri) {
|
||||
m_faceUri = ndn::FaceUri(readString(*val));
|
||||
++val;
|
||||
}
|
||||
@@ -149,7 +146,7 @@ Adjacent::wireDecode(const ndn::Block& wire)
|
||||
NDN_THROW(Error("Missing required Uri field"));
|
||||
}
|
||||
|
||||
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::Cost) {
|
||||
if (val != m_wire.elements_end() && val->type() == nlsr::tlv::Cost) {
|
||||
m_linkCost = ndn::encoding::readDouble(*val);
|
||||
++val;
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -17,13 +17,13 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
*/
|
||||
|
||||
#ifndef NLSR_ADJACENT_HPP
|
||||
#define NLSR_ADJACENT_HPP
|
||||
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/net/face-uri.hpp>
|
||||
@@ -183,8 +183,8 @@ public:
|
||||
wireDecode(const ndn::Block& wire);
|
||||
|
||||
public:
|
||||
static const double DEFAULT_LINK_COST;
|
||||
static const double NON_ADJACENT_COST;
|
||||
static constexpr double DEFAULT_LINK_COST = 10.0;
|
||||
static constexpr double NON_ADJACENT_COST = -12345.0;
|
||||
|
||||
private:
|
||||
/*! m_name The NLSR-configured router name of the neighbor */
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include <ndn-cxx/name.hpp>
|
||||
@@ -36,7 +37,7 @@ namespace nlsr {
|
||||
|
||||
using namespace ndn::time_literals;
|
||||
|
||||
const ndn::time::seconds TIME_ALLOWED_FOR_CANONIZATION = 4_s;
|
||||
constexpr ndn::time::seconds TIME_ALLOWED_FOR_CANONIZATION = 4_s;
|
||||
|
||||
template<typename T, typename = void>
|
||||
struct is_iterator
|
||||
@@ -47,9 +48,8 @@ struct is_iterator
|
||||
/*! Use C++11 iterator_traits to check if some type is an iterator
|
||||
*/
|
||||
template<typename T>
|
||||
struct is_iterator<T, typename std::enable_if<!std::is_same<
|
||||
typename std::iterator_traits<T>::value_type,
|
||||
void>::value>::type>
|
||||
struct is_iterator<T, std::enable_if_t<!std::is_same_v<
|
||||
typename std::iterator_traits<T>::value_type, void>>>
|
||||
{
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
@@ -20,15 +20,13 @@
|
||||
|
||||
#include "conf-parameter.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
#include <ndn-cxx/security/signing-helpers.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER(ConfParameter);
|
||||
|
||||
// To be changed when breaking changes are made to sync
|
||||
const uint64_t ConfParameter::SYNC_VERSION = 10;
|
||||
|
||||
static std::unique_ptr<ndn::security::CertificateFetcherDirectFetch>
|
||||
makeCertificateFetcher(ndn::Face& face)
|
||||
{
|
||||
@@ -119,7 +117,7 @@ ConfParameter::loadCertToValidator(const ndn::security::Certificate& cert)
|
||||
m_prefixUpdateValidator.loadAnchor("Authoritative-Certificate", ndn::security::Certificate(cert));
|
||||
}
|
||||
|
||||
ndn::optional<ndn::security::Certificate>
|
||||
std::optional<ndn::security::Certificate>
|
||||
ConfParameter::initializeKey()
|
||||
{
|
||||
using namespace ndn::security;
|
||||
@@ -133,7 +131,7 @@ ConfParameter::initializeKey()
|
||||
NLSR_LOG_ERROR("Router identity " << m_routerPrefix << " not found. "
|
||||
"NLSR is running without security. "
|
||||
"If security is enabled in the configuration, NLSR will not converge.");
|
||||
return ndn::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
catch (const std::invalid_argument& e) {
|
||||
// This is (probably) needed for the dummy keychain patch.
|
||||
@@ -155,7 +153,7 @@ ConfParameter::initializeKey()
|
||||
NLSR_LOG_ERROR(exceptionText);
|
||||
throw;
|
||||
}
|
||||
return ndn::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
auto key = m_keyChain.createIdentity(instanceName).getDefaultKey();
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#define NLSR_CONF_PARAMETER_HPP
|
||||
|
||||
#include "common.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "test-access-control.hpp"
|
||||
#include "adjacency-list.hpp"
|
||||
#include "name-prefix-list.hpp"
|
||||
@@ -32,6 +31,8 @@
|
||||
#include <ndn-cxx/security/validator-config.hpp>
|
||||
#include <ndn-cxx/security/certificate-fetcher-direct-fetch.hpp>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
enum {
|
||||
@@ -475,7 +476,7 @@ public:
|
||||
return m_keyChain;
|
||||
}
|
||||
|
||||
ndn::optional<ndn::security::Certificate>
|
||||
std::optional<ndn::security::Certificate>
|
||||
initializeKey();
|
||||
|
||||
void
|
||||
@@ -530,7 +531,8 @@ private:
|
||||
SyncProtocol m_syncProtocol;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
static const uint64_t SYNC_VERSION;
|
||||
// must be incremented when breaking changes are made to sync
|
||||
static constexpr uint64_t SYNC_VERSION = 10;
|
||||
|
||||
AdjacencyList m_adjl;
|
||||
NamePrefixList m_npl;
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#include "hello-protocol.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "lsdb.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
|
||||
#include <ndn-cxx/encoding/nfd-constants.hpp>
|
||||
|
||||
@@ -30,9 +30,6 @@ namespace nlsr {
|
||||
|
||||
INIT_LOGGER(HelloProtocol);
|
||||
|
||||
const std::string HelloProtocol::INFO_COMPONENT = "INFO";
|
||||
const std::string HelloProtocol::NLSR_COMPONENT = "nlsr";
|
||||
|
||||
HelloProtocol::HelloProtocol(ndn::Face& face, ndn::KeyChain& keyChain,
|
||||
ConfParameter& confParam, RoutingTable& routingTable,
|
||||
Lsdb& lsdb)
|
||||
@@ -204,9 +201,9 @@ HelloProtocol::processInterestTimedOut(const ndn::Interest& interest)
|
||||
}
|
||||
}
|
||||
|
||||
// This is the first function that incoming Hello data will
|
||||
// see. This checks if the data appears to be signed, and passes it
|
||||
// on to validate the content of the data.
|
||||
// This is the first function that incoming Hello data will
|
||||
// see. This checks if the data appears to be signed, and passes it
|
||||
// on to validate the content of the data.
|
||||
void
|
||||
HelloProtocol::onContent(const ndn::Interest& interest, const ndn::Data& data)
|
||||
{
|
||||
|
||||
+7
-10
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -22,19 +22,16 @@
|
||||
#ifndef NLSR_HELLO_PROTOCOL_HPP
|
||||
#define NLSR_HELLO_PROTOCOL_HPP
|
||||
|
||||
#include "statistics.hpp"
|
||||
#include "test-access-control.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
#include "lsdb.hpp"
|
||||
#include "route/routing-table.hpp"
|
||||
#include "statistics.hpp"
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
#include <ndn-cxx/util/signal.hpp>
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/control-response.hpp>
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
#include <ndn-cxx/security/validation-error.hpp>
|
||||
#include <ndn-cxx/security/validator-config.hpp>
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
#include <ndn-cxx/util/signal.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
@@ -139,8 +136,8 @@ private:
|
||||
AdjacencyList& m_adjacencyList;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
static const std::string INFO_COMPONENT;
|
||||
static const std::string NLSR_COMPONENT;
|
||||
static inline const std::string INFO_COMPONENT{"INFO"};
|
||||
static inline const std::string NLSR_COMPONENT{"nlsr"};
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
+7
-7
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -62,7 +62,7 @@ AdjLsa::wireEncode(ndn::EncodingImpl<TAG>& block) const
|
||||
totalLength += Lsa::wireEncode(block);
|
||||
|
||||
totalLength += block.prependVarNumber(totalLength);
|
||||
totalLength += block.prependVarNumber(ndn::tlv::nlsr::AdjacencyLsa);
|
||||
totalLength += block.prependVarNumber(nlsr::tlv::AdjacencyLsa);
|
||||
|
||||
return totalLength;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ AdjLsa::wireDecode(const ndn::Block& wire)
|
||||
{
|
||||
m_wire = wire;
|
||||
|
||||
if (m_wire.type() != ndn::tlv::nlsr::AdjacencyLsa) {
|
||||
if (m_wire.type() != nlsr::tlv::AdjacencyLsa) {
|
||||
NDN_THROW(Error("AdjacencyLsa", m_wire.type()));
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ AdjLsa::wireDecode(const ndn::Block& wire)
|
||||
|
||||
auto val = m_wire.elements_begin();
|
||||
|
||||
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::Lsa) {
|
||||
if (val != m_wire.elements_end() && val->type() == nlsr::tlv::Lsa) {
|
||||
Lsa::wireDecode(*val);
|
||||
++val;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ AdjLsa::wireDecode(const ndn::Block& wire)
|
||||
|
||||
AdjacencyList adl;
|
||||
for (; val != m_wire.elements_end(); ++val) {
|
||||
if (val->type() == ndn::tlv::nlsr::Adjacency) {
|
||||
if (val->type() == nlsr::tlv::Adjacency) {
|
||||
adl.insert(Adjacent(*val));
|
||||
}
|
||||
else {
|
||||
@@ -148,9 +148,9 @@ AdjLsa::update(const std::shared_ptr<Lsa>& lsa)
|
||||
for (const auto& adjacent : alsa->getAdl()) {
|
||||
addAdjacent(adjacent);
|
||||
}
|
||||
return std::make_tuple(true, std::list<ndn::Name>{}, std::list<ndn::Name>{});
|
||||
return {true, std::list<ndn::Name>{}, std::list<ndn::Name>{}};
|
||||
}
|
||||
return std::make_tuple(false, std::list<ndn::Name>{}, std::list<ndn::Name>{});
|
||||
return {false, std::list<ndn::Name>{}, std::list<ndn::Name>{}};
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
|
||||
+10
-11
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -65,16 +65,15 @@ CoordinateLsa::wireEncode(ndn::EncodingImpl<TAG>& block) const
|
||||
size_t totalLength = 0;
|
||||
|
||||
for (auto it = m_hyperbolicAngles.rbegin(); it != m_hyperbolicAngles.rend(); ++it) {
|
||||
totalLength += ndn::encoding::prependDoubleBlock(block, ndn::tlv::nlsr::HyperbolicAngle, *it);
|
||||
totalLength += ndn::encoding::prependDoubleBlock(block, nlsr::tlv::HyperbolicAngle, *it);
|
||||
}
|
||||
|
||||
totalLength += ndn::encoding::prependDoubleBlock(block, ndn::tlv::nlsr::HyperbolicRadius,
|
||||
m_hyperbolicRadius);
|
||||
totalLength += ndn::encoding::prependDoubleBlock(block, nlsr::tlv::HyperbolicRadius, m_hyperbolicRadius);
|
||||
|
||||
totalLength += Lsa::wireEncode(block);
|
||||
|
||||
totalLength += block.prependVarNumber(totalLength);
|
||||
totalLength += block.prependVarNumber(ndn::tlv::nlsr::CoordinateLsa);
|
||||
totalLength += block.prependVarNumber(nlsr::tlv::CoordinateLsa);
|
||||
|
||||
return totalLength;
|
||||
}
|
||||
@@ -104,7 +103,7 @@ CoordinateLsa::wireDecode(const ndn::Block& wire)
|
||||
{
|
||||
m_wire = wire;
|
||||
|
||||
if (m_wire.type() != ndn::tlv::nlsr::CoordinateLsa) {
|
||||
if (m_wire.type() != nlsr::tlv::CoordinateLsa) {
|
||||
NDN_THROW(Error("CoordinateLsa", m_wire.type()));
|
||||
}
|
||||
|
||||
@@ -112,7 +111,7 @@ CoordinateLsa::wireDecode(const ndn::Block& wire)
|
||||
|
||||
auto val = m_wire.elements_begin();
|
||||
|
||||
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::Lsa) {
|
||||
if (val != m_wire.elements_end() && val->type() == nlsr::tlv::Lsa) {
|
||||
Lsa::wireDecode(*val);
|
||||
++val;
|
||||
}
|
||||
@@ -120,7 +119,7 @@ CoordinateLsa::wireDecode(const ndn::Block& wire)
|
||||
NDN_THROW(Error("Missing required Lsa field"));
|
||||
}
|
||||
|
||||
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::HyperbolicRadius) {
|
||||
if (val != m_wire.elements_end() && val->type() == nlsr::tlv::HyperbolicRadius) {
|
||||
m_hyperbolicRadius = ndn::encoding::readDouble(*val);
|
||||
++val;
|
||||
}
|
||||
@@ -130,7 +129,7 @@ CoordinateLsa::wireDecode(const ndn::Block& wire)
|
||||
|
||||
std::vector<double> angles;
|
||||
for (; val != m_wire.elements_end(); ++val) {
|
||||
if (val->type() == ndn::tlv::nlsr::HyperbolicAngle) {
|
||||
if (val->type() == nlsr::tlv::HyperbolicAngle) {
|
||||
angles.push_back(ndn::encoding::readDouble(*val));
|
||||
}
|
||||
else {
|
||||
@@ -164,9 +163,9 @@ CoordinateLsa::update(const std::shared_ptr<Lsa>& lsa)
|
||||
for (const auto& angle : clsa->getCorTheta()) {
|
||||
m_hyperbolicAngles.push_back(angle);
|
||||
}
|
||||
return std::make_tuple(true, std::list<ndn::Name>{}, std::list<ndn::Name>{});
|
||||
return {true, std::list<ndn::Name>{}, std::list<ndn::Name>{}};
|
||||
}
|
||||
return std::make_tuple(false, std::list<ndn::Name>{}, std::list<ndn::Name>{});
|
||||
return {false, std::list<ndn::Name>{}, std::list<ndn::Name>{}};
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
|
||||
+5
-5
@@ -49,15 +49,15 @@ Lsa::wireEncode(ndn::EncodingImpl<TAG>& encoder) const
|
||||
size_t totalLength = 0;
|
||||
|
||||
totalLength += prependStringBlock(encoder,
|
||||
ndn::tlv::nlsr::ExpirationTime,
|
||||
nlsr::tlv::ExpirationTime,
|
||||
ndn::time::toString(m_expirationTimePoint));
|
||||
|
||||
totalLength += prependNonNegativeIntegerBlock(encoder, ndn::tlv::nlsr::SequenceNumber, m_seqNo);
|
||||
totalLength += prependNonNegativeIntegerBlock(encoder, nlsr::tlv::SequenceNumber, m_seqNo);
|
||||
|
||||
totalLength += m_originRouter.wireEncode(encoder);
|
||||
|
||||
totalLength += encoder.prependVarNumber(totalLength);
|
||||
totalLength += encoder.prependVarNumber(ndn::tlv::nlsr::Lsa);
|
||||
totalLength += encoder.prependVarNumber(nlsr::tlv::Lsa);
|
||||
|
||||
return totalLength;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ Lsa::wireDecode(const ndn::Block& wire)
|
||||
|
||||
++val;
|
||||
|
||||
if (val != baseWire.elements_end() && val->type() == ndn::tlv::nlsr::SequenceNumber) {
|
||||
if (val != baseWire.elements_end() && val->type() == nlsr::tlv::SequenceNumber) {
|
||||
m_seqNo = ndn::readNonNegativeInteger(*val);
|
||||
++val;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ Lsa::wireDecode(const ndn::Block& wire)
|
||||
NDN_THROW(Error("Missing required SequenceNumber field"));
|
||||
}
|
||||
|
||||
if (val != baseWire.elements_end() && val->type() == ndn::tlv::nlsr::ExpirationTime) {
|
||||
if (val != baseWire.elements_end() && val->type() == nlsr::tlv::ExpirationTime) {
|
||||
m_expirationTimePoint = ndn::time::fromString(readString(*val));
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -54,7 +54,7 @@ NameLsa::wireEncode(ndn::EncodingImpl<TAG>& block) const
|
||||
totalLength += Lsa::wireEncode(block);
|
||||
|
||||
totalLength += block.prependVarNumber(totalLength);
|
||||
totalLength += block.prependVarNumber(ndn::tlv::nlsr::NameLsa);
|
||||
totalLength += block.prependVarNumber(nlsr::tlv::NameLsa);
|
||||
|
||||
return totalLength;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ NameLsa::wireDecode(const ndn::Block& wire)
|
||||
{
|
||||
m_wire = wire;
|
||||
|
||||
if (m_wire.type() != ndn::tlv::nlsr::NameLsa) {
|
||||
if (m_wire.type() != nlsr::tlv::NameLsa) {
|
||||
NDN_THROW(Error("NameLsa", m_wire.type()));
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ NameLsa::wireDecode(const ndn::Block& wire)
|
||||
|
||||
auto val = m_wire.elements_begin();
|
||||
|
||||
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::Lsa) {
|
||||
if (val != m_wire.elements_end() && val->type() == nlsr::tlv::Lsa) {
|
||||
Lsa::wireDecode(*val);
|
||||
++val;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ NameLsa::update(const std::shared_ptr<Lsa>& lsa)
|
||||
updated = true;
|
||||
}
|
||||
|
||||
return std::make_tuple(updated, namesToAdd, namesToRemove);
|
||||
return {updated, namesToAdd, namesToRemove};
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
|
||||
+3
-9
@@ -31,16 +31,13 @@ namespace nlsr {
|
||||
|
||||
INIT_LOGGER(Lsdb);
|
||||
|
||||
const ndn::time::steady_clock::TimePoint Lsdb::DEFAULT_LSA_RETRIEVAL_DEADLINE =
|
||||
ndn::time::steady_clock::TimePoint::min();
|
||||
|
||||
Lsdb::Lsdb(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam)
|
||||
: m_face(face)
|
||||
, m_scheduler(face.getIoService())
|
||||
, m_confParam(confParam)
|
||||
, m_sync(m_face,
|
||||
[this] (const ndn::Name& routerName, const Lsa::Type& lsaType,
|
||||
const uint64_t& sequenceNumber, uint64_t incomingFaceId) {
|
||||
[this] (const auto& routerName, const Lsa::Type& lsaType,
|
||||
uint64_t sequenceNumber, uint64_t incomingFaceId) {
|
||||
return isLsaNew(routerName, lsaType, sequenceNumber);
|
||||
}, m_confParam)
|
||||
, m_lsaRefreshTime(ndn::time::seconds(m_confParam.getLsaRefreshTime()))
|
||||
@@ -249,10 +246,7 @@ Lsdb::installLsa(std::shared_ptr<Lsa> lsa)
|
||||
chkLsa->setSeqNo(lsa->getSeqNo());
|
||||
chkLsa->setExpirationTimePoint(lsa->getExpirationTimePoint());
|
||||
|
||||
bool updated;
|
||||
std::list<ndn::Name> namesToAdd, namesToRemove;
|
||||
std::tie(updated, namesToAdd, namesToRemove) = chkLsa->update(lsa);
|
||||
|
||||
auto [updated, namesToAdd, namesToRemove] = chkLsa->update(lsa);
|
||||
if (updated) {
|
||||
onLsdbModified(lsa, LsdbUpdate::UPDATED, namesToAdd, namesToRemove);
|
||||
}
|
||||
|
||||
+5
-5
@@ -279,7 +279,7 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
|
||||
void
|
||||
expressInterest(const ndn::Name& interestName, uint32_t timeoutCount, uint64_t incomingFaceId,
|
||||
ndn::time::steady_clock::TimePoint deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
|
||||
ndn::time::steady_clock::time_point deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
|
||||
|
||||
/*!
|
||||
\brief Error callback when SegmentFetcher fails to return an LSA
|
||||
@@ -298,7 +298,7 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
void
|
||||
onFetchLsaError(uint32_t errorCode, const std::string& msg,
|
||||
const ndn::Name& interestName, uint32_t retransmitNo,
|
||||
const ndn::time::steady_clock::TimePoint& deadline,
|
||||
const ndn::time::steady_clock::time_point& deadline,
|
||||
ndn::Name lsaName, uint64_t seqNo);
|
||||
|
||||
/*!
|
||||
@@ -316,7 +316,7 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
afterSegmentValidatedSignal(data);
|
||||
}
|
||||
|
||||
ndn::time::system_clock::TimePoint
|
||||
ndn::time::system_clock::time_point
|
||||
getLsaExpirationTimePoint() const
|
||||
{
|
||||
return ndn::time::system_clock::now() + ndn::time::seconds(m_confParam.getRouterDeadInterval());
|
||||
@@ -360,8 +360,8 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
|
||||
ndn::InMemoryStoragePersistent m_lsaStorage;
|
||||
|
||||
const ndn::Name::Component NAME_COMPONENT = ndn::Name::Component("lsdb");
|
||||
static const ndn::time::steady_clock::TimePoint DEFAULT_LSA_RETRIEVAL_DEADLINE;
|
||||
static inline const ndn::time::steady_clock::time_point DEFAULT_LSA_RETRIEVAL_DEADLINE =
|
||||
ndn::time::steady_clock::time_point::min();
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
+13
-25
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
*/
|
||||
|
||||
#include "name-prefix-list.hpp"
|
||||
#include "common.hpp"
|
||||
@@ -26,23 +26,10 @@ namespace nlsr {
|
||||
|
||||
NamePrefixList::NamePrefixList() = default;
|
||||
|
||||
NamePrefixList::NamePrefixList(const std::initializer_list<ndn::Name>& names)
|
||||
{
|
||||
std::vector<NamePrefixList::NamePair> namePairs;
|
||||
std::transform(names.begin(), names.end(), std::back_inserter(namePairs),
|
||||
[] (const ndn::Name& name) {
|
||||
return NamePrefixList::NamePair{name, {""}};
|
||||
});
|
||||
m_names = std::move(namePairs);
|
||||
}
|
||||
|
||||
NamePrefixList::NamePrefixList(const std::initializer_list<NamePrefixList::NamePair>& namesAndSources)
|
||||
: m_names(namesAndSources)
|
||||
{
|
||||
}
|
||||
|
||||
NamePrefixList::~NamePrefixList()
|
||||
NamePrefixList::NamePrefixList(ndn::span<const ndn::Name> names)
|
||||
{
|
||||
std::transform(names.begin(), names.end(), std::back_inserter(m_names),
|
||||
[] (const auto& name) { return NamePair{name, {""}}; });
|
||||
}
|
||||
|
||||
std::vector<NamePrefixList::NamePair>::iterator
|
||||
@@ -70,11 +57,11 @@ NamePrefixList::insert(const ndn::Name& name, const std::string& source)
|
||||
auto pairItr = get(name);
|
||||
if (pairItr == m_names.end()) {
|
||||
std::vector<std::string> sources{source};
|
||||
m_names.push_back(std::tie(name, sources));
|
||||
m_names.emplace_back(name, sources);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
std::vector<std::string>& sources = std::get<NamePrefixList::NamePairIndex::SOURCES>(*pairItr);
|
||||
auto& sources = std::get<NamePrefixList::NamePairIndex::SOURCES>(*pairItr);
|
||||
auto sourceItr = getSource(source, pairItr);
|
||||
if (sourceItr == sources.end()) {
|
||||
sources.push_back(source);
|
||||
@@ -89,11 +76,11 @@ NamePrefixList::remove(const ndn::Name& name, const std::string& source)
|
||||
{
|
||||
auto pairItr = get(name);
|
||||
if (pairItr != m_names.end()) {
|
||||
std::vector<std::string>& sources = std::get<NamePrefixList::NamePairIndex::SOURCES>(*pairItr);
|
||||
auto& sources = std::get<NamePrefixList::NamePairIndex::SOURCES>(*pairItr);
|
||||
auto sourceItr = getSource(source, pairItr);
|
||||
if (sourceItr != sources.end()) {
|
||||
sources.erase(sourceItr);
|
||||
if (sources.size() == 0) {
|
||||
if (sources.empty()) {
|
||||
m_names.erase(pairItr);
|
||||
}
|
||||
return true;
|
||||
@@ -141,12 +128,13 @@ NamePrefixList::getSources(const ndn::Name& name) const
|
||||
return std::get<NamePrefixList::NamePairIndex::SOURCES>(*it);
|
||||
}
|
||||
else {
|
||||
return std::vector<std::string>{};
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NamePrefixList& list) {
|
||||
operator<<(std::ostream& os, const NamePrefixList& list)
|
||||
{
|
||||
os << "Name prefix list: {\n";
|
||||
for (const auto& name : list.getNames()) {
|
||||
os << name << "\n"
|
||||
|
||||
+18
-14
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -17,15 +17,19 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
*/
|
||||
|
||||
#ifndef NLSR_NAME_PREFIX_LIST_HPP
|
||||
#define NLSR_NAME_PREFIX_LIST_HPP
|
||||
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
#include <initializer_list>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include <ndn-cxx/name.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
@@ -34,6 +38,7 @@ class NamePrefixList
|
||||
{
|
||||
public:
|
||||
using NamePair = std::tuple<ndn::Name, std::vector<std::string>>;
|
||||
|
||||
enum NamePairIndex {
|
||||
NAME,
|
||||
SOURCES
|
||||
@@ -41,21 +46,20 @@ public:
|
||||
|
||||
NamePrefixList();
|
||||
|
||||
NamePrefixList(const std::initializer_list<ndn::Name>& names);
|
||||
explicit
|
||||
NamePrefixList(ndn::span<const ndn::Name> names);
|
||||
|
||||
NamePrefixList(const std::initializer_list<NamePrefixList::NamePair>& namesAndSources);
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
template<class ContainerType>
|
||||
NamePrefixList(const ContainerType& names)
|
||||
#ifdef WITH_TESTS
|
||||
NamePrefixList(std::initializer_list<ndn::Name> names)
|
||||
: NamePrefixList(ndn::span<const ndn::Name>(names))
|
||||
{
|
||||
for (const auto& elem : names) {
|
||||
m_names.push_back(NamePair{elem, {""}});
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
~NamePrefixList();
|
||||
NamePrefixList(std::initializer_list<NamePair> namesAndSources)
|
||||
: m_names(namesAndSources)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! \brief inserts name into NamePrefixList
|
||||
\retval true If the name was successfully inserted.
|
||||
|
||||
+4
-6
@@ -33,8 +33,6 @@ namespace nlsr {
|
||||
|
||||
INIT_LOGGER(Nlsr);
|
||||
|
||||
const ndn::Name Nlsr::LOCALHOST_PREFIX = ndn::Name("/localhost/nlsr");
|
||||
|
||||
Nlsr::Nlsr(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam)
|
||||
: m_face(face)
|
||||
, m_scheduler(face.getIoService())
|
||||
@@ -126,8 +124,8 @@ Nlsr::registerStrategyForCerts(const ndn::Name& originRouter)
|
||||
ndn::Name instanceKey(originRouter);
|
||||
instanceKey.append("nlsr").append(ndn::security::Certificate::KEY_COMPONENT);
|
||||
|
||||
m_fib.setStrategy(routerKey, Fib::BEST_ROUTE_V2_STRATEGY, 0);
|
||||
m_fib.setStrategy(instanceKey, Fib::BEST_ROUTE_V2_STRATEGY, 0);
|
||||
m_fib.setStrategy(routerKey, Fib::BEST_ROUTE_STRATEGY, 0);
|
||||
m_fib.setStrategy(instanceKey, Fib::BEST_ROUTE_STRATEGY, 0);
|
||||
|
||||
ndn::Name siteKey;
|
||||
for (size_t i = 0; i < originRouter.size(); ++i) {
|
||||
@@ -138,10 +136,10 @@ Nlsr::registerStrategyForCerts(const ndn::Name& originRouter)
|
||||
}
|
||||
ndn::Name opPrefix(siteKey);
|
||||
siteKey.append(ndn::security::Certificate::KEY_COMPONENT);
|
||||
m_fib.setStrategy(siteKey, Fib::BEST_ROUTE_V2_STRATEGY, 0);
|
||||
m_fib.setStrategy(siteKey, Fib::BEST_ROUTE_STRATEGY, 0);
|
||||
|
||||
opPrefix.append(std::string("%C1.Operator"));
|
||||
m_fib.setStrategy(opPrefix, Fib::BEST_ROUTE_V2_STRATEGY, 0);
|
||||
m_fib.setStrategy(opPrefix, Fib::BEST_ROUTE_STRATEGY, 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -159,7 +159,7 @@ private:
|
||||
enableIncomingFaceIdIndication();
|
||||
|
||||
public:
|
||||
static const ndn::Name LOCALHOST_PREFIX;
|
||||
static inline const ndn::Name LOCALHOST_PREFIX{"/localhost/nlsr"};
|
||||
|
||||
private:
|
||||
ndn::Face& m_face;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -35,17 +35,17 @@
|
||||
#include "route/routing-table.hpp"
|
||||
#include "route/nexthop-list.hpp"
|
||||
#include "lsdb.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
#include <ndn-cxx/mgmt/dispatcher.hpp>
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/mgmt/dispatcher.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
namespace dataset {
|
||||
const ndn::Name::Component ADJACENCY_COMPONENT = ndn::Name::Component{"adjacencies"};
|
||||
const ndn::Name::Component NAME_COMPONENT = ndn::Name::Component{"names"};
|
||||
const ndn::Name::Component COORDINATE_COMPONENT = ndn::Name::Component{"coordinates"};
|
||||
inline const ndn::Name::Component ADJACENCY_COMPONENT{"adjacencies"};
|
||||
inline const ndn::Name::Component NAME_COMPONENT{"names"};
|
||||
inline const ndn::Name::Component COORDINATE_COMPONENT{"coordinates"};
|
||||
} // namespace dataset
|
||||
|
||||
/*!
|
||||
@@ -59,11 +59,7 @@ public:
|
||||
class Error : std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit
|
||||
Error(const std::string& what)
|
||||
: std::runtime_error(what)
|
||||
{
|
||||
}
|
||||
using std::runtime_error::runtime_error;
|
||||
};
|
||||
|
||||
DatasetInterestHandler(ndn::mgmt::Dispatcher& dispatcher,
|
||||
@@ -79,7 +75,7 @@ private:
|
||||
|
||||
/*! \brief provide LSA status dataset
|
||||
*/
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
void
|
||||
publishLsaStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
|
||||
ndn::mgmt::StatusDatasetContext& context);
|
||||
|
||||
+8
-15
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -24,18 +24,14 @@
|
||||
#include "logger.hpp"
|
||||
#include "nexthop-list.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER(route.Fib);
|
||||
|
||||
const std::string Fib::MULTICAST_STRATEGY("ndn:/localhost/nfd/strategy/multicast");
|
||||
const std::string Fib::BEST_ROUTE_V2_STRATEGY("ndn:/localhost/nfd/strategy/best-route");
|
||||
|
||||
Fib::Fib(ndn::Face& face, ndn::Scheduler& scheduler, AdjacencyList& adjacencyList,
|
||||
ConfParameter& conf, ndn::security::KeyChain& keyChain)
|
||||
: m_scheduler(scheduler)
|
||||
@@ -109,12 +105,9 @@ Fib::update(const ndn::Name& name, const NexthopList& allHops)
|
||||
|
||||
FibEntry entry;
|
||||
entry.name = name;
|
||||
|
||||
addNextHopsToFibEntryAndNfd(entry, hopsToAdd);
|
||||
|
||||
m_table.emplace(name, std::move(entry));
|
||||
|
||||
entryIt = m_table.find(name);
|
||||
entryIt = m_table.try_emplace(name, std::move(entry)).first;
|
||||
}
|
||||
// Existing FIB entry that may or may not have nextHops
|
||||
else {
|
||||
@@ -127,7 +120,7 @@ Fib::update(const ndn::Name& name, const NexthopList& allHops)
|
||||
return;
|
||||
}
|
||||
|
||||
FibEntry& entry = (entryIt->second);
|
||||
FibEntry& entry = entryIt->second;
|
||||
addNextHopsToFibEntryAndNfd(entry, hopsToAdd);
|
||||
|
||||
std::set<NextHop, NextHopUriSortedComparator> hopsToRemove;
|
||||
@@ -278,7 +271,7 @@ Fib::unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri)
|
||||
}
|
||||
|
||||
void
|
||||
Fib::setStrategy(const ndn::Name& name, const std::string& strategy, uint32_t count)
|
||||
Fib::setStrategy(const ndn::Name& name, const ndn::Name& strategy, uint32_t count)
|
||||
{
|
||||
ndn::nfd::ControlParameters parameters;
|
||||
parameters
|
||||
@@ -311,7 +304,7 @@ Fib::onSetStrategyFailure(const ndn::nfd::ControlResponse& response,
|
||||
}
|
||||
|
||||
void
|
||||
Fib::scheduleEntryRefresh(FibEntry& entry, const afterRefreshCallback& refreshCallback)
|
||||
Fib::scheduleEntryRefresh(FibEntry& entry, const AfterRefreshCallback& refreshCallback)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Scheduling refresh for " << entry.name <<
|
||||
" Seq Num: " << entry.seqNo <<
|
||||
@@ -329,7 +322,7 @@ Fib::scheduleLoop(FibEntry& entry)
|
||||
}
|
||||
|
||||
void
|
||||
Fib::refreshEntry(const ndn::Name& name, afterRefreshCallback refreshCb)
|
||||
Fib::refreshEntry(const ndn::Name& name, AfterRefreshCallback refreshCb)
|
||||
{
|
||||
auto it = m_table.find(name);
|
||||
if (it == m_table.end()) {
|
||||
|
||||
+12
-10
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -31,16 +31,17 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
typedef NexthopListT<NextHopUriSortedComparator> NextHopsUriSortedSet;
|
||||
using NextHopsUriSortedSet = NexthopListT<NextHopUriSortedComparator>;
|
||||
|
||||
struct FibEntry {
|
||||
struct FibEntry
|
||||
{
|
||||
ndn::Name name;
|
||||
ndn::scheduler::ScopedEventId refreshEventId;
|
||||
int32_t seqNo = 1;
|
||||
NextHopsUriSortedSet nexthopSet;
|
||||
};
|
||||
|
||||
typedef std::function<void(FibEntry&)> afterRefreshCallback;
|
||||
using AfterRefreshCallback = std::function<void(FibEntry&)>;
|
||||
|
||||
class AdjacencyList;
|
||||
class ConfParameter;
|
||||
@@ -135,7 +136,7 @@ public:
|
||||
uint8_t times);
|
||||
|
||||
void
|
||||
setStrategy(const ndn::Name& name, const std::string& strategy, uint32_t count);
|
||||
setStrategy(const ndn::Name& name, const ndn::Name& strategy, uint32_t count);
|
||||
|
||||
void
|
||||
writeLog();
|
||||
@@ -204,7 +205,7 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
* \sa Fib::scheduleLoop
|
||||
*/
|
||||
void
|
||||
scheduleEntryRefresh(FibEntry& entry, const afterRefreshCallback& refreshCb);
|
||||
scheduleEntryRefresh(FibEntry& entry, const AfterRefreshCallback& refreshCb);
|
||||
|
||||
private:
|
||||
/*! \brief Continue the entry refresh cycle.
|
||||
@@ -215,12 +216,13 @@ private:
|
||||
/*! \brief Refreshes an entry in NFD.
|
||||
*/
|
||||
void
|
||||
refreshEntry(const ndn::Name& name, afterRefreshCallback refreshCb);
|
||||
refreshEntry(const ndn::Name& name, AfterRefreshCallback refreshCb);
|
||||
|
||||
public:
|
||||
static const std::string MULTICAST_STRATEGY;
|
||||
static const std::string BEST_ROUTE_V2_STRATEGY;
|
||||
ndn::util::Signal<Fib, const ndn::Name&> onPrefixRegistrationSuccess;
|
||||
static inline const ndn::Name MULTICAST_STRATEGY{"/localhost/nfd/strategy/multicast"};
|
||||
static inline const ndn::Name BEST_ROUTE_STRATEGY{"/localhost/nfd/strategy/best-route"};
|
||||
|
||||
ndn::util::Signal<Fib, ndn::Name> onPrefixRegistrationSuccess;
|
||||
|
||||
private:
|
||||
ndn::Scheduler& m_scheduler;
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -44,20 +44,20 @@ Map::addEntry(MapEntry& mpe)
|
||||
return m_entries.insert(mpe).second;
|
||||
}
|
||||
|
||||
ndn::optional<ndn::Name>
|
||||
std::optional<ndn::Name>
|
||||
Map::getRouterNameByMappingNo(int32_t mn) const
|
||||
{
|
||||
auto&& mappingNumberView = m_entries.get<detail::byMappingNumber>();
|
||||
auto it = mappingNumberView.find(mn);
|
||||
return it == mappingNumberView.end() ? ndn::nullopt : ndn::optional<ndn::Name>(it->router);
|
||||
return it == mappingNumberView.end() ? std::nullopt : std::optional(it->router);
|
||||
}
|
||||
|
||||
ndn::optional<int32_t>
|
||||
std::optional<int32_t>
|
||||
Map::getMappingNoByRouterName(const ndn::Name& rName)
|
||||
{
|
||||
auto&& routerNameView = m_entries.get<detail::byRouterName>();
|
||||
auto it = routerNameView.find(rName);
|
||||
return it == routerNameView.end() ? ndn::nullopt : ndn::optional<int32_t>(it->mappingNumber);
|
||||
return it == routerNameView.end() ? std::nullopt : std::optional(it->mappingNumber);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -66,7 +66,7 @@ Map::writeLog()
|
||||
NLSR_LOG_DEBUG("---------------Map----------------------");
|
||||
for (const auto& entry : m_entries.get<detail::byRouterName>()) {
|
||||
NLSR_LOG_DEBUG("MapEntry: ( Router: " << entry.router << " Mapping No: " <<
|
||||
entry.mappingNumber << " )");
|
||||
entry.mappingNumber << " )");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-4
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -29,9 +29,12 @@
|
||||
#include <boost/multi_index/member.hpp>
|
||||
#include <boost/multi_index/tag.hpp>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
struct MapEntry {
|
||||
struct MapEntry
|
||||
{
|
||||
ndn::Name router;
|
||||
int32_t mappingNumber = -1;
|
||||
};
|
||||
@@ -104,10 +107,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
ndn::optional<ndn::Name>
|
||||
std::optional<ndn::Name>
|
||||
getRouterNameByMappingNo(int32_t mn) const;
|
||||
|
||||
ndn::optional<int32_t>
|
||||
std::optional<int32_t>
|
||||
getMappingNoByRouterName(const ndn::Name& rName);
|
||||
|
||||
size_t
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -116,15 +116,11 @@ void
|
||||
NamePrefixTable::addEntry(const ndn::Name& name, const ndn::Name& destRouter)
|
||||
{
|
||||
// Check if the advertised name prefix is in the table already.
|
||||
NptEntryList::iterator nameItr =
|
||||
std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
[&] (const std::shared_ptr<NamePrefixTableEntry>& entry) {
|
||||
return name == entry->getNamePrefix();
|
||||
});
|
||||
auto nameItr = std::find_if(m_table.begin(), m_table.end(),
|
||||
[&] (const auto& entry) { return name == entry->getNamePrefix(); });
|
||||
|
||||
// Attempt to find a routing table pool entry (RTPE) we can use.
|
||||
RoutingTableEntryPool::iterator rtpeItr = m_rtpool.find(destRouter);
|
||||
auto rtpeItr = m_rtpool.find(destRouter);
|
||||
|
||||
// These declarations just to make the compiler happy...
|
||||
RoutingTablePoolEntry rtpe;
|
||||
@@ -196,8 +192,8 @@ NamePrefixTable::addEntry(const ndn::Name& name, const ndn::Name& destRouter)
|
||||
}
|
||||
|
||||
// Add the reference to this NPT to the RTPE.
|
||||
rtpePtr->namePrefixTableEntries.emplace(
|
||||
std::make_pair(npte->getNamePrefix(), std::weak_ptr<NamePrefixTableEntry>(npte)));
|
||||
rtpePtr->namePrefixTableEntries.try_emplace(npte->getNamePrefix(),
|
||||
std::weak_ptr<NamePrefixTableEntry>(npte));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -206,27 +202,23 @@ NamePrefixTable::removeEntry(const ndn::Name& name, const ndn::Name& destRouter)
|
||||
NLSR_LOG_DEBUG("Removing origin: " << destRouter << " from " << name);
|
||||
|
||||
// Fetch an iterator to the appropriate pair object in the pool.
|
||||
RoutingTableEntryPool::iterator rtpeItr = m_rtpool.find(destRouter);
|
||||
auto rtpeItr = m_rtpool.find(destRouter);
|
||||
|
||||
// Simple error checking to prevent any unusual behavior in the case
|
||||
// that we try to remove an entry that isn't there.
|
||||
if (rtpeItr == m_rtpool.end()) {
|
||||
NLSR_LOG_DEBUG("No entry for origin: " << destRouter
|
||||
<< " found, so it cannot be removed from prefix: "
|
||||
<< name);
|
||||
<< " found, so it cannot be removed from prefix: " << name);
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<RoutingTablePoolEntry> rtpePtr = rtpeItr->second;
|
||||
|
||||
// Ensure that the entry exists
|
||||
NptEntryList::iterator nameItr =
|
||||
std::find_if(m_table.begin(), m_table.end(),
|
||||
[&] (const std::shared_ptr<NamePrefixTableEntry>& entry) {
|
||||
return entry->getNamePrefix() == name;
|
||||
});
|
||||
auto nameItr = std::find_if(m_table.begin(), m_table.end(),
|
||||
[&] (const auto& entry) { return entry->getNamePrefix() == name; });
|
||||
if (nameItr != m_table.end()) {
|
||||
NLSR_LOG_TRACE("Removing origin: " << rtpePtr->getDestination()
|
||||
<< " from prefix: " << **nameItr);
|
||||
<< " from prefix: " << **nameItr);
|
||||
|
||||
// Rather than iterating through the whole list periodically, just
|
||||
// delete them here if they have no references.
|
||||
@@ -251,20 +243,20 @@ NamePrefixTable::removeEntry(const ndn::Name& name, const ndn::Name& destRouter)
|
||||
//
|
||||
if ((*nameItr)->getRteListSize() == 0) {
|
||||
NLSR_LOG_TRACE(**nameItr << " has no routing table entries;"
|
||||
<< " removing from table and FIB");
|
||||
<< " removing from table and FIB");
|
||||
m_table.erase(nameItr);
|
||||
m_fib.remove(name);
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_TRACE(**nameItr << " has other routing table entries;"
|
||||
<< " updating FIB with next hops");
|
||||
<< " updating FIB with next hops");
|
||||
(*nameItr)->generateNhlfromRteList();
|
||||
m_fib.update(name, (*nameItr)->getNexthopList());
|
||||
}
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_DEBUG("Attempted to remove origin: " << rtpePtr->getDestination()
|
||||
<< " from non-existent prefix: " << name);
|
||||
<< " from non-existent prefix: " << name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,33 +297,30 @@ NamePrefixTable::updateWithNewRoute(const std::list<RoutingTableEntry>& entries)
|
||||
}
|
||||
}
|
||||
|
||||
// Inserts the routing table pool entry into the NPT's RTE storage
|
||||
// pool. This cannot fail, so the pool is guaranteed to contain the
|
||||
// item after this occurs.
|
||||
// Inserts the routing table pool entry into the NPT's RTE storage
|
||||
// pool. This cannot fail, so the pool is guaranteed to contain the
|
||||
// item after this occurs.
|
||||
std::shared_ptr<RoutingTablePoolEntry>
|
||||
NamePrefixTable::addRtpeToPool(RoutingTablePoolEntry& rtpe)
|
||||
{
|
||||
RoutingTableEntryPool::iterator poolItr =
|
||||
m_rtpool.insert(std::make_pair(rtpe.getDestination(),
|
||||
std::make_shared<RoutingTablePoolEntry>
|
||||
(rtpe)))
|
||||
.first;
|
||||
return poolItr->second;
|
||||
auto poolIt = m_rtpool.try_emplace(rtpe.getDestination(),
|
||||
std::make_shared<RoutingTablePoolEntry>(rtpe)).first;
|
||||
return poolIt->second;
|
||||
}
|
||||
|
||||
// Removes the routing table pool entry from the storage pool. The
|
||||
// postconditions of this function are guaranteed to include that
|
||||
// the storage pool does not contain such an item. Additionally,
|
||||
// this function cannot fail, but nonetheless debug information is
|
||||
// given in the case that this function is called with an entry that
|
||||
// isn't in the pool.
|
||||
// Removes the routing table pool entry from the storage pool. The
|
||||
// postconditions of this function are guaranteed to include that
|
||||
// the storage pool does not contain such an item. Additionally,
|
||||
// this function cannot fail, but nonetheless debug information is
|
||||
// given in the case that this function is called with an entry that
|
||||
// isn't in the pool.
|
||||
void
|
||||
NamePrefixTable::deleteRtpeFromPool(std::shared_ptr<RoutingTablePoolEntry> rtpePtr)
|
||||
{
|
||||
if (m_rtpool.erase(rtpePtr->getDestination()) != 1) {
|
||||
NLSR_LOG_DEBUG("Attempted to delete non-existent origin: "
|
||||
<< rtpePtr->getDestination()
|
||||
<< " from NPT routing table entry storage pool.");
|
||||
<< rtpePtr->getDestination()
|
||||
<< " from NPT routing table entry storage pool.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -31,11 +31,11 @@ NextHop::wireEncode(ndn::EncodingImpl<TAG>& block) const
|
||||
{
|
||||
size_t totalLength = 0;
|
||||
|
||||
totalLength += ndn::encoding::prependDoubleBlock(block, ndn::tlv::nlsr::CostDouble, m_routeCost);
|
||||
totalLength += ndn::encoding::prependStringBlock(block, ndn::tlv::nlsr::Uri, m_connectingFaceUri);
|
||||
totalLength += ndn::encoding::prependDoubleBlock(block, nlsr::tlv::CostDouble, m_routeCost);
|
||||
totalLength += ndn::encoding::prependStringBlock(block, nlsr::tlv::Uri, m_connectingFaceUri);
|
||||
|
||||
totalLength += block.prependVarNumber(totalLength);
|
||||
totalLength += block.prependVarNumber(ndn::tlv::nlsr::NextHop);
|
||||
totalLength += block.prependVarNumber(nlsr::tlv::NextHop);
|
||||
|
||||
return totalLength;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ NextHop::wireDecode(const ndn::Block& wire)
|
||||
|
||||
m_wire = wire;
|
||||
|
||||
if (m_wire.type() != ndn::tlv::nlsr::NextHop) {
|
||||
if (m_wire.type() != nlsr::tlv::NextHop) {
|
||||
NDN_THROW(Error("NextHop", m_wire.type()));
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ NextHop::wireDecode(const ndn::Block& wire)
|
||||
|
||||
auto val = m_wire.elements_begin();
|
||||
|
||||
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::Uri) {
|
||||
if (val != m_wire.elements_end() && val->type() == nlsr::tlv::Uri) {
|
||||
m_connectingFaceUri = ndn::encoding::readString(*val);
|
||||
++val;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ NextHop::wireDecode(const ndn::Block& wire)
|
||||
NDN_THROW(Error("Missing required Uri field"));
|
||||
}
|
||||
|
||||
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::CostDouble) {
|
||||
if (val != m_wire.elements_end() && val->type() == nlsr::tlv::CostDouble) {
|
||||
m_routeCost = ndn::encoding::readDouble(*val);
|
||||
++val;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -142,7 +142,7 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
|
||||
e.g costs 12.34 and 12.35 will be installed into NFD's FIB as 12340 and 12350
|
||||
*/
|
||||
static const uint64_t HYPERBOLIC_COST_ADJUSTMENT_FACTOR = 1000;
|
||||
static constexpr uint64_t HYPERBOLIC_COST_ADJUSTMENT_FACTOR = 1000;
|
||||
};
|
||||
|
||||
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(NextHop);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -27,18 +27,20 @@
|
||||
#include "logger.hpp"
|
||||
#include "adjacent.hpp"
|
||||
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
#include <ndn-cxx/util/logger.hpp>
|
||||
#include <cmath>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <ndn-cxx/util/logger.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER(route.RoutingTableCalculator);
|
||||
|
||||
const int LinkStateRoutingTableCalculator::EMPTY_PARENT = -12345;
|
||||
const double LinkStateRoutingTableCalculator::INF_DISTANCE = 2147483647;
|
||||
const int LinkStateRoutingTableCalculator::NO_MAPPING_NUM = -1;
|
||||
const int LinkStateRoutingTableCalculator::NO_NEXT_HOP = -12345;
|
||||
const int EMPTY_PARENT = -12345;
|
||||
const double INF_DISTANCE = 2147483647;
|
||||
const int NO_MAPPING_NUM = -1;
|
||||
const int NO_NEXT_HOP = -12345;
|
||||
const double UNKNOWN_DISTANCE = -1.0;
|
||||
const double UNKNOWN_RADIUS = -1.0;
|
||||
|
||||
void
|
||||
RoutingTableCalculator::allocateAdjMatrix()
|
||||
@@ -67,17 +69,16 @@ RoutingTableCalculator::makeAdjMatrix(const Lsdb& lsdb, Map& pMap)
|
||||
auto lsaRange = lsdb.getLsdbIterator<AdjLsa>();
|
||||
for (auto lsaIt = lsaRange.first; lsaIt != lsaRange.second; ++lsaIt) {
|
||||
auto adjLsa = std::static_pointer_cast<AdjLsa>(*lsaIt);
|
||||
ndn::optional<int32_t> row = pMap.getMappingNoByRouterName(adjLsa->getOriginRouter());
|
||||
auto row = pMap.getMappingNoByRouterName(adjLsa->getOriginRouter());
|
||||
|
||||
std::list<Adjacent> adl = adjLsa->getAdl().getAdjList();
|
||||
// For each adjacency represented in the LSA
|
||||
for (const auto& adjacent : adl) {
|
||||
ndn::optional<int32_t> col = pMap.getMappingNoByRouterName(adjacent.getName());
|
||||
auto col = pMap.getMappingNoByRouterName(adjacent.getName());
|
||||
double cost = adjacent.getLinkCost();
|
||||
|
||||
if (row && col && *row < static_cast<int32_t>(m_nRouters)
|
||||
&& *col < static_cast<int32_t>(m_nRouters))
|
||||
{
|
||||
&& *col < static_cast<int32_t>(m_nRouters)) {
|
||||
adjMatrix[*row][*col] = cost;
|
||||
}
|
||||
}
|
||||
@@ -143,7 +144,7 @@ RoutingTableCalculator::writeAdjMatrixLog(const Map& map) const
|
||||
for (size_t i = 0; i < m_nRouters; i++) {
|
||||
std::string line;
|
||||
for (size_t j = 0; j < m_nRouters; j++) {
|
||||
if (adjMatrix[i][j] == LinkStateRoutingTableCalculator::NO_NEXT_HOP) {
|
||||
if (adjMatrix[i][j] == NO_NEXT_HOP) {
|
||||
line += "0 ";
|
||||
}
|
||||
else {
|
||||
@@ -240,8 +241,7 @@ LinkStateRoutingTableCalculator::calculatePath(Map& pMap, RoutingTable& rt,
|
||||
initMatrix();
|
||||
makeAdjMatrix(lsdb, pMap);
|
||||
writeAdjMatrixLog(pMap);
|
||||
ndn::optional<int32_t> sourceRouter =
|
||||
pMap.getMappingNoByRouterName(confParam.getRouterPrefix());
|
||||
auto sourceRouter = pMap.getMappingNoByRouterName(confParam.getRouterPrefix());
|
||||
allocateParent(); // These two matrices are used in Dijkstra's algorithm.
|
||||
allocateDistance(); //
|
||||
// We only bother to do the calculation if we have a router by that name.
|
||||
@@ -346,14 +346,13 @@ LinkStateRoutingTableCalculator::addAllLsNextHopsToRoutingTable(AdjacencyList& a
|
||||
// Fetch its distance
|
||||
double routeCost = m_distance[i];
|
||||
// Fetch its actual name
|
||||
ndn::optional<ndn::Name> nextHopRouterName= pMap.getRouterNameByMappingNo(nextHopRouter);
|
||||
auto nextHopRouterName = pMap.getRouterNameByMappingNo(nextHopRouter);
|
||||
if (nextHopRouterName) {
|
||||
std::string nextHopFace =
|
||||
adjacencies.getAdjacent(*nextHopRouterName).getFaceUri().toString();
|
||||
// Add next hop to routing table
|
||||
NextHop nh(nextHopFace, routeCost);
|
||||
rt.addNextHop(*(pMap.getRouterNameByMappingNo(i)), nh);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -427,18 +426,13 @@ void LinkStateRoutingTableCalculator::freeDistance()
|
||||
delete [] m_distance;
|
||||
}
|
||||
|
||||
const double HyperbolicRoutingCalculator::MATH_PI = boost::math::constants::pi<double>();
|
||||
|
||||
const double HyperbolicRoutingCalculator::UNKNOWN_DISTANCE = -1.0;
|
||||
const double HyperbolicRoutingCalculator::UNKNOWN_RADIUS = -1.0;
|
||||
|
||||
void
|
||||
HyperbolicRoutingCalculator::calculatePath(Map& map, RoutingTable& rt,
|
||||
Lsdb& lsdb, AdjacencyList& adjacencies)
|
||||
{
|
||||
NLSR_LOG_TRACE("Calculating hyperbolic paths");
|
||||
|
||||
ndn::optional<int32_t> thisRouter = map.getMappingNoByRouterName(m_thisRouterName);
|
||||
auto thisRouter = map.getMappingNoByRouterName(m_thisRouterName);
|
||||
|
||||
// Iterate over directly connected neighbors
|
||||
std::list<Adjacent> neighbors = adjacencies.getAdjList();
|
||||
@@ -462,8 +456,7 @@ HyperbolicRoutingCalculator::calculatePath(Map& map, RoutingTable& rt,
|
||||
// Install nexthops for this router to the neighbor; direct neighbors have a 0 cost link
|
||||
addNextHop(srcRouterName, srcFaceUri, 0, rt);
|
||||
|
||||
ndn::optional<int32_t> src = map.getMappingNoByRouterName(srcRouterName);
|
||||
|
||||
auto src = map.getMappingNoByRouterName(srcRouterName);
|
||||
if (!src) {
|
||||
NLSR_LOG_WARN(adj->getName() << " does not exist in the router map!");
|
||||
continue;
|
||||
@@ -474,7 +467,7 @@ HyperbolicRoutingCalculator::calculatePath(Map& map, RoutingTable& rt,
|
||||
// Don't calculate nexthops to this router or from a router to itself
|
||||
if (thisRouter && dest != *thisRouter && dest != *src) {
|
||||
|
||||
ndn::optional<ndn::Name> destRouterName = map.getRouterNameByMappingNo(dest);
|
||||
auto destRouterName = map.getRouterNameByMappingNo(dest);
|
||||
if (destRouterName) {
|
||||
double distance = getHyperbolicDistance(lsdb, srcRouterName, *destRouterName);
|
||||
|
||||
@@ -551,6 +544,7 @@ HyperbolicRoutingCalculator::calculateAngularDistance(std::vector<double> angleV
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (angleVectorI[angleVectorI.size()-1] > 2.*M_PI ||
|
||||
angleVectorI[angleVectorI.size()-1] < 0.0) {
|
||||
NLSR_LOG_ERROR("Angle not within [0, 2PI]");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -27,8 +27,6 @@
|
||||
#include "lsdb.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class Map;
|
||||
@@ -193,13 +191,6 @@ private:
|
||||
private:
|
||||
int* m_parent;
|
||||
double* m_distance;
|
||||
|
||||
static const int EMPTY_PARENT;
|
||||
static const double INF_DISTANCE;
|
||||
static const int NO_MAPPING_NUM;
|
||||
public:
|
||||
static const int NO_NEXT_HOP;
|
||||
|
||||
};
|
||||
|
||||
class AdjacencyList;
|
||||
@@ -236,10 +227,6 @@ private:
|
||||
const size_t m_nRouters;
|
||||
const bool m_isDryRun;
|
||||
const ndn::Name m_thisRouterName;
|
||||
|
||||
static const double MATH_PI;
|
||||
static const double UNKNOWN_DISTANCE;
|
||||
static const double UNKNOWN_RADIUS;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -37,7 +37,7 @@ RoutingTableEntry::wireEncode(ndn::EncodingImpl<TAG>& block) const
|
||||
totalLength += m_destination.wireEncode(block);
|
||||
|
||||
totalLength += block.prependVarNumber(totalLength);
|
||||
totalLength += block.prependVarNumber(ndn::tlv::nlsr::RoutingTableEntry);
|
||||
totalLength += block.prependVarNumber(nlsr::tlv::RoutingTableEntry);
|
||||
|
||||
return totalLength;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ RoutingTableEntry::wireDecode(const ndn::Block& wire)
|
||||
|
||||
m_wire = wire;
|
||||
|
||||
if (m_wire.type() != ndn::tlv::nlsr::RoutingTableEntry) {
|
||||
if (m_wire.type() != nlsr::tlv::RoutingTableEntry) {
|
||||
NDN_THROW(Error("RoutingTableEntry", m_wire.type()));
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ RoutingTableEntry::wireDecode(const ndn::Block& wire)
|
||||
}
|
||||
|
||||
for (; val != m_wire.elements_end(); ++val) {
|
||||
if (val->type() == ndn::tlv::nlsr::NextHop) {
|
||||
if (val->type() == nlsr::tlv::NextHop) {
|
||||
m_nexthopList.addNextHop(NextHop(*val));
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -16,8 +16,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
*/
|
||||
|
||||
#ifndef NLSR_ROUTING_TABLE_POOL_ENTRY_HPP
|
||||
#define NLSR_ROUTING_TABLE_POOL_ENTRY_HPP
|
||||
@@ -41,6 +40,7 @@ namespace nlsr {
|
||||
* maintain a collection of RoutingTablePoolEntries. Then, this new
|
||||
* class can be associated with the name prefixes instead of the
|
||||
* original entries, which provides a minimal memory solution.
|
||||
*
|
||||
* \sa NamePrefixTable
|
||||
*/
|
||||
class NamePrefixTableEntry;
|
||||
@@ -48,13 +48,7 @@ class NamePrefixTableEntry;
|
||||
class RoutingTablePoolEntry : public RoutingTableEntry
|
||||
{
|
||||
public:
|
||||
RoutingTablePoolEntry()
|
||||
{
|
||||
}
|
||||
|
||||
~RoutingTablePoolEntry()
|
||||
{
|
||||
}
|
||||
RoutingTablePoolEntry() = default;
|
||||
|
||||
RoutingTablePoolEntry(const ndn::Name& dest)
|
||||
{
|
||||
@@ -76,7 +70,7 @@ public:
|
||||
}
|
||||
|
||||
uint64_t
|
||||
getUseCount()
|
||||
getUseCount() const
|
||||
{
|
||||
return m_useCount;
|
||||
}
|
||||
@@ -99,16 +93,14 @@ public:
|
||||
void
|
||||
setNexthopList(NexthopList nhl)
|
||||
{
|
||||
m_nexthopList = nhl;
|
||||
m_nexthopList = std::move(nhl);
|
||||
}
|
||||
|
||||
public:
|
||||
std::unordered_map<ndn::Name, std::weak_ptr<NamePrefixTableEntry>>
|
||||
namePrefixTableEntries;
|
||||
std::unordered_map<ndn::Name, std::weak_ptr<NamePrefixTableEntry>> namePrefixTableEntries;
|
||||
|
||||
private:
|
||||
uint64_t m_useCount;
|
||||
|
||||
};
|
||||
|
||||
bool
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -262,7 +262,7 @@ RoutingTableStatus::wireEncode(ndn::EncodingImpl<TAG>& block) const
|
||||
}
|
||||
|
||||
totalLength += block.prependVarNumber(totalLength);
|
||||
totalLength += block.prependVarNumber(ndn::tlv::nlsr::RoutingTable);
|
||||
totalLength += block.prependVarNumber(nlsr::tlv::RoutingTable);
|
||||
|
||||
return totalLength;
|
||||
}
|
||||
@@ -294,7 +294,7 @@ RoutingTableStatus::wireDecode(const ndn::Block& wire)
|
||||
|
||||
m_wire = wire;
|
||||
|
||||
if (m_wire.type() != ndn::tlv::nlsr::RoutingTable) {
|
||||
if (m_wire.type() != nlsr::tlv::RoutingTable) {
|
||||
NDN_THROW(Error("RoutingTable", m_wire.type()));
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ RoutingTableStatus::wireDecode(const ndn::Block& wire)
|
||||
auto val = m_wire.elements_begin();
|
||||
|
||||
std::set<ndn::Name> destinations;
|
||||
for (; val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::RoutingTableEntry; ++val) {
|
||||
for (; val != m_wire.elements_end() && val->type() == nlsr::tlv::RoutingTableEntry; ++val) {
|
||||
auto entry = RoutingTableEntry(*val);
|
||||
|
||||
if (destinations.emplace(entry.getDestination()).second) {
|
||||
|
||||
+4
-8
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -22,9 +22,7 @@
|
||||
#ifndef NLSR_TLV_NLSR_HPP
|
||||
#define NLSR_TLV_NLSR_HPP
|
||||
|
||||
namespace ndn {
|
||||
namespace tlv {
|
||||
namespace nlsr {
|
||||
namespace nlsr::tlv {
|
||||
|
||||
/*! The TLV block types that NLSR uses to encode/decode LSA types. The
|
||||
* way NLSR encodes LSAs to TLV is by encoding each element of the
|
||||
@@ -47,11 +45,9 @@ enum {
|
||||
Uri = 141,
|
||||
NextHop = 143,
|
||||
RoutingTable = 144,
|
||||
RoutingTableEntry = 145
|
||||
RoutingTableEntry = 145,
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
} // namespace tlv
|
||||
} // namespace ndn
|
||||
} // namespace nlsr::tlv
|
||||
|
||||
#endif // NLSR_TLV_NLSR_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -17,9 +17,10 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
*/
|
||||
|
||||
#include "manager-base.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
namespace update {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "lsdb.hpp"
|
||||
#include "nfd-rib-commands.hpp"
|
||||
#include "prefix-update-commands.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/interest.hpp>
|
||||
@@ -38,6 +37,7 @@
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
@@ -95,7 +95,7 @@ private:
|
||||
std::string m_module;
|
||||
};
|
||||
|
||||
class CommandManagerBase: public ManagerBase
|
||||
class CommandManagerBase : public ManagerBase
|
||||
{
|
||||
public:
|
||||
CommandManagerBase(ndn::mgmt::Dispatcher& m_dispatcher,
|
||||
@@ -103,7 +103,8 @@ public:
|
||||
Lsdb& lsdb,
|
||||
const std::string& module);
|
||||
|
||||
virtual ~CommandManagerBase() {}
|
||||
virtual
|
||||
~CommandManagerBase() = default;
|
||||
|
||||
/*! \brief add desired name prefix to the advertised name prefix list
|
||||
* or insert a prefix into the FIB if parameters is valid.
|
||||
@@ -126,14 +127,20 @@ public:
|
||||
/*! \brief save an advertised prefix to the nlsr configuration file
|
||||
* returns bool from the overridden function while nullopt here
|
||||
*/
|
||||
virtual ndn::optional<bool>
|
||||
afterAdvertise(const ndn::Name& prefix) { return ndn::nullopt; }
|
||||
virtual std::optional<bool>
|
||||
afterAdvertise(const ndn::Name& prefix)
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/*! \brief save an advertised prefix to the nlsr configuration file
|
||||
* returns bool from the overridden function while nullopt here
|
||||
*/
|
||||
virtual ndn::optional<bool>
|
||||
afterWithdraw(const ndn::Name& prefix) { return ndn::nullopt; }
|
||||
virtual std::optional<bool>
|
||||
afterWithdraw(const ndn::Name& prefix)
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
protected:
|
||||
NamePrefixList& m_namePrefixList;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "prefix-update-processor.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "lsdb.hpp"
|
||||
#include "nlsr.hpp"
|
||||
|
||||
@@ -41,12 +42,12 @@ using SignerTag = ndn::SimpleTag<ndn::Name, 20>;
|
||||
|
||||
/** \brief obtain signer from SignerTag attached to Interest, if available
|
||||
*/
|
||||
static ndn::optional<std::string>
|
||||
static std::optional<std::string>
|
||||
getSignerFromTag(const ndn::Interest& interest)
|
||||
{
|
||||
auto signerTag = interest.getTag<SignerTag>();
|
||||
if (signerTag == nullptr) {
|
||||
return ndn::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
else {
|
||||
return signerTag->get().toUri();
|
||||
@@ -180,13 +181,13 @@ PrefixUpdateProcessor::addOrDeletePrefix(const ndn::Name& prefix, bool addPrefix
|
||||
return true;
|
||||
}
|
||||
|
||||
ndn::optional<bool>
|
||||
std::optional<bool>
|
||||
PrefixUpdateProcessor::afterAdvertise(const ndn::Name& prefix)
|
||||
{
|
||||
return addOrDeletePrefix(prefix, true);
|
||||
}
|
||||
|
||||
ndn::optional<bool>
|
||||
std::optional<bool>
|
||||
PrefixUpdateProcessor::afterWithdraw(const ndn::Name& prefix)
|
||||
{
|
||||
return addOrDeletePrefix(prefix, false);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -32,7 +32,7 @@
|
||||
namespace nlsr {
|
||||
namespace update {
|
||||
|
||||
typedef boost::property_tree::ptree ConfigSection;
|
||||
using ConfigSection = boost::property_tree::ptree;
|
||||
|
||||
class PrefixUpdateProcessor : public CommandManagerBase
|
||||
{
|
||||
@@ -62,11 +62,11 @@ public:
|
||||
bool
|
||||
addOrDeletePrefix(const ndn::Name& prefix, bool addPrefix);
|
||||
|
||||
ndn::optional<bool>
|
||||
afterAdvertise(const ndn::Name& prefix);
|
||||
std::optional<bool>
|
||||
afterAdvertise(const ndn::Name& prefix) override;
|
||||
|
||||
ndn::optional<bool>
|
||||
afterWithdraw(const ndn::Name& prefix);
|
||||
std::optional<bool>
|
||||
afterWithdraw(const ndn::Name& prefix) override;
|
||||
|
||||
/*! \brief Check if a prefix exists in the nlsr configuration file */
|
||||
bool
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis,
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -25,8 +25,7 @@
|
||||
|
||||
#include "common.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
namespace util {
|
||||
namespace nlsr::util {
|
||||
|
||||
/*!
|
||||
\brief search a name component in ndn::Name and return the position of the component
|
||||
@@ -42,13 +41,12 @@ getNameComponentPosition(const ndn::Name& name, const std::string& searchString)
|
||||
size_t nameSize = name.size();
|
||||
for (uint32_t i = 0; i < nameSize; i++) {
|
||||
if (component == name[i]) {
|
||||
return (int32_t)i;
|
||||
return static_cast<int32_t>(i);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace nlsr
|
||||
} // namespace nlsr::util
|
||||
|
||||
#endif // NLSR_NAME_HELPER_HPP
|
||||
@@ -28,8 +28,7 @@
|
||||
|
||||
#include <ndn-cxx/util/time-unit-test-clock.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
namespace nlsr::test {
|
||||
|
||||
namespace time = ndn::time;
|
||||
|
||||
@@ -85,7 +84,6 @@ protected:
|
||||
std::shared_ptr<time::UnitTestSystemClock> m_systemClock;
|
||||
};
|
||||
|
||||
} // namespace test
|
||||
} // namespace nlsr
|
||||
} // namespace nlsr::test
|
||||
|
||||
#endif // NLSR_TESTS_CLOCK_FIXTURE_HPP
|
||||
@@ -30,8 +30,7 @@
|
||||
|
||||
#include <boost/asio/io_service.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
namespace nlsr::test {
|
||||
|
||||
class IoFixture : public ClockFixture
|
||||
{
|
||||
@@ -53,7 +52,6 @@ protected:
|
||||
boost::asio::io_service m_io;
|
||||
};
|
||||
|
||||
} // namespace test
|
||||
} // namespace nlsr
|
||||
} // namespace nlsr::test
|
||||
|
||||
#endif // NLSR_TESTS_IO_FIXTURE_HPP
|
||||
@@ -25,14 +25,12 @@
|
||||
#include "tests/key-chain-fixture.hpp"
|
||||
#include "tests/io-fixture.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
namespace nlsr::test {
|
||||
|
||||
class IoKeyChainFixture : public IoFixture, public KeyChainFixture
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace test
|
||||
} // namespace nlsr
|
||||
} // namespace nlsr::test
|
||||
|
||||
#endif // NLSR_TESTS_IO_KEY_CHAIN_FIXTURE_HPP
|
||||
@@ -29,8 +29,7 @@
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
#include <ndn-cxx/security/signing-helpers.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
namespace nlsr::test {
|
||||
|
||||
/**
|
||||
* @brief A fixture providing an in-memory KeyChain.
|
||||
@@ -96,7 +95,6 @@ private:
|
||||
std::vector<std::string> m_certFiles;
|
||||
};
|
||||
|
||||
} // namespace test
|
||||
} // namespace nlsr
|
||||
} // namespace nlsr::test
|
||||
|
||||
#endif // NLSR_TESTS_KEY_CHAIN_FIXTURE_HPP
|
||||
@@ -55,19 +55,19 @@ BOOST_AUTO_TEST_CASE(Localhost)
|
||||
|
||||
// Request adjacency LSAs
|
||||
face.receive(ndn::Interest("/localhost/nlsr/lsdb/adjacencies").setCanBePrefix(true));
|
||||
processDatasetInterest([] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::AdjacencyLsa; });
|
||||
processDatasetInterest([] (const ndn::Block& block) { return block.type() == nlsr::tlv::AdjacencyLsa; });
|
||||
|
||||
// Request coordinate LSAs
|
||||
face.receive(ndn::Interest("/localhost/nlsr/lsdb/coordinates").setCanBePrefix(true));
|
||||
processDatasetInterest([] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::CoordinateLsa; });
|
||||
processDatasetInterest([] (const ndn::Block& block) { return block.type() == nlsr::tlv::CoordinateLsa; });
|
||||
|
||||
// Request Name LSAs
|
||||
face.receive(ndn::Interest("/localhost/nlsr/lsdb/names").setCanBePrefix(true));
|
||||
processDatasetInterest([] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::NameLsa; });
|
||||
processDatasetInterest([] (const ndn::Block& block) { return block.type() == nlsr::tlv::NameLsa; });
|
||||
|
||||
// Request Routing Table
|
||||
face.receive(ndn::Interest("/localhost/nlsr/routing-table").setCanBePrefix(true));
|
||||
processDatasetInterest([] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::RoutingTable; });
|
||||
processDatasetInterest([] (const ndn::Block& block) { return block.type() == nlsr::tlv::RoutingTable; });
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(RouterName)
|
||||
@@ -101,19 +101,19 @@ BOOST_AUTO_TEST_CASE(RouterName)
|
||||
|
||||
// Request adjacency LSAs
|
||||
face.receive(ndn::Interest(ndn::Name(routerName).append("lsdb").append("adjacencies")).setCanBePrefix(true));
|
||||
processDatasetInterest([] (const auto& block) { return block.type() == ndn::tlv::nlsr::AdjacencyLsa; });
|
||||
processDatasetInterest([] (const auto& block) { return block.type() == nlsr::tlv::AdjacencyLsa; });
|
||||
|
||||
// Request coordinate LSAs
|
||||
face.receive(ndn::Interest(ndn::Name(routerName).append("lsdb").append("coordinates")).setCanBePrefix(true));
|
||||
processDatasetInterest([] (const auto& block) { return block.type() == ndn::tlv::nlsr::CoordinateLsa; });
|
||||
processDatasetInterest([] (const auto& block) { return block.type() == nlsr::tlv::CoordinateLsa; });
|
||||
|
||||
// Request Name LSAs
|
||||
face.receive(ndn::Interest(ndn::Name(routerName).append("lsdb").append("names")).setCanBePrefix(true));
|
||||
processDatasetInterest([] (const auto& block) { return block.type() == ndn::tlv::nlsr::NameLsa; });
|
||||
processDatasetInterest([] (const auto& block) { return block.type() == nlsr::tlv::NameLsa; });
|
||||
|
||||
// Request Routing Table
|
||||
face.receive(ndn::Interest(ndn::Name(routerName).append("routing-table")).setCanBePrefix(true));
|
||||
processDatasetInterest([] (const auto& block) { return block.type() == ndn::tlv::nlsr::RoutingTable; });
|
||||
processDatasetInterest([] (const auto& block) { return block.type() == nlsr::tlv::RoutingTable; });
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -26,15 +26,14 @@ namespace test {
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(TestRoutingTableEntry)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(RoutingTableEntryDestination)
|
||||
BOOST_AUTO_TEST_CASE(Destination)
|
||||
{
|
||||
RoutingTableEntry rte1("router1");
|
||||
|
||||
BOOST_CHECK_EQUAL(rte1.getDestination(), "router1");
|
||||
}
|
||||
|
||||
const uint8_t RoutingTableEntryWithNexthopsData[] =
|
||||
{
|
||||
const uint8_t RoutingTableEntryWithNexthopsData[] = {
|
||||
// Header
|
||||
0x91, 0x35,
|
||||
// Destination Name
|
||||
@@ -47,15 +46,14 @@ const uint8_t RoutingTableEntryWithNexthopsData[] =
|
||||
0x66, 0x66, 0x66, 0x66
|
||||
};
|
||||
|
||||
const uint8_t RoutingTableEntryWithoutNexthopsData[] =
|
||||
{
|
||||
const uint8_t RoutingTableEntryWithoutNexthopsData[] = {
|
||||
// Header
|
||||
0x91, 0x09,
|
||||
// Destination Name
|
||||
0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(RoutingTableEntryEncodeWithNexthops)
|
||||
BOOST_AUTO_TEST_CASE(EncodeWithNexthops)
|
||||
{
|
||||
RoutingTableEntry rte(ndn::Name("dest1"));
|
||||
|
||||
@@ -73,7 +71,7 @@ BOOST_AUTO_TEST_CASE(RoutingTableEntryEncodeWithNexthops)
|
||||
boost::test_tools::per_element());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(RoutingTableEntryDecodeWithNexthops)
|
||||
BOOST_AUTO_TEST_CASE(DecodeWithNexthops)
|
||||
{
|
||||
RoutingTableEntry rte(ndn::Block{RoutingTableEntryWithNexthopsData});
|
||||
BOOST_CHECK_EQUAL(rte.getDestination(), "dest1");
|
||||
@@ -88,21 +86,21 @@ BOOST_AUTO_TEST_CASE(RoutingTableEntryDecodeWithNexthops)
|
||||
BOOST_CHECK_EQUAL(it->getRouteCost(), 1.65);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(RoutingTableEntryEncodeWithoutNexthops)
|
||||
BOOST_AUTO_TEST_CASE(EncodeWithoutNexthops)
|
||||
{
|
||||
RoutingTableEntry rte(ndn::Name("dest1"));
|
||||
BOOST_TEST(rte.wireEncode() == RoutingTableEntryWithoutNexthopsData,
|
||||
boost::test_tools::per_element());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(RoutingTableEntryDecodeWithoutNexthops)
|
||||
BOOST_AUTO_TEST_CASE(DecodeWithoutNexthops)
|
||||
{
|
||||
RoutingTableEntry rte(ndn::Block{RoutingTableEntryWithoutNexthopsData});
|
||||
BOOST_CHECK_EQUAL(rte.getDestination(), "dest1");
|
||||
BOOST_CHECK_EQUAL(rte.getNexthopList().size(), 0);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(RoutingTableEntryClear)
|
||||
BOOST_AUTO_TEST_CASE(Clear)
|
||||
{
|
||||
RoutingTableEntry rte(ndn::Name("dest1"));
|
||||
|
||||
@@ -131,7 +129,7 @@ BOOST_AUTO_TEST_CASE(RoutingTableEntryClear)
|
||||
BOOST_CHECK_EQUAL(it->getRouteCost(), 99);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(RoutingTableEntryOutputStream)
|
||||
BOOST_AUTO_TEST_CASE(OutputStream)
|
||||
{
|
||||
RoutingTableEntry rte(ndn::Name("dest1"));
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(TestRoutingTable)
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(RoutingTableAddNextHop, RoutingTableFixture)
|
||||
BOOST_FIXTURE_TEST_CASE(AddNextHop, RoutingTableFixture)
|
||||
{
|
||||
NextHop nh1;
|
||||
const std::string DEST_ROUTER = "destRouter";
|
||||
@@ -54,8 +54,7 @@ BOOST_FIXTURE_TEST_CASE(RoutingTableAddNextHop, RoutingTableFixture)
|
||||
BOOST_CHECK_EQUAL(rt.findRoutingTableEntry(DEST_ROUTER)->getDestination(), DEST_ROUTER);
|
||||
}
|
||||
|
||||
const uint8_t RoutingTableData1[] =
|
||||
{
|
||||
const uint8_t RoutingTableData1[] = {
|
||||
// Header
|
||||
0x90, 0x20,
|
||||
// Routing table entry
|
||||
@@ -67,39 +66,30 @@ const uint8_t RoutingTableData1[] =
|
||||
0x66, 0x66, 0x66, 0x66, 0x66
|
||||
};
|
||||
|
||||
const uint8_t RoutingTableData2[] =
|
||||
{
|
||||
const uint8_t RoutingTableData2[] = {
|
||||
// Header
|
||||
0x90, 0x00
|
||||
};
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(RoutingTableEncode1, RoutingTableFixture)
|
||||
BOOST_FIXTURE_TEST_CASE(Encode, RoutingTableFixture)
|
||||
{
|
||||
NextHop nexthops;
|
||||
nexthops.setConnectingFaceUri("nexthop");
|
||||
nexthops.setRouteCost(1.65);
|
||||
rt.addNextHop("dest1", nexthops);
|
||||
|
||||
auto wire = rt.wireEncode();
|
||||
BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableData1,
|
||||
RoutingTableData1 + sizeof(RoutingTableData1),
|
||||
wire.begin(), wire.end());
|
||||
BOOST_TEST(rt.wireEncode() == RoutingTableData1, boost::test_tools::per_element());
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(RoutingTableEncode2, RoutingTableFixture)
|
||||
BOOST_FIXTURE_TEST_CASE(EncodeEmpty, RoutingTableFixture)
|
||||
{
|
||||
auto wire = rt.wireEncode();
|
||||
BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableData2,
|
||||
RoutingTableData2 + sizeof(RoutingTableData2),
|
||||
wire.begin(), wire.end());
|
||||
BOOST_TEST(rt.wireEncode() == RoutingTableData2, boost::test_tools::per_element());
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(RoutingTableDecode1, RoutingTableFixture)
|
||||
BOOST_FIXTURE_TEST_CASE(Decode, RoutingTableFixture)
|
||||
{
|
||||
RoutingTableStatus rtStatus(ndn::Block{RoutingTableData1});
|
||||
|
||||
auto it1 = rtStatus.m_rTable.begin();
|
||||
|
||||
ndn::Name des1 = it1->getDestination();
|
||||
BOOST_CHECK_EQUAL(des1, "dest1");
|
||||
|
||||
@@ -110,7 +100,7 @@ BOOST_FIXTURE_TEST_CASE(RoutingTableDecode1, RoutingTableFixture)
|
||||
BOOST_CHECK_EQUAL(rtStatus.m_rTable.size(), 1);
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(RoutingTableOutputStream, RoutingTableFixture)
|
||||
BOOST_FIXTURE_TEST_CASE(OutputStream, RoutingTableFixture)
|
||||
{
|
||||
NextHop nexthops;
|
||||
nexthops.setConnectingFaceUri("nexthop");
|
||||
|
||||
@@ -119,7 +119,7 @@ public:
|
||||
const boost::filesystem::path ROOT_CERT_PATH;
|
||||
};
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(TestSecurityCertificateStore, CertificateStoreFixture)
|
||||
BOOST_FIXTURE_TEST_SUITE(TestCertificateStore, CertificateStoreFixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Basic)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
*/
|
||||
|
||||
#include "adjacency-list.hpp"
|
||||
#include "common.hpp"
|
||||
@@ -64,7 +64,7 @@ BOOST_AUTO_TEST_CASE(Basic)
|
||||
BOOST_CHECK_EQUAL(adjacentList1.getStatusOfNeighbor(n1), Adjacent::STATUS_ACTIVE);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(findAdjacentByFaceUri)
|
||||
BOOST_AUTO_TEST_CASE(FindAdjacentByFaceUri)
|
||||
{
|
||||
ndn::FaceUri faceUri("udp4://10.0.0.1:6363");
|
||||
Adjacent adj1("/ndn/test/1", faceUri, 10, Adjacent::STATUS_INACTIVE, 0, 0);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -18,7 +18,7 @@
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author Ashlesh Gawande <agawande@memphis.edu>
|
||||
**/
|
||||
*/
|
||||
|
||||
#include "adjacent.hpp"
|
||||
#include "tests/boost-test.hpp"
|
||||
@@ -26,8 +26,6 @@
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using namespace std;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(TestAdjacent)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(OperatorEquals)
|
||||
@@ -77,7 +75,7 @@ BOOST_AUTO_TEST_CASE(Accessors)
|
||||
BOOST_CHECK_EQUAL(adjacent1.getLinkCost(), 11);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(compareFaceUri)
|
||||
BOOST_AUTO_TEST_CASE(CompareFaceUri)
|
||||
{
|
||||
const ndn::Name ADJ_NAME_1 = "name1";
|
||||
const ndn::Name ADJ_NAME_2 = "name2";
|
||||
@@ -90,7 +88,7 @@ BOOST_AUTO_TEST_CASE(compareFaceUri)
|
||||
BOOST_CHECK(adjacent1.compareFaceUri(adjacent2.getFaceUri()));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(compareFaceId)
|
||||
BOOST_AUTO_TEST_CASE(CompareFaceId)
|
||||
{
|
||||
const ndn::Name ADJ_NAME_1 = "name1";
|
||||
const ndn::Name ADJ_NAME_2 = "name2";
|
||||
|
||||
@@ -29,8 +29,7 @@
|
||||
#include <ndn-cxx/data.hpp>
|
||||
#include <ndn-cxx/util/dummy-client-face.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
namespace nlsr::test {
|
||||
|
||||
/**
|
||||
* \brief Create a Data with a null (i.e., empty) signature
|
||||
@@ -78,7 +77,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace test
|
||||
} // namespace nlsr
|
||||
} // namespace nlsr::test
|
||||
|
||||
#endif // NLSR_TESTS_TEST_COMMON_HPP
|
||||
+21
-42
@@ -101,26 +101,22 @@ BOOST_AUTO_TEST_CASE(NameLsaBasic)
|
||||
BOOST_CHECK(nlsa1.getExpirationTimePoint() == nlsa2.getExpirationTimePoint());
|
||||
|
||||
auto wire = nlsa1.wireEncode();
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(NAME_LSA1, NAME_LSA1 + sizeof(NAME_LSA1),
|
||||
wire.begin(), wire.end());
|
||||
BOOST_TEST(wire == NAME_LSA1, boost::test_tools::per_element());
|
||||
|
||||
nlsa1.addName("name3");
|
||||
wire = nlsa1.wireEncode();
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(NAME_LSA_EXTRA_NAME,
|
||||
NAME_LSA_EXTRA_NAME + sizeof(NAME_LSA_EXTRA_NAME),
|
||||
wire.begin(), wire.end());
|
||||
BOOST_TEST(wire == NAME_LSA_EXTRA_NAME, boost::test_tools::per_element());
|
||||
|
||||
nlsa1.setSeqNo(14);
|
||||
wire = nlsa1.wireEncode();
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(NAME_LSA_DIFF_SEQ, NAME_LSA_DIFF_SEQ + sizeof(NAME_LSA_DIFF_SEQ),
|
||||
wire.begin(), wire.end());
|
||||
BOOST_TEST(wire == NAME_LSA_DIFF_SEQ, boost::test_tools::per_element());
|
||||
|
||||
testTimePoint =
|
||||
ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196024993));
|
||||
nlsa1.setExpirationTimePoint(testTimePoint);
|
||||
wire = nlsa1.wireEncode();
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(NAME_LSA_DIFF_TS, NAME_LSA_DIFF_TS + sizeof(NAME_LSA_DIFF_TS),
|
||||
wire.begin(), wire.end());
|
||||
BOOST_TEST(wire == NAME_LSA_DIFF_TS, boost::test_tools::per_element());
|
||||
|
||||
// Not testing router name as not sure if that will ever change once set
|
||||
}
|
||||
|
||||
@@ -209,28 +205,22 @@ BOOST_AUTO_TEST_CASE(AdjLsaBasic)
|
||||
BOOST_CHECK(alsa1.isEqualContent(alsa3));
|
||||
|
||||
auto wire = alsa1.wireEncode();
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(ADJ_LSA1, ADJ_LSA1 + sizeof(ADJ_LSA1),
|
||||
wire.begin(), wire.end());
|
||||
BOOST_TEST(wire == ADJ_LSA1, boost::test_tools::per_element());
|
||||
|
||||
Adjacent activeAdjacency2("/ndn/edu/adjacency");
|
||||
activeAdjacency2.setStatus(Adjacent::STATUS_ACTIVE);
|
||||
alsa1.addAdjacent(activeAdjacency2);
|
||||
wire = alsa1.wireEncode();
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(ADJ_LSA_EXTRA_NEIGHBOR,
|
||||
ADJ_LSA_EXTRA_NEIGHBOR + sizeof(ADJ_LSA_EXTRA_NEIGHBOR),
|
||||
wire.begin(), wire.end());
|
||||
BOOST_TEST(wire == ADJ_LSA_EXTRA_NEIGHBOR, boost::test_tools::per_element());
|
||||
|
||||
alsa1.setSeqNo(14);
|
||||
wire = alsa1.wireEncode();
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(ADJ_LSA_DIFF_SEQ, ADJ_LSA_DIFF_SEQ + sizeof(ADJ_LSA_DIFF_SEQ),
|
||||
wire.begin(), wire.end());
|
||||
BOOST_TEST(wire == ADJ_LSA_DIFF_SEQ, boost::test_tools::per_element());
|
||||
|
||||
testTimePoint =
|
||||
ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196024993));
|
||||
testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196024993));
|
||||
alsa1.setExpirationTimePoint(testTimePoint);
|
||||
wire = alsa1.wireEncode();
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(ADJ_LSA_DIFF_TS, ADJ_LSA_DIFF_TS + sizeof(ADJ_LSA_DIFF_TS),
|
||||
wire.begin(), wire.end());
|
||||
BOOST_TEST(wire == ADJ_LSA_DIFF_TS, boost::test_tools::per_element());
|
||||
}
|
||||
|
||||
const uint8_t COORDINATE_LSA1[] = {
|
||||
@@ -286,35 +276,25 @@ BOOST_AUTO_TEST_CASE(CoordinateLsaBasic)
|
||||
BOOST_CHECK_EQUAL(clsa1.wireEncode(), clsa2.wireEncode());
|
||||
|
||||
auto wire = clsa1.wireEncode();
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(COORDINATE_LSA1, COORDINATE_LSA1 + sizeof(COORDINATE_LSA1),
|
||||
wire.begin(), wire.end());
|
||||
BOOST_TEST(wire == COORDINATE_LSA1, boost::test_tools::per_element());
|
||||
|
||||
std::vector<double> angles3{40.0};
|
||||
clsa1.setCorTheta(angles3);
|
||||
wire = clsa1.wireEncode();
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(COORDINATE_LSA_DIFF_ANGLE,
|
||||
COORDINATE_LSA_DIFF_ANGLE + sizeof(COORDINATE_LSA_DIFF_ANGLE),
|
||||
wire.begin(), wire.end());
|
||||
BOOST_TEST(wire == COORDINATE_LSA_DIFF_ANGLE, boost::test_tools::per_element());
|
||||
|
||||
clsa1.setCorRadius(2.3);
|
||||
wire = clsa1.wireEncode();
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(COORDINATE_LSA_DIFF_RADIUS,
|
||||
COORDINATE_LSA_DIFF_RADIUS + sizeof(COORDINATE_LSA_DIFF_RADIUS),
|
||||
wire.begin(), wire.end());
|
||||
BOOST_TEST(wire == COORDINATE_LSA_DIFF_RADIUS, boost::test_tools::per_element());
|
||||
|
||||
clsa1.setSeqNo(14);
|
||||
wire = clsa1.wireEncode();
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(COORDINATE_LSA_DIFF_SEQ,
|
||||
COORDINATE_LSA_DIFF_SEQ + sizeof(COORDINATE_LSA_DIFF_SEQ),
|
||||
wire.begin(), wire.end());
|
||||
BOOST_TEST(wire == COORDINATE_LSA_DIFF_SEQ, boost::test_tools::per_element());
|
||||
|
||||
testTimePoint =
|
||||
ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196024993));
|
||||
testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196024993));
|
||||
clsa1.setExpirationTimePoint(testTimePoint);
|
||||
wire = clsa1.wireEncode();
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(COORDINATE_LSA_DIFF_TS,
|
||||
COORDINATE_LSA_DIFF_TS + sizeof(COORDINATE_LSA_DIFF_TS),
|
||||
wire.begin(), wire.end());
|
||||
BOOST_TEST(wire == COORDINATE_LSA_DIFF_TS, boost::test_tools::per_element());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(IncrementAdjacentNumber)
|
||||
@@ -417,11 +397,11 @@ BOOST_AUTO_TEST_CASE(NameLsaUpdate)
|
||||
knownNameLsa.addName("/yoursunny/_/dal");
|
||||
knownNameLsa.addName("/ndn");
|
||||
|
||||
std::shared_ptr<Lsa> rcvdLsa = std::make_shared<NameLsa>();
|
||||
|
||||
auto rcvdLsa = std::make_shared<NameLsa>();
|
||||
rcvdLsa->m_originRouter = ndn::Name("/yoursunny/_/%C1.Router/dal");
|
||||
rcvdLsa->m_seqNo = 2684;
|
||||
rcvdLsa->setExpirationTimePoint(ndn::time::system_clock::now() + 3600_ms);
|
||||
|
||||
auto nlsa = std::static_pointer_cast<NameLsa>(rcvdLsa);
|
||||
nlsa->addName("/ndn");
|
||||
nlsa->addName("/yoursunny/_/dal");
|
||||
@@ -430,12 +410,11 @@ BOOST_AUTO_TEST_CASE(NameLsaUpdate)
|
||||
nlsa->addName(addedName1);
|
||||
nlsa->addName(addedName2);
|
||||
|
||||
bool updated;
|
||||
std::list<ndn::Name> namesToAdd, namesToRemove;
|
||||
std::tie(updated, namesToAdd, namesToRemove) = knownNameLsa.update(rcvdLsa);
|
||||
auto [updated, namesToAdd, namesToRemove] = knownNameLsa.update(rcvdLsa);
|
||||
|
||||
BOOST_CHECK_EQUAL(namesToRemove.size(), 0);
|
||||
BOOST_CHECK_EQUAL(updated, true);
|
||||
BOOST_CHECK_EQUAL(namesToAdd.size(), 2);
|
||||
BOOST_CHECK_EQUAL(namesToRemove.size(), 0);
|
||||
auto it = std::find(namesToAdd.begin(), namesToAdd.end(), addedName1);
|
||||
BOOST_CHECK(it != namesToAdd.end());
|
||||
it = std::find(namesToAdd.begin(), namesToAdd.end(), addedName2);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
*/
|
||||
|
||||
#include "name-prefix-list.hpp"
|
||||
#include "tests/boost-test.hpp"
|
||||
@@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(GetNames)
|
||||
The NamePrefixList will count the number of sources for a given
|
||||
name, with zero for a non-existent name.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(countSources)
|
||||
BOOST_AUTO_TEST_CASE(CountSources)
|
||||
{
|
||||
const ndn::Name name1{"/ndn/test/prefix1"};
|
||||
const ndn::Name invalidName{"/not/a/prefix"};
|
||||
@@ -104,7 +104,7 @@ BOOST_AUTO_TEST_CASE(countSources)
|
||||
The NamePrefixList will return a container with all the sources for
|
||||
a given name, with an empty container for a non-existent name.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(getSources)
|
||||
BOOST_AUTO_TEST_CASE(GetSources)
|
||||
{
|
||||
NamePrefixList list;
|
||||
const ndn::Name name1{"/ndn/test/prefix1"};
|
||||
@@ -183,10 +183,6 @@ BOOST_AUTO_TEST_CASE(BraceInitializerCtors)
|
||||
const std::vector<ndn::Name> namesVector{name1, name2, name3};
|
||||
NamePrefixList list3(namesVector);
|
||||
BOOST_CHECK(list1 == list3);
|
||||
|
||||
const std::list<ndn::Name> namesList{name1, name2, name3};
|
||||
NamePrefixList list4(namesList);
|
||||
BOOST_CHECK(list1 == list4);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(ValidateParametersFailure, NfdRibCommand, Commands
|
||||
BOOST_CHECK(!wasValidated);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(onReceiveInterestRegisterCommand)
|
||||
BOOST_AUTO_TEST_CASE(OnReceiveInterestRegisterCommand)
|
||||
{
|
||||
ndn::Name name("/localhost/nlsr/rib/register");
|
||||
ndn::Name prefixName("/test/prefixA");
|
||||
@@ -145,7 +145,7 @@ BOOST_AUTO_TEST_CASE(onReceiveInterestRegisterCommand)
|
||||
BOOST_CHECK(nameLsaSeqNoBeforeInterest < nlsr.m_lsdb.m_sequencingManager.getNameLsaSeq());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(onReceiveInterestUnregisterCommand)
|
||||
BOOST_AUTO_TEST_CASE(OnReceiveInterestUnregisterCommand)
|
||||
{
|
||||
ndn::Name name("/localhost/nlsr/rib/unregister");
|
||||
ndn::Name prefixName("/test/prefixA");
|
||||
@@ -161,7 +161,7 @@ BOOST_AUTO_TEST_CASE(onReceiveInterestUnregisterCommand)
|
||||
BOOST_CHECK(nameLsaSeqNoBeforeInterest < nlsr.m_lsdb.m_sequencingManager.getNameLsaSeq());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(onReceiveInterestInvalidPrefix)
|
||||
BOOST_AUTO_TEST_CASE(OnReceiveInterestInvalidPrefix)
|
||||
{
|
||||
ndn::Name name("/localhost/invalid/rib/register");
|
||||
ndn::Name prefixName("/test/prefixA");
|
||||
|
||||
+5
-8
@@ -367,15 +367,12 @@ Nlsrc::fetchFromRt(const std::function<void(const T&)>& recordDataset)
|
||||
|
||||
template<class T>
|
||||
void
|
||||
Nlsrc::onFetchSuccess(const ndn::ConstBufferPtr& data,
|
||||
Nlsrc::onFetchSuccess(const ndn::ConstBufferPtr& buf,
|
||||
const std::function<void(const T&)>& recordDataset)
|
||||
{
|
||||
ndn::Block block;
|
||||
size_t offset = 0;
|
||||
|
||||
while (offset < data->size()) {
|
||||
bool isOk = false;
|
||||
std::tie(isOk, block) = ndn::Block::fromBuffer(data, offset);
|
||||
while (offset < buf->size()) {
|
||||
auto [isOk, block] = ndn::Block::fromBuffer(buf, offset);
|
||||
|
||||
if (!isOk) {
|
||||
std::cerr << "ERROR: cannot decode LSA TLV" << std::endl;
|
||||
@@ -384,8 +381,8 @@ Nlsrc::onFetchSuccess(const ndn::ConstBufferPtr& data,
|
||||
|
||||
offset += block.size();
|
||||
|
||||
T data(block);
|
||||
recordDataset(data);
|
||||
T dataset(block);
|
||||
recordDataset(dataset);
|
||||
}
|
||||
|
||||
runNextStep();
|
||||
|
||||
Reference in new issue
Block a user