Compare commits
11
Commits
NLSR-0.7.0
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd1e940648 | ||
|
|
5849ee7582 | ||
|
|
2ecb059eb9 | ||
|
|
20377645fb | ||
|
|
6593a43fa3 | ||
|
|
931ca9f576 | ||
|
|
cd77aabaa9 | ||
|
|
eed3209c8d | ||
|
|
5110a8a4ee | ||
|
|
52f16644ab | ||
|
|
43f37a08fc |
No files matched your search
@@ -3,10 +3,12 @@
|
||||
import platform
|
||||
from waflib import Configure, Logs, Utils
|
||||
|
||||
|
||||
def options(opt):
|
||||
opt.add_option('--debug', '--with-debug', action='store_true', default=False,
|
||||
help='Compile in debugging mode with minimal optimizations (-Og)')
|
||||
|
||||
|
||||
def configure(conf):
|
||||
conf.start_msg('Checking C++ compiler version')
|
||||
|
||||
@@ -18,19 +20,22 @@ def configure(conf):
|
||||
if cxx == 'gcc':
|
||||
if ccver < (7, 4, 0):
|
||||
errmsg = ('The version of gcc you are using is too old.\n'
|
||||
'The minimum supported gcc version is 7.4.')
|
||||
'The minimum supported gcc version is 9.3.')
|
||||
elif ccver < (9, 3, 0):
|
||||
warnmsg = ('Using a version of gcc older than 9.3 is not '
|
||||
'officially supported and may result in build failures.')
|
||||
conf.flags = GccFlags()
|
||||
elif cxx == 'clang':
|
||||
if Utils.unversioned_sys_platform() == 'darwin':
|
||||
if ccver < (10, 0, 0):
|
||||
errmsg = ('The version of Xcode you are using is too old.\n'
|
||||
'The minimum supported Xcode version is 11.3.')
|
||||
elif ccver < (11, 0, 0):
|
||||
warnmsg = ('Using a version of Xcode older than 11.3 is not '
|
||||
'The minimum supported Xcode version is 12.4.')
|
||||
elif ccver < (12, 0, 0):
|
||||
warnmsg = ('Using a version of Xcode older than 12.4 is not '
|
||||
'officially supported and may result in build failures.')
|
||||
elif ccver < (6, 0, 0):
|
||||
elif ccver < (7, 0, 0):
|
||||
errmsg = ('The version of clang you are using is too old.\n'
|
||||
'The minimum supported clang version is 6.0.')
|
||||
'The minimum supported clang version is 7.0.')
|
||||
conf.flags = ClangFlags()
|
||||
else:
|
||||
warnmsg = f'{cxx} compiler is unsupported'
|
||||
@@ -45,7 +50,7 @@ def configure(conf):
|
||||
else:
|
||||
conf.end_msg(ccverstr)
|
||||
|
||||
conf.areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
|
||||
conf.areCustomCxxflagsPresent = len(conf.env.CXXFLAGS) > 0
|
||||
|
||||
# General flags are always applied (e.g., selecting C++ language standard)
|
||||
generalFlags = conf.flags.getGeneralFlags(conf)
|
||||
@@ -53,6 +58,7 @@ def configure(conf):
|
||||
conf.add_supported_linkflags(generalFlags['LINKFLAGS'])
|
||||
conf.env.DEFINES += generalFlags['DEFINES']
|
||||
|
||||
|
||||
@Configure.conf
|
||||
def check_compiler_flags(conf):
|
||||
# Debug or optimized CXXFLAGS and LINKFLAGS are applied only if the
|
||||
@@ -75,10 +81,11 @@ def check_compiler_flags(conf):
|
||||
|
||||
conf.env.DEFINES += extraFlags['DEFINES']
|
||||
|
||||
|
||||
@Configure.conf
|
||||
def add_supported_cxxflags(self, cxxflags):
|
||||
"""
|
||||
Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
|
||||
Check which cxxflags are supported by the active compiler and add them to env.CXXFLAGS variable.
|
||||
"""
|
||||
if len(cxxflags) == 0:
|
||||
return
|
||||
@@ -94,10 +101,11 @@ def add_supported_cxxflags(self, cxxflags):
|
||||
self.end_msg(' '.join(supportedFlags))
|
||||
self.env.prepend_value('CXXFLAGS', supportedFlags)
|
||||
|
||||
|
||||
@Configure.conf
|
||||
def add_supported_linkflags(self, linkflags):
|
||||
"""
|
||||
Check which linkflags are supported by compiler and add them to env.LINKFLAGS variable
|
||||
Check which linkflags are supported by the active compiler and add them to env.LINKFLAGS variable.
|
||||
"""
|
||||
if len(linkflags) == 0:
|
||||
return
|
||||
@@ -114,13 +122,17 @@ def add_supported_linkflags(self, linkflags):
|
||||
self.env.prepend_value('LINKFLAGS', supportedFlags)
|
||||
|
||||
|
||||
class CompilerFlags(object):
|
||||
class CompilerFlags:
|
||||
def getCompilerVersion(self, conf):
|
||||
return tuple(int(i) for i in conf.env.CC_VERSION)
|
||||
|
||||
def getGeneralFlags(self, conf):
|
||||
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are always needed"""
|
||||
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []}
|
||||
return {
|
||||
'CXXFLAGS': [],
|
||||
'LINKFLAGS': [],
|
||||
'DEFINES': ['BOOST_ASIO_NO_DEPRECATED', 'BOOST_FILESYSTEM_NO_DEPRECATED'],
|
||||
}
|
||||
|
||||
def getDebugFlags(self, conf):
|
||||
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in debug mode"""
|
||||
@@ -130,94 +142,99 @@ class CompilerFlags(object):
|
||||
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in optimized mode"""
|
||||
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['NDEBUG']}
|
||||
|
||||
class GccBasicFlags(CompilerFlags):
|
||||
|
||||
class GccClangCommonFlags(CompilerFlags):
|
||||
"""
|
||||
This class defines basic flags that work for both gcc and clang compilers
|
||||
This class defines common flags that work for both gcc and clang compilers.
|
||||
"""
|
||||
|
||||
def getGeneralFlags(self, conf):
|
||||
flags = super(GccBasicFlags, self).getGeneralFlags(conf)
|
||||
flags = super().getGeneralFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-std=c++17']
|
||||
if Utils.unversioned_sys_platform() != 'darwin':
|
||||
flags['LINKFLAGS'] += ['-fuse-ld=lld']
|
||||
return flags
|
||||
|
||||
__cxxFlags = [
|
||||
'-fdiagnostics-color',
|
||||
'-Wall',
|
||||
'-Wextra',
|
||||
'-Wpedantic',
|
||||
'-Wenum-conversion',
|
||||
'-Wextra-semi',
|
||||
'-Wno-unused-parameter',
|
||||
]
|
||||
__linkFlags = ['-Wl,-O1']
|
||||
|
||||
def getDebugFlags(self, conf):
|
||||
flags = super(GccBasicFlags, self).getDebugFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-Og',
|
||||
'-g3',
|
||||
'-Wall',
|
||||
'-Wextra',
|
||||
'-Wpedantic',
|
||||
'-Werror',
|
||||
'-Wcatch-value=2',
|
||||
'-Wextra-semi',
|
||||
'-Wnon-virtual-dtor',
|
||||
'-Wno-error=deprecated-declarations', # Bug #3795
|
||||
'-Wno-error=maybe-uninitialized', # Bug #1615
|
||||
'-Wno-unused-parameter',
|
||||
]
|
||||
flags['LINKFLAGS'] += ['-Wl,-O1']
|
||||
flags = super().getDebugFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-Og', '-g'] + self.__cxxFlags + [
|
||||
'-Werror',
|
||||
'-Wno-error=deprecated-declarations', # Bug #3795
|
||||
'-Wno-error=maybe-uninitialized', # Bug #1615
|
||||
]
|
||||
flags['LINKFLAGS'] += self.__linkFlags
|
||||
return flags
|
||||
|
||||
def getOptimizedFlags(self, conf):
|
||||
flags = super(GccBasicFlags, self).getOptimizedFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-O2',
|
||||
'-g',
|
||||
'-Wall',
|
||||
'-Wextra',
|
||||
'-Wpedantic',
|
||||
'-Wcatch-value=2',
|
||||
'-Wextra-semi',
|
||||
'-Wnon-virtual-dtor',
|
||||
'-Wno-unused-parameter',
|
||||
]
|
||||
flags['LINKFLAGS'] += ['-Wl,-O1']
|
||||
flags = super().getOptimizedFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-O2', '-g1'] + self.__cxxFlags
|
||||
flags['LINKFLAGS'] += self.__linkFlags
|
||||
return flags
|
||||
|
||||
class GccFlags(GccBasicFlags):
|
||||
|
||||
class GccFlags(GccClangCommonFlags):
|
||||
__cxxFlags = [
|
||||
'-Wcatch-value=2',
|
||||
'-Wcomma-subscript', # enabled by default in C++20
|
||||
'-Wduplicated-branches',
|
||||
'-Wduplicated-cond',
|
||||
'-Wlogical-op',
|
||||
'-Wredundant-tags',
|
||||
'-Wvolatile', # enabled by default in C++20
|
||||
]
|
||||
|
||||
def getDebugFlags(self, conf):
|
||||
flags = super(GccFlags, self).getDebugFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-fdiagnostics-color',
|
||||
'-Wredundant-tags',
|
||||
]
|
||||
flags = super().getDebugFlags(conf)
|
||||
flags['CXXFLAGS'] += self.__cxxFlags
|
||||
if platform.machine() == 'armv7l':
|
||||
flags['CXXFLAGS'] += ['-Wno-psabi'] # Bug #5106
|
||||
return flags
|
||||
|
||||
def getOptimizedFlags(self, conf):
|
||||
flags = super(GccFlags, self).getOptimizedFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-fdiagnostics-color',
|
||||
'-Wredundant-tags',
|
||||
]
|
||||
flags = super().getOptimizedFlags(conf)
|
||||
flags['CXXFLAGS'] += self.__cxxFlags
|
||||
if platform.machine() == 'armv7l':
|
||||
flags['CXXFLAGS'] += ['-Wno-psabi'] # Bug #5106
|
||||
return flags
|
||||
|
||||
class ClangFlags(GccBasicFlags):
|
||||
|
||||
class ClangFlags(GccClangCommonFlags):
|
||||
def getGeneralFlags(self, conf):
|
||||
flags = super(ClangFlags, self).getGeneralFlags(conf)
|
||||
flags = super().getGeneralFlags(conf)
|
||||
if Utils.unversioned_sys_platform() == 'darwin':
|
||||
# Bug #4296
|
||||
brewdir = '/opt/homebrew' if platform.machine() == 'arm64' else '/usr/local'
|
||||
flags['CXXFLAGS'] += [['-isystem', f'{brewdir}/include'], # for Homebrew
|
||||
['-isystem', '/opt/local/include']] # for MacPorts
|
||||
flags['CXXFLAGS'] += [
|
||||
['-isystem', f'{brewdir}/include'], # for Homebrew
|
||||
['-isystem', '/opt/local/include'], # for MacPorts
|
||||
]
|
||||
elif Utils.unversioned_sys_platform() == 'freebsd':
|
||||
# Bug #4790
|
||||
flags['CXXFLAGS'] += [['-isystem', '/usr/local/include']]
|
||||
return flags
|
||||
|
||||
__cxxFlags = [
|
||||
'-Wundefined-func-template',
|
||||
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
|
||||
]
|
||||
|
||||
def getDebugFlags(self, conf):
|
||||
flags = super(ClangFlags, self).getDebugFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
|
||||
'-Wundefined-func-template',
|
||||
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
|
||||
]
|
||||
flags = super().getDebugFlags(conf)
|
||||
flags['CXXFLAGS'] += self.__cxxFlags
|
||||
return flags
|
||||
|
||||
def getOptimizedFlags(self, conf):
|
||||
flags = super(ClangFlags, self).getOptimizedFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
|
||||
'-Wundefined-func-template',
|
||||
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
|
||||
]
|
||||
flags = super().getOptimizedFlags(conf)
|
||||
flags['CXXFLAGS'] += self.__cxxFlags
|
||||
return flags
|
||||
+3
-3
@@ -17,9 +17,9 @@ Prerequisites
|
||||
Download the PSync library and build it according to the instructions available at
|
||||
https://github.com/named-data/PSync#build
|
||||
|
||||
- ChronoSync library [optional]
|
||||
- ChronoSync library [optional, deprecated]
|
||||
|
||||
For testing purposes, NLSR can be optionally built with Chronosync support. Download
|
||||
For testing purposes, NLSR can be optionally built with ChronoSync support. Download
|
||||
the ChronoSync library and build it according to the instructions available at
|
||||
https://github.com/named-data/ChronoSync#build
|
||||
|
||||
@@ -29,7 +29,7 @@ Prerequisites
|
||||
the ndn-svs library and build it according to the instructions available at
|
||||
https://github.com/named-data/ndn-svs#installation
|
||||
|
||||
Note that at least one sync library must be enabled.
|
||||
Note that at least one Sync library must be enabled.
|
||||
|
||||
Build
|
||||
-----
|
||||
|
||||
@@ -100,7 +100,7 @@ should be run as root:
|
||||
$ dnf list --installed gcc
|
||||
$ dnf list --installed gcc-c++
|
||||
|
||||
#. Python version 3.6 or later
|
||||
#. Python version 3.8 or later
|
||||
|
||||
::
|
||||
|
||||
@@ -124,7 +124,7 @@ should be run as root:
|
||||
|
||||
$ dnf list --installed pkgconf*
|
||||
|
||||
#. Boost libraries version 1.65.1 or later
|
||||
#. Boost libraries version 1.71.0 or later
|
||||
|
||||
::
|
||||
|
||||
|
||||
+26
-52
@@ -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-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -43,9 +43,9 @@ Adjacent
|
||||
AdjacencyList::getAdjacent(const ndn::Name& adjName)
|
||||
{
|
||||
Adjacent adj(adjName);
|
||||
std::list<Adjacent>::iterator it = find(adjName);
|
||||
auto it = find(adjName);
|
||||
if (it != m_adjList.end()) {
|
||||
return (*it);
|
||||
return *it;
|
||||
}
|
||||
return adj;
|
||||
}
|
||||
@@ -60,56 +60,47 @@ AdjacencyList::operator==(const AdjacencyList& adl) const
|
||||
|
||||
std::set<Adjacent> ourSet(m_adjList.cbegin(), m_adjList.cend());
|
||||
std::set<Adjacent> theirSet(theirList.cbegin(), theirList.cend());
|
||||
|
||||
return ourSet == theirSet;
|
||||
}
|
||||
|
||||
bool
|
||||
AdjacencyList::isNeighbor(const ndn::Name& adjName) const
|
||||
{
|
||||
std::list<Adjacent>::const_iterator it = find(adjName);
|
||||
if (it == m_adjList.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return find(adjName) != m_adjList.end();
|
||||
}
|
||||
|
||||
void
|
||||
AdjacencyList::incrementTimedOutInterestCount(const ndn::Name& neighbor)
|
||||
{
|
||||
std::list<Adjacent>::iterator it = find(neighbor);
|
||||
if (it == m_adjList.end()) {
|
||||
return ;
|
||||
auto it = find(neighbor);
|
||||
if (it != m_adjList.end()) {
|
||||
it->setInterestTimedOutNo(it->getInterestTimedOutNo() + 1);
|
||||
}
|
||||
(*it).setInterestTimedOutNo((*it).getInterestTimedOutNo() + 1);
|
||||
}
|
||||
|
||||
void
|
||||
AdjacencyList::setTimedOutInterestCount(const ndn::Name& neighbor,
|
||||
uint32_t count)
|
||||
AdjacencyList::setTimedOutInterestCount(const ndn::Name& neighbor, uint32_t count)
|
||||
{
|
||||
std::list<Adjacent>::iterator it = find(neighbor);
|
||||
auto it = find(neighbor);
|
||||
if (it != m_adjList.end()) {
|
||||
(*it).setInterestTimedOutNo(count);
|
||||
it->setInterestTimedOutNo(count);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t
|
||||
AdjacencyList::getTimedOutInterestCount(const ndn::Name& neighbor) const
|
||||
{
|
||||
std::list<Adjacent>::const_iterator it = find(neighbor);
|
||||
auto it = find(neighbor);
|
||||
if (it == m_adjList.end()) {
|
||||
return -1;
|
||||
}
|
||||
return (*it).getInterestTimedOutNo();
|
||||
return it->getInterestTimedOutNo();
|
||||
}
|
||||
|
||||
Adjacent::Status
|
||||
AdjacencyList::getStatusOfNeighbor(const ndn::Name& neighbor) const
|
||||
{
|
||||
std::list<Adjacent>::const_iterator it = find(neighbor);
|
||||
|
||||
auto it = find(neighbor);
|
||||
if (it == m_adjList.end()) {
|
||||
return Adjacent::STATUS_UNKNOWN;
|
||||
}
|
||||
@@ -121,7 +112,7 @@ AdjacencyList::getStatusOfNeighbor(const ndn::Name& neighbor) const
|
||||
void
|
||||
AdjacencyList::setStatusOfNeighbor(const ndn::Name& neighbor, Adjacent::Status status)
|
||||
{
|
||||
std::list<Adjacent>::iterator it = find(neighbor);
|
||||
auto it = find(neighbor);
|
||||
if (it != m_adjList.end()) {
|
||||
it->setStatus(status);
|
||||
}
|
||||
@@ -144,8 +135,7 @@ AdjacencyList::isAdjLsaBuildable(const uint32_t interestRetryNo) const
|
||||
{
|
||||
uint32_t nTimedOutNeighbors = 0;
|
||||
|
||||
for (const Adjacent& adjacency : m_adjList) {
|
||||
|
||||
for (const auto& adjacency : m_adjList) {
|
||||
if (adjacency.getStatus() == Adjacent::STATUS_ACTIVE) {
|
||||
return true;
|
||||
}
|
||||
@@ -154,12 +144,7 @@ AdjacencyList::isAdjLsaBuildable(const uint32_t interestRetryNo) const
|
||||
}
|
||||
}
|
||||
|
||||
if (nTimedOutNeighbors == m_adjList.size()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return nTimedOutNeighbors == m_adjList.size();
|
||||
}
|
||||
|
||||
int32_t
|
||||
@@ -177,54 +162,43 @@ AdjacencyList::getNumOfActiveNeighbor() const
|
||||
std::list<Adjacent>::iterator
|
||||
AdjacencyList::find(const ndn::Name& adjName)
|
||||
{
|
||||
return std::find_if(m_adjList.begin(),
|
||||
m_adjList.end(),
|
||||
return std::find_if(m_adjList.begin(), m_adjList.end(),
|
||||
std::bind(&Adjacent::compare, _1, std::cref(adjName)));
|
||||
}
|
||||
|
||||
std::list<Adjacent>::const_iterator
|
||||
AdjacencyList::find(const ndn::Name& adjName) const
|
||||
{
|
||||
return std::find_if(m_adjList.cbegin(),
|
||||
m_adjList.cend(),
|
||||
return std::find_if(m_adjList.cbegin(), m_adjList.cend(),
|
||||
std::bind(&Adjacent::compare, _1, std::cref(adjName)));
|
||||
}
|
||||
|
||||
AdjacencyList::iterator
|
||||
AdjacencyList::findAdjacent(const ndn::Name& adjName)
|
||||
{
|
||||
return std::find_if(m_adjList.begin(),
|
||||
m_adjList.end(),
|
||||
std::bind(&Adjacent::compare,
|
||||
_1, std::cref(adjName)));
|
||||
return std::find_if(m_adjList.begin(), m_adjList.end(),
|
||||
std::bind(&Adjacent::compare, _1, std::cref(adjName)));
|
||||
}
|
||||
|
||||
AdjacencyList::iterator
|
||||
AdjacencyList::findAdjacent(uint64_t faceId)
|
||||
{
|
||||
return std::find_if(m_adjList.begin(),
|
||||
m_adjList.end(),
|
||||
std::bind(&Adjacent::compareFaceId,
|
||||
_1, faceId));
|
||||
return std::find_if(m_adjList.begin(), m_adjList.end(),
|
||||
std::bind(&Adjacent::compareFaceId, _1, faceId));
|
||||
}
|
||||
|
||||
AdjacencyList::iterator
|
||||
AdjacencyList::findAdjacent(const ndn::FaceUri& faceUri)
|
||||
{
|
||||
return std::find_if(m_adjList.begin(),
|
||||
m_adjList.end(),
|
||||
std::bind(&Adjacent::compareFaceUri,
|
||||
_1, faceUri));
|
||||
return std::find_if(m_adjList.begin(), m_adjList.end(),
|
||||
std::bind(&Adjacent::compareFaceUri, _1, faceUri));
|
||||
}
|
||||
|
||||
uint64_t
|
||||
AdjacencyList::getFaceId(const ndn::FaceUri& faceUri)
|
||||
{
|
||||
std::list<Adjacent>::iterator it = std::find_if(m_adjList.begin(),
|
||||
m_adjList.end(),
|
||||
std::bind(&Adjacent::compareFaceUri,
|
||||
_1, faceUri));
|
||||
|
||||
auto it = std::find_if(m_adjList.begin(), m_adjList.end(),
|
||||
std::bind(&Adjacent::compareFaceUri, _1, faceUri));
|
||||
return it != m_adjList.end() ? it->getFaceId() : 0;
|
||||
}
|
||||
|
||||
|
||||
+1
-10
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -110,15 +110,6 @@ public:
|
||||
AdjacencyList::iterator
|
||||
findAdjacent(const ndn::FaceUri& faceUri);
|
||||
|
||||
/*! \brief Hack to stop developers from using this function
|
||||
|
||||
It is here so that faceUri cannot be passed in as string,
|
||||
converted to Name and findAdjacent(Name) be used.
|
||||
So when faceUri is passed as string this will cause a compile error
|
||||
*/
|
||||
void
|
||||
findAdjacent(const std::string&) = delete;
|
||||
|
||||
uint64_t
|
||||
getFaceId(const ndn::FaceUri& faceUri);
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <ndn-cxx/net/face-uri.hpp>
|
||||
#include <ndn-cxx/util/io.hpp>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/property_tree/info_parser.hpp>
|
||||
|
||||
@@ -127,8 +128,8 @@ private:
|
||||
private:
|
||||
const std::string m_key;
|
||||
const ConfParameterCallback m_setterCallback;
|
||||
T m_defaultValue;
|
||||
|
||||
T m_defaultValue;
|
||||
T m_minValue;
|
||||
T m_maxValue;
|
||||
|
||||
@@ -493,7 +494,7 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
m_io,
|
||||
TIME_ALLOWED_FOR_CANONIZATION);
|
||||
m_io.run();
|
||||
m_io.reset();
|
||||
m_io.restart();
|
||||
|
||||
if (failedToCanonize) {
|
||||
return 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-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "common.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
@@ -118,8 +118,8 @@ private:
|
||||
std::string m_confFileName;
|
||||
/*! m_confParam The ConfFileProcessor object to configure as parsing is done. */
|
||||
ConfParameter& m_confParam;
|
||||
/*! m_io For canonization of faceUri. */
|
||||
boost::asio::io_service m_io;
|
||||
/*! m_io For canonization of FaceUri. */
|
||||
boost::asio::io_context m_io;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
+11
-13
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -34,7 +34,7 @@ HelloProtocol::HelloProtocol(ndn::Face& face, ndn::KeyChain& keyChain,
|
||||
ConfParameter& confParam, RoutingTable& routingTable,
|
||||
Lsdb& lsdb)
|
||||
: m_face(face)
|
||||
, m_scheduler(m_face.getIoService())
|
||||
, m_scheduler(m_face.getIoContext())
|
||||
, m_keyChain(keyChain)
|
||||
, m_signingInfo(confParam.getSigningInfo())
|
||||
, m_confParam(confParam)
|
||||
@@ -72,8 +72,7 @@ HelloProtocol::expressInterest(const ndn::Name& interestName, uint32_t seconds)
|
||||
interest.setCanBePrefix(true);
|
||||
m_face.expressInterest(interest,
|
||||
std::bind(&HelloProtocol::onContent, this, _1, _2),
|
||||
[this, seconds] (const ndn::Interest& interest, const ndn::lp::Nack& nack)
|
||||
{
|
||||
[this, seconds] (const auto& interest, const auto& nack) {
|
||||
NDN_LOG_TRACE("Received Nack with reason: " << nack.getReason());
|
||||
NDN_LOG_TRACE("Will treat as timeout in " << 2 * seconds << " seconds");
|
||||
m_scheduler.schedule(ndn::time::seconds(2 * seconds),
|
||||
@@ -89,7 +88,6 @@ void
|
||||
HelloProtocol::sendHelloInterest(const ndn::Name& neighbor)
|
||||
{
|
||||
auto adjacent = m_adjacencyList.findAdjacent(neighbor);
|
||||
|
||||
if (adjacent == m_adjacencyList.end()) {
|
||||
return;
|
||||
}
|
||||
@@ -119,10 +117,10 @@ HelloProtocol::processInterest(const ndn::Name& name,
|
||||
// increment RCV_HELLO_INTEREST
|
||||
hpIncrementSignal(Statistics::PacketType::RCV_HELLO_INTEREST);
|
||||
|
||||
NLSR_LOG_DEBUG("Interest Received for Name: " << interestName);
|
||||
NLSR_LOG_DEBUG("Interest received for Name: " << interestName);
|
||||
if (interestName.get(-2).toUri() != INFO_COMPONENT) {
|
||||
NLSR_LOG_DEBUG("INFO_COMPONENT not found or interestName: " << interestName
|
||||
<< " does not match expression");
|
||||
NLSR_LOG_DEBUG("INFO_COMPONENT not found or Interest Name " << interestName
|
||||
<< " does not match expression");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -130,9 +128,9 @@ HelloProtocol::processInterest(const ndn::Name& name,
|
||||
neighbor.wireDecode(interestName.get(-1).blockFromValue());
|
||||
NLSR_LOG_DEBUG("Neighbor: " << neighbor);
|
||||
if (m_adjacencyList.isNeighbor(neighbor)) {
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>();
|
||||
auto data = std::make_shared<ndn::Data>();
|
||||
data->setName(ndn::Name(interest.getName()).appendVersion());
|
||||
data->setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec
|
||||
data->setFreshnessPeriod(10_s);
|
||||
data->setContent(ndn::make_span(reinterpret_cast<const uint8_t*>(INFO_COMPONENT.data()),
|
||||
INFO_COMPONENT.size()));
|
||||
|
||||
@@ -233,8 +231,8 @@ HelloProtocol::onContentValidated(const ndn::Data& data)
|
||||
m_adjacencyList.setTimedOutInterestCount(neighbor, 0);
|
||||
Adjacent::Status newStatus = m_adjacencyList.getStatusOfNeighbor(neighbor);
|
||||
|
||||
NLSR_LOG_DEBUG("Neighbor : " << neighbor);
|
||||
NLSR_LOG_DEBUG("Old Status: " << oldStatus << " New Status: " << newStatus);
|
||||
NLSR_LOG_DEBUG("Neighbor: " << neighbor);
|
||||
NLSR_LOG_DEBUG("Old Status: " << oldStatus << ", New Status: " << newStatus);
|
||||
// change in Adjacency list
|
||||
if ((oldStatus - newStatus) != 0) {
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
@@ -254,7 +252,7 @@ void
|
||||
HelloProtocol::onContentValidationFailed(const ndn::Data& data,
|
||||
const ndn::security::ValidationError& ve)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Validation Error: " << ve);
|
||||
NLSR_LOG_DEBUG("Validation error: " << ve);
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
void
|
||||
processInterest(const ndn::Name& name, const ndn::Interest& interest);
|
||||
|
||||
ndn::util::Signal<HelloProtocol, Statistics::PacketType> hpIncrementSignal;
|
||||
ndn::signal::Signal<HelloProtocol, Statistics::PacketType> hpIncrementSignal;
|
||||
|
||||
private:
|
||||
/*! \brief Try to contact a neighbor via Hello protocol again
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
static inline const std::string INFO_COMPONENT{"INFO"};
|
||||
static inline const std::string NLSR_COMPONENT{"nlsr"};
|
||||
|
||||
ndn::util::Signal<HelloProtocol, const ndn::Name&> onInitialHelloDataValidated;
|
||||
ndn::signal::Signal<HelloProtocol, const ndn::Name&> onInitialHelloDataValidated;
|
||||
|
||||
private:
|
||||
ndn::Face& m_face;
|
||||
|
||||
+2
-1
@@ -23,7 +23,8 @@
|
||||
#define NLSR_LSA_ADJ_LSA_HPP
|
||||
|
||||
#include "lsa.hpp"
|
||||
#include "test-access-control.hpp"
|
||||
#include "adjacent.hpp"
|
||||
#include "adjacency-list.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include "coordinate-lsa.hpp"
|
||||
#include "tlv-nlsr.hpp"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
CoordinateLsa::CoordinateLsa(const ndn::Name& originRouter, uint64_t seqNo,
|
||||
|
||||
@@ -20,9 +20,6 @@
|
||||
*/
|
||||
|
||||
#include "lsa.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "name-prefix-list.hpp"
|
||||
#include "adjacent.hpp"
|
||||
#include "tlv-nlsr.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
+3
-3
@@ -22,13 +22,13 @@
|
||||
#ifndef NLSR_LSA_LSA_HPP
|
||||
#define NLSR_LSA_LSA_HPP
|
||||
|
||||
#include "name-prefix-list.hpp"
|
||||
#include "adjacent.hpp"
|
||||
#include "adjacency-list.hpp"
|
||||
#include "common.hpp"
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
/*!
|
||||
|
||||
@@ -112,12 +112,6 @@ NameLsa::wireDecode(const ndn::Block& wire)
|
||||
m_npl = npl;
|
||||
}
|
||||
|
||||
bool
|
||||
NameLsa::isEqualContent(const NameLsa& other) const
|
||||
{
|
||||
return m_npl == other.getNpl();
|
||||
}
|
||||
|
||||
std::string
|
||||
NameLsa::toString() const
|
||||
{
|
||||
@@ -138,9 +132,6 @@ NameLsa::update(const std::shared_ptr<Lsa>& lsa)
|
||||
auto nlsa = std::static_pointer_cast<NameLsa>(lsa);
|
||||
bool updated = false;
|
||||
|
||||
m_npl.sort();
|
||||
nlsa->getNpl().sort();
|
||||
|
||||
// Obtain the set difference of the current and the incoming
|
||||
// name prefix sets, and add those.
|
||||
std::list<ndn::Name> newNames = nlsa->getNpl().getNames();
|
||||
@@ -153,8 +144,6 @@ NameLsa::update(const std::shared_ptr<Lsa>& lsa)
|
||||
updated = true;
|
||||
}
|
||||
|
||||
m_npl.sort();
|
||||
|
||||
// Also remove any names that are no longer being advertised.
|
||||
std::list<ndn::Name> namesToRemove;
|
||||
std::set_difference(oldNames.begin(), oldNames.end(), newNames.begin(), newNames.end(),
|
||||
|
||||
+16
-5
@@ -23,6 +23,9 @@
|
||||
#define NLSR_LSA_NAME_LSA_HPP
|
||||
|
||||
#include "lsa.hpp"
|
||||
#include "name-prefix-list.hpp"
|
||||
|
||||
#include <boost/operators.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
@@ -32,7 +35,7 @@ namespace nlsr {
|
||||
Lsa
|
||||
Name+
|
||||
*/
|
||||
class NameLsa : public Lsa
|
||||
class NameLsa : public Lsa, private boost::equality_comparable<NameLsa>
|
||||
{
|
||||
public:
|
||||
NameLsa() = default;
|
||||
@@ -78,12 +81,9 @@ public:
|
||||
removeName(const ndn::Name& name)
|
||||
{
|
||||
m_wire.reset();
|
||||
m_npl.remove(name);
|
||||
m_npl.erase(name);
|
||||
}
|
||||
|
||||
bool
|
||||
isEqualContent(const NameLsa& other) const;
|
||||
|
||||
template<ndn::encoding::Tag TAG>
|
||||
size_t
|
||||
wireEncode(ndn::EncodingImpl<TAG>& block) const;
|
||||
@@ -100,6 +100,17 @@ public:
|
||||
std::tuple<bool, std::list<ndn::Name>, std::list<ndn::Name>>
|
||||
update(const std::shared_ptr<Lsa>& lsa) override;
|
||||
|
||||
private: // non-member operators
|
||||
// NOTE: the following "hidden friend" operators are available via
|
||||
// argument-dependent lookup only and must be defined inline.
|
||||
// boost::equality_comparable provides != operator.
|
||||
|
||||
friend bool
|
||||
operator==(const NameLsa& lhs, const NameLsa& rhs)
|
||||
{
|
||||
return lhs.m_npl == rhs.m_npl;
|
||||
}
|
||||
|
||||
private:
|
||||
NamePrefixList m_npl;
|
||||
};
|
||||
|
||||
+16
-25
@@ -33,7 +33,7 @@ INIT_LOGGER(Lsdb);
|
||||
|
||||
Lsdb::Lsdb(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam)
|
||||
: m_face(face)
|
||||
, m_scheduler(face.getIoService())
|
||||
, m_scheduler(face.getIoContext())
|
||||
, m_confParam(confParam)
|
||||
, m_sync(m_face, keyChain,
|
||||
[this] (const auto& routerName, const Lsa::Type& lsaType,
|
||||
@@ -203,7 +203,7 @@ Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
}
|
||||
// else the interest is for other router's LSA, serve signed data from LsaSegmentStorage
|
||||
else if (auto lsaSegment = m_lsaStorage.find(interest); lsaSegment) {
|
||||
NLSR_LOG_TRACE("Found data in lsa storage. Sending data for " << interest.getName());
|
||||
NLSR_LOG_TRACE("Found data in LSA storage. Sending data for " << interest.getName());
|
||||
m_face.put(*lsaSegment);
|
||||
}
|
||||
}
|
||||
@@ -256,19 +256,16 @@ Lsdb::installLsa(std::shared_ptr<Lsa> lsa)
|
||||
|
||||
auto chkLsa = findLsa(lsa->getOriginRouter(), lsa->getType());
|
||||
if (chkLsa == nullptr) {
|
||||
NLSR_LOG_DEBUG("Adding " << lsa->getType() << " LSA");
|
||||
NLSR_LOG_DEBUG(lsa->toString());
|
||||
NLSR_LOG_DEBUG("Adding LSA:\n" << lsa->toString());
|
||||
|
||||
m_lsdb.emplace(lsa);
|
||||
|
||||
onLsdbModified(lsa, LsdbUpdate::INSTALLED, {}, {});
|
||||
|
||||
lsa->setExpiringEventId(scheduleLsaExpiration(lsa, timeToExpire));
|
||||
}
|
||||
// Else this is a known name LSA, so we are updating it.
|
||||
else if (chkLsa->getSeqNo() < lsa->getSeqNo()) {
|
||||
NLSR_LOG_DEBUG("Updating " << lsa->getType() << " LSA:");
|
||||
NLSR_LOG_DEBUG(chkLsa->toString());
|
||||
NLSR_LOG_DEBUG("Updating LSA:\n" << chkLsa->toString());
|
||||
chkLsa->setSeqNo(lsa->getSeqNo());
|
||||
chkLsa->setExpirationTimePoint(lsa->getExpirationTimePoint());
|
||||
|
||||
@@ -278,8 +275,7 @@ Lsdb::installLsa(std::shared_ptr<Lsa> lsa)
|
||||
}
|
||||
|
||||
chkLsa->setExpiringEventId(scheduleLsaExpiration(chkLsa, timeToExpire));
|
||||
NLSR_LOG_DEBUG("Updated " << lsa->getType() << " LSA:");
|
||||
NLSR_LOG_DEBUG(chkLsa->toString());
|
||||
NLSR_LOG_DEBUG("Updated LSA:\n" << chkLsa->toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,8 +284,7 @@ Lsdb::removeLsa(const LsaContainer::index<Lsdb::byName>::type::iterator& lsaIt)
|
||||
{
|
||||
if (lsaIt != m_lsdb.end()) {
|
||||
auto lsaPtr = *lsaIt;
|
||||
NLSR_LOG_DEBUG("Removing " << lsaPtr->getType() << " LSA:");
|
||||
NLSR_LOG_DEBUG(lsaPtr->toString());
|
||||
NLSR_LOG_DEBUG("Removing LSA:\n" << lsaPtr->toString());
|
||||
m_lsdb.erase(lsaIt);
|
||||
onLsdbModified(lsaPtr, LsdbUpdate::REMOVED, {}, {});
|
||||
}
|
||||
@@ -385,13 +380,11 @@ Lsdb::expireOrRefreshLsa(std::shared_ptr<Lsa> lsa)
|
||||
if (lsaPtr->getSeqNo() == lsa->getSeqNo()) {
|
||||
if (lsaPtr->getOriginRouter() == m_thisRouterPrefix) {
|
||||
NLSR_LOG_DEBUG("Own " << lsaPtr->getType() << " LSA, so refreshing it");
|
||||
NLSR_LOG_DEBUG("Current LSA:");
|
||||
NLSR_LOG_DEBUG(lsaPtr->toString());
|
||||
NLSR_LOG_DEBUG("Current LSA:\n" << lsaPtr->toString());
|
||||
lsaPtr->setSeqNo(lsaPtr->getSeqNo() + 1);
|
||||
m_sequencingManager.setLsaSeq(lsaPtr->getSeqNo(), lsaPtr->getType());
|
||||
lsaPtr->setExpirationTimePoint(getLsaExpirationTimePoint());
|
||||
NLSR_LOG_DEBUG("Updated LSA:");
|
||||
NLSR_LOG_DEBUG(lsaPtr->toString());
|
||||
NLSR_LOG_DEBUG("Updated LSA:\n" << lsaPtr->toString());
|
||||
// schedule refreshing event again
|
||||
lsaPtr->setExpiringEventId(scheduleLsaExpiration(lsaPtr, m_lsaRefreshTime));
|
||||
m_sequencingManager.writeSeqNoToFile();
|
||||
@@ -438,13 +431,12 @@ Lsdb::expressInterest(const ndn::Name& interestName, uint32_t timeoutCount, uint
|
||||
if (incomingFaceId != 0) {
|
||||
interest.setTag(std::make_shared<ndn::lp::NextHopFaceIdTag>(incomingFaceId));
|
||||
}
|
||||
ndn::util::SegmentFetcher::Options options;
|
||||
ndn::SegmentFetcher::Options options;
|
||||
options.interestLifetime = m_confParam.getLsaInterestLifetime();
|
||||
options.maxTimeout = m_confParam.getLsaInterestLifetime();
|
||||
|
||||
NLSR_LOG_DEBUG("Fetching Data for LSA: " << interestName << " Seq number: " << seqNo);
|
||||
auto fetcher = ndn::util::SegmentFetcher::start(m_face, interest,
|
||||
m_confParam.getValidator(), options);
|
||||
auto fetcher = ndn::SegmentFetcher::start(m_face, interest, m_confParam.getValidator(), options);
|
||||
|
||||
auto it = m_fetchers.insert(fetcher).first;
|
||||
|
||||
@@ -491,13 +483,12 @@ Lsdb::onFetchLsaError(uint32_t errorCode, const std::string& msg, const ndn::Nam
|
||||
// immediately since at the least the LSA Interest lifetime has elapsed.
|
||||
// Otherwise, it is necessary to delay the Interest re-expression to prevent
|
||||
// the potential for constant Interest flooding.
|
||||
ndn::time::seconds delay = m_confParam.getLsaInterestLifetime();
|
||||
|
||||
if (errorCode == ndn::util::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT) {
|
||||
delay = ndn::time::seconds(0);
|
||||
auto delay = m_confParam.getLsaInterestLifetime();
|
||||
if (errorCode == ndn::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT) {
|
||||
delay = 0_s;
|
||||
}
|
||||
m_scheduler.schedule(delay, std::bind(&Lsdb::expressInterest, this,
|
||||
interestName, retransmitNo + 1, /*Multicast FaceID*/0, deadline));
|
||||
m_scheduler.schedule(delay, std::bind(&Lsdb::expressInterest, this, interestName,
|
||||
retransmitNo + 1, /*Multicast FaceID*/0, deadline));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -560,7 +551,7 @@ Lsdb::afterFetchLsa(const ndn::ConstBufferPtr& bufferPtr, const ndn::Name& inter
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
NLSR_LOG_TRACE("LSA data decoding error :( " << e.what());
|
||||
NLSR_LOG_TRACE("LSA data decoding error: " << e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -220,11 +220,11 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
\param seqNo The sequence number to check.
|
||||
*/
|
||||
bool
|
||||
isLsaNew(const ndn::Name& originRouter, const Lsa::Type& lsaType, uint64_t lsSeqNo) const
|
||||
isLsaNew(const ndn::Name& originRouter, const Lsa::Type& lsaType, uint64_t seqNo) const
|
||||
{
|
||||
// Is the name in the LSDB and the supplied seq no is the highest so far
|
||||
auto lsaPtr = findLsa(originRouter, lsaType);
|
||||
return lsaPtr ? lsaPtr->getSeqNo() < lsSeqNo : true;
|
||||
return lsaPtr ? lsaPtr->getSeqNo() < seqNo : true;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -321,10 +321,10 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
}
|
||||
|
||||
public:
|
||||
ndn::util::Signal<Lsdb, Statistics::PacketType> lsaIncrementSignal;
|
||||
ndn::util::Signal<Lsdb, ndn::Data> afterSegmentValidatedSignal;
|
||||
using AfterLsdbModified = ndn::util::Signal<Lsdb, std::shared_ptr<Lsa>, LsdbUpdate,
|
||||
std::list<ndn::Name>, std::list<ndn::Name>>;
|
||||
ndn::signal::Signal<Lsdb, Statistics::PacketType> lsaIncrementSignal;
|
||||
ndn::signal::Signal<Lsdb, ndn::Data> afterSegmentValidatedSignal;
|
||||
using AfterLsdbModified = ndn::signal::Signal<Lsdb, std::shared_ptr<Lsa>, LsdbUpdate,
|
||||
std::list<ndn::Name>, std::list<ndn::Name>>;
|
||||
AfterLsdbModified onLsdbModified;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
@@ -346,10 +346,10 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
|
||||
SequencingManager m_sequencingManager;
|
||||
|
||||
ndn::util::signal::ScopedConnection m_onNewLsaConnection;
|
||||
ndn::signal::ScopedConnection m_onNewLsaConnection;
|
||||
|
||||
std::set<std::shared_ptr<ndn::util::SegmentFetcher>> m_fetchers;
|
||||
ndn::util::Segmenter m_segmenter;
|
||||
std::set<std::shared_ptr<ndn::SegmentFetcher>> m_fetchers;
|
||||
ndn::Segmenter m_segmenter;
|
||||
ndn::InMemoryStorageFifo m_segmentFifo;
|
||||
|
||||
bool m_isBuildAdjLsaScheduled;
|
||||
|
||||
+2
-4
@@ -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-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -63,13 +63,11 @@ main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
boost::asio::io_service ioService;
|
||||
ndn::Face face(ioService);
|
||||
ndn::KeyChain keyChain;
|
||||
ndn::Face face(nullptr, keyChain);
|
||||
|
||||
nlsr::ConfParameter confParam(face, keyChain, configFileName);
|
||||
nlsr::ConfFileProcessor configProcessor(confParam);
|
||||
|
||||
if (!configProcessor.processConfFile()) {
|
||||
std::cerr << "Error in configuration file processing" << std::endl;
|
||||
return 2;
|
||||
|
||||
+28
-83
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -26,120 +26,65 @@ namespace nlsr {
|
||||
|
||||
NamePrefixList::NamePrefixList() = default;
|
||||
|
||||
NamePrefixList::NamePrefixList(ndn::span<const ndn::Name> names)
|
||||
NamePrefixList::NamePrefixList(std::initializer_list<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
|
||||
NamePrefixList::get(const ndn::Name& name)
|
||||
{
|
||||
return std::find_if(m_names.begin(), m_names.end(),
|
||||
[&] (const NamePrefixList::NamePair& pair) {
|
||||
return name == std::get<NamePrefixList::NamePairIndex::NAME>(pair);
|
||||
});
|
||||
}
|
||||
|
||||
std::vector<std::string>::iterator
|
||||
NamePrefixList::getSource(const std::string& source, std::vector<NamePair>::iterator& entry)
|
||||
{
|
||||
return std::find_if(std::get<NamePairIndex::SOURCES>(*entry).begin(),
|
||||
std::get<NamePairIndex::SOURCES>(*entry).end(),
|
||||
[&] (const std::string& containerSource) {
|
||||
return source == containerSource;
|
||||
});
|
||||
for (const auto& name : names) {
|
||||
insert(name);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
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.emplace_back(name, sources);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
auto& sources = std::get<NamePrefixList::NamePairIndex::SOURCES>(*pairItr);
|
||||
auto sourceItr = getSource(source, pairItr);
|
||||
if (sourceItr == sources.end()) {
|
||||
sources.push_back(source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
auto& sources = m_namesSources[name];
|
||||
return sources.insert(source).second;
|
||||
}
|
||||
|
||||
bool
|
||||
NamePrefixList::remove(const ndn::Name& name, const std::string& source)
|
||||
NamePrefixList::erase(const ndn::Name& name, const std::string& source)
|
||||
{
|
||||
auto pairItr = get(name);
|
||||
if (pairItr != m_names.end()) {
|
||||
auto& sources = std::get<NamePrefixList::NamePairIndex::SOURCES>(*pairItr);
|
||||
auto sourceItr = getSource(source, pairItr);
|
||||
if (sourceItr != sources.end()) {
|
||||
sources.erase(sourceItr);
|
||||
if (sources.empty()) {
|
||||
m_names.erase(pairItr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
auto it = m_namesSources.find(name);
|
||||
if (it == m_namesSources.end()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
NamePrefixList::operator==(const NamePrefixList& other) const
|
||||
{
|
||||
return m_names == other.m_names;
|
||||
}
|
||||
|
||||
void
|
||||
NamePrefixList::sort()
|
||||
{
|
||||
std::sort(m_names.begin(), m_names.end());
|
||||
bool isRemoved = it->second.erase(source);
|
||||
if (it->second.empty()) {
|
||||
m_namesSources.erase(it);
|
||||
}
|
||||
return isRemoved;
|
||||
}
|
||||
|
||||
std::list<ndn::Name>
|
||||
NamePrefixList::getNames() const
|
||||
{
|
||||
std::list<ndn::Name> names;
|
||||
for (const auto& namePair : m_names) {
|
||||
names.push_back(std::get<NamePrefixList::NamePairIndex::NAME>(namePair));
|
||||
for (const auto& [name, sources] : m_namesSources) {
|
||||
names.push_back(name);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
NamePrefixList::countSources(const ndn::Name& name) const
|
||||
{
|
||||
return getSources(name).size();
|
||||
}
|
||||
#ifdef WITH_TESTS
|
||||
|
||||
const std::vector<std::string>
|
||||
std::set<std::string>
|
||||
NamePrefixList::getSources(const ndn::Name& name) const
|
||||
{
|
||||
auto it = std::find_if(m_names.begin(), m_names.end(),
|
||||
[&] (const NamePrefixList::NamePair& pair) {
|
||||
return name == std::get<NamePrefixList::NamePairIndex::NAME>(pair);
|
||||
});
|
||||
if (it != m_names.end()) {
|
||||
return std::get<NamePrefixList::NamePairIndex::SOURCES>(*it);
|
||||
}
|
||||
else {
|
||||
return {};
|
||||
if (auto it = m_namesSources.find(name); it != m_namesSources.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NamePrefixList& list)
|
||||
{
|
||||
os << "Name prefix list: {\n";
|
||||
for (const auto& name : list.getNames()) {
|
||||
os << name << "\n"
|
||||
<< "Sources:\n";
|
||||
for (const auto& source : list.getSources(name)) {
|
||||
for (const auto& [name, sources] : list.m_namesSources) {
|
||||
os << name << "\nSources:\n";
|
||||
for (const auto& source : sources) {
|
||||
os << " " << source << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
+36
-68
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -24,113 +24,81 @@
|
||||
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
#include <ndn-cxx/name.hpp>
|
||||
|
||||
#include <boost/operators.hpp>
|
||||
|
||||
#include <initializer_list>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include <ndn-cxx/name.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class NamePrefixList
|
||||
class NamePrefixList : private boost::equality_comparable<NamePrefixList>
|
||||
{
|
||||
public:
|
||||
using NamePair = std::tuple<ndn::Name, std::vector<std::string>>;
|
||||
|
||||
enum NamePairIndex {
|
||||
NAME,
|
||||
SOURCES
|
||||
};
|
||||
|
||||
NamePrefixList();
|
||||
|
||||
explicit
|
||||
NamePrefixList(ndn::span<const ndn::Name> names);
|
||||
NamePrefixList(std::initializer_list<ndn::Name> names);
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
NamePrefixList(std::initializer_list<ndn::Name> names)
|
||||
: NamePrefixList(ndn::span<const ndn::Name>(names))
|
||||
{
|
||||
}
|
||||
|
||||
NamePrefixList(std::initializer_list<NamePair> namesAndSources)
|
||||
: m_names(namesAndSources)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! \brief inserts name into NamePrefixList
|
||||
\retval true If the name was successfully inserted.
|
||||
\retval false If the name could not be inserted.
|
||||
/*! \brief Inserts name and source combination.
|
||||
\retval true Name and source combination is inserted.
|
||||
\retval false Name and source combination already exists.
|
||||
*/
|
||||
bool
|
||||
insert(const ndn::Name& name, const std::string& source = "");
|
||||
|
||||
/*! \brief removes name from NamePrefixList
|
||||
\retval true If the name is removed
|
||||
\retval false If the name failed to be removed.
|
||||
/*! \brief Deletes name and source combination
|
||||
\retval true Name and source combination is deleted.
|
||||
\retval false Name and source combination does not exist.
|
||||
*/
|
||||
bool
|
||||
remove(const ndn::Name& name, const std::string& source = "");
|
||||
|
||||
void
|
||||
sort();
|
||||
erase(const ndn::Name& name, const std::string& source = "");
|
||||
|
||||
size_t
|
||||
size() const
|
||||
{
|
||||
return m_names.size();
|
||||
return m_namesSources.size();
|
||||
}
|
||||
|
||||
std::list<ndn::Name>
|
||||
getNames() const;
|
||||
|
||||
bool
|
||||
operator==(const NamePrefixList& other) const;
|
||||
|
||||
/*! Returns how many unique sources this name has.
|
||||
|
||||
\retval 0 if the name is not in the list, else the number of sources.
|
||||
*/
|
||||
uint32_t
|
||||
countSources(const ndn::Name& name) const;
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
/*! Returns the sources that this name has.
|
||||
|
||||
\retval an empty vector if the name is not in the list, else a
|
||||
vector containing the sources.
|
||||
If the name does not exist, returns an empty container.
|
||||
*/
|
||||
const std::vector<std::string>
|
||||
std::set<std::string>
|
||||
getSources(const ndn::Name& name) const;
|
||||
#endif
|
||||
|
||||
void
|
||||
clear()
|
||||
{
|
||||
m_names.clear();
|
||||
m_namesSources.clear();
|
||||
}
|
||||
|
||||
private: // non-member operators
|
||||
// NOTE: the following "hidden friend" operators are available via
|
||||
// argument-dependent lookup only and must be defined inline.
|
||||
// boost::equality_comparable provides != operators.
|
||||
|
||||
friend bool
|
||||
operator==(const NamePrefixList& lhs, const NamePrefixList& rhs)
|
||||
{
|
||||
return lhs.getNames() == rhs.getNames();
|
||||
}
|
||||
|
||||
private:
|
||||
/*! Obtain an iterator to the entry matching name.
|
||||
std::map<ndn::Name, std::set<std::string>> m_namesSources;
|
||||
|
||||
\note We could do this quite easily inline with a lambda, but this
|
||||
is slightly more efficient.
|
||||
*/
|
||||
std::vector<NamePair>::iterator
|
||||
get(const ndn::Name& name);
|
||||
|
||||
/*! Obtain an iterator to a specific source in an entry
|
||||
*/
|
||||
std::vector<std::string>::iterator
|
||||
getSource(const std::string& source, std::vector<NamePair>::iterator& entry);
|
||||
|
||||
std::vector<NamePair> m_names;
|
||||
friend std::ostream&
|
||||
operator<<(std::ostream& os, const NamePrefixList& list);
|
||||
};
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NamePrefixList& list);
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_NAME_PREFIX_LIST_HPP
|
||||
+10
-17
@@ -36,7 +36,7 @@ INIT_LOGGER(Nlsr);
|
||||
|
||||
Nlsr::Nlsr(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam)
|
||||
: m_face(face)
|
||||
, m_scheduler(face.getIoService())
|
||||
, m_scheduler(face.getIoContext())
|
||||
, m_confParam(confParam)
|
||||
, m_adjacencyList(confParam.getAdjacencyList())
|
||||
, m_namePrefixList(confParam.getNamePrefixList())
|
||||
@@ -259,7 +259,7 @@ void
|
||||
Nlsr::initializeFaces(const FetchDatasetCallback& onFetchSuccess,
|
||||
const FetchDatasetTimeoutCallback& onFetchFailure)
|
||||
{
|
||||
NLSR_LOG_TRACE("Initializing Faces...");
|
||||
NLSR_LOG_TRACE("Initializing faces");
|
||||
m_faceDatasetController.fetch<ndn::nfd::FaceDataset>(onFetchSuccess, onFetchFailure);
|
||||
}
|
||||
|
||||
@@ -317,14 +317,12 @@ Nlsr::onFaceDatasetFetchTimeout(uint32_t code,
|
||||
const std::string& msg,
|
||||
uint32_t nRetriesSoFar)
|
||||
{
|
||||
NLSR_LOG_DEBUG("onFaceDatasetFetchTimeout");
|
||||
// If we have exceeded the maximum attempt count, do not try again.
|
||||
if (nRetriesSoFar++ < m_confParam.getFaceDatasetFetchTries()) {
|
||||
NLSR_LOG_DEBUG("Failed to fetch dataset: " << msg << ". Attempting retry #" << nRetriesSoFar);
|
||||
m_faceDatasetController.fetch<ndn::nfd::FaceDataset>(std::bind(&Nlsr::processFaceDataset,
|
||||
this, _1),
|
||||
std::bind(&Nlsr::onFaceDatasetFetchTimeout,
|
||||
this, _1, _2, nRetriesSoFar));
|
||||
m_faceDatasetController.fetch<ndn::nfd::FaceDataset>(std::bind(&Nlsr::processFaceDataset, this, _1),
|
||||
std::bind(&Nlsr::onFaceDatasetFetchTimeout,
|
||||
this, _1, _2, nRetriesSoFar));
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_ERROR("Failed to fetch dataset: " << msg << ". Exceeded limit of " <<
|
||||
@@ -339,17 +337,12 @@ Nlsr::onFaceDatasetFetchTimeout(uint32_t code,
|
||||
void
|
||||
Nlsr::scheduleDatasetFetch()
|
||||
{
|
||||
NLSR_LOG_DEBUG("Scheduling Dataset Fetch in " << m_confParam.getFaceDatasetFetchInterval());
|
||||
NLSR_LOG_DEBUG("Scheduling dataset fetch in " << m_confParam.getFaceDatasetFetchInterval());
|
||||
|
||||
m_scheduler.schedule(m_confParam.getFaceDatasetFetchInterval(),
|
||||
[this] {
|
||||
this->initializeFaces(
|
||||
[this] (const std::vector<ndn::nfd::FaceStatus>& faces) {
|
||||
this->processFaceDataset(faces);
|
||||
},
|
||||
[this] (uint32_t code, const std::string& msg) {
|
||||
this->onFaceDatasetFetchTimeout(code, msg, 0);
|
||||
});
|
||||
m_scheduler.schedule(m_confParam.getFaceDatasetFetchInterval(), [this] {
|
||||
initializeFaces(
|
||||
[this] (const auto& faces) { processFaceDataset(faces); },
|
||||
[this] (uint32_t code, const std::string& msg) { onFaceDatasetFetchTimeout(code, msg, 0); });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -176,9 +176,9 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
HelloProtocol m_helloProtocol;
|
||||
|
||||
private:
|
||||
ndn::util::signal::ScopedConnection m_onNewLsaConnection;
|
||||
ndn::util::signal::ScopedConnection m_onPrefixRegistrationSuccess;
|
||||
ndn::util::signal::ScopedConnection m_onInitialHelloDataValidated;
|
||||
ndn::signal::ScopedConnection m_onNewLsaConnection;
|
||||
ndn::signal::ScopedConnection m_onPrefixRegistrationSuccess;
|
||||
ndn::signal::ScopedConnection m_onInitialHelloDataValidated;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
ndn::mgmt::Dispatcher m_dispatcher;
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -242,10 +242,10 @@ Fib::onRegistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
}
|
||||
|
||||
void
|
||||
Fib::unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri)
|
||||
Fib::unregisterPrefix(const ndn::Name& namePrefix, const ndn::FaceUri& faceUri)
|
||||
{
|
||||
uint64_t faceId = 0;
|
||||
auto adjacent = m_adjacencyList.findAdjacent(ndn::FaceUri(faceUri));
|
||||
auto adjacent = m_adjacencyList.findAdjacent(faceUri);
|
||||
if (adjacent != m_adjacencyList.end()) {
|
||||
faceId = adjacent->getFaceId();
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -165,7 +165,7 @@ private:
|
||||
*
|
||||
*/
|
||||
void
|
||||
unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri);
|
||||
unregisterPrefix(const ndn::Name& namePrefix, const ndn::FaceUri& faceUri);
|
||||
|
||||
/*! \brief Log registration success, and update the Face ID associated with a URI.
|
||||
*/
|
||||
@@ -222,7 +222,7 @@ public:
|
||||
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;
|
||||
ndn::signal::Signal<Fib, ndn::Name> onPrefixRegistrationSuccess;
|
||||
|
||||
private:
|
||||
ndn::Scheduler& m_scheduler;
|
||||
|
||||
@@ -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-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -141,8 +141,8 @@ private:
|
||||
const ndn::Name& m_ownRouterName;
|
||||
Fib& m_fib;
|
||||
RoutingTable& m_routingTable;
|
||||
ndn::util::signal::Connection m_afterRoutingChangeConnection;
|
||||
ndn::util::signal::Connection m_afterLsdbModified;
|
||||
ndn::signal::Connection m_afterRoutingChangeConnection;
|
||||
ndn::signal::Connection m_afterLsdbModified;
|
||||
};
|
||||
|
||||
inline NamePrefixTable::const_iterator
|
||||
|
||||
+14
-39
@@ -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-2023, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -31,42 +31,16 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
struct NextHopComparator {
|
||||
struct NextHopUriSortedComparator
|
||||
{
|
||||
bool
|
||||
operator() (const NextHop& nh1, const NextHop& nh2) const {
|
||||
if (nh1.getRouteCostAsAdjustedInteger() < nh2.getRouteCostAsAdjustedInteger()) {
|
||||
return true;
|
||||
}
|
||||
else if (nh1.getRouteCostAsAdjustedInteger() == nh2.getRouteCostAsAdjustedInteger()) {
|
||||
return nh1.getConnectingFaceUri() < nh2.getConnectingFaceUri();
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
operator()(const NextHop& lhs, const NextHop& rhs) const
|
||||
{
|
||||
return lhs.getConnectingFaceUri() < rhs.getConnectingFaceUri();
|
||||
}
|
||||
};
|
||||
|
||||
struct NextHopUriSortedComparator {
|
||||
bool
|
||||
operator() (const NextHop& nh1, const NextHop& nh2) const {
|
||||
return nh1.getConnectingFaceUri() < nh2.getConnectingFaceUri();
|
||||
}
|
||||
};
|
||||
|
||||
static inline bool
|
||||
nexthopAddCompare(const NextHop& nh1, const NextHop& nh2)
|
||||
{
|
||||
return nh1.getConnectingFaceUri() == nh2.getConnectingFaceUri();
|
||||
}
|
||||
|
||||
static inline bool
|
||||
nexthopRemoveCompare(const NextHop& nh1, const NextHop& nh2)
|
||||
{
|
||||
return (nh1.getConnectingFaceUri() == nh2.getConnectingFaceUri() &&
|
||||
nh1.getRouteCostAsAdjustedInteger() == nh2.getRouteCostAsAdjustedInteger()) ;
|
||||
}
|
||||
|
||||
template<typename T = NextHopComparator>
|
||||
template<typename T = std::less<NextHop>>
|
||||
class NexthopListT
|
||||
{
|
||||
public:
|
||||
@@ -76,19 +50,21 @@ public:
|
||||
\param nh The next hop.
|
||||
|
||||
Adds a next hop to this object. If the next hop is new it is
|
||||
added. If the next hop already exists in the list then that next
|
||||
hop's route cost is updated.
|
||||
added. If the next hop already exists but has a higher cost then
|
||||
its route cost is updated.
|
||||
*/
|
||||
void
|
||||
addNextHop(const NextHop& nh)
|
||||
{
|
||||
auto it = std::find_if(m_nexthopList.begin(), m_nexthopList.end(),
|
||||
std::bind(&nexthopAddCompare, _1, nh));
|
||||
[&nh] (const auto& item) {
|
||||
return item.getConnectingFaceUri() == nh.getConnectingFaceUri();
|
||||
});
|
||||
if (it == m_nexthopList.end()) {
|
||||
m_nexthopList.insert(nh);
|
||||
}
|
||||
else if (it->getRouteCost() > nh.getRouteCost()) {
|
||||
removeNextHop(*it);
|
||||
m_nexthopList.erase(it);
|
||||
m_nexthopList.insert(nh);
|
||||
}
|
||||
}
|
||||
@@ -101,8 +77,7 @@ public:
|
||||
void
|
||||
removeNextHop(const NextHop& nh)
|
||||
{
|
||||
auto it = std::find_if(m_nexthopList.begin(), m_nexthopList.end(),
|
||||
std::bind(&nexthopRemoveCompare, _1, nh));
|
||||
auto it = std::find(m_nexthopList.begin(), m_nexthopList.end(), nh);
|
||||
if (it != m_nexthopList.end()) {
|
||||
m_nexthopList.erase(it);
|
||||
}
|
||||
|
||||
+9
-11
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -32,7 +32,7 @@ NextHop::wireEncode(ndn::EncodingImpl<TAG>& block) const
|
||||
size_t totalLength = 0;
|
||||
|
||||
totalLength += ndn::encoding::prependDoubleBlock(block, nlsr::tlv::CostDouble, m_routeCost);
|
||||
totalLength += ndn::encoding::prependStringBlock(block, nlsr::tlv::Uri, m_connectingFaceUri);
|
||||
totalLength += ndn::encoding::prependStringBlock(block, nlsr::tlv::Uri, m_connectingFaceUri.toString());
|
||||
|
||||
totalLength += block.prependVarNumber(totalLength);
|
||||
totalLength += block.prependVarNumber(nlsr::tlv::NextHop);
|
||||
@@ -63,7 +63,7 @@ NextHop::wireEncode() const
|
||||
void
|
||||
NextHop::wireDecode(const ndn::Block& wire)
|
||||
{
|
||||
m_connectingFaceUri = "";
|
||||
m_connectingFaceUri = {};
|
||||
m_routeCost = 0;
|
||||
|
||||
m_wire = wire;
|
||||
@@ -77,7 +77,12 @@ NextHop::wireDecode(const ndn::Block& wire)
|
||||
auto val = m_wire.elements_begin();
|
||||
|
||||
if (val != m_wire.elements_end() && val->type() == nlsr::tlv::Uri) {
|
||||
m_connectingFaceUri = ndn::encoding::readString(*val);
|
||||
try {
|
||||
m_connectingFaceUri = ndn::FaceUri(ndn::encoding::readString(*val));
|
||||
}
|
||||
catch (const ndn::FaceUri::Error& e) {
|
||||
NDN_THROW_NESTED(Error("Invalid Uri"));
|
||||
}
|
||||
++val;
|
||||
}
|
||||
else {
|
||||
@@ -93,13 +98,6 @@ NextHop::wireDecode(const ndn::Block& wire)
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
operator==(const NextHop& lhs, const NextHop& rhs)
|
||||
{
|
||||
return (lhs.getRouteCostAsAdjustedInteger() == rhs.getRouteCostAsAdjustedInteger()) &&
|
||||
(lhs.getConnectingFaceUri() == rhs.getConnectingFaceUri());
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NextHop& hop)
|
||||
{
|
||||
|
||||
+32
-18
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -26,6 +26,9 @@
|
||||
#include <ndn-cxx/encoding/block.hpp>
|
||||
#include <ndn-cxx/encoding/encoding-buffer.hpp>
|
||||
#include <ndn-cxx/encoding/tlv.hpp>
|
||||
#include <ndn-cxx/net/face-uri.hpp>
|
||||
|
||||
#include <boost/operators.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <ostream>
|
||||
@@ -40,38 +43,33 @@ namespace nlsr {
|
||||
*
|
||||
* \sa https://redmine.named-data.net/projects/nlsr/wiki/Routing_Table_Dataset
|
||||
*/
|
||||
class NextHop
|
||||
class NextHop : private boost::totally_ordered<NextHop>
|
||||
{
|
||||
public:
|
||||
using Error = ndn::tlv::Error;
|
||||
|
||||
NextHop()
|
||||
: m_connectingFaceUri()
|
||||
, m_routeCost(0)
|
||||
, m_isHyperbolic(false)
|
||||
{
|
||||
}
|
||||
NextHop() = default;
|
||||
|
||||
NextHop(const std::string& cfu, double rc)
|
||||
NextHop(const ndn::FaceUri& cfu, double rc)
|
||||
: m_connectingFaceUri(cfu)
|
||||
, m_routeCost(rc)
|
||||
, m_isHyperbolic(false)
|
||||
{
|
||||
}
|
||||
|
||||
explicit
|
||||
NextHop(const ndn::Block& block)
|
||||
{
|
||||
wireDecode(block);
|
||||
}
|
||||
|
||||
const std::string&
|
||||
const ndn::FaceUri&
|
||||
getConnectingFaceUri() const
|
||||
{
|
||||
return m_connectingFaceUri;
|
||||
}
|
||||
|
||||
void
|
||||
setConnectingFaceUri(const std::string& cfu)
|
||||
setConnectingFaceUri(const ndn::FaceUri& cfu)
|
||||
{
|
||||
m_connectingFaceUri = cfu;
|
||||
}
|
||||
@@ -124,10 +122,29 @@ public:
|
||||
void
|
||||
wireDecode(const ndn::Block& wire);
|
||||
|
||||
private: // non-member operators
|
||||
// NOTE: the following "hidden friend" operators are available via
|
||||
// argument-dependent lookup only and must be defined inline.
|
||||
// boost::totally_ordered provides !=, <=, >=, and > operators.
|
||||
|
||||
friend bool
|
||||
operator==(const NextHop& lhs, const NextHop& rhs)
|
||||
{
|
||||
return lhs.getRouteCostAsAdjustedInteger() == rhs.getRouteCostAsAdjustedInteger() &&
|
||||
lhs.getConnectingFaceUri() == rhs.getConnectingFaceUri();
|
||||
}
|
||||
|
||||
friend bool
|
||||
operator<(const NextHop& lhs, const NextHop& rhs)
|
||||
{
|
||||
return std::forward_as_tuple(lhs.getRouteCostAsAdjustedInteger(), lhs.getConnectingFaceUri()) <
|
||||
std::forward_as_tuple(rhs.getRouteCostAsAdjustedInteger(), rhs.getConnectingFaceUri());
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_connectingFaceUri;
|
||||
double m_routeCost;
|
||||
bool m_isHyperbolic;
|
||||
ndn::FaceUri m_connectingFaceUri;
|
||||
double m_routeCost = 0.0;
|
||||
bool m_isHyperbolic = false;
|
||||
|
||||
mutable ndn::Block m_wire;
|
||||
|
||||
@@ -147,9 +164,6 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
|
||||
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(NextHop);
|
||||
|
||||
bool
|
||||
operator==(const NextHop& lhs, const NextHop& rhs);
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NextHop& hop);
|
||||
|
||||
|
||||
@@ -348,8 +348,7 @@ LinkStateRoutingTableCalculator::addAllLsNextHopsToRoutingTable(AdjacencyList& a
|
||||
// Fetch its actual name
|
||||
auto nextHopRouterName = pMap.getRouterNameByMappingNo(nextHopRouter);
|
||||
if (nextHopRouterName) {
|
||||
std::string nextHopFace =
|
||||
adjacencies.getAdjacent(*nextHopRouterName).getFaceUri().toString();
|
||||
auto nextHopFace = adjacencies.getAdjacent(*nextHopRouterName).getFaceUri();
|
||||
// Add next hop to routing table
|
||||
NextHop nh(nextHopFace, routeCost);
|
||||
rt.addNextHop(*(pMap.getRouterNameByMappingNo(i)), nh);
|
||||
@@ -436,7 +435,7 @@ HyperbolicRoutingCalculator::calculatePath(Map& map, RoutingTable& rt,
|
||||
|
||||
// Iterate over directly connected neighbors
|
||||
std::list<Adjacent> neighbors = adjacencies.getAdjList();
|
||||
for (std::list<Adjacent>::iterator adj = neighbors.begin(); adj != neighbors.end(); ++adj) {
|
||||
for (auto adj = neighbors.begin(); adj != neighbors.end(); ++adj) {
|
||||
|
||||
// Don't calculate nexthops using an inactive router
|
||||
if (adj->getStatus() == Adjacent::STATUS_INACTIVE) {
|
||||
@@ -451,10 +450,8 @@ HyperbolicRoutingCalculator::calculatePath(Map& map, RoutingTable& rt,
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string srcFaceUri = adj->getFaceUri().toString();
|
||||
|
||||
// Install nexthops for this router to the neighbor; direct neighbors have a 0 cost link
|
||||
addNextHop(srcRouterName, srcFaceUri, 0, rt);
|
||||
addNextHop(srcRouterName, adj->getFaceUri(), 0, rt);
|
||||
|
||||
auto src = map.getMappingNoByRouterName(srcRouterName);
|
||||
if (!src) {
|
||||
@@ -477,7 +474,7 @@ HyperbolicRoutingCalculator::calculatePath(Map& map, RoutingTable& rt,
|
||||
<< " to " << *destRouterName);
|
||||
continue;
|
||||
}
|
||||
addNextHop(*destRouterName, srcFaceUri, distance, rt);
|
||||
addNextHop(*destRouterName, adj->getFaceUri(), distance, rt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -618,7 +615,7 @@ HyperbolicRoutingCalculator::calculateHyperbolicDistance(double rI, double rJ,
|
||||
}
|
||||
|
||||
void
|
||||
HyperbolicRoutingCalculator::addNextHop(ndn::Name dest, std::string faceUri,
|
||||
HyperbolicRoutingCalculator::addNextHop(const ndn::Name& dest, const ndn::FaceUri& faceUri,
|
||||
double cost, RoutingTable& rt)
|
||||
{
|
||||
NextHop hop(faceUri, cost);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -214,7 +214,7 @@ private:
|
||||
getHyperbolicDistance(Lsdb& lsdb, ndn::Name src, ndn::Name dest);
|
||||
|
||||
void
|
||||
addNextHop(ndn::Name destinationRouter, std::string faceUri, double cost, RoutingTable& rt);
|
||||
addNextHop(const ndn::Name& destinationRouter, const ndn::FaceUri& faceUri, double cost, RoutingTable& rt);
|
||||
|
||||
double
|
||||
calculateHyperbolicDistance(double rI, double rJ, double deltaTheta);
|
||||
|
||||
@@ -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-2023, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -155,7 +155,7 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
bool m_isRouteCalculationScheduled;
|
||||
|
||||
ConfParameter& m_confParam;
|
||||
ndn::util::signal::Connection m_afterLsdbModified;
|
||||
ndn::signal::Connection m_afterLsdbModified;
|
||||
int32_t m_hyperbolicState;
|
||||
bool m_ownAdjLsaExist = false;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -104,7 +104,7 @@ private:
|
||||
ndn::Face& m_face;
|
||||
ConfParameter& m_confParam;
|
||||
ndn::security::ValidatorConfig& m_validator;
|
||||
ndn::util::signal::ScopedConnection m_afterSegmentValidatedConnection;
|
||||
ndn::signal::ScopedConnection m_afterSegmentValidatedConnection;
|
||||
};
|
||||
|
||||
} // namespace security
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -32,8 +32,8 @@ class RoutingTable;
|
||||
class RoutingTableEntry;
|
||||
class SyncLogicHandler;
|
||||
|
||||
using AfterRoutingChange = ndn::util::Signal<RoutingTable, std::list<RoutingTableEntry>>;
|
||||
using OnNewLsa = ndn::util::Signal<SyncLogicHandler, ndn::Name, uint64_t, ndn::Name, uint64_t>;
|
||||
using AfterRoutingChange = ndn::signal::Signal<RoutingTable, std::list<RoutingTableEntry>>;
|
||||
using OnNewLsa = ndn::signal::Signal<SyncLogicHandler, ndn::Name, uint64_t, ndn::Name, uint64_t>;
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -28,8 +28,9 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
// brief: a class designed to handle statistical signals in nlsr
|
||||
|
||||
/**
|
||||
* \brief a class designed to handle statistical signals in nlsr
|
||||
*/
|
||||
class StatsCollector
|
||||
{
|
||||
public:
|
||||
@@ -63,8 +64,8 @@ private:
|
||||
HelloProtocol& m_hp;
|
||||
Statistics m_stats;
|
||||
|
||||
ndn::util::signal::ScopedConnection m_lsaIncrementConn;
|
||||
ndn::util::signal::ScopedConnection m_helloIncrementConn;
|
||||
ndn::signal::ScopedConnection m_lsaIncrementConn;
|
||||
ndn::signal::ScopedConnection m_helloIncrementConn;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -102,7 +102,7 @@ CommandManagerBase::withdrawAndRemovePrefix(const ndn::Name& prefix,
|
||||
static_cast<const ndn::nfd::ControlParameters&>(parameters);
|
||||
|
||||
// Only build a Name LSA if the added name is new
|
||||
if (m_namePrefixList.remove(castParams.getName())) {
|
||||
if (m_namePrefixList.erase(castParams.getName())) {
|
||||
NLSR_LOG_INFO("Withdrawing/Removing name: " << castParams.getName() << "\n");
|
||||
m_lsdb.buildAndInstallOwnNameLsa();
|
||||
if (castParams.hasFlags() && castParams.getFlags() == PREFIX_FLAG) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -30,8 +30,6 @@
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using std::shared_ptr;
|
||||
|
||||
class SyncLogicFixture : public IoKeyChainFixture
|
||||
{
|
||||
public:
|
||||
@@ -58,7 +56,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face{m_io, m_keyChain};
|
||||
ndn::DummyClientFace face{m_io, m_keyChain};
|
||||
ConfParameter conf{face, m_keyChain};
|
||||
DummyConfFileProcessor confProcessor{conf, SyncProtocol::PSYNC};
|
||||
SyncLogicHandler::IsLsaNew testIsLsaNew;
|
||||
@@ -84,7 +82,7 @@ BOOST_AUTO_TEST_CASE(UpdateForOtherLS)
|
||||
for (auto lsaType : {Lsa::Type::NAME, Lsa::Type::ADJACENCY}) {
|
||||
std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);
|
||||
|
||||
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
|
||||
ndn::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
|
||||
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
|
||||
BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
|
||||
BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
|
||||
@@ -111,7 +109,7 @@ BOOST_AUTO_TEST_CASE(UpdateForOtherHR)
|
||||
for (auto lsaType : {Lsa::Type::NAME, Lsa::Type::COORDINATE}) {
|
||||
std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);
|
||||
|
||||
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
|
||||
ndn::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
|
||||
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
|
||||
BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
|
||||
BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
|
||||
@@ -138,7 +136,7 @@ BOOST_AUTO_TEST_CASE(UpdateForOtherHRDry)
|
||||
for (auto lsaType : this->lsaTypes) {
|
||||
std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);
|
||||
|
||||
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
|
||||
ndn::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
|
||||
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
|
||||
BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
|
||||
BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
|
||||
@@ -167,7 +165,7 @@ BOOST_AUTO_TEST_CASE(NoUpdateForSelf)
|
||||
.append(this->conf.getRouterName())
|
||||
.append(boost::lexical_cast<std::string>(lsaType));
|
||||
|
||||
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
|
||||
ndn::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
|
||||
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
|
||||
BOOST_FAIL("Updates for self should not be emitted!");
|
||||
});
|
||||
@@ -191,7 +189,7 @@ BOOST_AUTO_TEST_CASE(MalformedUpdate)
|
||||
ndn::Name updateName{this->conf.getSiteName()};
|
||||
updateName.append(this->conf.getRouterName()).append(boost::lexical_cast<std::string>(lsaType));
|
||||
|
||||
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
|
||||
ndn::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
|
||||
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
|
||||
BOOST_FAIL("Malformed updates should not be emitted!");
|
||||
});
|
||||
@@ -216,7 +214,7 @@ BOOST_AUTO_TEST_CASE(LsaNotNew)
|
||||
|
||||
const uint64_t sequenceNumber = 1;
|
||||
SyncLogicHandler sync{this->face, this->m_keyChain, testLsaAlwaysFalse, this->conf};
|
||||
ndn::util::signal::ScopedConnection connection = sync.onNewLsa.connect(
|
||||
ndn::signal::ScopedConnection connection = sync.onNewLsa.connect(
|
||||
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
|
||||
BOOST_FAIL("An update for an LSA with non-new sequence number should not emit!");
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -29,7 +29,7 @@
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using namespace ndn;
|
||||
using ndn::Name;
|
||||
|
||||
class SyncProtocolAdapterFixture : public IoKeyChainFixture
|
||||
{
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
SyncProtocolAdapterFixture()
|
||||
: syncPrefix("/localhop/ndn/nlsr/sync")
|
||||
, nameLsaUserPrefix("/localhop/ndn/nlsr/LSA/NAME")
|
||||
, syncInterestLifetime(time::seconds(60))
|
||||
, syncInterestLifetime(60_s)
|
||||
{
|
||||
syncPrefix.appendVersion(4);
|
||||
}
|
||||
@@ -46,29 +46,28 @@ public:
|
||||
addNodes()
|
||||
{
|
||||
for (int i = 0; i < 2; i++) {
|
||||
faces[i] = std::make_shared<util::DummyClientFace>(m_io,
|
||||
util::DummyClientFace::Options{true, true});
|
||||
faces[i] = std::make_shared<ndn::DummyClientFace>(m_io, ndn::DummyClientFace::Options{true, true});
|
||||
userPrefixes[i] = Name(nameLsaUserPrefix).appendNumber(i);
|
||||
nodes[i] = std::make_shared<SyncProtocolAdapter>(*faces[i], m_keyChain, SyncProtocol::PSYNC,
|
||||
syncPrefix, userPrefixes[i],
|
||||
syncInterestLifetime,
|
||||
[i, this] (const ndn::Name& updateName,
|
||||
uint64_t highSeq, uint64_t incomingFaceId) {
|
||||
prefixToSeq[i].emplace(updateName, highSeq);
|
||||
});
|
||||
nodes[i] = std::make_shared<SyncProtocolAdapter>(
|
||||
*faces[i], m_keyChain, SyncProtocol::PSYNC, syncPrefix, userPrefixes[i],
|
||||
syncInterestLifetime,
|
||||
[i, this] (const Name& updateName, uint64_t highSeq, uint64_t incomingFaceId) {
|
||||
prefixToSeq[i].emplace(updateName, highSeq);
|
||||
});
|
||||
}
|
||||
|
||||
faces[0]->linkTo(*faces[1]);
|
||||
advanceClocks(ndn::time::milliseconds(10), 10);
|
||||
advanceClocks(10_ms, 10);
|
||||
}
|
||||
|
||||
public:
|
||||
Name syncPrefix, nameLsaUserPrefix;
|
||||
Name syncPrefix;
|
||||
Name nameLsaUserPrefix;
|
||||
Name userPrefixes[2];
|
||||
time::milliseconds syncInterestLifetime;
|
||||
std::shared_ptr<ndn::util::DummyClientFace> faces[2];
|
||||
ndn::time::milliseconds syncInterestLifetime;
|
||||
std::shared_ptr<ndn::DummyClientFace> faces[2];
|
||||
std::shared_ptr<SyncProtocolAdapter> nodes[2];
|
||||
std::map<ndn::Name, uint64_t> prefixToSeq[2];
|
||||
std::map<Name, uint64_t> prefixToSeq[2];
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(TestSyncProtocolAdapter)
|
||||
@@ -78,7 +77,7 @@ BOOST_FIXTURE_TEST_CASE(Basic, SyncProtocolAdapterFixture)
|
||||
addNodes();
|
||||
|
||||
nodes[0]->publishUpdate(userPrefixes[0], 10);
|
||||
advanceClocks(ndn::time::milliseconds(1000), 100);
|
||||
advanceClocks(1_s, 100);
|
||||
|
||||
auto it = prefixToSeq[1].find(userPrefixes[0]);
|
||||
BOOST_CHECK(it != prefixToSeq[1].end());
|
||||
@@ -86,7 +85,7 @@ BOOST_FIXTURE_TEST_CASE(Basic, SyncProtocolAdapterFixture)
|
||||
BOOST_CHECK_EQUAL(it->second, 10);
|
||||
|
||||
nodes[1]->publishUpdate(userPrefixes[1], 100);
|
||||
advanceClocks(ndn::time::milliseconds(1000), 100);
|
||||
advanceClocks(1_s, 100);
|
||||
|
||||
it = prefixToSeq[0].find(userPrefixes[1]);
|
||||
BOOST_CHECK(it != prefixToSeq[0].end());
|
||||
@@ -95,9 +94,9 @@ BOOST_FIXTURE_TEST_CASE(Basic, SyncProtocolAdapterFixture)
|
||||
|
||||
Name adjLsaUserPrefix("/localhop/ndn/nlsr/LSA/ADJACENCY");
|
||||
nodes[0]->addUserNode(adjLsaUserPrefix);
|
||||
advanceClocks(ndn::time::milliseconds(1000), 100);
|
||||
advanceClocks(1_s, 100);
|
||||
nodes[0]->publishUpdate(adjLsaUserPrefix, 10);
|
||||
advanceClocks(ndn::time::milliseconds(1000), 100);
|
||||
advanceClocks(1_s, 100);
|
||||
|
||||
it = prefixToSeq[1].find(adjLsaUserPrefix);
|
||||
BOOST_CHECK(it != prefixToSeq[1].end());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include "tests/clock-fixture.hpp"
|
||||
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
|
||||
namespace nlsr::test {
|
||||
|
||||
@@ -39,17 +39,13 @@ private:
|
||||
afterTick() final
|
||||
{
|
||||
if (m_io.stopped()) {
|
||||
#if BOOST_VERSION >= 106600
|
||||
m_io.restart();
|
||||
#else
|
||||
m_io.reset();
|
||||
#endif
|
||||
}
|
||||
m_io.poll();
|
||||
}
|
||||
|
||||
protected:
|
||||
boost::asio::io_service m_io;
|
||||
boost::asio::io_context m_io;
|
||||
};
|
||||
|
||||
} // namespace nlsr::test
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
*
|
||||
* NLSR is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Foundation,
|
||||
* either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* 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 "lsa/adj-lsa.hpp"
|
||||
|
||||
#include "tests/boost-test.hpp"
|
||||
|
||||
namespace nlsr::test {
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(TestAdjLsa)
|
||||
|
||||
const uint8_t ADJ_LSA1[] = {
|
||||
0x83, 0x58, 0x80, 0x2D, 0x07, 0x13, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04, 0x73, 0x69,
|
||||
0x74, 0x65, 0x08, 0x06, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x82, 0x01, 0x0C, 0x8B, 0x13,
|
||||
0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36, 0x20, 0x30, 0x34, 0x3A, 0x31,
|
||||
0x33, 0x3A, 0x33, 0x34, 0x84, 0x27, 0x07, 0x16, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04,
|
||||
0x73, 0x69, 0x74, 0x65, 0x08, 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79,
|
||||
0x8D, 0x03, 0x3A, 0x2F, 0x2F, 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const uint8_t ADJ_LSA_EXTRA_NEIGHBOR[] = {
|
||||
0x83, 0x80, 0x80, 0x2D, 0x07, 0x13, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04, 0x73, 0x69,
|
||||
0x74, 0x65, 0x08, 0x06, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x82, 0x01, 0x0C, 0x8B, 0x13,
|
||||
0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36, 0x20, 0x30, 0x34, 0x3A, 0x31,
|
||||
0x33, 0x3A, 0x33, 0x34, 0x84, 0x27, 0x07, 0x16, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04,
|
||||
0x73, 0x69, 0x74, 0x65, 0x08, 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79,
|
||||
0x8D, 0x03, 0x3A, 0x2F, 0x2F, 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x84, 0x26, 0x07, 0x15, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x03, 0x65, 0x64, 0x75, 0x08,
|
||||
0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79, 0x8D, 0x03, 0x3A, 0x2F, 0x2F,
|
||||
0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const uint8_t ADJ_LSA_DIFF_SEQ[] = {
|
||||
0x83, 0x80, 0x80, 0x2D, 0x07, 0x13, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04, 0x73, 0x69,
|
||||
0x74, 0x65, 0x08, 0x06, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x82, 0x01, 0x0E, 0x8B, 0x13,
|
||||
0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36, 0x20, 0x30, 0x34, 0x3A, 0x31,
|
||||
0x33, 0x3A, 0x33, 0x34, 0x84, 0x27, 0x07, 0x16, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04,
|
||||
0x73, 0x69, 0x74, 0x65, 0x08, 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79,
|
||||
0x8D, 0x03, 0x3A, 0x2F, 0x2F, 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x84, 0x26, 0x07, 0x15, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x03, 0x65, 0x64, 0x75, 0x08,
|
||||
0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79, 0x8D, 0x03, 0x3A, 0x2F, 0x2F,
|
||||
0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
const uint8_t ADJ_LSA_DIFF_TS[] = {
|
||||
0x83, 0x80, 0x80, 0x2D, 0x07, 0x13, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04, 0x73, 0x69,
|
||||
0x74, 0x65, 0x08, 0x06, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x82, 0x01, 0x0E, 0x8B, 0x13,
|
||||
0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36, 0x20, 0x30, 0x34, 0x3A, 0x31,
|
||||
0x33, 0x3A, 0x34, 0x34, 0x84, 0x27, 0x07, 0x16, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04,
|
||||
0x73, 0x69, 0x74, 0x65, 0x08, 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79,
|
||||
0x8D, 0x03, 0x3A, 0x2F, 0x2F, 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x84, 0x26, 0x07, 0x15, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x03, 0x65, 0x64, 0x75, 0x08,
|
||||
0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79, 0x8D, 0x03, 0x3A, 0x2F, 0x2F,
|
||||
0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Basic)
|
||||
{
|
||||
ndn::Name routerName("/ndn/site/router");
|
||||
ndn::Name adjacencyName("/ndn/site/adjacency");
|
||||
auto testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
|
||||
uint32_t seqNo = 12;
|
||||
|
||||
// An AdjLsa initialized with ACTIVE adjacencies should copy the adjacencies
|
||||
AdjacencyList activeAdjacencies;
|
||||
Adjacent activeAdjacency(adjacencyName);
|
||||
activeAdjacency.setStatus(Adjacent::STATUS_ACTIVE);
|
||||
activeAdjacencies.insert(activeAdjacency);
|
||||
|
||||
AdjLsa alsa1(routerName, seqNo, testTimePoint,
|
||||
activeAdjacencies.size(), activeAdjacencies);
|
||||
BOOST_CHECK_EQUAL(alsa1.getAdl().size(), 1);
|
||||
BOOST_CHECK_EQUAL(alsa1.getType(), Lsa::Type::ADJACENCY);
|
||||
BOOST_CHECK_EQUAL(alsa1.getSeqNo(), seqNo);
|
||||
BOOST_CHECK_EQUAL(alsa1.getExpirationTimePoint(), testTimePoint);
|
||||
BOOST_CHECK_EQUAL(alsa1.getNoLink(), 1);
|
||||
BOOST_CHECK(alsa1.getAdl().isNeighbor(activeAdjacency.getName()));
|
||||
|
||||
// An AdjLsa initialized with INACTIVE adjacencies should not copy the adjacencies
|
||||
AdjacencyList inactiveAdjacencies;
|
||||
Adjacent inactiveAdjacency(adjacencyName);
|
||||
inactiveAdjacency.setStatus(Adjacent::STATUS_INACTIVE);
|
||||
inactiveAdjacencies.insert(inactiveAdjacency);
|
||||
|
||||
AdjLsa alsa2(routerName, seqNo, testTimePoint,
|
||||
inactiveAdjacencies.size(), inactiveAdjacencies);
|
||||
BOOST_CHECK_EQUAL(alsa2.getAdl().size(), 0);
|
||||
|
||||
// Thus, the two LSAs should not have equal content
|
||||
BOOST_CHECK_EQUAL(alsa1.isEqualContent(alsa2), false);
|
||||
|
||||
// Create a duplicate of alsa1 which should have equal content
|
||||
AdjLsa alsa3(routerName, seqNo, testTimePoint,
|
||||
activeAdjacencies.size(), activeAdjacencies);
|
||||
BOOST_CHECK(alsa1.isEqualContent(alsa3));
|
||||
|
||||
auto wire = alsa1.wireEncode();
|
||||
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_TEST(wire == ADJ_LSA_EXTRA_NEIGHBOR, boost::test_tools::per_element());
|
||||
|
||||
alsa1.setSeqNo(14);
|
||||
wire = alsa1.wireEncode();
|
||||
BOOST_TEST(wire == ADJ_LSA_DIFF_SEQ, boost::test_tools::per_element());
|
||||
|
||||
testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196024993));
|
||||
alsa1.setExpirationTimePoint(testTimePoint);
|
||||
wire = alsa1.wireEncode();
|
||||
BOOST_TEST(wire == ADJ_LSA_DIFF_TS, boost::test_tools::per_element());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(IncrementAdjacentNumber)
|
||||
{
|
||||
Adjacent adj1("adjacent1");
|
||||
Adjacent adj2("adjacent2");
|
||||
|
||||
adj1.setStatus(Adjacent::STATUS_ACTIVE);
|
||||
adj2.setStatus(Adjacent::STATUS_ACTIVE);
|
||||
|
||||
AdjacencyList adjList;
|
||||
adjList.insert(adj1);
|
||||
adjList.insert(adj2);
|
||||
|
||||
auto testTimePoint = ndn::time::system_clock::now() + ndn::time::seconds(3600);
|
||||
|
||||
AdjLsa lsa("router1", 12, testTimePoint, adjList.size(), adjList);
|
||||
|
||||
std::ostringstream os;
|
||||
os << lsa;
|
||||
|
||||
std::string EXPECTED_OUTPUT =
|
||||
" ADJACENCY LSA:\n"
|
||||
" Origin Router : /router1\n"
|
||||
" Sequence Number : 12\n"
|
||||
" Expires in : 3599999 milliseconds\n"
|
||||
" Adjacent(s):\n"
|
||||
" Adjacent 0: (name=/adjacent1, uri=://, cost=10)\n"
|
||||
" Adjacent 1: (name=/adjacent2, uri=://, cost=10)\n";
|
||||
|
||||
BOOST_CHECK_EQUAL(os.str(), EXPECTED_OUTPUT);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(InitializeFromContent)
|
||||
{
|
||||
Adjacent adj1("adjacent1");
|
||||
Adjacent adj2("adjacent2");
|
||||
|
||||
adj1.setStatus(Adjacent::STATUS_ACTIVE);
|
||||
adj2.setStatus(Adjacent::STATUS_ACTIVE);
|
||||
|
||||
//If we don't do this the test will fail
|
||||
//Adjacent has default cost of 10 but no default
|
||||
//connecting face URI, so initializeFromContent fails
|
||||
adj1.setFaceUri(ndn::FaceUri("udp://10.0.0.1"));
|
||||
adj2.setFaceUri(ndn::FaceUri("udp://10.0.0.2"));
|
||||
|
||||
AdjacencyList adjList;
|
||||
adjList.insert(adj1);
|
||||
adjList.insert(adj2);
|
||||
|
||||
auto testTimePoint = ndn::time::system_clock::now();
|
||||
|
||||
AdjLsa adjlsa1("router1", 1, testTimePoint, adjList.size(), adjList);
|
||||
AdjLsa adjlsa2(adjlsa1.wireEncode());
|
||||
BOOST_CHECK(adjlsa1.isEqualContent(adjlsa2));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
} // namespace nlsr::test
|
||||
@@ -0,0 +1,137 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
*
|
||||
* NLSR is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Foundation,
|
||||
* either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* 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 "lsa/coordinate-lsa.hpp"
|
||||
|
||||
#include "tests/boost-test.hpp"
|
||||
|
||||
namespace nlsr::test {
|
||||
|
||||
/*
|
||||
static void
|
||||
printBytes(ndn::span<const uint8_t> buf)
|
||||
{
|
||||
std::string hex = ndn::toHex(buf);
|
||||
|
||||
for (size_t i = 0; i < hex.size(); i++) {
|
||||
if (i > 0 && i % 30 == 0)
|
||||
std::cout << "\n ";
|
||||
|
||||
std::cout << "0x" << hex[i];
|
||||
std::cout << hex[++i];
|
||||
|
||||
if ((i + 1) != hex.size())
|
||||
std::cout << ", ";
|
||||
}
|
||||
std::cout << "\n" << "};" << std::endl;
|
||||
}
|
||||
|
||||
printBytes(block);
|
||||
*/
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(TestCoordinateLsa)
|
||||
|
||||
const uint8_t COORDINATE_LSA1[] = {
|
||||
0x85, 0x43, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x87, 0x08, 0x40, 0x04, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x88, 0x08, 0x40, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88,
|
||||
0x08, 0x40, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const uint8_t COORDINATE_LSA_DIFF_ANGLE[] = {
|
||||
0x85, 0x39, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x87, 0x08, 0x40, 0x04, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x88, 0x08, 0x40, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const uint8_t COORDINATE_LSA_DIFF_RADIUS[] = {
|
||||
0x85, 0x39, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x87, 0x08, 0x40, 0x02, 0x66, 0x66,
|
||||
0x66, 0x66, 0x66, 0x66, 0x88, 0x08, 0x40, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const uint8_t COORDINATE_LSA_DIFF_SEQ[] = {
|
||||
0x85, 0x39, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0E, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x87, 0x08, 0x40, 0x02, 0x66, 0x66,
|
||||
0x66, 0x66, 0x66, 0x66, 0x88, 0x08, 0x40, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const uint8_t COORDINATE_LSA_DIFF_TS[] = {
|
||||
0x85, 0x39, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0E, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x34, 0x34, 0x87, 0x08, 0x40, 0x02, 0x66, 0x66,
|
||||
0x66, 0x66, 0x66, 0x66, 0x88, 0x08, 0x40, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Basic)
|
||||
{
|
||||
auto testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
|
||||
std::vector<double> angles1{30.0}, angles2{30.0};
|
||||
angles1.push_back(30.0);
|
||||
angles2.push_back(30.0);
|
||||
CoordinateLsa clsa1("router1", 12, testTimePoint, 2.5, angles1);
|
||||
CoordinateLsa clsa2("router1", 12, testTimePoint, 2.5, angles2);
|
||||
|
||||
BOOST_CHECK_CLOSE(clsa1.getCorRadius(), 2.5, 0.0001);
|
||||
BOOST_CHECK(clsa1.getCorTheta() == angles1);
|
||||
|
||||
BOOST_CHECK(clsa1.isEqualContent(clsa2));
|
||||
|
||||
BOOST_CHECK_EQUAL(clsa1.wireEncode(), clsa2.wireEncode());
|
||||
|
||||
auto wire = clsa1.wireEncode();
|
||||
BOOST_TEST(wire == COORDINATE_LSA1, boost::test_tools::per_element());
|
||||
|
||||
std::vector<double> angles3{40.0};
|
||||
clsa1.setCorTheta(angles3);
|
||||
wire = clsa1.wireEncode();
|
||||
BOOST_TEST(wire == COORDINATE_LSA_DIFF_ANGLE, boost::test_tools::per_element());
|
||||
|
||||
clsa1.setCorRadius(2.3);
|
||||
wire = clsa1.wireEncode();
|
||||
BOOST_TEST(wire == COORDINATE_LSA_DIFF_RADIUS, boost::test_tools::per_element());
|
||||
|
||||
clsa1.setSeqNo(14);
|
||||
wire = clsa1.wireEncode();
|
||||
BOOST_TEST(wire == COORDINATE_LSA_DIFF_SEQ, boost::test_tools::per_element());
|
||||
|
||||
testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196024993));
|
||||
clsa1.setExpirationTimePoint(testTimePoint);
|
||||
wire = clsa1.wireEncode();
|
||||
BOOST_TEST(wire == COORDINATE_LSA_DIFF_TS, boost::test_tools::per_element());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(InitializeFromContent)
|
||||
{
|
||||
auto testTimePoint = ndn::time::system_clock::now();
|
||||
std::vector<double> angles = {30, 40.0};
|
||||
CoordinateLsa clsa1("router1", 12, testTimePoint, 2.5, angles);
|
||||
CoordinateLsa clsa2(clsa1.wireEncode());
|
||||
BOOST_CHECK_EQUAL(clsa1.wireEncode(), clsa2.wireEncode());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
} // namespace nlsr::test
|
||||
@@ -0,0 +1,163 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
*
|
||||
* NLSR is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Foundation,
|
||||
* either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* 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 "lsa/name-lsa.hpp"
|
||||
|
||||
#include "tests/boost-test.hpp"
|
||||
|
||||
namespace nlsr::test {
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(TestNameLsa)
|
||||
|
||||
const uint8_t NAME_LSA1[] = {
|
||||
0x89, 0x37, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61,
|
||||
0x6D, 0x65, 0x31, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x32
|
||||
};
|
||||
|
||||
const uint8_t NAME_LSA_EXTRA_NAME[] = {
|
||||
0x89, 0x40, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61,
|
||||
0x6D, 0x65, 0x31, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x32, 0x07, 0x07, 0x08,
|
||||
0x05, 0x6E, 0x61, 0x6D, 0x65, 0x33
|
||||
};
|
||||
|
||||
const uint8_t NAME_LSA_DIFF_SEQ[] = {
|
||||
0x89, 0x40, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0E, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61,
|
||||
0x6D, 0x65, 0x31, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x32, 0x07, 0x07, 0x08,
|
||||
0x05, 0x6E, 0x61, 0x6D, 0x65, 0x33
|
||||
};
|
||||
|
||||
const uint8_t NAME_LSA_DIFF_TS[] = {
|
||||
0x89, 0x40, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0E, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x34, 0x34, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61,
|
||||
0x6D, 0x65, 0x31, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x32, 0x07, 0x07, 0x08,
|
||||
0x05, 0x6E, 0x61, 0x6D, 0x65, 0x33
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Basic)
|
||||
{
|
||||
ndn::Name s1{"name1"};
|
||||
ndn::Name s2{"name2"};
|
||||
NamePrefixList npl1{s1, s2};
|
||||
|
||||
auto testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
|
||||
|
||||
// 3rd argument is seqNo
|
||||
NameLsa nlsa1("router1", 12, testTimePoint, npl1);
|
||||
NameLsa nlsa2("router2", 12, testTimePoint, npl1);
|
||||
|
||||
BOOST_CHECK_EQUAL(nlsa1.getType(), Lsa::Type::NAME);
|
||||
BOOST_CHECK(nlsa1.getExpirationTimePoint() == nlsa2.getExpirationTimePoint());
|
||||
|
||||
auto wire = nlsa1.wireEncode();
|
||||
BOOST_TEST(wire == NAME_LSA1, boost::test_tools::per_element());
|
||||
|
||||
nlsa1.addName("name3");
|
||||
wire = nlsa1.wireEncode();
|
||||
BOOST_TEST(wire == NAME_LSA_EXTRA_NAME, boost::test_tools::per_element());
|
||||
|
||||
nlsa1.setSeqNo(14);
|
||||
wire = nlsa1.wireEncode();
|
||||
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_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
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(InitializeFromContent)
|
||||
{
|
||||
auto testTimePoint = ndn::time::system_clock::now();
|
||||
ndn::Name s1{"name1"};
|
||||
ndn::Name s2{"name2"};
|
||||
NamePrefixList npl1{s1, s2};
|
||||
|
||||
NameLsa nlsa1("router1", 1, testTimePoint, npl1);
|
||||
NameLsa nlsa2(nlsa1.wireEncode());
|
||||
BOOST_CHECK_EQUAL(nlsa1.wireEncode(), nlsa2.wireEncode());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(OperatorEquals)
|
||||
{
|
||||
ndn::Name name1("/ndn/test/name1");
|
||||
ndn::Name name2("/ndn/test/name2");
|
||||
ndn::Name name3("/ndn/some/other/name1");
|
||||
|
||||
NameLsa lsa1;
|
||||
lsa1.addName(name1);
|
||||
lsa1.addName(name2);
|
||||
lsa1.addName(name3);
|
||||
|
||||
NameLsa lsa2;
|
||||
lsa2.addName(name1);
|
||||
lsa2.addName(name2);
|
||||
BOOST_CHECK_NE(lsa1, lsa2);
|
||||
|
||||
lsa2.addName(name3);
|
||||
BOOST_CHECK_EQUAL(lsa1, lsa2);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Update)
|
||||
{
|
||||
NameLsa knownNameLsa;
|
||||
knownNameLsa.m_originRouter = ndn::Name("/yoursunny/_/%C1.Router/dal");
|
||||
knownNameLsa.m_seqNo = 2683;
|
||||
knownNameLsa.setExpirationTimePoint(ndn::time::system_clock::now() + 3561_ms);
|
||||
knownNameLsa.addName("/yoursunny/_/dal");
|
||||
knownNameLsa.addName("/ndn");
|
||||
|
||||
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");
|
||||
ndn::Name addedName1("/yoursunny/video/ndn-dpdk_acmicn20_20200917");
|
||||
ndn::Name addedName2("/yoursunny/pushups");
|
||||
nlsa->addName(addedName1);
|
||||
nlsa->addName(addedName2);
|
||||
|
||||
auto [updated, namesToAdd, namesToRemove] = knownNameLsa.update(rcvdLsa);
|
||||
|
||||
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);
|
||||
BOOST_CHECK(it != namesToAdd.end());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
} // namespace nlsr::test
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
NextHop
|
||||
createNextHop(const std::string& faceUri, double cost)
|
||||
{
|
||||
return {faceUri, cost};
|
||||
return {ndn::FaceUri(faceUri), cost};
|
||||
}
|
||||
|
||||
CoordinateLsa
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face;
|
||||
ndn::DummyClientFace face;
|
||||
ConfParameter conf;
|
||||
DummyConfFileProcessor confProcessor;
|
||||
Nlsr nlsr;
|
||||
|
||||
+21
-35
@@ -31,6 +31,16 @@
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
static const ndn::Name router1Name = "/ndn/router1";
|
||||
static const ndn::Name router2Name = "/ndn/router2";
|
||||
static const ndn::Name router3Name = "/ndn/router3";
|
||||
static const ndn::FaceUri router1FaceUri("udp4://10.0.0.1:6363");
|
||||
static const ndn::FaceUri router2FaceUri("udp4://10.0.0.2:6363");
|
||||
static const ndn::FaceUri router3FaceUri("udp4://10.0.0.3:6363");
|
||||
constexpr uint32_t router1FaceId = 1;
|
||||
constexpr uint32_t router2FaceId = 2;
|
||||
constexpr uint32_t router3FaceId = 3;
|
||||
|
||||
class FibFixture : public IoKeyChainFixture
|
||||
{
|
||||
public:
|
||||
@@ -41,13 +51,13 @@ public:
|
||||
{
|
||||
advanceClocks(1_s);
|
||||
|
||||
Adjacent neighbor1(router1Name, ndn::FaceUri(router1FaceUri), 0, Adjacent::STATUS_ACTIVE, 0, router1FaceId);
|
||||
Adjacent neighbor1(router1Name, router1FaceUri, 0, Adjacent::STATUS_ACTIVE, 0, router1FaceId);
|
||||
adjacencies.insert(neighbor1);
|
||||
|
||||
Adjacent neighbor2(router2Name, ndn::FaceUri(router2FaceUri), 0, Adjacent::STATUS_ACTIVE, 0, router2FaceId);
|
||||
Adjacent neighbor2(router2Name, router2FaceUri, 0, Adjacent::STATUS_ACTIVE, 0, router2FaceId);
|
||||
adjacencies.insert(neighbor2);
|
||||
|
||||
Adjacent neighbor3(router3Name, ndn::FaceUri(router3FaceUri), 0, Adjacent::STATUS_ACTIVE, 0, router3FaceId);
|
||||
Adjacent neighbor3(router3Name, router3FaceUri, 0, Adjacent::STATUS_ACTIVE, 0, router3FaceId);
|
||||
adjacencies.insert(neighbor3);
|
||||
|
||||
conf.setMaxFacesPerPrefix(2);
|
||||
@@ -71,8 +81,8 @@ private:
|
||||
ndn::Scheduler m_scheduler{m_io};
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face{m_io, m_keyChain, [] {
|
||||
ndn::util::DummyClientFace::Options opts;
|
||||
ndn::DummyClientFace face{m_io, m_keyChain, [] {
|
||||
ndn::DummyClientFace::Options opts;
|
||||
opts.enableRegistrationReply = true;
|
||||
opts.registrationReplyFaceId = 128;
|
||||
return opts;
|
||||
@@ -81,32 +91,8 @@ public:
|
||||
AdjacencyList& adjacencies;
|
||||
Fib fib;
|
||||
std::vector<ndn::Interest>& interests;
|
||||
|
||||
static const ndn::Name router1Name;
|
||||
static const ndn::Name router2Name;
|
||||
static const ndn::Name router3Name;
|
||||
|
||||
static const std::string router1FaceUri;
|
||||
static const std::string router2FaceUri;
|
||||
static const std::string router3FaceUri;
|
||||
|
||||
static const uint32_t router1FaceId;
|
||||
static const uint32_t router2FaceId;
|
||||
static const uint32_t router3FaceId;
|
||||
};
|
||||
|
||||
const ndn::Name FibFixture::router1Name = "/ndn/router1";
|
||||
const ndn::Name FibFixture::router2Name = "/ndn/router2";
|
||||
const ndn::Name FibFixture::router3Name = "/ndn/router3";
|
||||
|
||||
const std::string FibFixture::router1FaceUri = "udp4://10.0.0.1";
|
||||
const std::string FibFixture::router2FaceUri = "udp4://10.0.0.2";
|
||||
const std::string FibFixture::router3FaceUri = "udp4://10.0.0.3";
|
||||
|
||||
const uint32_t FibFixture::router1FaceId = 1;
|
||||
const uint32_t FibFixture::router2FaceId = 2;
|
||||
const uint32_t FibFixture::router3FaceId = 3;
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(TestFib, FibFixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(NextHopsAdd)
|
||||
@@ -367,16 +353,16 @@ BOOST_AUTO_TEST_CASE(PrefixWithdrawalFibUpdateBug) // #5179
|
||||
|
||||
// Wustl advertises /test
|
||||
NexthopList nhl1;
|
||||
nhl1.addNextHop(NextHop("udp4://10.0.0.13:6363", 28));
|
||||
nhl1.addNextHop(NextHop("udp4://10.0.0.9:6363", 38));
|
||||
nhl1.addNextHop(NextHop("udp4://10.0.0.26:6363", 44));
|
||||
nhl1.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.13:6363"), 28));
|
||||
nhl1.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.9:6363"), 38));
|
||||
nhl1.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.26:6363"), 44));
|
||||
fib.update("/test", nhl1);
|
||||
|
||||
// Memphis advertises /test
|
||||
NexthopList nhl2;
|
||||
nhl2.addNextHop(NextHop("udp4://10.0.0.9:6363", 21));
|
||||
nhl2.addNextHop(NextHop("udp4://10.0.0.13:6363", 26));
|
||||
nhl2.addNextHop(NextHop("udp4://10.0.0.26:6363", 42));
|
||||
nhl2.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.9:6363"), 21));
|
||||
nhl2.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.13:6363"), 26));
|
||||
nhl2.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.26:6363"), 42));
|
||||
fib.update("/test", nhl2);
|
||||
|
||||
advanceClocks(10_ms);
|
||||
|
||||
@@ -33,9 +33,15 @@
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using std::shared_ptr;
|
||||
using ndn::time::system_clock;
|
||||
|
||||
static const ndn::Name ROUTER_A_NAME = "/ndn/router/a";
|
||||
static const ndn::Name ROUTER_B_NAME = "/ndn/router/b";
|
||||
static const ndn::Name ROUTER_C_NAME = "/ndn/router/c";
|
||||
static const ndn::FaceUri ROUTER_A_FACE("udp4://10.0.0.1:6363");
|
||||
static const ndn::FaceUri ROUTER_B_FACE("udp4://10.0.0.2:6363");
|
||||
static const ndn::FaceUri ROUTER_C_FACE("udp4://10.0.0.3:6363");
|
||||
|
||||
constexpr system_clock::time_point MAX_TIME = system_clock::time_point::max();
|
||||
|
||||
class HyperbolicCalculatorFixture : public IoKeyChainFixture
|
||||
@@ -112,8 +118,8 @@ public:
|
||||
NexthopList& bHopList = entryB->getNexthopList();
|
||||
BOOST_REQUIRE_EQUAL(bHopList.getNextHops().size(), 2);
|
||||
|
||||
for (std::set<NextHop, NextHopComparator>::iterator it = bHopList.begin(); it != bHopList.end(); ++it) {
|
||||
std::string faceUri = it->getConnectingFaceUri();
|
||||
for (auto it = bHopList.begin(); it != bHopList.end(); ++it) {
|
||||
auto faceUri = it->getConnectingFaceUri();
|
||||
uint64_t cost = it->getRouteCostAsAdjustedInteger();
|
||||
|
||||
BOOST_CHECK((faceUri == ROUTER_B_FACE && cost == 0) ||
|
||||
@@ -126,8 +132,8 @@ public:
|
||||
NexthopList& cHopList = entryC->getNexthopList();
|
||||
BOOST_REQUIRE_EQUAL(cHopList.getNextHops().size(), 2);
|
||||
|
||||
for (std::set<NextHop, NextHopComparator>::iterator it = cHopList.begin(); it != cHopList.end(); ++it) {
|
||||
std::string faceUri = it->getConnectingFaceUri();
|
||||
for (auto it = cHopList.begin(); it != cHopList.end(); ++it) {
|
||||
auto faceUri = it->getConnectingFaceUri();
|
||||
uint64_t cost = it->getRouteCostAsAdjustedInteger();
|
||||
|
||||
BOOST_CHECK((faceUri == ROUTER_B_FACE && cost == applyHyperbolicFactorAndRound(expectedCost)) ||
|
||||
@@ -145,7 +151,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face;
|
||||
ndn::DummyClientFace face;
|
||||
ConfParameter conf;
|
||||
Nlsr nlsr;
|
||||
Map map;
|
||||
@@ -153,24 +159,8 @@ public:
|
||||
RoutingTable& routingTable;
|
||||
AdjacencyList& adjacencies;
|
||||
Lsdb& lsdb;
|
||||
|
||||
static const ndn::Name ROUTER_A_NAME;
|
||||
static const ndn::Name ROUTER_B_NAME;
|
||||
static const ndn::Name ROUTER_C_NAME;
|
||||
|
||||
static const std::string ROUTER_A_FACE;
|
||||
static const std::string ROUTER_B_FACE;
|
||||
static const std::string ROUTER_C_FACE;
|
||||
};
|
||||
|
||||
const ndn::Name HyperbolicCalculatorFixture::ROUTER_A_NAME = "/ndn/router/a";
|
||||
const ndn::Name HyperbolicCalculatorFixture::ROUTER_B_NAME = "/ndn/router/b";
|
||||
const ndn::Name HyperbolicCalculatorFixture::ROUTER_C_NAME = "/ndn/router/c";
|
||||
|
||||
const std::string HyperbolicCalculatorFixture::ROUTER_A_FACE = "udp4://10.0.0.1";
|
||||
const std::string HyperbolicCalculatorFixture::ROUTER_B_FACE = "udp4://10.0.0.2";
|
||||
const std::string HyperbolicCalculatorFixture::ROUTER_C_FACE = "udp4://10.0.0.3";
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(TestHyperbolicRoutingCalculator, HyperbolicCalculatorFixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Basic)
|
||||
|
||||
@@ -35,6 +35,15 @@ namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
constexpr ndn::time::system_clock::time_point MAX_TIME = ndn::time::system_clock::time_point::max();
|
||||
static const ndn::Name ROUTER_A_NAME = "/ndn/site/%C1.Router/this-router";
|
||||
static const ndn::Name ROUTER_B_NAME = "/ndn/site/%C1.Router/b";
|
||||
static const ndn::Name ROUTER_C_NAME = "/ndn/site/%C1.Router/c";
|
||||
static const ndn::FaceUri ROUTER_A_FACE("udp4://10.0.0.1");
|
||||
static const ndn::FaceUri ROUTER_B_FACE("udp4://10.0.0.2");
|
||||
static const ndn::FaceUri ROUTER_C_FACE("udp4://10.0.0.3");
|
||||
constexpr double LINK_AB_COST = 5;
|
||||
constexpr double LINK_AC_COST = 10;
|
||||
constexpr double LINK_BC_COST = 17;
|
||||
|
||||
class LinkStateCalculatorFixture : public IoKeyChainFixture
|
||||
{
|
||||
@@ -53,9 +62,9 @@ public:
|
||||
// Triangle topology with routers A, B, C connected
|
||||
void setUpTopology()
|
||||
{
|
||||
Adjacent a(ROUTER_A_NAME, ndn::FaceUri(ROUTER_A_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
|
||||
Adjacent b(ROUTER_B_NAME, ndn::FaceUri(ROUTER_B_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
|
||||
Adjacent c(ROUTER_C_NAME, ndn::FaceUri(ROUTER_C_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
|
||||
Adjacent a(ROUTER_A_NAME, ROUTER_A_FACE, 0, Adjacent::STATUS_ACTIVE, 0, 0);
|
||||
Adjacent b(ROUTER_B_NAME, ROUTER_B_FACE, 0, Adjacent::STATUS_ACTIVE, 0, 0);
|
||||
Adjacent c(ROUTER_C_NAME, ROUTER_C_FACE, 0, Adjacent::STATUS_ACTIVE, 0, 0);
|
||||
|
||||
// Router A
|
||||
b.setLinkCost(LINK_AB_COST);
|
||||
@@ -95,7 +104,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face;
|
||||
ndn::DummyClientFace face;
|
||||
ConfParameter conf;
|
||||
DummyConfFileProcessor confProcessor;
|
||||
Nlsr nlsr;
|
||||
@@ -103,32 +112,8 @@ public:
|
||||
|
||||
RoutingTable& routingTable;
|
||||
Lsdb& lsdb;
|
||||
|
||||
static const ndn::Name ROUTER_A_NAME;
|
||||
static const ndn::Name ROUTER_B_NAME;
|
||||
static const ndn::Name ROUTER_C_NAME;
|
||||
|
||||
static const std::string ROUTER_A_FACE;
|
||||
static const std::string ROUTER_B_FACE;
|
||||
static const std::string ROUTER_C_FACE;
|
||||
|
||||
static const double LINK_AB_COST;
|
||||
static const double LINK_AC_COST;
|
||||
static const double LINK_BC_COST;
|
||||
};
|
||||
|
||||
const ndn::Name LinkStateCalculatorFixture::ROUTER_A_NAME = "/ndn/site/%C1.Router/this-router";
|
||||
const ndn::Name LinkStateCalculatorFixture::ROUTER_B_NAME = "/ndn/site/%C1.Router/b";
|
||||
const ndn::Name LinkStateCalculatorFixture::ROUTER_C_NAME = "/ndn/site/%C1.Router/c";
|
||||
|
||||
const std::string LinkStateCalculatorFixture::ROUTER_A_FACE = "udp4://10.0.0.1";
|
||||
const std::string LinkStateCalculatorFixture::ROUTER_B_FACE = "udp4://10.0.0.2";
|
||||
const std::string LinkStateCalculatorFixture::ROUTER_C_FACE = "udp4://10.0.0.3";
|
||||
|
||||
const double LinkStateCalculatorFixture::LINK_AB_COST = 5;
|
||||
const double LinkStateCalculatorFixture::LINK_AC_COST = 10;
|
||||
const double LinkStateCalculatorFixture::LINK_BC_COST = 17;
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(TestLinkStateRoutingCalculator, LinkStateCalculatorFixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Basic)
|
||||
@@ -144,7 +129,7 @@ BOOST_AUTO_TEST_CASE(Basic)
|
||||
BOOST_REQUIRE_EQUAL(bHopList.getNextHops().size(), 2);
|
||||
|
||||
for (const NextHop& hop : bHopList) {
|
||||
std::string faceUri = hop.getConnectingFaceUri();
|
||||
auto faceUri = hop.getConnectingFaceUri();
|
||||
uint64_t cost = hop.getRouteCostAsAdjustedInteger();
|
||||
|
||||
BOOST_CHECK((faceUri == ROUTER_B_FACE && cost == LINK_AB_COST) ||
|
||||
@@ -160,7 +145,7 @@ BOOST_AUTO_TEST_CASE(Basic)
|
||||
BOOST_REQUIRE_EQUAL(cHopList.getNextHops().size(), 2);
|
||||
|
||||
for (const NextHop& hop : cHopList) {
|
||||
std::string faceUri = hop.getConnectingFaceUri();
|
||||
auto faceUri = hop.getConnectingFaceUri();
|
||||
uint64_t cost = hop.getRouteCostAsAdjustedInteger();
|
||||
|
||||
BOOST_CHECK((faceUri == ROUTER_C_FACE && cost == LINK_AC_COST) ||
|
||||
@@ -192,7 +177,7 @@ BOOST_AUTO_TEST_CASE(Asymmetric)
|
||||
BOOST_REQUIRE_EQUAL(bHopList.getNextHops().size(), 2);
|
||||
|
||||
for (const NextHop& hop : bHopList) {
|
||||
std::string faceUri = hop.getConnectingFaceUri();
|
||||
auto faceUri = hop.getConnectingFaceUri();
|
||||
uint64_t cost = hop.getRouteCostAsAdjustedInteger();
|
||||
|
||||
BOOST_CHECK((faceUri == ROUTER_B_FACE && cost == LINK_AB_COST) ||
|
||||
@@ -208,7 +193,7 @@ BOOST_AUTO_TEST_CASE(Asymmetric)
|
||||
BOOST_REQUIRE_EQUAL(cHopList.getNextHops().size(), 2);
|
||||
|
||||
for (const NextHop& hop : cHopList) {
|
||||
std::string faceUri = hop.getConnectingFaceUri();
|
||||
auto faceUri = hop.getConnectingFaceUri();
|
||||
uint64_t cost = hop.getRouteCostAsAdjustedInteger();
|
||||
|
||||
BOOST_CHECK((faceUri == ROUTER_C_FACE && cost == LINK_AC_COST) ||
|
||||
|
||||
@@ -53,7 +53,7 @@ private:
|
||||
ndn::Scheduler m_scheduler{m_io};
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face{m_io, m_keyChain};
|
||||
ndn::DummyClientFace face{m_io, m_keyChain};
|
||||
ConfParameter conf{face, m_keyChain};
|
||||
DummyConfFileProcessor confProcessor{conf};
|
||||
|
||||
@@ -274,9 +274,9 @@ BOOST_FIXTURE_TEST_CASE(RemoveNptEntryPtrFromRoutingEntry, NamePrefixTableFixtur
|
||||
BOOST_FIXTURE_TEST_CASE(RoutingTableUpdate, NamePrefixTableFixture)
|
||||
{
|
||||
const ndn::Name destination = ndn::Name{"/ndn/destination1"};
|
||||
NextHop hop1{"upd4://10.0.0.1", 0};
|
||||
NextHop hop2{"udp4://10.0.0.2", 1};
|
||||
NextHop hop3{"udp4://10.0.0.3", 2};
|
||||
NextHop hop1{ndn::FaceUri("upd4://10.0.0.1"), 0};
|
||||
NextHop hop2{ndn::FaceUri("upd4://10.0.0.2"), 1};
|
||||
NextHop hop3{ndn::FaceUri("upd4://10.0.0.3"), 2};
|
||||
const NamePrefixTableEntry entry1{"/ndn/router1"};
|
||||
npt.addEntry(entry1.getNamePrefix(), destination);
|
||||
|
||||
|
||||
@@ -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-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -86,14 +86,14 @@ BOOST_AUTO_TEST_CASE(HyperbolicRemoveNextHop)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TieBreaker)
|
||||
{
|
||||
// equal-cost hops are sorted lexicographically
|
||||
// equal-cost hops are sorted consistently
|
||||
NextHop hopA;
|
||||
hopA.setRouteCost(25);
|
||||
hopA.setConnectingFaceUri("AAAZZ");
|
||||
hopA.setConnectingFaceUri(ndn::FaceUri("udp4://192.168.3.1:6363"));
|
||||
|
||||
NextHop hopZ;
|
||||
hopZ.setRouteCost(25);
|
||||
hopZ.setConnectingFaceUri("ZZA");
|
||||
hopZ.setConnectingFaceUri(ndn::FaceUri("udp4://192.168.3.9:6363"));
|
||||
|
||||
NexthopList list;
|
||||
list.addNextHop(hopA);
|
||||
@@ -108,32 +108,15 @@ BOOST_AUTO_TEST_CASE(TieBreaker)
|
||||
|
||||
it = list.begin();
|
||||
BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), hopA.getConnectingFaceUri());
|
||||
|
||||
|
||||
// equal-cost and lexicographically equal hops are sorted by the length of their face uris
|
||||
NextHop longUriHop;
|
||||
longUriHop.setRouteCost(25);
|
||||
longUriHop.setConnectingFaceUri("AAAAAA");
|
||||
|
||||
NextHop shortUriHop;
|
||||
shortUriHop.setRouteCost(25);
|
||||
shortUriHop.setConnectingFaceUri("AAA");
|
||||
|
||||
list.clear();
|
||||
list.addNextHop(longUriHop);
|
||||
list.addNextHop(shortUriHop);
|
||||
|
||||
it = list.begin();
|
||||
BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), shortUriHop.getConnectingFaceUri());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SortOnAddAndRemove)
|
||||
{
|
||||
NexthopList list;
|
||||
|
||||
NextHop hopA("A", 10);
|
||||
NextHop hopB("B", 5);
|
||||
NextHop hopC("C", 25);
|
||||
NextHop hopA(ndn::FaceUri("udp4://192.168.3.1:6363"), 10);
|
||||
NextHop hopB(ndn::FaceUri("udp4://192.168.3.2:6363"), 5);
|
||||
NextHop hopC(ndn::FaceUri("udp4://192.168.3.3:6363"), 25);
|
||||
|
||||
list.addNextHop(hopA);
|
||||
list.addNextHop(hopB);
|
||||
@@ -168,8 +151,8 @@ BOOST_AUTO_TEST_CASE(UseCheaperNextHop)
|
||||
{
|
||||
NexthopList list;
|
||||
|
||||
NextHop hopA("udp4://10.0.0.1:6363", 10);
|
||||
NextHop hopB("udp4://10.0.0.1:6363", 5);
|
||||
NextHop hopA(ndn::FaceUri("udp4://10.0.0.1:6363"), 10);
|
||||
NextHop hopB(ndn::FaceUri("udp4://10.0.0.1:6363"), 5);
|
||||
|
||||
list.addNextHop(hopA);
|
||||
list.addNextHop(hopB);
|
||||
@@ -191,33 +174,32 @@ BOOST_AUTO_TEST_CASE(NextHopListDiffForFibUpdate) // #5179
|
||||
// If default sorter is used then difference results in
|
||||
// the same hops to remove as those that were added
|
||||
NexthopList nhl1;
|
||||
nhl1.addNextHop(NextHop("udp4://10.0.0.13:6363", 28));
|
||||
nhl1.addNextHop(NextHop("udp4://10.0.0.9:6363", 38));
|
||||
nhl1.addNextHop(NextHop("udp4://10.0.0.26:6363", 44));
|
||||
nhl1.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.13:6363"), 28));
|
||||
nhl1.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.9:6363"), 38));
|
||||
nhl1.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.26:6363"), 44));
|
||||
|
||||
NexthopList nhl2;
|
||||
nhl2.addNextHop(NextHop("udp4://10.0.0.9:6363", 21));
|
||||
nhl2.addNextHop(NextHop("udp4://10.0.0.13:6363", 26));
|
||||
nhl2.addNextHop(NextHop("udp4://10.0.0.26:6363", 42));
|
||||
nhl2.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.9:6363"), 21));
|
||||
nhl2.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.13:6363"), 26));
|
||||
nhl2.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.26:6363"), 42));
|
||||
|
||||
std::set<NextHop, NextHopComparator> hopsToRemove;
|
||||
std::set<NextHop> hopsToRemove;
|
||||
std::set_difference(nhl2.begin(), nhl2.end(),
|
||||
nhl1.begin(), nhl1.end(),
|
||||
std::inserter(hopsToRemove, hopsToRemove.begin()),
|
||||
NextHopComparator());
|
||||
std::inserter(hopsToRemove, hopsToRemove.begin()));
|
||||
|
||||
BOOST_CHECK_EQUAL(hopsToRemove.size(), 3);
|
||||
|
||||
// Sorted by FaceUri
|
||||
NextHopsUriSortedSet nhs1;
|
||||
nhs1.addNextHop(NextHop("udp4://10.0.0.13:6363", 28));
|
||||
nhs1.addNextHop(NextHop("udp4://10.0.0.9:6363", 38));
|
||||
nhs1.addNextHop(NextHop("udp4://10.0.0.26:6363", 44));
|
||||
nhs1.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.13:6363"), 28));
|
||||
nhs1.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.9:6363"), 38));
|
||||
nhs1.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.26:6363"), 44));
|
||||
|
||||
NextHopsUriSortedSet nhs2;
|
||||
nhs2.addNextHop(NextHop("udp4://10.0.0.9:6363", 21));
|
||||
nhs2.addNextHop(NextHop("udp4://10.0.0.13:6363", 26));
|
||||
nhs2.addNextHop(NextHop("udp4://10.0.0.26:6363", 42));
|
||||
nhs2.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.9:6363"), 21));
|
||||
nhs2.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.13:6363"), 26));
|
||||
nhs2.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.26:6363"), 42));
|
||||
|
||||
std::set<NextHop, NextHopUriSortedComparator> hopsToRemove2;
|
||||
std::set_difference(nhs2.begin(), nhs2.end(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -26,6 +26,9 @@ namespace test {
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(TestNexthop)
|
||||
|
||||
static const ndn::FaceUri faceUri1("udp4://192.168.3.1:6363");
|
||||
static const ndn::FaceUri faceUri2("udp4://192.168.3.2:6363");
|
||||
|
||||
static double
|
||||
getHyperbolicAdjustedDecimal(unsigned int i)
|
||||
{
|
||||
@@ -41,16 +44,23 @@ applyHyperbolicFactorAndRound(double d)
|
||||
BOOST_AUTO_TEST_CASE(LinkStateSetAndGet)
|
||||
{
|
||||
NextHop hop1;
|
||||
hop1.setConnectingFaceUri("udp://test/uri");
|
||||
hop1.setConnectingFaceUri(faceUri1);
|
||||
hop1.setRouteCost(12.34);
|
||||
|
||||
BOOST_CHECK_EQUAL(hop1.getConnectingFaceUri(), "udp://test/uri");
|
||||
BOOST_CHECK_EQUAL(hop1.getConnectingFaceUri(), faceUri1);
|
||||
BOOST_CHECK_EQUAL(hop1.getRouteCost(), 12.34);
|
||||
BOOST_CHECK_EQUAL(hop1.getRouteCostAsAdjustedInteger(), 12);
|
||||
|
||||
NextHop hop2;
|
||||
NextHop hop2(faceUri2, 12.34);
|
||||
BOOST_CHECK_NE(hop1, hop2);
|
||||
BOOST_CHECK_LT(hop1, hop2);
|
||||
BOOST_CHECK_LE(hop1, hop2);
|
||||
BOOST_CHECK_GT(hop2, hop1);
|
||||
BOOST_CHECK_GE(hop2, hop1);
|
||||
|
||||
hop2.setRouteCost(12.34);
|
||||
hop2.setConnectingFaceUri(faceUri1);
|
||||
BOOST_CHECK_EQUAL(hop1, hop2);
|
||||
BOOST_CHECK_LE(hop1, hop2);
|
||||
BOOST_CHECK_GE(hop2, hop1);
|
||||
BOOST_CHECK_EQUAL(hop1.getRouteCostAsAdjustedInteger(), hop2.getRouteCostAsAdjustedInteger());
|
||||
}
|
||||
|
||||
@@ -58,31 +68,37 @@ BOOST_AUTO_TEST_CASE(HyperbolicSetAndGet)
|
||||
{
|
||||
NextHop hop1;
|
||||
hop1.setHyperbolic(true);
|
||||
hop1.setConnectingFaceUri("udp://test/uri");
|
||||
hop1.setConnectingFaceUri(faceUri1);
|
||||
hop1.setRouteCost(12.34);
|
||||
|
||||
BOOST_CHECK_EQUAL(hop1.getConnectingFaceUri(), "udp://test/uri");
|
||||
BOOST_CHECK_EQUAL(hop1.getConnectingFaceUri(), faceUri1);
|
||||
BOOST_CHECK_EQUAL(hop1.getRouteCost(), 12.34);
|
||||
BOOST_CHECK_EQUAL(hop1.getRouteCostAsAdjustedInteger(), applyHyperbolicFactorAndRound(12.34));
|
||||
|
||||
NextHop hop2;
|
||||
NextHop hop2(faceUri2, 12.34);
|
||||
hop2.setHyperbolic(true);
|
||||
BOOST_CHECK_NE(hop1, hop2);
|
||||
BOOST_CHECK_LT(hop1, hop2);
|
||||
BOOST_CHECK_LE(hop1, hop2);
|
||||
BOOST_CHECK_GT(hop2, hop1);
|
||||
BOOST_CHECK_GE(hop2, hop1);
|
||||
|
||||
hop2.setRouteCost(12.34);
|
||||
hop2.setConnectingFaceUri(faceUri1);
|
||||
BOOST_CHECK_EQUAL(hop1, hop2);
|
||||
BOOST_CHECK_EQUAL(hop1.getRouteCostAsAdjustedInteger(), hop2.getRouteCostAsAdjustedInteger());
|
||||
|
||||
hop2.setRouteCost(12.35);
|
||||
BOOST_CHECK(hop1.getRouteCostAsAdjustedInteger() < hop2.getRouteCostAsAdjustedInteger());
|
||||
BOOST_CHECK_LT(hop1, hop2);
|
||||
BOOST_CHECK_LT(hop1.getRouteCostAsAdjustedInteger(), hop2.getRouteCostAsAdjustedInteger());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(HyperbolicRound)
|
||||
{
|
||||
NextHop hop1;
|
||||
hop1.setHyperbolic(true);
|
||||
hop1.setConnectingFaceUri("udp://test/uri");
|
||||
hop1.setConnectingFaceUri(faceUri1);
|
||||
hop1.setRouteCost(1 + getHyperbolicAdjustedDecimal(6));
|
||||
|
||||
BOOST_CHECK_EQUAL(hop1.getConnectingFaceUri(), "udp://test/uri");
|
||||
BOOST_CHECK_EQUAL(hop1.getConnectingFaceUri(), faceUri1);
|
||||
BOOST_CHECK_EQUAL(hop1.getRouteCost(), 1 + getHyperbolicAdjustedDecimal(6));
|
||||
BOOST_CHECK_EQUAL(hop1.getRouteCostAsAdjustedInteger(),
|
||||
applyHyperbolicFactorAndRound((1 + getHyperbolicAdjustedDecimal(6))));
|
||||
@@ -97,47 +113,47 @@ BOOST_AUTO_TEST_CASE(HyperbolicRound)
|
||||
BOOST_CHECK_EQUAL(hop1.getRouteCostAsAdjustedInteger(), hop2.getRouteCostAsAdjustedInteger());
|
||||
|
||||
hop2.setRouteCost(1 + getHyperbolicAdjustedDecimal(4));
|
||||
BOOST_CHECK(hop1.getRouteCostAsAdjustedInteger() > hop2.getRouteCostAsAdjustedInteger());
|
||||
BOOST_CHECK_GT(hop1.getRouteCostAsAdjustedInteger(), hop2.getRouteCostAsAdjustedInteger());
|
||||
}
|
||||
|
||||
const uint8_t NexthopData[] =
|
||||
{
|
||||
// Header
|
||||
0x8f, 0x1d,
|
||||
0x8f, 0x23,
|
||||
// Uri
|
||||
0x8d, 0x11, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f,
|
||||
0x70, 0x2f, 0x74, 0x6c, 0x76,
|
||||
0x8d, 0x17, 0x75, 0x64, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x31, 0x36, 0x38,
|
||||
0x2e, 0x33, 0x2e, 0x31, 0x3a, 0x36, 0x33, 0x36, 0x33,
|
||||
// Cost
|
||||
0x86, 0x08, 0x3f, 0xfa, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(NexthopEncode)
|
||||
BOOST_AUTO_TEST_CASE(Encode)
|
||||
{
|
||||
NextHop nexthops1;
|
||||
nexthops1.setConnectingFaceUri("/test/nexthop/tlv");
|
||||
nexthops1.setConnectingFaceUri(faceUri1);
|
||||
nexthops1.setRouteCost(1.65);
|
||||
|
||||
BOOST_TEST(nexthops1.wireEncode() == NexthopData, boost::test_tools::per_element());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(NexthopDecode)
|
||||
BOOST_AUTO_TEST_CASE(Decode)
|
||||
{
|
||||
NextHop nexthops1;
|
||||
nexthops1.wireDecode(ndn::Block{NexthopData});
|
||||
|
||||
BOOST_REQUIRE_EQUAL(nexthops1.getConnectingFaceUri(), "/test/nexthop/tlv");
|
||||
BOOST_REQUIRE_EQUAL(nexthops1.getConnectingFaceUri(), faceUri1);
|
||||
BOOST_REQUIRE_EQUAL(nexthops1.getRouteCost(), 1.65);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(AdjacencyOutputStream)
|
||||
BOOST_AUTO_TEST_CASE(OutputStream)
|
||||
{
|
||||
NextHop nexthops1;
|
||||
nexthops1.setConnectingFaceUri("/test/nexthop/tlv");
|
||||
nexthops1.setConnectingFaceUri(faceUri1);
|
||||
nexthops1.setRouteCost(99);
|
||||
|
||||
std::ostringstream os;
|
||||
os << nexthops1;
|
||||
BOOST_CHECK_EQUAL(os.str(), "NextHop(Uri: /test/nexthop/tlv, Cost: 99)");
|
||||
BOOST_CHECK_EQUAL(os.str(), "NextHop(Uri: udp4://192.168.3.1:6363, Cost: 99)");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -33,20 +33,31 @@ BOOST_AUTO_TEST_CASE(Destination)
|
||||
BOOST_CHECK_EQUAL(rte1.getDestination(), "router1");
|
||||
}
|
||||
|
||||
const uint8_t RoutingTableEntryWithNexthopsData[] = {
|
||||
static const ndn::FaceUri NEXTHOP1("udp4://192.168.3.1:6363");
|
||||
static const ndn::FaceUri NEXTHOP2("udp4://192.168.3.2:6363");
|
||||
|
||||
static const uint8_t RoutingTableEntryWithNexthopsData[] = {
|
||||
// Header
|
||||
0x91, 0x35,
|
||||
0x91, 0x53,
|
||||
// Destination Name
|
||||
0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31, 0x8f, 0x14,
|
||||
0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31,
|
||||
// Nexthop
|
||||
0x8d, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x31, 0x86, 0x08, 0x3f, 0xfa,
|
||||
0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x8f, 0x14, 0x8d, 0x08,
|
||||
0x8f, 0x23,
|
||||
// Nexthop.Uri
|
||||
0x8d, 0x17, 0x75, 0x64, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x31, 0x36, 0x38,
|
||||
0x2e, 0x33, 0x2e, 0x31, 0x3a, 0x36, 0x33, 0x36, 0x33,
|
||||
// Nexthop.CostDouble
|
||||
0x86, 0x08, 0x3f, 0xfa, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
|
||||
// Nexthop
|
||||
0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x32, 0x86, 0x08, 0x3f, 0xfa, 0x66, 0x66,
|
||||
0x66, 0x66, 0x66, 0x66
|
||||
0x8f, 0x23,
|
||||
// Nexthop.Uri
|
||||
0x8d, 0x17, 0x75, 0x64, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x31, 0x36, 0x38,
|
||||
0x2e, 0x33, 0x2e, 0x32, 0x3a, 0x36, 0x33, 0x36, 0x33,
|
||||
// Nexthop.CostDouble
|
||||
0x86, 0x08, 0x3f, 0xfa, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
|
||||
};
|
||||
|
||||
const uint8_t RoutingTableEntryWithoutNexthopsData[] = {
|
||||
static const uint8_t RoutingTableEntryWithoutNexthopsData[] = {
|
||||
// Header
|
||||
0x91, 0x09,
|
||||
// Destination Name
|
||||
@@ -58,12 +69,12 @@ BOOST_AUTO_TEST_CASE(EncodeWithNexthops)
|
||||
RoutingTableEntry rte(ndn::Name("dest1"));
|
||||
|
||||
NextHop nexthops1;
|
||||
nexthops1.setConnectingFaceUri("nexthop1");
|
||||
nexthops1.setConnectingFaceUri(NEXTHOP1);
|
||||
nexthops1.setRouteCost(1.65);
|
||||
rte.getNexthopList().addNextHop(nexthops1);
|
||||
|
||||
NextHop nexthops2;
|
||||
nexthops2.setConnectingFaceUri("nexthop2");
|
||||
nexthops2.setConnectingFaceUri(NEXTHOP2);
|
||||
nexthops2.setRouteCost(1.65);
|
||||
rte.getNexthopList().addNextHop(nexthops2);
|
||||
|
||||
@@ -78,11 +89,11 @@ BOOST_AUTO_TEST_CASE(DecodeWithNexthops)
|
||||
|
||||
BOOST_CHECK(rte.getNexthopList().size() != 0);
|
||||
auto it = rte.getNexthopList().begin();
|
||||
BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), "nexthop1");
|
||||
BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), NEXTHOP1);
|
||||
BOOST_CHECK_EQUAL(it->getRouteCost(), 1.65);
|
||||
|
||||
it++;
|
||||
BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), "nexthop2");
|
||||
BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), NEXTHOP2);
|
||||
BOOST_CHECK_EQUAL(it->getRouteCost(), 1.65);
|
||||
}
|
||||
|
||||
@@ -105,45 +116,41 @@ BOOST_AUTO_TEST_CASE(Clear)
|
||||
RoutingTableEntry rte(ndn::Name("dest1"));
|
||||
|
||||
NextHop nexthops1;
|
||||
nexthops1.setConnectingFaceUri("nexthop1");
|
||||
nexthops1.setConnectingFaceUri(NEXTHOP1);
|
||||
nexthops1.setRouteCost(99);
|
||||
rte.getNexthopList().addNextHop(nexthops1);
|
||||
|
||||
BOOST_CHECK_EQUAL(rte.getNexthopList().size(), 1);
|
||||
|
||||
auto it = rte.getNexthopList().begin();
|
||||
BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), "nexthop1");
|
||||
BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), NEXTHOP1);
|
||||
BOOST_CHECK_EQUAL(it->getRouteCost(), 99);
|
||||
|
||||
rte.getNexthopList().clear();
|
||||
BOOST_CHECK_EQUAL(rte.getNexthopList().size(), 0);
|
||||
|
||||
NextHop nexthops2;
|
||||
nexthops2.setConnectingFaceUri("nexthop2");
|
||||
nexthops2.setConnectingFaceUri(NEXTHOP2);
|
||||
nexthops2.setRouteCost(99);
|
||||
rte.getNexthopList().addNextHop(nexthops2);
|
||||
|
||||
BOOST_CHECK_EQUAL(rte.getNexthopList().size(), 1);
|
||||
it = rte.getNexthopList().begin();
|
||||
BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), "nexthop2");
|
||||
BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), NEXTHOP2);
|
||||
BOOST_CHECK_EQUAL(it->getRouteCost(), 99);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(OutputStream)
|
||||
{
|
||||
RoutingTableEntry rte(ndn::Name("dest1"));
|
||||
|
||||
NextHop nexthops1;
|
||||
nexthops1.setConnectingFaceUri("nexthop1");
|
||||
nexthops1.setRouteCost(99);
|
||||
rte.getNexthopList().addNextHop(nexthops1);
|
||||
rte.getNexthopList().addNextHop({NEXTHOP1, 99});
|
||||
|
||||
std::ostringstream os;
|
||||
os << rte;
|
||||
|
||||
BOOST_CHECK_EQUAL(os.str(),
|
||||
" Destination: /dest1\n"
|
||||
" NextHop(Uri: nexthop1, Cost: 99)\n");
|
||||
" NextHop(Uri: udp4://192.168.3.1:6363, Cost: 99)\n");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -35,11 +35,11 @@ BOOST_AUTO_TEST_CASE(EqualsOperator)
|
||||
{
|
||||
NextHop hop1;
|
||||
hop1.setRouteCost(25);
|
||||
hop1.setConnectingFaceUri("AAA");
|
||||
hop1.setConnectingFaceUri(ndn::FaceUri("udp4://192.168.3.1:6363"));
|
||||
|
||||
NextHop hop2;
|
||||
hop2.setRouteCost(10);
|
||||
hop2.setConnectingFaceUri("BBB");
|
||||
hop2.setConnectingFaceUri(ndn::FaceUri("udp4://192.168.3.2:6363"));
|
||||
|
||||
NexthopList nhl1;
|
||||
NexthopList nhl2;
|
||||
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
ndn::Scheduler m_scheduler{m_io};
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face{m_io, m_keyChain, {true, true}};
|
||||
ndn::DummyClientFace face{m_io, m_keyChain, {true, true}};
|
||||
ConfParameter conf{face, m_keyChain};
|
||||
DummyConfFileProcessor confProcessor{conf};
|
||||
|
||||
@@ -56,14 +56,18 @@ BOOST_FIXTURE_TEST_CASE(AddNextHop, RoutingTableFixture)
|
||||
|
||||
const uint8_t RoutingTableData1[] = {
|
||||
// Header
|
||||
0x90, 0x20,
|
||||
0x90, 0x30,
|
||||
// Routing table entry
|
||||
0x91, 0x1e,
|
||||
0x91, 0x2e,
|
||||
// Destination
|
||||
0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31, 0x8f, 0x13,
|
||||
0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31,
|
||||
// Nexthop
|
||||
0x8d, 0x07, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x86, 0x08, 0x3f, 0xfa, 0x66,
|
||||
0x66, 0x66, 0x66, 0x66, 0x66
|
||||
0x8f, 0x23,
|
||||
// Nexthop.Uri
|
||||
0x8d, 0x17, 0x75, 0x64, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x31, 0x36, 0x38,
|
||||
0x2e, 0x33, 0x2e, 0x31, 0x3a, 0x36, 0x33, 0x36, 0x33,
|
||||
// Nexthop.CostDouble
|
||||
0x86, 0x08, 0x3f, 0xfa, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
|
||||
};
|
||||
|
||||
const uint8_t RoutingTableData2[] = {
|
||||
@@ -74,7 +78,7 @@ const uint8_t RoutingTableData2[] = {
|
||||
BOOST_FIXTURE_TEST_CASE(Encode, RoutingTableFixture)
|
||||
{
|
||||
NextHop nexthops;
|
||||
nexthops.setConnectingFaceUri("nexthop");
|
||||
nexthops.setConnectingFaceUri(ndn::FaceUri("udp4://192.168.3.1:6363"));
|
||||
nexthops.setRouteCost(1.65);
|
||||
rt.addNextHop("dest1", nexthops);
|
||||
BOOST_TEST(rt.wireEncode() == RoutingTableData1, boost::test_tools::per_element());
|
||||
@@ -94,7 +98,7 @@ BOOST_FIXTURE_TEST_CASE(Decode, RoutingTableFixture)
|
||||
BOOST_CHECK_EQUAL(des1, "dest1");
|
||||
|
||||
auto it2 = it1->getNexthopList().begin();
|
||||
BOOST_CHECK_EQUAL(it2->getConnectingFaceUri(), "nexthop");
|
||||
BOOST_CHECK_EQUAL(it2->getConnectingFaceUri(), ndn::FaceUri("udp4://192.168.3.1:6363"));
|
||||
BOOST_CHECK_EQUAL(it2->getRouteCost(), 1.65);
|
||||
|
||||
BOOST_CHECK_EQUAL(rtStatus.m_rTable.size(), 1);
|
||||
@@ -103,7 +107,7 @@ BOOST_FIXTURE_TEST_CASE(Decode, RoutingTableFixture)
|
||||
BOOST_FIXTURE_TEST_CASE(OutputStream, RoutingTableFixture)
|
||||
{
|
||||
NextHop nexthops;
|
||||
nexthops.setConnectingFaceUri("nexthop");
|
||||
nexthops.setConnectingFaceUri(ndn::FaceUri("udp4://192.168.3.1:6363"));
|
||||
nexthops.setRouteCost(99);
|
||||
rt.addNextHop("dest1", nexthops);
|
||||
|
||||
@@ -113,7 +117,7 @@ BOOST_FIXTURE_TEST_CASE(OutputStream, RoutingTableFixture)
|
||||
BOOST_CHECK_EQUAL(os.str(),
|
||||
"Routing Table:\n"
|
||||
" Destination: /dest1\n"
|
||||
" NextHop(Uri: nexthop, Cost: 99)\n");
|
||||
" NextHop(Uri: udp4://192.168.3.1:6363, Cost: 99)\n");
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(UpdateFromLsdb, RoutingTableFixture)
|
||||
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
BOOST_CHECK(didFindInterest);
|
||||
}
|
||||
|
||||
ndn::util::DummyClientFace face;
|
||||
ndn::DummyClientFace face;
|
||||
|
||||
ConfParameter conf;
|
||||
DummyConfFileProcessor confProcessor;
|
||||
@@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE(Basic)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(RetrieveCert)
|
||||
{
|
||||
ndn::util::DummyClientFace consumer(m_io);
|
||||
ndn::DummyClientFace consumer(m_io);
|
||||
consumer.linkTo(face);
|
||||
|
||||
auto checkRetrieve = [&] (const ndn::Name& interestName, bool canBePrefix, const ndn::Name& dataName) {
|
||||
@@ -245,7 +245,7 @@ BOOST_AUTO_TEST_CASE(SegmentValidatedSignal)
|
||||
BOOST_CHECK(certStore.find(keyName) != nullptr);
|
||||
|
||||
// testing a callback after segment validation signal from lsdb
|
||||
ndn::util::signal::ScopedConnection connection = lsdb.afterSegmentValidatedSignal.connect(
|
||||
ndn::signal::ScopedConnection connection = lsdb.afterSegmentValidatedSignal.connect(
|
||||
[&] (const ndn::Data& lsaSegment) {
|
||||
BOOST_CHECK_EQUAL(lsaSegment.getName(), data.getName());
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -38,7 +38,7 @@ BOOST_AUTO_TEST_CASE(Basic)
|
||||
const std::string ADJ_NAME_1 = "testname";
|
||||
const std::string ADJ_NAME_2 = "testname2";
|
||||
|
||||
//adjacent needed to test adjacency list.
|
||||
// adjacent needed to test adjacency list
|
||||
Adjacent adjacent1(ADJ_NAME_1);
|
||||
Adjacent adjacent2(ADJ_NAME_2);
|
||||
|
||||
@@ -71,7 +71,7 @@ BOOST_AUTO_TEST_CASE(FindAdjacentByFaceUri)
|
||||
AdjacencyList adjList;
|
||||
adjList.insert(adj1);
|
||||
|
||||
std::list<Adjacent>::iterator adjIter = adjList.findAdjacent(faceUri);
|
||||
auto adjIter = adjList.findAdjacent(faceUri);
|
||||
BOOST_CHECK(adjIter != adjList.end());
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(AdjLsaIsBuildableWithOneNodeActive)
|
||||
adjacencies.insert(adjacencyA);
|
||||
adjacencies.insert(adjacencyB);
|
||||
|
||||
ndn::util::DummyClientFace face;
|
||||
ndn::DummyClientFace face;
|
||||
ndn::KeyChain keyChain;
|
||||
ConfParameter conf(face, keyChain);
|
||||
BOOST_CHECK(adjacencies.isAdjLsaBuildable(conf.getInterestRetryNumber()));
|
||||
@@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE(AdjLsaIsBuildableWithAllNodesTimedOut)
|
||||
adjacencies.insert(adjacencyA);
|
||||
adjacencies.insert(adjacencyB);
|
||||
|
||||
ndn::util::DummyClientFace face;
|
||||
ndn::DummyClientFace face;
|
||||
ndn::KeyChain keyChain;
|
||||
ConfParameter conf(face, keyChain);
|
||||
conf.setInterestRetryNumber(HELLO_RETRIES_DEFAULT);
|
||||
@@ -131,7 +131,7 @@ BOOST_AUTO_TEST_CASE(AdjLsaIsNotBuildable)
|
||||
adjacencies.insert(adjacencyA);
|
||||
adjacencies.insert(adjacencyB);
|
||||
|
||||
ndn::util::DummyClientFace face;
|
||||
ndn::DummyClientFace face;
|
||||
ndn::KeyChain keyChain;
|
||||
ConfParameter conf(face, keyChain);
|
||||
conf.setInterestRetryNumber(HELLO_RETRIES_DEFAULT);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -41,7 +41,7 @@ signData(ndn::Data& data)
|
||||
}
|
||||
|
||||
void
|
||||
checkPrefixRegistered(const ndn::util::DummyClientFace& face, const ndn::Name& prefix)
|
||||
checkPrefixRegistered(const ndn::DummyClientFace& face, const ndn::Name& prefix)
|
||||
{
|
||||
bool registerCommandEmitted = false;
|
||||
for (const auto& interest : face.sentInterests) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -56,7 +56,7 @@ signData(std::shared_ptr<ndn::Data> data)
|
||||
}
|
||||
|
||||
void
|
||||
checkPrefixRegistered(const ndn::util::DummyClientFace& face, const ndn::Name& prefix);
|
||||
checkPrefixRegistered(const ndn::DummyClientFace& face, const ndn::Name& prefix);
|
||||
|
||||
class DummyConfFileProcessor
|
||||
{
|
||||
|
||||
@@ -164,7 +164,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face;
|
||||
ndn::DummyClientFace face;
|
||||
ConfParameter conf;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -34,7 +34,7 @@ BOOST_AUTO_TEST_SUITE(TestConfParameter)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ConfParameterSettersAndGetters)
|
||||
{
|
||||
ndn::util::DummyClientFace face;
|
||||
ndn::DummyClientFace face;
|
||||
ndn::KeyChain keyChain;
|
||||
ConfParameter cp1(face, keyChain);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face;
|
||||
ndn::DummyClientFace face;
|
||||
ConfParameter conf;
|
||||
DummyConfFileProcessor confProcessor;
|
||||
AdjacencyList& adjList;
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face;
|
||||
ndn::DummyClientFace face;
|
||||
|
||||
ndn::Name rootIdName, siteIdentityName, opIdentityName, routerIdName;
|
||||
ndn::security::pib::Identity rootId, siteIdentity, opIdentity, routerId;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
ndn::time::system_clock::now() + refreshTime, npl1);
|
||||
|
||||
interestName.appendVersion();
|
||||
ndn::util::Segmenter segmenter(m_keyChain, ndn::security::SigningInfo());
|
||||
ndn::Segmenter segmenter(m_keyChain, ndn::security::SigningInfo());
|
||||
auto segments = segmenter.segment(nameLsa.wireEncode(), interestName,
|
||||
ndn::MAX_NDN_PACKET_SIZE / 2, refreshTime);
|
||||
for (const auto& seg : segments) {
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face{m_io, m_keyChain, {true, true}};
|
||||
ndn::DummyClientFace face{m_io, m_keyChain, {true, true}};
|
||||
ConfParameter conf{face, m_keyChain};
|
||||
DummyConfFileProcessor confProcessor{conf};
|
||||
Nlsr nlsr{face, m_keyChain, conf};
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
ndn::InMemoryStorageFifo ims{100};
|
||||
|
||||
int numValidationSignal = 0;
|
||||
ndn::util::signal::ScopedConnection afterSegmentValidatedConn;
|
||||
ndn::signal::ScopedConnection afterSegmentValidatedConn;
|
||||
};
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(TestLsaSegmentStorage, LsaSegmentStorageFixture)
|
||||
|
||||
@@ -1,427 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
*
|
||||
* NLSR is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Foundation,
|
||||
* either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* 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 "lsa/name-lsa.hpp"
|
||||
#include "lsa/adj-lsa.hpp"
|
||||
#include "lsa/coordinate-lsa.hpp"
|
||||
#include "adjacent.hpp"
|
||||
#include "name-prefix-list.hpp"
|
||||
|
||||
#include "tests/boost-test.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
/*
|
||||
static void
|
||||
printBytes(ndn::span<const uint8_t> buf)
|
||||
{
|
||||
std::string hex = ndn::toHex(buf);
|
||||
|
||||
for (size_t i = 0; i < hex.size(); i++) {
|
||||
if (i > 0 && i % 30 == 0)
|
||||
std::cout << "\n ";
|
||||
|
||||
std::cout << "0x" << hex[i];
|
||||
std::cout << hex[++i];
|
||||
|
||||
if ((i + 1) != hex.size())
|
||||
std::cout << ", ";
|
||||
}
|
||||
std::cout << "\n" << "};" << std::endl;
|
||||
}
|
||||
|
||||
printBytes(block);
|
||||
*/
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(TestLsa)
|
||||
|
||||
const uint8_t NAME_LSA1[] = {
|
||||
0x89, 0x37, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61,
|
||||
0x6D, 0x65, 0x31, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x32
|
||||
};
|
||||
|
||||
const uint8_t NAME_LSA_EXTRA_NAME[] = {
|
||||
0x89, 0x40, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61,
|
||||
0x6D, 0x65, 0x31, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x32, 0x07, 0x07, 0x08,
|
||||
0x05, 0x6E, 0x61, 0x6D, 0x65, 0x33
|
||||
};
|
||||
|
||||
const uint8_t NAME_LSA_DIFF_SEQ[] = {
|
||||
0x89, 0x40, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0E, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61,
|
||||
0x6D, 0x65, 0x31, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x32, 0x07, 0x07, 0x08,
|
||||
0x05, 0x6E, 0x61, 0x6D, 0x65, 0x33
|
||||
};
|
||||
|
||||
const uint8_t NAME_LSA_DIFF_TS[] = {
|
||||
0x89, 0x40, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0E, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x34, 0x34, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61,
|
||||
0x6D, 0x65, 0x31, 0x07, 0x07, 0x08, 0x05, 0x6E, 0x61, 0x6D, 0x65, 0x32, 0x07, 0x07, 0x08,
|
||||
0x05, 0x6E, 0x61, 0x6D, 0x65, 0x33
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(NameLsaBasic)
|
||||
{
|
||||
ndn::Name s1{"name1"};
|
||||
ndn::Name s2{"name2"};
|
||||
NamePrefixList npl1{s1, s2};
|
||||
|
||||
auto testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
|
||||
|
||||
// 3rd argument is seqNo
|
||||
NameLsa nlsa1("router1", 12, testTimePoint, npl1);
|
||||
NameLsa nlsa2("router2", 12, testTimePoint, npl1);
|
||||
|
||||
BOOST_CHECK_EQUAL(nlsa1.getType(), Lsa::Type::NAME);
|
||||
BOOST_CHECK(nlsa1.getExpirationTimePoint() == nlsa2.getExpirationTimePoint());
|
||||
|
||||
auto wire = nlsa1.wireEncode();
|
||||
BOOST_TEST(wire == NAME_LSA1, boost::test_tools::per_element());
|
||||
|
||||
nlsa1.addName("name3");
|
||||
wire = nlsa1.wireEncode();
|
||||
BOOST_TEST(wire == NAME_LSA_EXTRA_NAME, boost::test_tools::per_element());
|
||||
|
||||
nlsa1.setSeqNo(14);
|
||||
wire = nlsa1.wireEncode();
|
||||
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_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
|
||||
}
|
||||
|
||||
const uint8_t ADJ_LSA1[] = {
|
||||
0x83, 0x58, 0x80, 0x2D, 0x07, 0x13, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04, 0x73, 0x69,
|
||||
0x74, 0x65, 0x08, 0x06, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x82, 0x01, 0x0C, 0x8B, 0x13,
|
||||
0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36, 0x20, 0x30, 0x34, 0x3A, 0x31,
|
||||
0x33, 0x3A, 0x33, 0x34, 0x84, 0x27, 0x07, 0x16, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04,
|
||||
0x73, 0x69, 0x74, 0x65, 0x08, 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79,
|
||||
0x8D, 0x03, 0x3A, 0x2F, 0x2F, 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const uint8_t ADJ_LSA_EXTRA_NEIGHBOR[] = {
|
||||
0x83, 0x80, 0x80, 0x2D, 0x07, 0x13, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04, 0x73, 0x69,
|
||||
0x74, 0x65, 0x08, 0x06, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x82, 0x01, 0x0C, 0x8B, 0x13,
|
||||
0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36, 0x20, 0x30, 0x34, 0x3A, 0x31,
|
||||
0x33, 0x3A, 0x33, 0x34, 0x84, 0x27, 0x07, 0x16, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04,
|
||||
0x73, 0x69, 0x74, 0x65, 0x08, 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79,
|
||||
0x8D, 0x03, 0x3A, 0x2F, 0x2F, 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x84, 0x26, 0x07, 0x15, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x03, 0x65, 0x64, 0x75, 0x08,
|
||||
0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79, 0x8D, 0x03, 0x3A, 0x2F, 0x2F,
|
||||
0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const uint8_t ADJ_LSA_DIFF_SEQ[] = {
|
||||
0x83, 0x80, 0x80, 0x2D, 0x07, 0x13, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04, 0x73, 0x69,
|
||||
0x74, 0x65, 0x08, 0x06, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x82, 0x01, 0x0E, 0x8B, 0x13,
|
||||
0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36, 0x20, 0x30, 0x34, 0x3A, 0x31,
|
||||
0x33, 0x3A, 0x33, 0x34, 0x84, 0x27, 0x07, 0x16, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04,
|
||||
0x73, 0x69, 0x74, 0x65, 0x08, 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79,
|
||||
0x8D, 0x03, 0x3A, 0x2F, 0x2F, 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x84, 0x26, 0x07, 0x15, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x03, 0x65, 0x64, 0x75, 0x08,
|
||||
0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79, 0x8D, 0x03, 0x3A, 0x2F, 0x2F,
|
||||
0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
const uint8_t ADJ_LSA_DIFF_TS[] = {
|
||||
0x83, 0x80, 0x80, 0x2D, 0x07, 0x13, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04, 0x73, 0x69,
|
||||
0x74, 0x65, 0x08, 0x06, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x82, 0x01, 0x0E, 0x8B, 0x13,
|
||||
0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36, 0x20, 0x30, 0x34, 0x3A, 0x31,
|
||||
0x33, 0x3A, 0x34, 0x34, 0x84, 0x27, 0x07, 0x16, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x04,
|
||||
0x73, 0x69, 0x74, 0x65, 0x08, 0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79,
|
||||
0x8D, 0x03, 0x3A, 0x2F, 0x2F, 0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x84, 0x26, 0x07, 0x15, 0x08, 0x03, 0x6E, 0x64, 0x6E, 0x08, 0x03, 0x65, 0x64, 0x75, 0x08,
|
||||
0x09, 0x61, 0x64, 0x6A, 0x61, 0x63, 0x65, 0x6E, 0x63, 0x79, 0x8D, 0x03, 0x3A, 0x2F, 0x2F,
|
||||
0x8C, 0x08, 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(AdjLsaBasic)
|
||||
{
|
||||
ndn::Name routerName("/ndn/site/router");
|
||||
ndn::Name adjacencyName("/ndn/site/adjacency");
|
||||
auto testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
|
||||
uint32_t seqNo = 12;
|
||||
|
||||
// An AdjLsa initialized with ACTIVE adjacencies should copy the adjacencies
|
||||
AdjacencyList activeAdjacencies;
|
||||
Adjacent activeAdjacency(adjacencyName);
|
||||
activeAdjacency.setStatus(Adjacent::STATUS_ACTIVE);
|
||||
activeAdjacencies.insert(activeAdjacency);
|
||||
|
||||
AdjLsa alsa1(routerName, seqNo, testTimePoint,
|
||||
activeAdjacencies.size(), activeAdjacencies);
|
||||
BOOST_CHECK_EQUAL(alsa1.getAdl().size(), 1);
|
||||
BOOST_CHECK_EQUAL(alsa1.getType(), Lsa::Type::ADJACENCY);
|
||||
BOOST_CHECK_EQUAL(alsa1.getSeqNo(), seqNo);
|
||||
BOOST_CHECK_EQUAL(alsa1.getExpirationTimePoint(), testTimePoint);
|
||||
BOOST_CHECK_EQUAL(alsa1.getNoLink(), 1);
|
||||
BOOST_CHECK(alsa1.getAdl().isNeighbor(activeAdjacency.getName()));
|
||||
|
||||
// An AdjLsa initialized with INACTIVE adjacencies should not copy the adjacencies
|
||||
AdjacencyList inactiveAdjacencies;
|
||||
Adjacent inactiveAdjacency(adjacencyName);
|
||||
inactiveAdjacency.setStatus(Adjacent::STATUS_INACTIVE);
|
||||
inactiveAdjacencies.insert(inactiveAdjacency);
|
||||
|
||||
AdjLsa alsa2(routerName, seqNo, testTimePoint,
|
||||
inactiveAdjacencies.size(), inactiveAdjacencies);
|
||||
BOOST_CHECK_EQUAL(alsa2.getAdl().size(), 0);
|
||||
|
||||
// Thus, the two LSAs should not have equal content
|
||||
BOOST_CHECK_EQUAL(alsa1.isEqualContent(alsa2), false);
|
||||
|
||||
// Create a duplicate of alsa1 which should have equal content
|
||||
AdjLsa alsa3(routerName, seqNo, testTimePoint,
|
||||
activeAdjacencies.size(), activeAdjacencies);
|
||||
BOOST_CHECK(alsa1.isEqualContent(alsa3));
|
||||
|
||||
auto wire = alsa1.wireEncode();
|
||||
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_TEST(wire == ADJ_LSA_EXTRA_NEIGHBOR, boost::test_tools::per_element());
|
||||
|
||||
alsa1.setSeqNo(14);
|
||||
wire = alsa1.wireEncode();
|
||||
BOOST_TEST(wire == ADJ_LSA_DIFF_SEQ, boost::test_tools::per_element());
|
||||
|
||||
testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196024993));
|
||||
alsa1.setExpirationTimePoint(testTimePoint);
|
||||
wire = alsa1.wireEncode();
|
||||
BOOST_TEST(wire == ADJ_LSA_DIFF_TS, boost::test_tools::per_element());
|
||||
}
|
||||
|
||||
const uint8_t COORDINATE_LSA1[] = {
|
||||
0x85, 0x43, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x87, 0x08, 0x40, 0x04, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x88, 0x08, 0x40, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88,
|
||||
0x08, 0x40, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const uint8_t COORDINATE_LSA_DIFF_ANGLE[] = {
|
||||
0x85, 0x39, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x87, 0x08, 0x40, 0x04, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x88, 0x08, 0x40, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const uint8_t COORDINATE_LSA_DIFF_RADIUS[] = {
|
||||
0x85, 0x39, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0C, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x87, 0x08, 0x40, 0x02, 0x66, 0x66,
|
||||
0x66, 0x66, 0x66, 0x66, 0x88, 0x08, 0x40, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const uint8_t COORDINATE_LSA_DIFF_SEQ[] = {
|
||||
0x85, 0x39, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0E, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x33, 0x34, 0x87, 0x08, 0x40, 0x02, 0x66, 0x66,
|
||||
0x66, 0x66, 0x66, 0x66, 0x88, 0x08, 0x40, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const uint8_t COORDINATE_LSA_DIFF_TS[] = {
|
||||
0x85, 0x39, 0x80, 0x23, 0x07, 0x09, 0x08, 0x07, 0x72, 0x6F, 0x75, 0x74, 0x65, 0x72, 0x31,
|
||||
0x82, 0x01, 0x0E, 0x8B, 0x13, 0x32, 0x30, 0x32, 0x30, 0x2D, 0x30, 0x33, 0x2D, 0x32, 0x36,
|
||||
0x20, 0x30, 0x34, 0x3A, 0x31, 0x33, 0x3A, 0x34, 0x34, 0x87, 0x08, 0x40, 0x02, 0x66, 0x66,
|
||||
0x66, 0x66, 0x66, 0x66, 0x88, 0x08, 0x40, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(CoordinateLsaBasic)
|
||||
{
|
||||
auto testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
|
||||
std::vector<double> angles1{30.0}, angles2{30.0};
|
||||
angles1.push_back(30.0);
|
||||
angles2.push_back(30.0);
|
||||
CoordinateLsa clsa1("router1", 12, testTimePoint, 2.5, angles1);
|
||||
CoordinateLsa clsa2("router1", 12, testTimePoint, 2.5, angles2);
|
||||
|
||||
BOOST_CHECK_CLOSE(clsa1.getCorRadius(), 2.5, 0.0001);
|
||||
BOOST_CHECK(clsa1.getCorTheta() == angles1);
|
||||
|
||||
BOOST_CHECK(clsa1.isEqualContent(clsa2));
|
||||
|
||||
BOOST_CHECK_EQUAL(clsa1.wireEncode(), clsa2.wireEncode());
|
||||
|
||||
auto wire = clsa1.wireEncode();
|
||||
BOOST_TEST(wire == COORDINATE_LSA1, boost::test_tools::per_element());
|
||||
|
||||
std::vector<double> angles3{40.0};
|
||||
clsa1.setCorTheta(angles3);
|
||||
wire = clsa1.wireEncode();
|
||||
BOOST_TEST(wire == COORDINATE_LSA_DIFF_ANGLE, boost::test_tools::per_element());
|
||||
|
||||
clsa1.setCorRadius(2.3);
|
||||
wire = clsa1.wireEncode();
|
||||
BOOST_TEST(wire == COORDINATE_LSA_DIFF_RADIUS, boost::test_tools::per_element());
|
||||
|
||||
clsa1.setSeqNo(14);
|
||||
wire = clsa1.wireEncode();
|
||||
BOOST_TEST(wire == COORDINATE_LSA_DIFF_SEQ, boost::test_tools::per_element());
|
||||
|
||||
testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196024993));
|
||||
clsa1.setExpirationTimePoint(testTimePoint);
|
||||
wire = clsa1.wireEncode();
|
||||
BOOST_TEST(wire == COORDINATE_LSA_DIFF_TS, boost::test_tools::per_element());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(IncrementAdjacentNumber)
|
||||
{
|
||||
Adjacent adj1("adjacent1");
|
||||
Adjacent adj2("adjacent2");
|
||||
|
||||
adj1.setStatus(Adjacent::STATUS_ACTIVE);
|
||||
adj2.setStatus(Adjacent::STATUS_ACTIVE);
|
||||
|
||||
AdjacencyList adjList;
|
||||
adjList.insert(adj1);
|
||||
adjList.insert(adj2);
|
||||
|
||||
auto testTimePoint = ndn::time::system_clock::now() + ndn::time::seconds(3600);
|
||||
|
||||
AdjLsa lsa("router1", 12, testTimePoint, adjList.size(), adjList);
|
||||
|
||||
std::ostringstream os;
|
||||
os << lsa;
|
||||
|
||||
std::string EXPECTED_OUTPUT =
|
||||
" ADJACENCY LSA:\n"
|
||||
" Origin Router : /router1\n"
|
||||
" Sequence Number : 12\n"
|
||||
" Expires in : 3599999 milliseconds\n"
|
||||
" Adjacent(s):\n"
|
||||
" Adjacent 0: (name=/adjacent1, uri=://, cost=10)\n"
|
||||
" Adjacent 1: (name=/adjacent2, uri=://, cost=10)\n";
|
||||
|
||||
BOOST_CHECK_EQUAL(os.str(), EXPECTED_OUTPUT);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestInitializeFromContent)
|
||||
{
|
||||
//Adj LSA
|
||||
Adjacent adj1("adjacent1");
|
||||
Adjacent adj2("adjacent2");
|
||||
|
||||
adj1.setStatus(Adjacent::STATUS_ACTIVE);
|
||||
adj2.setStatus(Adjacent::STATUS_ACTIVE);
|
||||
|
||||
//If we don't do this the test will fail
|
||||
//Adjacent has default cost of 10 but no default
|
||||
//connecting face URI, so initializeFromContent fails
|
||||
adj1.setFaceUri(ndn::FaceUri("udp://10.0.0.1"));
|
||||
adj2.setFaceUri(ndn::FaceUri("udp://10.0.0.2"));
|
||||
|
||||
AdjacencyList adjList;
|
||||
adjList.insert(adj1);
|
||||
adjList.insert(adj2);
|
||||
|
||||
auto testTimePoint = ndn::time::system_clock::now();
|
||||
|
||||
AdjLsa adjlsa1("router1", 1, testTimePoint, adjList.size(), adjList);
|
||||
AdjLsa adjlsa2(adjlsa1.wireEncode());
|
||||
BOOST_CHECK(adjlsa1.isEqualContent(adjlsa2));
|
||||
|
||||
//Name LSA
|
||||
ndn::Name s1{"name1"};
|
||||
ndn::Name s2{"name2"};
|
||||
NamePrefixList npl1{s1, s2};
|
||||
|
||||
NameLsa nlsa1("router1", 1, testTimePoint, npl1);
|
||||
NameLsa nlsa2(nlsa1.wireEncode());
|
||||
BOOST_CHECK_EQUAL(nlsa1.wireEncode(), nlsa2.wireEncode());
|
||||
|
||||
//Coordinate LSA
|
||||
std::vector<double> angles = {30, 40.0};
|
||||
CoordinateLsa clsa1("router1", 12, testTimePoint, 2.5, angles);
|
||||
CoordinateLsa clsa2(clsa1.wireEncode());
|
||||
BOOST_CHECK_EQUAL(clsa1.wireEncode(), clsa2.wireEncode());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(OperatorEquals)
|
||||
{
|
||||
NameLsa lsa1;
|
||||
NameLsa lsa2;
|
||||
ndn::Name name1("/ndn/test/name1");
|
||||
ndn::Name name2("/ndn/test/name2");
|
||||
ndn::Name name3("/ndn/some/other/name1");
|
||||
|
||||
lsa1.addName(name1);
|
||||
lsa1.addName(name2);
|
||||
lsa1.addName(name3);
|
||||
|
||||
lsa2.addName(name1);
|
||||
lsa2.addName(name2);
|
||||
lsa2.addName(name3);
|
||||
|
||||
BOOST_CHECK(lsa1.isEqualContent(lsa2));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(NameLsaUpdate)
|
||||
{
|
||||
NameLsa knownNameLsa;
|
||||
knownNameLsa.m_originRouter = ndn::Name("/yoursunny/_/%C1.Router/dal");
|
||||
knownNameLsa.m_seqNo = 2683;
|
||||
knownNameLsa.setExpirationTimePoint(ndn::time::system_clock::now() + 3561_ms);
|
||||
knownNameLsa.addName("/yoursunny/_/dal");
|
||||
knownNameLsa.addName("/ndn");
|
||||
|
||||
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");
|
||||
ndn::Name addedName1("/yoursunny/video/ndn-dpdk_acmicn20_20200917");
|
||||
ndn::Name addedName2("/yoursunny/pushups");
|
||||
nlsa->addName(addedName1);
|
||||
nlsa->addName(addedName2);
|
||||
|
||||
auto [updated, namesToAdd, namesToRemove] = knownNameLsa.update(rcvdLsa);
|
||||
|
||||
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);
|
||||
BOOST_CHECK(it != namesToAdd.end());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
} // namespace test
|
||||
} // namespace nlsr
|
||||
+9
-24
@@ -50,20 +50,6 @@ public:
|
||||
face.sentInterests.clear();
|
||||
}
|
||||
|
||||
void
|
||||
areNamePrefixListsEqual(NamePrefixList& lhs, NamePrefixList& rhs)
|
||||
{
|
||||
auto lhsList = lhs.getNames();
|
||||
auto rhsList = rhs.getNames();
|
||||
BOOST_REQUIRE_EQUAL(lhsList.size(), rhsList.size());
|
||||
|
||||
auto i = lhsList.begin();
|
||||
auto j = rhsList.begin();
|
||||
for (; i != lhsList.end(); ++i, ++j) {
|
||||
BOOST_CHECK_EQUAL(*i, *j);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
isFirstNameLsaEqual(const Lsdb& otherLsdb)
|
||||
{
|
||||
@@ -110,7 +96,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face;
|
||||
ndn::DummyClientFace face;
|
||||
ConfParameter conf;
|
||||
DummyConfFileProcessor confProcessor;
|
||||
Lsdb lsdb;
|
||||
@@ -150,7 +136,7 @@ BOOST_AUTO_TEST_CASE(LsdbSync)
|
||||
auto deadline = ndn::time::steady_clock::now() + ndn::time::seconds(LSA_REFRESH_TIME_MAX);
|
||||
|
||||
// Simulate an LSA interest timeout
|
||||
lsdb.onFetchLsaError(ndn::util::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT, "Timeout",
|
||||
lsdb.onFetchLsaError(ndn::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT, "Timeout",
|
||||
oldInterestName, 0, deadline, interestName, oldSeqNo);
|
||||
advanceClocks(10_ms);
|
||||
|
||||
@@ -184,7 +170,7 @@ BOOST_AUTO_TEST_CASE(LsdbSync)
|
||||
interests.clear();
|
||||
|
||||
// Simulate an LSA interest timeout where the sequence number is outdated
|
||||
lsdb.onFetchLsaError(ndn::util::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT, "Timeout",
|
||||
lsdb.onFetchLsaError(ndn::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT, "Timeout",
|
||||
oldInterestName, 0, deadline, interestName, oldSeqNo);
|
||||
advanceClocks(10_ms);
|
||||
|
||||
@@ -211,7 +197,7 @@ BOOST_AUTO_TEST_CASE(LsdbSegmentedData)
|
||||
lsdb.installLsa(nameLsa);
|
||||
|
||||
// Create another Lsdb and expressInterest
|
||||
ndn::util::DummyClientFace face2(m_io, m_keyChain, {true, true});
|
||||
ndn::DummyClientFace face2(m_io, m_keyChain, {true, true});
|
||||
face.linkTo(face2);
|
||||
|
||||
ConfParameter conf2(face2, m_keyChain);
|
||||
@@ -256,11 +242,11 @@ BOOST_AUTO_TEST_CASE(SegmentLsaData)
|
||||
ndn::Name interestName("/localhop/ndn/nlsr/LSA/site/%C1.Router/this-router/NAME/");
|
||||
interestName.appendNumber(seqNo);
|
||||
|
||||
ndn::util::DummyClientFace face2(m_io, m_keyChain, {true, true});
|
||||
ndn::DummyClientFace face2(m_io, m_keyChain, {true, true});
|
||||
face.linkTo(face2);
|
||||
|
||||
auto fetcher = ndn::util::SegmentFetcher::start(face2, ndn::Interest(interestName),
|
||||
ndn::security::getAcceptAllValidator());
|
||||
auto fetcher = ndn::SegmentFetcher::start(face2, ndn::Interest(interestName),
|
||||
ndn::security::getAcceptAllValidator());
|
||||
fetcher->onComplete.connect([&expectedDataContent] (ndn::ConstBufferPtr bufferPtr) {
|
||||
ndn::Block block(bufferPtr);
|
||||
BOOST_CHECK_EQUAL(expectedDataContent, block);
|
||||
@@ -344,7 +330,6 @@ BOOST_AUTO_TEST_CASE(InstallNameLsa)
|
||||
NamePrefixList& nameList = std::static_pointer_cast<NameLsa>(lsdb.findLsa(otherRouter, Lsa::Type::NAME))->getNpl();
|
||||
|
||||
BOOST_CHECK_EQUAL(nameList, prefixes);
|
||||
//areNamePrefixListsEqual(nameList, prefixes);
|
||||
|
||||
// Add a prefix: name3
|
||||
ndn::Name name3("/ndn/name3");
|
||||
@@ -357,7 +342,7 @@ BOOST_AUTO_TEST_CASE(InstallNameLsa)
|
||||
BOOST_CHECK_EQUAL(nameList, prefixes);
|
||||
|
||||
// Remove a prefix: name2
|
||||
prefixes.remove(name2);
|
||||
prefixes.erase(name2);
|
||||
|
||||
NameLsa removeLsa(otherRouter, 3, MAX_TIME, prefixes);
|
||||
lsdb.installLsa(std::make_shared<NameLsa>(removeLsa));
|
||||
@@ -367,7 +352,7 @@ BOOST_AUTO_TEST_CASE(InstallNameLsa)
|
||||
|
||||
// Add and remove a prefix: add name2, remove name3
|
||||
prefixes.insert(name2);
|
||||
prefixes.remove(name3);
|
||||
prefixes.erase(name3);
|
||||
|
||||
NameLsa addAndRemoveLsa(otherRouter, 4, MAX_TIME, prefixes);
|
||||
lsdb.installLsa(std::make_shared<NameLsa>(addAndRemoveLsa));
|
||||
|
||||
+83
-136
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -27,20 +27,84 @@ namespace test {
|
||||
BOOST_AUTO_TEST_SUITE(TestNpl)
|
||||
|
||||
/*
|
||||
The NamePrefixList can have names inserted and removed from it.
|
||||
The NamePrefixList will provide a container of all the names it has,
|
||||
without the sources for those names.
|
||||
|
||||
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(NplSizeAndRemove)
|
||||
BOOST_AUTO_TEST_CASE(Ctor_Insert_Size_GetNames_GetSources)
|
||||
{
|
||||
ndn::Name a{"testname"};
|
||||
ndn::Name b{"name"};
|
||||
ndn::Name name1{"/ndn/test/prefix1"};
|
||||
ndn::Name name2{"/ndn/test/prefix2"};
|
||||
ndn::Name name3{"/ndn/test/prefix3"};
|
||||
std::list<ndn::Name> expectedNames{name1, name2, name3};
|
||||
|
||||
NamePrefixList npl1{a, b};
|
||||
NamePrefixList list1{name1, name2, name3};
|
||||
BOOST_CHECK_EQUAL(list1.size(), 3);
|
||||
BOOST_TEST(list1.getNames() == expectedNames, boost::test_tools::per_element());
|
||||
|
||||
BOOST_CHECK_EQUAL(npl1.size(), 2);
|
||||
std::vector<std::string> sources1{"static", "readvertise"};
|
||||
std::vector<std::string> sources2{"static", "nlsrc"};
|
||||
std::vector<std::string> sources3{"static"};
|
||||
|
||||
npl1.remove(b);
|
||||
NamePrefixList list2;
|
||||
auto list2InsertNameSources = [&] (const ndn::Name& name, ndn::span<const std::string> sources) {
|
||||
for (const auto& source : sources) {
|
||||
list2.insert(name, source);
|
||||
}
|
||||
};
|
||||
list2InsertNameSources(name1, sources1);
|
||||
list2InsertNameSources(name2, sources2);
|
||||
list2InsertNameSources(name3, sources3);
|
||||
BOOST_CHECK_EQUAL(list2.size(), 3);
|
||||
BOOST_TEST(list2.getNames() == expectedNames, boost::test_tools::per_element());
|
||||
|
||||
BOOST_CHECK_EQUAL(npl1.size(), 1);
|
||||
std::sort(sources1.begin(), sources1.end());
|
||||
std::sort(sources2.begin(), sources2.end());
|
||||
std::sort(sources3.begin(), sources3.end());
|
||||
BOOST_TEST(list2.getSources(name1) == sources1, boost::test_tools::per_element());
|
||||
BOOST_TEST(list2.getSources(name2) == sources2, boost::test_tools::per_element());
|
||||
BOOST_TEST(list2.getSources(name3) == sources3, boost::test_tools::per_element());
|
||||
|
||||
auto noSources = list2.getSources("/not/a/prefix");
|
||||
BOOST_CHECK_EQUAL(noSources.size(), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
The NamePrefixList can have names inserted and removed from it.
|
||||
|
||||
The NamePrefixList will not delete a name as long as it at least one
|
||||
source.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(Insert_Erase)
|
||||
{
|
||||
ndn::Name name1{"/ndn/test/prefix1"};
|
||||
ndn::Name name2{"/ndn/test/prefix2"};
|
||||
|
||||
NamePrefixList list;
|
||||
BOOST_CHECK_EQUAL(list.insert(name2), true);
|
||||
BOOST_CHECK_EQUAL(list.size(), 1);
|
||||
BOOST_CHECK_EQUAL(list.insert(name2), false);
|
||||
|
||||
list.insert(name1, "nlsr.conf");
|
||||
BOOST_CHECK_EQUAL(list.size(), 2);
|
||||
list.insert(name1, "readvertise");
|
||||
list.insert(name1, "prefix-update");
|
||||
BOOST_CHECK_EQUAL(list.size(), 2);
|
||||
list.erase(name1, "prefix-update");
|
||||
BOOST_CHECK_EQUAL(list.size(), 2);
|
||||
|
||||
BOOST_TEST(list.getSources(name1) == (std::set<std::string>{"nlsr.conf", "readvertise"}),
|
||||
boost::test_tools::per_element());
|
||||
|
||||
BOOST_CHECK_EQUAL(list.erase(name2), true);
|
||||
BOOST_CHECK_EQUAL(list.erase(name2), false);
|
||||
|
||||
list.erase(name1, "nlsr.conf");
|
||||
list.erase(name1, "readvertise");
|
||||
BOOST_CHECK_EQUAL(list.size(), 0);
|
||||
BOOST_CHECK_EQUAL(list.getSources(name1).size(), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -53,136 +117,19 @@ BOOST_AUTO_TEST_CASE(OperatorEquals)
|
||||
ndn::Name name2("/ndn/test/name2");
|
||||
ndn::Name name3("/ndn/some/other/name1");
|
||||
NamePrefixList list1{name1, name2, name3};
|
||||
NamePrefixList list2{name1, name2, name3};
|
||||
|
||||
NamePrefixList list2;
|
||||
BOOST_CHECK_NE(list1, list2);
|
||||
|
||||
list2.insert(name1);
|
||||
list2.insert(name1, "A1");
|
||||
list2.insert(name2, "B0");
|
||||
list2.insert(name2, "B1");
|
||||
list2.insert(name3, "C0");
|
||||
BOOST_CHECK_EQUAL(list1, list2);
|
||||
}
|
||||
|
||||
/*
|
||||
The NamePrefixList will provide a container of all the names it has,
|
||||
without the sources for those names.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(GetNames)
|
||||
{
|
||||
const ndn::Name name1{"/ndn/test/prefix1"};
|
||||
const ndn::Name name2{"/ndn/test/prefix2"};
|
||||
const ndn::Name name3{"/ndn/test/prefix3"};
|
||||
NamePrefixList list{name1, name2, name3};
|
||||
|
||||
std::vector<ndn::Name> referenceNames{name1, name2, name3};
|
||||
|
||||
auto names = list.getNames();
|
||||
BOOST_REQUIRE_EQUAL(names.size(), 3);
|
||||
// Verify that all of the names are in the list.
|
||||
for (const auto& name : names) {
|
||||
bool didMatch = false;
|
||||
for (const auto& referenceName : referenceNames) {
|
||||
didMatch = didMatch || (name == referenceName);
|
||||
}
|
||||
BOOST_CHECK(didMatch);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
The NamePrefixList will count the number of sources for a given
|
||||
name, with zero for a non-existent name.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(CountSources)
|
||||
{
|
||||
const ndn::Name name1{"/ndn/test/prefix1"};
|
||||
const ndn::Name invalidName{"/not/a/prefix"};
|
||||
NamePrefixList list;
|
||||
list.insert(name1, "nlsr.conf");
|
||||
list.insert(name1, "readvertise");
|
||||
list.insert(name1, "prefix-update");
|
||||
|
||||
BOOST_CHECK_EQUAL(list.countSources(name1), 3);
|
||||
BOOST_CHECK_EQUAL(list.countSources(invalidName), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
NamePrefixList list;
|
||||
const ndn::Name name1{"/ndn/test/prefix1"};
|
||||
const ndn::Name invalidName{"/not/a/prefix"};
|
||||
|
||||
list.insert(name1, "nlsr.conf");
|
||||
list.insert(name1, "readvertise");
|
||||
list.insert(name1, "prefix-update");
|
||||
std::vector<std::string> referenceSources{"nlsr.conf", "readvertise", "prefix-update"};
|
||||
|
||||
const std::vector<std::string> sources = list.getSources(name1);
|
||||
BOOST_REQUIRE_EQUAL(list.countSources(name1), 3);
|
||||
for (const auto& source : sources) {
|
||||
bool didMatch = false;
|
||||
for (const auto& referenceSource : referenceSources) {
|
||||
didMatch = didMatch || (source == referenceSource);
|
||||
}
|
||||
BOOST_CHECK(didMatch);
|
||||
}
|
||||
|
||||
std::vector<std::string> noSources = list.getSources(invalidName);
|
||||
BOOST_REQUIRE_EQUAL(noSources.size(), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
The NamePrefixList will not delete a name as long as it at least one
|
||||
source.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(RemainingSourcesAfterRemoval)
|
||||
{
|
||||
NamePrefixList list;
|
||||
const ndn::Name name1{"/ndn/test/prefix1"};
|
||||
list.insert(name1, "nlsr.conf");
|
||||
list.insert(name1, "readvertise");
|
||||
list.insert(name1, "prefix-update");
|
||||
|
||||
list.remove(name1, "prefix-update");
|
||||
|
||||
std::vector<std::string> referenceSources{"nlsr.conf", "readvertise", "prefix-update"};
|
||||
const std::vector<std::string> sources = list.getSources(name1);
|
||||
BOOST_REQUIRE_EQUAL(list.countSources(name1), 2);
|
||||
for (const auto& source : sources) {
|
||||
bool didMatch = false;
|
||||
for (const auto& referenceSource : referenceSources) {
|
||||
didMatch = didMatch || (source == referenceSource);
|
||||
}
|
||||
BOOST_CHECK(didMatch);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(BraceInitializerCtors)
|
||||
{
|
||||
const ndn::Name name1{"/ndn/test/prefix1"};
|
||||
const ndn::Name name2{"/ndn/test/prefix2"};
|
||||
const ndn::Name name3{"/ndn/test/prefix3"};
|
||||
std::list<ndn::Name> testList{name1, name2, name3};
|
||||
|
||||
const std::vector<std::string> sources1{"static", "readvertise"};
|
||||
const std::vector<std::string> sources2{"static", "nlsrc"};
|
||||
const std::vector<std::string> sources3{"static"};
|
||||
|
||||
NamePrefixList list1{name1, name2, name3};
|
||||
auto list = list1.getNames();
|
||||
BOOST_CHECK_EQUAL(list1.size(), 3);
|
||||
BOOST_CHECK(testList == list);
|
||||
|
||||
NamePrefixList list2{ NamePrefixList::NamePair{name1, sources1},
|
||||
NamePrefixList::NamePair{name2, sources2}, NamePrefixList::NamePair{name3, sources3} };
|
||||
auto name1Sources = list2.getSources(name1);
|
||||
BOOST_CHECK(sources1 == name1Sources);
|
||||
auto name2Sources = list2.getSources(name2);
|
||||
BOOST_CHECK(sources2 == name2Sources);
|
||||
auto name3Sources = list2.getSources(name3);
|
||||
BOOST_CHECK(sources3 == name3Sources);
|
||||
|
||||
const std::vector<ndn::Name> namesVector{name1, name2, name3};
|
||||
NamePrefixList list3(namesVector);
|
||||
BOOST_CHECK(list1 == list3);
|
||||
list2.erase(name3, "C0");
|
||||
BOOST_CHECK_NE(list1, list2);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
+2
-2
@@ -99,7 +99,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace m_face{m_io, m_keyChain, {true, true}};
|
||||
ndn::DummyClientFace m_face{m_io, m_keyChain, {true, true}};
|
||||
};
|
||||
|
||||
class NlsrFixture : public MockNfdMgmtFixture
|
||||
@@ -138,7 +138,7 @@ public:
|
||||
AdjacencyList& neighbors;
|
||||
uint32_t nSuccessCallbacks;
|
||||
uint32_t nFailureCallbacks;
|
||||
ndn::util::signal::ScopedConnection connection;
|
||||
ndn::signal::ScopedConnection connection;
|
||||
};
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(TestNlsr, NlsrFixture)
|
||||
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face;
|
||||
ndn::DummyClientFace face;
|
||||
ConfParameter conf;
|
||||
DummyConfFileProcessor confProcessor;
|
||||
Nlsr nlsr;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face;
|
||||
ndn::DummyClientFace face;
|
||||
ConfParameter conf;
|
||||
DummyConfFileProcessor confProcessor;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "tests/test-common.hpp"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/mp11/list.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
@@ -87,7 +88,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face;
|
||||
ndn::DummyClientFace face;
|
||||
ConfParameter conf;
|
||||
DummyConfFileProcessor confProcessor;
|
||||
|
||||
@@ -97,8 +98,10 @@ public:
|
||||
uint64_t nameLsaSeqNoBeforeInterest;
|
||||
};
|
||||
|
||||
typedef boost::mpl::vector<update::NfdRibRegisterCommand,
|
||||
update::NfdRibUnregisterCommand> Commands;
|
||||
using Commands = boost::mp11::mp_list<
|
||||
update::NfdRibRegisterCommand,
|
||||
update::NfdRibUnregisterCommand
|
||||
>;
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(TestNfdRibCommandProcessor, NfdRibCommandProcessorFixture)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face;
|
||||
ndn::DummyClientFace face;
|
||||
|
||||
ndn::Name siteIdentityName;
|
||||
ndn::security::pib::Identity siteIdentity;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, The University of Memphis,
|
||||
* Copyright (c) 2014-2023, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face;
|
||||
ndn::DummyClientFace face;
|
||||
ndn::Name siteIdentityName, routerIdName;
|
||||
ndn::security::pib::Identity siteIdentity, routerId;
|
||||
|
||||
|
||||
+8
-10
@@ -1,6 +1,6 @@
|
||||
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
"""
|
||||
Copyright (c) 2014-2022, The University of Memphis
|
||||
Copyright (c) 2014-2023, The University of Memphis
|
||||
Regents of the University of California
|
||||
|
||||
This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -21,12 +21,10 @@ NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
top = '..'
|
||||
|
||||
def build(bld):
|
||||
bld.objects(target='unit-test-objects',
|
||||
source=bld.path.ant_glob('**/*.cpp', excl=['main.cpp']),
|
||||
use='nlsr-objects')
|
||||
|
||||
bld.program(target='../unit-tests-nlsr',
|
||||
name='unit-tests-nlsr',
|
||||
source='main.cpp',
|
||||
use='unit-test-objects',
|
||||
install_path=None)
|
||||
bld.program(
|
||||
target=f'{top}/unit-tests-nlsr',
|
||||
name='unit-tests-nlsr',
|
||||
source=bld.path.ant_glob('**/*.cpp'),
|
||||
use='BOOST_TESTS nlsr-objects',
|
||||
includes=top,
|
||||
install_path=None)
|
||||
+2
-2
@@ -334,7 +334,7 @@ Nlsrc::fetchFromLsdb(const ndn::Name::Component& datasetType,
|
||||
name.append(datasetType);
|
||||
ndn::Interest interest(name);
|
||||
|
||||
auto fetcher = ndn::util::SegmentFetcher::start(m_face, interest, *m_validator);
|
||||
auto fetcher = ndn::SegmentFetcher::start(m_face, interest, *m_validator);
|
||||
fetcher->onComplete.connect(std::bind(&Nlsrc::onFetchSuccess<T>, this, _1, recordLsa));
|
||||
fetcher->onError.connect(std::bind(&Nlsrc::onTimeout, this, _1, _2));
|
||||
}
|
||||
@@ -363,7 +363,7 @@ Nlsrc::fetchFromRt(const std::function<void(const T&)>& recordDataset)
|
||||
name.append(RT_SUFFIX);
|
||||
ndn::Interest interest(name);
|
||||
|
||||
auto fetcher = ndn::util::SegmentFetcher::start(m_face, interest, *m_validator);
|
||||
auto fetcher = ndn::SegmentFetcher::start(m_face, interest, *m_validator);
|
||||
fetcher->onComplete.connect(std::bind(&Nlsrc::onFetchSuccess<T>, this, _1, recordDataset));
|
||||
fetcher->onError.connect(std::bind(&Nlsrc::onTimeout, this, _1, _2));
|
||||
}
|
||||
|
||||
@@ -32,13 +32,13 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import os, sys, inspect
|
||||
|
||||
VERSION="2.0.24"
|
||||
REVISION="c88b74123ce8b9d1a27999f7cf96dff0"
|
||||
GIT="c140c3f538c4a21f3d88bab9403b42c696759dcb"
|
||||
VERSION="2.0.26"
|
||||
REVISION="bbbe549153f90c006795714355b81761"
|
||||
GIT="ad7b733fc60852f77eff200b79e8b6f9562494d2"
|
||||
INSTALL=''
|
||||
C1='#/'
|
||||
C1='#-'
|
||||
C2='#*'
|
||||
C3='#('
|
||||
C3='#%'
|
||||
cwd = os.getcwd()
|
||||
join = os.path.join
|
||||
|
||||
@@ -168,6 +168,6 @@ if __name__ == '__main__':
|
||||
Scripting.waf_entry_point(cwd, VERSION, wafdir)
|
||||
|
||||
#==>
|
||||
#BZh91AY&SY¾¦§#(Ê)ÿÿ°#(Xÿÿÿÿÿÿÿÿÿÿÿe (Â(€0�Í0íŒb÷Ûë}¼ç°#(#(#(#(#(#(#(#(#(#(#(#(#(#(#(#(#(#(#(#(#(7n†•F°Š#*öÛ#(êR¢�§�šž¾ûÝ$Š¢—ÒšJëH«ÕÖWÕ¬e!-fg÷ŸOy0�vÕÒè¶û³Š”4l½ÛÍî`‹¬=!ëFÙï÷½ˆR³í„HöÑs;Á÷_º½h± ôéïcÝ÷ž÷£ &Þ6æêÏ_|Ãëos·pÝÜ›Î#(=#(¶CA;#(ðuN#(O #(îÕ³—Ø#(ºXhÈÖª”£Ö€#(•¥ìP#(#(%AI#(()"ƒC#( QB¨(¥½ÀéJŠ$C@4PvÇMU@QÛëOV•µô75¤F<û^êØdÝá®{7¶V•Š¥G¶MbR�½uwÑ[ì¾ùÞ”xovÇ$Ú>ïNÂzóÕïxÝv÷kÍ-î»ÖíîwÞåëë“íîùÞž÷v½ò|î¯öù{Þ¯zÚÛº›½ÏHóÝÁ]ÙªnÛbTr‚ª¥ ª( P “{;c“»/xwkCÓÞ4öÊ©"RªlÀƒZ#(¡ ˆ#(Яo@–¥U:;Ë=zÏ0Ûk¶²˜ÛíŸßsuÉôh#()Ñstѽ}Í÷ÚæÒøÎv²ö»{¡^ûÌpzQíÏYà®w>^®ò³¡m�® {�5Þ8‡G@%sœ¨_vÑ÷Šð9]î:Ío=Óïo›ÒeŒkr[u®Ãj×nÖ÷h¨¤sÜ\µ,îî#*pîc3ïš_'«³�Ч\,w°÷>ö÷&¼Ÿ îô¹ã¸QG ¦ko{|5PÍeÞ·rg}<ß]Þû±;{ÝííÌÜV”]Ã[)¯¾ã×–ÛëAîÐì#*'¶ÝŽ�ÝÎîy#(ìò{y{Ãßv´;¶C€à#/(#/ìÊ(QH 5®îçv¢#/ÖÓ-k48ú{Á«½©¶69ÚÀ=»mÜ:™®‹{¼rQ-©]*Ððr\²zî¼#(#(½yv÷p#(Ü9y.C¼Þ_o¸•¾ÖëÖòh¯^íq½fÀú{š{W¥¹¹÷;{²‘óì÷ŸqB#(uB�›³×{·•<9í�æïW›¾íÞç4ø +˜õiåÜ«·kO{ZàQÓÜÛk…7=î}|÷¹ö¤vÛ¤“‹bõOy<}Ý·œ÷]Ý.|^œöÇk›(ìcÈ{1#(=;zâìØ%#/·½Ú‘šƒ«ë^|&éìÍݘÔõïO{Ôº÷¡Ðn�’˜uÕò€QÜÞÆ¶*ºï<cï0UïºÜ膃çß¶ûÜîÝ[Yîîç û¾Óϵô}k@#(t(#*#(^žî›puëqJ®ôâ猺®FwZ{×yÎ}@>\€ô È296fÛÚ{€#(rÞ[¼cÁõ÷Û›#( #(#(@*ÞävîÖÛ#(Fì\{À=#/Ø•êîÑ¥¤»m[U˜#(4#*,íÝ:Òí¡V›`¶Õî®äéÜÁºç$µW“4pºöº|¼|C»Äºûw{ÍóépĈámœû<D½àrª+ÞöìÍ»™ßwp½Tí§Û.{@`æÝ»:ñzãSÞg¨â¾á¦ˆ#(€#( b4i‰‰¢z4zdšj�=F dié�Dɧê›Q %4B#(@ši¢iˆ˜i£HM=C#jdzF™#(#(#(#(#*#(i$Ѐ€†€C ˜�6©šdŒÒšgª~’yOÒ�éå�S@@4#(#(#($õJH¦“hšdOM&™(ü©úiê=@d4h#( £CÔ�h#(#(#(I Ðd#(CE< )ä`€ÈÈž¦$Í5OQ§¤4È#(4õ#(õ=C&Ôõ$D4ÂÑ1ODO%=ˆ©þ”6¨z€É¡ê€#(#(#(#(#(OÿÄÿXRQ?Ù%E„Ö#(”°=%ZïlÄ’ ÄS=êµ×d@HÂ6#(”P2"Œ#(!5TJˆ"ŒŠˆ€ÁõeÏ�ïÀÃ~ˆõÐásã»”ã^�{;]¹Þ©ÞóùÞ×*Ç+ÄÅT?§�ý+ܳ}÷Î@ Ô#/ìW´D$ DN´#(�%tÌë–ï³—xë‹•‡§Ä+š.®±‡‰¶U·¹¨¬U¾"o²«^Øh#(�Àk0DHýœx|Ä/È‚£m–Ó*¬®î¥U¥µX¶™mV5U‹jЍªÚƉA *Ž�"(b Hâ¡`$Dl‚ Ÿ¢*Q,EH’@á@Ì‘B)#/¥VšÛj«}UªÛTÌ™%š†™¦È€š0H¤¨ÛDÌÔ"XÈÔ¥QM´›#/&h$ÐJ2Zš�Q°h[Fi,šH�Ñj2R&Òš #(6�KbÊ›Fˆ¤Ù-¢(JYi¦–ѲÒ4Q™˜Æ¤�F¢Ô&ƒJl†BjcI@˜h²ËHÆR›F¦›"[M¶³jÚ4ÌIc3&d&ˆ“Y6Óm¦›@š’�”–šØËSm™²–“$ÌE@dY14Y( ¦E"FЈTY¤m˜#*X6)6a¥DAR˜ŒFÄ!#/ %ˆ†Dd‘µ"d#K6ÌÐÉ"b”$a™,¬°fbD#*%‘ˆ¥“Y664X¢aE’,¤$hÚSLbJLŠ2‰4dÐÓ2bARQ¤J#I VAM�Eˆ¢fRÒ¦`•ÉØ‰1MÍ‚ab5¤Ø–V‹$”›ˆ‰-%Š#/H“Q "Q ŠEP`&d”Â0™Be$¤ÔY›5„‚“RD“ˆKJl�!E’Ø€“Y”R6d”M”ÈØ‰›")FlŒÁ2©¦$„YJa³Q`,�i¦†Æ"5+%’6(”R"šIˆ&¤a³L�cIˆBI©%”e5LÒ6Цš(šÔ‰–Pi6FB1d¤Èš ¦R%FŒÂfÒ…&5Á™H$$Rf0"Å‚%’a1A$Ê™š³m”¶%3!©Ä)›+(QRE`ŠL’l‘�Œd©¤jf‹#)!I™�LR2³i„¶"0DQ%&š™4Ì‚�ÆQ†ÍSb‹5*R’š)#*‘“2)´…HÅ(ÊHR"‹E$š$“JmMF‘"†˜Ø�Ê�4È›A£c0e�šL£cH™2 ”Ù)LRˆ„,Ó!-fË ¶JÉ`2Hi,˜ÈjŠ ¨$MaH“!�ŒÄƒÊ#*IcQf‘(š1¥4 Qja¡&e&(�Ë&ÈŒ¦ ³F”ÆÔÉ”ˆ�Ñ*´ÖÖŒ(MLÑ”ÈÄÒŠI™ ԦسE˜¤Ò2„²Ê›4EE¦VÊ1!E6"¢&‘Ò›_©µÑ Sz[tD†#6Š1±[±Q²e)¦¢•$Ñ¡¥¤-FÂ6I¨ÚÈŒ5#*3FHÙL©"Ùf&f™l–ÑF%%-FÔRŒša55˜±acR#/e¥™2¤Ú#/�•i*l¡²e‘TªY*aM›ŒÍ[,ˆ“L¬‰S,¦ÖJ²ÙJRÌ‹l�’‘µ)¬±%¤2RÔZ µF$5´d¨(ÕdÖJ6¨¬TT‰F´M2FرF,V£a–�¬l¤É…* 4ÀJ)Ñ£L“JÒØ‹cFÓXŲE�´Aµª–µ–* ”ÍKY4IR1!M¤lY"¶¥Y¶1Jm*–R¦YaZšDF¶•K"e-MM¶„”Êk,Xl²k+,…l³$2£I4E‹Ò`b$H†ÐhLb¶�P”JŠ5EdšhÙ2i(² ,R)²�4lˆ¬² ÆS1(RQ³LÐ1‹L�™´ÚLQÛ!L"šdHQ�”Xi‰#& ±�Ù1 ’f¢�S"”h,²�ª¦#(ÈѤŘJTÍ’QhÈAfmFR�™I%FB�Å”ÛÃi4F5&ÉaH²Âd´PÐX¤3hÑfR¦RRÊVa’±„X²FÄ1©£TlÖŒÑ#*”¤ØiŠ–6̤µŒ„™c ÓbJ’¤ÊT¦˜Ù$2&k Jj5ƒlÃf’ɱšM6b&šQ’Ó#jÈ�4*fˆK#/$I6Q”š5M#b�5šM’˜…‰ˆšJHH-‹a*5Š1XÅ£2Øi0ÒI¡BÉ‘±ŠQlQ°% ¬ÓbÈfQÅFLl”²’¦D[FЬj�Q&Š,Õ( “Rj�A“BÂ1ªR†Ö6ƒJi–BŠ4IL’Ñj‹b2•¶EJ*‹cI‚"É¢)™BÔ¢�Ì”ISbQ*ÔF¬*dlY5FÅšQl™+Ö“•”Û"[&ÆÐÑ*ILƒ)Qa`ØØÙ(Ù4IˆÄm’$5“0A«2`ÐB£Jl͉ˆ¦±µ2²m™BšI¨ Š(¢Pµ%bÙI,l˜Š4PF“IZ‘-,´mµZ-QV2”m&¶DµcRQb‘M ‘LŒÈÌi©‰CS6IšÑIbÚ5%K*É6¤[ˆ(ØØÉQLªi[Fѱ¶Æ+Rf2”BY¬¬KQŠÅšTmDm*TR•¥Š„i¤ ²�£E‚$¨Òm�bÌ©"´•±dÛ)2´hÖ!¦-˜Ñ´jÛeµb‘2¡Q1%І4lSI6¦É6Ѷ-±iš¶ŒkYi*he”²m©©¶BÚ“MXš2Š"4dm$¢ƒa¬Ôš™™²ÍDP!Q&$“)&Ddb2¶Kh³-³ê}ŸÍ÷êßkŸÊ™ÍfÿÈ™�òÍ*“k…Šñ#q=Ÿ´ò�ã �td!ïPÂ6#%êŠ�wå߯¸ÏõMÐûÌ}ÀÍüœ½*#*MŸ$ç®Ûù¾v3ZÏöÿ¶š“Xƒ-Z–ŸÉžÌȰÿ³?Ùò2C¶›¢‚{~ûÞ�Ya€„íÁ¨e“´%¶�´Š½Z?7å÷þœíúÿÚµ?êÿÖ3ŸóÿÙ÷Îÿï*Æ{íÔøå7à\¥©ù7Œ?äË:_fh@!™·Û,b÷PŸ¢Lë¼9Âs,ã™cmöÜÇïC˜YPð“ÕÏû¯£‡†É昆"*jµÌ3¤±MK¬(£óa\Œ–#rѳj]uDÆ#[R'ýׯ?¬Îjäl>N×2Vù3tœTùoY8…b©XJ‘I"F)ž™ŽPÚ¶T`"ot•¥€¬¾#*Ë#7¦æ�ÉJ#*ÍÀÔÛA¾™2<_ý¼0?ÔÀ=CÏ%cDh³åt\×ÊדGŽX_Ob ‰"‹(#úé¦<}Yô}_‡/B|ÞÜE5…q#/‹'×Û…Ãèi"Íêþ>*�¬ŠGy’'½$®¿««›Cþ‘‡ÍÂÒL&B E¼¿™ñÿjºèËf;¨„ž&óúúÓPЧ¼°9ÌÅ2ÔfíÞw^ls—EÜS+›t²Š¹·^;llOÃuòÍoEˆ¨5ù»©óuûjñ}‹r)•ðr-±¹ré·Z¿KÓÅÍÂý{çÀ….ÓáðÝ(÷ÔvîXTé5ã¶«„ürÈtñãÓ$•d6•Ö ³Þøêº[aPë—Ä+:B°Zƒ‰®¹]çv7(é\¹’%-kX‹äüØI4ÚûGúK‡„¤ð”V)¢–DXh…hϳÆñÞ“Øf+#/þzUÌ“¯éi½_3/î~\�éõAÿ¶•=_‡Xb¬@Gl?õPÐdåЧ‡ûéÛu%]ößæØ¼ ™ZúÙ*3>¥(q’K!1âìý5#*ƒÛ_#¨½·xírH ̦‡âÔŠŠbàâY˜¸ìk—â~Ý0î¶ùf'NÆTö{gÍ:dò'„‘ÉýÐû&¤Ï<§^¹ŠËƒøqÑ3 Há;"迹¶ÜÔHÆefE…z•�„H,BB{#ƒ,ú'¢s¦ÁIÓN‹÷&áTø³á¶…ΨúôaŒãVOƒUëJ±Þ{æÿ3ûvÏŠ¼d_�tðš[A'ïÜÈ5*2,vÙŸj`cíKÇÑúm#*¶(Úus?æCç¶k•£þ†‘XÄb‚{ÒŸu(²1èýT0CÓ—ÆËÛñDp`šYEQ:kÓ3hìZ*±�Mõ²çŽ®Ÿ{/eÿ7Êœ^ê…‚€ª(«ž7‹&£xÚ¹¶¿‹÷;Éìh1�âí¡F+áöÿåÊE#º·6”0}äùµé¬„c”ÔR|�Û•ÞîªÝ7NmȾ¹@Á:Ol¼Jœ¼Jª ¥aSEl^»òo^¯"šU’¡íw,Z+î–ëÝØü�q�QBoš�w³z¶‹JÅ‘H,ˆÉåù3µ’ßc F‹>Eôùï+òúïÅïðÃA“òK6²V°={²b?ÑaíîPÔF19{ö“PAþfÇ𤖠¬E„FO¢‡ÊÐ=L¢Ô—áçÖ™e�sF¾yÕÉ˦9[âñ"},!ïÝ|Òt~j{>=•”E&[‰_#*[õ¸²9û.)ötUôû/Ùã3¯¦XEFžJQO;Äí©I[ÕéyHUØY<)¨œâT`æ7s•–^™#/"Ÿ*Yû�¾¾¸ÅQXLine truncated
|
||||
#BZh91AY&SY´¡#-bþÿÿÿ°#%Pÿÿÿÿÿÿÿÿÿÿÿeà(Â(€0�Í0ç„bœ÷*É#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%﮾�y”¬š¶²Ã·ÜÒöÛ*h5ÛtiïnÓk4:y®ï=¶l±}k³§S¼ç^ó»Y+ۮѶ'ËßWß. ½µ—vÝí£]÷»·½Û˜ouÞ½ítï{ݳR7[=fQ#%·Î÷MY=užëÁ÷¼ù÷Ó¥ÐgÛªº<¹�¹ï|÷¾ûãÐ*Ûá{E÷»¥0ØÝÝ[ï{Ýï#%#%#%#%(t± #%}Ù@ðl˘§¯)Þçz¥;ß{^f�[V€#%·¹\:ÝÓÑè=¶è:�€¬…zÕ£M¬Ž#%¤€!J#%^°ªJ¢¡ #%ž½ÔP)¶è=ïç�yëGÛ¸ö¤÷®LĻ»™¨:r•QÛ-Û‰Jkºkéíts×ÞÞ#%[ÝØž•®}7±£ÛÏ['›{ÎãÔžÙë§ooµÞwÎßzë|ínàÝ®ùîöm²·ßQ»¶ûž9÷ß{}‡ }#-«é {¥#-!zbºi*¶Öì»2jž·tÞwsÖâ`uÒºn7`ÇlëRD¤S·�FSÖ€(©#%R© Ñà#*e…{7yÀ;[Lí½ƒJWÜÞ÷W¾}÷Íöõ¤Š#%(}Š£m¯_]H}öwÇq@—{»3`:ùÞñí#%¯k·¼1¾G6äê–²¾Þ¼+Þsí]Ûº=\w™è£ïqÒ…é;8ë�ݵôî×å—Ðû–ÕbßWtwnºn6‘Û]îÞÖÓÛ9¹¸ÛŠt]ÝN½áÀí¾³«ÙKb†ƒM2ÂôÝ4öuËxÇ.Ù£›c§¶>ºŸ^çÞÞõ¾#*Jf¶Ù^õÕÈùìõ÷½ÏlÛjÚµ¯säžlÞ�^õ¥z½Ýe^»…ìx÷w½4Á½€š·unï@{¬Ï^î÷‡¾ï¾îvÃËN�#%¨PTTºƒs¹—² Zí•·vn;ì§¼ôêôyŽ.vm%zWtî;jªœžÜ{̤\îÍŽõŽ»cÀ#%Üêr#%#-ƒ½Ç,Žï#G2‘�EÛ6vtk¯»8Ö‡Ú•ÎhÍÝvZFÇÞçªÐzùö}>Ÿæš3e\+ˆ4ÁÎæ¾ØóÛÞú9é™×>J´k»#*½Ó=^»£Ä÷pkÜž}>©^øiµoš#nòñ÷»™ÌÝlÞï{Þó]îîÞ;�¶Ã_n»Ý绲î>]�ö7n:Ï](E£({u«³Öw½yÒ2ñÞnu¯¶Ê¯–ꔌâõáwÛS·Ÿq#%}jõò®T1Ò“îïo\Ž�ÁŽ•Ým¾sÖ#-½èõí¼êÒº÷Þc6½n¶Ö¾íd‡{ÏóÜúe¥(zÌ÷:š\Gm™ÝÞçl=žÀ¸:hÀÁ�Ø÷�ËÞùöí€÷[È=t#-C½³íeGÜ#%ʸò§¹Ý{é¶{¹¸ØRŠÚ”#--Þá^îÖ]€fzÏxÝÂìÝݺ{]ê¶®j7w[·tÁÙ¥ ª([¶ÝÑM³³'vݲ .‘£™³×=1{XíçzÌkÝ>¾õx‡½óí·³afô|›Ñ‘š;¬â'gn#*kï/s72îûÍÕ·€ò{íéÚÓð;»·ñt¼ôÞOt#*O•ñ³†š #%L€ #%™#%š4Ähž�2'”jž¦™P¡¡ê2)§“& ”Ð!A#% !¤É¡¤i�Iúž¦“L@õ4É¡ê#*€#%#%#%Ð#%‚D!jmÅOÔ@¤ýM¡©åO$ÛRz�)ê<¡²›P#% 4#%#%#%$õJHˆd2i6”Ÿ£Iê�SõCG©£@hz� 4š#%#%#%#%#%#%I #%@dÓM&CFSÑ4›$Ø“SÓÔ5LF 2#%È#%d$ÔD#%#@CB5Sð)±SôÒOi©ê‡¨ôÓ<£M¨#% #%#%“ÿéþmVºäŸèÇ5µ+ôUiæ%$±˜™ê«]vFLV�FÂa ‚,‚ ø@cò?‘�Ëòü\ªªÌWb�âÎf¤êԪƧ™•oupMTº·º§¨"ÿ¾kÞªÍîf‡ógbºDBAû€�dá1¿~ZºUUÓ•‡§O‹Š.®^±‡Œa•E»ÓÌNxγµòË<ê×¶6–DH~~¿æB¸�TвÚeR¹]ªÒ¶Ö+k3kh£[mÚ*Ømb´úŸSÈI£CŠœD 2ЍXˆ�ˆ �‰íŠ”EKƒjUÝÅb¯iµUª·¾µµLÉ�²Q™¨išlˆ £ŠJ�´LÍB%Œ€MJQ¥ÛI°¢f�2M£%©¨Õ…´f’ɤˆÑ-†£%"m) �hÔ±¡�¦,©´hŠM’Ñj"„¥–šim1-!³A0e™ŒjHÔj-A’h4¦Èa&ÍJÃE–ZF0"”Ú54ÙÚmµ–ÖѦ4RÆfLÈM&²m¦ÛM6�5%)–šØËSm™R–“$ÌE@dY14Y( ¦E"FЈTY¤m˜#*X6)6a¥DAR˜ŒFÄ!#- $DC"2HÚ‘2¥ˆ„†Ùš$LR„Œ3 ¥•–ÌH�¤²1²k&ÆÆ‹L"ȲC%”„�Ji‚lII‘FQ&ŒšfLH*J4‰Di$#-È)±¢H±LÊZAÌ£Y!›&)¡™°L,F´•#%’ÊÂ`JM�DD–’Å$I¨„‘(Ø"‘DÁ C!Œ’˜F(L¤”š‹3cF°�RjH’b iM�$"H°[bË2ŠFÌ’‰²™3bdE(Í‘˜&U4Ä�‹)L6j,’#*4ÐØÄF¥d²FÅŠBdSI1Ô€Œ6i�,i1I5$²Œ Æ£IšFÑ@AÓEZ�`12Ê#*&ÈÈEJL‰ še"ThÌ&m(RcPl‰”‚B@E&LÀˆ#–He„Ål“*fjÌQ¶RØ”D̆¤S¤FlhP¬¡EBE`ŠL’l‘�Œd©¤jf‹#)!I™�LR2³i„¶"0DQ%&š™4Ì‚�ÆQ†ÍSb‹5*R’š)#*‘“2)´…HÅ(ÊHR"‹E$š$“JmMF’H¡¦6ÄcA2¢Í2›C(ØÌd&“(ÄXÒ&B̈%6JS¢!4ÈKY²Âm’²X’K&2QT‰¬)d1±˜�aA©,j,Ò%F"Ô¦”#--L4$̤ÅdÙ”Á"–hÒ˜Â(4%“)!¢Ui¶ÖŒ(MLÑ”ÈÄÒŠI™ ԦسE˜¤Ò2‘,²¦ÍQi•…²ŒHQMˆ…(‰¤B4„¦×í¶º!*j‘FŒÚ(ÆÅlVÅFÉ”¦šŠT“F†–�µÙ&£k"0Ô4Ìe#e0¤‹dA˜™še²[E””µQHZ2i„ÔÖbÅ…�H)––dÈJ“h*6U¤h©²„VÉ–ER©d©…6lf35lh²"¶M2²%L²›Y*Ëe)K2-²4JFÔX¦²Ä–�ÉKQj‚Õ�ÔjÑ’ £U“Y(Eb¢¤J5¢h‰’6ňÚ1bµ´mc`-&L(ÁU¦QH&�ÈZdšV–Ä[6˜šÆ-’,m¢mTÚÖX¨d&S55²h’¤bB&›HزEmJ³lb”ÚU,¥LÙaZšDF¶•K"R–¦¦�ˆ[BJe5–,*Y5•–B¶YŠ#-Q¤‰£DX°Í&"Dˆm„Æ!KhÕ @„¨¡“TVI¦�“&’‹"²Å"›)FÈŠË ‰J2™‰B’�šf�ˆ(´Zd„ÈͦÒbŒcll…0Ši�1!F4RQa¦$Œš‚ÄbCd Æ‚IšŠ4ILŠQ ²Ê¨J˜#F“a)S6HME£!Q™µJ6e$”d#*#-CSlDS#*¤ÑÔ›%„PY"ËQ’ÑCAb�ÌI£E™J™IK)Y†JÆYbÉÆ¤Z�Q³Z3DT4jR“a¦*XÛ2“j4 2ÆALM‰*J“(QRšcd�È™¬%)¨Ö#*±(lÒY63I¢ÆÌDÓJ)-26¬ˆÓB¦h�”°¢D�ƒeAÉ£TÒ6(ÑY¤Ù)ˆX˜‰¤¤„‚Ñ´[ Q¨ÔQŠÆ-–ÃI†’M#-L�ŒRˆ#b��-f›C2’#*ŠŒ˜Ù)e%Lˆ¶� #XÕ¢M&Yª(,PA&¤Õƒ&…„cT¥#*¬m”Ó,…h’*™%¢Õ"Äe+lŠ”UÆ“%$Y4E3(Z”R’‰*lC6Dʵ«Š™MFÑ…1f”[&Jŵ¤Å%e6Ȗɱ´4J’S ÊTX@˜65%&‰1�²D†¢’f5fLTiM™±1Ö6¢¦VM³#HSI5„QE…©+ÊIcdÄQ¢‚4˜2JÔˆÑie£he¨’Ñjб”£i5² …¨Û’‹ŠhLŠdfA1¦¤F%#*LÙ&kDlU%�´jJ–U“Z&mH¶5Q±±’*¢™TÒ¶6�£cm�ZLÆRˆK5•‰j1X³J�¨�¥JŠSQ´£1P�4„P4h°D˜Ñ¤ÛÅ™REi+bɶRehÑlCLZ)1£hÚÛeµb‘2¡Q1%І4lSI6¦É6Ѷ-±iš¶ŒkYi*he”²m©©¶BÚ“MXš2Š"4dm!( Øk5&¦ó·fË5@…D˜’L¤™‘ˆÈFÙ-¢Ì¶ÌéùèÜõÿŽWÿ!¶–æïüצ•îAuY�Qɾßè¼§ïÅ›!5gòĬÈê1äKý&Ö8×ùÿÏbƘ5#q’õ/†«"Sþž¢Êg¦E7{«;�Q`D°@\:8À¥‰pÁI ä‚m½È?gëý¯�áçø*‘ÿ7úC?ù}Ö´ÐI(R×+ˆ½”:ଡT #*�šhÿ#*‹npOd›Œ>'o¦#�÷t+œÊ†£÷Xxf¬ZvÄäž2×õ0Õ"M�†É8¡·'%ˆÁþݳf‰Â‹BÑ#-JL`I¥Û"lÆLhƒcöhŽŽz:ì�çt„Æõ˽=*õ/åœîY”ëϱÖg5r 6×1š¼Y¢eS³\ÊÅR˜JH¤‘#‹#*îÛ ÅÊé˜Ö‰I^<ë¶|[•#7¦æ�¾#-`ˆ)œfÃ Š k{—¯ûl°þÖÁÂæS(°R;´)L7acÇ,/ÁÚå%±Å'Ýý¼{8³¹âôÍh'k«b(¦ShR(ü²Jgü÷¹óæ64›ÍT™å£Ç÷î\�þ‘£Ù…áô´hƒc72|OwùsÙ¹´Úû›´›K(áïãFÀ£ÔæíKªFEcšº¢äZi(R©A�sn–CQW6ëÇbM�‰àQ¸È[ ¤Q@U'¾¨4|P´ó[‘L¯‹‘m�Ë�þ‹uköÞ•‘¨Û?ÞT �óóÌ øÚy2ÄFm˜rÆê аXOUÔ†Ž\º2IH#Úrƒxã×”çqá$Da½J2ºæ÷W4j&ºåw�ØÜ£¥ræJ2ëºIæGË}¾[l2ýsúÉNYË ÛMˆ{!chÁ…43ÃleƉÈe«#-û(¥ZM?SF4»K¯©ì̆�+ýTRnÊzieªÀTqPÿ:@û0lþtÕ€¸IK�ž5öâÐ1Ñùha³–Øó2dnˆ«ªQŠÞ¨·Í‘±¶¾6GQ{nöZä‘A™MÅ©J^ݵãúì³Ðü0§É٪ͼMFx|6î‹Cl#(håþû&¤Ï<ν³—ðì�!ñe §&¢”øuûoÑÏKà`÷'nínœšúª‘FÒ!9#c*w&é�CbÛ†ÉòfR6z5\tOã]Á÷ÙJ̱e$):4¨ôRÄGçxû_ž*uW,‹×Z6LT >¼]Á¤¤dXâª_Å”+ñ §Ó÷d‘69#*ËÆÃÛ"Æ›7:cü—XfLRú:ëòuѳ=ïÑAbæ¶Ä^¨�ŒJDѧF\ƒÄám0zpÌï¼îaõ58øOõ½eì_+´TTQW<oMD¶@¦H³í«X>#*¡^41XýÞ?ÅaÙš"‘ª L‚#-Å^›5Èa¬„c”ÔR|;·+½ÝA(e#*2R)ßt‰¢rºÊRdJrÜ‹šå¢¶/]öï^«È„f•d¨{]ËŠýén½Ý�·®1ª4&ùº÷øzÞ)ïÝÑ×1±hÙ6ù_�¼cPi-õºi±>ëv0údøïš`4¾ÖE‘¥h;ëRZ?�C—2ƒŒbfµ³V}èAYö»>ζ졑¬›}]Ñ_ƒºÝî…¤•Ó…—†ˆ‘"˜,6m’è)J´„äÚDî¢Cž´ð¢hzèäíºQL¡—UiNÍ-wÕ¬�üªÔðХ߲œœ²ôî²Á‹¨ÀS�E#-lÃQMZd%7¬çy‚UØXùT¦˜F.´Õ¯½)wQ6zLine truncated
|
||||
#<==
|
||||
#-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCgAdFiEECzlystnjLqtCPS4PIr4MYv+/pUgFAmKKPjIACgkQIr4MYv+/\npUjn+g//e7jdxRv8RZO7ZkxklWuhFzgs31owc+2m7DiJovmBbi3/j6OHVFD6KH5b\nwGpqpbsji1Mj5L384ukPXnuMQSH73kiR4BhqZf5fllhLyNxr+fnGDBV1njwWY0Oo\nK81l5LW4kuPDrXBV+2ztnLJcDrYgZsU3J/L6DEhClwrHL2pL2qdpeZRzCKNnEfJP\nRrtkatTUgKnV+C/gWihzwUQlQbJuJA+qEFsJWrydMyi2d+QkoiqGFl6DWcD9yI++\n0JZ997+zGH4CNmCy1A1BMU2dtOHXQxcmKTwlIg4oSi0zfrbtw9MRr1mzUnVLEZkQ\nxQQykZ4fOT7S8kIMSjdeRUb3Q8SW+DcsSQxSWyQOK+W+oc4Z73d3qnJvciVflqbL\nqmqmTQm0FQN3vB18FbLgHswIw0RBI8/EjwHA6FEnh+f8t9LtN/QCVpPFRGktdAFi\n4A6UNggcawARZuwgvd5ygDOkWMVC0XKH/SjDMgFx+N94tsvmPHFtebYcrQvQA3jy\n12+PpGofCEgyD/KX2vcRWp7S80DQRwkHrXk1W2ED8z9T5BbwUeu+xzl2OkDq/q8X\nZQ8Gc89EjQe1YY7Mq/KCyLel/tsQhgUmTc0p6KBnFna3Ino5sxml7EUYhWAy+D/E\nKT5ifI8/RvdL4zhUNK2xF/VS1b/P9veJEC0xLiVBtFHHiZh9uI4=\n=jb/1\n-----END PGP SIGNATURE-----\n
|
||||
#-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCgAdFiEEjH6y+TsMRfVzL+XRG6xXHc13IpUFAmTW3xEACgkQG6xXHc13\nIpUBBA//X7EWVmGwG3rZIELAPfIre2RAFutwAtZwi10FhwtSSPcQDUW0oMgYgbea\ny8tCMpLXEPpPC2OQQhoxjHrMHu+xZwwKE419fBZjzHCbJ3HCfKa/K8zkJfRhFQgI\nnR4FxsCvWrV7RVoqKucmocGAsoTy4BAuPPo86cQSiAK+baHwP3Oo1O3zedXoXaBc\nJoNO1Fl6ldGSDh4xrcxonF+YomjWXgCy1Vplh2SD97c1SKREMtVpls3u0hUUg00q\nOXqfWT6MSdrAGq1zGTGWVl6/SSiFTlkRQhJfaNlA4uRdfYx37x4wuUhI1+OQpbyM\n6qs7s4pvbLG8t9tMB1onAJW7K92VkYxNjP67AeXuKD1HK9aJFw5xmPa3oIS9Cxly\nFAdoXSB99Y1QPNOgyPHqY0qzWiRyKK3melcsGE3CniKqQUosuzeNzagTY9hN0YwU\nB2DYQX6Yar7VLbaHROtk7KPs0nOnDgEezQZ0ZNdEbJXGv16n3s7QGD0w/e3tI3Ow\nC5vaBIGC/7iwoNmw0+iu//Cczw9Vjl1Ga5o++cpA2KCpwFB6/XC9OjEp3TEuPUf5\nn0p5BLFk3BsrhfGhui/mE+Q08LEFjX1yvWl6zyPEa0Gb9al+scK4uco12MslIV6H\n3GS7C2mrZVe8Mdjquttk1o/OSm7QlZ5Ej3aOlilbhiT6D3p2L1Y=\n=4SRH\n-----END PGP SIGNATURE-----\n
|
||||
@@ -19,8 +19,9 @@ 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/>.
|
||||
"""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
from waflib import Context, Logs, Utils
|
||||
import os, subprocess
|
||||
|
||||
VERSION = '0.7.0'
|
||||
APPNAME = 'nlsr'
|
||||
@@ -71,16 +72,15 @@ def configure(conf):
|
||||
conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.1', '--cflags', '--libs'],
|
||||
uselib_store='NDN_CXX', pkg_config_path=pkg_config_path)
|
||||
|
||||
boost_libs = ['system', 'iostreams', 'filesystem', 'regex']
|
||||
if conf.env.WITH_TESTS:
|
||||
boost_libs.append('unit_test_framework')
|
||||
|
||||
conf.check_boost(lib=boost_libs, mt=True)
|
||||
if conf.env.BOOST_VERSION_NUMBER < 106501:
|
||||
conf.fatal('The minimum supported version of Boost is 1.65.1.\n'
|
||||
conf.check_boost(lib='filesystem', mt=True)
|
||||
if conf.env.BOOST_VERSION_NUMBER < 107100:
|
||||
conf.fatal('The minimum supported version of Boost is 1.71.0.\n'
|
||||
'Please upgrade your distribution or manually install a newer version of Boost.\n'
|
||||
'For more information, see https://redmine.named-data.net/projects/nfd/wiki/Boost')
|
||||
|
||||
if conf.env.WITH_TESTS:
|
||||
conf.check_boost(lib='unit_test_framework', mt=True, uselib_store='BOOST_TESTS')
|
||||
|
||||
if conf.options.with_chronosync:
|
||||
conf.check_cfg(package='ChronoSync', args=['ChronoSync >= 0.5.5', '--cflags', '--libs'],
|
||||
uselib_store='CHRONOSYNC', pkg_config_path=pkg_config_path)
|
||||
@@ -104,7 +104,7 @@ def configure(conf):
|
||||
conf.load('sanitizers')
|
||||
|
||||
conf.define_cond('WITH_TESTS', conf.env.WITH_TESTS)
|
||||
conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/nlsr.conf' % conf.env.SYSCONFDIR)
|
||||
conf.define('DEFAULT_CONFIG_FILE', f'{conf.env.SYSCONFDIR}/ndn/nlsr.conf')
|
||||
# The config header will contain all defines that were added using conf.define()
|
||||
# or conf.define_cond(). Everything that was added directly to conf.env.DEFINES
|
||||
# will not appear in the config header, but will instead be passed directly to the
|
||||
@@ -118,6 +118,7 @@ def build(bld):
|
||||
name='version.hpp',
|
||||
source='src/version.hpp.in',
|
||||
target='src/version.hpp',
|
||||
install_path=None,
|
||||
VERSION_STRING=VERSION_BASE,
|
||||
VERSION_BUILD=VERSION,
|
||||
VERSION=int(VERSION_SPLIT[0]) * 1000000 +
|
||||
@@ -129,32 +130,32 @@ def build(bld):
|
||||
|
||||
bld.objects(
|
||||
target='nlsr-objects',
|
||||
source=bld.path.ant_glob('src/**/*.cpp',
|
||||
excl=['src/main.cpp']),
|
||||
use='NDN_CXX BOOST CHRONOSYNC PSYNC SVS',
|
||||
source=bld.path.ant_glob('src/**/*.cpp', excl=['src/main.cpp']),
|
||||
use='BOOST NDN_CXX CHRONOSYNC PSYNC SVS',
|
||||
includes='. src',
|
||||
export_includes='. src')
|
||||
|
||||
bld.program(
|
||||
target='bin/nlsr',
|
||||
name='nlsr',
|
||||
target='bin/nlsr',
|
||||
source='src/main.cpp',
|
||||
use='nlsr-objects')
|
||||
|
||||
bld.program(
|
||||
target='bin/nlsrc',
|
||||
name='nlsrc',
|
||||
target='bin/nlsrc',
|
||||
source='tools/nlsrc.cpp',
|
||||
use='nlsr-objects')
|
||||
|
||||
if bld.env.WITH_TESTS:
|
||||
bld.recurse('tests')
|
||||
|
||||
# Install sample config
|
||||
bld.install_as('${SYSCONFDIR}/ndn/nlsr.conf.sample', 'nlsr.conf')
|
||||
|
||||
if Utils.unversioned_sys_platform() == 'linux':
|
||||
bld(features='subst',
|
||||
name='nlsr.service',
|
||||
name='systemd-units',
|
||||
source='systemd/nlsr.service.in',
|
||||
target='systemd/nlsr.service')
|
||||
|
||||
@@ -220,16 +221,16 @@ def version(ctx):
|
||||
# first, try to get a version string from git
|
||||
gotVersionFromGit = False
|
||||
try:
|
||||
cmd = ['git', 'describe', '--always', '--match', '%s*' % GIT_TAG_PREFIX]
|
||||
out = subprocess.check_output(cmd, universal_newlines=True).strip()
|
||||
cmd = ['git', 'describe', '--always', '--match', f'{GIT_TAG_PREFIX}*']
|
||||
out = subprocess.run(cmd, capture_output=True, check=True, text=True).stdout.strip()
|
||||
if out:
|
||||
gotVersionFromGit = True
|
||||
if out.startswith(GIT_TAG_PREFIX):
|
||||
Context.g_module.VERSION = out.lstrip(GIT_TAG_PREFIX)
|
||||
else:
|
||||
# no tags matched
|
||||
Context.g_module.VERSION = '%s-commit-%s' % (VERSION_BASE, out)
|
||||
except (OSError, subprocess.CalledProcessError):
|
||||
Context.g_module.VERSION = f'{VERSION_BASE}-commit-{out}'
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
pass
|
||||
|
||||
versionFile = ctx.path.find_node('VERSION.info')
|
||||
@@ -247,14 +248,14 @@ def version(ctx):
|
||||
# already up-to-date
|
||||
return
|
||||
except EnvironmentError as e:
|
||||
Logs.warn('%s exists but is not readable (%s)' % (versionFile, e.strerror))
|
||||
Logs.warn(f'{versionFile} exists but is not readable ({e.strerror})')
|
||||
else:
|
||||
versionFile = ctx.path.make_node('VERSION.info')
|
||||
|
||||
try:
|
||||
versionFile.write(Context.g_module.VERSION)
|
||||
except EnvironmentError as e:
|
||||
Logs.warn('%s is not writable (%s)' % (versionFile, e.strerror))
|
||||
Logs.warn(f'{versionFile} is not writable ({e.strerror})')
|
||||
|
||||
def dist(ctx):
|
||||
ctx.algo = 'tar.xz'
|
||||
|
||||
Reference in new issue
Block a user