33 Commits
Author SHA1 Message Date
Saurab Dulal 301220346e docs: Prepare version 0.4.3 release notes
Change-Id: I0b3a6166eac489be67ea03ff69a13ffe35616f63
2018-05-21 12:54:11 -05:00
Ashlesh Gawande 8df15986ef tlv: avoid misaligned memory access
They cause unit test crashing on ARM platform.

refs: #4609

Change-Id: Ifdb0401529de48b5c08ebcf6938d80ba87ff883d
2018-05-19 22:21:25 -07:00
Ryan Wickman f3c79a6f87 src: make LSA's isEqualContent methods of type const
refs: #4137
Change-Id: Idb1cdea33d4efbc3af3c07d901a620d3ef253979
2018-05-10 20:15:01 -05:00
Ashlesh Gawande cba0ae2f56 **breaking** Change NLSR to nlsr for various prefixes
src: register router prefix to fix remote requests

refs: #4543

Change-Id: I698484318bf8e641f955ea40e6c51c6865cad8bf
2018-04-19 14:34:29 -05:00
Eric Newberry f1a8ee66de build: find Boost lib architecture automatically
refs #4573

Change-Id: I383f821bc651926ba5d2ed830b20dd3116e8a3fc
2018-04-07 16:38:47 -07:00
Ashlesh Gawande d65786a0ea src/lsa-segment-storage: fix convergence w/o content store
refs: #4430

Change-Id: I5124e9fd49bd9850c904c31d221b42b4249553a3
2018-04-02 22:55:17 -05:00
Ashlesh Gawande e6ba9158e0 Fix build with clang-5.0
refs: #4547

Change-Id: I7fd0411b3dc7c62651875aa035bbfb6ca269bf81
2018-03-30 16:20:27 -05:00
Eric Newberry aa41b04807 docs: disable sphinxcontrib-googleanalytics
refs #4553

Change-Id: I94529272787b0facd9370f9c6fca06435a636093
2018-03-26 15:16:43 -07:00
Alexander Afanasyev 67758b1fba build: update waf to version 2.0.6
Fix discovered build issues

Change-Id: I9a861c955283c1b20cc5065a4baa22bd7c2ab0c1
2018-03-11 12:17:41 -04:00
Ashlesh Gawande 350d58489b docs: Prepare version 0.4.2 release notes
Change-Id: I36780f66b803b6049e5399fde6e1a097c40a65b3
2018-03-05 12:04:31 -06:00
Ashlesh Gawande 8c6d8c831a lsa-segment-storage: fix segfault in scheduled erase of lsa segment
refs: #4520

Change-Id: I597604b4be9e063a08ff5031faa8d305408b676d
2018-03-01 12:54:15 -06:00
Ashlesh Gawande 0b27c1ff5c Update symlink to latest release notes
Change-Id: I0956f0be737af0b4d43810ff7c7c91fd89982c8a
2018-02-26 14:35:53 -06:00
Ashlesh Gawande 39cf81a110 docs: Prepare version 0.4.1 release notes
Change-Id: I91db5b65dfe06187ddb0e9df32905dc2c8797ddc
2018-02-22 17:37:51 -06:00
Alexander Afanasyev b0bf8df1bd Hard-code fixed session name for ChronoSync sockets
This commit reverts behavior of the hard-coded fixed session name that
was feature in old nsync-based implementation.

Also fixing an initialized configuration parameter.

refs: #4513

Change-Id: I44559e729c949f90511a5c53282fd4a240356157
2018-02-21 13:49:40 -08:00
laqinfan a073e2e23e publisher: fix encoding bug in routing table publisher
refs: #4453

Change-Id: I03e819e963f0957f3d40ff25e378f2b9b17357b7
2018-02-16 12:30:36 +00:00
Saurab Dulal 9da6aa7fce Routing: Print labels on adjacency matrix when logging
refs: #2045

Change-Id: I0fa36eed1a6afdca6f135c80a20aa062a5e8cd63
2018-02-15 12:20:15 -08:00
Ashlesh Gawande 304bebf64f Remove some unused functions
Change-Id: Ic99891d2037e928ac927651607559e7660bd677f
2018-02-15 12:41:43 -06:00
Ashlesh Gawande 982a58fae5 Add version number after ChronoSync prefix
Change-Id: I5c6782461e6c00129850ab00df407a1f59f4353b
2018-02-14 17:39:12 -06:00
Alexander Afanasyev 7afe22f410 Output extended diagnostic information on fatal errors
Change-Id: I36bdd60df742837aeffb16ab78a93b93d5b24887
2018-02-13 16:17:40 -05:00
Ashlesh Gawande f7da9c542c conf: make ChronoSync's sync interest lifetime configurable
refs: #4490

Change-Id: Id3eabeed1049d1208ba49c47206f73f798f37a35
2018-02-09 15:24:47 -06:00
Muktadir Chowdhury c3ea26f000 Serve other routers' certificate and LSA
refs #4448, #4430

Change-Id: I3a9a9ae613770774be06effe26dfb866ea49f05a
2018-01-29 23:23:19 +00:00
Ashlesh Gawande 0d2c38299e Change certificate validity period to 1 year
Change certificate freshness period to 1 year
Catch Malformed URI error

refs: #4473, #4474

Change-Id: Ia341cba1e72b541c13eb480dfa53f26f89d854fa
2018-01-25 10:34:01 -06:00
Nick Gordon 563611eb20 communication: improve constness
Change-Id: Iabc5093d3c8e84540ddef4f6f2ff768dd9f3d0da
refs: #4472
2018-01-23 14:08:26 -06:00
Nick Gordon af87575012 nlsr: refactor equality operator
Change-Id: Iaaef9511e6569d597afcc5fa083b98ce86d8f78d
refs: #4127
2018-01-23 11:36:54 -08:00
Nick Gordon 4964870e9d src: improve constness
Change-Id: I8b3084e311642578628ea7c1017dc2a58979ab83
refs: #4472
2018-01-23 08:45:37 -08:00
dmcoomes b2ef6adbd3 Remove log4cxx from Jenkins
refs: #3949

Change-Id: I7ff3da932fe8a011aa391766c501b475118eaea5
2018-01-22 16:22:50 -06:00
dmcoomes cf8d0eda75 Use ndn-cxx logging facility
refs: #3949

Change-Id: I5d0931c3576c88e0c2fa52bdd0a716946400e0bc
2018-01-22 13:24:35 -06:00
Davide Pesavento 437adfeed6 ci: expand Travis-CI build matrix
Change-Id: I6ef5a461eaed9d66bed12189cde28cab30e55df8
2018-01-11 18:57:47 -05:00
laqinfan 357318540d publisher: implement routing table dataset publisher
refs: #3631, #3634

Change-Id: I7e961fdd0857690bee65d2bdfa4cf3de90ccac06
2018-01-11 12:08:27 +00:00
Ashlesh Gawande 14ab329746 Fix NLSR not converging without content store
refs: #4430

Change-Id: I8bff1facf528a07a3c2d90e8f512128c0420d799
2017-12-29 12:03:26 -06:00
Nick Gordon ed473c6c47 docs: mention the contributing guide
Change-Id: Ie14448f2fdf228db380f8332bee3dbe0b769fa50
refs: #4412
2017-12-21 14:02:30 -06:00
laqinfan ac4b65664f communication: fix dry-run mode not working
refs: #4394

Change-Id: I6b7eba5e36af307b9da6b5c198d44f9915db6358
2017-12-08 11:33:52 +00:00
Ashlesh Gawande d88c1dfdc2 ci+docs: remove all references to cryptopp/crypto++
Also update COPYING

refs: #3946

Change-Id: I87ded823f806857bb27079648e51619bb9dde6bc
2017-12-05 16:37:22 -06:00
125 changed files with 3821 additions and 1556 deletions

No files matched your search

+32 -7
View File
@@ -1,7 +1,32 @@
.DS*
.waf-1*
.waf3-*
.lock*
**/*.pyc
build/
VERSION
# Emacs
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
.\#*
# Visual Studio Code
.vscode/
# KDevelop
*.kdev*
# macOS
.DS_Store
.AppleDouble
.LSOverride
._*
# Waf build system
/build/
.waf-*-*/
.waf3-*-*/
.lock-waf*
# Compiled python code
__pycache__/
*.py[cod]
# Other
/VERSION
+2 -4
View File
@@ -7,7 +7,7 @@ source "$JDIR"/util.sh
set -x
if has OSX $NODE_LABELS; then
FORMULAE=(boost pkg-config cryptopp log4cxx openssl)
FORMULAE=(boost pkg-config openssl)
brew update
if [[ -n $TRAVIS ]]; then
# travis images come with a large number of brew packages
@@ -19,15 +19,13 @@ if has OSX $NODE_LABELS; then
brew upgrade
fi
brew install "${FORMULAE[@]}"
brew link --force log4cxx
brew cleanup
fi
if has Ubuntu $NODE_LABELS; then
sudo apt-get -qq update
sudo apt-get -qy install build-essential pkg-config libboost-all-dev \
libcrypto++-dev libsqlite3-dev libssl-dev \
liblog4cxx10-dev
libsqlite3-dev libssl-dev
if [[ $JOB_NAME == *"code-coverage" ]]; then
sudo apt-get -qy install lcov libgd-perl python-setuptools
+7 -6
View File
@@ -10,6 +10,12 @@ git submodule init
git submodule sync
git submodule update
if [[ $JOB_NAME == *"code-coverage" ]]; then
COVERAGE="--with-coverage"
elif [[ -z $DISABLE_ASAN ]]; then
ASAN="--with-sanitizer=address"
fi
# Cleanup
sudo env "PATH=$PATH" ./waf --color=yes distclean
@@ -30,12 +36,7 @@ if [[ $JOB_NAME != *"code-coverage" && $JOB_NAME != *"limited-build" ]]; then
fi
# Configure/build in debug mode with tests
if [[ $JOB_NAME == *"code-coverage" ]]; then
COVERAGE="--with-coverage"
elif [[ -n $BUILD_WITH_ASAN || -z $TRAVIS ]]; then
ASAN="--with-sanitizer=address"
fi
./waf --color=yes configure --debug --with-tests $COVERAGE $ASAN
./waf --color=yes configure --debug --with-tests $ASAN $COVERAGE
./waf --color=yes build -j${WAF_JOBS:-1}
# (tests will be run against debug version)
+78 -14
View File
@@ -1,5 +1,6 @@
language: cpp
dist: trusty
sudo: required
language: generic
env:
global:
- JOB_NAME=limited-build
@@ -8,30 +9,93 @@ env:
matrix:
include:
# Linux/gcc
# https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test/+packages
- os: linux
dist: trusty
env:
- CXX=g++-4.8
- NODE_LABELS="Linux Ubuntu Ubuntu-14.04"
- BUILD_WITH_ASAN=yes
env: COMPILER=g++-4.8
- os: linux
env: COMPILER=g++-4.9
addons:
apt:
sources: ubuntu-toolchain-r-test
packages: g++-4.9
- os: linux
env: COMPILER=g++-5
addons:
apt:
sources: ubuntu-toolchain-r-test
packages: g++-5
- os: linux
env: COMPILER=g++-6
addons:
apt:
sources: ubuntu-toolchain-r-test
packages: g++-6
- os: linux
env: COMPILER=g++-7
addons:
apt:
sources: ubuntu-toolchain-r-test
packages: g++-7
# Linux/clang
# https://apt.llvm.org/
- os: linux
dist: trusty
env:
- CXX=clang++
- NODE_LABELS="Linux Ubuntu Ubuntu-14.04"
- BUILD_WITH_ASAN=yes
env: COMPILER=clang++-3.5
addons:
apt:
packages: clang-3.5
- os: linux
env: COMPILER=clang++-3.6
addons:
apt:
packages: clang-3.6
- os: linux
env: COMPILER=clang++-3.7 DISABLE_ASAN=yes
addons:
apt:
sources: ["llvm-toolchain-precise-3.7", "ubuntu-toolchain-r-test"]
packages: clang-3.7
- os: linux
env: COMPILER=clang++-3.8
addons:
apt:
sources: ["llvm-toolchain-precise-3.8", "ubuntu-toolchain-r-test"]
packages: clang-3.8
- os: linux
env: COMPILER=clang++-3.9 DISABLE_ASAN=yes
addons:
apt:
sources: ["llvm-toolchain-trusty-3.9", "ubuntu-toolchain-r-test"]
packages: clang-3.9
- os: linux
env: COMPILER=clang++-4.0
addons:
apt:
sources: ["llvm-toolchain-trusty-4.0", "ubuntu-toolchain-r-test"]
packages: clang-4.0
- os: linux
env: COMPILER=clang++-5.0
addons:
apt:
sources: ["llvm-toolchain-trusty-5.0", "ubuntu-toolchain-r-test"]
packages: clang-5.0
# macOS/clang
# https://docs.travis-ci.com/user/osx-ci-environment/#OS-X-Version
- os: osx
osx_image: xcode7.3
env: OSX_VERSION=10.11
- os: osx
osx_image: xcode8.3
env:
- NODE_LABELS="OSX OSX-10.12"
- BUILD_WITH_ASAN=yes
env: OSX_VERSION=10.12
- os: osx
osx_image: xcode9.2
env: OSX_VERSION=10.12
before_script:
- if [[ ${TRAVIS_OS_NAME} == linux ]]; then export NODE_LABELS="Linux Ubuntu Ubuntu-14.04"; fi
- if [[ ${TRAVIS_OS_NAME} == osx ]]; then export NODE_LABELS="OSX OSX-${OSX_VERSION}"; fi
- if [[ -n ${COMPILER} ]]; then export CXX=${COMPILER}; fi
- ${CXX:-c++} --version
- python --version
+220 -76
View File
@@ -30,15 +30,15 @@ When using this tool, the wscript will look like:
Options are generated, in order to specify the location of boost includes/libraries.
The `check_boost` configuration function allows to specify the used boost libraries.
It can also provide default arguments to the --boost-static and --boost-mt command-line arguments.
It can also provide default arguments to the --boost-mt command-line arguments.
Everything will be packaged together in a BOOST component that you can use.
When using MSVC, a lot of compilation flags need to match your BOOST build configuration:
- you may have to add /EHsc to your CXXFLAGS or define boost::throw_exception if BOOST_NO_EXCEPTIONS is defined.
Errors: C4530
- boost libraries will try to be smart and use the (pretty but often not useful) auto-linking feature of MSVC
So before calling `conf.check_boost` you might want to disabling by adding:
conf.env.DEFINES_BOOST += ['BOOST_ALL_NO_LIB']
So before calling `conf.check_boost` you might want to disabling by adding
conf.env.DEFINES_BOOST += ['BOOST_ALL_NO_LIB']
Errors:
- boost might also be compiled with /MT, which links the runtime statically.
If you have problems with redefined symbols,
@@ -52,24 +52,54 @@ import sys
import re
from waflib import Utils, Logs, Errors
from waflib.Configure import conf
from waflib.TaskGen import feature, after_method
BOOST_LIBS = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib/x86_64-linux-gnu', '/usr/lib/i386-linux-gnu', '/usr/local/ndn/lib']
BOOST_INCLUDES = ['/usr/include', '/usr/local/include', '/opt/local/include', '/sw/include', '/usr/local/ndn/include']
BOOST_LIBS = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib']
BOOST_INCLUDES = ['/usr/include', '/usr/local/include', '/opt/local/include', '/sw/include']
BOOST_VERSION_FILE = 'boost/version.hpp'
BOOST_VERSION_CODE = '''
#include <iostream>
#include <boost/version.hpp>
int main() { std::cout << BOOST_LIB_VERSION << ":" << BOOST_VERSION << std::endl; }
'''
BOOST_SYSTEM_CODE = '''
BOOST_ERROR_CODE = '''
#include <boost/system/error_code.hpp>
int main() { boost::system::error_code c; }
'''
PTHREAD_CODE = '''
#include <pthread.h>
static void* f(void*) { return 0; }
int main() {
pthread_t th;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_create(&th, &attr, &f, 0);
pthread_join(th, 0);
pthread_cleanup_push(0, 0);
pthread_cleanup_pop(0);
pthread_attr_destroy(&attr);
}
'''
BOOST_THREAD_CODE = '''
#include <boost/thread.hpp>
int main() { boost::thread t; }
'''
BOOST_LOG_CODE = '''
#include <boost/log/trivial.hpp>
#include <boost/log/utility/setup/console.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
int main() {
using namespace boost::log;
add_common_attributes();
add_console_log(std::clog, keywords::format = "%Message%");
BOOST_LOG_TRIVIAL(debug) << "log is working" << std::endl;
}
'''
# toolsets from {boost_dir}/tools/build/v2/tools/common.jam
PLATFORM = Utils.unversioned_sys_platform()
detect_intel = lambda env: (PLATFORM == 'win32') and 'iw' or 'il'
@@ -101,34 +131,37 @@ BOOST_TOOLSETS = {
def options(opt):
opt = opt.add_option_group('Boost Options')
opt.add_option('--boost-includes', type='string',
default='', dest='boost_includes',
help='''path to the directory where the boost includes are, e.g., /path/to/boost_1_55_0/stage/include''')
help='''path to the directory where the boost includes are,
e.g., /path/to/boost_1_55_0/stage/include''')
opt.add_option('--boost-libs', type='string',
default='', dest='boost_libs',
help='''path to the directory where the boost libs are, e.g., /path/to/boost_1_55_0/stage/lib''')
opt.add_option('--boost-static', action='store_true',
default=False, dest='boost_static',
help='link with static boost libraries (.lib/.a)')
help='''path to the directory where the boost libs are,
e.g., path/to/boost_1_55_0/stage/lib''')
opt.add_option('--boost-mt', action='store_true',
default=False, dest='boost_mt',
help='select multi-threaded libraries')
opt.add_option('--boost-abi', type='string', default='', dest='boost_abi',
help='''select libraries with tags (dgsyp, d for debug), see doc Boost, Getting Started, chapter 6.1''')
help='''select libraries with tags (gd for debug, static is automatically added),
see doc Boost, Getting Started, chapter 6.1''')
opt.add_option('--boost-linkage_autodetect', action="store_true", dest='boost_linkage_autodetect',
help="auto-detect boost linkage options (don't get used to it / might break other stuff)")
opt.add_option('--boost-toolset', type='string',
default='', dest='boost_toolset',
help='force a toolset e.g. msvc, vc90, gcc, mingw, mgw45 (default: auto)')
help='force a toolset e.g. msvc, vc90, \
gcc, mingw, mgw45 (default: auto)')
py_version = '%d%d' % (sys.version_info[0], sys.version_info[1])
opt.add_option('--boost-python', type='string',
default=py_version, dest='boost_python',
help='select the lib python with this version (default: %s)' % py_version)
help='select the lib python with this version \
(default: %s)' % py_version)
@conf
def __boost_get_version_file(self, d):
if not d:
return None
dnode = self.root.find_dir(d)
if dnode:
return dnode.find_node(BOOST_VERSION_FILE)
@@ -141,18 +174,15 @@ def boost_get_version(self, d):
if node:
try:
txt = node.read()
except (OSError, IOError):
except EnvironmentError:
Logs.error("Could not read the file %r" % node.abspath())
else:
re_but1 = re.compile('^#define\\s+BOOST_LIB_VERSION\\s+"(.+)"', re.M)
m1 = re_but1.search(txt)
re_but2 = re.compile('^#define\\s+BOOST_VERSION\\s+(\\d+)', re.M)
m2 = re_but2.search(txt)
if m1 and m2:
return (m1.group(1), m2.group(1))
return self.check_cxx(fragment=BOOST_VERSION_CODE, includes=[d], execute=True, define_ret=True).split(":")
@conf
@@ -160,7 +190,7 @@ def boost_get_includes(self, *k, **kw):
includes = k and k[0] or kw.get('includes', None)
if includes and self.__boost_get_version_file(includes):
return includes
for d in Utils.to_list(self.environ.get('INCLUDE', '')) + BOOST_INCLUDES:
for d in self.environ.get('INCLUDE', '').split(';') + BOOST_INCLUDES:
if self.__boost_get_version_file(d):
return d
if includes:
@@ -195,7 +225,9 @@ def __boost_get_libs_path(self, *k, **kw):
path = self.root.find_dir(libs)
files = path.ant_glob('*boost_*')
if not libs or not files:
for d in Utils.to_list(self.environ.get('LIB', [])) + BOOST_LIBS:
for d in self.environ.get('LIB', '').split(';') + BOOST_LIBS:
if not d:
continue
path = self.root.find_dir(d)
if path:
files = path.ant_glob('*boost_*')
@@ -226,15 +258,10 @@ def boost_get_libs(self, *k, **kw):
according to the parameters
'''
path, files = self.__boost_get_libs_path(**kw)
t = []
if kw.get('mt', False):
t.append('mt')
if kw.get('abi', None):
t.append(kw['abi'])
tags = t and '(-%s)+' % '-'.join(t) or ''
files = sorted(files, key=lambda f: (len(f.name), f.name), reverse=True)
toolset = self.boost_get_toolset(kw.get('toolset', ''))
toolset_pat = '(-%s[0-9]{0,3})+' % toolset
version = '(-%s)+' % self.env.BOOST_VERSION
toolset_pat = '(-%s[0-9]{0,3})' % toolset
version = '-%s' % self.env.BOOST_VERSION
def find_lib(re_lib, files):
for file in files:
@@ -248,28 +275,110 @@ def boost_get_libs(self, *k, **kw):
name = name[3:]
return name[:name.rfind('.')]
libs = []
for lib in Utils.to_list(k and k[0] or kw.get('lib', None)):
py = (lib == 'python') and '(-py%s)+' % kw['python'] or ''
# Trying libraries, from most strict match to least one
for pattern in ['boost_%s%s%s%s%s' % (lib, toolset_pat, tags, py, version),
'boost_%s%s%s%s' % (lib, tags, py, version),
'boost_%s%s%s' % (lib, tags, version),
# Give up trying to find the right version
'boost_%s%s%s%s' % (lib, toolset_pat, tags, py),
'boost_%s%s%s' % (lib, tags, py),
'boost_%s%s' % (lib, tags)]:
self.to_log('Trying pattern %s' % pattern)
file = find_lib(re.compile(pattern), files)
if file:
libs.append(format_lib_name(file.name))
break
else:
self.end_msg('lib %s not found in %s' % (lib, path.abspath()))
self.fatal('The configuration failed')
def match_libs(lib_names, is_static):
libs = []
lib_names = Utils.to_list(lib_names)
if not lib_names:
return libs
t = []
if kw.get('mt', False):
t.append('-mt')
if kw.get('abi', None):
t.append('%s%s' % (is_static and '-s' or '-', kw['abi']))
elif is_static:
t.append('-s')
tags_pat = t and ''.join(t) or ''
ext = is_static and self.env.cxxstlib_PATTERN or self.env.cxxshlib_PATTERN
ext = ext.partition('%s')[2] # remove '%s' or 'lib%s' from PATTERN
return path.abspath(), libs
for lib in lib_names:
if lib == 'python':
# for instance, with python='27',
# accepts '-py27', '-py2', '27' and '2'
# but will reject '-py3', '-py26', '26' and '3'
tags = '({0})?((-py{2})|(-py{1}(?=[^0-9]))|({2})|({1}(?=[^0-9]))|(?=[^0-9])(?!-py))'.format(tags_pat, kw['python'][0], kw['python'])
else:
tags = tags_pat
# Trying libraries, from most strict match to least one
for pattern in ['boost_%s%s%s%s%s$' % (lib, toolset_pat, tags, version, ext),
'boost_%s%s%s%s$' % (lib, tags, version, ext),
# Give up trying to find the right version
'boost_%s%s%s%s$' % (lib, toolset_pat, tags, ext),
'boost_%s%s%s$' % (lib, tags, ext),
'boost_%s%s$' % (lib, ext),
'boost_%s' % lib]:
self.to_log('Trying pattern %s' % pattern)
file = find_lib(re.compile(pattern), files)
if file:
libs.append(format_lib_name(file.name))
break
else:
self.end_msg('lib %s not found in %s' % (lib, path.abspath()))
self.fatal('The configuration failed')
return libs
return path.abspath(), match_libs(kw.get('lib', None), False), match_libs(kw.get('stlib', None), True)
@conf
def _check_pthread_flag(self, *k, **kw):
'''
Computes which flags should be added to CXXFLAGS and LINKFLAGS to compile in multi-threading mode
Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3,
boost/thread.hpp will trigger a #error if -pthread isn't used:
boost/config/requires_threads.hpp:47:5: #error "Compiler threading support
is not turned on. Please set the correct command line options for
threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
Based on _BOOST_PTHREAD_FLAG(): https://github.com/tsuna/boost.m4/blob/master/build-aux/boost.m4
'''
var = kw.get('uselib_store', 'BOOST')
self.start_msg('Checking the flags needed to use pthreads')
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# (none): in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -lpthreads: AIX (must check this before -lpthread)
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
# -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads)
# -pthreads: Solaris/GCC
# -mthreads: MinGW32/GCC, Lynx/GCC
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads too;
# also defines -D_REENTRANT)
# ... -mt is also the pthreads flag for HP/aCC
# -lpthread: GNU Linux, etc.
# --thread-safe: KAI C++
if Utils.unversioned_sys_platform() == "sunos":
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (We need to link with -pthreads/-mt/
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
# a function called by this macro, so we could check for that, but
# who knows whether they'll stub that too in a future libc.) So,
# we'll just look for -pthreads and -lpthread first:
boost_pthread_flags = ["-pthreads", "-lpthread", "-mt", "-pthread"]
else:
boost_pthread_flags = ["", "-lpthreads", "-Kthread", "-kthread", "-llthread", "-pthread",
"-pthreads", "-mthreads", "-lpthread", "--thread-safe", "-mt"]
for boost_pthread_flag in boost_pthread_flags:
try:
self.env.stash()
self.env['CXXFLAGS_%s' % var] += [boost_pthread_flag]
self.env['LINKFLAGS_%s' % var] += [boost_pthread_flag]
self.check_cxx(code=PTHREAD_CODE, msg=None, use=var, execute=False)
self.end_msg(boost_pthread_flag)
return
except self.errors.ConfigurationError:
self.env.revert()
self.end_msg('None')
@conf
def check_boost(self, *k, **kw):
@@ -282,7 +391,10 @@ def check_boost(self, *k, **kw):
if not self.env['CXX']:
self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
params = {'lib': k and k[0] or kw.get('lib', None)}
params = {
'lib': k and k[0] or kw.get('lib', None),
'stlib': kw.get('stlib', None)
}
for key, value in self.options.__dict__.items():
if not key.startswith('boost_'):
continue
@@ -291,48 +403,64 @@ def check_boost(self, *k, **kw):
var = kw.get('uselib_store', 'BOOST')
self.find_program('dpkg-architecture', var='DPKG_ARCHITECTURE', mandatory=False)
if self.env.DPKG_ARCHITECTURE:
deb_host_multiarch = self.cmd_and_log([self.env.DPKG_ARCHITECTURE[0], '-qDEB_HOST_MULTIARCH'])
BOOST_LIBS.insert(0, '/usr/lib/%s' % deb_host_multiarch.strip())
self.start_msg('Checking boost includes')
self.env['INCLUDES_%s' % var] = inc = self.boost_get_includes(**params)
versions = self.boost_get_version(inc)
self.env.BOOST_VERSION = versions[0]
self.env.BOOST_VERSION_NUMBER = int(versions[1])
self.end_msg("%d.%d.%d" % (int(versions[1]) / 100000,
int(versions[1]) / 100 % 1000,
int(versions[1]) % 100))
int(versions[1]) / 100 % 1000,
int(versions[1]) % 100))
if Logs.verbose:
Logs.pprint('CYAN', ' path : %s' % self.env['INCLUDES_%s' % var])
if not params['lib']:
if not params['lib'] and not params['stlib']:
return
if 'static' in kw or 'static' in params:
Logs.warn('boost: static parameter is deprecated, use stlib instead.')
self.start_msg('Checking boost libs')
suffix = params.get('static', None) and 'ST' or ''
path, libs = self.boost_get_libs(**params)
self.env['%sLIBPATH_%s' % (suffix, var)] = [path]
self.env['%sLIB_%s' % (suffix, var)] = libs
path, libs, stlibs = self.boost_get_libs(**params)
self.env['LIBPATH_%s' % var] = [path]
self.env['STLIBPATH_%s' % var] = [path]
self.env['LIB_%s' % var] = libs
self.env['STLIB_%s' % var] = stlibs
self.end_msg('ok')
if Logs.verbose:
Logs.pprint('CYAN', ' path : %s' % path)
Logs.pprint('CYAN', ' libs : %s' % libs)
Logs.pprint('CYAN', ' shared libs : %s' % libs)
Logs.pprint('CYAN', ' static libs : %s' % stlibs)
def has_shlib(lib):
return params['lib'] and lib in params['lib']
def has_stlib(lib):
return params['stlib'] and lib in params['stlib']
def has_lib(lib):
return has_shlib(lib) or has_stlib(lib)
if has_lib('thread'):
# not inside try_link to make check visible in the output
self._check_pthread_flag(k, kw)
def try_link():
if 'system' in params['lib']:
self.check_cxx(
fragment=BOOST_SYSTEM_CODE,
use=var,
execute=False,
)
if 'thread' in params['lib']:
self.check_cxx(
fragment=BOOST_THREAD_CODE,
use=var,
execute=False,
)
if has_lib('system'):
self.check_cxx(fragment=BOOST_ERROR_CODE, use=var, execute=False)
if has_lib('thread'):
self.check_cxx(fragment=BOOST_THREAD_CODE, use=var, execute=False)
if has_lib('log'):
if not has_lib('thread'):
self.env['DEFINES_%s' % var] += ['BOOST_LOG_NO_THREADS']
if has_shlib('log'):
self.env['DEFINES_%s' % var] += ['BOOST_LOG_DYN_LINK']
self.check_cxx(fragment=BOOST_LOG_CODE, use=var, execute=False)
if params.get('linkage_autodetect', False):
self.start_msg("Attempting to detect boost linkage flags")
toolset = self.boost_get_toolset(kw.get('toolset', ''))
if toolset in ['vc']:
if toolset in ('vc',):
# disable auto-linking feature, causing error LNK1181
# because the code wants to be linked against
self.env['DEFINES_%s' % var] += ['BOOST_ALL_NO_LIB']
@@ -356,14 +484,14 @@ def check_boost(self, *k, **kw):
try:
try_link()
self.end_msg("ok: winning cxxflags combination: %s" % (self.env["CXXFLAGS_%s" % var]))
e = None
exc = None
break
except Errors.ConfigurationError as exc:
except Errors.ConfigurationError as e:
self.env.revert()
e = exc
exc = e
if e is not None:
self.end_msg("Could not auto-detect boost linking flags combination, you may report it to boost.py author", ex=e)
if exc is not None:
self.end_msg("Could not auto-detect boost linking flags combination, you may report it to boost.py author", ex=exc)
self.fatal('The configuration failed')
else:
self.end_msg("Boost linkage flags auto-detection not implemented (needed ?) for this toolchain")
@@ -376,3 +504,19 @@ def check_boost(self, *k, **kw):
self.end_msg("Could not link against boost libraries using supplied options")
self.fatal('The configuration failed')
self.end_msg('ok')
@feature('cxx')
@after_method('apply_link')
def install_boost(self):
if install_boost.done or not Utils.is_win32 or not self.bld.cmd.startswith('install'):
return
install_boost.done = True
inst_to = getattr(self, 'install_path', '${BINDIR}')
for lib in self.env.LIB_BOOST:
try:
file = self.bld.find_file(self.env.cxxshlib_PATTERN % lib, self.env.LIBPATH_BOOST)
self.bld.install_files(inst_to, self.bld.root.find_node(file))
except:
continue
install_boost.done = False
+4 -4
View File
@@ -1,15 +1,15 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
from waflib import TaskGen, Logs
from waflib import TaskGen
def options(opt):
opt.add_option('--with-coverage', action='store_true', default=False, dest='with_coverage',
help='''Set compiler flags for gcc to enable code coverage information''')
opt.add_option('--with-coverage', action='store_true', default=False,
help='Add compiler flags to enable code coverage information')
def configure(conf):
if conf.options.with_coverage:
if not conf.options.debug:
conf.fatal("Code coverage flags require debug mode compilation (add --debug)")
conf.fatal('Code coverage flags require debug mode compilation (add --debug)')
conf.check_cxx(cxxflags=['-fprofile-arcs', '-ftest-coverage', '-fPIC'],
linkflags=['-fprofile-arcs'], uselib_store='GCOV', mandatory=True)
+53 -41
View File
@@ -1,64 +1,67 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
from waflib import Logs, Configure, Utils
from waflib import Configure, Logs, Utils
def options(opt):
opt.add_option('--debug', '--with-debug', action='store_true', default=False, dest='debug',
help='''Compile in debugging mode with minimal optimizations (-O0 or -Og)''')
opt.add_option('--debug', '--with-debug', action='store_true', default=False,
help='Compile in debugging mode with minimal optimizations (-O0 or -Og)')
def configure(conf):
conf.start_msg('Checking C++ compiler version')
cxx = conf.env['CXX_NAME'] # CXX_NAME is the generic name of the compiler
ccver = tuple(int(i) for i in conf.env['CC_VERSION'])
cxx = conf.env.CXX_NAME # generic name of the compiler
ccver = tuple(int(i) for i in conf.env.CC_VERSION)
ccverstr = '.'.join(conf.env.CC_VERSION)
errmsg = ''
warnmsg = ''
if cxx == 'gcc':
if ccver < (4, 8, 2):
errmsg = ('The version of gcc you are using is too old.\n'
'The minimum supported gcc version is 4.8.2.')
flags = GccFlags()
conf.flags = GccFlags()
elif cxx == 'clang':
if ccver < (3, 4, 0):
errmsg = ('The version of clang you are using is too old.\n'
'The minimum supported clang version is 3.4.0.')
flags = ClangFlags()
conf.flags = ClangFlags()
else:
warnmsg = 'Note: %s compiler is unsupported' % cxx
flags = CompilerFlags()
conf.flags = CompilerFlags()
if errmsg:
conf.end_msg('.'.join(conf.env['CC_VERSION']), color='RED')
conf.end_msg(ccverstr, color='RED')
conf.fatal(errmsg)
elif warnmsg:
conf.end_msg('.'.join(conf.env['CC_VERSION']), color='YELLOW')
conf.end_msg(ccverstr, color='YELLOW')
Logs.warn(warnmsg)
else:
conf.end_msg('.'.join(conf.env['CC_VERSION']))
conf.end_msg(ccverstr)
areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
conf.areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
# General flags are always applied (e.g., selecting C++11 mode)
generalFlags = flags.getGeneralFlags(conf)
generalFlags = conf.flags.getGeneralFlags(conf)
conf.add_supported_cxxflags(generalFlags['CXXFLAGS'])
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
# corresponding environment variables are not set.
# DEFINES are always applied.
if conf.options.debug:
extraFlags = flags.getDebugFlags(conf)
if areCustomCxxflagsPresent:
extraFlags = conf.flags.getDebugFlags(conf)
if conf.areCustomCxxflagsPresent:
missingFlags = [x for x in extraFlags['CXXFLAGS'] if x not in conf.env.CXXFLAGS]
if len(missingFlags) > 0:
Logs.warn("Selected debug mode, but CXXFLAGS is set to a custom value '%s'"
% " ".join(conf.env.CXXFLAGS))
Logs.warn("Default flags '%s' are not activated" % " ".join(missingFlags))
if missingFlags:
Logs.warn('Selected debug mode, but CXXFLAGS is set to a custom value "%s"'
% ' '.join(conf.env.CXXFLAGS))
Logs.warn('Default flags "%s" will not be used' % ' '.join(missingFlags))
else:
extraFlags = flags.getOptimizedFlags(conf)
extraFlags = conf.flags.getOptimizedFlags(conf)
if not areCustomCxxflagsPresent:
if not conf.areCustomCxxflagsPresent:
conf.add_supported_cxxflags(extraFlags['CXXFLAGS'])
conf.add_supported_linkflags(extraFlags['LINKFLAGS'])
@@ -75,9 +78,10 @@ def add_supported_cxxflags(self, cxxflags):
self.start_msg('Checking supported CXXFLAGS')
supportedFlags = []
for flag in cxxflags:
if self.check_cxx(cxxflags=['-Werror', flag], mandatory=False):
supportedFlags += [flag]
for flags in cxxflags:
flags = Utils.to_list(flags)
if self.check_cxx(cxxflags=['-Werror'] + flags, mandatory=False):
supportedFlags += flags
self.end_msg(' '.join(supportedFlags))
self.env.prepend_value('CXXFLAGS', supportedFlags)
@@ -93,15 +97,19 @@ def add_supported_linkflags(self, linkflags):
self.start_msg('Checking supported LINKFLAGS')
supportedFlags = []
for flag in linkflags:
if self.check_cxx(linkflags=['-Werror', flag], mandatory=False):
supportedFlags += [flag]
for flags in linkflags:
flags = Utils.to_list(flags)
if self.check_cxx(linkflags=['-Werror'] + flags, mandatory=False):
supportedFlags += flags
self.end_msg(' '.join(supportedFlags))
self.env.prepend_value('LINKFLAGS', supportedFlags)
class CompilerFlags(object):
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': []}
@@ -132,6 +140,7 @@ class GccBasicFlags(CompilerFlags):
'-Wall',
'-Wextra',
'-Werror',
'-Wnon-virtual-dtor',
'-Wno-error=deprecated-declarations', # Bug #3795
'-Wno-error=maybe-uninitialized', # Bug #1615
'-Wno-unused-parameter',
@@ -146,6 +155,7 @@ class GccBasicFlags(CompilerFlags):
'-pedantic',
'-Wall',
'-Wextra',
'-Wnon-virtual-dtor',
'-Wno-unused-parameter',
]
flags['LINKFLAGS'] += ['-fuse-ld=gold', '-Wl,-O1']
@@ -154,16 +164,14 @@ class GccBasicFlags(CompilerFlags):
class GccFlags(GccBasicFlags):
def getDebugFlags(self, conf):
flags = super(GccFlags, self).getDebugFlags(conf)
version = tuple(int(i) for i in conf.env['CC_VERSION'])
if version < (5, 1, 0):
if self.getCompilerVersion(conf) < (5, 1, 0):
flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
flags['CXXFLAGS'] += ['-fdiagnostics-color'] # gcc >= 4.9
return flags
def getOptimizedFlags(self, conf):
flags = super(GccFlags, self).getOptimizedFlags(conf)
version = tuple(int(i) for i in conf.env['CC_VERSION'])
if version < (5, 1, 0):
if self.getCompilerVersion(conf) < (5, 1, 0):
flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
flags['CXXFLAGS'] += ['-fdiagnostics-color'] # gcc >= 4.9
return flags
@@ -171,32 +179,36 @@ class GccFlags(GccBasicFlags):
class ClangFlags(GccBasicFlags):
def getGeneralFlags(self, conf):
flags = super(ClangFlags, self).getGeneralFlags(conf)
if Utils.unversioned_sys_platform() == 'darwin':
flags['CXXFLAGS'] += ['-stdlib=libc++']
flags['LINKFLAGS'] += ['-stdlib=libc++']
if Utils.unversioned_sys_platform() == 'darwin' and self.getCompilerVersion(conf) >= (9, 0, 0):
# Bug #4296
flags['CXXFLAGS'] += [['-isystem', '/usr/local/include'], # for Homebrew
['-isystem', '/opt/local/include']] # for MacPorts
return flags
def getDebugFlags(self, conf):
flags = super(ClangFlags, self).getDebugFlags(conf)
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
'-Wextra-semi',
'-Wundefined-func-template',
'-Wno-error=deprecated-register',
'-Wno-error=ignored-qualifiers',
'-Wno-error=infinite-recursion', # Bug #3358
'-Wno-error=keyword-macro', # Bug #3235
'-Wno-error=unneeded-internal-declaration', # Bug #1588
'-Wno-keyword-macro',
'-Wno-nested-anon-types',
'-Wno-sign-compare',
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
]
version = self.getCompilerVersion(conf)
if version < (3, 9, 0) or (Utils.unversioned_sys_platform() == 'darwin' and version < (8, 1, 0)):
flags['CXXFLAGS'] += ['-Wno-unknown-pragmas']
return flags
def getOptimizedFlags(self, conf):
flags = super(ClangFlags, self).getOptimizedFlags(conf)
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
'-Wno-keyword-macro',
'-Wno-nested-anon-types',
'-Wno-sign-compare',
'-Wextra-semi',
'-Wundefined-func-template',
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
]
version = self.getCompilerVersion(conf)
if version < (3, 9, 0) or (Utils.unversioned_sys_platform() == 'darwin' and version < (8, 1, 0)):
flags['CXXFLAGS'] += ['-Wno-unknown-pragmas']
return flags
+1
View File
@@ -34,6 +34,7 @@ NLSR is an open source project includes contributions from the members of the
* Nicholas Gordon <nmgordon@memphis.edu>
* Laqin Fan <lfan1@memphis.edu>
* Damian Coomes <dmcoomes@memphis.edu>
* Saurab Dulal <sdulal@memphis.edu>
* University of California, Los Angeles
+4 -21
View File
@@ -1,8 +1,7 @@
NLSR LICENSE
============
NLSR is released under the GPL with the additional exemption that
compiling, linking, and/or using OpenSSL is allowed.
NLSR is released under the GPL.
NLSR relies on third-party software and libraries, licensed under the following
licenses:
@@ -10,30 +9,14 @@ licenses:
- Boost libraries are licensed under the conditions of
[Boost Software License 1.0](http://www.boost.org/users/license.html)
- CryptoPP library is licensed under the conditions of
[Boost Software License 1.0](http://www.boost.org/users/license.html)
- log4cxx is licensed under the conditions of
[Apache License, Version 2.0](https://logging.apache.org/log4cxx/license.html)
- ndn-cxx is licensed under the conditions of
[LGPL 3.0](https://github.com/named-data/ndn-cxx/blob/master/COPYING.md)
- SQLite is in [public domain](http://www.sqlite.org/copyright.html)
- ChronoSync is licensed under the conditions of
[GPL 3.0](https://github.com/named-data/ChronoSync/blob/master/COPYING.md)
- waf build system is licensed under the conditions of
[BSD license](https://github.com/named-data/ndn-cxx/blob/master/waf)
NLSR also relies on third-party libraries with non-GPL compatible licenses.
These libraries fall into the category of "System Libraries" under GPL
license definitions and are used in accordance with the GPL license exception
for "System Libraries":
- OpenSSL is licensed under an
[Apache-style licence](http://www.openssl.org/source/license.html)
- (OS X platform only) OS X Security Framework is licensed under
[Apple Public Source License](http://www.opensource.apple.com/license/apsl/)
[BSD license](https://github.com/named-data/NLSR/blob/master/waf)
The GPL license is provided below in this file.
For more information, see http://www.gnu.org/licenses/
+6 -3
View File
@@ -28,10 +28,13 @@ Include the following header in all `.hpp` and `.cpp` files:
If you are affiliated with an NSF-supported NDN project institution,
please use the [NDN Team License Boilerplate]
(http://redmine.named-data.net/projects/nlsr/wiki/NDN_Team_License_Boilerplate_(NLSR)).
(https://redmine.named-data.net/projects/nlsr/wiki/NDN_Team_License_Boilerplate_(NLSR)).
Recommendations
---------------
NSLR code is subject to the code style, defined here:
http://redmine.named-data.net/projects/nfd/wiki/CodeStyle
NLSR code is subject to the code style, defined here:
https://redmine.named-data.net/projects/nfd/wiki/CodeStyle
NLSR Developer's guide can be found here:
https://github.com/named-data/NLSR/blob/developers-guide/NLSR-Developers-Guide.pdf
+10 -6
View File
@@ -4,6 +4,9 @@ NLSR - Named Data Link State Routing Protocol
For complete documentation and more extensive information,
please visit the [NLSR homepage](http://named-data.net/doc/NLSR/current/).
If you are new to the NDN community of software generally, read the
[Contributor's Guide](https://github.com/named-data/NFD/blob/master/CONTRIBUTING.md).
## Overview
NLSR is a routing protocol in NDN that populates NDN's Routing Information Base. NLSR
@@ -13,10 +16,10 @@ NLSR is an open and free software package licensed under the GPL 3.0 license and
Internet users and developers. For more information about the licensing details and
limitations, refer to [COPYING.md](https://github.com/named-data/NLSR/blob/master/COPYING.md).
NLSR is developed by the members of the [NSF-sponsored NDN project team](http://named-data.net/project/participants/).
NLSR is developed by the members of the [NSF-sponsored NDN project team](https://named-data.net/project/participants/).
For more details, please refer to [AUTHORS.md](https://github.com/named-data/NLSR/blob/master/AUTHORS.md).
Bug reports and feedback are highly appreciated and can be made through the
[Redmine site](http://redmine.named-data.net/projects/nlsr).
[Redmine site](https://redmine.named-data.net/projects/nlsr).
The main design goal of NLSR is to provide a routing protocol to populate NDN's FIB.
NLSR calculates the routing table using link-state or hyperbolic routing and produces
@@ -31,16 +34,17 @@ Source releases
The source code and source-code installation instructions are always available at
the following links:
- [Installation](http://named-data.net/doc/NLSR/current/INSTALL.html)
- [Getting Started with NLSR](http://named-data.net/doc/NLSR/current/GETTING-STARTED.html)
- [Installation](https://named-data.net/doc/NLSR/current/INSTALL.html)
- [Getting Started with NLSR](https://named-data.net/doc/NLSR/current/GETTING-STARTED.html)
- [GitHub NLSR repository](https://github.com/named-data/NLSR)
Additional information
----------------------
- [NLSR Wiki](http://redmine.named-data.net/projects/nlsr/wiki/)
- [Contributor's Guide](https://github.com/named-data/NFD/blob/master/CONTRIBUTING.md)
- [NLSR Wiki](https://redmine.named-data.net/projects/nlsr/wiki/)
- Feature requests and bug reports are welcome on our
[NLSR on NDN Redmine](http://redmine.named-data.net/projects/nlsr)
[NLSR on NDN Redmine](https://redmine.named-data.net/projects/nlsr)
- [NLSR Mailing List Sign Up](https://listserv.memphis.edu/scripts/wa.exe?GETPW1)
- [NLSR Mailing List](https://listserv.memphis.edu/scripts/wa.exe?SUBED1=NLSR-HELP-L&A=1)
- [NLSR Mailing List Archives](https://listserv.memphis.edu/scripts/wa.exe?A0=NLSR-HELP-L)
+20 -2
View File
@@ -53,8 +53,26 @@ You can also run ``nlsr -f`` with the absolute path of the configuration file:
nlsr -f /usr/local/etc/ndn/nlsr.conf
To run NLSR as daemon, use the ``-d`` flag:
Logging
-------
NLSR uses the ndn-cxx logging facility. All levels listed below the selected log-level
value are enabled.
::
nlsr -d
Valid values:
TRACE trace messages (most verbose)
DEBUG debugging messages
INFO informational messages
WARN warning messages
ERROR error messages
FATAL fatal (will be logged unconditionally)
To obtain logs for NLSR, set the NDN_LOG environment variable with the correct prefix and
log-level settings. For example, running the command `export NDN_LOG=nlsr.*=TRACE && nlsr`
will display all log messages in NLSR with a DEBUG level or below. If the user is presented
with an error message `User does not have read and write permission on the directory` it can
be circumvented by running the application with sudo: `sudo env NDN_LOG=nlsr.*=DEBUG nlsr`.
Use `man ndn-log` for more detailed instructions.
+2 -16
View File
@@ -7,9 +7,9 @@ NLSR Installation Instructions
Prerequisites
-------------
- `NFD <http://named-data.net/doc/NFD/current/>`_ and its requirements:
- `NFD <https://named-data.net/doc/NFD/>`_ and its requirements:
Refer to `Getting started with NFD <http://named-data.net/doc/NFD/current/INSTALL.html>`_
Refer to `Getting started with NFD <https://named-data.net/doc/NFD/current/INSTALL.html>`_
for detailed installation and running instruction.
- ChronoSync library
@@ -18,20 +18,6 @@ for detailed installation and running instruction.
https://github.com/named-data/ChronoSync#build
- log4cxx library
On Ubuntu Linux:
::
sudo apt-get install liblog4cxx10-dev
On OS X with MacPorts:
::
sudo port install log4cxx
Build
-----
+5 -21
View File
@@ -83,11 +83,7 @@ configuration commands follows:
; InterestLifetime (in seconds) for LSA fetching
lsa-interest-lifetime 4 ; default value 4. Valid values 1-60
; log-level is to set the levels of log for NLSR
log-level INFO ; default value INFO, valid value DEBUG, INFO
log-dir /var/log/nlsr/
seq-dir /var/lib/nlsr/
; log4cxx-conf /path/to/log4cxx-conf
}
; the neighbors section contains the configuration for router's neighbors and hello's behavior
@@ -183,28 +179,17 @@ configuration commands follows:
prefix /ndn/news/memphis/politics/lutherking
}
NLSR will have the following error if ``log-dir`` does not exist:
::
Provided log directory </var/log/nlsr/> does not exist
Error in configuration file processing! Exiting from NLSR
By default ``/var/log/nlsr/`` is set to be NLSR's log directory and ``/var/lib/nlsr/`` is set to be
NLSR's sequence file directory. They do not exist and will need to be created.
Also, since these are system directories it will require the user to run NLSR as root.
If one does not have permission to write to the specified directory,
then NLSR will produce the following error:
By default NLSR's sequence file directory is set to ``/var/lib/nlsr/``. User must create this
directory before starting NLSR. Since this is a system directory, NLSR must either be executed
as root, or NLSR can be run as user "nlsr" after configuring the filesystem to grant "nlsr"
read and write permissions. If user lacks permissions, the following error will occur:
::
User does not have read and write permission on the directory
Error in configuration file processing! Exiting from NLSR
To avoid this, the directories can be set in a user owned directory.
The directories for log and sequence file can be same.
For example:
To avoid this, the directory can be set in a user-owned directory. For example:
::
@@ -212,7 +197,6 @@ For example:
{
...
log-dir /home/username/nlsr/log ; path for log directory (Absolute path)
seq-dir /home/username/nlsr/log ; path for sequence directory (Absolute path)
}
+6 -6
View File
@@ -20,7 +20,7 @@ The trust model of NLSR is semi-hierarchical. An example certificate signing hie
router1 router2 router3 router4 router5 router6 router7
| | | | | | |
+ + + + + + +
NLSR NSLR NSLR NSLR NSLR NSLR NSLR
NLSR NLSR NLSR NLSR NLSR NLSR NLSR
Each entity's name and corresponding certificate name follow the
convention below:
@@ -28,11 +28,11 @@ convention below:
======== ===================================================== ================================= ===============================================
Entity Identity Name Example Certificate Name Example
-------- ----------------------------------------------------- --------------------------------- -----------------------------------------------
root /\<network\> /ndn /ndn/KEY/ksk-1/ID-CERT/%01
site /\<network\>/\<site\> /ndn/edu/ucla /ndn/edu/ucla/KEY/ksk-2/ID-CERT/%01
operator /\<network\>/\<site\>/%C1.Operator/\<operator-name\> /ndn/edu/ucla/%C1.Operator/op1 /ndn/edu/ucla/%C1.Operator/op1/KEY/ksk-3/ID-CERT/%01
router /\<network\>/\<site\>/%C1.Router/\<router-name\> /ndn/edu/ucla/%C1.Router/rt1 /ndn/edu/ucla/%C1.Router/rt1/KEY/ksk-4/ID-CERT/%01
NLSR /\<network\>/\<site\>/%C1.Router/\<router-name\>/NLSR /ndn/edu/ucla/%C1.Router/rt1/NLSR /ndn/edu/ucla/%C1.Router/rt1/NLSR/KEY/ksk-5/ID-CERT/%01
root /\<network\> /ndn /ndn/KEY/1/%00/%01
site /\<network\>/\<site\> /ndn/edu/ucla /ndn/edu/ucla/KEY/2/%00/%01
operator /\<network\>/\<site\>/%C1.Operator/\<operator-name\> /ndn/edu/ucla/%C1.Operator/op1 /ndn/edu/ucla/%C1.Operator/op1/KEY/3/%00/%01
router /\<network\>/\<site\>/%C1.Router/\<router-name\> /ndn/edu/ucla/%C1.Router/rt1 /ndn/edu/ucla/%C1.Router/rt1/KEY/4/%00/%01
NLSR /\<network\>/\<site\>/%C1.Router/\<router-name\>/NLSR /ndn/edu/ucla/%C1.Router/rt1/NLSR /ndn/edu/ucla/%C1.Router/rt1/NLSR/KEY/5/%00/%01
======== ===================================================== ================================= ===============================================
Users should create keys according to the naming and signing hierarchies above.
+3 -2
View File
@@ -44,8 +44,9 @@ def addExtensionIfExists(extension):
sys.stderr.write("To install, use \n"
" sudo pip install %s\n" % extension.replace('.', '-'))
if os.getenv('GOOGLE_ANALYTICS', None):
addExtensionIfExists('sphinxcontrib.googleanalytics')
# sphinxcontrib.googleanalytics is currently not working with the latest version of sphinx
# if os.getenv('GOOGLE_ANALYTICS', None):
# addExtensionIfExists('sphinxcontrib.googleanalytics')
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
+2 -12
View File
@@ -12,16 +12,12 @@ Usage
Description
-----------
``nlsr`` is a daemon that implements routing protocol in NDN to populates NDN's Routing
``nlsr`` is a process that implements routing protocol in NDN to populate NDN's Routing
Information Base.
Options:
--------
``-d``
Run in daemon mode
``-f <FILE>``
Specify configuration file name (default: ``./nlsr.conf``)
@@ -34,14 +30,8 @@ Options:
Examples
--------
To run NLSR daemon and use a configuration file from the ``/path/to`` directory.
To run NLSR and use a configuration file from the ``/path/to`` directory.
::
nlsr -f /path/to/nlsr.conf
To run NLSR as daemon, use the ``-d`` flag:
::
nlsr -d
+7 -1
View File
@@ -26,9 +26,15 @@ Options
``COMMAND``
``status``
``lsdb``
Retrieve LSDB status information
``routing``
Retrieve routing table status information
``status``
Retrieve LSDB status and routing table status information
``advertise``
Add a Name prefix to be advertised by NLSR
+6 -15
View File
@@ -12,7 +12,7 @@
<div class="row">
<div class="three columns">
<div id="logo">
<a href="http://named-data.net" title="A Future Internet Architecture"><img src="http://named-data.net/wp-content/uploads/cropped-20130722_Logo2.png" alt="" /></a>
<a href="https://named-data.net" title="A Future Internet Architecture"><img src="https://named-data.net/wp-content/uploads/cropped-20130722_Logo2.png" alt="" /></a>
</div><!--logo end-->
</div>
@@ -38,12 +38,14 @@
<h3>{{ _('Table Of Contents') }}</h3>
{{ toctree(includehidden=True) }}
<h3>{{ _('Additional documenation') }}</h3>
<h3>{{ _('Developer documentation') }}</h3>
<ul>
<li class="toctree-l1"><a class="reference external" href="http://redmine.named-data.net/projects/nlsr/wiki">NLSR Wiki</a></li>
<li class="toctree-l1"><a class="reference external" href="https://redmine.named-data.net/projects/nlsr/wiki">NLSR Wiki</a></li>
<li class="toctree-l1"><a class="reference internal" href="doxygen/annotated.html">API documentation (doxygen)</a></li>
<li class="toctree-l1"><a class="reference internal" href="code-style.html">ndn-cxx Code Style and Coding Guidelines</a></li>
</ul>
{%- endblock %}
{%- block sidebarsearch %}
<h3 style="margin-top: 1.5em;">{{ _('Search') }}</h3>
<form class="search" action="{{ pathto('search') }}" method="get">
@@ -74,22 +76,11 @@
<div class="row">
<div class="twelve columns">
<div id="copyright">This research is partially supported by NSF (Award <a href="http://www.nsf.gov/awardsearch/showAward?AWD_ID=1040868" target="_blank>">CNS-1040868</a>)<br/><br/><a rel="license" href="http://creativecommons.org/licenses/by/3.0/deed.en_US" target="_blank">Creative Commons Attribution 3.0 Unported License</a> except where noted.</div>
<div id="copyright">This research is partially supported by NSF (Award <a href="https://www.nsf.gov/awardsearch/showAward?AWD_ID=1040868" target="_blank>">CNS-1040868</a>)<br/><br/><a rel="license" href="https://creativecommons.org/licenses/by/3.0/deed.en_US" target="_blank">Creative Commons Attribution 3.0 Unported License</a> except where noted.</div>
</div>
</div>
</div><!--footer info end-->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22320603-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
{% endblock %}
{% block relbar1 %}{% endblock %}
@@ -0,0 +1,32 @@
<!-- start footer part -->
<!--BEGIN GENERATE_TREEVIEW-->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
$navpath
<li class="footer">$generatedby
<a href="https://www.doxygen.org/index.html">
<img class="footer" src="$relpath$doxygen.png" alt="doxygen"/></a> $doxygenversion </li>
</ul>
</div>
<!--END GENERATE_TREEVIEW-->
<!--BEGIN !GENERATE_TREEVIEW-->
<hr class="footer"/>
<address class="footer"><small>
$generatedby &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="$relpath$doxygen.png" alt="doxygen"/>
</a> $doxygenversion
</small></address>
<!--END !GENERATE_TREEVIEW-->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '@GOOGLE_ANALYTICS@', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>
+3 -1
View File
@@ -4,7 +4,7 @@
<ul>
$navpath
<li class="footer">$generatedby
<a href="http://www.doxygen.org/index.html">
<a href="https://www.doxygen.org/index.html">
<img class="footer" src="$relpath$doxygen.png" alt="doxygen"/></a> $doxygenversion </li>
</ul>
</div>
@@ -18,5 +18,7 @@ $generatedby &#160;<a href="http://www.doxygen.org/index.html">
</small></address>
<!--END !GENERATE_TREEVIEW-->
<script type="text/javascript">
</script>
</body>
</html>
+4 -4
View File
@@ -1,5 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
@@ -26,13 +26,13 @@ $mathjax
<div class="row">
<div class="three columns">
<div id="logo">
<a href="http://named-data.net" title="A Future Internet Architecture"><img src="http://named-data.net/wp-content/uploads/cropped-20130722_Logo2.png" alt="" /></a>
<a href="https://named-data.net" title="A Future Internet Architecture"><img src="https://named-data.net/wp-content/uploads/cropped-20130722_Logo2.png" alt="" /></a>
</div><!--logo end-->
</div>
<!--top menu-->
<div class="nine columns" id="menu_container" >
<h1><a href="http://named-data.net/doc/NLSR/$projectnumber/">$projectname $projectnumber documentation</a></h1>
<h1><a href="https://named-data.net/doc/NLSR/$projectnumber/">$projectname $projectnumber documentation</a></h1>
</div>
</div>
</div><!--header container end-->
+1 -1
View File
@@ -1 +1 @@
release-notes/release-notes-0.4.0.rst
release-notes/release-notes-0.4.3.rst
+1 -1
View File
@@ -4,7 +4,7 @@ NLSR version 0.1.0 (initial release)
Release date: August 25, 2014
The main design goal of NLSR is to provide a routing protocol to populate `NFD's
<http://named-data.net/doc/NFD/current/>`_ RIB. NLSR calculates the routing table using
<https://named-data.net/doc/NFD/>`_ RIB. NLSR calculates the routing table using
link-state or hyperbolic routing and produces multiple faces for each reachable name
prefix in a single authoritative domain.
@@ -0,0 +1,24 @@
NLSR version 0.4.1
++++++++++++++++++
**New features**:
- The routing table dataset publisher (:issue:`3630`)
- Use ndn-cxx logging facility, remove log4cxx dependency (:issue:`3949`)
- Automatic serving of other routers' certificates (:issue:`4448`)
**Bug Fixes**:
- Hard-code a fixed session name for ChronoSync sockets (:issue:`4513`)
- Fix encoding bug in the routing table publisher (:issue:`4453`)
- Fix NLSR not converging without content store (:issue:`4430`)
**Miscellaneous Changes**:
- Make ChronoSync's sync interest lifetime configurable (:issue:`4490`)
- Print labels on adjacency matrix when logging (:issue:`2045`)
@@ -0,0 +1,6 @@
NLSR version 0.4.2
++++++++++++++++++
**Bug Fixes**:
- Fix segfault in scheduled erase of lsa segment (:issue:`4520`)
@@ -0,0 +1,14 @@
NLSR version 0.4.3
++++++++++++++++++
**Changes**:
- **breaking change** Change NLSR to nlsr for various prefixes (:issue:`4543`)
**Bug Fixes**:
- Fix dry-run mode not working (:issue:`4394`)
- Fix convergence w/o content store (:issue:`4430`)
- Register router prefix to fix remote requests (:issue:`4543`)
- Fix build with clang-5.0 (:issue:`4547`)
- Avoid misaligned memory access (:issue:`4609`)
+9
View File
@@ -5,6 +5,9 @@ NLSR Versions
:hidden:
:maxdepth: 1
release-notes/release-notes-0.4.3
release-notes/release-notes-0.4.2
release-notes/release-notes-0.4.1
release-notes/release-notes-0.4.0
release-notes/release-notes-0.3.2
release-notes/release-notes-0.3.1
@@ -14,6 +17,12 @@ NLSR Versions
release-notes/release-notes-0.2.0
release-notes/release-notes-0.1.0
* **NLSR version 0.4.1**
(:doc:`Release Notes <release-notes/release-notes-0.4.1>`, `Documentation <https://named-data.net/doc/NLSR/0.4.1/>`__)
`src (git) <https://github.com/named-data/NLSR/releases/tag/NLSR-0.4.1>`__,
`src (tarball) <https://named-data.net/downloads/nlsr-0.4.1.tar.bz2>`__ (`checksum <https://named-data.net/downloads/nlsr-0.4.1.tar.bz2.sha256>`__)
* **NLSR version 0.4.0**
(:doc:`Release Notes <release-notes/release-notes-0.4.0>`, `Documentation <https://named-data.net/doc/NLSR/0.4.0/>`__)
-11
View File
@@ -1,11 +0,0 @@
log4j.rootLogger=DEBUG, Rolling
log4j.appender.Rolling=org.apache.log4j.rolling.RollingFileAppender
log4j.appender.Rolling.File=/tmp/testnlsrproperties.log
log4j.appender.Rolling.MaxSize=1MB
log4j.appender.Rolling.MaxBackupIndex=10
log4j.appender.Rolling.layout=PatternLayout
log4j.appender.Rolling.layout.ContextPrinting=enabled
log4j.appender.Rolling.layout.DateFormat=ISO8601
log4j.appender.Rolling.layout.ConversionPattern=%date{yyyyMMddHHmmssSSS} %p: [%c] %m%n
+10 -24
View File
@@ -19,24 +19,10 @@ general
; InterestLifetime (in seconds) for LSA fetching
lsa-interest-lifetime 4 ; default value 4. Valid values 1-60
; log-level is used to set the logging level for NLSR.
; All debugging levels listed above the selected value are enabled.
;
; Valid values:
;
; NONE ; no messages
; ERROR ; error messages
; WARN ; warning messages
; INFO ; informational messages (default)
; DEBUG ; debugging messages
; TRACE ; trace messages (most verbose)
; ALL ; all messages
; sync interest lifetime of ChronoSync in milliseconds
sync-interest-lifetime 60000 ; default value 60000. Valid values 1000-120,000
log-level INFO
log-dir /var/log/nlsr/ ; path for log directory (Absolute path)
seq-dir /var/lib/nlsr/ ; path for sequence directory (Absolute path)
;log4cxx-conf /path/to/log4cxx-conf ; path for log4cxx configuration file (Absolute path)
seq-dir /var/lib/nlsr ; path for sequence directory (Absolute path)
}
; the neighbor's section contains the configuration for router's neighbors and hellos behavior
@@ -155,7 +141,7 @@ security
filter
{
type name
regex ^[^<NLSR><INFO>]*<NLSR><INFO><><>$
regex ^[^<nlsr><INFO>]*<nlsr><INFO><><>$
}
checker
{
@@ -166,10 +152,10 @@ security
type name
hyper-relation
{
k-regex ^([^<KEY><NLSR>]*)<NLSR><KEY><>$
k-regex ^([^<KEY><nlsr>]*)<nlsr><KEY><>$
k-expand \\1
h-relation equal
p-regex ^([^<NLSR><INFO>]*)<NLSR><INFO><><>$
p-regex ^([^<nlsr><INFO>]*)<nlsr><INFO><><>$
p-expand \\1
}
}
@@ -183,7 +169,7 @@ security
filter
{
type name
regex ^[^<NLSR><LSA>]*<NLSR><LSA>
regex ^[^<nlsr><LSA>]*<nlsr><LSA>
}
checker
{
@@ -194,11 +180,11 @@ security
type name
hyper-relation
{
k-regex ^([^<KEY><NLSR>]*)<NLSR><KEY><>$
k-regex ^([^<KEY><nlsr>]*)<nlsr><KEY><>$
k-expand \\1
h-relation equal
; the last four components in the prefix should be <lsaType><seqNo><version><segmentNo>
p-regex ^<localhop>([^<NLSR><LSA>]*)<NLSR><LSA>(<>*)<><><><>$
p-regex ^<localhop>([^<nlsr><LSA>]*)<nlsr><LSA>(<>*)<><><><>$
p-expand \\1\\2
}
}
@@ -212,7 +198,7 @@ security
filter
{
type name
regex ^[^<KEY><%C1.Router>]*<%C1.Router>[^<KEY><NLSR>]*<KEY><><><>$
regex ^[^<KEY><%C1.Router>]*<%C1.Router>[^<KEY><nlsr>]*<KEY><><><>$
}
checker
{
+26 -58
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -29,7 +29,7 @@
namespace nlsr {
INIT_LOGGER("AdjacencyList");
INIT_LOGGER(AdjacencyList);
AdjacencyList::AdjacencyList()
{
@@ -59,20 +59,6 @@ AdjacencyList::addAdjacents(AdjacencyList& adl)
}
}
bool
AdjacencyList::updateAdjacentStatus(const ndn::Name& adjName, Adjacent::Status s)
{
std::list<Adjacent>::iterator it = find(adjName);
if (it == m_adjList.end()) {
return false;
}
else {
it->setStatus(s);
return true;
}
}
Adjacent
AdjacencyList::getAdjacent(const ndn::Name& adjName)
{
@@ -85,51 +71,22 @@ AdjacencyList::getAdjacent(const ndn::Name& adjName)
}
bool
AdjacencyList::operator==(AdjacencyList& adl) const
AdjacencyList::operator==(const AdjacencyList& adl) const
{
if (size() != adl.size()) {
if (m_adjList.size() != adl.getAdjList().size()) {
return false;
}
auto comparator =
[] (const Adjacent* lhs, const Adjacent* rhs) {
return *lhs < *rhs;
};
std::set<Adjacent> ourList(m_adjList.cbegin(), m_adjList.cend());
std::set<Adjacent> theirList(adl.getAdjList().cbegin(), adl.getAdjList().cend());
std::vector<const Adjacent*> ourList;
std::transform(m_adjList.begin(), m_adjList.end(),
std::back_inserter(ourList), std::pointer_traits<const Adjacent*>::pointer_to);
std::vector<const Adjacent*> theirList;
std::transform(adl.getAdjList().begin(), adl.getAdjList().end(),
std::back_inserter(theirList), std::pointer_traits<const Adjacent*>::pointer_to);
std::sort(ourList.begin(), ourList.end(), std::bind(comparator, _1, _2));
std::sort(theirList.begin(), theirList.end(), std::bind(comparator, _1, _2));
for (size_t i = 0; i < ourList.size(); i++) {
if (*(ourList[i]) != *(theirList[i])) {
return false;
}
}
return true;
}
int32_t
AdjacencyList::updateAdjacentLinkCost(const ndn::Name& adjName, double lc)
{
std::list<Adjacent>::iterator it = find(adjName);
if (it == m_adjList.end()) {
return -1;
}
(*it).setLinkCost(lc);
return 0;
return ourList == theirList;
}
bool
AdjacencyList::isNeighbor(const ndn::Name& adjName)
AdjacencyList::isNeighbor(const ndn::Name& adjName) const
{
std::list<Adjacent>::iterator it = find(adjName);
std::list<Adjacent>::const_iterator it = find(adjName);
if (it == m_adjList.end())
{
return false;
@@ -158,9 +115,9 @@ AdjacencyList::setTimedOutInterestCount(const ndn::Name& neighbor,
}
int32_t
AdjacencyList::getTimedOutInterestCount(const ndn::Name& neighbor)
AdjacencyList::getTimedOutInterestCount(const ndn::Name& neighbor) const
{
std::list<Adjacent>::iterator it = find(neighbor);
std::list<Adjacent>::const_iterator it = find(neighbor);
if (it == m_adjList.end()) {
return -1;
}
@@ -168,9 +125,9 @@ AdjacencyList::getTimedOutInterestCount(const ndn::Name& neighbor)
}
Adjacent::Status
AdjacencyList::getStatusOfNeighbor(const ndn::Name& neighbor)
AdjacencyList::getStatusOfNeighbor(const ndn::Name& neighbor) const
{
std::list<Adjacent>::iterator it = find(neighbor);
std::list<Adjacent>::const_iterator it = find(neighbor);
if (it == m_adjList.end()) {
return Adjacent::STATUS_UNKNOWN;
@@ -225,10 +182,10 @@ AdjacencyList::isAdjLsaBuildable(const uint32_t interestRetryNo) const
}
int32_t
AdjacencyList::getNumOfActiveNeighbor()
AdjacencyList::getNumOfActiveNeighbor() const
{
int32_t actNbrCount = 0;
for (std::list<Adjacent>::iterator it = m_adjList.begin(); it != m_adjList.end(); it++) {
for (std::list<Adjacent>::const_iterator it = m_adjList.begin(); it != m_adjList.end(); it++) {
if (it->getStatus() == Adjacent::STATUS_ACTIVE) {
actNbrCount++;
@@ -247,6 +204,17 @@ AdjacencyList::find(const ndn::Name& adjName)
return it;
}
std::list<Adjacent>::const_iterator
AdjacencyList::find(const ndn::Name& adjName) const
{
std::list<Adjacent>::const_iterator it = std::find_if(m_adjList.cbegin(),
m_adjList.cend(),
std::bind(&Adjacent::compare,
_1, std::cref(adjName)));
return it;
}
AdjacencyList::iterator
AdjacencyList::findAdjacent(const ndn::Name& adjName)
{
+9 -21
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -52,21 +52,6 @@ public:
int32_t
insert(Adjacent& adjacent);
/*! \brief Sets the status of an adjacency.
\param adjName The adjacency in this list you want to change the status of.
\param s The status to change to.
\return A boolean indicating whether an adjacency was
updated. This is false if s is not in the list.
*/
bool
updateAdjacentStatus(const ndn::Name& adjName, Adjacent::Status s);
int32_t
updateAdjacentLinkCost(const ndn::Name& adjName, double lc);
std::list<Adjacent>&
getAdjList();
@@ -74,16 +59,16 @@ public:
getAdjList() const;
bool
isNeighbor(const ndn::Name& adjName);
isNeighbor(const ndn::Name& adjName) const;
void
incrementTimedOutInterestCount(const ndn::Name& neighbor);
int32_t
getTimedOutInterestCount(const ndn::Name& neighbor);
getTimedOutInterestCount(const ndn::Name& neighbor) const;
Adjacent::Status
getStatusOfNeighbor(const ndn::Name& neighbor);
getStatusOfNeighbor(const ndn::Name& neighbor) const;
void
setStatusOfNeighbor(const ndn::Name& neighbor, Adjacent::Status status);
@@ -120,13 +105,13 @@ public:
isAdjLsaBuildable(const uint32_t interestRetryNo) const;
int32_t
getNumOfActiveNeighbor();
getNumOfActiveNeighbor() const;
Adjacent
getAdjacent(const ndn::Name& adjName);
bool
operator==(AdjacencyList& adl) const;
operator==(const AdjacencyList& adl) const;
size_t
size() const
@@ -187,6 +172,9 @@ private:
iterator
find(const ndn::Name& adjName);
const_iterator
find(const ndn::Name& adjName) const;
private:
std::list<Adjacent> m_adjList;
};
+2 -2
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -28,7 +28,7 @@
namespace nlsr {
INIT_LOGGER("Adjacent");
INIT_LOGGER(Adjacent);
const float Adjacent::DEFAULT_LINK_COST = 10.0;
+4 -4
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -140,19 +140,19 @@ public:
operator<(const Adjacent& adjacent) const;
inline bool
compare(const ndn::Name& adjacencyName)
compare(const ndn::Name& adjacencyName) const
{
return m_name == adjacencyName;
}
inline bool
compareFaceId(const uint64_t faceId)
compareFaceId(const uint64_t faceId) const
{
return m_faceId == faceId;
}
inline bool
compareFaceUri(const ndn::FaceUri& faceUri)
compareFaceUri(const ndn::FaceUri& faceUri) const
{
return m_faceUri == faceUri;
}
+16 -9
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -28,9 +28,9 @@
namespace nlsr {
INIT_LOGGER("SyncLogicHandler");
INIT_LOGGER(SyncLogicHandler);
const std::string NLSR_COMPONENT = "NLSR";
const std::string NLSR_COMPONENT = "nlsr";
const std::string LSA_COMPONENT = "LSA";
template<class T>
@@ -43,7 +43,8 @@ public:
}
};
SyncLogicHandler::SyncLogicHandler(ndn::Face& face, const IsLsaNew& isLsaNew, ConfParameter& conf)
SyncLogicHandler::SyncLogicHandler(ndn::Face& face, const IsLsaNew& isLsaNew,
const ConfParameter& conf)
: onNewLsa(ndn::make_unique<OnNewLsa>())
, m_syncFace(face)
, m_isLsaNew(isLsaNew)
@@ -52,7 +53,7 @@ SyncLogicHandler::SyncLogicHandler(ndn::Face& face, const IsLsaNew& isLsaNew, Co
}
void
SyncLogicHandler::createSyncSocket(const ndn::Name& syncPrefix)
SyncLogicHandler::createSyncSocket(const ndn::Name& syncPrefix, const ndn::time::milliseconds& syncInterestLifetime)
{
if (m_syncSocket != nullptr) {
NLSR_LOG_WARN("Trying to create Sync socket, but Sync socket already exists");
@@ -70,14 +71,21 @@ SyncLogicHandler::createSyncSocket(const ndn::Name& syncPrefix)
// of the object
std::shared_ptr<ndn::Face> facePtr(&m_syncFace, NullDeleter<ndn::Face>());
const auto fixedSession = ndn::name::Component::fromNumber(0);
m_syncSocket = std::make_shared<chronosync::Socket>(m_syncPrefix, m_nameLsaUserPrefix, *facePtr,
std::bind(&SyncLogicHandler::onChronoSyncUpdate, this, _1));
std::bind(&SyncLogicHandler::onChronoSyncUpdate, this, _1),
chronosync::Socket::DEFAULT_NAME, chronosync::Socket::DEFAULT_VALIDATOR,
syncInterestLifetime, fixedSession);
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
m_syncSocket->addSyncNode(m_adjLsaUserPrefix);
m_syncSocket->addSyncNode(m_adjLsaUserPrefix, chronosync::Socket::DEFAULT_NAME, fixedSession);
}
else if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
m_syncSocket->addSyncNode(m_coorLsaUserPrefix, chronosync::Socket::DEFAULT_NAME, fixedSession);
}
else {
m_syncSocket->addSyncNode(m_coorLsaUserPrefix);
m_syncSocket->addSyncNode(m_adjLsaUserPrefix, chronosync::Socket::DEFAULT_NAME, fixedSession);
m_syncSocket->addSyncNode(m_coorLsaUserPrefix, chronosync::Socket::DEFAULT_NAME, fixedSession);
}
}
@@ -152,7 +160,6 @@ SyncLogicHandler::publishRoutingUpdate(const Lsa::Type& type, const uint64_t& se
BOOST_THROW_EXCEPTION(SyncLogicHandler::Error("Cannot publish routing update; SyncSocket does not exist"));
}
switch (type) {
case Lsa::Type::ADJACENCY:
publishSyncUpdate(m_adjLsaUserPrefix, seqNo);
+7 -3
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -22,6 +22,7 @@
#ifndef NLSR_SYNC_LOGIC_HANDLER_HPP
#define NLSR_SYNC_LOGIC_HANDLER_HPP
#include "conf-parameter.hpp"
#include "test-access-control.hpp"
#include "signals.hpp"
#include "lsa.hpp"
@@ -61,7 +62,7 @@ public:
}
};
SyncLogicHandler(ndn::Face& face, const IsLsaNew& isLsaNew, ConfParameter& conf);
SyncLogicHandler(ndn::Face& face, const IsLsaNew& isLsaNew, const ConfParameter& conf);
/*! \brief Hook function to call whenever sync detects new data.
*
@@ -90,10 +91,13 @@ public:
*
* In a typical situation this only needs to be called once, when NLSR starts.
* \param syncPrefix The sync prefix you want this ChronoSync to use
* \param syncInterestLifetime ChronoSync sends a periodic sync interest every \p syncInterestLifetime / 2 ms
* \sa Nlsr::initialize
*/
void
createSyncSocket(const ndn::Name& syncPrefix);
createSyncSocket(const ndn::Name& syncPrefix,
const ndn::time::milliseconds& syncInterestLifetime =
ndn::time::milliseconds(SYNC_INTEREST_LIFETIME_DEFAULT));
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
/*! \brief Simple function to glue Name components together
+8 -63
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -287,49 +287,16 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
return false;
}
// log-level
std::string logLevel = section.get<std::string>("log-level", "INFO");
if (isValidLogLevel(logLevel)) {
m_nlsr.getConfParameter().setLogLevel(logLevel);
uint32_t syncInterestLifetime = section.get<uint32_t>("sync-interest-lifetime", SYNC_INTEREST_LIFETIME_DEFAULT);
if (syncInterestLifetime >= SYNC_INTEREST_LIFETIME_MIN &&
syncInterestLifetime <= SYNC_INTEREST_LIFETIME_MAX) {
m_nlsr.getConfParameter().setSyncInterestLifetime(syncInterestLifetime);
}
else {
std::cerr << "Invalid value for log-level ";
std::cerr << "Valid values: ALL, TRACE, DEBUG, INFO, WARN, ERROR, NONE" << std::endl;
return false;
}
std::cerr << "Wrong value for sync-interest-lifetime. "
<< "Allowed value:" << SYNC_INTEREST_LIFETIME_MIN << "-"
<< SYNC_INTEREST_LIFETIME_MAX << std::endl;
try {
std::string logDir = section.get<std::string>("log-dir");
if (boost::filesystem::exists(logDir)) {
if (boost::filesystem::is_directory(logDir)) {
std::string testFileName=logDir+"/test.log";
std::ofstream testOutFile;
testOutFile.open(testFileName.c_str());
if (testOutFile.is_open() && testOutFile.good()) {
m_nlsr.getConfParameter().setLogDir(logDir);
}
else {
std::cerr << "User does not have read and write permission on the directory";
std::cerr << std::endl;
return false;
}
testOutFile.close();
remove(testFileName.c_str());
}
else {
std::cerr << "Provided path is not a directory" << std::endl;
return false;
}
}
else {
std::cerr << "Provided log directory <" << logDir << "> does not exist" << std::endl;
return false;
}
}
catch (const std::exception& ex) {
std::cerr << "You must configure log directory" << std::endl;
std::cerr << ex.what() << std::endl;
return false;
}
@@ -367,28 +334,6 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
return false;
}
try {
std::string log4cxxPath = section.get<std::string>("log4cxx-conf");
if (log4cxxPath == "") {
std::cerr << "No value provided for log4cxx-conf" << std::endl;
return false;
}
if (boost::filesystem::exists(log4cxxPath)) {
m_nlsr.getConfParameter().setLog4CxxConfPath(log4cxxPath);
}
else {
std::cerr << "Provided path for log4cxx-conf <" << log4cxxPath
<< "> does not exist" << std::endl;
return false;
}
}
catch (const std::exception& ex) {
// Variable is optional so default configuration will be used; continue processing file
}
return true;
}
+2 -2
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -83,7 +83,7 @@ private:
bool
processSection(const std::string& sectionName, const ConfigSection& section);
/*! \brief Parse general options, including router name, logging directory, LSA refresh.
/*! \brief Parse general options, including router name, LSA refresh.
*/
bool
processConfSectionGeneral(const ConfigSection& section);
+22 -3
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -26,7 +26,10 @@
namespace nlsr {
INIT_LOGGER("ConfParameter");
INIT_LOGGER(ConfParameter);
// To be changed when breaking changes are made to sync
const uint64_t ConfParameter::SYNC_VERSION = 5;
void
ConfParameter::writeLog()
@@ -51,7 +54,6 @@ ConfParameter::writeLog()
for (auto const& value: m_corTheta) {
NLSR_LOG_INFO("Hyp Angle " << i++ << ": "<< value);
}
NLSR_LOG_INFO("Log Directory: " << m_logDir);
NLSR_LOG_INFO("Seq Directory: " << m_seqFileDir);
// Event Intervals
@@ -60,4 +62,21 @@ ConfParameter::writeLog()
NLSR_LOG_INFO("Routing calculation interval: " << m_routingCalcInterval);
}
void
ConfParameter::setNetwork(const ndn::Name& networkName)
{
m_network = networkName;
m_chronosyncPrefix.append("localhop");
m_chronosyncPrefix.append(m_network);
m_chronosyncPrefix.append("nlsr");
m_chronosyncPrefix.append("sync");
m_chronosyncPrefix.appendVersion(SYNC_VERSION);
m_lsaPrefix.append("localhop");
m_lsaPrefix.append(m_network);
m_lsaPrefix.append("nlsr");
m_lsaPrefix.append("LSA");
}
} // namespace nlsr
+18 -57
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -24,6 +24,7 @@
#include "common.hpp"
#include "logger.hpp"
#include "test-access-control.hpp"
#include <iostream>
#include <boost/cstdint.hpp>
@@ -106,6 +107,12 @@ enum HyperbolicState {
HYPERBOLIC_STATE_DEFAULT = 0
};
enum {
SYNC_INTEREST_LIFETIME_MIN = 1000,
SYNC_INTEREST_LIFETIME_DEFAULT = 60000,
SYNC_INTEREST_LIFETIME_MAX = 120000,
};
/*! \brief A class to house all the configuration parameters for NLSR.
*
* This class is conceptually a singleton (but not mechanically) which
@@ -136,25 +143,12 @@ public:
, m_hyperbolicState(HYPERBOLIC_STATE_OFF)
, m_corR(0)
, m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN)
, m_isLog4cxxConfAvailable(false)
, m_syncInterestLifetime(ndn::time::milliseconds(SYNC_INTEREST_LIFETIME_DEFAULT))
{
}
void
setNetwork(const ndn::Name& networkName)
{
m_network = networkName;
m_chronosyncPrefix.append("localhop");
m_chronosyncPrefix.append(m_network);
m_chronosyncPrefix.append("NLSR");
m_chronosyncPrefix.append("sync");
m_lsaPrefix.append("localhop");
m_lsaPrefix.append(m_network);
m_lsaPrefix.append("NLSR");
m_lsaPrefix.append("LSA");
}
setNetwork(const ndn::Name& networkName);
const ndn::Name&
getNetwork() const
@@ -309,18 +303,6 @@ public:
return m_faceDatasetFetchInterval;
}
void
setLogLevel(const std::string& logLevel)
{
m_logLevel = logLevel;
}
const std::string&
getLogLevel() const
{
return m_logLevel;
}
void
setInterestRetryNumber(uint32_t irn)
{
@@ -409,18 +391,6 @@ public:
return m_maxFacesPerPrefix;
}
void
setLogDir(const std::string& logDir)
{
m_logDir = logDir;
}
const std::string&
getLogDir() const
{
return m_logDir;
}
void
setSeqFileDir(const std::string& ssfd)
{
@@ -433,27 +403,18 @@ public:
return m_seqFileDir;
}
bool
isLog4CxxConfAvailable() const
{
return m_isLog4cxxConfAvailable;
}
void
setLog4CxxConfPath(const std::string& path)
setSyncInterestLifetime(uint32_t syncInterestLifetime)
{
m_log4CxxConfPath = path;
m_isLog4cxxConfAvailable = true;
m_syncInterestLifetime = ndn::time::milliseconds(syncInterestLifetime);
}
const std::string&
getLog4CxxConfPath() const
const ndn::time::milliseconds&
getSyncInterestLifetime() const
{
return m_log4CxxConfPath;
return m_syncInterestLifetime;
}
/*! \brief Dump the current state of all attributes to the log.
*/
void
writeLog();
@@ -492,11 +453,11 @@ private:
uint32_t m_maxFacesPerPrefix;
std::string m_logDir;
std::string m_seqFileDir;
ndn::time::milliseconds m_syncInterestLifetime;
bool m_isLog4cxxConfAvailable;
std::string m_log4CxxConfPath;
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
static const uint64_t SYNC_VERSION;
};
} // namespace nlsr
+3 -3
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -27,10 +27,10 @@
namespace nlsr {
INIT_LOGGER("HelloProtocol");
INIT_LOGGER(HelloProtocol);
const std::string HelloProtocol::INFO_COMPONENT = "INFO";
const std::string HelloProtocol::NLSR_COMPONENT = "NLSR";
const std::string HelloProtocol::NLSR_COMPONENT = "nlsr";
HelloProtocol::HelloProtocol(Nlsr& nlsr, ndn::Scheduler& scheduler)
: m_nlsr(nlsr)
-86
View File
@@ -1,86 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2017, The University of Memphis,
* Regents of the University of California
*
* 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 "logger.hpp"
#include <log4cxx/logger.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/xml/domconfigurator.h>
#include <log4cxx/propertyconfigurator.h>
#include <log4cxx/patternlayout.h>
#include <log4cxx/level.h>
#include <log4cxx/helpers/exception.h>
#include <log4cxx/rollingfileappender.h>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
void
INIT_LOG4CXX(const std::string& log4cxxConfPath)
{
if (boost::filesystem::path(log4cxxConfPath).extension().string() == ".xml") {
log4cxx::xml::DOMConfigurator::configure(log4cxxConfPath);
}
else {
log4cxx::PropertyConfigurator::configure(log4cxxConfPath);
}
}
void
INIT_LOGGERS(const std::string& logDir, const std::string& logLevel)
{
static bool configured = false;
if (configured) {
return;
}
log4cxx::PatternLayoutPtr
layout(new log4cxx::PatternLayout("%date{%s}.%date{SSS} %p: [%c] %m%n"));
log4cxx::RollingFileAppender* rollingFileAppender =
new log4cxx::RollingFileAppender(layout, logDir+"/nlsr.log", true);
rollingFileAppender->setMaxFileSize("10MB");
rollingFileAppender->setMaxBackupIndex(10);
log4cxx::helpers::Pool p;
rollingFileAppender->activateOptions(p);
log4cxx::BasicConfigurator::configure(log4cxx::AppenderPtr(rollingFileAppender));
if (boost::iequals(logLevel, "none")) {
log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getOff());
}
else {
log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::toLevel(logLevel));
}
configured = true;
}
bool
isValidLogLevel(const std::string& logLevel)
{
return boost::iequals(logLevel, "all") || boost::iequals(logLevel, "trace") ||
boost::iequals(logLevel, "debug") || boost::iequals(logLevel, "info") ||
boost::iequals(logLevel, "warn") || boost::iequals(logLevel, "error") ||
boost::iequals(logLevel, "none");
}
+9 -30
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -30,36 +30,15 @@
#ifndef NLSR_LOGGER_HPP
#define NLSR_LOGGER_HPP
#include <log4cxx/logger.h>
#include <ndn-cxx/util/logger.hpp>
#define INIT_LOGGER(name) \
static log4cxx::LoggerPtr staticModuleLogger = log4cxx::Logger::getLogger(name)
#define INIT_LOGGER(name) NDN_LOG_INIT(nlsr.name)
#define NLSR_LOG_TRACE(x) \
LOG4CXX_TRACE(staticModuleLogger, x)
#define NLSR_LOG_DEBUG(x) \
LOG4CXX_DEBUG(staticModuleLogger, x)
#define NLSR_LOG_INFO(x) \
LOG4CXX_INFO(staticModuleLogger, x)
#define NLSR_LOG_WARN(x) \
LOG4CXX_WARN(staticModuleLogger, x)
#define NLSR_LOG_ERROR(x) \
LOG4CXX_ERROR(staticModuleLogger, x)
#define NLSR_LOG_FATAL(x) \
LOG4CXX_FATAL(staticModuleLogger, x);
void
INIT_LOGGERS(const std::string& logDir, const std::string& logLevel);
void
INIT_LOG4CXX(const std::string& log4cxxConfPath);
bool
isValidLogLevel(const std::string& logLevel);
#define NLSR_LOG_TRACE(x) NDN_LOG_TRACE(x)
#define NLSR_LOG_DEBUG(x) NDN_LOG_DEBUG(x)
#define NLSR_LOG_INFO(x) NDN_LOG_INFO(x)
#define NLSR_LOG_WARN(x) NDN_LOG_WARN(x)
#define NLSR_LOG_ERROR(x) NDN_LOG_ERROR(x)
#define NLSR_LOG_FATAL(x) NDN_LOG_FATAL(x)
#endif // NLSR_LOGGER_HPP
+162
View File
@@ -0,0 +1,162 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2018, 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-segment-storage.hpp"
#include "logger.hpp"
#include "lsa.hpp"
#include "utility/name-helper.hpp"
#include "conf-parameter.hpp"
namespace nlsr {
INIT_LOGGER(LsaSegmentStorage);
LsaSegmentStorage::LsaSegmentStorage(ndn::Scheduler& scheduler)
: m_scheduler(scheduler)
{
}
void
LsaSegmentStorage::connectToFetcher(ndn::util::SegmentFetcher& fetcher)
{
fetcher.afterSegmentValidated.connect(std::bind(&LsaSegmentStorage::afterFetcherSignalEmitted,
this, _1));
}
const ndn::Data*
LsaSegmentStorage::getLsaSegment(const ndn::Interest& interest)
{
ndn::Name lsaSegmentsKey = interest.getName();
// If this is the first interest then it does not contain the segment number,
// so need to append zero segment component at the end to match with the data
if (lsaSegmentsKey.size() > 0) {
if (!lsaSegmentsKey.get(-1).isSegment()) {
lsaSegmentsKey.appendSegment(0);
}
auto it = m_lsaSegments.find(lsaSegmentsKey);
if (it == m_lsaSegments.end()) {
NLSR_LOG_TRACE("Data for interest: " << interest.getName() << " cannot be found in the lsa storage");
return nullptr;
}
else {
NLSR_LOG_TRACE("Data for interest: " << interest.getName() << " is in the storage.");
return &(it->second);
}
}
else {
NLSR_LOG_ERROR("Received interest has empty name.");
return nullptr;
}
}
void
LsaSegmentStorage::afterFetcherSignalEmitted(const ndn::Data& lsaSegment)
{
NLSR_LOG_TRACE("Received a LSA segment: " << lsaSegment.getName());
// lsaSegmentName is /<router-prefix>/<LS type>/<sequence no.>/<version no.>/<segment no.>
auto lsaSegmentName = lsaSegment.getName();
if (lsaSegmentName.size() > 0) {
// lsaSegmentsKey is /<router-prefix>/<LS type>/<sequence no.>/<segment no.>
ndn::Name lsaSegmentsKey(lsaSegmentName.getPrefix(lsaSegmentName.size() - 2));
lsaSegmentsKey.append(lsaSegmentName.get(-1));
// No need to store same LSA multiple time
if (m_lsaSegments.find(lsaSegmentsKey) == m_lsaSegments.end()) {
NLSR_LOG_TRACE("Received LSA segment is new. Storing it in the storage.\n"
<< " LSA data name: " << lsaSegmentName);
// Delete the same LSA with lower sequence number
deleteOldLsas(lsaSegmentName);
m_lsaSegments[lsaSegmentsKey] = lsaSegment;
}
else {
NLSR_LOG_TRACE("The received segment is already in the storage.");
}
std::string content(reinterpret_cast<const char*>(lsaSegment.getContent().value()),
lsaSegment.getContent().value_size());
ndn::time::seconds expirationTime(LSA_REFRESH_TIME_DEFAULT);
std::vector<std::string> options;
boost::split(options, content, boost::is_any_of("|"));
try {
expirationTime = ndn::time::duration_cast<ndn::time::seconds>
(ndn::time::fromIsoString(options.at(3)) - ndn::time::system_clock::now());
} catch (const std::exception& e) {
NLSR_LOG_ERROR("Cannot extract expiration time from LSA content: " << e.what());
}
// schedule the segment deletion
scheduleLsaSegmentDeletion(lsaSegmentsKey, expirationTime);
}
else {
NLSR_LOG_ERROR("The received LSA segment has empty name.");
}
}
void
LsaSegmentStorage::deleteOldLsas(const ndn::Name& newLsaName)
{
auto newLsaKey = newLsaName.getPrefix(newLsaName.size() - 3);
auto newSeqNo = newLsaName.get(-3).toNumber();
std::vector<decltype(m_lsaSegments)::key_type> lsaToDelete;
for (const auto& segment : m_lsaSegments) {
ndn::Name segmentKey = segment.first;
auto oldSeqNo = segmentKey.get(-2).toNumber();
auto existingLsaKey = segmentKey.getPrefix(segmentKey.size() - 2);
if (newLsaKey == existingLsaKey) {
if (newSeqNo > oldSeqNo) { // in the key the second last component is the sequence number
NLSR_LOG_TRACE("Outdated LSA: " << segmentKey << " with seq no: " <<
oldSeqNo << " is deleted.");
lsaToDelete.push_back(segmentKey);
}
}
}
for (const auto& segmentKey : lsaToDelete) {
m_lsaSegments.erase(segmentKey);
}
}
void
LsaSegmentStorage::scheduleLsaSegmentDeletion(const ndn::Name& lsaSegmentsKey,
ndn::time::seconds expirationTime)
{
NLSR_LOG_TRACE("Scheduling LSA segment deletion for "
<< lsaSegmentsKey << " in: " << expirationTime);
m_scheduler.scheduleEvent(expirationTime,
[lsaSegmentsKey, this] {
m_lsaSegments.erase(lsaSegmentsKey);
});
}
} // namespace nlsr
+85
View File
@@ -0,0 +1,85 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2018, 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/>.
**/
#ifndef NLSR_LSA_SEGMENT_STORAGE_HPP
#define NLSR_LSA_SEGMENT_STORAGE_HPP
#include "test-access-control.hpp"
#include <ndn-cxx/util/segment-fetcher.hpp>
#include <ndn-cxx/util/signal.hpp>
#include <ndn-cxx/util/time.hpp>
#include <vector>
#include <tuple>
namespace nlsr {
class LsaSegmentStorage
{
public:
LsaSegmentStorage(ndn::Scheduler& scheduler);
/*! \brief Get connected to the signal emitted by SegmentFetcher
* \param fetcher The SegmentFetcher to whose signal LsaSegmentStorage will subscribe to.
*/
void
connectToFetcher(ndn::util::SegmentFetcher& fetcher);
/*! \brief Returns an LSA segment for an interest from LsaSegmentStorage
* \param interest Interest corresponding to the returned LSA segment.
*/
const ndn::Data*
getLsaSegment(const ndn::Interest& interest);
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
/*! \brief Callback when SegmentFetcher retrieves a segment.
*/
void
afterFetcherSignalEmitted(const ndn::Data& lsaSegment);
private:
/*! \brief Given an LSA name check whether Data for the same name exists in the
* LsaSegmentStorage. If the matched LSA data are of a lower sequence number,
* then remove them from LsaSegmentStorage.
* \param newLsaName Name of the LSA that will be matched against
*/
void
deleteOldLsas(const ndn::Name& newLsaName);
/*! \brief Schedules the deletion of a LSA data given the segmentKey
*/
void
scheduleLsaSegmentDeletion(const ndn::Name& segmentKey, ndn::time::seconds expirationTime);
private:
ndn::Scheduler& m_scheduler;
// Key: /<router-prefix>/<LS type>/<sequence no.>/<segment no.>
// Value: corresponding LSA data packet
// Data name: /<router-prefix>/<LS type>/<sequence no.>/<version no.>/<segment no.>
std::unordered_map<ndn::Name, ndn::Data> m_lsaSegments;
};
} // namespace nlsr
#endif // NLSR_LSA_SEGMENT_STORAGE_HPP
+4 -4
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -35,7 +35,7 @@
namespace nlsr {
INIT_LOGGER("Lsa");
INIT_LOGGER(Lsa);
std::string
Lsa::getData() const
@@ -138,7 +138,7 @@ CoordinateLsa::CoordinateLsa(const ndn::Name& origR, uint32_t lsn,
}
bool
CoordinateLsa::isEqualContent(const CoordinateLsa& clsa)
CoordinateLsa::isEqualContent(const CoordinateLsa& clsa) const
{
if (clsa.getCorTheta().size() != m_angles.size()) {
return false;
@@ -213,7 +213,7 @@ AdjLsa::AdjLsa(const ndn::Name& origR, uint32_t lsn,
}
bool
AdjLsa::isEqualContent(AdjLsa& alsa)
AdjLsa::isEqualContent(const AdjLsa& alsa) const
{
return m_adl == alsa.getAdl();
}
+11 -8
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
*/
#ifndef NLSR_LSA_HPP
#define NLSR_LSA_HPP
@@ -54,6 +54,9 @@ public:
{
}
virtual
~Lsa() = default;
virtual Type
getType() const
{
@@ -155,7 +158,7 @@ protected:
ndn::EventId m_expiringEventId;
};
class NameLsa: public Lsa
class NameLsa : public Lsa
{
public:
NameLsa()
@@ -229,7 +232,7 @@ private:
operator<<(std::ostream& os, const NameLsa& lsa);
};
class AdjLsa: public Lsa
class AdjLsa : public Lsa
{
public:
typedef AdjacencyList::const_iterator const_iterator;
@@ -281,7 +284,7 @@ public:
}
bool
isEqualContent(AdjLsa& alsa);
isEqualContent(const AdjLsa& alsa) const;
/*! \brief Installs this LSA's name prefixes into the NPT.
@@ -327,7 +330,7 @@ private:
operator<<(std::ostream& os, const AdjLsa& lsa);
};
class CoordinateLsa: public Lsa
class CoordinateLsa : public Lsa
{
public:
CoordinateLsa()
@@ -381,7 +384,7 @@ public:
}
bool
isEqualContent(const CoordinateLsa& clsa);
isEqualContent(const CoordinateLsa& clsa) const;
void
writeLog() const override;
+66 -31
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -22,6 +22,7 @@
#include "lsdb.hpp"
#include "logger.hpp"
#include "lsa-segment-storage.hpp"
#include "nlsr.hpp"
#include "publisher/segment-publisher.hpp"
#include "utility/name-helper.hpp"
@@ -31,7 +32,7 @@
namespace nlsr {
INIT_LOGGER("Lsdb");
INIT_LOGGER(Lsdb);
class LsaContentPublisher : public SegmentPublisher<ndn::Face>
{
@@ -71,6 +72,7 @@ Lsdb::Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler)
const uint64_t& sequenceNumber) {
return isLsaNew(routerName, lsaType, sequenceNumber);
}, m_nlsr.getConfParameter())
, m_lsaStorage(scheduler)
, m_lsaRefreshTime(0)
, m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
, m_sequencingManager()
@@ -212,6 +214,7 @@ Lsdb::scheduleNameLsaExpiration(const ndn::Name& key, int seqNo,
bool
Lsdb::installNameLsa(NameLsa& nlsa)
{
NLSR_LOG_TRACE("installNameLsa");
ndn::time::seconds timeToExpire = m_lsaRefreshTime;
NameLsa* chkNameLsa = findNameLsa(nlsa.getKey());
// Determines if the name LSA is new or not.
@@ -221,6 +224,9 @@ Lsdb::installNameLsa(NameLsa& nlsa)
NLSR_LOG_DEBUG("Adding Name Lsa");
nlsa.writeLog();
NLSR_LOG_TRACE("nlsa.getOrigRouter(): " << nlsa.getOrigRouter());
NLSR_LOG_TRACE("m_nlsr.getConfParameter().getRouterPrefix(): " << m_nlsr.getConfParameter().getRouterPrefix());
if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
// If this name LSA is from another router, add the advertised
// prefixes to the NPT.
@@ -245,6 +251,9 @@ Lsdb::installNameLsa(NameLsa& nlsa)
}
// Else this is a known name LSA, so we are updating it.
else {
NLSR_LOG_TRACE("Known name lsa");
NLSR_LOG_TRACE("chkNameLsa->getLsSeqNo(): " << chkNameLsa->getLsSeqNo());
NLSR_LOG_TRACE("nlsa.getLsSeqNo(): " << nlsa.getLsSeqNo());
if (chkNameLsa->getLsSeqNo() < nlsa.getLsSeqNo()) {
NLSR_LOG_DEBUG("Updated Name LSA. Updating LSDB");
NLSR_LOG_DEBUG("Deleting Name Lsa");
@@ -999,11 +1008,16 @@ Lsdb::expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
interest.setInterestLifetime(m_nlsr.getConfParameter().getLsaInterestLifetime());
NLSR_LOG_DEBUG("Fetching Data for LSA: " << interestName << " Seq number: " << seqNo);
ndn::util::SegmentFetcher::fetch(m_nlsr.getNlsrFace(), interest,
m_nlsr.getValidator(),
std::bind(&Lsdb::afterFetchLsa, this, _1, interestName),
std::bind(&Lsdb::onFetchLsaError, this, _1, _2, interestName,
timeoutCount, deadline, lsaName, seqNo));
shared_ptr<ndn::util::SegmentFetcher> fetcher =
ndn::util::SegmentFetcher::fetch(m_nlsr.getNlsrFace(), interest,
m_nlsr.getValidator(),
std::bind(&Lsdb::afterFetchLsa, this, _1, interestName),
std::bind(&Lsdb::onFetchLsaError, this, _1, _2, interestName,
timeoutCount, deadline, lsaName, seqNo));
m_lsaStorage.connectToFetcher(*fetcher);
m_nlsr.connectToFetcher(*fetcher);
// increment a specific SENT_LSA_INTEREST
Lsa::Type lsaType;
std::istringstream(interestName[-2].toUri()) >> lsaType;
@@ -1034,35 +1048,49 @@ Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
std::string chkString("LSA");
int32_t lsaPosition = util::getNameComponentPosition(interest.getName(), chkString);
if (lsaPosition >= 0) {
// Forms the name of the router that the Interest packet came from.
ndn::Name originRouter = m_nlsr.getConfParameter().getNetwork();
originRouter.append(interestName.getSubName(lsaPosition + 1,
interest.getName().size() - lsaPosition - 3));
// Forms the name of the router that the Interest packet came from.
ndn::Name originRouter = m_nlsr.getConfParameter().getNetwork();
originRouter.append(interestName.getSubName(lsaPosition + 1,
interest.getName().size() - lsaPosition - 3));
// if the interest is for this router's LSA
if (originRouter == m_nlsr.getConfParameter().getRouterPrefix()) {
uint64_t seqNo = interestName[-1].toNumber();
NLSR_LOG_DEBUG("LSA sequence number from interest: " << seqNo);
if (lsaPosition >= 0) {
Lsa::Type interestedLsType;
std::istringstream(interestName[-2].toUri()) >> interestedLsType;
uint64_t seqNo = interestName[-1].toNumber();
NLSR_LOG_DEBUG("LSA sequence number from interest: " << seqNo);
if (interestedLsType == Lsa::Type::NAME) {
processInterestForNameLsa(interest, originRouter.append(std::to_string(interestedLsType)),
seqNo);
Lsa::Type interestedLsType;
std::istringstream(interestName[-2].toUri()) >> interestedLsType;
if (interestedLsType == Lsa::Type::NAME) {
processInterestForNameLsa(interest, originRouter.append(std::to_string(interestedLsType)),
seqNo);
}
else if (interestedLsType == Lsa::Type::ADJACENCY) {
processInterestForAdjacencyLsa(interest, originRouter.append(std::to_string(interestedLsType)),
seqNo);
}
else if (interestedLsType == Lsa::Type::COORDINATE) {
processInterestForCoordinateLsa(interest, originRouter.append(std::to_string(interestedLsType)),
seqNo);
}
else {
NLSR_LOG_WARN("Received unrecognized LSA type: " << interestedLsType);
}
lsaIncrementSignal(Statistics::PacketType::SENT_LSA_DATA);
}
else if (interestedLsType == Lsa::Type::ADJACENCY) {
processInterestForAdjacencyLsa(interest, originRouter.append(std::to_string(interestedLsType)),
seqNo);
}
else if (interestedLsType == Lsa::Type::COORDINATE) {
processInterestForCoordinateLsa(interest, originRouter.append(std::to_string(interestedLsType)),
seqNo);
}
else { // else the interest is for other router's lsa, serve from LsaSegmentStorage
const ndn::Data* lsaSegment = m_lsaStorage.getLsaSegment(interest);
if (lsaSegment != nullptr) {
NLSR_LOG_TRACE("Found data in lsa storage. Sending the data for " << interest.getName());
m_nlsr.getNlsrFace().put(*lsaSegment);
}
else {
NLSR_LOG_WARN("Received unrecognized LSA type: " << interestedLsType);
NLSR_LOG_TRACE(interest << " was not found in this lsa storage.");
}
lsaIncrementSignal(Statistics::PacketType::SENT_LSA_DATA);
}
}
@@ -1096,10 +1124,15 @@ Lsdb::processInterestForNameLsa(const ndn::Interest& interest,
lsaIncrementSignal(Statistics::PacketType::RCV_NAME_LSA_INTEREST);
NLSR_LOG_DEBUG("nameLsa interest " << interest << " received");
NameLsa* nameLsa = m_nlsr.getLsdb().findNameLsa(lsaKey);
if (nameLsa != 0) {
if (nameLsa != nullptr) {
NLSR_LOG_TRACE("Verifying SeqNo for NameLsa is same as requested.");
if (nameLsa->getLsSeqNo() == seqNo) {
// if requested lsa belongs to this router then sign it and serve it
std::string content = nameLsa->serialize();
putLsaData(interest,content);
// else the requested belongs to neighboring routers, so serve the
// original data packet corresponding to the lsa
// increment SENT_NAME_LSA_DATA
lsaIncrementSignal(Statistics::PacketType::SENT_NAME_LSA_DATA);
}
@@ -1130,7 +1163,8 @@ Lsdb::processInterestForAdjacencyLsa(const ndn::Interest& interest,
lsaIncrementSignal(Statistics::PacketType::RCV_ADJ_LSA_INTEREST);
NLSR_LOG_DEBUG("AdjLsa interest " << interest << " received");
AdjLsa* adjLsa = m_nlsr.getLsdb().findAdjLsa(lsaKey);
if (adjLsa != 0) {
if (adjLsa != nullptr) {
NLSR_LOG_TRACE("Verifying SeqNo for AdjLsa is same as requested.");
if (adjLsa->getLsSeqNo() == seqNo) {
std::string content = adjLsa->serialize();
putLsaData(interest,content);
@@ -1164,7 +1198,8 @@ Lsdb::processInterestForCoordinateLsa(const ndn::Interest& interest,
lsaIncrementSignal(Statistics::PacketType::RCV_COORD_LSA_INTEREST);
NLSR_LOG_DEBUG("CoordinateLsa interest " << interest << " received");
CoordinateLsa* corLsa = m_nlsr.getLsdb().findCoordinateLsa(lsaKey);
if (corLsa != 0) {
if (corLsa != nullptr) {
NLSR_LOG_TRACE("Verifying SeqNo for CoordinateLsa is same as requested.");
if (corLsa->getLsSeqNo() == seqNo) {
std::string content = corLsa->serialize();
putLsaData(interest,content);
+9 -2
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -24,6 +24,7 @@
#include "conf-parameter.hpp"
#include "lsa.hpp"
#include "lsa-segment-storage.hpp"
#include "sequencing-manager.hpp"
#include "test-access-control.hpp"
#include "communication/sync-logic-handler.hpp"
@@ -195,6 +196,12 @@ public:
return m_sequencingManager;
}
LsaSegmentStorage&
getLsaStorage()
{
return m_lsaStorage;
}
void
writeAdjLsdbLog();
@@ -381,6 +388,7 @@ private:
Nlsr& m_nlsr;
ndn::Scheduler& m_scheduler;
SyncLogicHandler m_sync;
LsaSegmentStorage m_lsaStorage;
std::list<NameLsa> m_nameLsdb;
std::list<AdjLsa> m_adjLsdb;
@@ -403,7 +411,6 @@ private:
SequencingManager m_sequencingManager;
ndn::util::signal::ScopedConnection m_onNewLsaConnection;
};
} // namespace nlsr
+27 -7
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -22,6 +22,30 @@
#include "nlsr-runner.hpp"
#include "version.hpp"
#include <boost/exception/get_error_info.hpp>
#include <sstream>
template<typename E>
std::string
getExtendedErrorMessage(const E& exception)
{
std::ostringstream errorMessage;
errorMessage << exception.what();
const char* const* file = boost::get_error_info<boost::throw_file>(exception);
const int* line = boost::get_error_info<boost::throw_line>(exception);
const char* const* func = boost::get_error_info<boost::throw_function>(exception);
if (file && line) {
errorMessage << " [from " << *file << ":" << *line;
if (func) {
errorMessage << " in " << *func;
}
errorMessage << "]";
}
return errorMessage.str();
}
int
main(int32_t argc, char** argv)
{
@@ -30,7 +54,6 @@ main(int32_t argc, char** argv)
std::string programName(argv[0]);
std::string configFileName = "nlsr.conf";
bool isDaemonProcess = false;
int32_t opt;
while ((opt = getopt(argc, argv, "df:hV")) != -1) {
@@ -38,9 +61,6 @@ main(int32_t argc, char** argv)
case 'f':
configFileName = optarg;
break;
case 'd':
isDaemonProcess = true;
break;
case 'V':
std::cout << NLSR_VERSION_BUILD_STRING << std::endl;
return EXIT_SUCCESS;
@@ -52,13 +72,13 @@ main(int32_t argc, char** argv)
}
}
NlsrRunner runner(configFileName, isDaemonProcess);
NlsrRunner runner(configFileName);
try {
runner.run();
}
catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
std::cerr << getExtendedErrorMessage(e) << std::endl;
return EXIT_FAILURE;
}
+2 -7
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -21,18 +21,13 @@
#include "name-prefix-list.hpp"
#include "common.hpp"
#include "logger.hpp"
#include <iostream>
#include <algorithm>
namespace nlsr {
INIT_LOGGER("NamePrefixList");
NamePrefixList::NamePrefixList()
{
}
NamePrefixList::NamePrefixList() = default;
NamePrefixList::NamePrefixList(const std::initializer_list<ndn::Name>& names)
{
+3 -17
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -20,21 +20,19 @@
**/
#include "nlsr-runner.hpp"
#include "conf-file-processor.hpp"
#include "logger.hpp"
namespace nlsr {
INIT_LOGGER("NlsrRunner");
INIT_LOGGER(NlsrRunner);
NlsrRunner::NlsrRunner(std::string& configFileName, bool isDaemonProcess)
NlsrRunner::NlsrRunner(std::string& configFileName)
: m_scheduler(m_ioService)
, m_face(m_ioService)
, m_nlsr(m_ioService, m_scheduler, m_face, m_keyChain)
{
m_nlsr.setConfFileName(configFileName);
m_nlsr.setIsDaemonProcess(isDaemonProcess);
}
void
@@ -46,17 +44,6 @@ NlsrRunner::run()
BOOST_THROW_EXCEPTION(Error("Error in configuration file processing! Exiting from NLSR"));
}
if (m_nlsr.getConfParameter().isLog4CxxConfAvailable()) {
INIT_LOG4CXX(m_nlsr.getConfParameter().getLog4CxxConfPath());
}
else {
INIT_LOGGERS(m_nlsr.getConfParameter().getLogDir(), m_nlsr.getConfParameter().getLogLevel());
}
if (m_nlsr.getIsSetDaemonProcess()) {
m_nlsr.daemonize();
}
/** Because URI canonization needs to occur before initialization,
we have to pass initialize as the finally() in neighbor
canonization.
@@ -86,7 +73,6 @@ NlsrRunner::printUsage(const std::string& programName)
{
std::cout << "Usage: " << programName << " [OPTIONS...]" << std::endl;
std::cout << " NDN routing...." << std::endl;
std::cout << " -d Run in daemon mode" << std::endl;
std::cout << " -f <FILE> Specify configuration file name" << std::endl;
std::cout << " -V Display version information" << std::endl;
std::cout << " -h Display this help message" << std::endl;
+7 -6
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -36,11 +36,11 @@ namespace nlsr {
*
* As its name suggests, this class is responsible for running
* NLSR. It creates an nlsr::ConfFileProcessor to read a configuration
* file and uses that to configure and then start an NLSR process. It
* also initializes loggers and optionally daemonizes the NLSR
* process. This class only exists to provide this functionality, and
* there is no special reliance of NLSR on this class.
* file and uses that to configure and then start an NLSR process.
* This class only exists to provide this functionality, and there is
* no special reliance of NLSR on this class.
*/
class NlsrRunner
{
public:
@@ -54,7 +54,8 @@ public:
}
};
NlsrRunner(std::string& configFileName, bool isDaemonProcess);
explicit
NlsrRunner(std::string& configFileName);
/*! \brief Instantiate, configure, and start the NLSR process.
*
+108 -74
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -28,13 +28,14 @@
#include <sstream>
#include <cstdio>
#include <unistd.h>
#include <vector>
#include <ndn-cxx/net/face-uri.hpp>
#include <ndn-cxx/signature.hpp>
namespace nlsr {
INIT_LOGGER("nlsr");
INIT_LOGGER(Nlsr);
const ndn::Name Nlsr::LOCALHOST_PREFIX = ndn::Name("/localhost/nlsr");
@@ -45,7 +46,6 @@ Nlsr::Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::F
, m_confParam()
, m_adjacencyList()
, m_namePrefixList()
, m_isDaemonProcess(false)
, m_configFileName("nlsr.conf")
, m_nlsrLsdb(*this, scheduler)
, m_adjBuildCount(0)
@@ -55,22 +55,21 @@ Nlsr::Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::F
, m_routingTable(scheduler)
, m_fib(m_nlsrFace, scheduler, m_adjacencyList, m_confParam, m_keyChain)
, m_namePrefixTable(*this, m_routingTable.afterRoutingChange)
, m_localhostDispatcher(m_nlsrFace, m_keyChain)
, m_routerNameDispatcher(m_nlsrFace, m_keyChain)
, m_lsdbDatasetHandler(m_nlsrLsdb,
m_localhostDispatcher,
m_routerNameDispatcher,
m_nlsrFace,
m_keyChain)
, m_dispatcher(m_nlsrFace, m_keyChain)
, m_datasetHandler(m_nlsrLsdb,
m_routingTable,
m_dispatcher,
m_nlsrFace,
m_keyChain)
, m_helloProtocol(*this, scheduler)
, m_validator(ndn::make_unique<ndn::security::v2::CertificateFetcherDirectFetch>(m_nlsrFace))
, m_controller(m_nlsrFace, m_keyChain)
, m_faceDatasetController(m_nlsrFace, m_keyChain)
, m_prefixUpdateProcessor(m_localhostDispatcher,
, m_prefixUpdateProcessor(m_dispatcher,
m_nlsrFace,
m_namePrefixList,
m_nlsrLsdb)
, m_nfdRibCommandProcessor(m_localhostDispatcher,
, m_nfdRibCommandProcessor(m_dispatcher,
m_namePrefixList,
m_nlsrLsdb)
, m_statsCollector(m_nlsrLsdb, m_helloProtocol)
@@ -98,36 +97,34 @@ void
Nlsr::setInfoInterestFilter()
{
ndn::Name name(m_confParam.getRouterPrefix());
name.append("NLSR");
name.append("nlsr");
name.append("INFO");
NLSR_LOG_DEBUG("Setting interest filter for Hello interest: " << name);
getNlsrFace().setInterestFilter(name,
std::bind(&HelloProtocol::processInterest,
&m_helloProtocol, _1, _2),
std::bind(&Nlsr::onRegistrationSuccess, this, _1),
std::bind(&Nlsr::registrationFailed, this, _1),
m_signingInfo,
ndn::nfd::ROUTE_FLAG_CAPTURE);
m_nlsrFace.setInterestFilter(name,
std::bind(&HelloProtocol::processInterest,
&m_helloProtocol, _1, _2),
std::bind(&Nlsr::onRegistrationSuccess, this, _1),
std::bind(&Nlsr::registrationFailed, this, _1),
m_signingInfo,
ndn::nfd::ROUTE_FLAG_CAPTURE);
}
void
Nlsr::setLsaInterestFilter()
{
ndn::Name name = m_confParam.getLsaPrefix();
name.append(m_confParam.getSiteName());
name.append(m_confParam.getRouterName());
NLSR_LOG_DEBUG("Setting interest filter for LsaPrefix: " << name);
getNlsrFace().setInterestFilter(name,
std::bind(&Lsdb::processInterest,
&m_nlsrLsdb, _1, _2),
std::bind(&Nlsr::onRegistrationSuccess, this, _1),
std::bind(&Nlsr::registrationFailed, this, _1),
m_signingInfo,
ndn::nfd::ROUTE_FLAG_CAPTURE);
m_nlsrFace.setInterestFilter(name,
std::bind(&Lsdb::processInterest,
&m_nlsrLsdb, _1, _2),
std::bind(&Nlsr::onRegistrationSuccess, this, _1),
std::bind(&Nlsr::registrationFailed, this, _1),
m_signingInfo,
ndn::nfd::ROUTE_FLAG_CAPTURE);
}
@@ -135,12 +132,8 @@ void
Nlsr::addDispatcherTopPrefix(const ndn::Name& topPrefix)
{
try {
if (topPrefix.equals(m_confParam.getRouterPrefix())) {
m_routerNameDispatcher.addTopPrefix(topPrefix, false, m_signingInfo);
}
else {
m_localhostDispatcher.addTopPrefix(topPrefix, false, m_signingInfo);
}
// false since we want to have control over the registration process
m_dispatcher.addTopPrefix(topPrefix, false, m_signingInfo);
}
catch (const std::exception& e) {
NLSR_LOG_ERROR("Error setting top-level prefix in dispatcher: " << e.what() << "\n");
@@ -156,32 +149,6 @@ Nlsr::setStrategies()
m_fib.setStrategy(m_confParam.getChronosyncPrefix(), strategy, 0);
}
void
Nlsr::daemonize()
{
pid_t process_id = 0;
pid_t sid = 0;
process_id = fork();
if (process_id < 0){
std::cerr << "Daemonization failed!" << std::endl;
BOOST_THROW_EXCEPTION(Error("Error: Daemonization process- fork failed!"));
}
if (process_id > 0) {
NLSR_LOG_DEBUG("Process daemonized. Process id: " << process_id);
exit(0);
}
umask(0);
sid = setsid();
if(sid < 0) {
BOOST_THROW_EXCEPTION(Error("Error: Daemonization process- setting id failed!"));
}
if (chdir("/") < 0) {
BOOST_THROW_EXCEPTION(Error("Error: Daemonization process-chdir failed!"));
}
}
void
Nlsr::canonizeContinuation(std::list<Adjacent>::iterator iterator,
std::function<void(void)> finally)
@@ -199,13 +166,13 @@ Nlsr::canonizeNeighborUris(std::list<Adjacent>::iterator currentNeighbor,
{
if (currentNeighbor != m_adjacencyList.getAdjList().end()) {
ndn::FaceUri uri(currentNeighbor->getFaceUri());
uri.canonize([this, then, currentNeighbor] (ndn::FaceUri canonicalUri) {
uri.canonize([then, currentNeighbor] (ndn::FaceUri canonicalUri) {
NLSR_LOG_DEBUG("Canonized URI: " << currentNeighbor->getFaceUri()
<< " to: " << canonicalUri);
currentNeighbor->setFaceUri(canonicalUri);
then(std::next(currentNeighbor));
},
[this, then, currentNeighbor] (const std::string& reason) {
[then, currentNeighbor] (const std::string& reason) {
NLSR_LOG_ERROR("Could not canonize URI: " << currentNeighbor->getFaceUri()
<< " because: " << reason);
then(std::next(currentNeighbor));
@@ -219,10 +186,10 @@ Nlsr::canonizeNeighborUris(std::list<Adjacent>::iterator currentNeighbor,
}
}
void
Nlsr::loadCertToPublish(const ndn::security::v2::Certificate& certificate)
{
NLSR_LOG_TRACE("Loading cert to publish.");
m_certStore.insert(certificate);
m_validator.loadAnchor("Authoritative-Certificate",
ndn::security::v2::Certificate(certificate));
@@ -231,12 +198,61 @@ Nlsr::loadCertToPublish(const ndn::security::v2::Certificate& certificate)
ndn::security::v2::Certificate(certificate));
}
void
Nlsr::connectToFetcher(ndn::util::SegmentFetcher& fetcher)
{
NLSR_LOG_TRACE("NLSR: Connect to SegmentFetcher.");
fetcher.afterSegmentValidated.connect(std::bind(&Nlsr::afterFetcherSignalEmitted,
this, _1));
}
void
Nlsr::afterFetcherSignalEmitted(const ndn::Data& lsaSegment)
{
NLSR_LOG_TRACE("SegmentFetcher fetched a data segment. Start inserting cert to own cert store.");
ndn::Name keyName = lsaSegment.getSignature().getKeyLocator().getName();
if (getCertificate(keyName) == nullptr) {
publishCertFromCache(keyName);
}
else {
NLSR_LOG_TRACE("Certificate is already in the store: " << keyName);
}
}
void
Nlsr::publishCertFromCache(const ndn::Name& keyName)
{
const ndn::security::v2::Certificate* cert = m_validator.getUnverifiedCertCache()
.find(keyName);
if (cert != nullptr) {
m_certStore.insert(*cert);
NLSR_LOG_TRACE(*cert);
NLSR_LOG_TRACE("Setting interest filter for: "
<< ndn::security::v2::extractKeyNameFromCertName(cert->getName()));
m_nlsrFace.setInterestFilter(ndn::security::v2::extractKeyNameFromCertName(cert->getName()),
std::bind(&Nlsr::onKeyInterest,
this, _1, _2),
std::bind(&Nlsr::onKeyPrefixRegSuccess, this, _1),
std::bind(&Nlsr::registrationFailed, this, _1),
m_signingInfo,
ndn::nfd::ROUTE_FLAG_CAPTURE);
if (!cert->getKeyName().equals(cert->getSignature().getKeyLocator().getName())) {
publishCertFromCache(cert->getSignature().getKeyLocator().getName());
}
}
else {
NLSR_LOG_TRACE("Cert for " << keyName << " was not found in the Validator's cache. ");
}
}
void
Nlsr::initialize()
{
NLSR_LOG_DEBUG("Initializing Nlsr");
m_confParam.buildRouterPrefix();
m_lsdbDatasetHandler.setRouterNameCommandPrefix(m_confParam.getRouterPrefix());
m_datasetHandler.setRouterNameCommandPrefix(m_confParam.getRouterPrefix());
m_nlsrLsdb.setLsaRefreshTime(ndn::time::seconds(m_confParam.getLsaRefreshTime()));
m_nlsrLsdb.setThisRouterPrefix(m_confParam.getRouterPrefix().toUri());
m_fib.setEntryRefreshTime(2 * m_confParam.getLsaRefreshTime());
@@ -244,7 +260,8 @@ Nlsr::initialize()
m_nlsrLsdb.getSequencingManager().setSeqFileDirectory(m_confParam.getSeqFileDir());
m_nlsrLsdb.getSequencingManager().initiateSeqNoFromFile(m_confParam.getHyperbolicState());
m_nlsrLsdb.getSyncLogicHandler().createSyncSocket(m_confParam.getChronosyncPrefix());
m_nlsrLsdb.getSyncLogicHandler().createSyncSocket(m_confParam.getChronosyncPrefix(),
m_confParam.getSyncInterestLifetime());
// Logging start
m_confParam.writeLog();
@@ -261,7 +278,7 @@ Nlsr::initialize()
setLsaInterestFilter();
// add top-level prefixes: router and localhost prefix
addDispatcherTopPrefix(m_confParam.getRouterPrefix());
addDispatcherTopPrefix(ndn::Name(m_confParam.getRouterPrefix()).append("nlsr"));
addDispatcherTopPrefix(LOCALHOST_PREFIX);
initializeFaces(std::bind(&Nlsr::processFaceDataset, this, _1),
@@ -283,6 +300,7 @@ Nlsr::initialize()
registerKeyPrefix();
registerLocalhostPrefix();
registerRouterPrefix();
m_helloProtocol.scheduleInterest(m_firstHelloInterval);
@@ -303,7 +321,7 @@ Nlsr::initializeKey()
NLSR_LOG_DEBUG("Initializing Key ...");
ndn::Name nlsrInstanceName = m_confParam.getRouterPrefix();
nlsrInstanceName.append("NLSR");
nlsrInstanceName.append("nlsr");
try {
m_keyChain.deleteIdentity(m_keyChain.getPib().getIdentity(nlsrInstanceName));
@@ -323,7 +341,7 @@ Nlsr::initializeKey()
// set metainfo
certificate.setContentType(ndn::tlv::ContentType_Key);
certificate.setFreshnessPeriod(ndn::time::days(7300));
certificate.setFreshnessPeriod(ndn::time::days(365));
// set content
certificate.setContent(nlsrInstanceKey.getPublicKey().data(), nlsrInstanceKey.getPublicKey().size());
@@ -332,7 +350,7 @@ Nlsr::initializeKey()
ndn::SignatureInfo signatureInfo;
signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(ndn::time::system_clock::TimePoint(),
ndn::time::system_clock::now()
+ ndn::time::days(20 * 365)));
+ ndn::time::days(365)));
try {
m_keyChain.sign(certificate,
ndn::security::SigningInfo(m_keyChain.getPib().getIdentity(m_confParam.getRouterPrefix()))
@@ -343,7 +361,7 @@ Nlsr::initializeKey()
<< "NLSR is running without security."
<< " If security is enabled NLSR will not converge.");
std::cerr << "Router's " << e.what() << "NLSR is running without security "
std::cerr << "Router's " << e.what() << ". NLSR is running without security "
<< "(Only for testing, should not be used in production.)"
<< " If security is enabled NLSR will not converge." << std::endl;
}
@@ -361,7 +379,7 @@ Nlsr::registerKeyPrefix()
{
// Start listening for the interest of this router's NLSR certificate
ndn::Name nlsrKeyPrefix = getConfParameter().getRouterPrefix();
nlsrKeyPrefix.append("NLSR");
nlsrKeyPrefix.append("nlsr");
nlsrKeyPrefix.append("KEY");
m_nlsrFace.setInterestFilter(nlsrKeyPrefix,
@@ -419,6 +437,14 @@ Nlsr::registerLocalhostPrefix()
std::bind(&Nlsr::registrationFailed, this, _1));
}
void
Nlsr::registerRouterPrefix()
{
m_nlsrFace.registerPrefix(ndn::Name(m_confParam.getRouterPrefix()).append("nlsr"),
std::bind(&Nlsr::onRegistrationSuccess, this, _1),
std::bind(&Nlsr::registrationFailed, this, _1));
}
void
Nlsr::onKeyInterest(const ndn::Name& name, const ndn::Interest& interest)
{
@@ -491,8 +517,16 @@ Nlsr::onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNo
}
case ndn::nfd::FACE_EVENT_CREATED: {
// Find the neighbor in our adjacency list
auto adjacent = m_adjacencyList.findAdjacent(
ndn::FaceUri(faceEventNotification.getRemoteUri()));
ndn::FaceUri faceUri;
try {
faceUri = ndn::FaceUri(faceEventNotification.getRemoteUri());
}
catch (const std::exception& e) {
NLSR_LOG_WARN(e.what());
return;
}
auto adjacent = m_adjacencyList.findAdjacent(faceUri);
// If we have a neighbor by that FaceUri and it has no FaceId, we
// have a match.
if (adjacent != m_adjacencyList.end()) {
+47 -32
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -29,7 +29,7 @@
#include "lsdb.hpp"
#include "name-prefix-list.hpp"
#include "test-access-control.hpp"
#include "publisher/lsdb-dataset-interest-handler.hpp"
#include "publisher/dataset-interest-handler.hpp"
#include "route/fib.hpp"
#include "route/name-prefix-table.hpp"
#include "route/routing-table.hpp"
@@ -117,36 +117,42 @@ public:
m_configFileName = fileName;
}
bool
getIsSetDaemonProcess()
{
return m_isDaemonProcess;
}
void
setIsDaemonProcess(bool value)
{
m_isDaemonProcess = value;
}
ConfParameter&
getConfParameter()
{
return m_confParam;
}
const ConfParameter&
getConfParameter() const
{
return m_confParam;
}
AdjacencyList&
getAdjacencyList()
{
return m_adjacencyList;
}
const AdjacencyList&
getAdjacencyList() const
{
return m_adjacencyList;
}
NamePrefixList&
getNamePrefixList()
{
return m_namePrefixList;
}
const NamePrefixList&
getNamePrefixList() const
{
return m_namePrefixList;
}
ndn::Face&
getNlsrFace()
{
@@ -231,10 +237,10 @@ public:
m_isRouteCalculationScheduled = ircs;
}
LsdbDatasetInterestHandler&
getLsdbDatasetHandler()
DatasetInterestHandler&
getDatasetHandler()
{
return m_lsdbDatasetHandler;
return m_datasetHandler;
}
void
@@ -292,6 +298,21 @@ public:
void
loadCertToPublish(const ndn::security::v2::Certificate& certificate);
void
connectToFetcher(ndn::util::SegmentFetcher& fetcher);
/*! \brief Callback when SegmentFetcher retrieves a segment.
*/
void
afterFetcherSignalEmitted(const ndn::Data& lsaSegment);
/*! \brief Retrieves the chain of certificates from Validator's cache and
* store them in Nlsr's own CertificateStore.
* \param keyName Name of the first key in the certificate chain.
*/
void
publishCertFromCache(const ndn::Name& keyName);
void
initializeKey();
@@ -356,23 +377,14 @@ public:
}
ndn::mgmt::Dispatcher&
getLocalhostDispatcher()
getDispatcher()
{
return m_localhostDispatcher;
}
ndn::mgmt::Dispatcher&
getRouterNameDispatcher()
{
return m_routerNameDispatcher;
return m_dispatcher;
}
void
setStrategies();
void
daemonize();
uint32_t
getFirstHelloInterval() const
{
@@ -424,6 +436,11 @@ private:
void
registerLocalhostPrefix();
/*! \brief Registers the <router-prefix>/nlsr so that NLSR can respond to status requests from remote routers.
*/
void
registerRouterPrefix();
/*! \brief Attempts to satisfy an Interest for a certificate, and send it back.
*/
void
@@ -485,7 +502,6 @@ private:
ConfParameter m_confParam;
AdjacencyList m_adjacencyList;
NamePrefixList m_namePrefixList;
bool m_isDaemonProcess;
std::string m_configFileName;
Lsdb m_nlsrLsdb;
int64_t m_adjBuildCount;
@@ -496,10 +512,9 @@ private:
Fib m_fib;
NamePrefixTable m_namePrefixTable;
ndn::mgmt::Dispatcher m_localhostDispatcher;
ndn::mgmt::Dispatcher m_routerNameDispatcher;
ndn::mgmt::Dispatcher m_dispatcher;
LsdbDatasetInterestHandler m_lsdbDatasetHandler;
DatasetInterestHandler m_datasetHandler;
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
HelloProtocol m_helloProtocol;
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -19,66 +19,56 @@
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
/*! \file lsdb-dataset-interest-handler.cpp
This file details a class that is used by NLSRC and other command-line
tools to examine the state of NLSR. This system is not designed to
be used by routers to publish data to each other.
*/
#include "lsdb-dataset-interest-handler.hpp"
#include "dataset-interest-handler.hpp"
#include "nlsr.hpp"
#include "tlv/lsdb-status.hpp"
#include "logger.hpp"
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/mgmt/nfd/control-response.hpp>
#include <ndn-cxx/util/regex.hpp>
namespace nlsr {
INIT_LOGGER("LsdbDatasetInterestHandler");
INIT_LOGGER(DatasetInterestHandler);
const ndn::PartialName ADJACENCIES_DATASET = ndn::PartialName("lsdb/adjacencies");
const ndn::PartialName COORDINATES_DATASET = ndn::PartialName("lsdb/coordinates");
const ndn::PartialName NAMES_DATASET = ndn::PartialName("lsdb/names");
const ndn::PartialName LISTS_DATASET = ndn::PartialName("lsdb/list");
const ndn::PartialName RT_DATASET = ndn::PartialName("routing-table");
LsdbDatasetInterestHandler::LsdbDatasetInterestHandler(Lsdb& lsdb,
ndn::mgmt::Dispatcher& localHostDispatcher,
ndn::mgmt::Dispatcher& routerNameDispatcher,
ndn::Face& face,
ndn::KeyChain& keyChain)
DatasetInterestHandler::DatasetInterestHandler(const Lsdb& lsdb,
const RoutingTable& rt,
ndn::mgmt::Dispatcher& dispatcher,
const ndn::Face& face,
const ndn::KeyChain& keyChain)
: m_lsdb(lsdb)
, m_localhostDispatcher(localHostDispatcher)
, m_routerNameDispatcher(routerNameDispatcher)
, m_dispatcher(dispatcher)
, m_routingTableEntries(rt.getRoutingTableEntry())
, m_dryRoutingTableEntries(rt.getDryRoutingTableEntry())
{
NLSR_LOG_DEBUG("Setting dispatcher for lsdb status dataset:");
setDispatcher(m_localhostDispatcher);
setDispatcher(m_routerNameDispatcher);
setDispatcher(m_dispatcher);
}
void
LsdbDatasetInterestHandler::setDispatcher(ndn::mgmt::Dispatcher& dispatcher)
DatasetInterestHandler::setDispatcher(ndn::mgmt::Dispatcher& dispatcher)
{
dispatcher.addStatusDataset(ADJACENCIES_DATASET,
ndn::mgmt::makeAcceptAllAuthorization(),
std::bind(&LsdbDatasetInterestHandler::publishAdjStatus, this, _1, _2, _3));
std::bind(&DatasetInterestHandler::publishAdjStatus, this, _1, _2, _3));
dispatcher.addStatusDataset(COORDINATES_DATASET,
ndn::mgmt::makeAcceptAllAuthorization(),
std::bind(&LsdbDatasetInterestHandler::publishCoordinateStatus, this, _1, _2, _3));
std::bind(&DatasetInterestHandler::publishCoordinateStatus, this, _1, _2, _3));
dispatcher.addStatusDataset(NAMES_DATASET,
ndn::mgmt::makeAcceptAllAuthorization(),
std::bind(&LsdbDatasetInterestHandler::publishNameStatus, this, _1, _2, _3));
dispatcher.addStatusDataset(LISTS_DATASET,
std::bind(&DatasetInterestHandler::publishNameStatus, this, _1, _2, _3));
dispatcher.addStatusDataset(RT_DATASET,
ndn::mgmt::makeAcceptAllAuthorization(),
std::bind(&LsdbDatasetInterestHandler::publishAllStatus, this, _1, _2, _3));
std::bind(&DatasetInterestHandler::publishRtStatus, this, _1, _2, _3));
}
void
LsdbDatasetInterestHandler::publishAdjStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
ndn::mgmt::StatusDatasetContext& context)
DatasetInterestHandler::publishAdjStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
ndn::mgmt::StatusDatasetContext& context)
{
NLSR_LOG_DEBUG("Received interest: " << interest);
@@ -104,8 +94,8 @@ LsdbDatasetInterestHandler::publishAdjStatus(const ndn::Name& topPrefix, const n
}
void
LsdbDatasetInterestHandler::publishCoordinateStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
ndn::mgmt::StatusDatasetContext& context)
DatasetInterestHandler::publishCoordinateStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
ndn::mgmt::StatusDatasetContext& context)
{
auto lsaRange = std::make_pair<std::list<CoordinateLsa>::const_iterator,
std::list<CoordinateLsa>::const_iterator>(
@@ -127,8 +117,8 @@ LsdbDatasetInterestHandler::publishCoordinateStatus(const ndn::Name& topPrefix,
}
void
LsdbDatasetInterestHandler::publishNameStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
ndn::mgmt::StatusDatasetContext& context)
DatasetInterestHandler::publishNameStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
ndn::mgmt::StatusDatasetContext& context)
{
auto lsaRange = std::make_pair<std::list<NameLsa>::const_iterator, std::list<NameLsa>::const_iterator>(
m_lsdb.getNameLsdb().cbegin(), m_lsdb.getNameLsdb().cend());
@@ -149,24 +139,50 @@ LsdbDatasetInterestHandler::publishNameStatus(const ndn::Name& topPrefix, const
context.end();
}
std::vector<tlv::RoutingTable>
DatasetInterestHandler::getTlvRTEntries()
{
std::vector<tlv::RoutingTable> rtable;
for (const auto& rte : m_routingTableEntries) {
tlv::RoutingTable tlvRoutingTable;
std::shared_ptr<tlv::Destination> tlvDes = tlv::makeDes(rte);
tlvRoutingTable.setDestination(*tlvDes);
for (const auto& nh : rte.getNexthopList().getNextHops()) {
tlv::NextHop tlvNexthop;
tlvNexthop.setUri(nh.getConnectingFaceUri());
tlvNexthop.setCost(nh.getRouteCost());
tlvRoutingTable.addNexthops(tlvNexthop);
}
rtable.push_back(tlvRoutingTable);
}
if (!m_dryRoutingTableEntries.empty()) {
for (const auto& dryRte : m_dryRoutingTableEntries) {
tlv::RoutingTable tlvRoutingTable;
std::shared_ptr<tlv::Destination> tlvDes = tlv::makeDes(dryRte);
tlvRoutingTable.setDestination(*tlvDes);
for (const auto& nh : dryRte.getNexthopList().getNextHops()) {
tlv::NextHop tlvNexthop;
tlvNexthop.setUri(nh.getConnectingFaceUri());
tlvNexthop.setCost(nh.getRouteCost());
tlvRoutingTable.addNexthops(tlvNexthop);
}
rtable.push_back(tlvRoutingTable);
}
}
return rtable;
}
void
LsdbDatasetInterestHandler::publishAllStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
ndn::mgmt::StatusDatasetContext& context)
DatasetInterestHandler::publishRtStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
ndn::mgmt::StatusDatasetContext& context)
{
NLSR_LOG_DEBUG("Received interest: " << interest);
tlv::LsdbStatus lsdbStatus;
for (const tlv::AdjacencyLsa& tlvLsa : getTlvLsas<tlv::AdjacencyLsa>(m_lsdb)) {
lsdbStatus.addAdjacencyLsa(tlvLsa);
tlv::RoutingTableStatus rtStatus;
for (const tlv::RoutingTable& rt : getTlvRTEntries()) {
rtStatus.addRoutingTable(rt);
}
for (const tlv::CoordinateLsa& tlvLsa : getTlvLsas<tlv::CoordinateLsa>(m_lsdb)) {
lsdbStatus.addCoordinateLsa(tlvLsa);
}
for (const tlv::NameLsa& tlvLsa : getTlvLsas<tlv::NameLsa>(m_lsdb)) {
lsdbStatus.addNameLsa(tlvLsa);
}
const ndn::Block& wire = lsdbStatus.wireEncode();
const ndn::Block& wire = rtStatus.wireEncode();
context.append(wire);
context.end();
}
@@ -192,7 +208,6 @@ getTlvLsas<tlv::AdjacencyLsa>(const Lsdb& lsdb)
tlvAdj.setCost(adj.getLinkCost());
tlvLsa.addAdjacency(tlvAdj);
}
lsas.push_back(tlvLsa);
}
@@ -250,5 +265,4 @@ getTlvLsas<tlv::NameLsa>(const Lsdb& lsdb)
}
} // 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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -19,31 +19,47 @@
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef NLSR_PUBLISHER_LSDB_DATASET_INTEREST_HANDLER_HPP
#define NLSR_PUBLISHER_LSDB_DATASET_INTEREST_HANDLER_HPP
/*! \file dataset-interest-handler.hpp
This file details a class that is used by NLSRC and other command-line
tools to examine the state of NLSR. This class doesn't only handle interest
from local host, but also handle interests from remote router.
This system is not designed to
be used by routers to publish data to each other.
*/
#ifndef NLSR_PUBLISHER_DATASET_INTEREST_HANDLER_HPP
#define NLSR_PUBLISHER_DATASET_INTEREST_HANDLER_HPP
#include "route/routing-table-entry.hpp"
#include "route/routing-table.hpp"
#include "route/nexthop-list.hpp"
#include "lsdb.hpp"
#include "logger.hpp"
#include "tlv/adjacency-lsa.hpp"
#include "tlv/coordinate-lsa.hpp"
#include "tlv/name-lsa.hpp"
#include "lsdb.hpp"
#include "tlv/routing-table-status.hpp"
#include "tlv/routing-table-entry.hpp"
#include <ndn-cxx/mgmt/dispatcher.hpp>
#include <ndn-cxx/face.hpp>
#include <boost/noncopyable.hpp>
namespace nlsr {
namespace dataset {
const ndn::Name::Component ADJACENCY_COMPONENT = ndn::Name::Component{"adjacencies"};
const ndn::Name::Component NAME_COMPONENT = ndn::Name::Component{"names"};
const ndn::Name::Component COORDINATE_COMPONENT = ndn::Name::Component{"coordinates"};
const ndn::Name::Component ADJACENCY_COMPONENT = ndn::Name::Component{"adjacencies"};
const ndn::Name::Component NAME_COMPONENT = ndn::Name::Component{"names"};
const ndn::Name::Component COORDINATE_COMPONENT = ndn::Name::Component{"coordinates"};
} // namespace dataset
/*!
\brief Class to publish all lsa dataset
\brief Class to publish all dataset
\sa https://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
\sa https://redmine.named-data.net/projects/nlsr/wiki/Routing_Table_DataSet
*/
class LsdbDatasetInterestHandler : boost::noncopyable
class DatasetInterestHandler : boost::noncopyable
{
public:
class Error : std::runtime_error
@@ -56,11 +72,11 @@ public:
}
};
LsdbDatasetInterestHandler(Lsdb& lsdb,
ndn::mgmt::Dispatcher& localHostDispatcher,
ndn::mgmt::Dispatcher& routerNameDispatcher,
ndn::Face& face,
ndn::KeyChain& keyChain);
DatasetInterestHandler(const Lsdb& lsdb,
const RoutingTable& rt,
ndn::mgmt::Dispatcher& dispatcher,
const ndn::Face& face,
const ndn::KeyChain& keyChain);
ndn::Name&
getRouterNameCommandPrefix()
@@ -75,12 +91,22 @@ public:
}
private:
/*! \brief Capture-point for Interests to verify Interests are
* valid, and then process them.
/*! \brief set dispatcher for localhost or remote router
*/
void
setDispatcher(ndn::mgmt::Dispatcher& dispatcher);
/*! \brief generate a TLV-format of routing table entry
*/
std::vector<tlv::RoutingTable>
getTlvRTEntries();
/*! \brief provide routing-table dataset
*/
void
publishRtStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
ndn::mgmt::StatusDatasetContext& context);
/*! \brief provide adjacent status dataset
*/
void
@@ -99,18 +125,14 @@ private:
publishNameStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
ndn::mgmt::StatusDatasetContext& context);
/*! \brief provide ladb status dataset
*/
void
publishAllStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
ndn::mgmt::StatusDatasetContext& context);
private:
const Lsdb& m_lsdb;
ndn::Name m_routerNamePrefix;
ndn::mgmt::Dispatcher& m_localhostDispatcher;
ndn::mgmt::Dispatcher& m_routerNameDispatcher;
ndn::mgmt::Dispatcher& m_dispatcher;
const std::list<RoutingTableEntry>& m_routingTableEntries;
const std::list<RoutingTableEntry>& m_dryRoutingTableEntries;
};
template<typename T> std::list<T>
@@ -127,4 +149,4 @@ getTlvLsas<tlv::NameLsa>(const Lsdb& lsdb);
} // namespace nlsr
#endif // NLSR_PUBLISHER_LSDB_DATASET_INTEREST_HANDLER_HPP
#endif // NLSR_PUBLISHER_DATASET_INTEREST_HANDLER_HPP
+2 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2017, Regents of the University of California,
* Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -105,7 +105,7 @@ public:
segmentBegin = segmentEnd;
if (segmentBegin >= end) {
data->setFinalBlockId(segmentName[-1]);
data->setFinalBlock(segmentName[-1]);
}
publishSegment(data);
+2 -2
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -29,7 +29,7 @@
namespace nlsr {
INIT_LOGGER("FaceMap");
INIT_LOGGER(route.FaceMap);
void
FaceMap::writeLog()
+2 -2
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -23,7 +23,7 @@
namespace nlsr {
INIT_LOGGER("FibEntry");
INIT_LOGGER(route.FibEntry);
void
FibEntry::writeLog()
+2 -2
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -31,7 +31,7 @@
namespace nlsr {
INIT_LOGGER("Fib");
INIT_LOGGER(route.Fib);
const uint64_t Fib::GRACE_PERIOD = 10;
+6 -4
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,8 +17,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*
**/
*/
#ifndef NLSR_ROUTE_FIB_HPP
#define NLSR_ROUTE_FIB_HPP
@@ -64,6 +63,9 @@ public:
{
}
VIRTUAL_WITH_TESTS
~Fib() = default;
/*! \brief Completely remove a name prefix from the FIB.
*
* If a name prefix is found to no longer be reachable from this
+3 -6
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -25,12 +25,9 @@
#include "lsdb.hpp"
#include "logger.hpp"
#include <iostream>
#include <list>
namespace nlsr {
INIT_LOGGER("Map");
INIT_LOGGER(route.Map);
void
Map::addEntry(const ndn::Name& rtrName)
@@ -48,7 +45,7 @@ Map::addEntry(MapEntry& mpe)
}
ndn::optional<ndn::Name>
Map::getRouterNameByMappingNo(int32_t mn)
Map::getRouterNameByMappingNo(int32_t mn) const
{
auto&& mappingNumberView = m_entries.get<detail::byMappingNumber>();
auto iterator = mappingNumberView.find(mn);
+2 -2
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -105,7 +105,7 @@ public:
}
ndn::optional<ndn::Name>
getRouterNameByMappingNo(int32_t mn);
getRouterNameByMappingNo(int32_t mn) const;
ndn::optional<int32_t>
getMappingNoByRouterName(const ndn::Name& rName);
+2 -2
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -27,7 +27,7 @@
namespace nlsr {
INIT_LOGGER("NamePrefixTableEntry");
INIT_LOGGER(route.NamePrefixTableEntry);
void
NamePrefixTableEntry::generateNhlfromRteList()
+2 -8
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -31,7 +31,7 @@
namespace nlsr {
INIT_LOGGER("NamePrefixTable");
INIT_LOGGER(route.NamePrefixTable);
NamePrefixTable::NamePrefixTable(Nlsr& nlsr,
std::unique_ptr<AfterRoutingChange>& afterRoutingChangeSignal)
@@ -48,12 +48,6 @@ NamePrefixTable::~NamePrefixTable()
m_afterRoutingChangeConnection.disconnect();
}
bool
npteCompare(std::shared_ptr<NamePrefixTableEntry>& npte, const ndn::Name& name)
{
return npte->getNamePrefix() == name;
}
void
NamePrefixTable::addEntry(const ndn::Name& name, const ndn::Name& destRouter)
{
+1 -4
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -140,9 +140,6 @@ NamePrefixTable::end() const
return m_table.end();
}
bool
npteCompare(NamePrefixTableEntry& npte, const ndn::Name& name);
std::ostream&
operator<<(std::ostream& os, const NamePrefixTable& table);
+2 -2
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -26,7 +26,7 @@
namespace nlsr {
INIT_LOGGER("NexthopList");
INIT_LOGGER(route.NexthopList);
static bool
nexthopAddCompare(const NextHop& nh1, const NextHop& nh2)
+3 -3
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -87,8 +87,8 @@ public:
m_nexthopList.clear();
}
std::set<NextHop, NextHopComparator>&
getNextHops()
const std::set<NextHop, NextHopComparator>&
getNextHops() const
{
return m_nexthopList;
}
+28 -7
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -29,11 +29,12 @@
#include <iostream>
#include <boost/math/constants/constants.hpp>
#include <ndn-cxx/util/logger.hpp>
#include <cmath>
namespace nlsr {
INIT_LOGGER("RoutingTableCalculator");
INIT_LOGGER(route.RoutingTableCalculator);
void
RoutingTableCalculator::allocateAdjMatrix()
@@ -56,7 +57,7 @@ RoutingTableCalculator::initMatrix()
}
void
RoutingTableCalculator::makeAdjMatrix(Nlsr& pnlsr, Map pMap)
RoutingTableCalculator::makeAdjMatrix(Nlsr& pnlsr, Map& pMap)
{
std::list<AdjLsa> adjLsdb = pnlsr.getLsdb().getAdjLsdb();
// For each LSA represented in the map
@@ -116,14 +117,34 @@ RoutingTableCalculator::makeAdjMatrix(Nlsr& pnlsr, Map pMap)
}
void
RoutingTableCalculator::writeAdjMatrixLog()
RoutingTableCalculator::writeAdjMatrixLog(const Map& map) const
{
if (!ndn_cxx_getLogger().isLevelEnabled(ndn::util::LogLevel::DEBUG)) {
return;
}
NLSR_LOG_DEBUG("-----------Legend (routerName -> index)------");
std::string routerIndex;
std::string indexToNameMapping;
std::string lengthOfDash = "--";
for (size_t i = 0; i < m_nRouters; i++) {
std::string line="";
routerIndex += boost::lexical_cast<std::string>(i);
routerIndex += " ";
lengthOfDash += "--";
NLSR_LOG_DEBUG("Router:" + map.getRouterNameByMappingNo(i)->toUri() +
" Index:" + boost::lexical_cast<std::string>(i));
}
NLSR_LOG_DEBUG(" |" + routerIndex);
NLSR_LOG_DEBUG(lengthOfDash);
for (size_t i = 0; i < m_nRouters; i++) {
std::string line;
for (size_t j = 0; j < m_nRouters; j++) {
line += boost::lexical_cast<std::string>(adjMatrix[i][j]);
line += " ";
}
line = boost::lexical_cast<std::string>(i) + "|" + line;
NLSR_LOG_DEBUG(line);
}
}
@@ -210,7 +231,7 @@ LinkStateRoutingTableCalculator::calculatePath(Map& pMap,
allocateAdjMatrix();
initMatrix();
makeAdjMatrix(pnlsr, pMap);
writeAdjMatrixLog();
writeAdjMatrixLog(pMap);
ndn::optional<int32_t> sourceRouter =
pMap.getMappingNoByRouterName(pnlsr.getConfParameter().getRouterPrefix());
allocateParent(); // These two matrices are used in Dijkstra's algorithm.
@@ -232,7 +253,7 @@ LinkStateRoutingTableCalculator::calculatePath(Map& pMap,
for (int i = 0 ; i < vNoLink; i++) {
// Simulate that only the current neighbor is accessible
adjustAdMatrix(*sourceRouter, links[i], linkCosts[i]);
writeAdjMatrixLog();
writeAdjMatrixLog(pMap);
// Do Dijkstra's algorithm using the current neighbor as your start.
doDijkstraPathCalculation(*sourceRouter);
// Update the routing table with the calculations.
+3 -3
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -61,10 +61,10 @@ protected:
\param pMap The map to populate with the adj. data.
*/
void
makeAdjMatrix(Nlsr& pnlsr, Map pMap);
makeAdjMatrix(Nlsr& pnlsr, Map& pMap);
void
writeAdjMatrixLog();
writeAdjMatrixLog(const Map& map) const;
/*! \brief Returns how many links a router in the matrix has.
\param sRouter The router to count the links of.
+2 -2
View File
@@ -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-2018, 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 @@
namespace nlsr {
INIT_LOGGER("RoutingTable");
INIT_LOGGER(route.RoutingTable);
RoutingTable::RoutingTable(ndn::Scheduler& scheduler)
: afterRoutingChange{ndn::make_unique<AfterRoutingChange>()}
+30 -11
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -37,29 +37,30 @@ namespace nlsr {
class Nlsr;
class NextHop;
class RoutingTable
class RoutingTable : boost::noncopyable
{
public:
explicit
RoutingTable(ndn::Scheduler& scheduler);
/*! \brief Calculates a list of next hops for each router in the network.
* \param pnlsr The NLSR object that contains the LSAs needed for adj. info.
* \param nlsr The NLSR object that contains the LSAs needed for adj. info.
*
* Calculates the list of next hops to every other router in the network.
* Calculates the list of next hops to every other router in the network.
*/
void
calculate(Nlsr& pnlsr);
calculate(Nlsr& nlsr);
/*! \brief Adds a next hop to a routing table entry.
* \param destRouter The destination router whose RTE we want to modify.
* \param nh The next hop to add to the RTE.
* \param destRouter The destination router whose RTE we want to modify.
* \param nh The next hop to add to the RTE.
*/
void
addNextHop(const ndn::Name& destRouter, NextHop& nh);
/*! \brief Adds a next hop to a routing table entry in a dry run scenario.
* \param destRouter The destination router whose RTE we want to modify.
* \param nh The next hop to add to the router.
* \param destRouter The destination router whose RTE we want to modify.
* \param nh The next hop to add to the router.
*/
void
addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh);
@@ -68,8 +69,8 @@ public:
findRoutingTableEntry(const ndn::Name& destRouter);
/*! \brief Schedules a calculation event in the event scheduler only
* if one isn't already scheduled.
* \param pnlsr The NLSR whose scheduling status is needed.
* if one isn't already scheduled.
* \param pnlsr The NLSR whose scheduling status is needed.
*/
void
scheduleRoutingTableCalculation(Nlsr& pnlsr);
@@ -92,6 +93,24 @@ public:
return m_routingCalcInterval;
}
const std::list<RoutingTableEntry>&
getRoutingTableEntry() const
{
return m_rTable;
}
const std::list<RoutingTableEntry>&
getDryRoutingTableEntry() const
{
return m_dryTable;
}
uint64_t
getRtSize()
{
return m_rTable.size();
}
private:
/*! \brief Calculates a link-state routing table. */
void
+2 -2
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -32,7 +32,7 @@
namespace nlsr {
INIT_LOGGER("SequencingManager");
INIT_LOGGER(SequencingManager);
void
SequencingManager::writeSeqNoToFile() const
+10 -18
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
*/
#include "adjacency-lsa.hpp"
#include "tlv-nlsr.hpp"
@@ -26,7 +26,7 @@
#include <ndn-cxx/encoding/block-helpers.hpp>
namespace nlsr {
namespace tlv {
namespace tlv {
BOOST_CONCEPT_ASSERT((ndn::WireEncodable<AdjacencyLsa>));
BOOST_CONCEPT_ASSERT((ndn::WireDecodable<AdjacencyLsa>));
@@ -62,11 +62,7 @@ AdjacencyLsa::wireEncode(ndn::EncodingImpl<TAG>& block) const
return totalLength;
}
template size_t
AdjacencyLsa::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& encoder) const;
template size_t
AdjacencyLsa::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& encoder) const;
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(AdjacencyLsa);
const ndn::Block&
AdjacencyLsa::wireEncode() const
@@ -95,10 +91,8 @@ AdjacencyLsa::wireDecode(const ndn::Block& wire)
m_wire = wire;
if (m_wire.type() != ndn::tlv::nlsr::AdjacencyLsa) {
std::stringstream error;
error << "Expected AdjacencyLsa Block, but Block is of a different type: #"
<< m_wire.type();
throw Error(error.str());
BOOST_THROW_EXCEPTION(Error("Expected AdjacencyLsa Block, but Block is of a different type: #" +
ndn::to_string(m_wire.type())));
}
m_wire.parse();
@@ -110,7 +104,7 @@ AdjacencyLsa::wireDecode(const ndn::Block& wire)
++val;
}
else {
throw Error("Missing required LsaInfo field");
BOOST_THROW_EXCEPTION(Error("Missing required LsaInfo field"));
}
for (; val != m_wire.elements_end(); ++val) {
@@ -119,10 +113,8 @@ AdjacencyLsa::wireDecode(const ndn::Block& wire)
m_hasAdjacencies = true;
}
else {
std::stringstream error;
error << "Expected Adjacency Block, but Block is of a different type: #"
<< m_wire.type();
throw Error(error.str());
BOOST_THROW_EXCEPTION(Error("Expected Adjacency Block, but Block is of a different type: #" +
ndn::to_string(m_wire.type())));
}
}
}
+5 -3
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
*/
#ifndef NLSR_TLV_ADJACENCY_LSA_HPP
#define NLSR_TLV_ADJACENCY_LSA_HPP
@@ -153,6 +153,8 @@ private:
mutable ndn::Block m_wire;
};
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(AdjacencyLsa);
inline AdjacencyLsa::iterator
AdjacencyLsa::begin() const
{
+10 -16
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
*/
#include "adjacency.hpp"
#include "tlv-nlsr.hpp"
@@ -26,7 +26,7 @@
#include <ndn-cxx/encoding/block-helpers.hpp>
namespace nlsr {
namespace tlv {
namespace tlv {
BOOST_CONCEPT_ASSERT((ndn::WireEncodable<Adjacency>));
BOOST_CONCEPT_ASSERT((ndn::WireDecodable<Adjacency>));
@@ -62,11 +62,7 @@ Adjacency::wireEncode(ndn::EncodingImpl<TAG>& encoder) const
return totalLength;
}
template size_t
Adjacency::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& block) const;
template size_t
Adjacency::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& block) const;
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Adjacency);
const ndn::Block&
Adjacency::wireEncode() const
@@ -96,10 +92,8 @@ Adjacency::wireDecode(const ndn::Block& wire)
m_wire = wire;
if (m_wire.type() != ndn::tlv::nlsr::Adjacency) {
std::stringstream error;
error << "Expected Adjacency Block, but Block is of a different type: #"
<< m_wire.type();
throw Error(error.str());
BOOST_THROW_EXCEPTION(Error("Expected Adjacency Block, but Block is of a different type: #" +
ndn::to_string(m_wire.type())));
}
m_wire.parse();
@@ -111,7 +105,7 @@ Adjacency::wireDecode(const ndn::Block& wire)
++val;
}
else {
throw Error("Missing required Name field");
BOOST_THROW_EXCEPTION(Error("Missing required Name field"));
}
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::Uri) {
@@ -119,7 +113,7 @@ Adjacency::wireDecode(const ndn::Block& wire)
++val;
}
else {
throw Error("Missing required Uri field");
BOOST_THROW_EXCEPTION(Error("Missing required Uri field"));
}
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::Cost) {
@@ -127,7 +121,7 @@ Adjacency::wireDecode(const ndn::Block& wire)
++val;
}
else {
throw Error("Missing required Cost field");
BOOST_THROW_EXCEPTION(Error("Missing required Cost field"));
}
}
+5 -3
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
*/
#ifndef NLSR_TLV_ADJACENCY_HPP
#define NLSR_TLV_ADJACENCY_HPP
@@ -137,6 +137,8 @@ private:
mutable ndn::Block m_wire;
};
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Adjacency);
std::ostream&
operator<<(std::ostream& os, const Adjacency& adjacency);
+9 -44
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,11 +17,10 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
*/
#include "coordinate-lsa.hpp"
#include "tlv-nlsr.hpp"
#include "logger.hpp"
#include <ndn-cxx/util/concepts.hpp>
#include <ndn-cxx/encoding/block-helpers.hpp>
@@ -31,8 +30,6 @@
namespace nlsr {
namespace tlv {
INIT_LOGGER("CoordinateLsa");
BOOST_CONCEPT_ASSERT((ndn::WireEncodable<CoordinateLsa>));
BOOST_CONCEPT_ASSERT((ndn::WireDecodable<CoordinateLsa>));
static_assert(std::is_base_of<ndn::tlv::Error, CoordinateLsa::Error>::value,
@@ -53,21 +50,12 @@ size_t
CoordinateLsa::wireEncode(ndn::EncodingImpl<TAG>& block) const
{
size_t totalLength = 0;
size_t doubleLength = 10;
const uint8_t* doubleBytes1;
for (auto it = m_hyperbolicAngle.rbegin(); it != m_hyperbolicAngle.rend(); ++it) {
doubleBytes1 = reinterpret_cast<const uint8_t*>(&*it);
totalLength += block.prependByteArrayBlock(ndn::tlv::nlsr::Double, doubleBytes1, 8);
totalLength += block.prependVarNumber(doubleLength);
totalLength += block.prependVarNumber(ndn::tlv::nlsr::HyperbolicAngle);
totalLength += prependDouble(block, ndn::tlv::nlsr::HyperbolicAngle, *it);
}
const uint8_t* doubleBytes2 = reinterpret_cast<const uint8_t*>(&m_hyperbolicRadius);
totalLength += block.prependByteArrayBlock(ndn::tlv::nlsr::Double, doubleBytes2, 8);
totalLength += block.prependVarNumber(doubleLength);
totalLength += block.prependVarNumber(ndn::tlv::nlsr::HyperbolicRadius);
totalLength += prependDouble(block, ndn::tlv::nlsr::HyperbolicRadius, m_hyperbolicRadius);
totalLength += m_lsaInfo.wireEncode(block);
@@ -77,11 +65,7 @@ CoordinateLsa::wireEncode(ndn::EncodingImpl<TAG>& block) const
return totalLength;
}
template size_t
CoordinateLsa::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& block) const;
template size_t
CoordinateLsa::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& block) const;
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(CoordinateLsa);
const ndn::Block&
CoordinateLsa::wireEncode() const
@@ -130,17 +114,8 @@ CoordinateLsa::wireDecode(const ndn::Block& wire)
}
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::HyperbolicRadius) {
val->parse();
ndn::Block::element_const_iterator it = val->elements_begin();
if (it != val->elements_end() && it->type() == ndn::tlv::nlsr::Double) {
m_hyperbolicRadius = *reinterpret_cast<const double*>(it->value());
++val;
}
else {
std::cout << "HyperbolicRadius: Missing required Double field" << std::endl;
BOOST_THROW_EXCEPTION(Error("HyperbolicRadius: Missing required Double field"));
}
m_hyperbolicRadius = ndn::tlv::nlsr::readDouble(*val);
++val;
}
else {
std::cout << "Missing required HyperbolicRadius field" << std::endl;
@@ -149,17 +124,7 @@ CoordinateLsa::wireDecode(const ndn::Block& wire)
for (; val != m_wire.elements_end(); ++val) {
if (val->type() == ndn::tlv::nlsr::HyperbolicAngle) {
val->parse();
for (auto it = val->elements_begin(); it != val->elements_end(); ++it) {
if (it->type() == ndn::tlv::nlsr::Double) {
m_hyperbolicAngle.push_back(*reinterpret_cast<const double*>(it->value()));
}
else {
std::cout << "HyperbolicAngle: Missing required Double field" << std::endl;
BOOST_THROW_EXCEPTION(Error("HyperbolicAngle: Missing required Double field"));
}
}
m_hyperbolicAngle.push_back(ndn::tlv::nlsr::readDouble(*val));
}
}
}
+5 -3
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
*/
#ifndef NLSR_TLV_COORDINATE_LSA_HPP
#define NLSR_TLV_COORDINATE_LSA_HPP
@@ -141,6 +141,8 @@ private:
mutable ndn::Block m_wire;
};
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(CoordinateLsa);
std::ostream&
operator<<(std::ostream& os, const CoordinateLsa& coordinateLsa);
+122
View File
@@ -0,0 +1,122 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2018, 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 "destination.hpp"
#include "tlv-nlsr.hpp"
#include <ndn-cxx/util/concepts.hpp>
#include <ndn-cxx/encoding/block-helpers.hpp>
namespace nlsr {
namespace tlv {
BOOST_CONCEPT_ASSERT((ndn::WireEncodable<Destination>));
BOOST_CONCEPT_ASSERT((ndn::WireDecodable<Destination>));
static_assert(std::is_base_of<ndn::tlv::Error, Destination::Error>::value,
"Destination::Error must inherit from tlv::Error");
Destination::Destination() = default;
Destination::Destination(const ndn::Block& block)
{
wireDecode(block);
}
template<ndn::encoding::Tag TAG>
size_t
Destination::wireEncode(ndn::EncodingImpl<TAG>& encoder) const
{
size_t totalLength = 0;
totalLength += m_name.wireEncode(encoder);
totalLength += encoder.prependVarNumber(totalLength);
totalLength += encoder.prependVarNumber(ndn::tlv::nlsr::Destination);
return totalLength;
}
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Destination);
const ndn::Block&
Destination::wireEncode() const
{
if (m_wire.hasWire()) {
return m_wire;
}
ndn::EncodingEstimator estimator;
size_t estimatedSize = wireEncode(estimator);
ndn::EncodingBuffer buffer(estimatedSize, 0);
wireEncode(buffer);
m_wire = buffer.block();
return m_wire;
}
void
Destination::wireDecode(const ndn::Block& wire)
{
m_name.clear();
m_wire = wire;
if (m_wire.type() != ndn::tlv::nlsr::Destination) {
std::stringstream error;
error << "Expected Destination Block, but Block is of a different type: #"
<< m_wire.type();
BOOST_THROW_EXCEPTION(Error(error.str()));
}
m_wire.parse();
ndn::Block::element_const_iterator val = m_wire.elements_begin();
if (val != m_wire.elements_end() && val->type() == ndn::tlv::Name) {
m_name.wireDecode(*val);
++val;
}
else {
BOOST_THROW_EXCEPTION(Error("Missing required Name field"));
}
}
std::ostream&
operator<<(std::ostream& os, const Destination& Destination)
{
os << "Destination: " << Destination.getName();
return os;
}
std::shared_ptr<Destination>
makeDes(const RoutingTableEntry& rte)
{
std::shared_ptr<Destination> desInfo = std::make_shared<Destination>();
desInfo->setName(rte.getDestination());
return desInfo;
}
} // namespace tlv
} // namespace nlsr
+105
View File
@@ -0,0 +1,105 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2018, 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/>.
**/
#ifndef NLSR_TLV_DESTINATION_HPP
#define NLSR_TLV_DESTINATION_HPP
#include "route/routing-table-entry.hpp"
#include <ndn-cxx/util/time.hpp>
#include <ndn-cxx/encoding/block.hpp>
#include <ndn-cxx/encoding/encoding-buffer.hpp>
#include <ndn-cxx/encoding/tlv.hpp>
#include <ndn-cxx/name.hpp>
#include <boost/throw_exception.hpp>
#include <list>
namespace nlsr {
namespace tlv {
/*! \brief Data abstraction for Destination
*
* Destination := DESTINATION-TYPE TLV-LENGTH
* Name
*
* \sa https://redmine.named-data.net/projects/nlsr/wiki/Routing_Table_DataSet
*/
class Destination
{
public:
class Error : public ndn::tlv::Error
{
public:
explicit
Error(const std::string& what)
: ndn::tlv::Error(what)
{
}
};
Destination();
explicit
Destination(const ndn::Block& block);
const ndn::Name&
getName() const
{
return m_name;
}
Destination&
setName(const ndn::Name& name)
{
m_name = name;
m_wire.reset();
return *this;
}
template<ndn::encoding::Tag TAG>
size_t
wireEncode(ndn::EncodingImpl<TAG>& block) const;
const ndn::Block&
wireEncode() const;
void
wireDecode(const ndn::Block& wire);
private:
ndn::Name m_name;
mutable ndn::Block m_wire;
};
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Destination);
std::ostream&
operator<<(std::ostream& os, const Destination& destination);
std::shared_ptr<Destination>
makeDes(const RoutingTableEntry& rte);
} // namespace tlv
} // namespace nlsr
#endif // NLSR_TLV_DESTINATION_HPP
+4 -8
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
*/
#include "lsa-info.hpp"
#include "tlv-nlsr.hpp"
@@ -72,11 +72,7 @@ LsaInfo::wireEncode(ndn::EncodingImpl<TAG>& encoder) const
return totalLength;
}
template size_t
LsaInfo::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& block) const;
template size_t
LsaInfo::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& block) const;
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(LsaInfo);
const ndn::Block&
LsaInfo::wireEncode() const
+5 -3
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
*/
#ifndef NLSR_TLV_LSA_INFO_HPP
#define NLSR_TLV_LSA_INFO_HPP
@@ -154,6 +154,8 @@ private:
mutable ndn::Block m_wire;
};
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(LsaInfo);
std::ostream&
operator<<(std::ostream& os, const LsaInfo& lsaInfo);
+58 -11
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
*/
#include "lsdb-status.hpp"
#include "tlv-nlsr.hpp"
@@ -26,7 +26,7 @@
#include <ndn-cxx/encoding/block-helpers.hpp>
namespace nlsr {
namespace tlv {
namespace tlv {
BOOST_CONCEPT_ASSERT((ndn::WireEncodable<LsdbStatus>));
BOOST_CONCEPT_ASSERT((ndn::WireDecodable<LsdbStatus>));
@@ -45,6 +45,57 @@ LsdbStatus::LsdbStatus(const ndn::Block& block)
wireDecode(block);
}
LsdbStatus&
LsdbStatus::addAdjacencyLsa(const AdjacencyLsa& adjacencyLsa)
{
m_adjacencyLsas.push_back(adjacencyLsa);
m_wire.reset();
m_hasAdjacencyLsas = true;
return *this;
}
LsdbStatus&
LsdbStatus::clearAdjacencyLsas()
{
m_adjacencyLsas.clear();
m_hasAdjacencyLsas = false;
return *this;
}
LsdbStatus&
LsdbStatus::addCoordinateLsa(const CoordinateLsa& coordinateLsa)
{
m_coordinateLsas.push_back(coordinateLsa);
m_wire.reset();
m_hasCoordinateLsas = true;
return *this;
}
LsdbStatus&
LsdbStatus::clearCoordinateLsas()
{
m_coordinateLsas.clear();
m_hasCoordinateLsas = false;
return *this;
}
LsdbStatus&
LsdbStatus::addNameLsa(const NameLsa& nameLsa)
{
m_nameLsas.push_back(nameLsa);
m_wire.reset();
m_hasNameLsas = true;
return *this;
}
LsdbStatus&
LsdbStatus::clearNameLsas()
{
m_nameLsas.clear();
m_hasNameLsas = false;
return *this;
}
template<ndn::encoding::Tag TAG>
size_t
LsdbStatus::wireEncode(ndn::EncodingImpl<TAG>& block) const
@@ -72,11 +123,7 @@ LsdbStatus::wireEncode(ndn::EncodingImpl<TAG>& block) const
return totalLength;
}
template size_t
LsdbStatus::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& block) const;
template size_t
LsdbStatus::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& block) const;
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(LsdbStatus);
const ndn::Block&
LsdbStatus::wireEncode() const
@@ -113,7 +160,7 @@ LsdbStatus::wireDecode(const ndn::Block& wire)
std::stringstream error;
error << "Expected LsdbStatus Block, but Block is of a different type: #"
<< m_wire.type();
throw Error(error.str());
BOOST_THROW_EXCEPTION(Error(error.str()));
}
m_wire.parse();
@@ -139,7 +186,7 @@ LsdbStatus::wireDecode(const ndn::Block& wire)
std::stringstream error;
error << "Expected the end of elements, but Block is of a different type: #"
<< val->type();
throw Error(error.str());
BOOST_THROW_EXCEPTION(Error(error.str()));
}
}
+19 -51
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
*/
#ifndef NLSR_TLV_LSDB_STATUS_HPP
#define NLSR_TLV_LSDB_STATUS_HPP
@@ -37,15 +37,14 @@
namespace nlsr {
namespace tlv {
/*!
\brief Data abstraction for LsdbStatus
LsdbStatus := LSDB-STATUS-TYPE TLV-LENGTH
AdjacencyLsa*
CoordinateLsa*
NameLsa*
\sa https://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
/*! \brief Data abstraction for LsdbStatus
*
* LsdbStatus := LSDB-STATUS-TYPE TLV-LENGTH
* AdjacencyLsa*
* CoordinateLsa*
* NameLsa*
*
* \sa https://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
*/
class LsdbStatus
{
@@ -76,21 +75,10 @@ public:
}
LsdbStatus&
addAdjacencyLsa(const AdjacencyLsa& adjacencyLsa)
{
m_adjacencyLsas.push_back(adjacencyLsa);
m_wire.reset();
m_hasAdjacencyLsas = true;
return *this;
}
addAdjacencyLsa(const AdjacencyLsa& adjacencyLsa);
LsdbStatus&
clearAdjacencyLsas()
{
m_adjacencyLsas.clear();
m_hasAdjacencyLsas = false;
return *this;
}
clearAdjacencyLsas();
bool
hasAdjacencyLsas()
@@ -105,21 +93,10 @@ public:
}
LsdbStatus&
addCoordinateLsa(const CoordinateLsa& coordinateLsa)
{
m_coordinateLsas.push_back(coordinateLsa);
m_wire.reset();
m_hasCoordinateLsas = true;
return *this;
}
addCoordinateLsa(const CoordinateLsa& coordinateLsa);
LsdbStatus&
clearCoordinateLsas()
{
m_coordinateLsas.clear();
m_hasCoordinateLsas = false;
return *this;
}
clearCoordinateLsas();
bool
hasCoordinateLsas()
@@ -134,21 +111,10 @@ public:
}
LsdbStatus&
addNameLsa(const NameLsa& nameLsa)
{
m_nameLsas.push_back(nameLsa);
m_wire.reset();
m_hasNameLsas = true;
return *this;
}
addNameLsa(const NameLsa& nameLsa);
LsdbStatus&
clearNameLsas()
{
m_nameLsas.clear();
m_hasNameLsas = false;
return *this;
}
clearNameLsas();
bool
hasNameLsas()
@@ -199,6 +165,8 @@ private:
mutable ndn::Block m_wire;
};
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(LsdbStatus);
std::ostream&
operator<<(std::ostream& os, const LsdbStatus& lsdbStatus);
+10 -18
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
*/
#include "name-lsa.hpp"
#include "tlv-nlsr.hpp"
@@ -26,7 +26,7 @@
#include <ndn-cxx/encoding/block-helpers.hpp>
namespace nlsr {
namespace tlv {
namespace tlv {
BOOST_CONCEPT_ASSERT((ndn::WireEncodable<NameLsa>));
BOOST_CONCEPT_ASSERT((ndn::WireDecodable<NameLsa>));
@@ -62,11 +62,7 @@ NameLsa::wireEncode(ndn::EncodingImpl<TAG>& block) const
return totalLength;
}
template size_t
NameLsa::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& block) const;
template size_t
NameLsa::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& block) const;
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(NameLsa);
const ndn::Block&
NameLsa::wireEncode() const
@@ -95,10 +91,8 @@ NameLsa::wireDecode(const ndn::Block& wire)
m_wire = wire;
if (m_wire.type() != ndn::tlv::nlsr::NameLsa) {
std::stringstream error;
error << "Expected NameLsa Block, but Block is of a different type: #"
<< m_wire.type();
throw Error(error.str());
BOOST_THROW_EXCEPTION(Error("Expected NameLsa Block, but Block is of a different type: #" +
ndn::to_string(m_wire.type())));
}
m_wire.parse();
@@ -110,7 +104,7 @@ NameLsa::wireDecode(const ndn::Block& wire)
++val;
}
else {
throw Error("Missing required LsaInfo field");
BOOST_THROW_EXCEPTION(Error("Missing required LsaInfo field"));
}
for (; val != m_wire.elements_end(); ++val) {
@@ -119,10 +113,8 @@ NameLsa::wireDecode(const ndn::Block& wire)
m_hasNames = true;
}
else {
std::stringstream error;
error << "Expected Name Block, but Block is of a different type: #"
<< m_wire.type();
throw Error(error.str());
BOOST_THROW_EXCEPTION(Error("Expected Name Block, but Block is of a different type: #" +
ndn::to_string(m_wire.type())));
}
}
}
+5 -3
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
*/
#ifndef NLSR_TLV_NAME_LSA_HPP
#define NLSR_TLV_NAME_LSA_HPP
@@ -152,6 +152,8 @@ private:
mutable ndn::Block m_wire;
};
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(NameLsa);
inline NameLsa::iterator
NameLsa::begin() const
{
+124
View File
@@ -0,0 +1,124 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2018, 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 "nexthop.hpp"
#include "tlv-nlsr.hpp"
#include "coordinate-lsa.hpp"
#include <ndn-cxx/util/concepts.hpp>
#include <ndn-cxx/encoding/block-helpers.hpp>
namespace nlsr {
namespace tlv {
BOOST_CONCEPT_ASSERT((ndn::WireEncodable<NextHop>));
BOOST_CONCEPT_ASSERT((ndn::WireDecodable<NextHop>));
static_assert(std::is_base_of<ndn::tlv::Error, NextHop::Error>::value,
"NextHop::Error must inherit from tlv::Error");
NextHop::NextHop()
: m_cost(0)
{
}
NextHop::NextHop(const ndn::Block& block)
{
wireDecode(block);
}
template<ndn::encoding::Tag TAG>
size_t
NextHop::wireEncode(ndn::EncodingImpl<TAG>& block) const
{
size_t totalLength = 0;
totalLength += prependDouble(block, ndn::tlv::nlsr::Double, m_cost);
totalLength += block.prependByteArrayBlock(
ndn::tlv::nlsr::Uri, reinterpret_cast<const uint8_t*>(m_uri.c_str()), m_uri.size());
totalLength += block.prependVarNumber(totalLength);
totalLength += block.prependVarNumber(ndn::tlv::nlsr::NextHop);
return totalLength;
}
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(NextHop);
const ndn::Block&
NextHop::wireEncode() const
{
if (m_wire.hasWire()) {
return m_wire;
}
ndn::EncodingEstimator estimator;
size_t estimatedSize = wireEncode(estimator);
ndn::EncodingBuffer buffer(estimatedSize, 0);
wireEncode(buffer);
m_wire = buffer.block();
return m_wire;
}
void
NextHop::wireDecode(const ndn::Block& wire)
{
m_uri = "";
m_cost = 0;
m_wire = wire;
if (m_wire.type() != ndn::tlv::nlsr::NextHop) {
std::stringstream error;
error << "Expected NextHop Block, but Block is of a different type: #"
<< m_wire.type();
BOOST_THROW_EXCEPTION(Error(error.str()));
}
m_wire.parse();
ndn::Block::element_const_iterator val = m_wire.elements_begin();
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::Uri) {
m_uri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
++val;
}
else {
BOOST_THROW_EXCEPTION(Error("Missing required Uri field"));
}
m_cost = ndn::tlv::nlsr::readDouble(*val);
}
std::ostream&
operator<<(std::ostream& os, const NextHop& nexthop)
{
os << "NextHop("
<< "Uri: " << nexthop.getUri() << ", "<< "Cost: " << nexthop.getCost() << ")" << std::endl;
return os;
}
} // namespace tlv
} // namespace nlsr
+114
View File
@@ -0,0 +1,114 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2018, 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/>.
**/
#ifndef NLSR_TLV_NEXTHOP_HPP
#define NLSR_TLV_NEXTHOP_HPP
#include <ndn-cxx/util/time.hpp>
#include <ndn-cxx/encoding/block.hpp>
#include <ndn-cxx/encoding/encoding-buffer.hpp>
#include <ndn-cxx/encoding/tlv.hpp>
#include <ndn-cxx/name.hpp>
#include <boost/throw_exception.hpp>
namespace nlsr {
namespace tlv {
/*! \brief Data abstraction for Nexthop
*
* NextHop := NEXTHOP-TYPE TLV-LENGTH
* Uri
* Cost
*
* \sa https://redmine.named-data.net/projects/nlsr/wiki/Routing_Table_Dataset
*/
class NextHop
{
public:
class Error : public ndn::tlv::Error
{
public:
explicit
Error(const std::string& what)
: ndn::tlv::Error(what)
{
}
};
NextHop();
explicit
NextHop(const ndn::Block& block);
const std::string&
getUri() const
{
return m_uri;
}
NextHop&
setUri(const std::string& uri)
{
m_uri = uri;
m_wire.reset();
return *this;
}
double
getCost() const
{
return m_cost;
}
NextHop&
setCost(double cost)
{
m_cost = cost;
m_wire.reset();
return *this;
}
template<ndn::encoding::Tag TAG>
size_t
wireEncode(ndn::EncodingImpl<TAG>& block) const;
const ndn::Block&
wireEncode() const;
void
wireDecode(const ndn::Block& wire);
private:
std::string m_uri;
double m_cost;
mutable ndn::Block m_wire;
};
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(NextHop);
std::ostream&
operator<<(std::ostream& os, const NextHop& nexthop);
} // namespace tlv
} // namespace nlsr
#endif // NLSR_TLV_NEXTHOP_HPP
+164
View File
@@ -0,0 +1,164 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2018, 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 "routing-table-entry.hpp"
#include "tlv-nlsr.hpp"
#include <ndn-cxx/util/concepts.hpp>
#include <ndn-cxx/encoding/block-helpers.hpp>
namespace nlsr {
namespace tlv {
BOOST_CONCEPT_ASSERT((ndn::WireEncodable<RoutingTable>));
BOOST_CONCEPT_ASSERT((ndn::WireDecodable<RoutingTable>));
static_assert(std::is_base_of<ndn::tlv::Error, RoutingTable::Error>::value,
"RoutingTable::Error must inherit from tlv::Error");
RoutingTable::RoutingTable()
: m_hasNexthops(false)
{
}
RoutingTable::RoutingTable(const ndn::Block& block)
{
wireDecode(block);
}
bool
RoutingTable::hasNexthops() const
{
return m_hasNexthops;
}
RoutingTable&
RoutingTable::addNexthops(const NextHop& nexthop)
{
m_nexthops.push_back(nexthop);
m_wire.reset();
m_hasNexthops = true;
return *this;
}
RoutingTable&
RoutingTable::clearNexthops()
{
m_nexthops.clear();
m_hasNexthops = false;
return *this;
}
template<ndn::encoding::Tag TAG>
size_t
RoutingTable::wireEncode(ndn::EncodingImpl<TAG>& block) const
{
size_t totalLength = 0;
for (std::list<NextHop>::const_reverse_iterator it = m_nexthops.rbegin();
it != m_nexthops.rend(); ++it) {
totalLength += it->wireEncode(block);
}
totalLength += m_des.wireEncode(block);
totalLength += block.prependVarNumber(totalLength);
totalLength += block.prependVarNumber(ndn::tlv::nlsr::RouteTableEntry);
return totalLength;
}
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(RoutingTable);
const ndn::Block&
RoutingTable::wireEncode() const
{
if (m_wire.hasWire()) {
return m_wire;
}
ndn::EncodingEstimator estimator;
size_t estimatedSize = wireEncode(estimator);
ndn::EncodingBuffer buffer(estimatedSize, 0);
wireEncode(buffer);
m_wire = buffer.block();
return m_wire;
}
void
RoutingTable::wireDecode(const ndn::Block& wire)
{
m_hasNexthops = false;
m_nexthops.clear();
m_wire = wire;
if (m_wire.type() != ndn::tlv::nlsr::RouteTableEntry) {
std::stringstream error;
error << "Expected RoutingTable Block, but Block is of a different type: #"
<< m_wire.type();
BOOST_THROW_EXCEPTION(Error(error.str()));
}
m_wire.parse();
ndn::Block::element_const_iterator val = m_wire.elements_begin();
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::Destination) {
m_des.wireDecode(*val);
++val;
}
else {
BOOST_THROW_EXCEPTION(Error("Missing required destination field"));
}
for (; val != m_wire.elements_end(); ++val) {
if (val->type() == ndn::tlv::nlsr::NextHop) {
m_nexthops.push_back(NextHop(*val));
m_hasNexthops = true;
}
else {
std::stringstream error;
error << "Expected NextHop Block, but Block is of a different type: #"
<< m_wire.type();
BOOST_THROW_EXCEPTION(Error(error.str()));
}
}
}
std::ostream&
operator<<(std::ostream& os, const RoutingTable& routingtable)
{
os << routingtable.getDestination() << std::endl;
os << "NexthopList(" << std::endl;
for (const auto& rtentry : routingtable) {
os << rtentry;
}
os << ")";
return os;
}
} // namespace tlv
} // namespace nlsr
+156
View File
@@ -0,0 +1,156 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2018, 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/>.
**/
#ifndef NLSR_TLV_ROUTING_TABLE_ENTRY_HPP
#define NLSR_TLV_ROUTING_TABLE_ENTRY_HPP
#include "destination.hpp"
#include "nexthop.hpp"
#include <ndn-cxx/util/time.hpp>
#include <ndn-cxx/encoding/block.hpp>
#include <ndn-cxx/encoding/encoding-buffer.hpp>
#include <ndn-cxx/encoding/tlv.hpp>
#include <ndn-cxx/name.hpp>
#include <list>
namespace nlsr {
namespace tlv {
/*! \brief Data abstraction for RouteTableInfo
*
* RouteTableInfo := ROUTINGTABLE-TYPE TLV-LENGTH
* Destination
* NexthopList*
*
* \sa https://redmine.named-data.net/projects/nlsr/wiki/Routing_Table_DataSet
*/
class RoutingTable
{
public:
class Error : public ndn::tlv::Error
{
public:
explicit
Error(const std::string& what)
: ndn::tlv::Error(what)
{
}
};
typedef std::list<NextHop> HopList;
typedef HopList::const_iterator const_iterator;
RoutingTable();
explicit
RoutingTable(const ndn::Block& block);
const Destination&
getDestination() const
{
return m_des;
}
RoutingTable&
setDestination(const Destination& des)
{
m_des = des;
m_wire.reset();
return *this;
}
uint64_t
getRtSize() const
{
return m_size;
}
RoutingTable&
setRtSize(uint64_t size)
{
m_size = size;
m_wire.reset();
return *this;
}
bool
hasNexthops() const;
const std::list<NextHop>&
getNextHops() const
{
return m_nexthops;
}
RoutingTable&
addNexthops(const NextHop& nexthop);
RoutingTable&
clearNexthops();
template<ndn::encoding::Tag TAG>
size_t
wireEncode(ndn::EncodingImpl<TAG>& block) const;
const ndn::Block&
wireEncode() const;
void
wireDecode(const ndn::Block& wire);
const_iterator
begin() const;
const_iterator
end() const;
private:
Destination m_des;
uint64_t m_size;
bool m_hasNexthops;
HopList m_nexthops;
mutable ndn::Block m_wire;
};
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(RoutingTable);
inline RoutingTable::const_iterator
RoutingTable::begin() const
{
return m_nexthops.begin();
}
inline RoutingTable::const_iterator
RoutingTable::end() const
{
return m_nexthops.end();
}
std::ostream&
operator<<(std::ostream& os, const RoutingTable& routetable);
} // namespace tlv
} // namespace nlsr
#endif // NLSR_TLV_ROUTING_TABLE_ENTRY_HPP
+161
View File
@@ -0,0 +1,161 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2018, 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 "routing-table-status.hpp"
#include "tlv-nlsr.hpp"
#include <ndn-cxx/util/concepts.hpp>
#include <ndn-cxx/encoding/block-helpers.hpp>
namespace nlsr {
namespace tlv {
BOOST_CONCEPT_ASSERT((ndn::WireEncodable<RoutingTableStatus>));
BOOST_CONCEPT_ASSERT((ndn::WireDecodable<RoutingTableStatus>));
static_assert(std::is_base_of<ndn::tlv::Error, RoutingTableStatus::Error>::value,
"RoutingTableStatus::Error must inherit from tlv::Error");
RoutingTableStatus::RoutingTableStatus()
: m_hasRoutingtable(false)
{
}
RoutingTableStatus::RoutingTableStatus(const ndn::Block& block)
{
wireDecode(block);
}
RoutingTableStatus&
RoutingTableStatus::addRoutingTable(const RoutingTable& routetable)
{
m_routingtables.push_back(routetable);
m_wire.reset();
m_hasRoutingtable = true;
return *this;
}
RoutingTableStatus&
RoutingTableStatus::clearRoutingTable()
{
m_routingtables.clear();
m_hasRoutingtable = false;
return *this;
}
bool
RoutingTableStatus::hasRoutingTable()
{
return m_hasRoutingtable;
}
template<ndn::encoding::Tag TAG>
size_t
RoutingTableStatus::wireEncode(ndn::EncodingImpl<TAG>& block) const
{
size_t totalLength = 0;
for (std::list<RoutingTable>::const_reverse_iterator it = m_routingtables.rbegin();
it != m_routingtables.rend(); ++it) {
totalLength += it->wireEncode(block);
}
totalLength += block.prependVarNumber(totalLength);
totalLength += block.prependVarNumber(ndn::tlv::nlsr::RoutingTable);
return totalLength;
}
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(RoutingTableStatus);
const ndn::Block&
RoutingTableStatus::wireEncode() const
{
if (m_wire.hasWire()) {
return m_wire;
}
ndn::EncodingEstimator estimator;
size_t estimatedSize = wireEncode(estimator);
ndn::EncodingBuffer buffer(estimatedSize, 0);
wireEncode(buffer);
m_wire = buffer.block();
return m_wire;
}
void
RoutingTableStatus::wireDecode(const ndn::Block& wire)
{
m_routingtables.clear();
m_hasRoutingtable = false;
m_wire = wire;
if (m_wire.type() != ndn::tlv::nlsr::RoutingTable) {
std::stringstream error;
error << "Expected RoutingTableStatus Block, but Block is of a different type: #"
<< m_wire.type();
BOOST_THROW_EXCEPTION(Error(error.str()));
}
m_wire.parse();
ndn::Block::element_const_iterator val = m_wire.elements_begin();
for (; val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::RouteTableEntry; ++val) {
m_routingtables.push_back(RoutingTable(*val));
m_hasRoutingtable = true;
}
if (val != m_wire.elements_end()) {
std::stringstream error;
error << "Expected the end of elements, but Block is of a different type: #"
<< val->type();
BOOST_THROW_EXCEPTION(Error(error.str()));
}
}
std::ostream&
operator<<(std::ostream& os, const RoutingTableStatus& rtStatus)
{
os << "Routing Table Status: " << std::endl;;
bool isFirst = true;
for (const auto& routingtable : rtStatus.getRoutingtable()) {
if (isFirst) {
isFirst = false;
}
else {
os << ", ";
}
os << routingtable;
}
return os;
}
} // namespace tlv
} // namespace nlsr
+106
View File
@@ -0,0 +1,106 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2018, 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/>.
**/
#ifndef NLSR_TLV_ROUTING_TABLE_STATUS_HPP
#define NLSR_TLV_ROUTING_TABLE_STATUS_HPP
#include "routing-table-entry.hpp"
#include "destination.hpp"
#include <ndn-cxx/util/time.hpp>
#include <ndn-cxx/encoding/block.hpp>
#include <ndn-cxx/encoding/encoding-buffer.hpp>
#include <ndn-cxx/encoding/tlv.hpp>
#include <ndn-cxx/name.hpp>
#include <list>
namespace nlsr {
namespace tlv {
/*! \brief Data abstraction for routing table status
*
* RtStatus := RT-STATUS-TYPE TLV-LENGTH
* RouteTableInfo*
*
* \sa https://redmine.named-data.net/projects/nlsr/wiki/Routing_Table_Dataset
*/
class RoutingTableStatus
{
public:
class Error : public ndn::tlv::Error
{
public:
explicit
Error(const std::string& what)
: ndn::tlv::Error(what)
{
}
};
typedef std::list<RoutingTable> RTList;
RoutingTableStatus();
explicit
RoutingTableStatus(const ndn::Block& block);
const std::list<RoutingTable>&
getRoutingtable() const
{
return m_routingtables;
}
RoutingTableStatus&
addRoutingTable(const RoutingTable& routeTable);
RoutingTableStatus&
clearRoutingTable();
bool
hasRoutingTable();
template<ndn::encoding::Tag TAG>
size_t
wireEncode(ndn::EncodingImpl<TAG>& block) const;
const ndn::Block&
wireEncode() const;
void
wireDecode(const ndn::Block& wire);
private:
RTList m_routingtables;
bool m_hasRoutingtable;
mutable ndn::Block m_wire;
};
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(RoutingTableStatus);
std::ostream&
operator<<(std::ostream& os, const RoutingTableStatus& rtStatus);
} // namespace tlv
} // namespace nlsr
#endif // NLSR_TLV_ROUTING_TABLE_STATUS_HPP
+46 -2
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -23,6 +23,7 @@
#define NLSR_TLV_NLSR_HPP
#include <ndn-cxx/encoding/tlv.hpp>
#include <ndn-cxx/encoding/block-helpers.hpp>
namespace ndn {
namespace tlv {
@@ -47,9 +48,52 @@ enum {
LsdbStatus = 138,
ExpirationPeriod = 139,
Cost = 140,
Uri = 141
Uri = 141,
Destination = 142,
NextHop = 143,
RoutingTable = 144,
RouteTableEntry = 145
};
/*! \brief Read a double from a TLV element
* \param block the TLV element
* \throw ndn::tlv::Error block does not contain a double
* \sa prependDouble
*/
inline double
readDouble(const ndn::Block& block)
{
block.parse();
auto it = block.elements_begin();
double doubleFromBlock = 0.0;
if (it == it->elements_end() || it->type() != ndn::tlv::nlsr::Double ||
it->value_size() != sizeof(doubleFromBlock)) {
BOOST_THROW_EXCEPTION(ndn::tlv::Error("Block does not contain a double"));
}
memcpy(&doubleFromBlock, it->value(), sizeof(doubleFromBlock));
return doubleFromBlock;
}
/*! \brief Prepend a TLV element containing a double.
* \param encoder an EncodingBuffer or EncodingEstimator
* \param type TLV-TYPE number
* \param value double value
*/
template<ndn::encoding::Tag TAG>
inline size_t
prependDouble(ndn::EncodingImpl<TAG>& encoder, uint32_t type, double value)
{
size_t totalLength = 0;
const uint8_t* doubleBytes = reinterpret_cast<const uint8_t*>(&value);
totalLength = encoder.prependByteArrayBlock(ndn::tlv::nlsr::Double, doubleBytes, 8);
totalLength += encoder.prependVarNumber(totalLength);
totalLength += encoder.prependVarNumber(type);
return totalLength;
}
} // namespace nlsr
} // namespace tlv
} // namespace ndn
+2 -2
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -25,7 +25,7 @@
namespace nlsr {
namespace update {
INIT_LOGGER("UpdatePrefixCommandProcessor");
INIT_LOGGER(update.PrefixCommandProcessor);
ManagerBase::ManagerBase(ndn::mgmt::Dispatcher& dispatcher,
const std::string& module)
+1 -4
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -20,13 +20,10 @@
**/
#include "nfd-rib-command-processor.hpp"
#include "logger.hpp"
namespace nlsr {
namespace update {
INIT_LOGGER("NfdRibProcessor");
NfdRibCommandProcessor::NfdRibCommandProcessor(ndn::mgmt::Dispatcher& dispatcher,
NamePrefixList& namePrefixList,
Lsdb& lsdb)
+2 -2
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -29,7 +29,7 @@
namespace nlsr {
namespace update {
INIT_LOGGER("PrefixUpdateProcessor");
INIT_LOGGER(update.PrefixUpdateProcessor);
/** \brief an Interest tag to indicate command signer
*/
+28 -3
View File
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -22,7 +22,7 @@
#ifndef NLSR_PUBLISHER_FIXTURE_HPP
#define NLSR_PUBLISHER_FIXTURE_HPP
#include "publisher/lsdb-dataset-interest-handler.hpp"
#include "publisher/dataset-interest-handler.hpp"
#include "nlsr.hpp"
#include "../boost-test.hpp"
@@ -48,8 +48,8 @@ public:
: face(m_ioService, m_keyChain, {true, true})
, nlsr(m_ioService, m_scheduler, face, m_keyChain)
, lsdb(nlsr.getLsdb())
, rt1(nlsr.getRoutingTable())
{
INIT_LOGGERS("/tmp/", "TRACE");
nlsr.getConfParameter().setNetwork("/ndn");
nlsr.getConfParameter().setRouterName("/This/Router");
@@ -59,6 +59,23 @@ public:
face.processEvents(ndn::time::milliseconds(100));
}
void
checkPrefixRegistered(const Name& prefix)
{
bool registerCommandEmitted = false;
for (const auto& interest : face.sentInterests) {
if (interest.getName().size() > 4 && interest.getName().get(3) == name::Component("register")) {
name::Component test = interest.getName().get(4);
ndn::nfd::ControlParameters params(test.blockFromValue());
if (params.getName() == prefix) {
registerCommandEmitted = true;
break;
}
}
}
BOOST_CHECK(registerCommandEmitted);
}
void
addAdjacency(AdjLsa& lsa, const std::string& name, const std::string& faceUri, double cost)
{
@@ -100,6 +117,13 @@ public:
}
}
NextHop
createNextHop(const std::string& faceUri, double cost)
{
NextHop nexthop(faceUri, cost);
return nexthop;
}
CoordinateLsa
createCoordinateLsa(const std::string& origin, double radius, std::vector<double> angle)
{
@@ -159,6 +183,7 @@ public:
Lsdb& lsdb;
ndn::security::pib::Identity routerId;
RoutingTable& rt1;
};
} // namespace test
@@ -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-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -19,7 +19,7 @@
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
#include "publisher/lsdb-dataset-interest-handler.hpp"
#include "publisher/dataset-interest-handler.hpp"
#include "tests/test-common.hpp"
#include "tlv/tlv-nlsr.hpp"
@@ -28,6 +28,8 @@
#include <ndn-cxx/mgmt/nfd/control-response.hpp>
#include <iostream>
namespace nlsr {
namespace test {
@@ -36,6 +38,7 @@ processDatasetInterest(ndn::util::DummyClientFace& face,
std::function<bool(const ndn::Block&)> isSameType)
{
face.processEvents(ndn::time::milliseconds(30));
BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
ndn::Block parser(face.sentData[0].getContent());
@@ -50,21 +53,12 @@ processDatasetInterest(ndn::util::DummyClientFace& face,
face.sentData.clear();
}
void
checkErrorResponse(ndn::util::DummyClientFace& face, uint64_t expectedCode)
{
BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
ndn::nfd::ControlResponse response(face.sentData[0].getContent().blockFromValue());
BOOST_CHECK_EQUAL(response.getCode(), expectedCode);
face.sentData.clear();
}
BOOST_FIXTURE_TEST_SUITE(PublisherTestLsdbDatasetInterestHandler, PublisherFixture)
BOOST_AUTO_TEST_CASE(Localhost)
{
checkPrefixRegistered(Nlsr::LOCALHOST_PREFIX);
// Install adjacency LSA
AdjLsa adjLsa;
adjLsa.setOrigRouter("/RouterA");
@@ -83,6 +77,14 @@ BOOST_AUTO_TEST_CASE(Localhost)
nameLsa.addName("/RouterA/name1");
lsdb.installNameLsa(nameLsa);
// Install routing table
RoutingTableEntry rte1("desrouter1");
const ndn::Name& DEST_ROUTER = rte1.getDestination();
NextHop nh = createNextHop("udp://face-test1", 10);
rt1.addNextHop(DEST_ROUTER, nh);
// Request adjacency LSAs
face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/lsdb").append("adjacencies")));
processDatasetInterest(face,
@@ -98,15 +100,23 @@ BOOST_AUTO_TEST_CASE(Localhost)
processDatasetInterest(face,
[] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::NameLsa; });
// Request LSDB Status
face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/lsdb").append("list")));
// Request Routing Table
face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/routing-table")));
processDatasetInterest(face,
[] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::LsdbStatus; });
[] (const ndn::Block& block) {
return block.type() == ndn::tlv::nlsr::RoutingTable; });
}
BOOST_AUTO_TEST_CASE(Routername)
{
ndn::Name regRouterPrefix(nlsr.getConfParameter().getRouterPrefix());
regRouterPrefix.append("nlsr");
// Should already be added to dispatcher
BOOST_CHECK_THROW(nlsr.getDispatcher().addTopPrefix(regRouterPrefix), std::out_of_range);
checkPrefixRegistered(regRouterPrefix);
//Install adjacencies LSA
AdjLsa adjLsa;
adjLsa.setOrigRouter("/RouterA");
@@ -119,25 +129,34 @@ BOOST_AUTO_TEST_CASE(Routername)
CoordinateLsa coordinateLsa = createCoordinateLsa("/RouterA", 10.0, angles);
lsdb.installCoordinateLsa(coordinateLsa);
//Install routing table
RoutingTableEntry rte1("desrouter1");
const ndn::Name& DEST_ROUTER = rte1.getDestination();
NextHop nh = createNextHop("udp://face-test1", 10);
rt1.addNextHop(DEST_ROUTER, nh);
// Request adjacency LSAs
face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/lsdb").append("adjacencies")));
face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/nlsr/lsdb").append("adjacencies")));
processDatasetInterest(face,
[] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::AdjacencyLsa; });
// Request coordinate LSAs
face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/lsdb").append("coordinates")));
face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/nlsr/lsdb").append("coordinates")));
processDatasetInterest(face,
[] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::CoordinateLsa; });
// Request Name LSAs
face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/lsdb").append("names")));
face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/nlsr/lsdb").append("names")));
processDatasetInterest(face,
[] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::NameLsa; });
// Request LSDB Status
face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/lsdb").append("list")));
// Request Routing Table
face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/nlsr/routing-table")));
processDatasetInterest(face,
[] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::LsdbStatus; });
[] (const ndn::Block& block) {
return block.type() == ndn::tlv::nlsr::RoutingTable; });
}
BOOST_AUTO_TEST_SUITE_END()
Loaded 100 of 125 files, more files were not shown because too many files have changed in this diff. Show more