Compare commits
51
Commits
NLSR-0.2.1
...
NLSR-0.3.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f023a88ec1 | ||
|
|
4c2bb361ae | ||
|
|
1de901f161 | ||
|
|
9f93666519 | ||
|
|
48daea20d7 | ||
|
|
218aaef118 | ||
|
|
87911dacd5 | ||
|
|
54e726cf5e | ||
|
|
a4cf402084 | ||
|
|
f590fecfc2 | ||
|
|
6077ea910c | ||
|
|
d1f4f33cfd | ||
|
|
d8c9d8cdab | ||
|
|
feae5574b8 | ||
|
|
4fc69e49a9 | ||
|
|
c6a852234d | ||
|
|
44395237b8 | ||
|
|
c5fa320239 | ||
|
|
41330f4256 | ||
|
|
96bf2f0db8 | ||
|
|
2b057af9e1 | ||
|
|
b71684744f | ||
|
|
b50e51b374 | ||
|
|
3e5120c543 | ||
|
|
ef21d8eab0 | ||
|
|
97e3494256 | ||
|
|
d69f9a3c82 | ||
|
|
63bd0348b3 | ||
|
|
b9d43d06cc | ||
|
|
e2d3fe9d9a | ||
|
|
7b5872ec86 | ||
|
|
fad8e257c0 | ||
|
|
f8b5bcd27e | ||
|
|
800833b7ac | ||
|
|
e8e03ac303 | ||
|
|
5ec9ae4271 | ||
|
|
f7eec4f4c0 | ||
|
|
5c467f0ca8 | ||
|
|
aa3b085384 | ||
|
|
d02c3880d5 | ||
|
|
3ac0728e5a | ||
|
|
c778e814db | ||
|
|
af909fcc13 | ||
|
|
c69da0a350 | ||
|
|
0ff5d45ba8 | ||
|
|
5d9c0573c0 | ||
|
|
4c7caadb72 | ||
|
|
f9f3910dd2 | ||
|
|
53c0e3e9ee | ||
|
|
c57c64b633 | ||
|
|
97473d47fd |
No files matched your search
@@ -3,7 +3,8 @@ set -e
|
||||
|
||||
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
|
||||
for i in $( find "$DIR/.jenkins.d" -type f -perm +111 | sort ); do
|
||||
echo "Run: $i"
|
||||
"$i"
|
||||
for file in "$DIR"/.jenkins.d/*; do
|
||||
[[ -f $file && -x $file ]] || continue
|
||||
echo "Run: $file"
|
||||
"$file"
|
||||
done
|
||||
@@ -10,6 +10,7 @@ if has OSX $NODE_LABELS && ! has OSX-10.8-c++11-64bit $NODE_LABELS; then
|
||||
brew update
|
||||
brew upgrade
|
||||
brew install boost pkg-config sqlite cryptopp log4cxx protobuf openssl
|
||||
brew link --force openssl log4cxx protobuf
|
||||
brew cleanup
|
||||
fi
|
||||
|
||||
|
||||
@@ -2,12 +2,17 @@
|
||||
set -x
|
||||
set -e
|
||||
|
||||
JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
source "$JDIR"/util.sh
|
||||
|
||||
pushd /tmp >/dev/null
|
||||
|
||||
INSTALLED_VERSION=$((cd ndn-cxx && git rev-parse HEAD) 2>/dev/null || echo NONE)
|
||||
|
||||
sudo rm -Rf ndn-cxx-latest
|
||||
|
||||
git clone --depth 1 git://github.com/named-data/ndn-cxx ndn-cxx-latest
|
||||
|
||||
LATEST_VERSION=$((cd ndn-cxx-latest && git rev-parse HEAD) 2>/dev/null || echo UNKNOWN)
|
||||
|
||||
if [[ $INSTALLED_VERSION != $LATEST_VERSION ]]; then
|
||||
@@ -23,9 +28,15 @@ sudo rm -f /usr/local/lib/pkgconfig/libndn-cxx*
|
||||
|
||||
pushd ndn-cxx >/dev/null
|
||||
|
||||
./waf configure -j1 --color=yes --without-osx-keychain
|
||||
./waf configure -j1 --color=yes --enable-shared --disable-static --without-osx-keychain
|
||||
./waf -j1 --color=yes
|
||||
sudo ./waf install -j1 --color=yes
|
||||
|
||||
popd >/dev/null
|
||||
popd >/dev/null
|
||||
|
||||
if has Linux $NODE_LABELS; then
|
||||
sudo ldconfig
|
||||
elif has FreeBSD $NODE_LABELS; then
|
||||
sudo ldconfig -a
|
||||
fi
|
||||
+19
-9
@@ -1,15 +1,25 @@
|
||||
sudo: true
|
||||
language: cpp
|
||||
os:
|
||||
- linux
|
||||
compiler:
|
||||
- gcc
|
||||
sudo: required
|
||||
language: generic
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
dist: trusty
|
||||
env:
|
||||
- CXX=g++
|
||||
- NODE_LABELS="Linux Ubuntu Ubuntu-14.04"
|
||||
- os: linux
|
||||
dist: trusty
|
||||
env:
|
||||
- CXX=clang++
|
||||
- NODE_LABELS="Linux Ubuntu Ubuntu-14.04"
|
||||
- os: osx
|
||||
osx_image: xcode8.2
|
||||
env:
|
||||
- CXX=clang++
|
||||
- NODE_LABELS="OSX OSX-10.12"
|
||||
notifications:
|
||||
email:
|
||||
on_success: always
|
||||
on_failure: always
|
||||
env:
|
||||
global:
|
||||
- NODE_LABELS="Linux Ubuntu Ubuntu-12.04 Ubuntu-12.04-64bit Boost1.48"
|
||||
script:
|
||||
- ./.jenkins
|
||||
@@ -1,53 +1,58 @@
|
||||
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
from waflib import Logs, Configure
|
||||
from waflib import Logs, Configure, Utils
|
||||
|
||||
def options(opt):
|
||||
opt.add_option('--debug', '--with-debug', action='store_true', default=False, dest='debug',
|
||||
help='''Compile in debugging mode without optimizations (-O0 or -Og)''')
|
||||
|
||||
def configure(conf):
|
||||
areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
|
||||
defaultFlags = ['-std=c++0x', '-std=c++11',
|
||||
'-stdlib=libc++', # clang on OSX < 10.9 by default uses a non
|
||||
# C++11-compatible STL library
|
||||
'-Wall', '-Wno-long-long']
|
||||
cxx = conf.env['CXX_NAME'] # CXX_NAME represents generic name of the compiler
|
||||
if cxx == 'gcc':
|
||||
flags = GccFlags()
|
||||
elif cxx == 'clang':
|
||||
flags = ClangFlags()
|
||||
else:
|
||||
flags = CompilerFlags()
|
||||
Logs.warn('The code has not yet been tested with %s compiler' % cxx)
|
||||
|
||||
areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
|
||||
|
||||
# General flags are always applied (e.g., selecting C++11 mode)
|
||||
generalFlags = flags.getGeneralFlags(conf)
|
||||
conf.add_supported_cxxflags(generalFlags['CXXFLAGS'])
|
||||
conf.add_supported_linkflags(generalFlags['LINKFLAGS'])
|
||||
conf.env.DEFINES += generalFlags['DEFINES']
|
||||
|
||||
# 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:
|
||||
conf.define('_DEBUG', 1)
|
||||
defaultFlags += ['-O0',
|
||||
'-Og', # gcc >= 4.8
|
||||
'-g3',
|
||||
'-fcolor-diagnostics', # clang
|
||||
'-fdiagnostics-color', # gcc >= 4.9
|
||||
'-Werror',
|
||||
'-Wno-error=deprecated-register',
|
||||
'-Wno-error=maybe-uninitialized', # Bug #1615
|
||||
'-Wno-error=unneeded-internal-declaration', # Bug #1588
|
||||
'-Wno-nested-anon-types',
|
||||
]
|
||||
extraFlags = flags.getDebugFlags(conf)
|
||||
if areCustomCxxflagsPresent:
|
||||
missingFlags = [x for x in defaultFlags if x not in conf.env.CXXFLAGS]
|
||||
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))
|
||||
else:
|
||||
conf.add_supported_cxxflags(defaultFlags)
|
||||
else:
|
||||
defaultFlags += ['-O2', '-g']
|
||||
if not areCustomCxxflagsPresent:
|
||||
conf.add_supported_cxxflags(defaultFlags)
|
||||
extraFlags = flags.getOptimizedFlags(conf)
|
||||
|
||||
# clang on OSX < 10.9 by default uses a non C++11-compatible STL library
|
||||
conf.add_supported_linkflags(['-stdlib=libc++'])
|
||||
if not areCustomCxxflagsPresent:
|
||||
conf.add_supported_cxxflags(extraFlags['CXXFLAGS'])
|
||||
conf.add_supported_linkflags(extraFlags['LINKFLAGS'])
|
||||
|
||||
conf.env.DEFINES += extraFlags['DEFINES']
|
||||
|
||||
@Configure.conf
|
||||
def add_supported_cxxflags(self, cxxflags):
|
||||
"""
|
||||
Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
|
||||
"""
|
||||
self.start_msg('Checking allowed compile-stage flags for c++ compiler')
|
||||
if len(cxxflags) == 0:
|
||||
return
|
||||
|
||||
self.start_msg('Checking supported CXXFLAGS')
|
||||
|
||||
supportedFlags = []
|
||||
for flag in cxxflags:
|
||||
@@ -62,7 +67,10 @@ def add_supported_linkflags(self, linkflags):
|
||||
"""
|
||||
Check which linkflags are supported by compiler and add them to env.LINKFLAGS variable
|
||||
"""
|
||||
self.start_msg('Checking allowed link-stage flags for c++ compiler')
|
||||
if len(linkflags) == 0:
|
||||
return
|
||||
|
||||
self.start_msg('Checking supported LINKFLAGS')
|
||||
|
||||
supportedFlags = []
|
||||
for flag in linkflags:
|
||||
@@ -71,3 +79,114 @@ def add_supported_linkflags(self, linkflags):
|
||||
|
||||
self.end_msg(' '.join(supportedFlags))
|
||||
self.env.LINKFLAGS = supportedFlags + self.env.LINKFLAGS
|
||||
|
||||
|
||||
class CompilerFlags(object):
|
||||
def getGeneralFlags(self, conf):
|
||||
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are always needed"""
|
||||
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []}
|
||||
|
||||
def getDebugFlags(self, conf):
|
||||
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in debug mode"""
|
||||
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['_DEBUG']}
|
||||
|
||||
def getOptimizedFlags(self, conf):
|
||||
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in optimized mode"""
|
||||
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['NDEBUG']}
|
||||
|
||||
class GccBasicFlags(CompilerFlags):
|
||||
"""
|
||||
This class defines basic flags that work for both gcc and clang compilers
|
||||
"""
|
||||
def getDebugFlags(self, conf):
|
||||
flags = super(GccBasicFlags, self).getDebugFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-O0',
|
||||
'-g3',
|
||||
'-pedantic',
|
||||
'-Wall',
|
||||
'-Wextra',
|
||||
'-Werror',
|
||||
'-Wno-unused-parameter',
|
||||
'-Wno-error=maybe-uninitialized', # Bug #1615
|
||||
'-Wno-error=deprecated-declarations', # Bug #3795
|
||||
]
|
||||
return flags
|
||||
|
||||
def getOptimizedFlags(self, conf):
|
||||
flags = super(GccBasicFlags, self).getOptimizedFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-O2',
|
||||
'-g',
|
||||
'-pedantic',
|
||||
'-Wall',
|
||||
'-Wextra',
|
||||
'-Wno-unused-parameter',
|
||||
]
|
||||
return flags
|
||||
|
||||
class GccFlags(GccBasicFlags):
|
||||
def getGeneralFlags(self, conf):
|
||||
flags = super(GccFlags, self).getGeneralFlags(conf)
|
||||
version = tuple(int(i) for i in conf.env['CC_VERSION'])
|
||||
if version < (4, 6, 0):
|
||||
conf.fatal('The version of gcc you are using (%s) is too old.\n' %
|
||||
'.'.join(conf.env['CC_VERSION']) +
|
||||
'The minimum supported gcc version is 4.6.0.')
|
||||
elif version < (4, 7, 0):
|
||||
flags['CXXFLAGS'] += ['-std=c++0x']
|
||||
else:
|
||||
flags['CXXFLAGS'] += ['-std=c++11']
|
||||
if version < (4, 8, 0):
|
||||
flags['DEFINES'] += ['_GLIBCXX_USE_NANOSLEEP'] # Bug #2499
|
||||
return flags
|
||||
|
||||
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):
|
||||
flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
|
||||
flags['CXXFLAGS'] += ['-Og', # gcc >= 4.8
|
||||
'-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):
|
||||
flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
|
||||
flags['CXXFLAGS'] += ['-fdiagnostics-color'] # gcc >= 4.9
|
||||
return flags
|
||||
|
||||
class ClangFlags(GccBasicFlags):
|
||||
def getGeneralFlags(self, conf):
|
||||
flags = super(ClangFlags, self).getGeneralFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-std=c++11']
|
||||
if Utils.unversioned_sys_platform() == 'darwin':
|
||||
flags['CXXFLAGS'] += ['-stdlib=libc++']
|
||||
flags['LINKFLAGS'] += ['-stdlib=libc++']
|
||||
return flags
|
||||
|
||||
def getDebugFlags(self, conf):
|
||||
flags = super(ClangFlags, self).getDebugFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
|
||||
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
|
||||
'-Wno-error=unneeded-internal-declaration', # Bug #1588
|
||||
'-Wno-error=deprecated-register',
|
||||
'-Wno-error=keyword-macro', # Bug #3235
|
||||
'-Wno-nested-anon-types',
|
||||
'-Wno-sign-compare',
|
||||
'-Wno-keyword-macro',
|
||||
'-Wno-error=ignored-qualifiers',
|
||||
'-Wno-error=infinite-recursion',
|
||||
]
|
||||
return flags
|
||||
|
||||
def getOptimizedFlags(self, conf):
|
||||
flags = super(ClangFlags, self).getOptimizedFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
|
||||
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
|
||||
'-Wno-nested-anon-types',
|
||||
'-Wno-sign-compare',
|
||||
'-Wno-keyword-macro',
|
||||
]
|
||||
return flags
|
||||
+9
-3
@@ -28,6 +28,9 @@ NLSR is an open source project includes contributions from the members of the
|
||||
* Minsheng Zhang <mzhang4@memphis.edu>
|
||||
* Syed Obaid Amin <http://obaidamin.weebly.com/>
|
||||
* Vince Lehman <http://vslehman.com>
|
||||
* Muktadir R Chowdhury <mrchwdhr@memphis.edu>
|
||||
* Nicholas Gordon <nmgordon@memphis.edu>
|
||||
* Laqin Fan <lfan1@memphis.edu>
|
||||
|
||||
* University of California, Los Angeles
|
||||
|
||||
@@ -36,9 +39,12 @@ NLSR is an open source project includes contributions from the members of the
|
||||
* Spyridon Mastorakis <http://cs.ucla.edu/~mastorakis/>
|
||||
* Jiewen Tan <alanwake@ucla.edu>
|
||||
|
||||
* University of Arizona
|
||||
|
||||
* Junxiao Shi <https://www.cs.arizona.edu/people/shijunxiao/>
|
||||
|
||||
|
||||
## Queries about NLSR
|
||||
|
||||
Any general question related to NLSR should be directed to Vince Lehman
|
||||
(vslehman@memphis.edu) and security related question should be directed to
|
||||
Yingdi Yu (yingdi@cs.ucla.edu)
|
||||
Any question related to NLSR should be directed to Ashlesh Gawande (agawande@memphis.edu),
|
||||
Muktadir R Chowdhury (mrchwdhr@memphis.edu), and Nicholas Gordon (nmgordon@memphis.edu).
|
||||
@@ -1,6 +1,99 @@
|
||||
Release Notes
|
||||
=============
|
||||
|
||||
NLSR version 0.3.2 (changes since version 0.3.1)
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Release date: March 15, 2017
|
||||
|
||||
**Changes**
|
||||
|
||||
- NLSR constructor now accept a KeyChain argument. (:issue:`3742`)
|
||||
|
||||
- Fix security rule for /localhop LSA prefix (:issue:`3899`)
|
||||
|
||||
- Use ndn::nfd::ROUTE_ORIGIN_NLSR instead of a magic number. (:issue:`3903`)
|
||||
|
||||
- Handle "Face Already Exists" error (error code 409) in NFD. (:issue:`3976`)
|
||||
|
||||
- Enable NLSR to register localhost prefix with dispatcher before top-level prefix. (:issue:`3938`)
|
||||
|
||||
- Don't use ndn aliases provided by ndn-cxx/common.hpp. (:issue:`3983`)
|
||||
|
||||
- Remove use of deprecated code. (:issue:`3988`)
|
||||
|
||||
NLSR version 0.3.1 (changes since version 0.3.0)
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Release date: January 22, 2017
|
||||
|
||||
**Changes**
|
||||
|
||||
- **breaking change** Sync uses /localhop component in prefix to reduce duplicate NACKs (:issue:`3627`)
|
||||
|
||||
- **breaking change** LSA uses /localhop component in prefix to reduce duplicate NACKs (:issue:`3899`)
|
||||
|
||||
**Code Changes**:
|
||||
|
||||
- Fib and FaceMap use std::map instead of std::list (:issue:`2781`)
|
||||
|
||||
- NamePrefixTableEntries store RoutingTableEntries using a pointer (:issue:`2863`)
|
||||
|
||||
- Namespace closing comments are now consistent with ndn-cxx guidelines (:issue:`3735`)
|
||||
|
||||
- Update copyright date across all files (:issue:`3736`, `3909`, `3923`)
|
||||
|
||||
- Improve formatting of FaceMap and FaceMapEntry (:issue:`3737`)
|
||||
|
||||
- Sort NextHops on NexthopList insertion (:issue:`2721`)
|
||||
|
||||
**Bug fixes**:
|
||||
|
||||
- HR now recalculates paths after status change of a neighbor (:issue:`3874`)
|
||||
|
||||
- NLSR no longer sets strategies multiple times (:issue:`3743`)
|
||||
|
||||
- NLSR should enable use of ndn-cxx dispatcher (:issue:`3930`)
|
||||
|
||||
- Fix typos in the sample configuration file (:issue:`3113`)
|
||||
|
||||
NLSR version 0.3.0 (changes since version 0.2.2)
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Release date: August 1, 2016
|
||||
|
||||
**Code changes**:
|
||||
|
||||
- Updated validation checker for LSA rule in the configuration file (:issue:`2965`)
|
||||
|
||||
- Do not advertise Adjacency LSAs when hyperbolic routing is enabled (:issue:`2402`)
|
||||
|
||||
- Do not distribute coordinate LSAs when using link-state routing. (:issue:`3661`)
|
||||
|
||||
- LSAs should be segmented before they are published (:issue:`2965`)
|
||||
|
||||
- Don't use DummyClientFace::sentDatas (:issue:`3383`)
|
||||
|
||||
- Remove disabled security files (:issue:`2960`)
|
||||
|
||||
- Lsa type should be argument for base class LSA constructor (:issue:`2788`)
|
||||
|
||||
- Use ndn-cxx/DummyClientFace (:issue:`2637`)
|
||||
|
||||
**Bug fixes**:
|
||||
|
||||
- Unit tests cases are installed with `./waf install` (:issue:`3359`)
|
||||
|
||||
|
||||
NLSR version 0.2.2 (changes since version 0.2.1)
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Release date: January 5, 2016
|
||||
|
||||
**Code changes**:
|
||||
|
||||
- Adapt code to changes in NFD/ndn-cxx version 0.4.0 release
|
||||
|
||||
NLSR version 0.2.1 (changes since version 0.2.0)
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ configuration commands follows:
|
||||
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
|
||||
@@ -104,6 +105,17 @@ configuration commands follows:
|
||||
|
||||
hello-interval 60 ; interest sending interval in seconds. Default value 60
|
||||
; valid values 30-90
|
||||
|
||||
; adj-lsa-build-interval is the time to wait in seconds after an Adjacency LSA build is scheduled
|
||||
; before actually building the Adjacency LSA
|
||||
|
||||
adj-lsa-build-interval 5 ; default value 5. Valid values 0-5. It is recommended that
|
||||
; adj-lsa-build-interval have a lower value than routing-calc-interval
|
||||
|
||||
; first-hello-interval is the time to wait in seconds before sending the first Hello Interest
|
||||
|
||||
first-hello-interval 10 ; Default value 10. Valid values 0-10
|
||||
|
||||
; neighbor command is used to configure router's neighbor. Each neighbor will need
|
||||
; one block of neighbor command
|
||||
|
||||
|
||||
+16
-17
@@ -408,7 +408,7 @@ EXTRACT_PRIVATE = NO
|
||||
# scope will be included in the documentation.
|
||||
# The default value is: NO.
|
||||
|
||||
EXTRACT_PACKAGE = NO
|
||||
EXTRACT_PACKAGE = YES
|
||||
|
||||
# If the EXTRACT_STATIC tag is set to YES all static members of a file will be
|
||||
# included in the documentation.
|
||||
@@ -1782,18 +1782,6 @@ GENERATE_XML = NO
|
||||
|
||||
XML_OUTPUT = xml
|
||||
|
||||
# The XML_SCHEMA tag can be used to specify a XML schema, which can be used by a
|
||||
# validating XML parser to check the syntax of the XML files.
|
||||
# This tag requires that the tag GENERATE_XML is set to YES.
|
||||
|
||||
XML_SCHEMA =
|
||||
|
||||
# The XML_DTD tag can be used to specify a XML DTD, which can be used by a
|
||||
# validating XML parser to check the syntax of the XML files.
|
||||
# This tag requires that the tag GENERATE_XML is set to YES.
|
||||
|
||||
XML_DTD =
|
||||
|
||||
# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program
|
||||
# listings (including syntax highlighting and cross-referencing information) to
|
||||
# the XML output. Note that enabling this will significantly increase the size
|
||||
@@ -1928,7 +1916,18 @@ INCLUDE_FILE_PATTERNS =
|
||||
# recursively expanded use the := operator instead of the = operator.
|
||||
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
|
||||
|
||||
PREDEFINED =
|
||||
PREDEFINED = DOXYGEN=1 \
|
||||
INIT_LOGGER(x)= \
|
||||
BOOST_STATIC_ASSERT(x)= \
|
||||
BOOST_CONCEPT_ASSERT(x)= \
|
||||
BOOST_CONCEPT_REQUIRES(x)= \
|
||||
DECL_OVERRIDE=override \
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE=private \
|
||||
PUBLIC_WITH_TESTS_ELSE_PROTECTED=protected \
|
||||
PROTECTED_WITH_TESTS_ELSE_PRIVATE=private \
|
||||
VIRTUAL_WITH_TESTS \
|
||||
DECL_CLASS_FINAL=final \
|
||||
DECL_FINAL=final
|
||||
|
||||
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
|
||||
# tag can be used to specify a list of macro names that should be expanded. The
|
||||
@@ -2026,7 +2025,7 @@ MSCGEN_PATH =
|
||||
# and usage relations if the target is undocumented or is not a class.
|
||||
# The default value is: YES.
|
||||
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HIDE_UNDOC_RELATIONS = NO
|
||||
|
||||
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
|
||||
# available from the path. This tool is part of Graphviz (see:
|
||||
@@ -2151,7 +2150,7 @@ INCLUDED_BY_GRAPH = YES
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag HAVE_DOT is set to YES.
|
||||
|
||||
CALL_GRAPH = NO
|
||||
CALL_GRAPH = YES
|
||||
|
||||
# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
|
||||
# dependency graph for every global function or class method.
|
||||
@@ -2162,7 +2161,7 @@ CALL_GRAPH = NO
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag HAVE_DOT is set to YES.
|
||||
|
||||
CALLER_GRAPH = NO
|
||||
CALLER_GRAPH = YES
|
||||
|
||||
# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical
|
||||
# hierarchy of all classes instead of a textual one.
|
||||
|
||||
@@ -140,7 +140,7 @@ security
|
||||
{
|
||||
rule
|
||||
{
|
||||
id "NSLR Hello Rule"
|
||||
id "NLSR Hello Rule"
|
||||
for data
|
||||
filter
|
||||
{
|
||||
@@ -168,7 +168,7 @@ security
|
||||
|
||||
rule
|
||||
{
|
||||
id "NSLR LSA Rule"
|
||||
id "NLSR LSA Rule"
|
||||
for data
|
||||
filter
|
||||
{
|
||||
@@ -187,7 +187,8 @@ security
|
||||
k-regex ^([^<KEY><NLSR>]*)<NLSR><KEY><ksk-.*><ID-CERT>$
|
||||
k-expand \\1
|
||||
h-relation equal
|
||||
p-regex ^([^<NLSR><LSA>]*)<NLSR><LSA>(<>*)<><><>$
|
||||
; the last four components in the prefix should be <lsaType><seqNo><version><segmentNo>
|
||||
p-regex ^<localhop>([^<NLSR><LSA>]*)<NLSR><LSA>(<>*)<><><><>$
|
||||
p-expand \\1\\2
|
||||
}
|
||||
}
|
||||
@@ -196,7 +197,7 @@ security
|
||||
|
||||
rule
|
||||
{
|
||||
id "NSLR Hierarchy Exception Rule"
|
||||
id "NLSR Hierarchy Exception Rule"
|
||||
for data
|
||||
filter
|
||||
{
|
||||
@@ -224,7 +225,7 @@ security
|
||||
|
||||
rule
|
||||
{
|
||||
id "NSLR Hierarchical Rule"
|
||||
id "NLSR Hierarchical Rule"
|
||||
for data
|
||||
filter
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* See COPYING.md for copyright and distribution information.
|
||||
*/
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, 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.
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <log4cxx/logger.h>
|
||||
|
||||
#define INIT_LOGGER(name) \
|
||||
static log4cxx::LoggerPtr staticModuleLogger = log4cxx::Logger::getLogger (name);
|
||||
static log4cxx::LoggerPtr staticModuleLogger = log4cxx::Logger::getLogger (name)
|
||||
|
||||
#define _LOG_DEBUG(x) \
|
||||
LOG4CXX_DEBUG(staticModuleLogger, x);
|
||||
|
||||
+4
-1
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
@@ -217,7 +218,7 @@ SyncLogic::onSyncRegisterFailed(const Name& prefix, const string& msg)
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogic::onSyncData(const ndn::Interest& interest, Data& data)
|
||||
SyncLogic::onSyncData(const ndn::Interest& interest, const Data& data)
|
||||
{
|
||||
OnDataValidated onValidated = bind(&SyncLogic::onSyncDataValidated, this, _1);
|
||||
OnDataValidationFailed onValidationFailed = bind(&SyncLogic::onSyncDataValidationFailed, this, _1);
|
||||
@@ -623,6 +624,7 @@ SyncLogic::sendSyncInterest ()
|
||||
|
||||
m_face->expressInterest(interest,
|
||||
bind(&SyncLogic::onSyncData, this, _1, _2),
|
||||
bind(&SyncLogic::onSyncTimeout, this, _1), // Nack
|
||||
bind(&SyncLogic::onSyncTimeout, this, _1));
|
||||
}
|
||||
|
||||
@@ -651,6 +653,7 @@ SyncLogic::sendSyncRecoveryInterests (DigestConstPtr digest)
|
||||
|
||||
m_face->expressInterest(interest,
|
||||
bind(&SyncLogic::onSyncData, this, _1, _2),
|
||||
bind(&SyncLogic::onSyncTimeout, this, _1), // Nack
|
||||
bind(&SyncLogic::onSyncTimeout, this, _1));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@ private:
|
||||
onSyncRegisterFailed(const ndn::Name& prefix, const std::string& msg);
|
||||
|
||||
void
|
||||
onSyncData(const ndn::Interest& interest, ndn::Data& data);
|
||||
onSyncData(const ndn::Interest& interest, const ndn::Data& data);
|
||||
|
||||
void
|
||||
onSyncTimeout(const ndn::Interest& interest);
|
||||
|
||||
+11
-1
@@ -20,7 +20,9 @@
|
||||
|
||||
#include "sync-socket.h"
|
||||
#include "sync-logging.h"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -110,13 +112,15 @@ SyncSocket::fetchData(const Name &prefix, const SeqNo &seq,
|
||||
m_face->expressInterest(interest,
|
||||
bind(&SyncSocket::onData, this, _1, _2,
|
||||
onValidated, onValidationFailed),
|
||||
bind(&SyncSocket::onDataTimeout, this, _1, retry, // Nack
|
||||
onValidated, onValidationFailed),
|
||||
bind(&SyncSocket::onDataTimeout, this, _1, retry,
|
||||
onValidated, onValidationFailed));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
SyncSocket::onData(const ndn::Interest& interest, Data& data,
|
||||
SyncSocket::onData(const ndn::Interest& interest, const Data& data,
|
||||
const OnDataValidated& onValidated,
|
||||
const OnDataValidationFailed& onValidationFailed)
|
||||
{
|
||||
@@ -138,6 +142,12 @@ SyncSocket::onDataTimeout(const ndn::Interest& interest,
|
||||
_2,
|
||||
onValidated,
|
||||
onValidationFailed),
|
||||
bind(&SyncSocket::onDataTimeout,
|
||||
this,
|
||||
_1,
|
||||
retry - 1,
|
||||
onValidated,
|
||||
onValidationFailed),
|
||||
bind(&SyncSocket::onDataTimeout,
|
||||
this,
|
||||
_1,
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ private:
|
||||
}
|
||||
|
||||
void
|
||||
onData(const ndn::Interest& interest, ndn::Data& data,
|
||||
onData(const ndn::Interest& interest, const ndn::Data& data,
|
||||
const ndn::OnDataValidated& onValidated,
|
||||
const ndn::OnDataValidationFailed& onValidationFailed);
|
||||
|
||||
|
||||
+26
-27
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, 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.
|
||||
@@ -16,19 +17,16 @@
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
#include <algorithm>
|
||||
#include <ndn-cxx/common.hpp>
|
||||
|
||||
#include "adjacency-list.hpp"
|
||||
|
||||
#include "adjacent.hpp"
|
||||
#include "common.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER("AdjacencyList");
|
||||
@@ -197,25 +195,26 @@ AdjacencyList::getAdjList()
|
||||
}
|
||||
|
||||
bool
|
||||
AdjacencyList::isAdjLsaBuildable(Nlsr& pnlsr)
|
||||
AdjacencyList::isAdjLsaBuildable(const uint32_t interestRetryNo) const
|
||||
{
|
||||
uint32_t nbrCount = 0;
|
||||
for (std::list<Adjacent>::iterator it = m_adjList.begin(); it != m_adjList.end() ; it++) {
|
||||
uint32_t nTimedOutNeighbors = 0;
|
||||
|
||||
if (it->getStatus() == Adjacent::STATUS_ACTIVE) {
|
||||
nbrCount++;
|
||||
for (const Adjacent& adjacency : m_adjList) {
|
||||
|
||||
if (adjacency.getStatus() == Adjacent::STATUS_ACTIVE) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if ((*it).getInterestTimedOutNo() >=
|
||||
pnlsr.getConfParameter().getInterestRetryNumber()) {
|
||||
nbrCount++;
|
||||
}
|
||||
else if (adjacency.getInterestTimedOutNo() >= interestRetryNo) {
|
||||
nTimedOutNeighbors++;
|
||||
}
|
||||
}
|
||||
if (nbrCount == m_adjList.size()) {
|
||||
|
||||
if (nTimedOutNeighbors == m_adjList.size()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t
|
||||
@@ -236,8 +235,8 @@ AdjacencyList::find(const ndn::Name& adjName)
|
||||
{
|
||||
std::list<Adjacent>::iterator it = std::find_if(m_adjList.begin(),
|
||||
m_adjList.end(),
|
||||
ndn::bind(&Adjacent::compare,
|
||||
_1, ndn::cref(adjName)));
|
||||
std::bind(&Adjacent::compare,
|
||||
_1, std::cref(adjName)));
|
||||
return it;
|
||||
}
|
||||
|
||||
@@ -246,8 +245,8 @@ AdjacencyList::findAdjacent(const ndn::Name& adjName)
|
||||
{
|
||||
std::list<Adjacent>::iterator it = std::find_if(m_adjList.begin(),
|
||||
m_adjList.end(),
|
||||
ndn::bind(&Adjacent::compare,
|
||||
_1, ndn::cref(adjName)));
|
||||
std::bind(&Adjacent::compare,
|
||||
_1, std::cref(adjName)));
|
||||
if (it != m_adjList.end()) {
|
||||
return &(*it);
|
||||
}
|
||||
@@ -260,7 +259,7 @@ AdjacencyList::findAdjacent(uint64_t faceId)
|
||||
{
|
||||
std::list<Adjacent>::iterator it = std::find_if(m_adjList.begin(),
|
||||
m_adjList.end(),
|
||||
ndn::bind(&Adjacent::compareFaceId,
|
||||
std::bind(&Adjacent::compareFaceId,
|
||||
_1, faceId));
|
||||
if (it != m_adjList.end()) {
|
||||
return &(*it);
|
||||
@@ -274,7 +273,7 @@ AdjacencyList::getFaceId(const std::string& faceUri)
|
||||
{
|
||||
std::list<Adjacent>::iterator it = std::find_if(m_adjList.begin(),
|
||||
m_adjList.end(),
|
||||
ndn::bind(&Adjacent::compareFaceUri,
|
||||
std::bind(&Adjacent::compareFaceUri,
|
||||
_1, faceUri));
|
||||
if (it != m_adjList.end()) {
|
||||
return it->getFaceId();
|
||||
@@ -293,4 +292,4 @@ AdjacencyList::writeLog()
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
+45
-5
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "adjacent.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
class Nlsr;
|
||||
|
||||
class AdjacencyList
|
||||
{
|
||||
@@ -40,9 +39,28 @@ public:
|
||||
AdjacencyList();
|
||||
~AdjacencyList();
|
||||
|
||||
/*! \brief Inserts an adjacency into the list.
|
||||
|
||||
\param adjacent The adjacency that we want to add to this list.
|
||||
|
||||
\retval 0 Indicates success.
|
||||
\retval 1 Indicates failure.
|
||||
|
||||
This function attempts to insert the supplied adjacency into this
|
||||
object, which is an adjacency list.
|
||||
*/
|
||||
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);
|
||||
|
||||
@@ -70,11 +88,33 @@ public:
|
||||
void
|
||||
setTimedOutInterestCount(const ndn::Name& neighbor, uint32_t count);
|
||||
|
||||
/*! \brief Copies the adjacencies in a list to this one.
|
||||
|
||||
\param adl The adjacency list, the entries of which we want to
|
||||
copy into this object.
|
||||
|
||||
Copies the entries contained in one list into this object.
|
||||
*/
|
||||
void
|
||||
addAdjacents(AdjacencyList& adl);
|
||||
|
||||
/*! \brief Determines whether this list can be used to build an adj. LSA.
|
||||
\param interestRetryNo The maximum number of hello-interest
|
||||
retries to contact a neighbor.
|
||||
|
||||
\return Returns a boolean indicating whether this list can be used
|
||||
to build an adj. LSA.
|
||||
|
||||
Determines whether this adjacency list object could be used to
|
||||
build an adjacency LSA. An LSA is buildable when the status of all
|
||||
neighbors is known. A neighbor's status is known when their status
|
||||
is ACTIVE, or INACTIVE and some number of hello interests
|
||||
(specified by nlsr::ConfParameter::getInterestRetryNumber()) have
|
||||
failed. To be explicit, a neighbor's status is unknown if we are
|
||||
still sending hello interests.
|
||||
*/
|
||||
bool
|
||||
isAdjLsaBuildable(Nlsr& pnlsr);
|
||||
isAdjLsaBuildable(const uint32_t interestRetryNo) const;
|
||||
|
||||
int32_t
|
||||
getNumOfActiveNeighbor();
|
||||
@@ -132,5 +172,5 @@ private:
|
||||
std::list<Adjacent> m_adjList;
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
#endif //NLSR_ADJACENCY_LIST_HPP
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
@@ -88,4 +88,4 @@ Adjacent::writeLog()
|
||||
_LOG_DEBUG("Interest Timed out: " << m_interestTimedOutNo);
|
||||
}
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -69,10 +69,10 @@ public:
|
||||
int32_t lsaPosition = util::getNameComponentPosition(m_name, LSA_COMPONENT);
|
||||
|
||||
if (nlsrPosition < 0 || lsaPosition < 0) {
|
||||
throw Error("Cannot parse update name because expected components are missing");
|
||||
BOOST_THROW_EXCEPTION(Error("Cannot parse update name because expected components are missing"));
|
||||
}
|
||||
|
||||
ndn::Name networkName = m_name.getSubName(0, nlsrPosition);
|
||||
ndn::Name networkName = m_name.getSubName(1, nlsrPosition-1);
|
||||
ndn::Name routerName = m_name.getSubName(lsaPosition + 1);
|
||||
|
||||
ndn::Name originRouter = networkName;
|
||||
@@ -154,12 +154,12 @@ SyncLogicHandler::createSyncSocket(const ndn::Name& syncPrefix)
|
||||
|
||||
// The face's lifetime is managed in main.cpp; SyncSocket should not manage the memory
|
||||
// of the object
|
||||
ndn::shared_ptr<ndn::Face> facePtr(&m_syncFace, NullDeleter<ndn::Face>());
|
||||
std::shared_ptr<ndn::Face> facePtr(&m_syncFace, NullDeleter<ndn::Face>());
|
||||
|
||||
m_syncSocket = ndn::make_shared<Sync::SyncSocket>(m_syncPrefix, m_validator, facePtr,
|
||||
ndn::bind(&SyncLogicHandler::onNsyncUpdate,
|
||||
m_syncSocket = std::make_shared<Sync::SyncSocket>(m_syncPrefix, m_validator, facePtr,
|
||||
std::bind(&SyncLogicHandler::onNsyncUpdate,
|
||||
this, _1, _2),
|
||||
ndn::bind(&SyncLogicHandler::onNsyncRemoval,
|
||||
std::bind(&SyncLogicHandler::onNsyncRemoval,
|
||||
this, _1));
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ SyncLogicHandler::processUpdateFromSync(const SyncUpdate& update)
|
||||
try {
|
||||
originRouter = update.getOriginRouter();
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
catch (const std::exception& e) {
|
||||
_LOG_WARN("Received malformed sync update");
|
||||
return;
|
||||
}
|
||||
@@ -201,8 +201,7 @@ SyncLogicHandler::processUpdateFromSync(const SyncUpdate& update)
|
||||
|
||||
update.getSequencingManager().writeLog();
|
||||
|
||||
try {
|
||||
if (isLsaNew(originRouter, NameLsa::TYPE_STRING, update.getNameLsaSeqNo())) {
|
||||
if (isLsaNew(originRouter, NameLsa::TYPE_STRING, update.getNameLsaSeqNo())) {
|
||||
_LOG_DEBUG("Received sync update with higher Name LSA sequence number than entry in LSDB");
|
||||
|
||||
expressInterestForLsa(update, NameLsa::TYPE_STRING, update.getNameLsaSeqNo());
|
||||
@@ -210,20 +209,29 @@ SyncLogicHandler::processUpdateFromSync(const SyncUpdate& update)
|
||||
|
||||
if (isLsaNew(originRouter, AdjLsa::TYPE_STRING, update.getAdjLsaSeqNo())) {
|
||||
_LOG_DEBUG("Received sync update with higher Adj LSA sequence number than entry in LSDB");
|
||||
|
||||
expressInterestForLsa(update, AdjLsa::TYPE_STRING, update.getAdjLsaSeqNo());
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
if (update.getAdjLsaSeqNo() != 0) {
|
||||
_LOG_ERROR("Tried to fetch an adjacency LSA when hyperbolic routing"
|
||||
<< " is enabled.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
expressInterestForLsa(update, AdjLsa::TYPE_STRING, update.getAdjLsaSeqNo());
|
||||
}
|
||||
}
|
||||
|
||||
if (isLsaNew(originRouter, CoordinateLsa::TYPE_STRING, update.getCorLsaSeqNo())) {
|
||||
_LOG_DEBUG("Received sync update with higher Cor LSA sequence number than entry in LSDB");
|
||||
|
||||
expressInterestForLsa(update, CoordinateLsa::TYPE_STRING, update.getCorLsaSeqNo());
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
|
||||
if (update.getCorLsaSeqNo() != 0) {
|
||||
_LOG_ERROR("Tried to fetch a coordinate LSA when link-state"
|
||||
<< " is enabled.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
expressInterestForLsa(update, CoordinateLsa::TYPE_STRING, update.getCorLsaSeqNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,7 +275,7 @@ SyncLogicHandler::publishRoutingUpdate()
|
||||
if (m_syncSocket == nullptr) {
|
||||
_LOG_FATAL("Cannot publish routing update; SyncSocket does not exist");
|
||||
|
||||
throw SyncLogicHandler::Error("Cannot publish routing update; SyncSocket does not exist");
|
||||
BOOST_THROW_EXCEPTION(SyncLogicHandler::Error("Cannot publish routing update; SyncSocket does not exist"));
|
||||
}
|
||||
|
||||
m_sequencingManager.writeSeqNoToFile();
|
||||
@@ -294,4 +302,4 @@ SyncLogicHandler::publishSyncUpdate(const ndn::Name& updatePrefix, uint64_t seqN
|
||||
m_syncSocket->publishData(updateName.toUri(), 0, data.c_str(), data.size(), 1000, seqNo);
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
@@ -56,6 +57,11 @@ public:
|
||||
|
||||
SyncLogicHandler(ndn::Face& face, Lsdb& lsdb, ConfParameter& conf, SequencingManager& seqManager);
|
||||
|
||||
/*! \brief Simple wrapper function to handle updates from Sync.
|
||||
|
||||
\param v The information that Sync has acquired.
|
||||
\param socket The socket that Sync is using to synchronize updates.
|
||||
*/
|
||||
void
|
||||
onNsyncUpdate(const std::vector<Sync::MissingDataInfo>& v, Sync::SyncSocket* socket);
|
||||
|
||||
@@ -85,9 +91,9 @@ private:
|
||||
publishSyncUpdate(const ndn::Name& updatePrefix, uint64_t seqNo);
|
||||
|
||||
private:
|
||||
ndn::shared_ptr<ndn::ValidatorNull> m_validator;
|
||||
std::shared_ptr<ndn::ValidatorNull> m_validator;
|
||||
ndn::Face& m_syncFace;
|
||||
ndn::shared_ptr<Sync::SyncSocket> m_syncSocket;
|
||||
std::shared_ptr<Sync::SyncSocket> m_syncSocket;
|
||||
ndn::Name m_syncPrefix;
|
||||
|
||||
private:
|
||||
@@ -104,6 +110,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_SYNC_LOGIC_HANDLER_HPP
|
||||
#endif // NLSR_SYNC_LOGIC_HANDLER_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -45,7 +45,7 @@ template <class T>
|
||||
class ConfigurationVariable
|
||||
{
|
||||
public:
|
||||
typedef ndn::function<void(T)> ConfParameterCallback;
|
||||
typedef std::function<void(T)> ConfParameterCallback;
|
||||
typedef boost::property_tree::ptree ConfigSection;
|
||||
|
||||
ConfigurationVariable(const std::string& key, const ConfParameterCallback& setter)
|
||||
@@ -446,7 +446,7 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
// Event intervals
|
||||
// adj-lsa-build-interval
|
||||
ConfigurationVariable<uint32_t> adjLsaBuildInterval("adj-lsa-build-interval",
|
||||
bind(&ConfParameter::setAdjLsaBuildInterval,
|
||||
std::bind(&ConfParameter::setAdjLsaBuildInterval,
|
||||
&m_nlsr.getConfParameter(), _1));
|
||||
adjLsaBuildInterval.setMinAndMaxValue(ADJ_LSA_BUILD_INTERVAL_MIN, ADJ_LSA_BUILD_INTERVAL_MAX);
|
||||
adjLsaBuildInterval.setOptional(ADJ_LSA_BUILD_INTERVAL_DEFAULT);
|
||||
@@ -457,7 +457,7 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
|
||||
// first-hello-interval
|
||||
ConfigurationVariable<uint32_t> firstHelloInterval("first-hello-interval",
|
||||
bind(&ConfParameter::setFirstHelloInterval,
|
||||
std::bind(&ConfParameter::setFirstHelloInterval,
|
||||
&m_nlsr.getConfParameter(), _1));
|
||||
firstHelloInterval.setMinAndMaxValue(FIRST_HELLO_INTERVAL_MIN, FIRST_HELLO_INTERVAL_MAX);
|
||||
firstHelloInterval.setOptional(FIRST_HELLO_INTERVAL_DEFAULT);
|
||||
@@ -569,7 +569,7 @@ ConfFileProcessor::processConfSectionFib(const ConfigSection& section)
|
||||
|
||||
// routing-calc-interval
|
||||
ConfigurationVariable<uint32_t> routingCalcInterval("routing-calc-interval",
|
||||
bind(&ConfParameter::setRoutingCalcInterval,
|
||||
std::bind(&ConfParameter::setRoutingCalcInterval,
|
||||
&m_nlsr.getConfParameter(), _1));
|
||||
routingCalcInterval.setMinAndMaxValue(ROUTING_CALC_INTERVAL_MIN, ROUTING_CALC_INTERVAL_MAX);
|
||||
routingCalcInterval.setOptional(ROUTING_CALC_INTERVAL_DEFAULT);
|
||||
@@ -635,7 +635,7 @@ ConfFileProcessor::processConfSectionSecurity(const ConfigSection& section)
|
||||
|
||||
std::string file = it->second.data();
|
||||
path certfilePath = absolute(file, path(m_confFileName).parent_path());
|
||||
shared_ptr<ndn::IdentityCertificate> idCert =
|
||||
std::shared_ptr<ndn::IdentityCertificate> idCert =
|
||||
ndn::io::load<ndn::IdentityCertificate>(certfilePath.string());
|
||||
|
||||
if (idCert == nullptr) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
@@ -76,5 +76,5 @@ private:
|
||||
Nlsr& m_nlsr;
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
#endif //CONF_PROCESSOR_HPP
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -86,7 +86,7 @@ enum {
|
||||
MAX_FACES_PER_PREFIX_MAX = 60
|
||||
};
|
||||
|
||||
enum {
|
||||
enum HyperbolicState {
|
||||
HYPERBOLIC_STATE_OFF = 0,
|
||||
HYPERBOLIC_STATE_ON = 1,
|
||||
HYPERBOLIC_STATE_DRY_RUN = 2,
|
||||
@@ -120,11 +120,13 @@ public:
|
||||
setNetwork(const ndn::Name& networkName)
|
||||
{
|
||||
m_network = networkName;
|
||||
m_chronosyncPrefix = m_network;
|
||||
|
||||
m_chronosyncPrefix.append("localhop");
|
||||
m_chronosyncPrefix.append("NLSR");
|
||||
m_chronosyncPrefix.append("sync");
|
||||
|
||||
m_lsaPrefix = m_network;
|
||||
m_lsaPrefix.append("localhop");
|
||||
m_lsaPrefix.append(m_network);
|
||||
m_lsaPrefix.append("NLSR");
|
||||
m_lsaPrefix.append("LSA");
|
||||
}
|
||||
|
||||
+57
-25
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
@@ -20,6 +20,7 @@
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#include "nlsr.hpp"
|
||||
#include "lsdb.hpp"
|
||||
#include "hello-protocol.hpp"
|
||||
@@ -41,10 +42,12 @@ HelloProtocol::expressInterest(const ndn::Name& interestName, uint32_t seconds)
|
||||
i.setInterestLifetime(ndn::time::seconds(seconds));
|
||||
i.setMustBeFresh(true);
|
||||
m_nlsr.getNlsrFace().expressInterest(i,
|
||||
ndn::bind(&HelloProtocol::onContent,
|
||||
std::bind(&HelloProtocol::onContent,
|
||||
this,
|
||||
_1, _2),
|
||||
ndn::bind(&HelloProtocol::processInterestTimedOut,
|
||||
std::bind(&HelloProtocol::processInterestTimedOut, // Nack
|
||||
this, _1),
|
||||
std::bind(&HelloProtocol::processInterestTimedOut,
|
||||
this, _1));
|
||||
}
|
||||
|
||||
@@ -54,8 +57,9 @@ HelloProtocol::sendScheduledInterest(uint32_t seconds)
|
||||
std::list<Adjacent> adjList = m_nlsr.getAdjacencyList().getAdjList();
|
||||
for (std::list<Adjacent>::iterator it = adjList.begin(); it != adjList.end();
|
||||
++it) {
|
||||
// If this adjacency has a Face, just proceed as usual.
|
||||
if((*it).getFaceId() != 0) {
|
||||
/* interest name: /<neighbor>/NLSR/INFO/<router> */
|
||||
// interest name: /<neighbor>/NLSR/INFO/<router>
|
||||
ndn::Name interestName = (*it).getName() ;
|
||||
interestName.append(NLSR_COMPONENT);
|
||||
interestName.append(INFO_COMPONENT);
|
||||
@@ -63,6 +67,9 @@ HelloProtocol::sendScheduledInterest(uint32_t seconds)
|
||||
expressInterest(interestName,
|
||||
m_nlsr.getConfParameter().getInterestResendTime());
|
||||
}
|
||||
// If it does not have a Face, we need to give it one. A
|
||||
// successful registration prompts a callback that sends the hello
|
||||
// Interest to the new Face.
|
||||
else {
|
||||
registerPrefixes((*it).getName(), (*it).getConnectingFaceUri(),
|
||||
(*it).getLinkCost(), ndn::time::milliseconds::max());
|
||||
@@ -77,14 +84,14 @@ HelloProtocol::scheduleInterest(uint32_t seconds)
|
||||
_LOG_DEBUG("Scheduling HELLO Interests in " << ndn::time::seconds(seconds));
|
||||
|
||||
m_scheduler.scheduleEvent(ndn::time::seconds(seconds),
|
||||
ndn::bind(&HelloProtocol::sendScheduledInterest, this, seconds));
|
||||
std::bind(&HelloProtocol::sendScheduledInterest, this, seconds));
|
||||
}
|
||||
|
||||
void
|
||||
HelloProtocol::processInterest(const ndn::Name& name,
|
||||
const ndn::Interest& interest)
|
||||
{
|
||||
/* interest name: /<neighbor>/NLSR/INFO/<router> */
|
||||
// interest name: /<neighbor>/NLSR/INFO/<router>
|
||||
const ndn::Name interestName = interest.getName();
|
||||
_LOG_DEBUG("Interest Received for Name: " << interestName);
|
||||
if (interestName.get(-2).toUri() != INFO_COMPONENT) {
|
||||
@@ -94,7 +101,7 @@ HelloProtocol::processInterest(const ndn::Name& name,
|
||||
neighbor.wireDecode(interestName.get(-1).blockFromValue());
|
||||
_LOG_DEBUG("Neighbor: " << neighbor);
|
||||
if (m_nlsr.getAdjacencyList().isNeighbor(neighbor)) {
|
||||
ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>();
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>();
|
||||
data->setName(ndn::Name(interest.getName()).appendVersion());
|
||||
data->setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec
|
||||
data->setContent(reinterpret_cast<const uint8_t*>(INFO_COMPONENT.c_str()),
|
||||
@@ -103,9 +110,11 @@ HelloProtocol::processInterest(const ndn::Name& name,
|
||||
_LOG_DEBUG("Sending out data for name: " << interest.getName());
|
||||
m_nlsr.getNlsrFace().put(*data);
|
||||
Adjacent *adjacent = m_nlsr.getAdjacencyList().findAdjacent(neighbor);
|
||||
// If this neighbor was previously inactive, send our own hello interest, too
|
||||
if (adjacent->getStatus() == Adjacent::STATUS_INACTIVE) {
|
||||
// We can only do that if the neighbor currently has a face.
|
||||
if(adjacent->getFaceId() != 0){
|
||||
/* interest name: /<neighbor>/NLSR/INFO/<router> */
|
||||
// interest name: /<neighbor>/NLSR/INFO/<router>
|
||||
ndn::Name interestName(neighbor);
|
||||
interestName.append(NLSR_COMPONENT);
|
||||
interestName.append(INFO_COMPONENT);
|
||||
@@ -113,6 +122,8 @@ HelloProtocol::processInterest(const ndn::Name& name,
|
||||
expressInterest(interestName,
|
||||
m_nlsr.getConfParameter().getInterestResendTime());
|
||||
}
|
||||
// If the originator of the Interest currently lacks a Face, we
|
||||
// need to give it one.
|
||||
else {
|
||||
registerPrefixes(adjacent->getName(), adjacent->getConnectingFaceUri(),
|
||||
adjacent->getLinkCost(), ndn::time::milliseconds::max());
|
||||
@@ -124,7 +135,7 @@ HelloProtocol::processInterest(const ndn::Name& name,
|
||||
void
|
||||
HelloProtocol::processInterestTimedOut(const ndn::Interest& interest)
|
||||
{
|
||||
/* interest name: /<neighbor>/NLSR/INFO/<router> */
|
||||
// interest name: /<neighbor>/NLSR/INFO/<router>
|
||||
const ndn::Name interestName(interest.getName());
|
||||
_LOG_DEBUG("Interest timed out for Name: " << interestName);
|
||||
if (interestName.get(-2).toUri() != INFO_COMPONENT) {
|
||||
@@ -141,7 +152,7 @@ HelloProtocol::processInterestTimedOut(const ndn::Interest& interest)
|
||||
_LOG_DEBUG("Status: " << status);
|
||||
_LOG_DEBUG("Info Interest Timed out: " << infoIntTimedOutCount);
|
||||
if ((infoIntTimedOutCount < m_nlsr.getConfParameter().getInterestRetryNumber())) {
|
||||
/* interest name: /<neighbor>/NLSR/INFO/<router> */
|
||||
// interest name: /<neighbor>/NLSR/INFO/<router>
|
||||
ndn::Name interestName(neighbor);
|
||||
interestName.append(NLSR_COMPONENT);
|
||||
interestName.append(INFO_COMPONENT);
|
||||
@@ -157,6 +168,9 @@ HelloProtocol::processInterestTimedOut(const ndn::Interest& interest)
|
||||
}
|
||||
}
|
||||
|
||||
// This is the first function that incoming Hello data will
|
||||
// see. This checks if the data appears to be signed, and passes it
|
||||
// on to validate the content of the data.
|
||||
void
|
||||
HelloProtocol::onContent(const ndn::Interest& interest, const ndn::Data& data)
|
||||
{
|
||||
@@ -167,15 +181,20 @@ HelloProtocol::onContent(const ndn::Interest& interest, const ndn::Data& data)
|
||||
}
|
||||
}
|
||||
m_nlsr.getValidator().validate(data,
|
||||
ndn::bind(&HelloProtocol::onContentValidated, this, _1),
|
||||
ndn::bind(&HelloProtocol::onContentValidationFailed,
|
||||
std::bind(&HelloProtocol::onContentValidated, this, _1),
|
||||
std::bind(&HelloProtocol::onContentValidationFailed,
|
||||
this, _1, _2));
|
||||
}
|
||||
|
||||
// A validator is called on the incoming data, and if the data
|
||||
// passes the validator's description/definitions, this function is
|
||||
// called. Set the neighbor's status to active and refresh its
|
||||
// LSA. If there was a change in status, we schedule an adjacency
|
||||
// LSA build.
|
||||
void
|
||||
HelloProtocol::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
|
||||
HelloProtocol::onContentValidated(const std::shared_ptr<const ndn::Data>& data)
|
||||
{
|
||||
/* data name: /<neighbor>/NLSR/INFO/<router>/<version> */
|
||||
// data name: /<neighbor>/NLSR/INFO/<router>/<version>
|
||||
ndn::Name dataName = data->getName();
|
||||
_LOG_DEBUG("Data validation successful for INFO(name): " << dataName);
|
||||
if (dataName.get(-3).toUri() == INFO_COMPONENT) {
|
||||
@@ -190,30 +209,43 @@ HelloProtocol::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
|
||||
_LOG_DEBUG("Old Status: " << oldStatus << " New Status: " << newStatus);
|
||||
// change in Adjacency list
|
||||
if ((oldStatus - newStatus) != 0) {
|
||||
m_nlsr.getLsdb().scheduleAdjLsaBuild();
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
}
|
||||
else {
|
||||
m_nlsr.getLsdb().scheduleAdjLsaBuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Simply logs a debug message that the content could not be
|
||||
// validated (and is implicitly being discarded as a result).
|
||||
void
|
||||
HelloProtocol::onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
HelloProtocol::onContentValidationFailed(const std::shared_ptr<const ndn::Data>& data,
|
||||
const std::string& msg)
|
||||
{
|
||||
_LOG_DEBUG("Validation Error: " << msg);
|
||||
}
|
||||
|
||||
|
||||
// Asks the FIB to register the supplied adjacency (in other words,
|
||||
// create a Face for it).
|
||||
void
|
||||
HelloProtocol::registerPrefixes(const ndn::Name& adjName, const std::string& faceUri,
|
||||
double linkCost, const ndn::time::milliseconds& timeout)
|
||||
{
|
||||
m_nlsr.getFib().registerPrefix(adjName, faceUri, linkCost, timeout,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE, 0,
|
||||
ndn::bind(&HelloProtocol::onRegistrationSuccess,
|
||||
std::bind(&HelloProtocol::onRegistrationSuccess,
|
||||
this, _1, adjName,timeout),
|
||||
ndn::bind(&HelloProtocol::onRegistrationFailure,
|
||||
this, _1, _2, adjName));
|
||||
std::bind(&HelloProtocol::onRegistrationFailure,
|
||||
this, _1, adjName));
|
||||
}
|
||||
|
||||
// After we create a new Face, we need to set it up for use. This
|
||||
// function sets the controlling strategy, registers prefixes in
|
||||
// sync, broadcast, and LSA.
|
||||
void
|
||||
HelloProtocol::onRegistrationSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
|
||||
const ndn::Name& neighbor,const ndn::time::milliseconds& timeout)
|
||||
@@ -234,9 +266,9 @@ HelloProtocol::onRegistrationSuccess(const ndn::nfd::ControlParameters& commandS
|
||||
m_nlsr.getFib().registerPrefix(broadcastKeyPrefix,
|
||||
faceUri, linkCost, timeout,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
|
||||
m_nlsr.setStrategies();
|
||||
|
||||
/* interest name: /<neighbor>/NLSR/INFO/<router> */
|
||||
// Sends a Hello Interest to determine status before the next scheduled.
|
||||
// interest name: /<neighbor>/NLSR/INFO/<router>
|
||||
ndn::Name interestName(neighbor);
|
||||
interestName.append(NLSR_COMPONENT);
|
||||
interestName.append(INFO_COMPONENT);
|
||||
@@ -247,10 +279,10 @@ HelloProtocol::onRegistrationSuccess(const ndn::nfd::ControlParameters& commandS
|
||||
}
|
||||
|
||||
void
|
||||
HelloProtocol::onRegistrationFailure(uint32_t code, const std::string& error,
|
||||
HelloProtocol::onRegistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
const ndn::Name& name)
|
||||
{
|
||||
_LOG_DEBUG(error << " (code: " << code << ")");
|
||||
_LOG_DEBUG(response.getText() << " (code: " << response.getCode() << ")");
|
||||
/*
|
||||
* If NLSR can not create face for given faceUri then it will treat this
|
||||
* failure as one INFO interest timed out. So that NLSR can move on with
|
||||
@@ -274,4 +306,4 @@ HelloProtocol::onRegistrationFailure(uint32_t code, const std::string& error,
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
+50
-7
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -22,9 +22,11 @@
|
||||
#ifndef NLSR_HELLO_PROTOCOL_HPP
|
||||
#define NLSR_HELLO_PROTOCOL_HPP
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/management/nfd-control-parameters.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/control-response.hpp>
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
@@ -40,15 +42,54 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
/*! \brief Schedules a hello Interest event.
|
||||
|
||||
\param seconds The number of seconds to wait before calling the event.
|
||||
*/
|
||||
void
|
||||
scheduleInterest(uint32_t seconds);
|
||||
|
||||
/*! \brief Sends a hello Interest packet.
|
||||
|
||||
\param interestNamePrefix The name of the router that has published the
|
||||
update we want. Here that should be: \<router name\>/NLSR/INFO
|
||||
|
||||
\param seconds The lifetime of the Interest we construct, in seconds
|
||||
|
||||
This function attempts to contact neighboring routers to
|
||||
determine their status (which currently is one of: ACTIVE,
|
||||
INACTIVE, or UNKNOWN)
|
||||
*/
|
||||
void
|
||||
expressInterest(const ndn::Name& interestNamePrefix, uint32_t seconds);
|
||||
|
||||
/*! \brief Sends a hello Interest packet that was previously scheduled.
|
||||
|
||||
\param seconds (ignored)
|
||||
|
||||
This function is called as part of a schedule to regularly
|
||||
determine the adjacency status of neighbors. This function checks
|
||||
if the specified neighbor has a Face, and if not creates one. If
|
||||
the neighbor had a Face, it calls \c expressInterest, else it will
|
||||
attempt to create a Face, which will itself attempt to contact the
|
||||
neighbor. Then the function schedules for this function to be invoked again.
|
||||
*/
|
||||
void
|
||||
sendScheduledInterest(uint32_t seconds);
|
||||
|
||||
/*! \brief Processes a hello Interest from a neighbor.
|
||||
|
||||
\param name (ignored)
|
||||
|
||||
\param interest The Interest object that we have received and need to
|
||||
process.
|
||||
|
||||
Processes a hello Interest that this router receives from one of
|
||||
its neighbors. If the neighbor that sent the Interest does not
|
||||
have a Face, NLSR will attempt to register one. Also, if the
|
||||
neighbor that sent the Interest was previously marked as INACTIVE,
|
||||
NLSR will attempt to contact it with its own hello Interest.
|
||||
*/
|
||||
void
|
||||
processInterest(const ndn::Name& name, const ndn::Interest& interest);
|
||||
|
||||
@@ -59,15 +100,17 @@ private:
|
||||
void
|
||||
onContent(const ndn::Interest& interest, const ndn::Data& data);
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
void
|
||||
onContentValidated(const ndn::shared_ptr<const ndn::Data>& data);
|
||||
onContentValidated(const std::shared_ptr<const ndn::Data>& data);
|
||||
|
||||
private:
|
||||
void
|
||||
onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
onContentValidationFailed(const std::shared_ptr<const ndn::Data>& data,
|
||||
const std::string& msg);
|
||||
|
||||
void
|
||||
onRegistrationFailure(uint32_t code, const std::string& error,
|
||||
onRegistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
const ndn::Name& name);
|
||||
|
||||
void
|
||||
@@ -85,6 +128,6 @@ private:
|
||||
static const std::string NLSR_COMPONENT;
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_HELLO_PROTOCOL_HPP
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
|
||||
+26
-13
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -53,12 +53,12 @@ NameLsa::getKey() const
|
||||
return key;
|
||||
}
|
||||
|
||||
NameLsa::NameLsa(const ndn::Name& origR, const string& lst, uint32_t lsn,
|
||||
NameLsa::NameLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
NamePrefixList& npl)
|
||||
: Lsa(NameLsa::TYPE_STRING)
|
||||
{
|
||||
m_origRouter = origR;
|
||||
m_lsType = lst;
|
||||
m_lsSeqNo = lsn;
|
||||
m_expirationTimePoint = lt;
|
||||
std::list<ndn::Name>& nl = npl.getNameList();
|
||||
@@ -97,12 +97,16 @@ NameLsa::initializeFromContent(const std::string& content)
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
m_lsType = *tok_iter++;
|
||||
if (*tok_iter++ != NameLsa::TYPE_STRING) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
m_expirationTimePoint = ndn::time::fromIsoString(*tok_iter++);
|
||||
numName = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_ERROR(e.what());
|
||||
return false;
|
||||
}
|
||||
for (uint32_t i = 0; i < numName; i++) {
|
||||
@@ -130,13 +134,12 @@ NameLsa::writeLog()
|
||||
_LOG_DEBUG("name_lsa_end");
|
||||
}
|
||||
|
||||
CoordinateLsa::CoordinateLsa(const ndn::Name& origR, const string lst,
|
||||
uint32_t lsn,
|
||||
CoordinateLsa::CoordinateLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
double r, double theta)
|
||||
: Lsa(CoordinateLsa::TYPE_STRING)
|
||||
{
|
||||
m_origRouter = origR;
|
||||
m_lsType = lst;
|
||||
m_lsSeqNo = lsn;
|
||||
m_expirationTimePoint = lt;
|
||||
m_corRad = r;
|
||||
@@ -186,13 +189,17 @@ CoordinateLsa::initializeFromContent(const std::string& content)
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
m_lsType = *tok_iter++;
|
||||
if (*tok_iter++ != CoordinateLsa::TYPE_STRING) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
m_expirationTimePoint = ndn::time::fromIsoString(*tok_iter++);
|
||||
m_corRad = boost::lexical_cast<double>(*tok_iter++);
|
||||
m_corTheta = boost::lexical_cast<double>(*tok_iter++);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_ERROR(e.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -210,12 +217,12 @@ CoordinateLsa::writeLog()
|
||||
_LOG_DEBUG(" Hyperbolic Theta: " << m_corTheta);
|
||||
}
|
||||
|
||||
AdjLsa::AdjLsa(const ndn::Name& origR, const string& lst, uint32_t lsn,
|
||||
AdjLsa::AdjLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
uint32_t nl , AdjacencyList& adl)
|
||||
: Lsa(AdjLsa::TYPE_STRING)
|
||||
{
|
||||
m_origRouter = origR;
|
||||
m_lsType = lst;
|
||||
m_lsSeqNo = lsn;
|
||||
m_expirationTimePoint = lt;
|
||||
m_noLink = nl;
|
||||
@@ -241,7 +248,6 @@ AdjLsa::isEqualContent(AdjLsa& alsa)
|
||||
return m_adl == alsa.getAdl();
|
||||
}
|
||||
|
||||
|
||||
string
|
||||
AdjLsa::getData()
|
||||
{
|
||||
@@ -276,12 +282,16 @@ AdjLsa::initializeFromContent(const std::string& content)
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
m_lsType = *tok_iter++;
|
||||
if (*tok_iter++ != AdjLsa::TYPE_STRING) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
m_expirationTimePoint = ndn::time::fromIsoString(*tok_iter++);
|
||||
numLink = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_ERROR(e.what());
|
||||
return false;
|
||||
}
|
||||
for (uint32_t i = 0; i < numLink; i++) {
|
||||
@@ -293,17 +303,20 @@ AdjLsa::initializeFromContent(const std::string& content)
|
||||
addAdjacent(adjacent);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_ERROR(e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AdjLsa::addNptEntries(Nlsr& pnlsr)
|
||||
{
|
||||
// Only add NPT entries if this is an adj LSA from another router.
|
||||
if (getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix()) {
|
||||
// Pass the originating router as both the name to register and
|
||||
// where it came from.
|
||||
pnlsr.getNamePrefixTable().addEntry(getOrigRouter(), getOrigRouter());
|
||||
}
|
||||
}
|
||||
|
||||
+61
-20
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -32,24 +32,20 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class Nlsr;
|
||||
|
||||
class Lsa
|
||||
{
|
||||
public:
|
||||
Lsa()
|
||||
Lsa(const std::string& lsaType)
|
||||
: m_origRouter()
|
||||
, m_lsType(lsaType)
|
||||
, m_lsSeqNo()
|
||||
, m_expirationTimePoint()
|
||||
, m_expiringEventId()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
setLsType(const std::string& lst)
|
||||
{
|
||||
m_lsType = lst;
|
||||
}
|
||||
|
||||
const std::string&
|
||||
getLsType() const
|
||||
{
|
||||
@@ -106,7 +102,7 @@ public:
|
||||
|
||||
protected:
|
||||
ndn::Name m_origRouter;
|
||||
std::string m_lsType;
|
||||
const std::string m_lsType;
|
||||
uint32_t m_lsSeqNo;
|
||||
ndn::time::system_clock::TimePoint m_expirationTimePoint;
|
||||
ndn::EventId m_expiringEventId;
|
||||
@@ -116,13 +112,12 @@ class NameLsa: public Lsa
|
||||
{
|
||||
public:
|
||||
NameLsa()
|
||||
: Lsa()
|
||||
: Lsa(NameLsa::TYPE_STRING)
|
||||
, m_npl()
|
||||
{
|
||||
setLsType(NameLsa::TYPE_STRING);
|
||||
}
|
||||
|
||||
NameLsa(const ndn::Name& origR, const std::string& lst, uint32_t lsn,
|
||||
NameLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
NamePrefixList& npl);
|
||||
|
||||
@@ -144,12 +139,30 @@ public:
|
||||
m_npl.remove(name);
|
||||
}
|
||||
|
||||
/*! \brief Gets the key for this LSA.
|
||||
|
||||
Format is: \<router name\>/\<LSA type>\
|
||||
*/
|
||||
const ndn::Name
|
||||
getKey() const;
|
||||
|
||||
/*! \brief Returns the data that this name LSA has.
|
||||
|
||||
Format is: \<original router
|
||||
prefix\>|name|\<seq. no.\>|\<exp. time\>|\<prefix 1\>|\<prefix
|
||||
2\>|...|\<prefix n\>|
|
||||
*/
|
||||
std::string
|
||||
getData();
|
||||
|
||||
/*! \brief Initializes this LSA object with content's data.
|
||||
|
||||
\param content The data (e.g. name prefixes) to initialize this LSA with.
|
||||
|
||||
This function initializes this object to represent the data
|
||||
contained in content. The format for this is the same as for
|
||||
getData(); getData() returns data of this format, in other words.
|
||||
*/
|
||||
bool
|
||||
initializeFromContent(const std::string& content);
|
||||
|
||||
@@ -168,13 +181,12 @@ public:
|
||||
typedef AdjacencyList::const_iterator const_iterator;
|
||||
|
||||
AdjLsa()
|
||||
: Lsa()
|
||||
: Lsa(AdjLsa::TYPE_STRING)
|
||||
, m_adl()
|
||||
{
|
||||
setLsType(AdjLsa::TYPE_STRING);
|
||||
}
|
||||
|
||||
AdjLsa(const ndn::Name& origR, const std::string& lst, uint32_t lsn,
|
||||
AdjLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
uint32_t nl , AdjacencyList& adl);
|
||||
|
||||
@@ -193,9 +205,21 @@ public:
|
||||
const ndn::Name
|
||||
getKey() const;
|
||||
|
||||
/*! \brief Returns the data this adjacency LSA has.
|
||||
|
||||
The format is: \<original
|
||||
router\>|adjacency|\<seq. no.\>|\<exp. time\>|\<size\>|\<adjacency prefix
|
||||
1\>|\<face uri 1\>|\<cost 1\>|...|\<adjacency prefix n\>|\<face uri
|
||||
n\>|\<cost n\>|
|
||||
*/
|
||||
std::string
|
||||
getData();
|
||||
|
||||
/*! \brief Initializes this adj. LSA from the supplied content.
|
||||
|
||||
\param content The content that this LSA is to have, formatted
|
||||
according to getData().
|
||||
*/
|
||||
bool
|
||||
initializeFromContent(const std::string& content);
|
||||
|
||||
@@ -208,6 +232,11 @@ public:
|
||||
bool
|
||||
isEqualContent(AdjLsa& alsa);
|
||||
|
||||
/*! \brief Installs this LSA's name prefixes into the NPT.
|
||||
|
||||
\param pnlsr The NLSR top-level whose NPT you want to install the
|
||||
entries into.
|
||||
*/
|
||||
void
|
||||
addNptEntries(Nlsr& pnlsr);
|
||||
|
||||
@@ -242,23 +271,35 @@ class CoordinateLsa: public Lsa
|
||||
{
|
||||
public:
|
||||
CoordinateLsa()
|
||||
: Lsa()
|
||||
: Lsa(CoordinateLsa::TYPE_STRING)
|
||||
, m_corRad(0)
|
||||
, m_corTheta(0)
|
||||
{
|
||||
setLsType(CoordinateLsa::TYPE_STRING);
|
||||
}
|
||||
|
||||
CoordinateLsa(const ndn::Name& origR, const std::string lst, uint32_t lsn,
|
||||
CoordinateLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
double r, double theta);
|
||||
|
||||
const ndn::Name
|
||||
getKey() const;
|
||||
|
||||
/*! \brief Returns the data that this coordinate LSA represents.
|
||||
|
||||
The format is: \<original
|
||||
router\>|coordinate|\<seq. no.\>|\<exp. time\>|\<radians\>|\<theta\>|
|
||||
*/
|
||||
std::string
|
||||
getData();
|
||||
|
||||
/*! \brief Initializes this coordinate LSA with the data in content.
|
||||
|
||||
\param content The string content that is used to build the LSA.
|
||||
|
||||
This function initializes this LSA object to represent the data
|
||||
specified by the parameter. The format that it is expecting is the
|
||||
same as for getData();
|
||||
*/
|
||||
bool
|
||||
initializeFromContent(const std::string& content);
|
||||
|
||||
@@ -303,6 +344,6 @@ public:
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const AdjLsa& adjLsa);
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_LSA_HPP
|
||||
+301
-156
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -19,24 +19,114 @@
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "lsdb.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
|
||||
#include "logger.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "publisher/segment-publisher.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
|
||||
#include <ndn-cxx/security/signing-helpers.hpp>
|
||||
#include <ndn-cxx/util/segment-fetcher.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER("Lsdb");
|
||||
|
||||
class LsaContentPublisher : public SegmentPublisher<ndn::Face>
|
||||
{
|
||||
public:
|
||||
LsaContentPublisher(ndn::Face& face,
|
||||
ndn::KeyChain& keyChain,
|
||||
const ndn::time::milliseconds& freshnessPeriod,
|
||||
const std::string& content)
|
||||
: SegmentPublisher(face, keyChain, freshnessPeriod)
|
||||
, m_content(content)
|
||||
{
|
||||
}
|
||||
|
||||
virtual size_t
|
||||
generate(ndn::EncodingBuffer& outBuffer) {
|
||||
size_t totalLength = 0;
|
||||
totalLength += outBuffer.prependByteArray(reinterpret_cast<const uint8_t*>(m_content.c_str()),
|
||||
m_content.size());
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string m_content;
|
||||
};
|
||||
|
||||
const ndn::Name::Component Lsdb::NAME_COMPONENT = ndn::Name::Component("lsdb");
|
||||
const ndn::time::seconds Lsdb::GRACE_PERIOD = ndn::time::seconds(10);
|
||||
const steady_clock::TimePoint Lsdb::DEFAULT_LSA_RETRIEVAL_DEADLINE = steady_clock::TimePoint::min();
|
||||
|
||||
using namespace std;
|
||||
Lsdb::Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler, SyncLogicHandler& sync)
|
||||
: m_nlsr(nlsr)
|
||||
, m_scheduler(scheduler)
|
||||
, m_sync(sync)
|
||||
, m_lsaRefreshTime(0)
|
||||
, m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::onFetchLsaError(uint32_t errorCode,
|
||||
const std::string& msg,
|
||||
ndn::Name& interestName,
|
||||
uint32_t retransmitNo,
|
||||
const ndn::time::steady_clock::TimePoint& deadline,
|
||||
ndn::Name lsaName,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Failed to fetch LSA: " << lsaName << ", Error code: " << errorCode
|
||||
<< ", Message: " << msg);
|
||||
|
||||
if (ndn::time::steady_clock::now() < deadline) {
|
||||
SequenceNumberMap::const_iterator it = m_highestSeqNo.find(lsaName);
|
||||
|
||||
if (it != m_highestSeqNo.end() && it->second == seqNo) {
|
||||
// If the SegmentFetcher failed due to an Interest timeout, it is safe to re-express
|
||||
// immediately since at the least the LSA Interest lifetime has elapsed.
|
||||
// Otherwise, it is necessary to delay the Interest re-expression to prevent
|
||||
// the potential for constant Interest flooding.
|
||||
ndn::time::seconds delay = m_nlsr.getConfParameter().getLsaInterestLifetime();
|
||||
|
||||
if (errorCode == ndn::util::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT) {
|
||||
delay = ndn::time::seconds(0);
|
||||
}
|
||||
|
||||
m_scheduler.scheduleEvent(delay, std::bind(&Lsdb::expressInterest, this,
|
||||
interestName, retransmitNo + 1, deadline));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::afterFetchLsa(const ndn::ConstBufferPtr& bufferPtr, ndn::Name& interestName)
|
||||
{
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>(ndn::Name(interestName));
|
||||
data->setContent(bufferPtr);
|
||||
|
||||
_LOG_DEBUG("Received data for LSA(name): " << data->getName());
|
||||
|
||||
ndn::Name lsaName = interestName.getSubName(0, interestName.size()-1);
|
||||
uint64_t seqNo = interestName[-1].toNumber();
|
||||
|
||||
if (m_highestSeqNo.find(lsaName) == m_highestSeqNo.end()) {
|
||||
m_highestSeqNo[lsaName] = seqNo;
|
||||
}
|
||||
else if (seqNo > m_highestSeqNo[lsaName]) {
|
||||
m_highestSeqNo[lsaName] = seqNo;
|
||||
}
|
||||
else if (seqNo < m_highestSeqNo[lsaName]) {
|
||||
return;
|
||||
}
|
||||
|
||||
onContentValidated(data);
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::cancelScheduleLsaExpiringEvent(ndn::EventId eid)
|
||||
@@ -44,18 +134,21 @@ Lsdb::cancelScheduleLsaExpiringEvent(ndn::EventId eid)
|
||||
m_scheduler.cancelEvent(eid);
|
||||
}
|
||||
|
||||
/*! \brief Compares if a name LSA is the same as the one specified by key
|
||||
|
||||
\param nlsa1 A name LSA object
|
||||
\param key A key of an originating router to compare to nlsa1
|
||||
*/
|
||||
static bool
|
||||
nameLsaCompareByKey(const NameLsa& nlsa1, const ndn::Name& key)
|
||||
{
|
||||
return nlsa1.getKey() == key;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Lsdb::buildAndInstallOwnNameLsa()
|
||||
{
|
||||
NameLsa nameLsa(m_nlsr.getConfParameter().getRouterPrefix(),
|
||||
NameLsa::TYPE_STRING,
|
||||
m_nlsr.getSequencingManager().getNameLsaSeq() + 1,
|
||||
getLsaExpirationTimePoint(),
|
||||
m_nlsr.getNamePrefixList());
|
||||
@@ -68,7 +161,7 @@ Lsdb::findNameLsa(const ndn::Name& key)
|
||||
{
|
||||
std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
|
||||
m_nameLsdb.end(),
|
||||
bind(nameLsaCompareByKey, _1, key));
|
||||
std::bind(nameLsaCompareByKey, _1, key));
|
||||
if (it != m_nameLsdb.end()) {
|
||||
return &(*it);
|
||||
}
|
||||
@@ -79,7 +172,9 @@ bool
|
||||
Lsdb::isNameLsaNew(const ndn::Name& key, uint64_t seqNo)
|
||||
{
|
||||
NameLsa* nameLsaCheck = findNameLsa(key);
|
||||
// Is the name in the LSDB
|
||||
if (nameLsaCheck != 0) {
|
||||
// And the supplied seq no is the highest so far
|
||||
if (nameLsaCheck->getLsSeqNo() < seqNo) {
|
||||
return true;
|
||||
}
|
||||
@@ -95,7 +190,7 @@ Lsdb::scheduleNameLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const ndn::time::seconds& expTime)
|
||||
{
|
||||
return m_scheduler.scheduleEvent(expTime + GRACE_PERIOD,
|
||||
ndn::bind(&Lsdb::exprireOrRefreshNameLsa, this, key, seqNo));
|
||||
std::bind(&Lsdb::exprireOrRefreshNameLsa, this, key, seqNo));
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -103,6 +198,7 @@ Lsdb::installNameLsa(NameLsa& nlsa)
|
||||
{
|
||||
ndn::time::seconds timeToExpire = m_lsaRefreshTime;
|
||||
NameLsa* chkNameLsa = findNameLsa(nlsa.getKey());
|
||||
// Determines if the name LSA is new or not.
|
||||
if (chkNameLsa == 0) {
|
||||
addNameLsa(nlsa);
|
||||
_LOG_DEBUG("New Name LSA");
|
||||
@@ -110,6 +206,8 @@ Lsdb::installNameLsa(NameLsa& nlsa)
|
||||
nlsa.writeLog();
|
||||
|
||||
if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
// If this name LSA is from another router, add the advertised
|
||||
// prefixes to the NPT.
|
||||
m_nlsr.getNamePrefixTable().addEntry(nlsa.getOrigRouter(),
|
||||
nlsa.getOrigRouter());
|
||||
std::list<ndn::Name> nameList = nlsa.getNpl().getNameList();
|
||||
@@ -129,6 +227,7 @@ Lsdb::installNameLsa(NameLsa& nlsa)
|
||||
nlsa.getLsSeqNo(),
|
||||
timeToExpire));
|
||||
}
|
||||
// Else this is a known name LSA, so we are updating it.
|
||||
else {
|
||||
if (chkNameLsa->getLsSeqNo() < nlsa.getLsSeqNo()) {
|
||||
_LOG_DEBUG("Updated Name LSA. Updating LSDB");
|
||||
@@ -138,6 +237,8 @@ Lsdb::installNameLsa(NameLsa& nlsa)
|
||||
chkNameLsa->setExpirationTimePoint(nlsa.getExpirationTimePoint());
|
||||
chkNameLsa->getNpl().sort();
|
||||
nlsa.getNpl().sort();
|
||||
// Obtain the set difference of the current and the incoming
|
||||
// name prefix sets, and add those.
|
||||
std::list<ndn::Name> nameToAdd;
|
||||
std::set_difference(nlsa.getNpl().getNameList().begin(),
|
||||
nlsa.getNpl().getNameList().end(),
|
||||
@@ -156,6 +257,7 @@ Lsdb::installNameLsa(NameLsa& nlsa)
|
||||
|
||||
chkNameLsa->getNpl().sort();
|
||||
|
||||
// Also remove any names that are no longer being advertised.
|
||||
std::list<ndn::Name> nameToRemove;
|
||||
std::set_difference(chkNameLsa->getNpl().getNameList().begin(),
|
||||
chkNameLsa->getNpl().getNameList().end(),
|
||||
@@ -192,7 +294,7 @@ Lsdb::addNameLsa(NameLsa& nlsa)
|
||||
{
|
||||
std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
|
||||
m_nameLsdb.end(),
|
||||
bind(nameLsaCompareByKey, _1,
|
||||
std::bind(nameLsaCompareByKey, _1,
|
||||
nlsa.getKey()));
|
||||
if (it == m_nameLsdb.end()) {
|
||||
m_nameLsdb.push_back(nlsa);
|
||||
@@ -206,10 +308,12 @@ Lsdb::removeNameLsa(const ndn::Name& key)
|
||||
{
|
||||
std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
|
||||
m_nameLsdb.end(),
|
||||
ndn::bind(nameLsaCompareByKey, _1, key));
|
||||
std::bind(nameLsaCompareByKey, _1, key));
|
||||
if (it != m_nameLsdb.end()) {
|
||||
_LOG_DEBUG("Deleting Name Lsa");
|
||||
(*it).writeLog();
|
||||
// If the requested name LSA is not ours, we also need to remove
|
||||
// its entries from the NPT.
|
||||
if ((*it).getOrigRouter() !=
|
||||
m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().removeEntry((*it).getOrigRouter(),
|
||||
@@ -232,7 +336,7 @@ Lsdb::doesNameLsaExist(const ndn::Name& key)
|
||||
{
|
||||
std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
|
||||
m_nameLsdb.end(),
|
||||
ndn::bind(nameLsaCompareByKey, _1, key));
|
||||
std::bind(nameLsaCompareByKey, _1, key));
|
||||
if (it == m_nameLsdb.end()) {
|
||||
return false;
|
||||
}
|
||||
@@ -257,6 +361,10 @@ Lsdb::getNameLsdb()
|
||||
|
||||
// Cor LSA and LSDB related Functions start here
|
||||
|
||||
/*! \brief Compares whether an LSA object is the same as a key.
|
||||
\param clsa The cor. LSA to check the identity of.
|
||||
\param key The key of the publishing router to check against.
|
||||
*/
|
||||
static bool
|
||||
corLsaCompareByKey(const CoordinateLsa& clsa, const ndn::Name& key)
|
||||
{
|
||||
@@ -267,13 +375,19 @@ bool
|
||||
Lsdb::buildAndInstallOwnCoordinateLsa()
|
||||
{
|
||||
CoordinateLsa corLsa(m_nlsr.getConfParameter().getRouterPrefix(),
|
||||
CoordinateLsa::TYPE_STRING,
|
||||
m_nlsr.getSequencingManager().getCorLsaSeq() + 1,
|
||||
getLsaExpirationTimePoint(),
|
||||
m_nlsr.getConfParameter().getCorR(),
|
||||
m_nlsr.getConfParameter().getCorTheta());
|
||||
m_nlsr.getSequencingManager().increaseCorLsaSeq();
|
||||
|
||||
// Sync coordinate LSAs if using HR or HR dry run.
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_nlsr.getSequencingManager().increaseCorLsaSeq();
|
||||
m_sync.publishRoutingUpdate();
|
||||
}
|
||||
|
||||
installCoordinateLsa(corLsa);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -282,7 +396,7 @@ Lsdb::findCoordinateLsa(const ndn::Name& key)
|
||||
{
|
||||
std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
|
||||
m_corLsdb.end(),
|
||||
ndn::bind(corLsaCompareByKey, _1, key));
|
||||
std::bind(corLsaCompareByKey, _1, key));
|
||||
if (it != m_corLsdb.end()) {
|
||||
return &(*it);
|
||||
}
|
||||
@@ -293,7 +407,9 @@ bool
|
||||
Lsdb::isCoordinateLsaNew(const ndn::Name& key, uint64_t seqNo)
|
||||
{
|
||||
CoordinateLsa* clsa = findCoordinateLsa(key);
|
||||
// Is the coordinate LSA in the LSDB already
|
||||
if (clsa != 0) {
|
||||
// And the seq no is newer (higher) than the current one
|
||||
if (clsa->getLsSeqNo() < seqNo) {
|
||||
return true;
|
||||
}
|
||||
@@ -304,12 +420,16 @@ Lsdb::isCoordinateLsaNew(const ndn::Name& key, uint64_t seqNo)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Schedules a refresh/expire event in the scheduler.
|
||||
// \param key The name of the router that published the LSA.
|
||||
// \param seqNo the seq. no. associated with the LSA to check.
|
||||
// \param expTime How long to wait before triggering the event.
|
||||
ndn::EventId
|
||||
Lsdb::scheduleCoordinateLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const ndn::time::seconds& expTime)
|
||||
{
|
||||
return m_scheduler.scheduleEvent(expTime + GRACE_PERIOD,
|
||||
ndn::bind(&Lsdb::exprireOrRefreshCoordinateLsa,
|
||||
std::bind(&Lsdb::exprireOrRefreshCoordinateLsa,
|
||||
this, key, seqNo));
|
||||
}
|
||||
|
||||
@@ -318,19 +438,22 @@ Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
|
||||
{
|
||||
ndn::time::seconds timeToExpire = m_lsaRefreshTime;
|
||||
CoordinateLsa* chkCorLsa = findCoordinateLsa(clsa.getKey());
|
||||
// Checking whether the LSA is new or not.
|
||||
if (chkCorLsa == 0) {
|
||||
_LOG_DEBUG("New Coordinate LSA. Adding to LSDB");
|
||||
_LOG_DEBUG("Adding Coordinate Lsa");
|
||||
clsa.writeLog();
|
||||
addCoordinateLsa(clsa);
|
||||
|
||||
// Register the LSA's origin router prefix
|
||||
if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().addEntry(clsa.getOrigRouter(),
|
||||
clsa.getOrigRouter());
|
||||
}
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() >= HYPERBOLIC_STATE_ON) {
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
}
|
||||
// Set the expiration time for the new LSA.
|
||||
if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
ndn::time::system_clock::Duration duration = clsa.getExpirationTimePoint() -
|
||||
ndn::time::system_clock::now();
|
||||
@@ -339,6 +462,7 @@ Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
|
||||
scheduleCoordinateLsaExpiration(clsa.getKey(),
|
||||
clsa.getLsSeqNo(), timeToExpire);
|
||||
}
|
||||
// We are just updating this LSA.
|
||||
else {
|
||||
if (chkCorLsa->getLsSeqNo() < clsa.getLsSeqNo()) {
|
||||
_LOG_DEBUG("Updated Coordinate LSA. Updating LSDB");
|
||||
@@ -346,6 +470,7 @@ Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
|
||||
chkCorLsa->writeLog();
|
||||
chkCorLsa->setLsSeqNo(clsa.getLsSeqNo());
|
||||
chkCorLsa->setExpirationTimePoint(clsa.getExpirationTimePoint());
|
||||
// If the new LSA contains new routing information, update the LSDB with it.
|
||||
if (!chkCorLsa->isEqualContent(clsa)) {
|
||||
chkCorLsa->setCorRadius(clsa.getCorRadius());
|
||||
chkCorLsa->setCorTheta(clsa.getCorTheta());
|
||||
@@ -353,6 +478,7 @@ Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
}
|
||||
}
|
||||
// If this is an LSA from another router, refresh its expiration time.
|
||||
if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
ndn::time::system_clock::Duration duration = clsa.getExpirationTimePoint() -
|
||||
ndn::time::system_clock::now();
|
||||
@@ -374,7 +500,7 @@ Lsdb::addCoordinateLsa(CoordinateLsa& clsa)
|
||||
{
|
||||
std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
|
||||
m_corLsdb.end(),
|
||||
ndn::bind(corLsaCompareByKey, _1,
|
||||
std::bind(corLsaCompareByKey, _1,
|
||||
clsa.getKey()));
|
||||
if (it == m_corLsdb.end()) {
|
||||
m_corLsdb.push_back(clsa);
|
||||
@@ -388,16 +514,16 @@ Lsdb::removeCoordinateLsa(const ndn::Name& key)
|
||||
{
|
||||
std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
|
||||
m_corLsdb.end(),
|
||||
ndn::bind(corLsaCompareByKey,
|
||||
std::bind(corLsaCompareByKey,
|
||||
_1, key));
|
||||
if (it != m_corLsdb.end()) {
|
||||
_LOG_DEBUG("Deleting Coordinate Lsa");
|
||||
(*it).writeLog();
|
||||
if ((*it).getOrigRouter() !=
|
||||
m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().removeEntry((*it).getOrigRouter(),
|
||||
(*it).getOrigRouter());
|
||||
it->writeLog();
|
||||
|
||||
if (it->getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().removeEntry(it->getOrigRouter(), it->getOrigRouter());
|
||||
}
|
||||
|
||||
m_corLsdb.erase(it);
|
||||
return true;
|
||||
}
|
||||
@@ -409,7 +535,7 @@ Lsdb::doesCoordinateLsaExist(const ndn::Name& key)
|
||||
{
|
||||
std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
|
||||
m_corLsdb.end(),
|
||||
ndn::bind(corLsaCompareByKey,
|
||||
std::bind(corLsaCompareByKey,
|
||||
_1, key));
|
||||
if (it == m_corLsdb.end()) {
|
||||
return false;
|
||||
@@ -435,6 +561,10 @@ Lsdb::getCoordinateLsdb()
|
||||
|
||||
// Adj LSA and LSDB related function starts here
|
||||
|
||||
/*! \brief Returns whether an adj. LSA object is from some router.
|
||||
\param alsa The adj. LSA object.
|
||||
\param key The router name that you want to compare the LSA with.
|
||||
*/
|
||||
static bool
|
||||
adjLsaCompareByKey(AdjLsa& alsa, const ndn::Name& key)
|
||||
{
|
||||
@@ -446,10 +576,15 @@ Lsdb::scheduleAdjLsaBuild()
|
||||
{
|
||||
m_nlsr.incrementAdjBuildCount();
|
||||
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
// Don't build adjacency LSAs in hyperbolic routing
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_nlsr.getIsBuildAdjLsaSheduled() == false) {
|
||||
_LOG_DEBUG("Scheduling Adjacency LSA build in " << m_adjLsaBuildInterval);
|
||||
|
||||
m_scheduler.scheduleEvent(m_adjLsaBuildInterval, ndn::bind(&Lsdb::buildAdjLsa, this));
|
||||
m_scheduler.scheduleEvent(m_adjLsaBuildInterval, std::bind(&Lsdb::buildAdjLsa, this));
|
||||
m_nlsr.setIsBuildAdjLsaSheduled(true);
|
||||
}
|
||||
}
|
||||
@@ -457,41 +592,58 @@ Lsdb::scheduleAdjLsaBuild()
|
||||
void
|
||||
Lsdb::buildAdjLsa()
|
||||
{
|
||||
_LOG_TRACE("buildAdjLsa called");
|
||||
_LOG_TRACE("Lsdb::buildAdjLsa called");
|
||||
|
||||
m_nlsr.setIsBuildAdjLsaSheduled(false);
|
||||
if (m_nlsr.getAdjacencyList().isAdjLsaBuildable(m_nlsr)) {
|
||||
|
||||
if (m_nlsr.getAdjacencyList().isAdjLsaBuildable(m_nlsr.getConfParameter().getInterestRetryNumber())) {
|
||||
|
||||
int adjBuildCount = m_nlsr.getAdjBuildCount();
|
||||
// Only do the adjLsa build if there's one scheduled
|
||||
if (adjBuildCount > 0) {
|
||||
// It only makes sense to do the adjLsa build if we have neighbors
|
||||
if (m_nlsr.getAdjacencyList().getNumOfActiveNeighbor() > 0) {
|
||||
_LOG_DEBUG("Building and installing Adj LSA");
|
||||
_LOG_DEBUG("Building and installing own Adj LSA");
|
||||
buildAndInstallOwnAdjLsa();
|
||||
}
|
||||
// We have no active neighbors, meaning no one can route through
|
||||
// us. So delete our entry in the LSDB. This prevents this
|
||||
// router from refreshing the LSA, eventually causing other
|
||||
// routers to delete it, too.
|
||||
else {
|
||||
_LOG_DEBUG("Removing own Adj LSA; no ACTIVE neighbors");
|
||||
// Get this router's key
|
||||
ndn::Name key = m_nlsr.getConfParameter().getRouterPrefix();
|
||||
key.append(AdjLsa::TYPE_STRING);
|
||||
|
||||
removeAdjLsa(key);
|
||||
// Recompute routing table after removal
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
}
|
||||
// In the case that during building the adj LSA, the FIB has to
|
||||
// wait on an Interest response, the number of scheduled adj LSA
|
||||
// builds could change, so we shouldn't just set it to 0.
|
||||
m_nlsr.setAdjBuildCount(m_nlsr.getAdjBuildCount() - adjBuildCount);
|
||||
}
|
||||
}
|
||||
// We are still waiting to know the adjacency status of some
|
||||
// neighbor, so schedule a build for later (when all that has
|
||||
// hopefully finished)
|
||||
else {
|
||||
m_nlsr.setIsBuildAdjLsaSheduled(true);
|
||||
int schedulingTime = m_nlsr.getConfParameter().getInterestRetryNumber() *
|
||||
m_nlsr.getConfParameter().getInterestResendTime();
|
||||
m_scheduler.scheduleEvent(ndn::time::seconds(schedulingTime),
|
||||
ndn::bind(&Lsdb::buildAdjLsa, this));
|
||||
std::bind(&Lsdb::buildAdjLsa, this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Lsdb::addAdjLsa(AdjLsa& alsa)
|
||||
{
|
||||
std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
|
||||
m_adjLsdb.end(),
|
||||
bind(adjLsaCompareByKey, _1,
|
||||
std::bind(adjLsaCompareByKey, _1,
|
||||
alsa.getKey()));
|
||||
if (it == m_adjLsdb.end()) {
|
||||
m_adjLsdb.push_back(alsa);
|
||||
@@ -505,19 +657,20 @@ Lsdb::findAdjLsa(const ndn::Name& key)
|
||||
{
|
||||
std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
|
||||
m_adjLsdb.end(),
|
||||
bind(adjLsaCompareByKey, _1, key));
|
||||
std::bind(adjLsaCompareByKey, _1, key));
|
||||
if (it != m_adjLsdb.end()) {
|
||||
return &(*it);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Lsdb::isAdjLsaNew(const ndn::Name& key, uint64_t seqNo)
|
||||
{
|
||||
AdjLsa* adjLsaCheck = findAdjLsa(key);
|
||||
// If it is in the LSDB
|
||||
if (adjLsaCheck != 0) {
|
||||
// And the supplied seq no is newer (higher) than the current one.
|
||||
if (adjLsaCheck->getLsSeqNo() < seqNo) {
|
||||
return true;
|
||||
}
|
||||
@@ -528,13 +681,12 @@ Lsdb::isAdjLsaNew(const ndn::Name& key, uint64_t seqNo)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
ndn::EventId
|
||||
Lsdb::scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const ndn::time::seconds& expTime)
|
||||
{
|
||||
return m_scheduler.scheduleEvent(expTime + GRACE_PERIOD,
|
||||
ndn::bind(&Lsdb::exprireOrRefreshAdjLsa, this, key, seqNo));
|
||||
std::bind(&Lsdb::exprireOrRefreshAdjLsa, this, key, seqNo));
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -542,11 +694,13 @@ Lsdb::installAdjLsa(AdjLsa& alsa)
|
||||
{
|
||||
ndn::time::seconds timeToExpire = m_lsaRefreshTime;
|
||||
AdjLsa* chkAdjLsa = findAdjLsa(alsa.getKey());
|
||||
// If this adj. LSA is not in the LSDB already
|
||||
if (chkAdjLsa == 0) {
|
||||
_LOG_DEBUG("New Adj LSA. Adding to LSDB");
|
||||
_LOG_DEBUG("Adding Adj Lsa");
|
||||
alsa.writeLog();
|
||||
addAdjLsa(alsa);
|
||||
// Add any new name prefixes to the NPT
|
||||
alsa.addNptEntries(m_nlsr);
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
if (alsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
@@ -564,6 +718,10 @@ Lsdb::installAdjLsa(AdjLsa& alsa)
|
||||
chkAdjLsa->writeLog();
|
||||
chkAdjLsa->setLsSeqNo(alsa.getLsSeqNo());
|
||||
chkAdjLsa->setExpirationTimePoint(alsa.getExpirationTimePoint());
|
||||
// If the new adj LSA has new content, update the contents of
|
||||
// the LSDB entry. Additionally, since we've changed the
|
||||
// contents of the LSDB, we have to schedule a routing
|
||||
// calculation.
|
||||
if (!chkAdjLsa->isEqualContent(alsa)) {
|
||||
chkAdjLsa->getAdl().reset();
|
||||
chkAdjLsa->getAdl().addAdjacents(alsa.getAdl());
|
||||
@@ -589,15 +747,16 @@ bool
|
||||
Lsdb::buildAndInstallOwnAdjLsa()
|
||||
{
|
||||
AdjLsa adjLsa(m_nlsr.getConfParameter().getRouterPrefix(),
|
||||
AdjLsa::TYPE_STRING,
|
||||
m_nlsr.getSequencingManager().getAdjLsaSeq() + 1,
|
||||
getLsaExpirationTimePoint(),
|
||||
m_nlsr.getAdjacencyList().getNumOfActiveNeighbor(),
|
||||
m_nlsr.getAdjacencyList());
|
||||
|
||||
m_nlsr.getSequencingManager().increaseAdjLsaSeq();
|
||||
|
||||
m_sync.publishRoutingUpdate();
|
||||
//Sync adjacency LSAs if link-state or dry-run HR is enabled.
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_ON) {
|
||||
m_nlsr.getSequencingManager().increaseAdjLsaSeq();
|
||||
m_sync.publishRoutingUpdate();
|
||||
}
|
||||
|
||||
return installAdjLsa(adjLsa);
|
||||
}
|
||||
@@ -607,7 +766,7 @@ Lsdb::removeAdjLsa(const ndn::Name& key)
|
||||
{
|
||||
std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
|
||||
m_adjLsdb.end(),
|
||||
ndn::bind(adjLsaCompareByKey, _1, key));
|
||||
std::bind(adjLsaCompareByKey, _1, key));
|
||||
if (it != m_adjLsdb.end()) {
|
||||
_LOG_DEBUG("Deleting Adj Lsa");
|
||||
(*it).writeLog();
|
||||
@@ -623,7 +782,7 @@ Lsdb::doesAdjLsaExist(const ndn::Name& key)
|
||||
{
|
||||
std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
|
||||
m_adjLsdb.end(),
|
||||
bind(adjLsaCompareByKey, _1, key));
|
||||
std::bind(adjLsaCompareByKey, _1, key));
|
||||
if (it == m_adjLsdb.end()) {
|
||||
return false;
|
||||
}
|
||||
@@ -643,19 +802,28 @@ Lsdb::setLsaRefreshTime(const seconds& lsaRefreshTime)
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::setThisRouterPrefix(string trp)
|
||||
Lsdb::setThisRouterPrefix(std::string trp)
|
||||
{
|
||||
m_thisRouterPrefix = trp;
|
||||
}
|
||||
|
||||
// This function determines whether a name LSA should be refreshed
|
||||
// or expired. The conditions for getting refreshed are: it is still
|
||||
// in the LSDB, it hasn't been updated by something else already (as
|
||||
// evidenced by its seq. no.), and this is the originating router for
|
||||
// the LSA. Is it let expire in all other cases.
|
||||
// lsaKey is the key of the LSA's publishing router.
|
||||
// seqNo is the seq. no. of the candidate LSA.
|
||||
void
|
||||
Lsdb::exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Lsdb::exprireOrRefreshNameLsa Called");
|
||||
_LOG_DEBUG("LSA Key : " << lsaKey << " Seq No: " << seqNo);
|
||||
NameLsa* chkNameLsa = findNameLsa(lsaKey);
|
||||
// If this name LSA exists in the LSDB
|
||||
if (chkNameLsa != 0) {
|
||||
_LOG_DEBUG("LSA Exists with seq no: " << chkNameLsa->getLsSeqNo());
|
||||
// If its seq no is the one we are expecting.
|
||||
if (chkNameLsa->getLsSeqNo() == seqNo) {
|
||||
if (chkNameLsa->getOrigRouter() == m_thisRouterPrefix) {
|
||||
_LOG_DEBUG("Own Name LSA, so refreshing it");
|
||||
@@ -672,6 +840,7 @@ Lsdb::exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo)
|
||||
m_lsaRefreshTime));
|
||||
m_sync.publishRoutingUpdate();
|
||||
}
|
||||
// Since we cannot refresh other router's LSAs, our only choice is to expire.
|
||||
else {
|
||||
_LOG_DEBUG("Other's Name LSA, so removing form LSDB");
|
||||
removeNameLsa(lsaKey);
|
||||
@@ -680,15 +849,25 @@ Lsdb::exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo)
|
||||
}
|
||||
}
|
||||
|
||||
// This function determines whether an adj. LSA should be refreshed
|
||||
// or expired. The conditions for getting refreshed are: it is still
|
||||
// in the LSDB, it hasn't been updated by something else already (as
|
||||
// evidenced by its seq. no.), and this is the originating router for
|
||||
// the LSA. Is it let expire in all other cases.
|
||||
// lsaKey is the key of the LSA's publishing router.
|
||||
// seqNo is the seq. no. of the candidate LSA.
|
||||
void
|
||||
Lsdb::exprireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Lsdb::exprireOrRefreshAdjLsa Called");
|
||||
_LOG_DEBUG("LSA Key : " << lsaKey << " Seq No: " << seqNo);
|
||||
AdjLsa* chkAdjLsa = findAdjLsa(lsaKey);
|
||||
// If this is a valid LSA
|
||||
if (chkAdjLsa != 0) {
|
||||
_LOG_DEBUG("LSA Exists with seq no: " << chkAdjLsa->getLsSeqNo());
|
||||
// And if it hasn't been updated for some other reason
|
||||
if (chkAdjLsa->getLsSeqNo() == seqNo) {
|
||||
// If it is our own LSA
|
||||
if (chkAdjLsa->getOrigRouter() == m_thisRouterPrefix) {
|
||||
_LOG_DEBUG("Own Adj LSA, so refreshing it");
|
||||
_LOG_DEBUG("Deleting Adj Lsa");
|
||||
@@ -704,16 +883,25 @@ Lsdb::exprireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo)
|
||||
m_lsaRefreshTime));
|
||||
m_sync.publishRoutingUpdate();
|
||||
}
|
||||
// An LSA from another router is expiring
|
||||
else {
|
||||
_LOG_DEBUG("Other's Adj LSA, so removing form LSDB");
|
||||
removeAdjLsa(lsaKey);
|
||||
}
|
||||
// schedule Routing table calculaiton
|
||||
// We have changed the contents of the LSDB, so we have to
|
||||
// schedule a routing calculation
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This function determines whether an adj. LSA should be refreshed
|
||||
// or expired. The conditions for getting refreshed are: it is still
|
||||
// in the LSDB, it hasn't been updated by something else already (as
|
||||
// evidenced by its seq. no.), and this is the originating router for
|
||||
// the LSA. It is let expire in all other cases.
|
||||
// lsaKey is the key of the LSA's publishing router.
|
||||
// seqNo is the seq. no. of the candidate LSA.
|
||||
void
|
||||
Lsdb::exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
|
||||
uint64_t seqNo)
|
||||
@@ -721,15 +909,20 @@ Lsdb::exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
|
||||
_LOG_DEBUG("Lsdb::exprireOrRefreshCorLsa Called ");
|
||||
_LOG_DEBUG("LSA Key : " << lsaKey << " Seq No: " << seqNo);
|
||||
CoordinateLsa* chkCorLsa = findCoordinateLsa(lsaKey);
|
||||
// Whether the LSA is in the LSDB or not.
|
||||
if (chkCorLsa != 0) {
|
||||
_LOG_DEBUG("LSA Exists with seq no: " << chkCorLsa->getLsSeqNo());
|
||||
// Whether the LSA has been updated without our knowledge.
|
||||
if (chkCorLsa->getLsSeqNo() == seqNo) {
|
||||
if (chkCorLsa->getOrigRouter() == m_thisRouterPrefix) {
|
||||
_LOG_DEBUG("Own Cor LSA, so refreshing it");
|
||||
_LOG_DEBUG("Deleting Coordinate Lsa");
|
||||
chkCorLsa->writeLog();
|
||||
chkCorLsa->setLsSeqNo(chkCorLsa->getLsSeqNo() + 1);
|
||||
m_nlsr.getSequencingManager().setCorLsaSeq(chkCorLsa->getLsSeqNo());
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_nlsr.getSequencingManager().setCorLsaSeq(chkCorLsa->getLsSeqNo());
|
||||
}
|
||||
|
||||
chkCorLsa->setExpirationTimePoint(getLsaExpirationTimePoint());
|
||||
_LOG_DEBUG("Adding Coordinate Lsa");
|
||||
chkCorLsa->writeLog();
|
||||
@@ -738,20 +931,23 @@ Lsdb::exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
|
||||
chkCorLsa->getKey(),
|
||||
chkCorLsa->getLsSeqNo(),
|
||||
m_lsaRefreshTime));
|
||||
m_sync.publishRoutingUpdate();
|
||||
// Only sync coordinate LSAs if link-state routing is disabled
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_sync.publishRoutingUpdate();
|
||||
}
|
||||
}
|
||||
// We can't refresh other router's LSAs, so we remove it.
|
||||
else {
|
||||
_LOG_DEBUG("Other's Cor LSA, so removing form LSDB");
|
||||
removeCoordinateLsa(lsaKey);
|
||||
}
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() >= HYPERBOLIC_STATE_ON) {
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Lsdb::expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
steady_clock::TimePoint deadline)
|
||||
@@ -759,30 +955,33 @@ Lsdb::expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
if (deadline == DEFAULT_LSA_RETRIEVAL_DEADLINE) {
|
||||
deadline = steady_clock::now() + ndn::time::seconds(static_cast<int>(LSA_REFRESH_TIME_MAX));
|
||||
}
|
||||
|
||||
// The first component of the interest is the name.
|
||||
ndn::Name lsaName = interestName.getSubName(0, interestName.size()-1);
|
||||
|
||||
ndn::Interest interest(interestName);
|
||||
// The seq no is the last
|
||||
uint64_t seqNo = interestName[-1].toNumber();
|
||||
|
||||
// If the LSA is not found in the list currently.
|
||||
if (m_highestSeqNo.find(lsaName) == m_highestSeqNo.end()) {
|
||||
m_highestSeqNo[lsaName] = seqNo;
|
||||
}
|
||||
// If the new seq no is higher, that means the LSA is valid
|
||||
else if (seqNo > m_highestSeqNo[lsaName]) {
|
||||
m_highestSeqNo[lsaName] = seqNo;
|
||||
}
|
||||
// Otherwise, its an old/invalid LSA
|
||||
else if (seqNo < m_highestSeqNo[lsaName]) {
|
||||
return;
|
||||
}
|
||||
|
||||
ndn::Interest interest(interestName);
|
||||
interest.setInterestLifetime(m_nlsr.getConfParameter().getLsaInterestLifetime());
|
||||
|
||||
_LOG_DEBUG("Expressing Interest for LSA: " << interestName << " Seq number: " << seqNo);
|
||||
m_nlsr.getNlsrFace().expressInterest(interest,
|
||||
ndn::bind(&Lsdb::onContent,
|
||||
this, _2, deadline, lsaName, seqNo),
|
||||
ndn::bind(&Lsdb::processInterestTimedOut,
|
||||
this, _1, timeoutCount, deadline, lsaName, seqNo));
|
||||
_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));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -791,11 +990,12 @@ Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
const ndn::Name& interestName(interest.getName());
|
||||
_LOG_DEBUG("Interest received for LSA: " << interestName);
|
||||
|
||||
string chkString("LSA");
|
||||
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));
|
||||
@@ -805,6 +1005,7 @@ Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
|
||||
std::string interestedLsType = interestName[-2].toUri();
|
||||
|
||||
// Passes the Interest off to the appropriate subprocessor
|
||||
if (interestedLsType == NameLsa::TYPE_STRING) {
|
||||
processInterestForNameLsa(interest, originRouter.append(interestedLsType), seqNo);
|
||||
}
|
||||
@@ -820,21 +1021,25 @@ Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
}
|
||||
}
|
||||
|
||||
// \brief Sends LSA data.
|
||||
// \param interest The Interest that warranted the data.
|
||||
// \param content The data that the Interest was seeking.
|
||||
void
|
||||
Lsdb::putLsaData(const ndn::Interest& interest, const std::string& content)
|
||||
{
|
||||
ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>();
|
||||
data->setName(ndn::Name(interest.getName()).appendVersion());
|
||||
data->setFreshnessPeriod(m_lsaRefreshTime);
|
||||
data->setContent(reinterpret_cast<const uint8_t*>(content.c_str()), content.size());
|
||||
m_nlsr.getKeyChain().sign(*data, m_nlsr.getDefaultCertName());
|
||||
ndn::SignatureSha256WithRsa signature(data->getSignature());
|
||||
ndn::Name signingCertName = signature.getKeyLocator().getName();
|
||||
_LOG_DEBUG("Sending data for LSA(name): " << interest.getName());
|
||||
_LOG_DEBUG("Data signed with: " << signingCertName);
|
||||
m_nlsr.getNlsrFace().put(*data);
|
||||
LsaContentPublisher publisher(m_nlsr.getNlsrFace(),
|
||||
m_nlsr.getKeyChain(),
|
||||
m_lsaRefreshTime,
|
||||
content);
|
||||
publisher.publish(interest.getName(),
|
||||
ndn::security::signingByCertificate(m_nlsr.getDefaultCertName()));
|
||||
}
|
||||
|
||||
// \brief Finds and sends a requested name LSA.
|
||||
// \param interest The interest that seeks the name LSA.
|
||||
// \param lsaKey The LSA that the Interest is seeking.
|
||||
// \param seqNo A sequence number to ensure that we are sending the
|
||||
// version that was requested.
|
||||
void
|
||||
Lsdb::processInterestForNameLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
@@ -849,11 +1054,20 @@ Lsdb::processInterestForNameLsa(const ndn::Interest& interest,
|
||||
}
|
||||
}
|
||||
|
||||
// \brief Finds and sends a requested adj. LSA.
|
||||
// \param interest The interest that seeks the adj. LSA.
|
||||
// \param lsaKey The LSA that the Interest is seeking.
|
||||
// \param seqNo A sequence number to ensure that we are sending the
|
||||
// version that was requested.
|
||||
void
|
||||
Lsdb::processInterestForAdjacencyLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
_LOG_ERROR("Received interest for an adjacency LSA when hyperbolic routing is enabled.");
|
||||
}
|
||||
|
||||
AdjLsa* adjLsa = m_nlsr.getLsdb().findAdjLsa(lsaKey);
|
||||
if (adjLsa != 0) {
|
||||
if (adjLsa->getLsSeqNo() == seqNo) {
|
||||
@@ -863,11 +1077,20 @@ Lsdb::processInterestForAdjacencyLsa(const ndn::Interest& interest,
|
||||
}
|
||||
}
|
||||
|
||||
// \brief Finds and sends a requested cor. LSA.
|
||||
// \param interest The interest that seeks the cor. LSA.
|
||||
// \param lsaKey The LSA that the Interest is seeking.
|
||||
// \param seqNo A sequence number to ensure that we are sending the
|
||||
// version that was requested.
|
||||
void
|
||||
Lsdb::processInterestForCoordinateLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
|
||||
_LOG_ERROR("Received Interest for a coordinate LSA when link-state routing is enabled.");
|
||||
}
|
||||
|
||||
CoordinateLsa* corLsa = m_nlsr.getLsdb().findCoordinateLsa(lsaKey);
|
||||
if (corLsa != 0) {
|
||||
if (corLsa->getLsSeqNo() == seqNo) {
|
||||
@@ -878,58 +1101,24 @@ Lsdb::processInterestForCoordinateLsa(const ndn::Interest& interest,
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::onContent(const ndn::Data& data,
|
||||
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Received data for LSA(name): " << data.getName());
|
||||
if (data.getSignature().hasKeyLocator()) {
|
||||
if (data.getSignature().getKeyLocator().getType() == ndn::KeyLocator::KeyLocator_Name) {
|
||||
_LOG_DEBUG("Data signed with: " << data.getSignature().getKeyLocator().getName());
|
||||
}
|
||||
}
|
||||
m_nlsr.getValidator().validate(data,
|
||||
ndn::bind(&Lsdb::onContentValidated, this, _1),
|
||||
ndn::bind(&Lsdb::onContentValidationFailed, this, _1, _2,
|
||||
deadline, lsaName, seqNo));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::retryContentValidation(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Retrying validation of LSA(name): " << data->getName());
|
||||
if (data->getSignature().hasKeyLocator()) {
|
||||
if (data->getSignature().getKeyLocator().getType() == ndn::KeyLocator::KeyLocator_Name) {
|
||||
_LOG_DEBUG("Data signed with: " << data->getSignature().getKeyLocator().getName());
|
||||
}
|
||||
}
|
||||
m_nlsr.getValidator().validate(*data,
|
||||
ndn::bind(&Lsdb::onContentValidated, this, _1),
|
||||
ndn::bind(&Lsdb::onContentValidationFailed, this, _1, _2,
|
||||
deadline, lsaName, seqNo));
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
|
||||
Lsdb::onContentValidated(const std::shared_ptr<const ndn::Data>& data)
|
||||
{
|
||||
const ndn::Name& dataName = data->getName();
|
||||
_LOG_DEBUG("Data validation successful for LSA: " << dataName);
|
||||
|
||||
string chkString("LSA");
|
||||
std::string chkString("LSA");
|
||||
int32_t lsaPosition = util::getNameComponentPosition(dataName, chkString);
|
||||
|
||||
if (lsaPosition >= 0) {
|
||||
|
||||
// Extracts the prefix of the originating router from the data.
|
||||
ndn::Name originRouter = m_nlsr.getConfParameter().getNetwork();
|
||||
originRouter.append(dataName.getSubName(lsaPosition + 1, dataName.size() - lsaPosition - 4));
|
||||
originRouter.append(dataName.getSubName(lsaPosition + 1, dataName.size() - lsaPosition - 3));
|
||||
|
||||
uint64_t seqNo = dataName[-2].toNumber();
|
||||
string dataContent(reinterpret_cast<const char*>(data->getContent().value()));
|
||||
uint64_t seqNo = dataName[-1].toNumber();
|
||||
std::string dataContent(reinterpret_cast<const char*>(data->getContent().value()));
|
||||
|
||||
std::string interestedLsType = dataName[-3].toUri();
|
||||
std::string interestedLsType = dataName[-2].toUri();
|
||||
|
||||
if (interestedLsType == NameLsa::TYPE_STRING) {
|
||||
processContentNameLsa(originRouter.append(interestedLsType), seqNo, dataContent);
|
||||
@@ -946,32 +1135,6 @@ Lsdb::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
const std::string& msg,
|
||||
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Validation Error: " << msg);
|
||||
|
||||
// Delay re-validation by LSA Interest Lifetime. When error callback will have an error
|
||||
// code, re-validation should be done only when some keys from certification chain failed
|
||||
// to be fetched. After that change, delaying will no longer be necessary.
|
||||
|
||||
// Stop retrying if delayed re-validation will be scheduled pass the deadline
|
||||
if (steady_clock::now() + m_nlsr.getConfParameter().getLsaInterestLifetime() < deadline) {
|
||||
|
||||
SequenceNumberMap::const_iterator it = m_highestSeqNo.find(lsaName);
|
||||
|
||||
if (it != m_highestSeqNo.end() && it->second == seqNo) {
|
||||
_LOG_DEBUG("Scheduling revalidation attempt");
|
||||
m_scheduler.scheduleEvent(m_nlsr.getConfParameter().getLsaInterestLifetime(),
|
||||
ndn::bind(&Lsdb::retryContentValidation, this, data,
|
||||
deadline, lsaName, seqNo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::processContentNameLsa(const ndn::Name& lsaKey,
|
||||
uint64_t lsSeqNo, std::string& dataContent)
|
||||
@@ -1017,24 +1180,6 @@ Lsdb::processContentCoordinateLsa(const ndn::Name& lsaKey,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::processInterestTimedOut(const ndn::Interest& interest, uint32_t retransmitNo,
|
||||
const ndn::time::steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
const ndn::Name& interestName = interest.getName();
|
||||
_LOG_DEBUG("Interest timed out for LSA: " << interestName);
|
||||
|
||||
if (ndn::time::steady_clock::now() < deadline) {
|
||||
|
||||
SequenceNumberMap::const_iterator it = m_highestSeqNo.find(lsaName);
|
||||
|
||||
if (it != m_highestSeqNo.end() && it->second == seqNo) {
|
||||
expressInterest(interestName, retransmitNo + 1, deadline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ndn::time::system_clock::TimePoint
|
||||
Lsdb::getLsaExpirationTimePoint()
|
||||
{
|
||||
|
||||
+142
-49
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <utility>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
#include <ndn-cxx/util/time.hpp>
|
||||
|
||||
@@ -41,31 +42,44 @@ class SyncLogicHandler;
|
||||
class Lsdb
|
||||
{
|
||||
public:
|
||||
Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler, SyncLogicHandler& sync)
|
||||
: m_nlsr(nlsr)
|
||||
, m_scheduler(scheduler)
|
||||
, m_sync(sync)
|
||||
, m_lsaRefreshTime(0)
|
||||
, m_adjLsaBuildInterval(static_cast<uint32_t>(ADJ_LSA_BUILD_INTERVAL_DEFAULT))
|
||||
{
|
||||
}
|
||||
Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler, SyncLogicHandler& sync);
|
||||
|
||||
bool
|
||||
doesLsaExist(const ndn::Name& key, const std::string& lsType);
|
||||
// function related to Name LSDB
|
||||
|
||||
|
||||
/*! \brief Builds a name LSA for this router and then installs it
|
||||
into the LSDB.
|
||||
*/
|
||||
bool
|
||||
buildAndInstallOwnNameLsa();
|
||||
|
||||
/*! \brief Returns the name LSA with the given key.
|
||||
\param key The name of the router that the desired LSA comes from.
|
||||
*/
|
||||
NameLsa*
|
||||
findNameLsa(const ndn::Name& key);
|
||||
|
||||
/*! \brief Installs a name LSA into the LSDB
|
||||
\param nlsa The name LSA to install into the LSDB.
|
||||
*/
|
||||
bool
|
||||
installNameLsa(NameLsa& nlsa);
|
||||
|
||||
/*! \brief Remove a name LSA from the LSDB.
|
||||
\param key The name of the router that published the LSA to remove.
|
||||
|
||||
This function will remove a name LSA from the LSDB by finding an
|
||||
LSA whose name matches key. This removal also causes the NPT to
|
||||
remove those name prefixes if no more LSAs advertise them.
|
||||
*/
|
||||
bool
|
||||
removeNameLsa(const ndn::Name& key);
|
||||
|
||||
/*! Returns whether a seq. no. from a certain router signals a new LSA.
|
||||
\param key The name of the originating router.
|
||||
\param seqNo The sequence number to check.
|
||||
*/
|
||||
bool
|
||||
isNameLsaNew(const ndn::Name& key, uint64_t seqNo);
|
||||
|
||||
@@ -75,19 +89,36 @@ public:
|
||||
const std::list<NameLsa>&
|
||||
getNameLsdb();
|
||||
|
||||
//function related to Cor LSDB
|
||||
/*! \brief Builds a cor. LSA for this router and installs it into the LSDB. */
|
||||
bool
|
||||
buildAndInstallOwnCoordinateLsa();
|
||||
|
||||
/*! \brief Finds a cor. LSA in the LSDB.
|
||||
\param key The name of the originating router that published the LSA.
|
||||
*/
|
||||
CoordinateLsa*
|
||||
findCoordinateLsa(const ndn::Name& key);
|
||||
|
||||
/*! \brief Installs a cor. LSA into the LSDB.
|
||||
\param clsa The cor. LSA to install.
|
||||
*/
|
||||
bool
|
||||
installCoordinateLsa(CoordinateLsa& clsa);
|
||||
|
||||
/*! \brief Removes a cor. LSA from the LSDB.
|
||||
\param key The name of the router that published the LSA to remove.
|
||||
|
||||
Removes the coordinate LSA whose origin router name matches that
|
||||
given by key. Additionally, ask the NPT to remove the prefix,
|
||||
which will occur if no other LSAs point there.
|
||||
*/
|
||||
bool
|
||||
removeCoordinateLsa(const ndn::Name& key);
|
||||
|
||||
/*! \brief Returns whether a cor. LSA from a router is new or not.
|
||||
\param key The name prefix of the originating router.
|
||||
\param seqNo The sequence number of the candidate LSA.
|
||||
*/
|
||||
bool
|
||||
isCoordinateLsaNew(const ndn::Name& key, uint64_t seqNo);
|
||||
|
||||
@@ -99,21 +130,39 @@ public:
|
||||
|
||||
//function related to Adj LSDB
|
||||
|
||||
/*! \brief Schedules a build of this router's LSA. */
|
||||
void
|
||||
scheduleAdjLsaBuild();
|
||||
|
||||
/*! \brief Wrapper event to build and install an adj. LSA for this router. */
|
||||
bool
|
||||
buildAndInstallOwnAdjLsa();
|
||||
|
||||
/*! \brief Removes an adj. LSA from the LSDB.
|
||||
\param key The name of the publishing router whose LSA to remove.
|
||||
*/
|
||||
bool
|
||||
removeAdjLsa(const ndn::Name& key);
|
||||
|
||||
/*! \brief Returns whether an LSA is new.
|
||||
\param key The name of the publishing router.
|
||||
\param seqNo The seq. no. of the candidate LSA.
|
||||
|
||||
This function determines whether the LSA with the name key and
|
||||
seq. no. seqNo would be new to this LSDB.
|
||||
*/
|
||||
bool
|
||||
isAdjLsaNew(const ndn::Name& key, uint64_t seqNo);
|
||||
|
||||
/*! \brief Installs an adj. LSA into the LSDB.
|
||||
\param alsa The adj. LSA to add to the LSDB.
|
||||
*/
|
||||
bool
|
||||
installAdjLsa(AdjLsa& alsa);
|
||||
|
||||
/*! \brief Finds an adj. LSA in the LSDB.
|
||||
\param key The name of the publishing router whose LSA to find.
|
||||
*/
|
||||
AdjLsa*
|
||||
findAdjLsa(const ndn::Name& key);
|
||||
|
||||
@@ -141,42 +190,88 @@ public:
|
||||
void
|
||||
setThisRouterPrefix(std::string trp);
|
||||
|
||||
void
|
||||
expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
steady_clock::TimePoint deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
|
||||
|
||||
void
|
||||
processInterest(const ndn::Name& name, const ndn::Interest& interest);
|
||||
|
||||
private:
|
||||
/* \brief Add a name LSA to the LSDB if it isn't already there.
|
||||
\param nlsa The candidade name LSA.
|
||||
*/
|
||||
bool
|
||||
addNameLsa(NameLsa& nlsa);
|
||||
|
||||
/*! \brief Returns whether the LSDB contains some LSA.
|
||||
\param key The name of the publishing router whose LSA to check for.
|
||||
*/
|
||||
bool
|
||||
doesNameLsaExist(const ndn::Name& key);
|
||||
|
||||
|
||||
/*! \brief Adds a cor. LSA to the LSDB if it isn't already there.
|
||||
\param clsa The candidate cor. LSA.
|
||||
*/
|
||||
bool
|
||||
addCoordinateLsa(CoordinateLsa& clsa);
|
||||
|
||||
/*! \brief Returns whether a cor. LSA is in the LSDB.
|
||||
\param key The name of the router that published the queried LSA.
|
||||
*/
|
||||
bool
|
||||
doesCoordinateLsaExist(const ndn::Name& key);
|
||||
|
||||
/*! \brief Attempts to construct an adj. LSA.
|
||||
|
||||
This function will attempt to construct an adjacency LSA. An LSA
|
||||
can only be built when the status of all of the router's neighbors
|
||||
is known. That is, when we are not currently trying to contact any
|
||||
neighbor.
|
||||
*/
|
||||
void
|
||||
buildAdjLsa();
|
||||
|
||||
/*! \brief Adds an adj. LSA to the LSDB if it isn't already there.
|
||||
\param alsa The candidate adj. LSA to add to the LSDB.
|
||||
*/
|
||||
bool
|
||||
addAdjLsa(AdjLsa& alsa);
|
||||
|
||||
/*! \brief Returns whether the LSDB contains an LSA.
|
||||
\param key The name of a router whose LSA to check for in the LSDB.
|
||||
*/
|
||||
bool
|
||||
doesAdjLsaExist(const ndn::Name& key);
|
||||
|
||||
/*! \brief Schedules a refresh/expire event in the scheduler.
|
||||
\param key The name of the router that published the LSA.
|
||||
\param seqNo The seq. no. associated with the LSA.
|
||||
\param expTime How many seconds to wait before triggering the event.
|
||||
*/
|
||||
ndn::EventId
|
||||
scheduleNameLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const seconds& expTime);
|
||||
|
||||
/*! \brief Either allow to expire, or refresh a name LSA.
|
||||
\param lsaKey The name of the router that published the LSA.
|
||||
\param seqNo The seq. no. of the LSA to check.
|
||||
*/
|
||||
void
|
||||
exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo);
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
/*! \brief Schedules an expire/refresh event in the LSA.
|
||||
\param key The name of the router whose LSA is in question.
|
||||
\param seqNo The sequence number of the LSA to check.
|
||||
\param expTime The number of seconds to wait before triggering the event.
|
||||
*/
|
||||
ndn::EventId
|
||||
scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const seconds& expTime);
|
||||
|
||||
private:
|
||||
|
||||
void
|
||||
exprireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo);
|
||||
|
||||
@@ -187,15 +282,9 @@ private:
|
||||
void
|
||||
exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
|
||||
uint64_t seqNo);
|
||||
public:
|
||||
void
|
||||
expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
steady_clock::TimePoint deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
|
||||
|
||||
void
|
||||
processInterest(const ndn::Name& name, const ndn::Interest& interest);
|
||||
|
||||
private:
|
||||
|
||||
void
|
||||
putLsaData(const ndn::Interest& interest, const std::string& content);
|
||||
|
||||
@@ -213,32 +302,8 @@ private:
|
||||
processInterestForCoordinateLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
uint64_t seqNo);
|
||||
|
||||
void
|
||||
onContent(const ndn::Data& data, const steady_clock::TimePoint& deadline,
|
||||
ndn::Name lsaName, uint64_t seqNo);
|
||||
|
||||
/**
|
||||
* @brief Retry validation after it fails
|
||||
*
|
||||
* Data packet validation can fail either because the packet does not have
|
||||
* valid signature (fatal) or because some of the certificate chain Data packets
|
||||
* failed to be fetched (non-fatal). Currently, the library does not provide
|
||||
* clear indication (besides plain-text message in error callback) of what is
|
||||
* the reason for failure and we will try to re-validate for as long as it the deadline.
|
||||
*/
|
||||
void
|
||||
retryContentValidation(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo);
|
||||
|
||||
void
|
||||
onContentValidated(const ndn::shared_ptr<const ndn::Data>& data);
|
||||
|
||||
void
|
||||
onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data, const std::string& msg,
|
||||
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo);
|
||||
onContentValidated(const std::shared_ptr<const ndn::Data>& data);
|
||||
|
||||
void
|
||||
processContentNameLsa(const ndn::Name& lsaKey,
|
||||
@@ -253,15 +318,43 @@ private:
|
||||
uint64_t lsSeqNo, std::string& dataContent);
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
/*!
|
||||
\brief Error callback when SegmentFetcher fails to return an LSA
|
||||
|
||||
In all error cases, a reattempt to fetch the LSA will be made.
|
||||
|
||||
Segment validation can fail either because the packet does not have a
|
||||
valid signature (fatal) or because some of the certificates in the trust chain
|
||||
could not be fetched (non-fatal).
|
||||
|
||||
Currently, the library does not provide clear indication (besides a plain-text message
|
||||
in the error callback) of the reason for the failure nor the segment that failed
|
||||
to be validated, thus we will continue to try to fetch the LSA until the deadline
|
||||
is reached.
|
||||
*/
|
||||
void
|
||||
processInterestTimedOut(const ndn::Interest& interest, uint32_t retransmitNo,
|
||||
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo);
|
||||
onFetchLsaError(uint32_t errorCode,
|
||||
const std::string& msg,
|
||||
ndn::Name& interestName,
|
||||
uint32_t retransmitNo,
|
||||
const ndn::time::steady_clock::TimePoint& deadline,
|
||||
ndn::Name lsaName,
|
||||
uint64_t seqNo);
|
||||
|
||||
/*!
|
||||
\brief Success callback when SegmentFetcher returns a valid LSA
|
||||
|
||||
\param interestName The base Interest used to fetch the LSA in the format:
|
||||
/<network>/NLSR/LSA/<site>/%C1.Router/<router>/<lsa-type>/<seqNo>
|
||||
*/
|
||||
void
|
||||
afterFetchLsa(const ndn::ConstBufferPtr& data, ndn::Name& interestName);
|
||||
|
||||
private:
|
||||
system_clock::TimePoint
|
||||
getLsaExpirationTimePoint();
|
||||
|
||||
/*! \brief Cancels an event in the event scheduler. */
|
||||
void
|
||||
cancelScheduleLsaExpiringEvent(ndn::EventId eid);
|
||||
|
||||
@@ -292,6 +385,6 @@ private:
|
||||
ndn::time::seconds m_adjLsaBuildInterval;
|
||||
};
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_LSDB_HPP
|
||||
#endif // NLSR_LSDB_HPP
|
||||
+19
-58
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -19,39 +19,27 @@
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
|
||||
#include "conf-file-processor.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "nlsr-runner.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
// boost needs to be included after ndn-cxx, otherwise there will be conflict with _1, _2, ...
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
int
|
||||
main(int32_t argc, char** argv)
|
||||
{
|
||||
boost::asio::io_service ioService;
|
||||
ndn::Scheduler scheduler(ioService);
|
||||
ndn::Face face(ioService);
|
||||
|
||||
Nlsr nlsr(ioService, scheduler, face);
|
||||
using namespace nlsr;
|
||||
|
||||
std::string programName(argv[0]);
|
||||
nlsr.setConfFileName("nlsr.conf");
|
||||
|
||||
std::string configFileName = "nlsr.conf";
|
||||
bool isDaemonProcess = false;
|
||||
|
||||
int32_t opt;
|
||||
while ((opt = getopt(argc, argv, "df:hV")) != -1) {
|
||||
switch (opt)
|
||||
{
|
||||
switch (opt) {
|
||||
case 'f':
|
||||
nlsr.setConfFileName(optarg);
|
||||
configFileName = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
nlsr.setIsDaemonProcess(true);
|
||||
isDaemonProcess = true;
|
||||
break;
|
||||
case 'V':
|
||||
std::cout << NLSR_VERSION_BUILD_STRING << std::endl;
|
||||
@@ -59,47 +47,20 @@ main(int32_t argc, char** argv)
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
nlsr.usage(programName);
|
||||
NlsrRunner::printUsage(programName);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConfFileProcessor cfp(nlsr, nlsr.getConfFileName());
|
||||
if (!cfp.processConfFile()) {
|
||||
std::cerr << "Error in configuration file processing! Exiting from NLSR" << std::endl;
|
||||
NlsrRunner runner(configFileName, isDaemonProcess);
|
||||
|
||||
try {
|
||||
runner.run();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (nlsr.getConfParameter().isLog4CxxConfAvailable()) {
|
||||
INIT_LOG4CXX(nlsr.getConfParameter().getLog4CxxConfPath());
|
||||
}
|
||||
else {
|
||||
INIT_LOGGERS(nlsr.getConfParameter().getLogDir(), nlsr.getConfParameter().getLogLevel());
|
||||
}
|
||||
|
||||
INIT_LOGGER("Main");
|
||||
|
||||
nlsr.initialize();
|
||||
if (nlsr.getIsSetDaemonProcess()) {
|
||||
nlsr.daemonize();
|
||||
}
|
||||
try {
|
||||
nlsr.startEventLoop();
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_FATAL("ERROR: " << e.what());
|
||||
std::cerr << "ERROR: " << e.what() << std::endl;
|
||||
|
||||
nlsr.getFib().clean();
|
||||
nlsr.destroyFaces();
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
int
|
||||
main(int32_t argc, char** argv)
|
||||
{
|
||||
return nlsr::main(argc, argv);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -53,8 +53,8 @@ NamePrefixList::insert(const ndn::Name& name)
|
||||
{
|
||||
std::list<ndn::Name>::iterator it = std::find_if(m_nameList.begin(),
|
||||
m_nameList.end(),
|
||||
ndn::bind(&nameCompare, _1 ,
|
||||
ndn::cref(name)));
|
||||
std::bind(&nameCompare, _1 ,
|
||||
std::cref(name)));
|
||||
if (it != m_nameList.end()) {
|
||||
return false;
|
||||
}
|
||||
@@ -67,8 +67,8 @@ NamePrefixList::remove(const ndn::Name& name)
|
||||
{
|
||||
std::list<ndn::Name>::iterator it = std::find_if(m_nameList.begin(),
|
||||
m_nameList.end(),
|
||||
ndn::bind(&nameCompare, _1 ,
|
||||
ndn::cref(name)));
|
||||
std::bind(&nameCompare, _1 ,
|
||||
std::cref(name)));
|
||||
if (it != m_nameList.end()) {
|
||||
m_nameList.erase(it);
|
||||
return true;
|
||||
@@ -95,4 +95,4 @@ NamePrefixList::writeLog()
|
||||
}
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -37,14 +37,16 @@ public:
|
||||
|
||||
~NamePrefixList();
|
||||
|
||||
/** \brief inserts name into NamePrefixList
|
||||
* \return true if the name is inserted, otherwise false
|
||||
/*! \brief inserts name into NamePrefixList
|
||||
\retval true If the name was successfully inserted.
|
||||
\retval false If the name could not be inserted.
|
||||
*/
|
||||
bool
|
||||
insert(const ndn::Name& name);
|
||||
|
||||
/** \brief removes name from NamePrefixList
|
||||
* \return true if the name is removed, otherwise false
|
||||
/*! \brief removes name from NamePrefixList
|
||||
\retval true If the name is removed
|
||||
\retval false If the name failed to be removed.
|
||||
*/
|
||||
bool
|
||||
remove(const ndn::Name& name);
|
||||
@@ -72,6 +74,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_NAME_PREFIX_LIST_HPP
|
||||
@@ -0,0 +1,85 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, 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 "nlsr-runner.hpp"
|
||||
|
||||
#include "conf-file-processor.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER("NlsrRunner");
|
||||
|
||||
NlsrRunner::NlsrRunner(std::string& configFileName, bool isDaemonProcess)
|
||||
: 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
|
||||
NlsrRunner::run()
|
||||
{
|
||||
ConfFileProcessor configProcessor(m_nlsr, m_nlsr.getConfFileName());
|
||||
|
||||
if (!configProcessor.processConfFile()) {
|
||||
throw 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());
|
||||
}
|
||||
|
||||
m_nlsr.initialize();
|
||||
|
||||
if (m_nlsr.getIsSetDaemonProcess()) {
|
||||
m_nlsr.daemonize();
|
||||
}
|
||||
|
||||
try {
|
||||
m_nlsr.startEventLoop();
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_FATAL("ERROR: " << e.what());
|
||||
std::cerr << "ERROR: " << e.what() << std::endl;
|
||||
|
||||
m_nlsr.getFib().clean();
|
||||
m_nlsr.destroyFaces();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
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;
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -0,0 +1,66 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, 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_NLSR_RUNNER_HPP
|
||||
#define NLSR_NLSR_RUNNER_HPP
|
||||
|
||||
#include "nlsr.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
|
||||
// boost needs to be included after ndn-cxx, otherwise there will be conflict with _1, _2, ...
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class NlsrRunner
|
||||
{
|
||||
public:
|
||||
class Error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit
|
||||
Error(const std::string& what)
|
||||
: std::runtime_error(what)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
NlsrRunner(std::string& configFileName, bool isDaemonProcess);
|
||||
|
||||
void
|
||||
run();
|
||||
|
||||
static void
|
||||
printUsage(const std::string& programName);
|
||||
|
||||
private:
|
||||
boost::asio::io_service m_ioService;
|
||||
ndn::Scheduler m_scheduler;
|
||||
ndn::Face m_face;
|
||||
ndn::KeyChain m_keyChain;
|
||||
Nlsr m_nlsr;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_NLSR_RUNNER_HPP
|
||||
+82
-71
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -39,9 +39,10 @@ const ndn::Name Nlsr::LOCALHOST_PREFIX = ndn::Name("/localhost/nlsr");
|
||||
using namespace ndn;
|
||||
using namespace std;
|
||||
|
||||
Nlsr::Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::Face& face)
|
||||
Nlsr::Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::Face& face, ndn::KeyChain& keyChain)
|
||||
: m_nlsrFace(face)
|
||||
, m_scheduler(scheduler)
|
||||
, m_keyChain(keyChain)
|
||||
, m_confParam()
|
||||
, m_adjacencyList()
|
||||
, m_namePrefixList()
|
||||
@@ -57,11 +58,10 @@ Nlsr::Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::F
|
||||
, m_fib(m_nlsrFace, scheduler, m_adjacencyList, m_confParam, m_keyChain)
|
||||
, m_namePrefixTable(*this)
|
||||
, m_syncLogicHandler(m_nlsrFace, m_nlsrLsdb, m_confParam, m_sequencingManager)
|
||||
, m_helloProtocol(*this, scheduler)
|
||||
, m_lsdbDatasetHandler(m_nlsrLsdb,
|
||||
m_nlsrFace,
|
||||
m_confParam.getRouterPrefix(),
|
||||
m_keyChain)
|
||||
, m_helloProtocol(*this, scheduler)
|
||||
, m_certificateCache(new ndn::CertificateCacheTtl(ioService))
|
||||
, m_validator(m_nlsrFace, DEFAULT_BROADCAST_PREFIX, m_certificateCache, m_certStore)
|
||||
, m_prefixUpdateProcessor(m_nlsrFace,
|
||||
@@ -72,18 +72,19 @@ Nlsr::Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::F
|
||||
m_keyChain,
|
||||
m_certificateCache,
|
||||
m_certStore)
|
||||
, m_dispatcher(m_nlsrFace, m_keyChain, m_signingInfo)
|
||||
, m_faceMonitor(m_nlsrFace)
|
||||
, m_firstHelloInterval(FIRST_HELLO_INTERVAL_DEFAULT)
|
||||
{
|
||||
m_faceMonitor.onNotification.connect(bind(&Nlsr::onFaceEventNotification, this, _1));
|
||||
m_faceMonitor.onNotification.connect(std::bind(&Nlsr::onFaceEventNotification, this, _1));
|
||||
m_faceMonitor.start();
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::registrationFailed(const ndn::Name& name)
|
||||
{
|
||||
std::cerr << "ERROR: Failed to register prefix in local hub's daemon" << endl;
|
||||
throw Error("Error: Prefix registration failed");
|
||||
std::cerr << "ERROR: Failed to register prefix in local hub's daemon" << std::endl;
|
||||
BOOST_THROW_EXCEPTION(Error("Error: Prefix registration failed"));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -111,11 +112,11 @@ Nlsr::setInfoInterestFilter()
|
||||
ndn::Name name(m_confParam.getRouterPrefix());
|
||||
_LOG_DEBUG("Setting interest filter for name: " << name);
|
||||
getNlsrFace().setInterestFilter(name,
|
||||
ndn::bind(&HelloProtocol::processInterest,
|
||||
std::bind(&HelloProtocol::processInterest,
|
||||
&m_helloProtocol, _1, _2),
|
||||
ndn::bind(&Nlsr::onRegistrationSuccess, this, _1),
|
||||
ndn::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_defaultIdentity,
|
||||
std::bind(&Nlsr::onRegistrationSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_signingInfo,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
}
|
||||
|
||||
@@ -127,20 +128,22 @@ Nlsr::setLsaInterestFilter()
|
||||
name.append(m_confParam.getRouterName());
|
||||
_LOG_DEBUG("Setting interest filter for name: " << name);
|
||||
getNlsrFace().setInterestFilter(name,
|
||||
ndn::bind(&Lsdb::processInterest,
|
||||
std::bind(&Lsdb::processInterest,
|
||||
&m_nlsrLsdb, _1, _2),
|
||||
ndn::bind(&Nlsr::onRegistrationSuccess, this, _1),
|
||||
ndn::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_defaultIdentity,
|
||||
std::bind(&Nlsr::onRegistrationSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_signingInfo,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::setStrategies()
|
||||
{
|
||||
std::string strategy("ndn:/localhost/nfd/strategy/broadcast");
|
||||
const std::string strategy("ndn:/localhost/nfd/strategy/multicast");
|
||||
|
||||
ndn::Name broadcastKeyPrefix = DEFAULT_BROADCAST_PREFIX;
|
||||
broadcastKeyPrefix.append("KEYS");
|
||||
|
||||
m_fib.setStrategy(m_confParam.getLsaPrefix(), strategy, 0);
|
||||
m_fib.setStrategy(broadcastKeyPrefix, strategy, 0);
|
||||
m_fib.setStrategy(m_confParam.getChronosyncPrefix(), strategy, 0);
|
||||
@@ -154,7 +157,7 @@ Nlsr::daemonize()
|
||||
process_id = fork();
|
||||
if (process_id < 0){
|
||||
std::cerr << "Daemonization failed!" << std::endl;
|
||||
throw Error("Error: Daemonization process- fork failed!");
|
||||
BOOST_THROW_EXCEPTION(Error("Error: Daemonization process- fork failed!"));
|
||||
}
|
||||
if (process_id > 0) {
|
||||
_LOG_DEBUG("Process daemonized. Process id: " << process_id);
|
||||
@@ -164,11 +167,11 @@ Nlsr::daemonize()
|
||||
umask(0);
|
||||
sid = setsid();
|
||||
if(sid < 0) {
|
||||
throw Error("Error: Daemonization process- setting id failed!");
|
||||
BOOST_THROW_EXCEPTION(Error("Error: Daemonization process- setting id failed!"));
|
||||
}
|
||||
|
||||
if (chdir("/") < 0) {
|
||||
throw Error("Error: Daemonization process-chdir failed!");
|
||||
BOOST_THROW_EXCEPTION(Error("Error: Daemonization process-chdir failed!"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,22 +180,23 @@ Nlsr::initialize()
|
||||
{
|
||||
_LOG_DEBUG("Initializing Nlsr");
|
||||
m_confParam.buildRouterPrefix();
|
||||
m_lsdbDatasetHandler.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());
|
||||
m_sequencingManager.setSeqFileName(m_confParam.getSeqFileDir());
|
||||
m_sequencingManager.initiateSeqNoFromFile();
|
||||
m_sequencingManager.initiateSeqNoFromFile(m_confParam.getHyperbolicState());
|
||||
|
||||
m_syncLogicHandler.createSyncSocket(m_confParam.getChronosyncPrefix());
|
||||
|
||||
/* Logging start */
|
||||
// Logging start
|
||||
m_confParam.writeLog();
|
||||
m_adjacencyList.writeLog();
|
||||
m_namePrefixList.writeLog();
|
||||
/* Logging end */
|
||||
// Logging end
|
||||
initializeKey();
|
||||
setStrategies();
|
||||
_LOG_DEBUG("Default NLSR identity: " << m_defaultIdentity);
|
||||
_LOG_DEBUG("Default NLSR identity: " << m_signingInfo.getSignerName());
|
||||
setInfoInterestFilter();
|
||||
setLsaInterestFilter();
|
||||
|
||||
@@ -202,7 +206,11 @@ Nlsr::initialize()
|
||||
m_routingTable.setRoutingCalcInterval(m_confParam.getRoutingCalcInterval());
|
||||
|
||||
m_nlsrLsdb.buildAndInstallOwnNameLsa();
|
||||
m_nlsrLsdb.buildAndInstallOwnCoordinateLsa();
|
||||
|
||||
// Install coordinate LSAs if using HR or dry-run HR.
|
||||
if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_nlsrLsdb.buildAndInstallOwnCoordinateLsa();
|
||||
}
|
||||
|
||||
registerKeyPrefix();
|
||||
registerLocalhostPrefix();
|
||||
@@ -223,22 +231,21 @@ Nlsr::initialize()
|
||||
void
|
||||
Nlsr::initializeKey()
|
||||
{
|
||||
m_defaultIdentity = m_confParam.getRouterPrefix();
|
||||
m_defaultIdentity.append("NLSR");
|
||||
ndn::Name defaultIdentity = m_confParam.getRouterPrefix();
|
||||
defaultIdentity.append("NLSR");
|
||||
|
||||
try
|
||||
{
|
||||
m_keyChain.deleteIdentity(m_defaultIdentity);
|
||||
try {
|
||||
m_keyChain.deleteIdentity(defaultIdentity);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
catch (const std::exception& e) {
|
||||
}
|
||||
m_signingInfo = ndn::security::SigningInfo(ndn::security::SigningInfo::SIGNER_TYPE_ID, defaultIdentity);
|
||||
|
||||
ndn::Name keyName = m_keyChain.generateRsaKeyPairAsDefault(m_defaultIdentity, true);
|
||||
ndn::Name keyName = m_keyChain.generateRsaKeyPairAsDefault(defaultIdentity, true);
|
||||
|
||||
ndn::shared_ptr<ndn::IdentityCertificate> certificate =
|
||||
ndn::make_shared<ndn::IdentityCertificate>();
|
||||
ndn::shared_ptr<ndn::PublicKey> pubKey = m_keyChain.getPublicKey(keyName);
|
||||
std::shared_ptr<ndn::IdentityCertificate> certificate =
|
||||
std::make_shared<ndn::IdentityCertificate>();
|
||||
std::shared_ptr<ndn::PublicKey> pubKey = m_keyChain.getPublicKey(keyName);
|
||||
Name certificateName = keyName.getPrefix(-1);
|
||||
certificateName.append("KEY").append(keyName.get(-1)).append("ID-CERT").appendVersion();
|
||||
certificate->setName(certificateName);
|
||||
@@ -262,11 +269,11 @@ Nlsr::registerKeyPrefix()
|
||||
ndn::Name keyPrefix = DEFAULT_BROADCAST_PREFIX;
|
||||
keyPrefix.append("KEYS");
|
||||
m_nlsrFace.setInterestFilter(keyPrefix,
|
||||
ndn::bind(&Nlsr::onKeyInterest,
|
||||
std::bind(&Nlsr::onKeyInterest,
|
||||
this, _1, _2),
|
||||
ndn::bind(&Nlsr::onKeyPrefixRegSuccess, this, _1),
|
||||
ndn::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_defaultIdentity,
|
||||
std::bind(&Nlsr::onKeyPrefixRegSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_signingInfo,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
|
||||
}
|
||||
@@ -274,8 +281,16 @@ Nlsr::registerKeyPrefix()
|
||||
void
|
||||
Nlsr::registerLocalhostPrefix()
|
||||
{
|
||||
_LOG_TRACE("Registering prefix: " << LOCALHOST_PREFIX);
|
||||
|
||||
_LOG_TRACE("Registering prefix with dispatcher and Face: " << LOCALHOST_PREFIX);
|
||||
// All dispatcher-related sub-prefixes *must* be registered before
|
||||
// the top-level prefixes are added.
|
||||
try {
|
||||
m_dispatcher.addTopPrefix(LOCALHOST_PREFIX, false, m_signingInfo);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
_LOG_ERROR("Error setting top-level prefix in dispatcher: " << e.what() << "\n");
|
||||
registrationFailed(LOCALHOST_PREFIX);
|
||||
}
|
||||
m_nlsrFace.registerPrefix(LOCALHOST_PREFIX,
|
||||
std::bind(&Nlsr::onLocalhostRegistrationSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1));
|
||||
@@ -295,12 +310,12 @@ Nlsr::onKeyInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
else if (certName[-1].toUri() != "ID-CERT")
|
||||
return; //Wrong key interest.
|
||||
|
||||
ndn::shared_ptr<const ndn::IdentityCertificate> cert = getCertificate(certName);
|
||||
std::shared_ptr<const ndn::IdentityCertificate> cert = getCertificate(certName);
|
||||
|
||||
if (!static_cast<bool>(cert))
|
||||
return; // cert is not found
|
||||
|
||||
ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>();
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>();
|
||||
data->setName(interestName);
|
||||
data->setContent(cert->wireEncode());
|
||||
m_keyChain.signWithSha256(*data);
|
||||
@@ -319,10 +334,10 @@ Nlsr::onDestroyFaceSuccess(const ndn::nfd::ControlParameters& commandSuccessResu
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::onDestroyFaceFailure(int32_t code, const std::string& error)
|
||||
Nlsr::onDestroyFaceFailure(const ndn::nfd::ControlResponse& response)
|
||||
{
|
||||
std::cerr << error << " (code: " << code << ")";
|
||||
throw Error("Error: Face destruction failed");
|
||||
std::cerr << response.getText() << " (code: " << response.getCode() << ")";
|
||||
BOOST_THROW_EXCEPTION(Error("Error: Face destruction failed"));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -332,8 +347,8 @@ Nlsr::destroyFaces()
|
||||
for (std::list<Adjacent>::iterator it = adjacents.begin();
|
||||
it != adjacents.end(); it++) {
|
||||
m_fib.destroyFace((*it).getConnectingFaceUri(),
|
||||
ndn::bind(&Nlsr::onDestroyFaceSuccess, this, _1),
|
||||
ndn::bind(&Nlsr::onDestroyFaceFailure, this, _1, _2));
|
||||
std::bind(&Nlsr::onDestroyFaceSuccess, this, _1),
|
||||
std::bind(&Nlsr::onDestroyFaceFailure, this, _1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,18 +371,21 @@ Nlsr::onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNo
|
||||
|
||||
adjacent->setFaceId(0);
|
||||
|
||||
// Only trigger an Adjacency LSA build if this node is changing from ACTIVE to INACTIVE
|
||||
// since this rebuild will effectively cancel the previous Adjacency LSA refresh event
|
||||
// and schedule a new one further in the future.
|
||||
// Only trigger an Adjacency LSA build if this node is changing
|
||||
// from ACTIVE to INACTIVE since this rebuild will effectively
|
||||
// cancel the previous Adjacency LSA refresh event and schedule
|
||||
// a new one further in the future.
|
||||
//
|
||||
// Continuously scheduling the refresh in the future will block the router from refreshing
|
||||
// its Adjacency LSA. Since other routers' Name prefixes' expiration times are updated
|
||||
// when this router refreshes its Adjacency LSA, the other routers' prefixes will expire
|
||||
// and be removed from the RIB.
|
||||
// Continuously scheduling the refresh in the future will block
|
||||
// the router from refreshing its Adjacency LSA. Since other
|
||||
// routers' Name prefixes' expiration times are updated when
|
||||
// this router refreshes its Adjacency LSA, the other routers'
|
||||
// prefixes will expire and be removed from the RIB.
|
||||
//
|
||||
// This check is required to fix Bug #2733 for now. This check would be unnecessary
|
||||
// to fix Bug #2733 when Issue #2732 is completed, but the check also helps with
|
||||
// optimization so it can remain even when Issue #2732 is implemented.
|
||||
// This check is required to fix Bug #2733 for now. This check
|
||||
// would be unnecessary to fix Bug #2733 when Issue #2732 is
|
||||
// completed, but the check also helps with optimization so it
|
||||
// can remain even when Issue #2732 is implemented.
|
||||
if (adjacent->getStatus() == Adjacent::STATUS_ACTIVE) {
|
||||
adjacent->setStatus(Adjacent::STATUS_INACTIVE);
|
||||
|
||||
@@ -375,7 +393,12 @@ Nlsr::onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNo
|
||||
// has met the HELLO retry threshold
|
||||
adjacent->setInterestTimedOutNo(m_confParam.getInterestRetryNumber());
|
||||
|
||||
m_nlsrLsdb.scheduleAdjLsaBuild();
|
||||
if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
getRoutingTable().scheduleRoutingTableCalculation(*this);
|
||||
}
|
||||
else {
|
||||
m_nlsrLsdb.scheduleAdjLsaBuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -388,16 +411,4 @@ Nlsr::startEventLoop()
|
||||
m_nlsrFace.processEvents();
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::usage(const string& progname)
|
||||
{
|
||||
std::cout << "Usage: " << progname << " [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;
|
||||
}
|
||||
|
||||
|
||||
} // namespace nlsr
|
||||
+33
-19
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -19,18 +19,20 @@
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
#ifndef NLSR_HPP
|
||||
#define NLSR_HPP
|
||||
#ifndef NLSR_NLSR_HPP
|
||||
#define NLSR_NLSR_HPP
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <stdexcept>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
#include <ndn-cxx/security/certificate-cache-ttl.hpp>
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
#include <ndn-cxx/management/nfd-face-event-notification.hpp>
|
||||
#include <ndn-cxx/management/nfd-face-monitor.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/face-event-notification.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/face-monitor.hpp>
|
||||
#include <ndn-cxx/mgmt/dispatcher.hpp>
|
||||
|
||||
#include "adjacency-list.hpp"
|
||||
#include "common.hpp"
|
||||
@@ -68,7 +70,7 @@ class Nlsr
|
||||
};
|
||||
|
||||
public:
|
||||
Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::Face& face);
|
||||
Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::Face& face, ndn::KeyChain& keyChain);
|
||||
|
||||
void
|
||||
registrationFailed(const ndn::Name& name);
|
||||
@@ -88,9 +90,6 @@ public:
|
||||
void
|
||||
startEventLoop();
|
||||
|
||||
void
|
||||
usage(const std::string& progname);
|
||||
|
||||
std::string
|
||||
getConfFileName() const
|
||||
{
|
||||
@@ -229,6 +228,12 @@ public:
|
||||
return m_syncLogicHandler;
|
||||
}
|
||||
|
||||
LsdbDatasetInterestHandler&
|
||||
getLsdbDatasetHandler()
|
||||
{
|
||||
return m_lsdbDatasetHandler;
|
||||
}
|
||||
|
||||
void
|
||||
initialize();
|
||||
|
||||
@@ -249,12 +254,12 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
loadCertToPublish(ndn::shared_ptr<ndn::IdentityCertificate> certificate)
|
||||
loadCertToPublish(std::shared_ptr<ndn::IdentityCertificate> certificate)
|
||||
{
|
||||
m_certStore.insert(certificate);
|
||||
}
|
||||
|
||||
ndn::shared_ptr<const ndn::IdentityCertificate>
|
||||
std::shared_ptr<const ndn::IdentityCertificate>
|
||||
getCertificate(const ndn::Name& certificateNameWithoutVersion)
|
||||
{
|
||||
shared_ptr<const ndn::IdentityCertificate> cert =
|
||||
@@ -285,6 +290,12 @@ public:
|
||||
return m_prefixUpdateProcessor;
|
||||
}
|
||||
|
||||
ndn::mgmt::Dispatcher&
|
||||
getDispatcher()
|
||||
{
|
||||
return m_dispatcher;
|
||||
}
|
||||
|
||||
void
|
||||
createFace(const std::string& faceUri,
|
||||
const CommandSucceedCallback& onSuccess,
|
||||
@@ -307,7 +318,7 @@ public:
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
void
|
||||
addCertificateToCache(ndn::shared_ptr<ndn::IdentityCertificate> certificate)
|
||||
addCertificateToCache(std::shared_ptr<ndn::IdentityCertificate> certificate)
|
||||
{
|
||||
if (certificate != nullptr) {
|
||||
m_certificateCache->insertCertificate(certificate);
|
||||
@@ -337,7 +348,7 @@ private:
|
||||
onDestroyFaceSuccess(const ndn::nfd::ControlParameters& commandSuccessResult);
|
||||
|
||||
void
|
||||
onDestroyFaceFailure(int32_t code, const std::string& error);
|
||||
onDestroyFaceFailure(const ndn::nfd::ControlResponse& response);
|
||||
|
||||
void
|
||||
onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNotification);
|
||||
@@ -354,6 +365,7 @@ public:
|
||||
private:
|
||||
ndn::Face& m_nlsrFace;
|
||||
ndn::Scheduler& m_scheduler;
|
||||
ndn::KeyChain& m_keyChain;
|
||||
ConfParameter m_confParam;
|
||||
AdjacencyList m_adjacencyList;
|
||||
NamePrefixList m_namePrefixList;
|
||||
@@ -369,23 +381,25 @@ private:
|
||||
Fib m_fib;
|
||||
NamePrefixTable m_namePrefixTable;
|
||||
SyncLogicHandler m_syncLogicHandler;
|
||||
HelloProtocol m_helloProtocol;
|
||||
LsdbDatasetInterestHandler m_lsdbDatasetHandler;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
HelloProtocol m_helloProtocol;
|
||||
|
||||
private:
|
||||
ndn::shared_ptr<ndn::CertificateCacheTtl> m_certificateCache;
|
||||
std::shared_ptr<ndn::CertificateCacheTtl> m_certificateCache;
|
||||
security::CertificateStore m_certStore;
|
||||
Validator m_validator;
|
||||
ndn::KeyChain m_keyChain;
|
||||
ndn::Name m_defaultIdentity;
|
||||
ndn::security::SigningInfo m_signingInfo;
|
||||
ndn::Name m_defaultCertName;
|
||||
update::PrefixUpdateProcessor m_prefixUpdateProcessor;
|
||||
ndn::mgmt::Dispatcher m_dispatcher;
|
||||
|
||||
ndn::nfd::FaceMonitor m_faceMonitor;
|
||||
|
||||
uint32_t m_firstHelloInterval;
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_HPP
|
||||
#endif // NLSR_NLSR_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -78,6 +78,7 @@ CoordinateLsaPublisher::CoordinateLsaPublisher(Lsdb& lsdb,
|
||||
{
|
||||
}
|
||||
|
||||
// Returns the list of coordinate LSAs represented by this object.
|
||||
std::list<tlv::CoordinateLsa>
|
||||
CoordinateLsaPublisher::getTlvLsas()
|
||||
{
|
||||
@@ -113,6 +114,8 @@ NameLsaPublisher::NameLsaPublisher(Lsdb& lsdb,
|
||||
{
|
||||
}
|
||||
|
||||
// Returns the list of name LSAs represented by this object.
|
||||
// Note: each name LSA has a list of prefixes as well.
|
||||
std::list<tlv::NameLsa>
|
||||
NameLsaPublisher::getTlvLsas()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -63,10 +63,11 @@ protected:
|
||||
getTlvLsas() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Abstraction to publish adjacency lsa dataset
|
||||
* \sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
/*! \brief Class to publish adjacency lsa dataset
|
||||
|
||||
\sa https://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
|
||||
*/
|
||||
class AdjacencyLsaPublisher : public LsaPublisher<tlv::AdjacencyLsa>
|
||||
{
|
||||
public:
|
||||
@@ -74,6 +75,7 @@ public:
|
||||
ndn::Face& face,
|
||||
ndn::KeyChain& keyChain);
|
||||
|
||||
/*! \brief Returns the adj. LSAs represented by this object. */
|
||||
std::list<tlv::AdjacencyLsa>
|
||||
getTlvLsas();
|
||||
|
||||
@@ -84,10 +86,9 @@ private:
|
||||
const std::list<AdjLsa>& m_adjacencyLsas;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Abstraction to publish coordinate lsa dataset
|
||||
* \sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
/*! \brief Class to publish coordinate lsa dataset
|
||||
\sa https://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class CoordinateLsaPublisher : public LsaPublisher<tlv::CoordinateLsa>
|
||||
{
|
||||
public:
|
||||
@@ -95,6 +96,7 @@ public:
|
||||
ndn::Face& face,
|
||||
ndn::KeyChain& keyChain);
|
||||
|
||||
/*! \brief Returns the cor. LSAs represented by this object. */
|
||||
std::list<tlv::CoordinateLsa>
|
||||
getTlvLsas();
|
||||
|
||||
@@ -105,17 +107,16 @@ private:
|
||||
const std::list<CoordinateLsa>& m_coordinateLsas;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Abstraction to publish name lsa dataset
|
||||
* \sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
/*! \brief Class to publish name lsa dataset
|
||||
\sa https://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class NameLsaPublisher : public LsaPublisher<tlv::NameLsa>
|
||||
{
|
||||
public:
|
||||
NameLsaPublisher(Lsdb& lsdb,
|
||||
ndn::Face& face,
|
||||
ndn::KeyChain& keyChain);
|
||||
|
||||
/*! \brief Returns the name LSAs represented by this object. */
|
||||
std::list<tlv::NameLsa>
|
||||
getTlvLsas();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -19,13 +19,20 @@
|
||||
* 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 "logger.hpp"
|
||||
#include "nlsr.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/management/nfd-control-response.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/control-response.hpp>
|
||||
#include <ndn-cxx/util/regex.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
@@ -37,10 +44,8 @@ const uint32_t LsdbDatasetInterestHandler::ERROR_CODE_UNSUPPORTED_COMMAND = 501;
|
||||
|
||||
LsdbDatasetInterestHandler::LsdbDatasetInterestHandler(Lsdb& lsdb,
|
||||
ndn::Face& face,
|
||||
const ndn::Name& routerName,
|
||||
ndn::KeyChain& keyChain)
|
||||
: LOCALHOST_COMMAND_PREFIX(ndn::Name(Nlsr::LOCALHOST_PREFIX).append(Lsdb::NAME_COMPONENT))
|
||||
, ROUTER_NAME_COMMAND_PREFIX(ndn::Name(routerName).append(Lsdb::NAME_COMPONENT))
|
||||
, m_face(face)
|
||||
, m_keyChain(keyChain)
|
||||
, m_adjacencyLsaPublisher(lsdb, face, keyChain)
|
||||
@@ -66,10 +71,10 @@ LsdbDatasetInterestHandler::startListeningOnLocalhost()
|
||||
void
|
||||
LsdbDatasetInterestHandler::startListeningOnRouterPrefix()
|
||||
{
|
||||
_LOG_DEBUG("Setting interest filter for: " << ROUTER_NAME_COMMAND_PREFIX);
|
||||
m_face.setInterestFilter(ROUTER_NAME_COMMAND_PREFIX,
|
||||
_LOG_DEBUG("Setting interest filter for: " << m_routerNameCommandPrefix);
|
||||
m_face.setInterestFilter(m_routerNameCommandPrefix,
|
||||
std::bind(&LsdbDatasetInterestHandler::onInterest, this, _2,
|
||||
std::cref(ROUTER_NAME_COMMAND_PREFIX)));
|
||||
std::cref(m_routerNameCommandPrefix)));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -94,7 +99,6 @@ LsdbDatasetInterestHandler::isValidCommandPrefix(const ndn::Interest& interest,
|
||||
{
|
||||
size_t commandSize = interest.getName().size();
|
||||
|
||||
// Does the Interest match the command prefix with one additional component?
|
||||
return (commandSize == commandPrefix.size() + 1 && commandPrefix.isPrefixOf(interest.getName()));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -29,9 +29,9 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
/**
|
||||
* @brief Abstraction to publish all lsa dataset
|
||||
* \sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
/*!
|
||||
\brief Class to publish all lsa dataset
|
||||
\sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class LsdbDatasetInterestHandler
|
||||
{
|
||||
@@ -48,7 +48,6 @@ public:
|
||||
|
||||
LsdbDatasetInterestHandler(Lsdb& lsdb,
|
||||
ndn::Face& face,
|
||||
const ndn::Name& routerName,
|
||||
ndn::KeyChain& keyChain);
|
||||
|
||||
void
|
||||
@@ -63,10 +62,16 @@ public:
|
||||
return LOCALHOST_COMMAND_PREFIX;
|
||||
}
|
||||
|
||||
const ndn::Name&
|
||||
ndn::Name&
|
||||
getRouterNameCommandPrefix()
|
||||
{
|
||||
return ROUTER_NAME_COMMAND_PREFIX;
|
||||
return m_routerNameCommandPrefix;
|
||||
}
|
||||
|
||||
void
|
||||
setRouterNameCommandPrefix(const ndn::Name& routerName) {
|
||||
m_routerNameCommandPrefix = routerName;
|
||||
m_routerNameCommandPrefix.append(Lsdb::NAME_COMPONENT);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -84,7 +89,7 @@ private:
|
||||
|
||||
private:
|
||||
const ndn::Name LOCALHOST_COMMAND_PREFIX;
|
||||
const ndn::Name ROUTER_NAME_COMMAND_PREFIX;
|
||||
ndn::Name m_routerNameCommandPrefix;
|
||||
|
||||
ndn::Face& m_face;
|
||||
ndn::KeyChain& m_keyChain;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -30,9 +30,9 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
/**
|
||||
* @brief Abstraction to publish lsdb status dataset
|
||||
* \sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
/*!
|
||||
\brief Publishes lsdb status dataset
|
||||
\sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class LsdbStatusPublisher : public SegmentPublisher<ndn::Face>
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, Regents of the University of California,
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -31,11 +31,11 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
/** \brief provides a publisher of Status Dataset or other segmented octet stream
|
||||
* \sa http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
|
||||
/*! \brief provides a publisher of Status Dataset or other segmented octet stream
|
||||
\sa https://redmine.named-data.net/projects/nfd/wiki/StatusDataset
|
||||
*/
|
||||
template <class FaceBase>
|
||||
class SegmentPublisher : ndn::noncopyable
|
||||
class SegmentPublisher : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
SegmentPublisher(FaceBase& face,
|
||||
@@ -65,10 +65,11 @@ public:
|
||||
return ndn::time::milliseconds(1000);
|
||||
}
|
||||
|
||||
/** \brief Publish data under provided prefix
|
||||
/*! \brief Publish data under provided prefix
|
||||
*/
|
||||
void
|
||||
publish(const ndn::Name& prefix)
|
||||
publish(const ndn::Name& prefix,
|
||||
const ndn::security::SigningInfo& signingInfo = ndn::security::KeyChain::DEFAULT_SIGNING_INFO)
|
||||
{
|
||||
ndn::EncodingBuffer buffer;
|
||||
generate(buffer);
|
||||
@@ -90,7 +91,7 @@ public:
|
||||
ndn::Name segmentName(segmentPrefix);
|
||||
segmentName.appendSegment(segmentNo);
|
||||
|
||||
ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>(segmentName);
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>(segmentName);
|
||||
data->setContent(segmentBegin, segmentEnd - segmentBegin);
|
||||
data->setFreshnessPeriod(m_freshnessPeriod);
|
||||
|
||||
@@ -99,22 +100,22 @@ public:
|
||||
data->setFinalBlockId(segmentName[-1]);
|
||||
}
|
||||
|
||||
publishSegment(data);
|
||||
publishSegment(data, signingInfo);
|
||||
++segmentNo;
|
||||
} while (segmentBegin < end);
|
||||
}
|
||||
|
||||
protected:
|
||||
/** \brief In a derived class, write the octets into outBuffer.
|
||||
/*! \brief In a derived class, write the octets into outBuffer.
|
||||
*/
|
||||
virtual size_t
|
||||
generate(ndn::EncodingBuffer& outBuffer) = 0;
|
||||
|
||||
private:
|
||||
void
|
||||
publishSegment(ndn::shared_ptr<ndn::Data>& data)
|
||||
publishSegment(std::shared_ptr<ndn::Data>& data, const ndn::security::SigningInfo& signingInfo)
|
||||
{
|
||||
m_keyChain.sign(*data);
|
||||
m_keyChain.sign(*data, signingInfo);
|
||||
m_face.put(*data);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
@@ -21,7 +21,6 @@
|
||||
*
|
||||
**/
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <utility>
|
||||
|
||||
#include "common.hpp"
|
||||
@@ -36,11 +35,10 @@ void
|
||||
FaceMap::writeLog()
|
||||
{
|
||||
_LOG_DEBUG("------- Face Map-----------");
|
||||
for(std::list<FaceMapEntry>::iterator it = m_table.begin();
|
||||
it != m_table.end(); ++it) {
|
||||
_LOG_DEBUG("Face Map Entry (FaceUri: " << (*it).getFaceUri() << " Face Id: "
|
||||
<< (*it).getFaceId() << ")");
|
||||
for (const auto& it : m_table) {
|
||||
_LOG_DEBUG("Face Map Entry (FaceUri: " << (it.second).getFaceUri()
|
||||
<< " Face Id: " << (it.second).getFaceId() << ")");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace NLSR
|
||||
} // namespace nlsr
|
||||
+15
-19
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
@@ -17,8 +17,6 @@
|
||||
* 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/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
#ifndef NLSR_FACE_MAP_HPP
|
||||
#define NLSR_FACE_MAP_HPP
|
||||
@@ -26,9 +24,12 @@
|
||||
#include <ndn-cxx/common.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class FaceMapEntry {
|
||||
class FaceMapEntry
|
||||
{
|
||||
|
||||
public:
|
||||
FaceMapEntry(const std::string& faceUri, uint32_t faceId)
|
||||
@@ -72,7 +73,8 @@ private:
|
||||
uint32_t m_faceId;
|
||||
};
|
||||
|
||||
class FaceMap {
|
||||
class FaceMap
|
||||
{
|
||||
|
||||
public:
|
||||
FaceMap()
|
||||
@@ -87,15 +89,12 @@ public:
|
||||
update(const std::string& faceUri, uint32_t faceId)
|
||||
{
|
||||
FaceMapEntry fme(faceUri, faceId);
|
||||
std::list<FaceMapEntry>::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
bind(&FaceMapEntry::compare,
|
||||
&fme, _1));
|
||||
std::map<std::string, FaceMapEntry>::iterator it = m_table.find(faceUri);
|
||||
if (it == m_table.end()) {
|
||||
m_table.push_back(fme);
|
||||
m_table.emplace(faceUri, fme);
|
||||
}
|
||||
else {
|
||||
(*it).setFaceId(fme.getFaceId());
|
||||
(it->second).setFaceId(fme.getFaceId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,12 +102,9 @@ public:
|
||||
getFaceId(const std::string& faceUri)
|
||||
{
|
||||
FaceMapEntry fme(faceUri, 0);
|
||||
std::list<FaceMapEntry>::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
bind(&FaceMapEntry::compare,
|
||||
&fme, _1));
|
||||
std::map<std::string, FaceMapEntry>::iterator it = m_table.find(faceUri);
|
||||
if (it != m_table.end()) {
|
||||
return (*it).getFaceId();
|
||||
return (it->second).getFaceId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -117,9 +113,9 @@ public:
|
||||
writeLog();
|
||||
|
||||
private:
|
||||
std::list<FaceMapEntry> m_table;
|
||||
std::map<std::string, FaceMapEntry> m_table;
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_FACE_MAP_HPP
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
@@ -40,4 +40,4 @@ FibEntry::writeLog()
|
||||
m_nexthopList.writeLog();
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
@@ -113,6 +113,6 @@ private:
|
||||
NexthopList m_nexthopList;
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_FIB_ENTRY_HPP
|
||||
+53
-69
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
@@ -16,13 +16,12 @@
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
#include <cmath>
|
||||
#include <ndn-cxx/common.hpp>
|
||||
#include <ndn-cxx/encoding/nfd-constants.hpp>
|
||||
|
||||
#include "adjacency-list.hpp"
|
||||
#include "common.hpp"
|
||||
@@ -41,19 +40,12 @@ const uint64_t Fib::GRACE_PERIOD = 10;
|
||||
using namespace std;
|
||||
using namespace ndn;
|
||||
|
||||
static bool
|
||||
fibEntryNameCompare(const FibEntry& fibEntry, const ndn::Name& name)
|
||||
{
|
||||
return fibEntry.getName() == name;
|
||||
}
|
||||
|
||||
void
|
||||
Fib::cancelScheduledExpiringEvent(EventId eid)
|
||||
{
|
||||
m_scheduler.cancelEvent(eid);
|
||||
}
|
||||
|
||||
|
||||
ndn::EventId
|
||||
Fib::scheduleEntryExpiration(const ndn::Name& name, int32_t feSeqNum,
|
||||
const ndn::time::seconds& expTime)
|
||||
@@ -61,27 +53,25 @@ Fib::scheduleEntryExpiration(const ndn::Name& name, int32_t feSeqNum,
|
||||
_LOG_DEBUG("Fib::scheduleEntryExpiration Called");
|
||||
_LOG_INFO("Name: " << name << " Seq Num: " << feSeqNum);
|
||||
|
||||
return m_scheduler.scheduleEvent(expTime, ndn::bind(&Fib::remove, this, name));
|
||||
return m_scheduler.scheduleEvent(expTime, std::bind(&Fib::remove, this, name));
|
||||
}
|
||||
|
||||
void
|
||||
Fib::remove(const ndn::Name& name)
|
||||
{
|
||||
_LOG_DEBUG("Fib::remove called");
|
||||
std::list<FibEntry>::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
bind(&fibEntryNameCompare, _1, name));
|
||||
std::map<ndn::Name, FibEntry>::iterator it = m_table.find(name);
|
||||
if (it != m_table.end()) {
|
||||
for (std::list<NextHop>::iterator nhit =
|
||||
(*it).getNexthopList().getNextHops().begin();
|
||||
nhit != (*it).getNexthopList().getNextHops().end(); nhit++) {
|
||||
for (std::set<NextHop, NextHopComparator>::iterator nhit =
|
||||
(it->second).getNexthopList().getNextHops().begin();
|
||||
nhit != (it->second).getNexthopList().getNextHops().end(); nhit++) {
|
||||
//remove entry from NDN-FIB
|
||||
if (isPrefixUpdatable(it->getName())) {
|
||||
unregisterPrefix(it->getName(), nhit->getConnectingFaceUri());
|
||||
if (isPrefixUpdatable((it->second).getName())) {
|
||||
unregisterPrefix((it->second).getName(), nhit->getConnectingFaceUri());
|
||||
}
|
||||
}
|
||||
_LOG_DEBUG("Cancelling Scheduled event. Name: " << name);
|
||||
cancelScheduledExpiringEvent((*it).getExpiringEventId());
|
||||
cancelScheduledExpiringEvent((it->second).getExpiringEventId());
|
||||
m_table.erase(it);
|
||||
}
|
||||
}
|
||||
@@ -110,8 +100,6 @@ Fib::addNextHopsToFibEntryAndNfd(FibEntry& entry, NexthopList& hopsToAdd)
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
entry.getNexthopList().sort();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -129,7 +117,7 @@ Fib::removeOldNextHopsFromFibEntryAndNfd(FibEntry& entry, const NexthopList& ins
|
||||
// See if the nexthop is installed in NFD's FIB
|
||||
NexthopList::const_iterator foundIt = std::find_if(installedHops.cbegin(),
|
||||
installedHops.cend(),
|
||||
bind(&compareFaceUri, _1, faceUri));
|
||||
std::bind(&compareFaceUri, _1, faceUri));
|
||||
|
||||
// The next hop is not installed
|
||||
if (foundIt == installedHops.cend()) {
|
||||
@@ -156,9 +144,6 @@ Fib::update(const ndn::Name& name, NexthopList& allHops)
|
||||
{
|
||||
_LOG_DEBUG("Fib::update called");
|
||||
|
||||
// Sort all of the next hops so lower cost hops are prioritized
|
||||
allHops.sort();
|
||||
|
||||
// Get the max possible faces which is the minumum of the configuration setting and
|
||||
// the length of the list of all next hops.
|
||||
unsigned int maxFaces = getNumberOfFacesForName(allHops);
|
||||
@@ -173,9 +158,7 @@ Fib::update(const ndn::Name& name, NexthopList& allHops)
|
||||
hopsToAdd.addNextHop(*it);
|
||||
}
|
||||
|
||||
std::list<FibEntry>::iterator entryIt = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
bind(&fibEntryNameCompare, _1, name));
|
||||
std::map<ndn::Name, FibEntry>::iterator entryIt = m_table.find(name);
|
||||
|
||||
// New FIB entry
|
||||
if (entryIt == m_table.end()) {
|
||||
@@ -198,13 +181,12 @@ Fib::update(const ndn::Name& name, NexthopList& allHops)
|
||||
// Schedule entry to be refreshed
|
||||
entry.setExpiringEventId(scheduleEntryExpiration(name , entry.getSeqNo(),
|
||||
ndn::time::seconds(m_refreshTime)));
|
||||
m_table.push_back(entry);
|
||||
m_table.emplace(name, entry);
|
||||
}
|
||||
else {
|
||||
// Existing FIB entry
|
||||
_LOG_DEBUG("Existing FIB Entry");
|
||||
|
||||
FibEntry& entry = *entryIt;
|
||||
FibEntry& entry = (entryIt->second);
|
||||
|
||||
// Remove empty FIB entry
|
||||
if (hopsToAdd.getSize() == 0) {
|
||||
@@ -235,15 +217,16 @@ void
|
||||
Fib::clean()
|
||||
{
|
||||
_LOG_DEBUG("Fib::clean called");
|
||||
for (std::list<FibEntry>::iterator it = m_table.begin(); it != m_table.end();
|
||||
for (std::map<ndn::Name, FibEntry>::iterator it = m_table.begin();
|
||||
it != m_table.end();
|
||||
++it) {
|
||||
_LOG_DEBUG("Cancelling Scheduled event. Name: " << it->getName());
|
||||
cancelScheduledExpiringEvent((*it).getExpiringEventId());
|
||||
for (std::list<NextHop>::iterator nhit =
|
||||
(*it).getNexthopList().getNextHops().begin();
|
||||
nhit != (*it).getNexthopList().getNextHops().end(); nhit++) {
|
||||
_LOG_DEBUG("Cancelling Scheduled event. Name: " << (it->second).getName());
|
||||
cancelScheduledExpiringEvent((it->second).getExpiringEventId());
|
||||
for (std::set<NextHop, NextHopComparator>::iterator nhit =
|
||||
(it->second).getNexthopList().getNextHops().begin();
|
||||
nhit != (it->second).getNexthopList().getNextHops().end(); nhit++) {
|
||||
//Remove entry from NDN-FIB
|
||||
unregisterPrefix(it->getName(), nhit->getConnectingFaceUri());
|
||||
unregisterPrefix((it->second).getName(), nhit->getConnectingFaceUri());
|
||||
}
|
||||
}
|
||||
if (m_table.size() > 0) {
|
||||
@@ -279,7 +262,7 @@ void
|
||||
Fib::removeHop(NexthopList& nl, const std::string& doNotRemoveHopFaceUri,
|
||||
const ndn::Name& name)
|
||||
{
|
||||
for (std::list<NextHop>::iterator it = nl.getNextHops().begin();
|
||||
for (std::set<NextHop, NextHopComparator>::iterator it = nl.getNextHops().begin();
|
||||
it != nl.getNextHops().end(); ++it) {
|
||||
if (it->getConnectingFaceUri() != doNotRemoveHopFaceUri) {
|
||||
//Remove FIB Entry from NDN-FIB
|
||||
@@ -304,7 +287,7 @@ Fib::destroyFace(const std::string& faceUri,
|
||||
const CommandFailCallback& onFailure)
|
||||
{
|
||||
createFace(faceUri,
|
||||
ndn::bind(&Fib::destroyFaceInNfd, this, _1, onSuccess, onFailure),
|
||||
std::bind(&Fib::destroyFaceInNfd, this, _1, onSuccess, onFailure),
|
||||
onFailure);
|
||||
}
|
||||
|
||||
@@ -335,7 +318,7 @@ Fib::registerPrefix(const ndn::Name& namePrefix, const std::string& faceUri,
|
||||
.setFlags(flags)
|
||||
.setCost(faceCost)
|
||||
.setExpirationPeriod(timeout)
|
||||
.setOrigin(128);
|
||||
.setOrigin(ndn::nfd::ROUTE_ORIGIN_NLSR);
|
||||
|
||||
_LOG_DEBUG("Registering prefix: " << namePrefix << " Face Uri: " << faceUri
|
||||
<< " Face Id: " << faceId);
|
||||
@@ -368,9 +351,9 @@ Fib::registerPrefix(const ndn::Name& namePrefix,
|
||||
.setFlags(flags)
|
||||
.setCost(faceCost)
|
||||
.setExpirationPeriod(timeout)
|
||||
.setOrigin(128);
|
||||
.setOrigin(ndn::nfd::ROUTE_ORIGIN_NLSR);
|
||||
createFace(faceUri,
|
||||
ndn::bind(static_cast<RegisterPrefixCallback>(&Fib::registerPrefixInNfd),
|
||||
std::bind(static_cast<RegisterPrefixCallback>(&Fib::registerPrefixInNfd),
|
||||
this, _1, parameters, times, onSuccess, onFailure),
|
||||
onFailure);
|
||||
}
|
||||
@@ -381,11 +364,11 @@ Fib::registerPrefixInNfd(ndn::nfd::ControlParameters& parameters,
|
||||
uint8_t times)
|
||||
{
|
||||
m_controller.start<ndn::nfd::RibRegisterCommand>(parameters,
|
||||
ndn::bind(&Fib::onRegistration, this, _1,
|
||||
std::bind(&Fib::onRegistration, this, _1,
|
||||
"Successful in name registration",
|
||||
faceUri),
|
||||
ndn::bind(&Fib::onRegistrationFailure,
|
||||
this, _1, _2,
|
||||
std::bind(&Fib::onRegistrationFailure,
|
||||
this, _1,
|
||||
"Failed in name registration",
|
||||
parameters,
|
||||
faceUri, times));
|
||||
@@ -405,7 +388,7 @@ Fib::registerPrefixInNfd(const ndn::nfd::ControlParameters& faceCreateResult,
|
||||
.setCost(parameters.getCost())
|
||||
.setFlags(parameters.getFlags())
|
||||
.setExpirationPeriod(parameters.getExpirationPeriod())
|
||||
.setOrigin(128);
|
||||
.setOrigin(ndn::nfd::ROUTE_ORIGIN_NLSR);
|
||||
m_controller.start<ndn::nfd::RibRegisterCommand>(controlParameters,
|
||||
onSuccess,
|
||||
onFailure);
|
||||
@@ -421,12 +404,12 @@ Fib::unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri)
|
||||
controlParameters
|
||||
.setName(namePrefix)
|
||||
.setFaceId(faceId)
|
||||
.setOrigin(128);
|
||||
.setOrigin(ndn::nfd::ROUTE_ORIGIN_NLSR);
|
||||
m_controller.start<ndn::nfd::RibUnregisterCommand>(controlParameters,
|
||||
ndn::bind(&Fib::onUnregistration, this, _1,
|
||||
std::bind(&Fib::onUnregistration, this, _1,
|
||||
"Successful in unregistering name"),
|
||||
ndn::bind(&Fib::onUnregistrationFailure,
|
||||
this, _1, _2,
|
||||
std::bind(&Fib::onUnregistrationFailure,
|
||||
this, _1,
|
||||
"Failed in unregistering name"));
|
||||
}
|
||||
}
|
||||
@@ -440,9 +423,9 @@ Fib::setStrategy(const ndn::Name& name, const std::string& strategy, uint32_t co
|
||||
.setStrategy(strategy);
|
||||
|
||||
m_controller.start<ndn::nfd::StrategyChoiceSetCommand>(parameters,
|
||||
bind(&Fib::onSetStrategySuccess, this, _1,
|
||||
std::bind(&Fib::onSetStrategySuccess, this, _1,
|
||||
"Successfully set strategy choice"),
|
||||
bind(&Fib::onSetStrategyFailure, this, _1, _2,
|
||||
std::bind(&Fib::onSetStrategyFailure, this, _1,
|
||||
parameters,
|
||||
count,
|
||||
"Failed to set strategy choice"));
|
||||
@@ -467,13 +450,13 @@ Fib::onUnregistration(const ndn::nfd::ControlParameters& commandSuccessResult,
|
||||
}
|
||||
|
||||
void
|
||||
Fib::onRegistrationFailure(uint32_t code, const std::string& error,
|
||||
Fib::onRegistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
const std::string& message,
|
||||
const ndn::nfd::ControlParameters& parameters,
|
||||
const std::string& faceUri,
|
||||
uint8_t times)
|
||||
{
|
||||
_LOG_DEBUG(message << ": " << error << " (code: " << code << ")");
|
||||
_LOG_DEBUG(message << ": " << response.getText() << " (code: " << response.getCode() << ")");
|
||||
_LOG_DEBUG("Prefix: " << parameters.getName() << " failed for: " << times);
|
||||
if (times < 3) {
|
||||
_LOG_DEBUG("Trying to register again...");
|
||||
@@ -488,10 +471,10 @@ Fib::onRegistrationFailure(uint32_t code, const std::string& error,
|
||||
}
|
||||
|
||||
void
|
||||
Fib::onUnregistrationFailure(uint32_t code, const std::string& error,
|
||||
const std::string& message)
|
||||
Fib::onUnregistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
const std::string& message)
|
||||
{
|
||||
_LOG_DEBUG(message << ": " << error << " (code: " << code << ")");
|
||||
_LOG_DEBUG(message << ": " << response.getText() << " (code: " << response.getCode() << ")");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -503,10 +486,10 @@ Fib::onSetStrategySuccess(const ndn::nfd::ControlParameters& commandSuccessResul
|
||||
}
|
||||
|
||||
void
|
||||
Fib::onSetStrategyFailure(uint32_t code, const std::string& error,
|
||||
const ndn::nfd::ControlParameters& parameters,
|
||||
uint32_t count,
|
||||
const std::string& message)
|
||||
Fib::onSetStrategyFailure(const ndn::nfd::ControlResponse& response,
|
||||
const ndn::nfd::ControlParameters& parameters,
|
||||
uint32_t count,
|
||||
const std::string& message)
|
||||
{
|
||||
_LOG_DEBUG(message << ": " << parameters.getStrategy() << " "
|
||||
<< "for name: " << parameters.getName());
|
||||
@@ -519,10 +502,11 @@ void
|
||||
Fib::writeLog()
|
||||
{
|
||||
_LOG_DEBUG("-------------------FIB-----------------------------");
|
||||
for (std::list<FibEntry>::iterator it = m_table.begin(); it != m_table.end();
|
||||
for (std::map<ndn::Name, FibEntry>::iterator it = m_table.begin();
|
||||
it != m_table.end();
|
||||
++it) {
|
||||
(*it).writeLog();
|
||||
(it->second).writeLog();
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
+14
-15
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, 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.
|
||||
@@ -17,16 +18,15 @@
|
||||
* 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/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
#ifndef NLSR_FIB_HPP
|
||||
#define NLSR_FIB_HPP
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <ndn-cxx/management/nfd-controller.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/controller.hpp>
|
||||
#include <ndn-cxx/util/time.hpp>
|
||||
#include "face-map.hpp"
|
||||
#include "fib-entry.hpp"
|
||||
@@ -35,8 +35,8 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
typedef ndn::function<void(const ndn::nfd::ControlParameters&)> CommandSucceedCallback;
|
||||
typedef ndn::function<void(uint32_t/*code*/,const std::string&/*reason*/)> CommandFailCallback;
|
||||
typedef ndn::nfd::Controller::CommandSucceedCallback CommandSucceedCallback;
|
||||
typedef ndn::nfd::Controller::CommandFailCallback CommandFailCallback;
|
||||
|
||||
class AdjacencyList;
|
||||
class ConfParameter;
|
||||
@@ -163,30 +163,29 @@ private:
|
||||
const std::string& message);
|
||||
|
||||
void
|
||||
onRegistrationFailure(uint32_t code, const std::string& error,
|
||||
onRegistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
const std::string& message,
|
||||
const ndn::nfd::ControlParameters& parameters,
|
||||
const std::string& faceUri,
|
||||
uint8_t times);
|
||||
|
||||
void
|
||||
onUnregistrationFailure(uint32_t code, const std::string& error,
|
||||
const std::string& message);
|
||||
onUnregistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
const std::string& message);
|
||||
|
||||
void
|
||||
onSetStrategySuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
|
||||
const std::string& message);
|
||||
|
||||
void
|
||||
onSetStrategyFailure(uint32_t code, const std::string& error,
|
||||
onSetStrategyFailure(const ndn::nfd::ControlResponse& response,
|
||||
const ndn::nfd::ControlParameters& parameters,
|
||||
uint32_t count,
|
||||
const std::string& message);
|
||||
|
||||
private:
|
||||
ndn::Scheduler& m_scheduler;
|
||||
|
||||
std::list<FibEntry> m_table;
|
||||
std::map<ndn::Name, FibEntry> m_table;
|
||||
int32_t m_refreshTime;
|
||||
ndn::nfd::Controller m_controller;
|
||||
util::FaceController m_faceController;
|
||||
@@ -201,5 +200,5 @@ private:
|
||||
static const uint64_t GRACE_PERIOD;
|
||||
};
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
#endif //NLSR_FIB_HPP
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
|
||||
+14
-6
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
@@ -62,7 +62,7 @@ Map::addEntry(MapEntry& mpe)
|
||||
//cout << mpe;
|
||||
std::list<MapEntry>::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
ndn::bind(&mapEntryCompareByRouter,
|
||||
std::bind(&mapEntryCompareByRouter,
|
||||
_1, mpe.getRouter()));
|
||||
if (it == m_table.end()) {
|
||||
m_table.push_back(mpe);
|
||||
@@ -76,7 +76,7 @@ Map::getRouterNameByMappingNo(int32_t mn)
|
||||
{
|
||||
std::list<MapEntry>::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
ndn::bind(&mapEntryCompareByMappingNo,
|
||||
std::bind(&mapEntryCompareByMappingNo,
|
||||
_1, mn));
|
||||
if (it != m_table.end()) {
|
||||
return (*it).getRouter();
|
||||
@@ -89,7 +89,7 @@ Map::getMappingNoByRouterName(const ndn::Name& rName)
|
||||
{
|
||||
std::list<MapEntry>::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
ndn::bind(&mapEntryCompareByRouter,
|
||||
std::bind(&mapEntryCompareByRouter,
|
||||
_1, rName));
|
||||
if (it != m_table.end()) {
|
||||
return (*it).getMappingNumber();
|
||||
@@ -112,6 +112,14 @@ Map::createFromAdjLsdb(Nlsr& pnlsr)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Map::createFromCoordinateLsdb(Nlsr& nlsr)
|
||||
{
|
||||
for (CoordinateLsa lsa : nlsr.getLsdb().getCoordinateLsdb()) {
|
||||
addEntry(lsa.getOrigRouter());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Map::reset()
|
||||
{
|
||||
@@ -129,4 +137,4 @@ Map::writeLog()
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
+10
-2
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
@@ -43,13 +43,21 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
/*! \brief Add a map entry to this map.
|
||||
\param rtrName The name of the router.
|
||||
|
||||
Adds a router to this map. Each entry is also given an arbitrary,
|
||||
ascending mappingNo (mapping number).
|
||||
*/
|
||||
void
|
||||
addEntry(const ndn::Name& rtrName);
|
||||
|
||||
void
|
||||
createFromAdjLsdb(Nlsr& pnlsr);
|
||||
|
||||
void
|
||||
createFromCoordinateLsdb(Nlsr& nlsr);
|
||||
|
||||
const ndn::Name
|
||||
getRouterNameByMappingNo(int32_t mn);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -33,79 +33,80 @@ void
|
||||
NamePrefixTableEntry::generateNhlfromRteList()
|
||||
{
|
||||
m_nexthopList.reset();
|
||||
for (std::list<RoutingTableEntry>::iterator it = m_rteList.begin();
|
||||
it != m_rteList.end(); ++it)
|
||||
{
|
||||
for (std::list<NextHop>::iterator nhit =
|
||||
(*it).getNexthopList().getNextHops().begin();
|
||||
nhit != (*it).getNexthopList().getNextHops().end(); ++nhit)
|
||||
{
|
||||
m_nexthopList.addNextHop((*nhit));
|
||||
for (auto rtpeItr = m_rteList.begin(); rtpeItr != m_rteList.end(); ++rtpeItr) {
|
||||
for (auto nhItr = (*rtpeItr)->getNexthopList().getNextHops().begin();
|
||||
nhItr != (*rtpeItr)->getNexthopList().getNextHops().end();
|
||||
++nhItr) {
|
||||
m_nexthopList.addNextHop((*nhItr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static bool
|
||||
rteCompare(RoutingTableEntry& rte, ndn::Name& destRouter)
|
||||
uint64_t
|
||||
NamePrefixTableEntry::removeRoutingTableEntry(std::shared_ptr<RoutingTablePoolEntry>
|
||||
rtpePtr)
|
||||
{
|
||||
return rte.getDestination() == destRouter;
|
||||
auto rtpeItr = std::find(m_rteList.begin(), m_rteList.end(), rtpePtr);
|
||||
|
||||
if (rtpeItr != m_rteList.end()) {
|
||||
(*rtpeItr)->decrementUseCount();
|
||||
m_rteList.erase(rtpeItr);
|
||||
}
|
||||
else {
|
||||
_LOG_ERROR("Routing entry for: " << rtpePtr->getDestination()
|
||||
<< " not found in NPT entry: " << getNamePrefix());
|
||||
}
|
||||
return (*rtpeItr)->getUseCount();
|
||||
}
|
||||
|
||||
void
|
||||
NamePrefixTableEntry::removeRoutingTableEntry(RoutingTableEntry& rte)
|
||||
NamePrefixTableEntry::addRoutingTableEntry(std::shared_ptr<RoutingTablePoolEntry>
|
||||
rtpePtr)
|
||||
{
|
||||
std::list<RoutingTableEntry>::iterator it = std::find_if(m_rteList.begin(),
|
||||
m_rteList.end(),
|
||||
bind(&rteCompare, _1, rte.getDestination()));
|
||||
if (it != m_rteList.end())
|
||||
{
|
||||
m_rteList.erase(it);
|
||||
}
|
||||
}
|
||||
auto rtpeItr = std::find(m_rteList.begin(), m_rteList.end(), rtpePtr);
|
||||
|
||||
void
|
||||
NamePrefixTableEntry::addRoutingTableEntry(RoutingTableEntry& rte)
|
||||
{
|
||||
std::list<RoutingTableEntry>::iterator it = std::find_if(m_rteList.begin(),
|
||||
m_rteList.end(),
|
||||
bind(&rteCompare, _1, rte.getDestination()));
|
||||
if (it == m_rteList.end())
|
||||
{
|
||||
m_rteList.push_back(rte);
|
||||
}
|
||||
else
|
||||
{
|
||||
(*it).getNexthopList().reset(); // reseting existing routing table's next hop
|
||||
for (std::list<NextHop>::iterator nhit =
|
||||
rte.getNexthopList().getNextHops().begin();
|
||||
nhit != rte.getNexthopList().getNextHops().end(); ++nhit) {
|
||||
(*it).getNexthopList().addNextHop((*nhit));
|
||||
}
|
||||
// Ensure that this is a new entry
|
||||
if (rtpeItr == m_rteList.end()) {
|
||||
// Adding a new routing entry to the NPT entry
|
||||
rtpePtr->incrementUseCount();
|
||||
m_rteList.push_back(rtpePtr);
|
||||
}
|
||||
// Note: we don't need to update in the else case because these are
|
||||
// pointers, and they are centrally-located in the NPT and will all
|
||||
// be updated there.
|
||||
}
|
||||
|
||||
void
|
||||
NamePrefixTableEntry::writeLog()
|
||||
{
|
||||
_LOG_DEBUG("Name: " << m_namePrefix);
|
||||
for (std::list<RoutingTableEntry>::iterator it = m_rteList.begin();
|
||||
it != m_rteList.end(); ++it) {
|
||||
_LOG_DEBUG("Destination: " << (*it).getDestination());
|
||||
for (auto it = m_rteList.begin(); it != m_rteList.end(); ++it) {
|
||||
_LOG_DEBUG("Destination: " << (*it)->getDestination());
|
||||
_LOG_DEBUG("Nexthops: ");
|
||||
(*it).getNexthopList().writeLog();
|
||||
(*it)->getNexthopList().writeLog();
|
||||
}
|
||||
m_nexthopList.writeLog();
|
||||
}
|
||||
|
||||
bool
|
||||
operator==(const NamePrefixTableEntry& lhs, const NamePrefixTableEntry& rhs)
|
||||
{
|
||||
return (lhs.getNamePrefix() == rhs.getNamePrefix());
|
||||
}
|
||||
|
||||
bool
|
||||
operator==(const NamePrefixTableEntry& lhs, const ndn::Name& rhs)
|
||||
{
|
||||
return (lhs.getNamePrefix() == rhs);
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NamePrefixTableEntry& entry)
|
||||
{
|
||||
os << "Name: " << entry.getNamePrefix() << "\n";
|
||||
|
||||
for (const RoutingTableEntry& rte : entry.getRteList()) {
|
||||
os << "Destination: " << rte.getDestination() << "\n";
|
||||
for (const std::shared_ptr<RoutingTablePoolEntry> rtpePtr : entry.getRteList()) {
|
||||
os << "Destination: " << rtpePtr->getDestination() << "\n";
|
||||
}
|
||||
|
||||
return os;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -22,7 +22,9 @@
|
||||
#ifndef NLSR_NAME_PREFIX_TABLE_ENTRY_HPP
|
||||
#define NLSR_NAME_PREFIX_TABLE_ENTRY_HPP
|
||||
|
||||
#include "routing-table-entry.hpp"
|
||||
#include "routing-table-pool-entry.hpp"
|
||||
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
#include <list>
|
||||
#include <utility>
|
||||
@@ -48,7 +50,7 @@ public:
|
||||
return m_namePrefix;
|
||||
}
|
||||
|
||||
const std::list<RoutingTableEntry>&
|
||||
const std::list<std::shared_ptr<RoutingTablePoolEntry>>&
|
||||
getRteList() const
|
||||
{
|
||||
return m_rteList;
|
||||
@@ -58,9 +60,8 @@ public:
|
||||
resetRteListNextHop()
|
||||
{
|
||||
if (m_rteList.size() > 0) {
|
||||
for (std::list<RoutingTableEntry>::iterator it = m_rteList.begin();
|
||||
it != m_rteList.end(); ++it) {
|
||||
(*it).getNexthopList().reset();
|
||||
for (auto it = m_rteList.begin(); it != m_rteList.end(); ++it) {
|
||||
(*it)->getNexthopList().reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,24 +78,45 @@ public:
|
||||
return m_nexthopList;
|
||||
}
|
||||
|
||||
/*! \brief Generates a next-hop list from routing table entries. */
|
||||
void
|
||||
generateNhlfromRteList();
|
||||
|
||||
void
|
||||
removeRoutingTableEntry(RoutingTableEntry& rte);
|
||||
/*! \brief Removes a routing entry from this NPT entry.
|
||||
\param rtpePtr The routing entry
|
||||
\return The remaining number of other NPTs using the removed routing entry.
|
||||
*/
|
||||
uint64_t
|
||||
removeRoutingTableEntry(std::shared_ptr<RoutingTablePoolEntry> rtpePtr);
|
||||
|
||||
/*! \brief Adds a routing entry to this NPT entry.
|
||||
\param rtpePtr The routing entry.
|
||||
|
||||
Adds a routing table pool entry to this NPT entry's list
|
||||
(reminder: each RTPE has a next-hop list). They are used to
|
||||
calculate this entry's overall next-hop list.
|
||||
*/
|
||||
void
|
||||
addRoutingTableEntry(RoutingTableEntry& rte);
|
||||
addRoutingTableEntry(std::shared_ptr<RoutingTablePoolEntry> rtpePtr);
|
||||
|
||||
void
|
||||
writeLog();
|
||||
|
||||
private:
|
||||
ndn::Name m_namePrefix;
|
||||
std::list<RoutingTableEntry> m_rteList;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
std::list<std::shared_ptr<RoutingTablePoolEntry>> m_rteList;
|
||||
NexthopList m_nexthopList;
|
||||
|
||||
};
|
||||
|
||||
bool
|
||||
operator==(const NamePrefixTableEntry& lhs, const NamePrefixTableEntry& rhs);
|
||||
|
||||
bool
|
||||
operator==(const NamePrefixTableEntry& lhs, const ndn::Name& rhs);
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NamePrefixTableEntry& entry);
|
||||
|
||||
|
||||
+172
-108
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -33,110 +33,90 @@ namespace nlsr {
|
||||
|
||||
INIT_LOGGER("NamePrefixTable");
|
||||
|
||||
static bool
|
||||
bool
|
||||
npteCompare(NamePrefixTableEntry& npte, const ndn::Name& name)
|
||||
{
|
||||
return npte.getNamePrefix() == name;
|
||||
}
|
||||
|
||||
void
|
||||
NamePrefixTable::addEntry(const ndn::Name& name, RoutingTableEntry& rte)
|
||||
{
|
||||
NptEntryList::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
bind(&npteCompare, _1, name));
|
||||
if (it == m_table.end()) {
|
||||
_LOG_TRACE("Adding origin: " << rte.getDestination() << " to new name prefix: " << name);
|
||||
|
||||
NamePrefixTableEntry entry(name);
|
||||
|
||||
entry.addRoutingTableEntry(rte);
|
||||
|
||||
entry.generateNhlfromRteList();
|
||||
entry.getNexthopList().sort();
|
||||
|
||||
m_table.push_back(entry);
|
||||
|
||||
if (rte.getNexthopList().getSize() > 0) {
|
||||
_LOG_TRACE("Updating FIB with next hops for " << entry);
|
||||
m_nlsr.getFib().update(name, entry.getNexthopList());
|
||||
}
|
||||
}
|
||||
else {
|
||||
_LOG_TRACE("Adding origin: " << rte.getDestination() << " to existing prefix: " << *it);
|
||||
|
||||
it->addRoutingTableEntry(rte);
|
||||
|
||||
it->generateNhlfromRteList();
|
||||
it->getNexthopList().sort();
|
||||
|
||||
if (it->getNexthopList().getSize() > 0) {
|
||||
_LOG_TRACE("Updating FIB with next hops for " << *it);
|
||||
m_nlsr.getFib().update(name, it->getNexthopList());
|
||||
}
|
||||
else {
|
||||
// The routing table may recalculate and add a routing table entry with no next hops to
|
||||
// replace an existing routing table entry. In this case, the name prefix is no longer
|
||||
// reachable through a next hop and should be removed from the FIB. But, the prefix
|
||||
// should remain in the Name Prefix Table as a future routing table calculation may
|
||||
// add next hops.
|
||||
_LOG_TRACE(*it << " has no next hops; removing from FIB");
|
||||
m_nlsr.getFib().remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NamePrefixTable::removeEntry(const ndn::Name& name, RoutingTableEntry& rte)
|
||||
{
|
||||
NptEntryList::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
bind(&npteCompare, _1, name));
|
||||
if (it != m_table.end()) {
|
||||
_LOG_TRACE("Removing origin: " << rte.getDestination() << " from prefix: " << *it);
|
||||
|
||||
it->removeRoutingTableEntry(rte);
|
||||
|
||||
// If the prefix is a router prefix and it does not have any other routing table entries,
|
||||
// the Adjacency/Coordinate LSA associated with that origin router has been removed from
|
||||
// the LSDB and so the router prefix should be removed from the Name Prefix Table.
|
||||
//
|
||||
// If the prefix is an advertised name prefix:
|
||||
// If another router advertises this name prefix, the RteList should have another entry
|
||||
// for that router; the next hops should be recalculated and installed in the FIB.
|
||||
//
|
||||
// If no other router advertises this name prefix, the RteList should be empty and the
|
||||
// prefix can be removed from the Name Prefix Table. Once a new Name LSA advertises this
|
||||
// prefix, a new entry for the prefix will be created.
|
||||
//
|
||||
if (it->getRteListSize() == 0) {
|
||||
_LOG_TRACE(*it << " has no routing table entries; removing from table and FIB");
|
||||
m_table.erase(it);
|
||||
m_nlsr.getFib().remove(name);
|
||||
}
|
||||
else {
|
||||
_LOG_TRACE(*it << " has other routing table entries; updating FIB with next hops");
|
||||
it->generateNhlfromRteList();
|
||||
it->getNexthopList().sort();
|
||||
|
||||
m_nlsr.getFib().update(name, it->getNexthopList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NamePrefixTable::addEntry(const ndn::Name& name, const ndn::Name& destRouter)
|
||||
{
|
||||
_LOG_DEBUG("Adding origin: " << destRouter << " to " << name);
|
||||
|
||||
RoutingTableEntry* rteCheck = m_nlsr.getRoutingTable().findRoutingTableEntry(destRouter);
|
||||
// Check if the advertised name prefix is in the table already.
|
||||
NptEntryList::iterator nameItr = std::find(m_table.begin(),
|
||||
m_table.end(),
|
||||
name);
|
||||
|
||||
if (rteCheck != nullptr) {
|
||||
addEntry(name, *rteCheck);
|
||||
// Attempt to find a routing table pool entry (RTPE) we can use.
|
||||
RtpEntryMap::iterator rtpeItr = m_rtpool.find(destRouter);
|
||||
|
||||
// These declarations just to make the compiler happy...
|
||||
RoutingTablePoolEntry rtpe;
|
||||
std::shared_ptr<RoutingTablePoolEntry> rtpePtr(nullptr);
|
||||
|
||||
// There isn't currently a routing table entry in the pool for this name
|
||||
if (rtpeItr == m_rtpool.end()) {
|
||||
// See if there is a routing table entry available we could use
|
||||
RoutingTableEntry* routeEntryPtr = m_nlsr.getRoutingTable()
|
||||
.findRoutingTableEntry(destRouter);
|
||||
|
||||
// We have to create a new routing table entry
|
||||
if (routeEntryPtr == nullptr) {
|
||||
rtpe = RoutingTablePoolEntry(destRouter, 0);
|
||||
}
|
||||
// There was already a usable one in the routing table
|
||||
else {
|
||||
rtpe = RoutingTablePoolEntry(*routeEntryPtr, 0);
|
||||
}
|
||||
|
||||
// Add the new pool object to the pool.
|
||||
rtpePtr = addRtpeToPool(rtpe);
|
||||
}
|
||||
// There was one already, so just fetch that one.
|
||||
else {
|
||||
rtpePtr = (*rtpeItr).second;
|
||||
}
|
||||
|
||||
// Either we have to make a new NPT entry or there already was one.
|
||||
if (nameItr == m_table.end()) {
|
||||
_LOG_DEBUG("Adding origin: " << rtpePtr->getDestination()
|
||||
<< " to a new name prefix: " << name);
|
||||
NamePrefixTableEntry npte(name);
|
||||
npte.addRoutingTableEntry(rtpePtr);
|
||||
npte.generateNhlfromRteList();
|
||||
m_table.push_back(npte);
|
||||
|
||||
// If this entry has next hops, we need to inform the FIB
|
||||
if (npte.getNexthopList().getSize() > 0) {
|
||||
_LOG_TRACE("Updating FIB with next hops for " << npte);
|
||||
m_nlsr.getFib().update(name, npte.getNexthopList());
|
||||
}
|
||||
// The routing table may recalculate and add a routing table entry
|
||||
// with no next hops to replace an existing routing table entry. In
|
||||
// this case, the name prefix is no longer reachable through a next
|
||||
// hop and should be removed from the FIB. But, the prefix should
|
||||
// remain in the Name Prefix Table as a future routing table
|
||||
// calculation may add next hops.
|
||||
else {
|
||||
_LOG_TRACE(npte << " has no next hops; removing from FIB");
|
||||
m_nlsr.getFib().remove(name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
RoutingTableEntry rte(destRouter);
|
||||
addEntry(name, rte);
|
||||
_LOG_TRACE("Adding origin: " << rtpePtr->getDestination()
|
||||
<< " to existing prefix: " << *nameItr);
|
||||
nameItr->addRoutingTableEntry(rtpePtr);
|
||||
nameItr->generateNhlfromRteList();
|
||||
|
||||
if (nameItr->getNexthopList().getSize() > 0) {
|
||||
_LOG_TRACE("Updating FIB with next hops for " << (*nameItr));
|
||||
m_nlsr.getFib().update(name, nameItr->getNexthopList());
|
||||
}
|
||||
else {
|
||||
_LOG_TRACE((*nameItr) << " has no next hops; removing from FIB");
|
||||
m_nlsr.getFib().remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,14 +125,64 @@ NamePrefixTable::removeEntry(const ndn::Name& name, const ndn::Name& destRouter)
|
||||
{
|
||||
_LOG_DEBUG("Removing origin: " << destRouter << " from " << name);
|
||||
|
||||
RoutingTableEntry* rteCheck = m_nlsr.getRoutingTable().findRoutingTableEntry(destRouter);
|
||||
// Fetch an iterator to the appropriate pair object in the pool.
|
||||
RtpEntryMap::iterator rtpeItr = m_rtpool.find(destRouter);
|
||||
|
||||
if (rteCheck != nullptr) {
|
||||
removeEntry(name, *rteCheck);
|
||||
// Simple error checking to prevent any unusual behavior in the case
|
||||
// that we try to remove an entry that isn't there.
|
||||
if (rtpeItr == m_rtpool.end()) {
|
||||
_LOG_DEBUG("No entry for origin: " << destRouter
|
||||
<< " found, so it cannot be removed from prefix: "
|
||||
<< name);
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<RoutingTablePoolEntry> rtpePtr = rtpeItr->second;
|
||||
|
||||
// Ensure that the entry exists
|
||||
NptEntryList::iterator nameItr = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
std::bind(&npteCompare, _1, name));
|
||||
if (nameItr != m_table.end()) {
|
||||
_LOG_TRACE("Removing origin: " << rtpePtr->getDestination()
|
||||
<< " from prefix: " << *nameItr);
|
||||
|
||||
// Rather than iterating through the whole list periodically, just
|
||||
// delete them here if they have no references.
|
||||
if ((*nameItr).removeRoutingTableEntry(rtpePtr) == 0) {
|
||||
deleteRtpeFromPool(rtpePtr);
|
||||
}
|
||||
|
||||
// If the prefix is a router prefix and it does not have any other
|
||||
// routing table entries, the Adjacency/Coordinate LSA associated
|
||||
// with that origin router has been removed from the LSDB and so
|
||||
// the router prefix should be removed from the Name Prefix Table.
|
||||
//
|
||||
// If the prefix is an advertised name prefix: If another router
|
||||
// advertises this name prefix, the RteList should have another
|
||||
// entry for that router; the next hops should be recalculated
|
||||
// and installed in the FIB.
|
||||
//
|
||||
// If no other router advertises this name prefix, the RteList
|
||||
// should be empty and the prefix can be removed from the Name
|
||||
// Prefix Table. Once a new Name LSA advertises this prefix, a
|
||||
// new entry for the prefix will be created.
|
||||
//
|
||||
if ((*nameItr).getRteListSize() == 0) {
|
||||
_LOG_TRACE(*nameItr << " has no routing table entries;"
|
||||
<< " removing from table and FIB");
|
||||
m_table.erase(nameItr);
|
||||
m_nlsr.getFib().remove(name);
|
||||
}
|
||||
else {
|
||||
_LOG_TRACE(*nameItr << " has other routing table entries;"
|
||||
<< " updating FIB with next hops");
|
||||
(*nameItr).generateNhlfromRteList();
|
||||
m_nlsr.getFib().update(name, (*nameItr).getNexthopList());
|
||||
}
|
||||
}
|
||||
else {
|
||||
RoutingTableEntry rte(destRouter);
|
||||
removeEntry(name, rte);
|
||||
_LOG_DEBUG("Attempted to remove origin: " << rtpePtr->getDestination()
|
||||
<< " from non-existant prefix: " << name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,26 +191,60 @@ NamePrefixTable::updateWithNewRoute()
|
||||
{
|
||||
_LOG_DEBUG("Updating table with newly calculated routes");
|
||||
|
||||
// Update each name prefix entry in the Name Prefix Table with newly calculated next hops
|
||||
for (const NamePrefixTableEntry& prefixEntry : m_table) {
|
||||
for (const RoutingTableEntry& routingEntry : prefixEntry.getRteList()) {
|
||||
_LOG_TRACE("Updating next hops to origin: " << routingEntry.getDestination()
|
||||
<< " for prefix: " << prefixEntry);
|
||||
|
||||
// Update each name prefix table entry in the NPT with the
|
||||
// newly calculated next hops.
|
||||
for (auto&& npte : m_table) {
|
||||
// For each routing table pool entry in this NPT entry.
|
||||
for (auto&& rtpe : npte.getRteList()) {
|
||||
_LOG_TRACE("Updating next hops to origin: " << rtpe->getDestination()
|
||||
<< " for prefix: " << npte);
|
||||
RoutingTableEntry* rteCheck =
|
||||
m_nlsr.getRoutingTable().findRoutingTableEntry(routingEntry.getDestination());
|
||||
m_nlsr.getRoutingTable().findRoutingTableEntry(rtpe->getDestination());
|
||||
|
||||
// If there is a routing table entry for this prefix, update the NPT with it.
|
||||
if (rteCheck != nullptr) {
|
||||
addEntry(prefixEntry.getNamePrefix(), *rteCheck);
|
||||
rtpe->setNexthopList(rteCheck->getNexthopList());
|
||||
}
|
||||
else {
|
||||
RoutingTableEntry rte(routingEntry.getDestination());
|
||||
addEntry(prefixEntry.getNamePrefix(), rte);
|
||||
rtpe->getNexthopList().reset();
|
||||
}
|
||||
addEntry(npte.getNamePrefix(), rtpe->getDestination());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Inserts the routing table pool entry into the NPT's RTE storage
|
||||
// pool. This cannot fail, so the pool is guaranteed to contain the
|
||||
// item after this occurs.
|
||||
std::shared_ptr<RoutingTablePoolEntry>
|
||||
NamePrefixTable::addRtpeToPool(RoutingTablePoolEntry& rtpe)
|
||||
{
|
||||
RtpEntryMap::iterator poolItr =
|
||||
m_rtpool.insert(std::make_pair(rtpe.getDestination(),
|
||||
std::make_shared<RoutingTablePoolEntry>
|
||||
(rtpe)))
|
||||
.first;
|
||||
//| There's gotta be a more efficient way to do this
|
||||
//std::shared_ptr<RoutingTablePoolEntry> poolPtr = &(poolItr->second);
|
||||
return poolItr->second;
|
||||
}
|
||||
|
||||
// Removes the routing table pool entry from the storage pool. The
|
||||
// postconditions of this function are guaranteed to include that
|
||||
// the storage pool does not contain such an item. Additionally,
|
||||
// this function cannot fail, but nonetheless debug information is
|
||||
// given in the case that this function is called with an entry that
|
||||
// isn't in the pool.
|
||||
void
|
||||
NamePrefixTable::deleteRtpeFromPool(std::shared_ptr<RoutingTablePoolEntry> rtpePtr)
|
||||
{
|
||||
if (m_rtpool.erase(rtpePtr->getDestination()) != 1) {
|
||||
_LOG_DEBUG("Attempted to delete non-existant origin: "
|
||||
<< rtpePtr->getDestination()
|
||||
<< " from NPT routing table entry storage pool.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NamePrefixTable::writeLog()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -23,9 +23,12 @@
|
||||
#define NLSR_NAME_PREFIX_TABLE_HPP
|
||||
|
||||
#include "name-prefix-table-entry.hpp"
|
||||
#include "routing-table-entry.hpp"
|
||||
#include "routing-table-pool-entry.hpp"
|
||||
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
#include <list>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace nlsr {
|
||||
class Nlsr;
|
||||
@@ -37,20 +40,78 @@ public:
|
||||
typedef std::list<NamePrefixTableEntry> NptEntryList;
|
||||
typedef NptEntryList::const_iterator const_iterator;
|
||||
|
||||
typedef std::unordered_map<ndn::Name, std::shared_ptr<RoutingTablePoolEntry>>
|
||||
RtpEntryMap;
|
||||
|
||||
NamePrefixTable(Nlsr& nlsr)
|
||||
: m_nlsr(nlsr)
|
||||
{
|
||||
}
|
||||
|
||||
/*! \brief Adds a destination to the specified name prefix.
|
||||
\param name The name prefix
|
||||
\param destRouter The destination router prefix
|
||||
|
||||
This method adds a router to a name prefix table entry. If the
|
||||
name prefix table entry does not exist, it is created. The method
|
||||
will first look through its local pool of cached entries to find
|
||||
the routing information for destRouter. If it is not found there,
|
||||
it will construct one and fill it with information from an
|
||||
appropriate RoutingTableEntry in the routing table. If there isn't
|
||||
a match, it will instantiate it with no next hops. The FIB will be
|
||||
notified of the change to the NPT entry, too.
|
||||
*/
|
||||
void
|
||||
addEntry(const ndn::Name& name, const ndn::Name& destRouter);
|
||||
|
||||
/*! \brief Removes a destination from a name prefix table entry.
|
||||
\param name The name prefix
|
||||
\param destRouter The destination.
|
||||
|
||||
This method removes a destination from an entry. It will not fail
|
||||
if an invalid name/destination pair are passed. After removal, if
|
||||
the RoutingTablePoolEntry has a use count of 0, it is deleted from
|
||||
the table. Additionally, if the name prefix has no routing table
|
||||
entries associated with it, it is deleted from the NPT. In any
|
||||
case, the FIB is informed of the changes.
|
||||
*/
|
||||
void
|
||||
removeEntry(const ndn::Name& name, const ndn::Name& destRouter);
|
||||
|
||||
/*! \brief Updates all routing information in the NPT.
|
||||
|
||||
Naively iterates over all the NPT entries, then over each of their
|
||||
RoutingTablePoolEntries, passing the name/destination pair back to
|
||||
addEntry after updating the pool entry with new information. This
|
||||
ensures that the FIB is appropriately apprised of any changes to a
|
||||
prefix's preferred next hops.
|
||||
*/
|
||||
void
|
||||
updateWithNewRoute();
|
||||
|
||||
/*! \brief Adds a pool entry to the pool.
|
||||
\param rtpe The entry.
|
||||
|
||||
\return A shared_ptr to the entry, now in the pool.
|
||||
|
||||
Adds a RoutingTablePoolEntry to the NPT's local pool. Shared
|
||||
pointers are used because it eliminates complicated hacks to deal
|
||||
with lifetime issues, and to simplify memory management.
|
||||
*/
|
||||
std::shared_ptr<RoutingTablePoolEntry>
|
||||
addRtpeToPool(RoutingTablePoolEntry& rtpe);
|
||||
|
||||
/*! \brief Removes a pool entry from the pool.
|
||||
\param rtpePtr The shared_ptr to the entry.
|
||||
|
||||
Removes a pool entry from the pool. Comparing these shared_ptrs
|
||||
should not be a problem, because the same pointer is moved around,
|
||||
all sourced from this central location. A more robust solution is
|
||||
certainly possible, though.
|
||||
*/
|
||||
void
|
||||
deleteRtpeFromPool(std::shared_ptr<RoutingTablePoolEntry> rtpePtr);
|
||||
|
||||
void
|
||||
writeLog();
|
||||
|
||||
@@ -60,16 +121,13 @@ public:
|
||||
const_iterator
|
||||
end() const;
|
||||
|
||||
private:
|
||||
void
|
||||
addEntry(const ndn::Name& name, RoutingTableEntry& rte);
|
||||
|
||||
void
|
||||
removeEntry(const ndn::Name& name, RoutingTableEntry& rte);
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
RtpEntryMap m_rtpool;
|
||||
NptEntryList m_table;
|
||||
|
||||
private:
|
||||
Nlsr& m_nlsr;
|
||||
std::list<NamePrefixTableEntry> m_table;
|
||||
|
||||
};
|
||||
|
||||
inline NamePrefixTable::const_iterator
|
||||
@@ -84,6 +142,9 @@ NamePrefixTable::end() const
|
||||
return m_table.end();
|
||||
}
|
||||
|
||||
bool
|
||||
npteCompare(NamePrefixTableEntry& npte, const ndn::Name& name);
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NamePrefixTable& table);
|
||||
|
||||
|
||||
+43
-45
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -19,8 +19,6 @@
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "nexthop-list.hpp"
|
||||
#include "nexthop.hpp"
|
||||
@@ -33,87 +31,87 @@ INIT_LOGGER("NexthopList");
|
||||
using namespace std;
|
||||
|
||||
static bool
|
||||
nexthopCompare(NextHop& nh1, NextHop& nh2)
|
||||
nexthopAddCompare(const NextHop& nh1, const NextHop& nh2)
|
||||
{
|
||||
return nh1.getConnectingFaceUri() == nh2.getConnectingFaceUri();
|
||||
}
|
||||
|
||||
static bool
|
||||
nexthopRemoveCompare(NextHop& nh1, NextHop& nh2)
|
||||
nexthopRemoveCompare(const NextHop& nh1, const NextHop& nh2)
|
||||
{
|
||||
return (nh1.getConnectingFaceUri() == nh2.getConnectingFaceUri() &&
|
||||
nh1.getRouteCostAsAdjustedInteger() == nh2.getRouteCostAsAdjustedInteger()) ;
|
||||
}
|
||||
|
||||
static bool
|
||||
nextHopSortingComparator(const NextHop& nh1, const NextHop& nh2)
|
||||
bool
|
||||
operator==(const NexthopList& lhs, const NexthopList& rhs)
|
||||
{
|
||||
if (nh1.getRouteCostAsAdjustedInteger() < nh2.getRouteCostAsAdjustedInteger()) {
|
||||
return true;
|
||||
}
|
||||
else if (nh1.getRouteCostAsAdjustedInteger() == nh2.getRouteCostAsAdjustedInteger()) {
|
||||
return nh1.getConnectingFaceUri() < nh2.getConnectingFaceUri();
|
||||
}
|
||||
else {
|
||||
if (lhs.getSize() != rhs.getSize()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NexthopList slhs = lhs;
|
||||
NexthopList srhs = rhs;
|
||||
|
||||
for (struct {std::set<NextHop>::iterator lItr;
|
||||
std::set<NextHop>::iterator rItr;} pair = {slhs.begin(), srhs.begin()};
|
||||
(pair.lItr != slhs.end() || pair.rItr != srhs.end());
|
||||
pair.rItr++, pair.lItr++) {
|
||||
if (!((*pair.lItr) == (*pair.rItr))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
Add next hop to the Next Hop list
|
||||
If next hop is new it is added
|
||||
If next hop already exists in next
|
||||
hop list then updates the route
|
||||
cost with new next hop's route cost
|
||||
*/
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NexthopList& nhl)
|
||||
{
|
||||
NexthopList& ucnhl = const_cast<NexthopList&>(nhl);
|
||||
os << "NexthopList(\nNext hops: ";
|
||||
for (auto&& nh : ucnhl.getNextHops()) {
|
||||
os << nh;
|
||||
}
|
||||
os << ")";
|
||||
return os;
|
||||
}
|
||||
|
||||
void
|
||||
NexthopList::addNextHop(NextHop& nh)
|
||||
NexthopList::addNextHop(const NextHop& nh)
|
||||
{
|
||||
std::list<NextHop>::iterator it = std::find_if(m_nexthopList.begin(),
|
||||
std::set<NextHop, NextHopComparator>::iterator it = std::find_if(m_nexthopList.begin(),
|
||||
m_nexthopList.end(),
|
||||
ndn::bind(&nexthopCompare, _1, nh));
|
||||
std::bind(&nexthopAddCompare, _1, nh));
|
||||
if (it == m_nexthopList.end()) {
|
||||
m_nexthopList.push_back(nh);
|
||||
return;
|
||||
m_nexthopList.insert(nh);
|
||||
}
|
||||
if ((*it).getRouteCost() > nh.getRouteCost()) {
|
||||
(*it).setRouteCost(nh.getRouteCost());
|
||||
else if (it->getRouteCost() > nh.getRouteCost()) {
|
||||
removeNextHop(*it);
|
||||
m_nexthopList.insert(nh);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Remove a next hop only if both next hop face and route cost are same
|
||||
|
||||
*/
|
||||
|
||||
void
|
||||
NexthopList::removeNextHop(NextHop& nh)
|
||||
NexthopList::removeNextHop(const NextHop& nh)
|
||||
{
|
||||
std::list<NextHop>::iterator it = std::find_if(m_nexthopList.begin(),
|
||||
std::set<NextHop, NextHopComparator>::iterator it = std::find_if(m_nexthopList.begin(),
|
||||
m_nexthopList.end(),
|
||||
ndn::bind(&nexthopRemoveCompare, _1, nh));
|
||||
std::bind(&nexthopRemoveCompare, _1, nh));
|
||||
if (it != m_nexthopList.end()) {
|
||||
m_nexthopList.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NexthopList::sort()
|
||||
{
|
||||
m_nexthopList.sort(nextHopSortingComparator);
|
||||
}
|
||||
|
||||
void
|
||||
NexthopList::writeLog()
|
||||
{
|
||||
int i = 1;
|
||||
sort();
|
||||
for (std::list<NextHop>::iterator it = m_nexthopList.begin();
|
||||
|
||||
for (std::set<NextHop, NextHopComparator>::iterator it = m_nexthopList.begin();
|
||||
it != m_nexthopList.end() ; it++, i++) {
|
||||
_LOG_DEBUG("Nexthop " << i << ": " << (*it).getConnectingFaceUri()
|
||||
<< " Route Cost: " << (*it).getRouteCost());
|
||||
}
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
+51
-15
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
@@ -16,14 +16,11 @@
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
#ifndef NLSR_NEXTHOP_LIST_HPP
|
||||
#define NLSR_NEXTHOP_LIST_HPP
|
||||
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <iostream>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
@@ -34,6 +31,21 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
struct NextHopComparator {
|
||||
bool
|
||||
operator() (const NextHop& nh1, const NextHop& nh2) const {
|
||||
if (nh1.getRouteCostAsAdjustedInteger() < nh2.getRouteCostAsAdjustedInteger()) {
|
||||
return true;
|
||||
}
|
||||
else if (nh1.getRouteCostAsAdjustedInteger() == nh2.getRouteCostAsAdjustedInteger()) {
|
||||
return nh1.getConnectingFaceUri() < nh2.getConnectingFaceUri();
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class NexthopList
|
||||
{
|
||||
public:
|
||||
@@ -45,14 +57,23 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
addNextHop(NextHop& nh);
|
||||
/*! \brief Adds a next hop to the list.
|
||||
\param nh The next hop.
|
||||
|
||||
Adds a next hop to this object. If the next hop is new it is
|
||||
added. If the next hop already exists in the list then that next
|
||||
hop's route cost is updated.
|
||||
*/
|
||||
void
|
||||
removeNextHop(NextHop& nh);
|
||||
addNextHop(const NextHop& nh);
|
||||
|
||||
/*! \brief Remove a next hop from the Next Hop list
|
||||
\param nh The NextHop we want to remove.
|
||||
|
||||
The next hop gets removed only if both next hop face and route cost are same.
|
||||
*/
|
||||
void
|
||||
sort();
|
||||
removeNextHop(const NextHop& nh);
|
||||
|
||||
size_t
|
||||
getSize()
|
||||
@@ -60,20 +81,26 @@ public:
|
||||
return m_nexthopList.size();
|
||||
}
|
||||
|
||||
size_t
|
||||
getSize() const
|
||||
{
|
||||
return m_nexthopList.size();
|
||||
}
|
||||
|
||||
void
|
||||
reset()
|
||||
{
|
||||
m_nexthopList.clear();
|
||||
}
|
||||
|
||||
std::list<NextHop>&
|
||||
std::set<NextHop, NextHopComparator>&
|
||||
getNextHops()
|
||||
{
|
||||
return m_nexthopList;
|
||||
}
|
||||
|
||||
typedef std::list<NextHop>::iterator iterator;
|
||||
typedef std::list<NextHop>::const_iterator const_iterator;
|
||||
typedef std::set<NextHop, NextHopComparator>::iterator iterator;
|
||||
typedef std::set<NextHop, NextHopComparator>::const_iterator const_iterator;
|
||||
|
||||
iterator
|
||||
begin()
|
||||
@@ -103,9 +130,18 @@ public:
|
||||
writeLog();
|
||||
|
||||
private:
|
||||
std::list<NextHop> m_nexthopList;
|
||||
std::set<NextHop, NextHopComparator> m_nexthopList;
|
||||
};
|
||||
|
||||
}//namespace nlsr
|
||||
bool
|
||||
operator==(NexthopList& lhs, NexthopList& rhs);
|
||||
|
||||
bool
|
||||
operator==(const NexthopList& lhs, const NexthopList& rhs);
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NexthopList& nhl);
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_NEXTHOP_LIST_HPP
|
||||
+11
-3
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
@@ -24,6 +24,14 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
bool
|
||||
operator==(const NextHop& lhs, const NextHop& rhs)
|
||||
{
|
||||
return ((lhs.getRouteCostAsAdjustedInteger() == rhs.getRouteCostAsAdjustedInteger())
|
||||
&&
|
||||
(lhs.getConnectingFaceUri() == rhs.getConnectingFaceUri()));
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NextHop& hop)
|
||||
{
|
||||
@@ -34,4 +42,4 @@ operator<<(std::ostream& os, const NextHop& hop)
|
||||
return os;
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
+16
-16
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
@@ -16,9 +16,6 @@
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
#ifndef NLSR_NEXTHOP_HPP
|
||||
#define NLSR_NEXTHOP_HPP
|
||||
@@ -80,7 +77,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
setRouteCost(double rc)
|
||||
setRouteCost(const double rc)
|
||||
{
|
||||
m_routeCost = rc;
|
||||
}
|
||||
@@ -103,22 +100,25 @@ private:
|
||||
bool m_isHyperbolic;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
/** \brief Used to adjust floating point route costs to integers
|
||||
* Since NFD uses integer route costs in the FIB, hyperbolic paths with similar route costs
|
||||
* will be rounded to integers and installed with identical nexthop costs.
|
||||
*
|
||||
* e.g. costs 12.34 and 12.35 will be equal in NFD's FIB
|
||||
*
|
||||
* This multiplier is used to differentiate similar route costs in the FIB.
|
||||
*
|
||||
* e.g costs 12.34 and 12.35 will be installed into NFD's FIB as 12340 and 12350
|
||||
/*! \brief Used to adjust floating point route costs to integers
|
||||
Since NFD uses integer route costs in the FIB, hyperbolic paths with similar route costs
|
||||
will be rounded to integers and installed with identical nexthop costs.
|
||||
|
||||
e.g. costs 12.34 and 12.35 will be equal in NFD's FIB
|
||||
|
||||
This multiplier is used to differentiate similar route costs in the FIB.
|
||||
|
||||
e.g costs 12.34 and 12.35 will be installed into NFD's FIB as 12340 and 12350
|
||||
*/
|
||||
static const uint64_t HYPERBOLIC_COST_ADJUSTMENT_FACTOR = 1000;
|
||||
};
|
||||
|
||||
bool
|
||||
operator==(const NextHop& lhs, const NextHop& rhs);
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NextHop& hop);
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_NEXTHOP_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -60,11 +60,14 @@ void
|
||||
RoutingTableCalculator::makeAdjMatrix(Nlsr& pnlsr, Map pMap)
|
||||
{
|
||||
std::list<AdjLsa> adjLsdb = pnlsr.getLsdb().getAdjLsdb();
|
||||
// For each LSA represented in the map
|
||||
for (std::list<AdjLsa>::iterator it = adjLsdb.begin(); it != adjLsdb.end() ; it++) {
|
||||
|
||||
|
||||
int32_t row = pMap.getMappingNoByRouterName((*it).getOrigRouter());
|
||||
|
||||
std::list<Adjacent> adl = (*it).getAdl().getAdjList();
|
||||
// For each adjacency represented in the LSA
|
||||
for (std::list<Adjacent>::iterator itAdl = adl.begin(); itAdl != adl.end() ; itAdl++) {
|
||||
|
||||
int32_t col = pMap.getMappingNoByRouterName((*itAdl).getName());
|
||||
@@ -78,14 +81,17 @@ RoutingTableCalculator::makeAdjMatrix(Nlsr& pnlsr, Map pMap)
|
||||
}
|
||||
}
|
||||
|
||||
// Links that do not have the same cost for both directions should have their
|
||||
// costs corrected:
|
||||
// Links that do not have the same cost for both directions should
|
||||
// have their costs corrected:
|
||||
//
|
||||
// If the cost of one side of the link is 0, both sides of the link should have their cost
|
||||
// corrected to 0.
|
||||
// If the cost of one side of the link is 0, both sides of the
|
||||
// link should have their cost corrected to 0.
|
||||
//
|
||||
// Otherwise, both sides of the link should use the larger of the two costs.
|
||||
//
|
||||
// Additionally, this means that we can halve the amount of space
|
||||
// that the matrix uses by only maintaining a triangle.
|
||||
// - But that is not yet implemented.
|
||||
for (size_t row = 0; row < m_nRouters; ++row) {
|
||||
for (size_t col = 0; col < m_nRouters; ++col) {
|
||||
double toCost = adjMatrix[row][col];
|
||||
@@ -173,7 +179,6 @@ RoutingTableCalculator::freeAdjMatrix()
|
||||
delete [] adjMatrix;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RoutingTableCalculator::allocateLinks()
|
||||
{
|
||||
@@ -208,12 +213,12 @@ LinkStateRoutingTableCalculator::calculatePath(Map& pMap,
|
||||
makeAdjMatrix(pnlsr, pMap);
|
||||
writeAdjMatrixLog();
|
||||
int sourceRouter = pMap.getMappingNoByRouterName(pnlsr.getConfParameter().getRouterPrefix());
|
||||
allocateParent();
|
||||
allocateDistance();
|
||||
allocateParent(); // These two matrices are used in Dijkstra's algorithm.
|
||||
allocateDistance(); //
|
||||
if (pnlsr.getConfParameter().getMaxFacesPerPrefix() == 1) {
|
||||
// Single Path
|
||||
// In the single path case we can simply run Dijkstra's algorithm.
|
||||
doDijkstraPathCalculation(sourceRouter);
|
||||
// update routing table
|
||||
// Inform the routing table of the new next hops.
|
||||
addAllLsNextHopsToRoutingTable(pnlsr, rt, pMap, sourceRouter);
|
||||
}
|
||||
else {
|
||||
@@ -221,12 +226,15 @@ LinkStateRoutingTableCalculator::calculatePath(Map& pMap,
|
||||
setNoLink(getNumOfLinkfromAdjMatrix(sourceRouter));
|
||||
allocateLinks();
|
||||
allocateLinkCosts();
|
||||
// Gets a sparse listing of adjacencies for path calculation
|
||||
getLinksFromAdjMatrix(links, linkCosts, sourceRouter);
|
||||
for (int i = 0 ; i < vNoLink; i++) {
|
||||
// Simulate that only the current neighbor is accessible
|
||||
adjustAdMatrix(sourceRouter, links[i], linkCosts[i]);
|
||||
writeAdjMatrixLog();
|
||||
// Do Dijkstra's algorithm using the current neighbor as your start.
|
||||
doDijkstraPathCalculation(sourceRouter);
|
||||
//update routing table
|
||||
// Update the routing table with the calculations.
|
||||
addAllLsNextHopsToRoutingTable(pnlsr, rt, pMap, sourceRouter);
|
||||
}
|
||||
freeLinks();
|
||||
@@ -242,32 +250,44 @@ LinkStateRoutingTableCalculator::doDijkstraPathCalculation(int sourceRouter)
|
||||
{
|
||||
int i;
|
||||
int v, u;
|
||||
int* Q = new int[m_nRouters];
|
||||
int* Q = new int[m_nRouters]; // Each cell represents the router with that mapping no.
|
||||
int head = 0;
|
||||
/* Initiate the Parent */
|
||||
for (i = 0 ; i < static_cast<int>(m_nRouters); i++) {
|
||||
m_parent[i] = EMPTY_PARENT;
|
||||
// Array where the ith element is the distance to the router with mapping no i.
|
||||
m_distance[i] = INF_DISTANCE;
|
||||
Q[i] = i;
|
||||
}
|
||||
if (sourceRouter != NO_MAPPING_NUM) {
|
||||
// Distance to source from source is always 0.
|
||||
m_distance[sourceRouter] = 0;
|
||||
sortQueueByDistance(Q, m_distance, head, m_nRouters);
|
||||
// While we haven't visited every node.
|
||||
while (head < static_cast<int>(m_nRouters)) {
|
||||
u = Q[head];
|
||||
u = Q[head]; // Set u to be the current node pointed to by head.
|
||||
if (m_distance[u] == INF_DISTANCE) {
|
||||
break;
|
||||
break; // This can only happen when there are no accessible nodes.
|
||||
}
|
||||
// Iterate over the adjacent nodes to u.
|
||||
for (v = 0 ; v < static_cast<int>(m_nRouters); v++) {
|
||||
// If the current node is accessible.
|
||||
if (adjMatrix[u][v] > 0) {
|
||||
// And we haven't visited it yet.
|
||||
if (isNotExplored(Q, v, head + 1, m_nRouters)) {
|
||||
// And if the distance to this node + from this node to v
|
||||
// is less than the distance from our source node to v
|
||||
// that we got when we built the adj LSAs
|
||||
if (m_distance[u] + adjMatrix[u][v] < m_distance[v]) {
|
||||
// Set the new distance
|
||||
m_distance[v] = m_distance[u] + adjMatrix[u][v] ;
|
||||
// Set how we get there.
|
||||
m_parent[v] = u;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Increment the head position, resort the list by distance from where we are.
|
||||
head++;
|
||||
sortQueueByDistance(Q, m_distance, head, m_nRouters);
|
||||
}
|
||||
@@ -283,14 +303,19 @@ LinkStateRoutingTableCalculator::addAllLsNextHopsToRoutingTable(Nlsr& pnlsr, Rou
|
||||
|
||||
int nextHopRouter = 0;
|
||||
|
||||
// For each router we have
|
||||
for (size_t i = 0; i < m_nRouters ; i++) {
|
||||
if (i != sourceRouter) {
|
||||
|
||||
// Obtain the next hop that was determined by the algorithm
|
||||
nextHopRouter = getLsNextHop(i, sourceRouter);
|
||||
|
||||
// If this router is accessible at all
|
||||
if (nextHopRouter != NO_NEXT_HOP) {
|
||||
|
||||
// Fetch its distance
|
||||
double routeCost = m_distance[i];
|
||||
// Fetch its actual name
|
||||
ndn::Name nextHopRouterName = pMap.getRouterNameByMappingNo(nextHopRouter);
|
||||
std::string nextHopFace =
|
||||
pnlsr.getAdjacencyList().getAdjacent(nextHopRouterName).getConnectingFaceUri();
|
||||
@@ -503,4 +528,4 @@ void HyperbolicRoutingCalculator::addNextHop(ndn::Name dest, std::string faceUri
|
||||
}
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
@@ -46,30 +46,56 @@ public:
|
||||
m_nRouters = nRouters;
|
||||
}
|
||||
protected:
|
||||
/*! \brief Allocate the space needed for the adj. matrix. */
|
||||
void
|
||||
allocateAdjMatrix();
|
||||
|
||||
/*! \brief Zero every cell of the matrix to ensure that the memory is safe. */
|
||||
void
|
||||
initMatrix();
|
||||
|
||||
/*! \brief Constructs an adj. matrix to calculate with.
|
||||
\param pnlsr The NLSR object that contains the LSAs that we need to iterate
|
||||
over.
|
||||
\param pMap The map to populate with the adj. data.
|
||||
*/
|
||||
void
|
||||
makeAdjMatrix(Nlsr& pnlsr, Map pMap);
|
||||
|
||||
void
|
||||
writeAdjMatrixLog();
|
||||
|
||||
/*! \brief Returns how many links a router in the matrix has.
|
||||
\param sRouter The router to count the links of.
|
||||
*/
|
||||
int
|
||||
getNumOfLinkfromAdjMatrix(int sRouter);
|
||||
|
||||
void
|
||||
freeAdjMatrix();
|
||||
|
||||
/*! \brief Adjust a link cost in the adj. matrix
|
||||
\param source The source router whose adjacency to adjust.
|
||||
\param link The adjacency of the source to adjust.
|
||||
\param linkCost The cost to change to.
|
||||
*/
|
||||
void
|
||||
adjustAdMatrix(int source, int link, double linkCost);
|
||||
|
||||
/*! \brief Populates temp. variables with the link costs for some router.
|
||||
\param source The router whose values are to be adjusted.
|
||||
\param links An integer pointer array for the link mappingNos.
|
||||
\param linkCosts A double pointer array that stores the link costs.
|
||||
|
||||
Obtains a sparse list of adjacencies and link costs for some
|
||||
router. Since this is sparse, that means while generating these
|
||||
arrays, if there is no adjacency at i in the matrix, these
|
||||
temporary variables will not contain a 0 at i, but rather will
|
||||
contain the values for the next valid adjacency.
|
||||
*/
|
||||
void
|
||||
getLinksFromAdjMatrix(int* links, double* linkCosts, int source);
|
||||
|
||||
/*! Allocates an array large enough to hold multipath calculation temps. */
|
||||
void
|
||||
allocateLinks();
|
||||
|
||||
@@ -113,12 +139,30 @@ public:
|
||||
calculatePath(Map& pMap, RoutingTable& rt, Nlsr& pnlsr);
|
||||
|
||||
private:
|
||||
/*! \brief Performs a Dijkstra's calculation over the adjacency matrix.
|
||||
\param sourceRouter The origin router to compute paths from.
|
||||
*/
|
||||
void
|
||||
doDijkstraPathCalculation(int sourceRouter);
|
||||
|
||||
/*! \brief Sort the elements of a list.
|
||||
\param Q The array that contains the elements to sort.
|
||||
\param dist The array that contains the distances.
|
||||
\param start The first element in the list to sort.
|
||||
\param element The last element in the list to sort through.
|
||||
|
||||
Sorts the list based on distance. The distances are indexed by
|
||||
their mappingNo in dist. Currently uses an insertion sort.
|
||||
*/
|
||||
void
|
||||
sortQueueByDistance(int* Q, double* dist, int start, int element);
|
||||
|
||||
/*! \brief Returns whether an element has been visited yet.
|
||||
\param Q The list of elements to look through.
|
||||
\param u The element to check.
|
||||
\param start The start of list to look through.
|
||||
\param element The end of the list to look through.
|
||||
*/
|
||||
int
|
||||
isNotExplored(int* Q, int u, int start, int element);
|
||||
|
||||
@@ -126,6 +170,10 @@ private:
|
||||
addAllLsNextHopsToRoutingTable(Nlsr& pnlsr, RoutingTable& rt,
|
||||
Map& pMap, uint32_t sourceRouter);
|
||||
|
||||
/*! \brief Determines a destination's next hop.
|
||||
\param dest The router whose next hop we want to determine.
|
||||
\param source The router to determine a next path to.
|
||||
*/
|
||||
int
|
||||
getLsNextHop(int dest, int source);
|
||||
|
||||
@@ -186,6 +234,6 @@ private:
|
||||
static const int32_t ROUTER_NOT_FOUND;
|
||||
};
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_ROUTING_TABLE_CALCULATOR_HPP
|
||||
@@ -0,0 +1,36 @@
|
||||
/* -*- 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 "routing-table-entry.hpp"
|
||||
#include "nexthop-list.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const RoutingTableEntry& rte)
|
||||
{
|
||||
os << "RoutingTableEntry("
|
||||
<< "Destination: " << rte.getDestination()
|
||||
<< "Next hop list: " << rte.getNexthopList() << ")";
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
@@ -57,11 +57,28 @@ public:
|
||||
return m_nexthopList;
|
||||
}
|
||||
|
||||
private:
|
||||
const NexthopList&
|
||||
getNexthopList() const
|
||||
{
|
||||
return m_nexthopList;
|
||||
}
|
||||
|
||||
inline bool
|
||||
operator==(RoutingTableEntry& rhs)
|
||||
{
|
||||
return ((*this).getDestination() == rhs.getDestination()
|
||||
&&
|
||||
(*this).getNexthopList() == rhs.getNexthopList());
|
||||
}
|
||||
|
||||
protected:
|
||||
ndn::Name m_destination;
|
||||
NexthopList m_nexthopList;
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const RoutingTableEntry& rte);
|
||||
|
||||
#endif //NLSR_ROUTING_TABLE_ENTRY_HPP
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_ROUTING_TABLE_ENTRY_HPP
|
||||
@@ -0,0 +1,46 @@
|
||||
/* -*- 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 "routing-table-pool-entry.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, RoutingTablePoolEntry& rtpe)
|
||||
{
|
||||
os << "RoutingTablePoolEntry("
|
||||
<< "Destination router: " << rtpe.getDestination()
|
||||
<< "Next hop list: ";
|
||||
for (auto && nh : rtpe.getNexthopList()) {
|
||||
os << nh;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
bool
|
||||
operator==(const RoutingTablePoolEntry& lhs, const RoutingTablePoolEntry& rhs)
|
||||
{
|
||||
return (lhs.getDestination() == rhs.getDestination()
|
||||
&&
|
||||
lhs.getNexthopList() == rhs.getNexthopList());
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -0,0 +1,103 @@
|
||||
/* -*- 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/>.
|
||||
*
|
||||
* \author Nicholas Gordon <nmgordon@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef NLSR_ROUTING_TABLE_POOL_ENTRY_HPP
|
||||
#define NLSR_ROUTING_TABLE_POOL_ENTRY_HPP
|
||||
|
||||
#include <iostream>
|
||||
#include <ndn-cxx/name.hpp>
|
||||
#include "nexthop-list.hpp"
|
||||
#include "routing-table-entry.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
class RoutingTablePoolEntry : public RoutingTableEntry
|
||||
{
|
||||
public:
|
||||
RoutingTablePoolEntry()
|
||||
{
|
||||
}
|
||||
|
||||
~RoutingTablePoolEntry()
|
||||
{
|
||||
}
|
||||
|
||||
RoutingTablePoolEntry(const ndn::Name& dest)
|
||||
{
|
||||
m_destination = dest;
|
||||
m_useCount = 1;
|
||||
}
|
||||
|
||||
RoutingTablePoolEntry(RoutingTableEntry& rte, uint64_t useCount)
|
||||
{
|
||||
m_destination = rte.getDestination();
|
||||
m_nexthopList = rte.getNexthopList();
|
||||
m_useCount = useCount;
|
||||
}
|
||||
|
||||
RoutingTablePoolEntry(const ndn::Name& dest, uint64_t useCount)
|
||||
{
|
||||
m_destination = dest;
|
||||
m_useCount = useCount;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
getUseCount()
|
||||
{
|
||||
return m_useCount;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
incrementUseCount()
|
||||
{
|
||||
return ++m_useCount;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
decrementUseCount()
|
||||
{
|
||||
if (m_useCount != 0) {
|
||||
return --m_useCount;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
setNexthopList(NexthopList nhl)
|
||||
{
|
||||
m_nexthopList = nhl;
|
||||
}
|
||||
|
||||
private:
|
||||
uint64_t m_useCount;
|
||||
|
||||
};
|
||||
|
||||
bool
|
||||
operator==(const RoutingTablePoolEntry& lhs, const RoutingTablePoolEntry& rhs);
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, RoutingTablePoolEntry& rtpe);
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_ROUTING_TABLE_POOL_ENTRY_HPP
|
||||
+25
-18
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
@@ -49,9 +49,20 @@ RoutingTable::calculate(Nlsr& pnlsr)
|
||||
if (pnlsr.getIsRoutingTableCalculating() == false) {
|
||||
//setting routing table calculation
|
||||
pnlsr.setIsRoutingTableCalculating(true);
|
||||
if (pnlsr.getLsdb().doesLsaExist(
|
||||
pnlsr.getConfParameter().getRouterPrefix().toUri() + "/" + "adjacency",
|
||||
std::string("adjacency"))) {
|
||||
|
||||
bool isHrEnabled = pnlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF;
|
||||
|
||||
if ((!isHrEnabled
|
||||
&&
|
||||
pnlsr.getLsdb()
|
||||
.doesLsaExist(pnlsr.getConfParameter().getRouterPrefix().toUri()
|
||||
+ "/" + "adjacency", std::string("adjacency")))
|
||||
||
|
||||
(isHrEnabled
|
||||
&&
|
||||
pnlsr.getLsdb()
|
||||
.doesLsaExist(pnlsr.getConfParameter().getRouterPrefix().toUri()
|
||||
+ "/" + "coordinate", std::string("coordinate")))) {
|
||||
if (pnlsr.getIsBuildAdjLsaSheduled() != 1) {
|
||||
_LOG_TRACE("Clearing old routing table");
|
||||
clearRoutingTable();
|
||||
@@ -73,7 +84,7 @@ RoutingTable::calculate(Nlsr& pnlsr)
|
||||
if (pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN) {
|
||||
calculateHypDryRoutingTable(pnlsr);
|
||||
}
|
||||
//need to update NPT here
|
||||
// Inform the NPT that updates have been made
|
||||
_LOG_DEBUG("Calling Update NPT With new Route");
|
||||
pnlsr.getNamePrefixTable().updateWithNewRoute();
|
||||
writeLog(pnlsr.getConfParameter().getHyperbolicState());
|
||||
@@ -106,7 +117,6 @@ RoutingTable::calculate(Nlsr& pnlsr)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RoutingTable::calculateLsRoutingTable(Nlsr& nlsr)
|
||||
{
|
||||
@@ -120,14 +130,14 @@ RoutingTable::calculateLsRoutingTable(Nlsr& nlsr)
|
||||
|
||||
LinkStateRoutingTableCalculator calculator(nRouters);
|
||||
|
||||
calculator.calculatePath(map, ndn::ref(*this), nlsr);
|
||||
calculator.calculatePath(map, std::ref(*this), nlsr);
|
||||
}
|
||||
|
||||
void
|
||||
RoutingTable::calculateHypRoutingTable(Nlsr& nlsr)
|
||||
{
|
||||
Map map;
|
||||
map.createFromAdjLsdb(nlsr);
|
||||
map.createFromCoordinateLsdb(nlsr);
|
||||
map.writeLog();
|
||||
|
||||
size_t nRouters = map.getMapSize();
|
||||
@@ -135,7 +145,7 @@ RoutingTable::calculateHypRoutingTable(Nlsr& nlsr)
|
||||
HyperbolicRoutingCalculator calculator(nRouters, false,
|
||||
nlsr.getConfParameter().getRouterPrefix());
|
||||
|
||||
calculator.calculatePaths(map, ndn::ref(*this),
|
||||
calculator.calculatePaths(map, std::ref(*this),
|
||||
nlsr.getLsdb(), nlsr.getAdjacencyList());
|
||||
}
|
||||
|
||||
@@ -151,7 +161,7 @@ RoutingTable::calculateHypDryRoutingTable(Nlsr& nlsr)
|
||||
HyperbolicRoutingCalculator calculator(nRouters, true,
|
||||
nlsr.getConfParameter().getRouterPrefix());
|
||||
|
||||
calculator.calculatePaths(map, ndn::ref(*this),
|
||||
calculator.calculatePaths(map, std::ref(*this),
|
||||
nlsr.getLsdb(), nlsr.getAdjacencyList());
|
||||
}
|
||||
|
||||
@@ -162,7 +172,7 @@ RoutingTable::scheduleRoutingTableCalculation(Nlsr& pnlsr)
|
||||
_LOG_DEBUG("Scheduling routing table calculation in " << m_routingCalcInterval);
|
||||
|
||||
m_scheduler.scheduleEvent(m_routingCalcInterval,
|
||||
ndn::bind(&RoutingTable::calculate, this, ndn::ref(pnlsr)));
|
||||
std::bind(&RoutingTable::calculate, this, std::ref(pnlsr)));
|
||||
|
||||
pnlsr.setIsRouteCalculationScheduled(true);
|
||||
}
|
||||
@@ -174,7 +184,6 @@ routingTableEntryCompare(RoutingTableEntry& rte, ndn::Name& destRouter)
|
||||
return rte.getDestination() == destRouter;
|
||||
}
|
||||
|
||||
// function related to manipulation of routing table
|
||||
void
|
||||
RoutingTable::addNextHop(const ndn::Name& destRouter, NextHop& nh)
|
||||
{
|
||||
@@ -196,7 +205,7 @@ RoutingTable::findRoutingTableEntry(const ndn::Name& destRouter)
|
||||
{
|
||||
std::list<RoutingTableEntry>::iterator it = std::find_if(m_rTable.begin(),
|
||||
m_rTable.end(),
|
||||
ndn::bind(&routingTableEntryCompare,
|
||||
std::bind(&routingTableEntryCompare,
|
||||
_1, destRouter));
|
||||
if (it != m_rTable.end()) {
|
||||
return &(*it);
|
||||
@@ -226,7 +235,6 @@ RoutingTable::writeLog(int hyperbolicState)
|
||||
}
|
||||
}
|
||||
|
||||
//function related to manipulation of dry routing table
|
||||
void
|
||||
RoutingTable::addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh)
|
||||
{
|
||||
@@ -234,7 +242,7 @@ RoutingTable::addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh)
|
||||
|
||||
std::list<RoutingTableEntry>::iterator it = std::find_if(m_dryTable.begin(),
|
||||
m_dryTable.end(),
|
||||
ndn::bind(&routingTableEntryCompare,
|
||||
std::bind(&routingTableEntryCompare,
|
||||
_1, destRouter));
|
||||
if (it == m_dryTable.end()) {
|
||||
RoutingTableEntry rte(destRouter);
|
||||
@@ -262,5 +270,4 @@ RoutingTable::clearDryRoutingTable()
|
||||
}
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
@@ -47,18 +47,34 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
/*! \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.
|
||||
|
||||
Calculates the list of next hops to every other router in the network.
|
||||
*/
|
||||
void
|
||||
calculate(Nlsr& pnlsr);
|
||||
|
||||
/*! \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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
void
|
||||
addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh);
|
||||
|
||||
RoutingTableEntry*
|
||||
findRoutingTableEntry(const ndn::Name& destRouter);
|
||||
|
||||
/*! \brief Schedules a calculation event in the event scheduler.
|
||||
\param pnlsr The NLSR whose scheduling status is needed.
|
||||
*/
|
||||
void
|
||||
scheduleRoutingTableCalculation(Nlsr& pnlsr);
|
||||
|
||||
@@ -81,12 +97,15 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
/*! \brief Calculates a link-state routing table. */
|
||||
void
|
||||
calculateLsRoutingTable(Nlsr& pnlsr);
|
||||
|
||||
/*! \brief Calculates a HR routing table. */
|
||||
void
|
||||
calculateHypRoutingTable(Nlsr& pnlsr);
|
||||
|
||||
/*! \brief Calculates a dry-run HR routing table. */
|
||||
void
|
||||
calculateHypDryRoutingTable(Nlsr& pnlsr);
|
||||
|
||||
@@ -110,6 +129,6 @@ private:
|
||||
ndn::time::seconds m_routingCalcInterval;
|
||||
};
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_ROUTING_TABLE_HPP
|
||||
@@ -1,17 +0,0 @@
|
||||
#include <ndn-cpp-dev/security/signature-sha256-with-rsa.hpp>
|
||||
#include "certificate-store-entry.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const CertificateStoreEntry& ncse)
|
||||
{
|
||||
os << "------Certificate Entry---------------" << std::endl;
|
||||
os << *(ncse.getCert()) << std::endl;
|
||||
ndn::SignatureSha256WithRsa sig(ncse.getCert()->getSignature());
|
||||
ndn::Name keyName = sig.getKeyLocator().getName();
|
||||
os << "Signee : " << keyName.toUri() << std::endl;
|
||||
os << "Cert Seq Num: " << ncse.getCertSeqNum() << std::endl;
|
||||
os << "Is Signer Verified: " << ncse.getIsSignerVerified() << std::endl;
|
||||
return os;
|
||||
}
|
||||
}//namespace nlsr
|
||||
@@ -1,72 +0,0 @@
|
||||
#ifndef NLSR_CERT_STORE_ENTRY_HPP
|
||||
#define NLSR_CERT_STORE_ENTRY_HPP
|
||||
|
||||
#include <iostream>
|
||||
#include <ndn-cpp-dev/face.hpp>
|
||||
#include <ndn-cpp-dev/security/identity-certificate.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
class CertificateStoreEntry
|
||||
{
|
||||
public:
|
||||
CertificateStoreEntry()
|
||||
: m_cert(ndn::make_shared<ndn::IdentityCertificate>())
|
||||
, m_certSeqNum(0)
|
||||
, m_isSignerVerified(false)
|
||||
{}
|
||||
|
||||
CertificateStoreEntry(ndn::shared_ptr<ndn::IdentityCertificate> pcert
|
||||
, uint32_t csn, bool isv)
|
||||
: m_cert(pcert)
|
||||
, m_certSeqNum(csn)
|
||||
, m_isSignerVerified(isv)
|
||||
{}
|
||||
|
||||
ndn::shared_ptr<ndn::IdentityCertificate>
|
||||
getCert() const
|
||||
{
|
||||
return m_cert;
|
||||
}
|
||||
|
||||
void
|
||||
setCert(ndn::shared_ptr<ndn::IdentityCertificate> pcert)
|
||||
{
|
||||
m_cert = pcert;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
getCertSeqNum() const
|
||||
{
|
||||
return m_certSeqNum;
|
||||
}
|
||||
|
||||
void
|
||||
setCertSeqNum(uint32_t csn)
|
||||
{
|
||||
m_certSeqNum = csn;
|
||||
}
|
||||
|
||||
bool
|
||||
getIsSignerVerified() const
|
||||
{
|
||||
return m_isSignerVerified;
|
||||
}
|
||||
|
||||
void
|
||||
setIsSignerVerified(bool isv)
|
||||
{
|
||||
m_isSignerVerified = isv;
|
||||
}
|
||||
|
||||
private:
|
||||
ndn::shared_ptr<ndn::IdentityCertificate> m_cert;
|
||||
uint32_t m_certSeqNum;
|
||||
bool m_isSignerVerified;
|
||||
};
|
||||
/* Debugging Purpose */
|
||||
std::ostream&
|
||||
operator <<(std::ostream& os, const CertificateStoreEntry& ncse);
|
||||
|
||||
}//namespace NLSR
|
||||
|
||||
#endif //NLSR_CERT_STORE_ENTRY_HPP
|
||||
@@ -1,231 +0,0 @@
|
||||
#include <ndn-cpp-dev/security/signature-sha256-with-rsa.hpp>
|
||||
#include <ndn-cpp-dev/security/key-chain.hpp>
|
||||
#include "certificate-store.hpp"
|
||||
#include "waiting-list-entry.hpp"
|
||||
#include "key-manager.hpp"
|
||||
|
||||
|
||||
namespace nlsr {
|
||||
static bool
|
||||
nlsrCertificateStoreEntryCompare(CertificateStoreEntry& ncse1,
|
||||
CertificateStoreEntry& ncse2)
|
||||
|
||||
{
|
||||
int sizeDiff = ncse1.getCert()->getName().size() -
|
||||
ncse2.getCert()->getName().size();
|
||||
return (ncse2.getCert()->getName().isPrefixOf(ncse1.getCert()->getName()) &&
|
||||
(sizeDiff <= 1 && sizeDiff >= 0));
|
||||
}
|
||||
|
||||
static bool
|
||||
nlsrCertificateStoreEntryCompareByName(CertificateStoreEntry& ncse1,
|
||||
std::string compCertName)
|
||||
|
||||
{
|
||||
ndn::Name ccn(compCertName);
|
||||
int sizeDiff = ncse1.getCert()->getName().size() - ccn.size();
|
||||
return (ccn.isPrefixOf(ncse1.getCert()->getName()) &&
|
||||
(sizeDiff <= 1 && sizeDiff >= 0));
|
||||
}
|
||||
|
||||
void
|
||||
CertificateStore::updateWaitingList(std::string respCertName)
|
||||
{
|
||||
ndn::Name tmpName(respCertName);
|
||||
respCertName = tmpName.getPrefix(-1).toUri();
|
||||
std::pair<WaitingListEntry, bool> chkWle =
|
||||
m_waitingList.getWaitingListEntry(respCertName);
|
||||
if (chkWle.second)
|
||||
{
|
||||
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool> sc =
|
||||
getCertificateFromStore(respCertName);
|
||||
std::list<std::string> waitees = (chkWle.first).getWaitingCerts();
|
||||
for (std::list<std::string>::iterator it = waitees.begin();
|
||||
it != waitees.end(); ++it)
|
||||
{
|
||||
KeyManager km;
|
||||
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool> wc =
|
||||
getCertificateFromStore(*(it));
|
||||
if (wc.second && sc.second)
|
||||
{
|
||||
if (km.verifySignature(*(wc.first), sc.first->getPublicKeyInfo()))
|
||||
{
|
||||
//1. Update Certificate Store
|
||||
setCertificateIsVerified(*(it), true);
|
||||
//2. Call updateWaitingList for waitee ( *(it) )
|
||||
updateWaitingList(*(it));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//remove that entry from waiting list
|
||||
m_waitingList.remove(respCertName);
|
||||
}
|
||||
|
||||
void
|
||||
CertificateStore::updateWaitingList(CertificateStoreEntry& ncse)
|
||||
{
|
||||
if (ncse.getIsSignerVerified())
|
||||
{
|
||||
updateWaitingList(ncse.getCert()->getName().toUri());
|
||||
}
|
||||
else
|
||||
{
|
||||
ndn::SignatureSha256WithRsa signature(ncse.getCert()->getSignature());
|
||||
m_waitingList.add(signature.getKeyLocator().getName().toUri(),
|
||||
ncse.getCert()->getName().toUri());
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CertificateStore::addCertificate(CertificateStoreEntry& ncse)
|
||||
{
|
||||
std::list<CertificateStoreEntry>::iterator it =
|
||||
std::find_if(m_certTable.begin(), m_certTable.end(),
|
||||
bind(&nlsrCertificateStoreEntryCompare, _1, ncse));
|
||||
if (it == m_certTable.end())
|
||||
{
|
||||
m_certTable.push_back(ncse);
|
||||
updateWaitingList(ncse);
|
||||
return true;
|
||||
}
|
||||
else if (it != m_certTable.end())
|
||||
{
|
||||
if ((*it).getCertSeqNum() < ncse.getCertSeqNum())
|
||||
{
|
||||
m_certTable.erase(it);
|
||||
m_certTable.push_back(ncse);
|
||||
updateWaitingList(ncse);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
CertificateStore::addCertificate(
|
||||
ndn::shared_ptr<ndn::IdentityCertificate> pcert, uint32_t csn, bool isv)
|
||||
{
|
||||
CertificateStoreEntry ncse(pcert, csn, isv);
|
||||
return addCertificate(ncse);
|
||||
}
|
||||
|
||||
std::pair<uint32_t, bool>
|
||||
CertificateStore::getCertificateSeqNum(std::string certName)
|
||||
{
|
||||
std::list<CertificateStoreEntry>::iterator it =
|
||||
std::find_if(m_certTable.begin(), m_certTable.end(),
|
||||
bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
|
||||
if (it == m_certTable.end())
|
||||
{
|
||||
return std::make_pair(0, false);
|
||||
}
|
||||
return std::make_pair((*it).getCertSeqNum(), true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
CertificateStore::setCertificateIsVerified(std::string certName,
|
||||
bool isVerified)
|
||||
{
|
||||
std::list<CertificateStoreEntry>::iterator it =
|
||||
std::find_if(m_certTable.begin(), m_certTable.end(),
|
||||
bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
|
||||
if (it != m_certTable.end())
|
||||
{
|
||||
it->setIsSignerVerified(true);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CertificateStore::getCertificateIsVerified(std::string certName)
|
||||
{
|
||||
std::list<CertificateStoreEntry>::iterator it =
|
||||
std::find_if(m_certTable.begin(), m_certTable.end(),
|
||||
bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
|
||||
if (it != m_certTable.end())
|
||||
{
|
||||
return it->getIsSignerVerified();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool>
|
||||
CertificateStore::getCertificateFromStore(const std::string certName)
|
||||
{
|
||||
std::list<CertificateStoreEntry>::iterator it =
|
||||
std::find_if(m_certTable.begin(), m_certTable.end(),
|
||||
bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
|
||||
if (it == m_certTable.end())
|
||||
{
|
||||
ndn::shared_ptr<ndn::IdentityCertificate> cert =
|
||||
ndn::make_shared<ndn::IdentityCertificate>();
|
||||
return std::make_pair(cert, false);
|
||||
}
|
||||
return std::make_pair((*it).getCert(), true);
|
||||
}
|
||||
|
||||
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool>
|
||||
CertificateStore::getCertificateFromStore(
|
||||
const std::string certName, uint64_t checkSeqNum)
|
||||
{
|
||||
std::list<CertificateStoreEntry>::iterator it =
|
||||
std::find_if(m_certTable.begin(), m_certTable.end(),
|
||||
bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
|
||||
if (it == m_certTable.end())
|
||||
{
|
||||
ndn::shared_ptr<ndn::IdentityCertificate> cert =
|
||||
ndn::make_shared<ndn::IdentityCertificate>();
|
||||
return std::make_pair(cert, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((*it).getCertSeqNum() == checkSeqNum)
|
||||
{
|
||||
return std::make_pair((*it).getCert(), true);
|
||||
}
|
||||
}
|
||||
return std::make_pair((*it).getCert(), false);
|
||||
}
|
||||
|
||||
bool
|
||||
CertificateStore::isCertificateNewInStore(const std::string certName,
|
||||
int checkSeqNo)
|
||||
{
|
||||
std::list<CertificateStoreEntry>::iterator it =
|
||||
std::find_if(m_certTable.begin(), m_certTable.end(),
|
||||
bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
|
||||
if (it != m_certTable.end())
|
||||
{
|
||||
return (*it).getCertSeqNum() < checkSeqNo ;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CertificateStore::removeCertificateFromStroe(const std::string certName)
|
||||
{
|
||||
std::list<CertificateStoreEntry>::iterator it =
|
||||
std::find_if(m_certTable.begin(), m_certTable.end(),
|
||||
bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
|
||||
if (it != m_certTable.end())
|
||||
{
|
||||
m_certTable.erase(it);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
CertificateStore::print()
|
||||
{
|
||||
std::list<CertificateStoreEntry>::iterator it;
|
||||
for (it = m_certTable.begin(); it != m_certTable.end(); ++it)
|
||||
{
|
||||
std::cout << (*it) << std::endl;
|
||||
}
|
||||
std::cout << m_waitingList << std::endl;
|
||||
}
|
||||
|
||||
} //namespace nlsr
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "../test-access-control.hpp"
|
||||
|
||||
#include <ndn-cxx/interest.hpp>
|
||||
#include <ndn-cxx/security/identity-certificate.hpp>
|
||||
#include <ndn-cxx/security/v1/identity-certificate.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace security {
|
||||
@@ -35,7 +35,7 @@ class CertificateStore
|
||||
{
|
||||
public:
|
||||
void
|
||||
insert(shared_ptr<ndn::IdentityCertificate> certificate)
|
||||
insert(std::shared_ptr<ndn::IdentityCertificate> certificate)
|
||||
{
|
||||
if (certificate != nullptr) {
|
||||
// Key is cert name without version
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<const ndn::IdentityCertificate>
|
||||
std::shared_ptr<const ndn::IdentityCertificate>
|
||||
find(const ndn::Name& certificateNameWithoutVersion) const
|
||||
{
|
||||
CertMap::const_iterator it = m_certificates.find(certificateNameWithoutVersion);
|
||||
@@ -63,7 +63,7 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::map<ndn::Name, shared_ptr<ndn::IdentityCertificate>> CertMap;
|
||||
typedef std::map<ndn::Name, std::shared_ptr<ndn::IdentityCertificate>> CertMap;
|
||||
CertMap m_certificates;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
#ifndef NLSR_CERT_STORE_HPP
|
||||
#define NLSR_CERT_STORE_HPP
|
||||
|
||||
#include <list>
|
||||
#include <ndn-cpp-dev/security/identity-certificate.hpp>
|
||||
#include "certificate-store-entry.hpp"
|
||||
#include "waiting-list.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
class CertificateStore
|
||||
{
|
||||
public:
|
||||
CertificateStore()
|
||||
: m_certTable()
|
||||
, m_waitingList()
|
||||
{}
|
||||
|
||||
bool
|
||||
addCertificate(CertificateStoreEntry& ncse);
|
||||
|
||||
bool
|
||||
addCertificate(ndn::shared_ptr<ndn::IdentityCertificate> pcert
|
||||
, uint32_t csn, bool isv);
|
||||
|
||||
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool>
|
||||
getCertificateFromStore(const std::string certName);
|
||||
|
||||
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool>
|
||||
getCertificateFromStore(const std::string certName, uint64_t checkSeqNum);
|
||||
|
||||
bool
|
||||
removeCertificateFromStroe(const std::string certName);
|
||||
|
||||
bool
|
||||
isCertificateNewInStore(const std::string certName, int checkSeqNo);
|
||||
|
||||
std::pair<uint32_t, bool>
|
||||
getCertificateSeqNum(std::string certName);
|
||||
|
||||
void
|
||||
print();
|
||||
|
||||
void
|
||||
setCertificateIsVerified(std::string certName, bool isVerified);
|
||||
|
||||
bool
|
||||
getCertificateIsVerified(std::string certName);
|
||||
|
||||
private:
|
||||
void
|
||||
updateWaitingList(CertificateStoreEntry& ncse);
|
||||
|
||||
void
|
||||
updateWaitingList(std::string respCertName);
|
||||
|
||||
private:
|
||||
std::list<CertificateStoreEntry> m_certTable;
|
||||
WaitingList m_waitingList;
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
|
||||
#endif // NLSR_CERT_STORE_HPP
|
||||
@@ -1,400 +0,0 @@
|
||||
#include <ndn-cpp-dev/security/identity-certificate.hpp>
|
||||
#include <ndn-cpp-dev/encoding/block.hpp>
|
||||
#include <ndn-cpp-dev/util/io.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "sequencing-manager.hpp"
|
||||
#include "key-manager.hpp"
|
||||
#include "nlsr.hpp"
|
||||
|
||||
|
||||
namespace nlsr {
|
||||
bool
|
||||
KeyManager::initialize(ConfParameter& cp)
|
||||
{
|
||||
initCertSeqFromFile(cp.getSeqFileDir());
|
||||
if (!loadAllCertificates(cp.getCertDir()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_nlsrRootKeyPrefix = cp.getRootKeyPrefix();
|
||||
string processIdentityName(cp.getRootKeyPrefix());
|
||||
processIdentityName += "/";
|
||||
processIdentityName += cp.getSiteName();
|
||||
processIdentityName += "/";
|
||||
processIdentityName += "R.Start";
|
||||
processIdentityName += "/";
|
||||
processIdentityName += cp.getRouterName();
|
||||
ndn::Name ri(processIdentityName);
|
||||
std::cout << "Router Identity: " << ri.toUri() << std::endl;
|
||||
m_routerIdentity = ri;
|
||||
processIdentityName += "/";
|
||||
processIdentityName += "nlsr";
|
||||
cout << "Proces Identity Name: " << processIdentityName << endl;
|
||||
ndn::Name identityName(processIdentityName);
|
||||
m_processIdentity = identityName;
|
||||
ndn::KeyChain::deleteIdentity(m_processIdentity);
|
||||
m_processCertName = ndn::KeyChain::createIdentity(m_processIdentity);
|
||||
cout << "Certificate Name: " << m_processCertName.toUri() << endl;
|
||||
m_processKeyName = m_processCertName.getPrefix(-2);
|
||||
cout << "Key Name: " << m_processKeyName.toUri() << endl;
|
||||
ndn::shared_ptr<ndn::IdentityCertificate> cert =
|
||||
getCertificate(m_processCertName);
|
||||
signByIdentity(*(cert), m_routerIdentity);
|
||||
m_certStore.addCertificate(cert, m_certSeqNo, true);
|
||||
m_certStore.print();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
KeyManager::loadAllCertificates(std::string certDirPath)
|
||||
{
|
||||
std::string filePath = certDirPath;
|
||||
if (filePath.empty())
|
||||
{
|
||||
SequencingManager sm;
|
||||
filePath = sm.getUserHomeDirectory();
|
||||
filePath += "/nlsrCertDir";
|
||||
}
|
||||
return loadCertificate(filePath + "/root.cert", KEY_TYPE_ROOT)
|
||||
&& loadCertificate(filePath + "/site.cert", KEY_TYPE_SITE)
|
||||
&& loadCertificate(filePath + "/operator.cert", KEY_TYPE_OPERATOR)
|
||||
&& loadCertificate(filePath + "/router.cert", KEY_TYPE_ROUTER) ;
|
||||
}
|
||||
|
||||
bool
|
||||
KeyManager::loadCertificate(std::string inputFile, nlsrKeyType keyType)
|
||||
{
|
||||
try
|
||||
{
|
||||
ndn::shared_ptr<ndn::IdentityCertificate> cert =
|
||||
ndn::io::load<ndn::IdentityCertificate>(inputFile, ndn::io::BASE_64);
|
||||
ndn::Name certName = cert->getName();
|
||||
switch (keyType)
|
||||
{
|
||||
case KEY_TYPE_ROOT:
|
||||
m_certStore.addCertificate(cert, 10, true);
|
||||
m_rootCertName = certName;
|
||||
std::cout << "Root Cert: " << m_rootCertName << std::endl;
|
||||
break;
|
||||
case KEY_TYPE_SITE:
|
||||
m_certStore.addCertificate(cert, 10, true);
|
||||
m_siteCertName = certName;
|
||||
std::cout << "Site Cert: " << m_siteCertName << std::endl;
|
||||
break;
|
||||
case KEY_TYPE_OPERATOR:
|
||||
m_certStore.addCertificate(cert, 10, true);
|
||||
m_opCertName = certName;
|
||||
std::cout << "Operator Cert: " << m_opCertName << std::endl;
|
||||
break;
|
||||
case KEY_TYPE_ROUTER:
|
||||
m_certStore.addCertificate(cert, m_certSeqNo, true);
|
||||
m_routerCertName = certName;
|
||||
std::cout << "Router Cert: " << m_routerCertName << std::endl;
|
||||
break;
|
||||
case KEY_TYPE_PROCESS:
|
||||
m_certStore.addCertificate(cert, m_certSeqNo, true);
|
||||
m_processCertName = certName;
|
||||
std::cout << "Process Cert: " << m_processCertName << std::endl;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ndn::Name
|
||||
KeyManager::getProcessCertName()
|
||||
{
|
||||
return m_processCertName;
|
||||
}
|
||||
|
||||
ndn::Name
|
||||
KeyManager::getRouterCertName()
|
||||
{
|
||||
return m_routerCertName;
|
||||
}
|
||||
|
||||
ndn::Name
|
||||
KeyManager::getOperatorCertName()
|
||||
{
|
||||
return m_opCertName;
|
||||
}
|
||||
|
||||
ndn::Name
|
||||
KeyManager::getSiteCertName()
|
||||
{
|
||||
return m_siteCertName;
|
||||
}
|
||||
|
||||
ndn::Name
|
||||
KeyManager::getRootCertName()
|
||||
{
|
||||
return m_rootCertName;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
KeyManager::getCertSeqNo()
|
||||
{
|
||||
return m_certSeqNo;
|
||||
}
|
||||
|
||||
void
|
||||
KeyManager::setCerSeqNo(uint32_t csn)
|
||||
{
|
||||
m_certSeqNo = csn;
|
||||
}
|
||||
|
||||
void
|
||||
KeyManager::initCertSeqFromFile(string certSeqFileDir)
|
||||
{
|
||||
m_certSeqFileNameWithPath = certSeqFileDir;
|
||||
if (m_certSeqFileNameWithPath.empty())
|
||||
{
|
||||
SequencingManager sm;
|
||||
m_certSeqFileNameWithPath = sm.getUserHomeDirectory();
|
||||
}
|
||||
m_certSeqFileNameWithPath += "/nlsrCertSeqNo.txt";
|
||||
cout << "Key Seq File Name: " << m_certSeqFileNameWithPath << endl;
|
||||
std::ifstream inputFile(m_certSeqFileNameWithPath.c_str(), ios::binary);
|
||||
if (inputFile.good())
|
||||
{
|
||||
inputFile >> m_certSeqNo;
|
||||
m_certSeqNo++;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_certSeqNo = 1;
|
||||
}
|
||||
writeCertSeqToFile();
|
||||
}
|
||||
|
||||
void
|
||||
KeyManager::writeCertSeqToFile()
|
||||
{
|
||||
std::ofstream outputFile(m_certSeqFileNameWithPath.c_str(), ios::binary);
|
||||
outputFile << m_certSeqNo;
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
bool
|
||||
KeyManager::isNewCertificate(std::string certName, int checkSeqNum)
|
||||
{
|
||||
return m_certStore.isCertificateNewInStore(certName, checkSeqNum);
|
||||
}
|
||||
|
||||
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool>
|
||||
KeyManager::getCertificateFromStore(const std::string certName, int checkSeqNum)
|
||||
{
|
||||
return m_certStore.getCertificateFromStore(certName, checkSeqNum);
|
||||
}
|
||||
|
||||
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool>
|
||||
KeyManager::getCertificateFromStore(const std::string certName)
|
||||
{
|
||||
return m_certStore.getCertificateFromStore(certName);
|
||||
}
|
||||
|
||||
bool
|
||||
KeyManager::addCertificate(ndn::shared_ptr<ndn::IdentityCertificate> pcert
|
||||
, uint32_t csn, bool isv)
|
||||
{
|
||||
return m_certStore.addCertificate(pcert, csn, isv);
|
||||
}
|
||||
|
||||
std::pair<uint32_t, bool>
|
||||
KeyManager::getCertificateSeqNum(std::string certName)
|
||||
{
|
||||
return m_certStore.getCertificateSeqNum(certName);
|
||||
}
|
||||
|
||||
nlsrKeyType
|
||||
KeyManager::getKeyTypeFromName(const std::string keyName)
|
||||
{
|
||||
Tokenizer nt(keyName, "/");
|
||||
std::string KEY("KEY");
|
||||
std::string opHandle("O.Start");
|
||||
std::string routerHandle("R.Start");
|
||||
std::string processHandle("nlsr");
|
||||
if (nt.getTokenString(0, nt.getTokenPosition(KEY) - 1) == m_nlsrRootKeyPrefix)
|
||||
{
|
||||
return KEY_TYPE_ROOT;
|
||||
}
|
||||
else if (nt.doesTokenExist(opHandle))
|
||||
{
|
||||
return KEY_TYPE_OPERATOR;
|
||||
}
|
||||
else if (nt.doesTokenExist(routerHandle) &&
|
||||
nt.doesTokenExist(processHandle))
|
||||
{
|
||||
return KEY_TYPE_PROCESS;
|
||||
}
|
||||
else if (nt.doesTokenExist(routerHandle) &&
|
||||
!nt.doesTokenExist(processHandle))
|
||||
{
|
||||
return KEY_TYPE_ROUTER;
|
||||
}
|
||||
else
|
||||
{
|
||||
return KEY_TYPE_SITE;
|
||||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
KeyManager::getRouterName(const std::string name)
|
||||
{
|
||||
std::string routerName;
|
||||
std::string rkp(m_nlsrRootKeyPrefix);
|
||||
Tokenizer ntRkp(rkp, "/");
|
||||
Tokenizer nt(name, "/");
|
||||
std::string KEY("KEY");
|
||||
std::string opHandle("O.Start");
|
||||
std::string routerHandle("R.Start");
|
||||
std::string processHandle("nlsr");
|
||||
std::string infoHandle("info");
|
||||
std::string lsaHandle("LSA");
|
||||
if (nt.doesTokenExist(processHandle) && nt.doesTokenExist(routerHandle))
|
||||
{
|
||||
routerName = "/ndn" +
|
||||
nt.getTokenString(ntRkp.getTokenNumber(),
|
||||
nt.getTokenPosition(routerHandle) - 1) +
|
||||
nt.getTokenString(nt.getTokenPosition(routerHandle) + 1,
|
||||
nt.getTokenPosition(processHandle) - 1);
|
||||
}
|
||||
else if (nt.doesTokenExist(routerHandle) && !nt.doesTokenExist(infoHandle)
|
||||
&& !nt.doesTokenExist(lsaHandle))
|
||||
{
|
||||
routerName = "/ndn" +
|
||||
nt.getTokenString(ntRkp.getTokenNumber(),
|
||||
nt.getTokenPosition(routerHandle) - 1) +
|
||||
nt.getTokenString(nt.getTokenPosition(routerHandle) + 1,
|
||||
nt.getTokenPosition(KEY) - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nt.doesTokenExist(infoHandle))
|
||||
{
|
||||
routerName = nt.getTokenString(0, nt.getTokenPosition(infoHandle) - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
routerName = nt.getTokenString(nt.getTokenPosition(lsaHandle) + 1,
|
||||
nt.getTokenNumber() - 4);
|
||||
}
|
||||
}
|
||||
return routerName;
|
||||
}
|
||||
|
||||
std::string
|
||||
KeyManager::getSiteName(const std::string name)
|
||||
{
|
||||
std::string siteName;
|
||||
std::string routerName;
|
||||
std::string rkp(m_nlsrRootKeyPrefix);
|
||||
Tokenizer ntRkp(rkp, "/");
|
||||
Tokenizer nt(name, "/");
|
||||
std::string KEY("KEY");
|
||||
std::string opHandle("O.Start");
|
||||
std::string routerHandle("R.Start");
|
||||
if (nt.doesTokenExist(routerHandle))
|
||||
{
|
||||
siteName = "/ndn" + nt.getTokenString(ntRkp.getTokenNumber(),
|
||||
nt.getTokenPosition(routerHandle) - 1);
|
||||
}
|
||||
else if (nt.doesTokenExist(opHandle))
|
||||
{
|
||||
siteName = "/ndn" + nt.getTokenString(ntRkp.getTokenNumber(),
|
||||
nt.getTokenPosition(opHandle) - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
siteName = "/ndn" + nt.getTokenString(ntRkp.getTokenNumber(),
|
||||
nt.getTokenPosition(KEY) - 1);
|
||||
}
|
||||
return siteName;
|
||||
}
|
||||
|
||||
std::string
|
||||
KeyManager::getRootName(const std::string name)
|
||||
{
|
||||
std::string rName;
|
||||
Tokenizer nt(name, "/");
|
||||
std::string rkp(m_nlsrRootKeyPrefix);
|
||||
Tokenizer ntRkp(rkp, "/");
|
||||
rName = nt.getTokenString(0, ntRkp.getTokenNumber() - 1);
|
||||
return rName;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
KeyManager::verifyCertPacket(Nlsr& pnlsr, ndn::IdentityCertificate& packet)
|
||||
{
|
||||
std::cout << "KeyManager::verifyCertPacket Called" << std::endl;
|
||||
ndn::SignatureSha256WithRsa signature(packet.getSignature());
|
||||
std::string signingCertName = signature.getKeyLocator().getName().toUri();
|
||||
std::string packetName = packet.getName().toUri();
|
||||
std::cout << "Packet Name: " << packetName << std::endl;
|
||||
std::cout << "Signee Name: " << signingCertName << std::endl;
|
||||
int paketCertType = getKeyTypeFromName(packetName);
|
||||
int signingCertType = getKeyTypeFromName(signingCertName);
|
||||
if (signingCertType > paketCertType) //lower level Cert can not sign
|
||||
{
|
||||
//upper level Cert
|
||||
return false;
|
||||
}
|
||||
if ((signingCertType == paketCertType) && (paketCertType != KEY_TYPE_ROOT))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool> signee =
|
||||
m_certStore.getCertificateFromStore(signingCertName);
|
||||
if (signee.second)
|
||||
{
|
||||
switch (paketCertType)
|
||||
{
|
||||
case KEY_TYPE_ROOT:
|
||||
return ((getRootName(packetName) == m_nlsrRootKeyPrefix) &&
|
||||
verifySignature(packet, signee.first->getPublicKeyInfo()));
|
||||
break;
|
||||
case KEY_TYPE_SITE:
|
||||
return ((getRootName(packetName) == getRootName(signingCertName)) &&
|
||||
verifySignature(packet, signee.first->getPublicKeyInfo()) &&
|
||||
m_certStore.getCertificateIsVerified(signingCertName));
|
||||
break;
|
||||
case KEY_TYPE_OPERATOR:
|
||||
return ((getSiteName(packetName) == getSiteName(signingCertName)) &&
|
||||
verifySignature(packet, signee.first->getPublicKeyInfo()) &&
|
||||
m_certStore.getCertificateIsVerified(signingCertName));
|
||||
break;
|
||||
case KEY_TYPE_ROUTER:
|
||||
return ((getSiteName(packetName) == getSiteName(signingCertName)) &&
|
||||
verifySignature(packet, signee.first->getPublicKeyInfo()) &&
|
||||
m_certStore.getCertificateIsVerified(signingCertName));
|
||||
break;
|
||||
case KEY_TYPE_PROCESS:
|
||||
return ((getRouterName(packetName) == getRouterName(signingCertName)) &&
|
||||
verifySignature(packet, signee.first->getPublicKeyInfo()) &&
|
||||
m_certStore.getCertificateIsVerified(signingCertName));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Certificate Not Found in store. Sending Interest" << std::endl;
|
||||
pnlsr.getIm().expressInterest(signingCertName, 3,
|
||||
pnlsr.getConfParameter().getInterestResendTime());
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
|
||||
|
||||
|
||||
@@ -1,273 +0,0 @@
|
||||
#ifndef NLSR_KM_HPP
|
||||
#define NLSR_KM_HPP
|
||||
|
||||
#include <ndn-cpp-dev/face.hpp>
|
||||
#include <ndn-cpp-dev/data.hpp>
|
||||
#include <ndn-cpp-dev/security/key-chain.hpp>
|
||||
#include <ndn-cpp-dev/security/validator.hpp>
|
||||
#include <ndn-cpp-dev/util/random.hpp>
|
||||
#include <ndn-cpp-dev/security/identity-certificate.hpp>
|
||||
#include <list>
|
||||
#include "conf-parameter.hpp"
|
||||
#include "certificate-store.hpp"
|
||||
#include "utility/tokenizer.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
class Nlsr;
|
||||
enum nlsrKeyType
|
||||
{
|
||||
KEY_TYPE_ROOT,
|
||||
KEY_TYPE_SITE,
|
||||
KEY_TYPE_OPERATOR,
|
||||
KEY_TYPE_ROUTER,
|
||||
KEY_TYPE_PROCESS,
|
||||
KEY_TYPE_UNKNOWN
|
||||
};
|
||||
|
||||
enum nlsrContentType
|
||||
{
|
||||
CONTENT_TYPE_DATA,
|
||||
CONTENT_TYPE_CERT
|
||||
};
|
||||
|
||||
class KeyManager: public ndn::KeyChain, public ndn::Validator
|
||||
{
|
||||
typedef SecPublicInfo::Error InfoError;
|
||||
typedef SecTpm::Error TpmError;
|
||||
public:
|
||||
using ndn::KeyChain::addCertificate;
|
||||
KeyManager()
|
||||
: m_certSeqNo(1)
|
||||
, m_nlsrRootKeyPrefix()
|
||||
, m_certStore()
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
initialize(ConfParameter& cp);
|
||||
|
||||
|
||||
|
||||
void
|
||||
checkPolicy(const ndn::Data& data,
|
||||
int stepCount,
|
||||
const ndn::OnDataValidated& onValidated,
|
||||
const ndn::OnDataValidationFailed& onValidationFailed,
|
||||
std::vector<ndn::shared_ptr<ndn::ValidationRequest> >& nextSteps)
|
||||
{}
|
||||
|
||||
void
|
||||
checkPolicy(const ndn::Interest& interest,
|
||||
int stepCount,
|
||||
const ndn::OnInterestValidated& onValidated,
|
||||
const ndn::OnInterestValidationFailed& onValidationFailed,
|
||||
std::vector<ndn::shared_ptr<ndn::ValidationRequest> >& nextSteps)
|
||||
{}
|
||||
|
||||
void
|
||||
signData(ndn::Data& data)
|
||||
{
|
||||
ndn::KeyChain::signByIdentity(data, m_processIdentity);
|
||||
}
|
||||
|
||||
template<typename T> void
|
||||
signByIdentity(T& packet, ndn::Name signeeIdentity)
|
||||
{
|
||||
ndn::KeyChain::signByIdentity(packet, signeeIdentity);
|
||||
}
|
||||
|
||||
ndn::Name
|
||||
createIdentity(const ndn::Name identityName)
|
||||
{
|
||||
return ndn::KeyChain::createIdentity(identityName);
|
||||
}
|
||||
|
||||
ndn::Name
|
||||
createIdentity(const ndn::Name identityName, const ndn::Name signee)
|
||||
{
|
||||
ndn::KeyChain::addIdentity(identityName);
|
||||
ndn::Name keyName;
|
||||
try
|
||||
{
|
||||
keyName = ndn::KeyChain::getDefaultKeyNameForIdentity(identityName);
|
||||
}
|
||||
catch (InfoError& e)
|
||||
{
|
||||
keyName = ndn::KeyChain::generateRSAKeyPairAsDefault(identityName, true);
|
||||
}
|
||||
ndn::shared_ptr<ndn::PublicKey> pubKey;
|
||||
try
|
||||
{
|
||||
pubKey = ndn::KeyChain::getPublicKey(keyName);
|
||||
}
|
||||
catch (InfoError& e)
|
||||
{
|
||||
return identityName;
|
||||
}
|
||||
ndn::Name certName;
|
||||
try
|
||||
{
|
||||
certName = ndn::KeyChain::getDefaultCertificateNameForKey(keyName);
|
||||
}
|
||||
catch (InfoError& e)
|
||||
{
|
||||
ndn::shared_ptr<ndn::IdentityCertificate> certificate =
|
||||
ndn::make_shared<ndn::IdentityCertificate>();
|
||||
ndn::Name certificateName = keyName.getPrefix(-1);
|
||||
certificateName.append("KEY").append(
|
||||
keyName.get(-1)).append("ID-CERT").appendVersion();
|
||||
certificate->setName(certificateName);
|
||||
certificate->setNotBefore(ndn::time::system_clock::now());
|
||||
certificate->setNotAfter(ndn::time::system_clock::now() + ndn::time::days(
|
||||
7300) /* 1 year*/);
|
||||
certificate->setPublicKeyInfo(*pubKey);
|
||||
certificate->addSubjectDescription(
|
||||
ndn::CertificateSubjectDescription("2.5.4.41",
|
||||
keyName.toUri()));
|
||||
certificate->encode();
|
||||
try
|
||||
{
|
||||
ndn::KeyChain::signByIdentity(*certificate, signee);
|
||||
}
|
||||
catch (InfoError& e)
|
||||
{
|
||||
try
|
||||
{
|
||||
ndn::KeyChain::deleteIdentity(identityName);
|
||||
}
|
||||
catch (InfoError& e)
|
||||
{
|
||||
}
|
||||
return identityName;
|
||||
}
|
||||
certName = certificate->getName();
|
||||
}
|
||||
return certName;
|
||||
}
|
||||
|
||||
void
|
||||
printCertStore()
|
||||
{
|
||||
m_certStore.print();
|
||||
}
|
||||
|
||||
private:
|
||||
bool
|
||||
verifyDataPacket(ndn::Data packet)
|
||||
{
|
||||
std::cout << "KeyManager::verifyDataPacket Called" << std::endl;
|
||||
ndn::SignatureSha256WithRsa signature(packet.getSignature());
|
||||
std::string signingCertName = signature.getKeyLocator().getName().toUri();
|
||||
std::string packetName = packet.getName().toUri();
|
||||
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool> signee =
|
||||
m_certStore.getCertificateFromStore(signingCertName);
|
||||
if (signee.second)
|
||||
{
|
||||
std::string routerNameFromPacketName = getRouterName(packetName);
|
||||
std::string routerNameFromCertName = getRouterName(signingCertName);
|
||||
return ((routerNameFromPacketName == routerNameFromCertName) &&
|
||||
verifySignature(packet, signee.first->getPublicKeyInfo()) &&
|
||||
m_certStore.getCertificateIsVerified(signingCertName));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
verifyCertPacket(Nlsr& pnlsr, ndn::IdentityCertificate& packet);
|
||||
|
||||
public:
|
||||
template<typename T> bool
|
||||
verify(T& packet)
|
||||
{
|
||||
std::cout << "KeyManager::verify Called" << std::endl;
|
||||
return verifyDataPacket(packet);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
verify(Nlsr& pnlsr, ndn::IdentityCertificate& packet)
|
||||
{
|
||||
return verifyCertPacket(pnlsr, packet);
|
||||
}
|
||||
|
||||
ndn::Name
|
||||
getProcessCertName();
|
||||
|
||||
ndn::Name
|
||||
getRouterCertName();
|
||||
|
||||
ndn::Name
|
||||
getOperatorCertName();
|
||||
|
||||
ndn::Name
|
||||
getSiteCertName();
|
||||
|
||||
ndn::Name
|
||||
getRootCertName();
|
||||
|
||||
uint32_t
|
||||
getCertSeqNo();
|
||||
|
||||
std::pair<uint32_t, bool>
|
||||
getCertificateSeqNum(std::string certName);
|
||||
|
||||
void
|
||||
setCerSeqNo(uint32_t csn);
|
||||
|
||||
void
|
||||
initCertSeqFromFile(std::string certSeqFileDir);
|
||||
|
||||
void
|
||||
writeCertSeqToFile();
|
||||
|
||||
bool
|
||||
isNewCertificate(std::string certName, int checkSeqNum);
|
||||
|
||||
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool>
|
||||
getCertificateFromStore(const std::string certName, int checkSeqNum);
|
||||
|
||||
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool>
|
||||
getCertificateFromStore(const std::string certName);
|
||||
|
||||
bool
|
||||
addCertificate(ndn::shared_ptr<ndn::IdentityCertificate> pcert,
|
||||
uint32_t csn, bool isv);
|
||||
|
||||
|
||||
private:
|
||||
bool
|
||||
loadAllCertificates(std::string certDirPath);
|
||||
|
||||
bool
|
||||
loadCertificate(std::string inputFile, nlsrKeyType keyType);
|
||||
|
||||
nlsrKeyType
|
||||
getKeyTypeFromName(const std::string keyName);
|
||||
|
||||
std::string
|
||||
getRouterName(const std::string name);
|
||||
|
||||
std::string
|
||||
getSiteName(const std::string name);
|
||||
|
||||
std::string
|
||||
getRootName(const std::string name);
|
||||
|
||||
private:
|
||||
ndn::Name m_processIdentity;
|
||||
ndn::Name m_routerIdentity;
|
||||
ndn::Name m_processCertName;
|
||||
ndn::Name m_routerCertName;
|
||||
ndn::Name m_opCertName;
|
||||
ndn::Name m_siteCertName;
|
||||
ndn::Name m_rootCertName;
|
||||
ndn::Name m_processKeyName;
|
||||
uint32_t m_certSeqNo;
|
||||
std::string m_certSeqFileNameWithPath;
|
||||
std::string m_nlsrRootKeyPrefix;
|
||||
CertificateStore m_certStore;
|
||||
|
||||
};
|
||||
}//namespace nlsr
|
||||
|
||||
#endif //NLSR_KM_HPP
|
||||
@@ -1,40 +0,0 @@
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <ndn-cpp-dev/face.hpp>
|
||||
#include "waiting-list-entry.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
static bool
|
||||
waiteeCompare(std::string& w1, std::string& w2)
|
||||
{
|
||||
return w1 == w2 ;
|
||||
}
|
||||
|
||||
bool
|
||||
WaitingListEntry::addWaitee(std::string waiteeName)
|
||||
{
|
||||
std::list<std::string>::iterator it = std::find_if(m_waitingCerts.begin(),
|
||||
m_waitingCerts.end(), ndn::bind(&waiteeCompare, _1, waiteeName));
|
||||
if (it == m_waitingCerts.end())
|
||||
{
|
||||
m_waitingCerts.push_back(waiteeName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const WaitingListEntry& we)
|
||||
{
|
||||
os << "-------------Wiating List Entry-------------" << std::endl;
|
||||
os << "Responsible Certificate: " << we.getResponsibleCert() << std::endl;
|
||||
std::list<std::string> waitee = we.getWaitingCerts();
|
||||
int i = 1;
|
||||
for (std::list<std::string>::iterator it = waitee.begin();
|
||||
it != waitee.end(); ++i, ++it)
|
||||
{
|
||||
os << "Waite " << i << ": " << *(it) << std::endl;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
}//namespace nlsr
|
||||
@@ -1,51 +0,0 @@
|
||||
#ifndef NLSR_WLE_HPP
|
||||
#define NLSR_WLE_HPP
|
||||
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
|
||||
namespace nlsr {
|
||||
class WaitingListEntry
|
||||
{
|
||||
public:
|
||||
WaitingListEntry()
|
||||
: m_responsibleCert()
|
||||
, m_waitingCerts()
|
||||
{}
|
||||
|
||||
WaitingListEntry(std::string resCert)
|
||||
: m_responsibleCert(resCert)
|
||||
, m_waitingCerts()
|
||||
{}
|
||||
|
||||
std::string
|
||||
getResponsibleCert() const
|
||||
{
|
||||
return m_responsibleCert;
|
||||
}
|
||||
|
||||
void
|
||||
setResponsibleCert(std::string resCert)
|
||||
{
|
||||
m_responsibleCert = resCert;
|
||||
}
|
||||
|
||||
std::list<std::string>
|
||||
getWaitingCerts() const
|
||||
{
|
||||
return m_waitingCerts;
|
||||
}
|
||||
|
||||
bool
|
||||
addWaitee(std::string waiteeName);
|
||||
|
||||
private:
|
||||
std::string m_responsibleCert;
|
||||
std::list<std::string> m_waitingCerts;
|
||||
};
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const WaitingListEntry& we);
|
||||
} //end name space
|
||||
|
||||
#endif //NLSR_WLE_HPP
|
||||
@@ -1,72 +0,0 @@
|
||||
#include <ndn-cpp-dev/face.hpp>
|
||||
#include "waiting-list.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
static bool
|
||||
waitingListCompare(const WaitingListEntry& w1, const std::string& respCert)
|
||||
{
|
||||
return w1.getResponsibleCert() == respCert;
|
||||
}
|
||||
|
||||
std::pair<WaitingListEntry, bool>
|
||||
WaitingList::getWaitingListEntry(std::string respCert)
|
||||
{
|
||||
std::list<WaitingListEntry>::iterator it = std::find_if(m_waitingTable.begin(),
|
||||
m_waitingTable.end(), ndn::bind(&waitingListCompare, _1, respCert));
|
||||
if (it != m_waitingTable.end())
|
||||
{
|
||||
return std::make_pair(*(it), true);
|
||||
}
|
||||
WaitingListEntry wle;
|
||||
return std::make_pair(wle, false);
|
||||
}
|
||||
|
||||
bool
|
||||
WaitingList::add(std::string respCert, std::string waitee)
|
||||
{
|
||||
std::list<WaitingListEntry>::iterator it = std::find_if(m_waitingTable.begin(),
|
||||
m_waitingTable.end(), ndn::bind(&waitingListCompare, _1, respCert));
|
||||
if (it == m_waitingTable.end())
|
||||
{
|
||||
WaitingListEntry newWle(respCert);
|
||||
newWle.addWaitee(waitee);
|
||||
m_waitingTable.push_back(newWle);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return it->addWaitee(waitee);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
WaitingList::remove(std::string respCert)
|
||||
{
|
||||
std::list<WaitingListEntry>::iterator it = std::find_if(m_waitingTable.begin(),
|
||||
m_waitingTable.end(), ndn::bind(&waitingListCompare, _1, respCert));
|
||||
if (it == m_waitingTable.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_waitingTable.erase(it);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, WaitingList wl)
|
||||
{
|
||||
os << "-------Waiting List--------" << std::endl;
|
||||
std::list<WaitingListEntry> wles = wl.getWaitingTable();
|
||||
for (std::list<WaitingListEntry> ::iterator it = wles.begin();
|
||||
it != wles.end(); ++it)
|
||||
{
|
||||
os << *(it) << std::endl;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
}//namespace nlsr
|
||||
@@ -1,38 +0,0 @@
|
||||
#ifndef NLSR_WL_HPP
|
||||
#define NLSR_WL_HPP
|
||||
|
||||
#include "waiting-list-entry.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
class WaitingList
|
||||
{
|
||||
public:
|
||||
WaitingList()
|
||||
: m_waitingTable()
|
||||
{}
|
||||
|
||||
std::list<WaitingListEntry>&
|
||||
getWaitingTable()
|
||||
{
|
||||
return m_waitingTable;
|
||||
}
|
||||
|
||||
bool
|
||||
add(std::string respCert, std::string waitee);
|
||||
|
||||
std::pair<WaitingListEntry, bool>
|
||||
getWaitingListEntry(std::string respCert);
|
||||
|
||||
bool
|
||||
remove(std::string respCert);
|
||||
|
||||
private:
|
||||
std::list<WaitingListEntry> m_waitingTable;
|
||||
};
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, WaitingList wl);
|
||||
|
||||
}//namespace nlsr
|
||||
|
||||
#endif //NLSR_WL_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -62,15 +62,34 @@ SequencingManager::writeSeqNoToFile() const
|
||||
}
|
||||
|
||||
void
|
||||
SequencingManager::initiateSeqNoFromFile()
|
||||
SequencingManager::initiateSeqNoFromFile(int hypState)
|
||||
{
|
||||
_LOG_DEBUG("Seq File Name: " << m_seqFileNameWithPath);
|
||||
std::ifstream inputFile(m_seqFileNameWithPath.c_str(), ios::binary);
|
||||
if (inputFile.good()) {
|
||||
inputFile >> m_combinedSeqNo;
|
||||
splitSequenceNo(m_combinedSeqNo);
|
||||
m_adjLsaSeq += 10;
|
||||
m_corLsaSeq += 10;
|
||||
|
||||
// Increment the adjacency LSA seq. no. if link-state or dry HR is enabled
|
||||
if (hypState != HYPERBOLIC_STATE_ON) {
|
||||
if (m_corLsaSeq != 0) {
|
||||
_LOG_WARN("This router was previously configured for hyperbolic"
|
||||
<< " routing without clearing the seq. no. file.");
|
||||
m_corLsaSeq = 0;
|
||||
}
|
||||
m_adjLsaSeq += 10;
|
||||
}
|
||||
|
||||
// Similarly, increment the coordinate LSA seq. no only if link-state is disabled.
|
||||
if (hypState != HYPERBOLIC_STATE_OFF) {
|
||||
if (m_adjLsaSeq != 0 &&
|
||||
hypState == HYPERBOLIC_STATE_ON) {
|
||||
_LOG_WARN("This router was previously configured for link-state"
|
||||
<< " routing without clearing the seq. no. file.");
|
||||
m_adjLsaSeq = 0;
|
||||
}
|
||||
m_corLsaSeq += 10;
|
||||
}
|
||||
m_nameLsaSeq += 10;
|
||||
combineSequenceNo();
|
||||
inputFile.close();
|
||||
@@ -110,6 +129,4 @@ SequencingManager::writeLog() const
|
||||
_LOG_DEBUG("Combined LSDB Seq no: " << m_combinedSeqNo);
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -28,7 +28,10 @@
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
|
||||
#include "conf-parameter.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class SequencingManager
|
||||
{
|
||||
public:
|
||||
@@ -124,7 +127,7 @@ public:
|
||||
writeSeqNoToFile() const;
|
||||
|
||||
void
|
||||
initiateSeqNoFromFile();
|
||||
initiateSeqNoFromFile(int hypState);
|
||||
|
||||
void
|
||||
setSeqFileName(std::string filePath);
|
||||
@@ -150,5 +153,5 @@ private:
|
||||
std::string m_seqFileNameWithPath;
|
||||
};
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
#endif //NLSR_SEQUENCING_MANAGER_HPP
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* 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.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -43,9 +43,9 @@ AdjacencyLsa::AdjacencyLsa(const ndn::Block& block)
|
||||
wireDecode(block);
|
||||
}
|
||||
|
||||
template<bool T>
|
||||
template<ndn::encoding::Tag TAG>
|
||||
size_t
|
||||
AdjacencyLsa::wireEncode(ndn::EncodingImpl<T>& block) const
|
||||
AdjacencyLsa::wireEncode(ndn::EncodingImpl<TAG>& block) const
|
||||
{
|
||||
size_t totalLength = 0;
|
||||
|
||||
@@ -63,10 +63,10 @@ AdjacencyLsa::wireEncode(ndn::EncodingImpl<T>& block) const
|
||||
}
|
||||
|
||||
template size_t
|
||||
AdjacencyLsa::wireEncode<true>(ndn::EncodingImpl<true>& block) const;
|
||||
AdjacencyLsa::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& encoder) const;
|
||||
|
||||
template size_t
|
||||
AdjacencyLsa::wireEncode<false>(ndn::EncodingImpl<false>& block) const;
|
||||
AdjacencyLsa::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& encoder) const;
|
||||
|
||||
const ndn::Block&
|
||||
AdjacencyLsa::wireEncode() const
|
||||
|
||||
+12
-12
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -34,16 +34,16 @@
|
||||
#include <list>
|
||||
|
||||
namespace nlsr {
|
||||
namespace tlv {
|
||||
namespace tlv {
|
||||
|
||||
/**
|
||||
* @brief Data abstraction for AdjacencyLsa
|
||||
*
|
||||
* AdjacencyLsa := ADJACENCY-LSA-TYPE TLV-LENGTH
|
||||
* LsaInfo
|
||||
* Adjacency*
|
||||
*
|
||||
* @sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
/*!
|
||||
\brief Data abstraction for AdjacencyLsa
|
||||
|
||||
AdjacencyLsa := ADJACENCY-LSA-TYPE TLV-LENGTH
|
||||
LsaInfo
|
||||
Adjacency*
|
||||
|
||||
\sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class AdjacencyLsa
|
||||
{
|
||||
@@ -109,9 +109,9 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<bool T>
|
||||
template<ndn::encoding::Tag TAG>
|
||||
size_t
|
||||
wireEncode(ndn::EncodingImpl<T>& block) const;
|
||||
wireEncode(ndn::EncodingImpl<TAG>& block) const;
|
||||
|
||||
const ndn::Block&
|
||||
wireEncode() const;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -43,9 +43,9 @@ Adjacency::Adjacency(const ndn::Block& block)
|
||||
wireDecode(block);
|
||||
}
|
||||
|
||||
template<bool T>
|
||||
template<ndn::encoding::Tag TAG>
|
||||
size_t
|
||||
Adjacency::wireEncode(ndn::EncodingImpl<T>& encoder) const
|
||||
Adjacency::wireEncode(ndn::EncodingImpl<TAG>& encoder) const
|
||||
{
|
||||
size_t totalLength = 0;
|
||||
|
||||
@@ -63,10 +63,10 @@ Adjacency::wireEncode(ndn::EncodingImpl<T>& encoder) const
|
||||
}
|
||||
|
||||
template size_t
|
||||
Adjacency::wireEncode<true>(ndn::EncodingImpl<true>& block) const;
|
||||
Adjacency::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& block) const;
|
||||
|
||||
template size_t
|
||||
Adjacency::wireEncode<false>(ndn::EncodingImpl<false>& block) const;
|
||||
Adjacency::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& block) const;
|
||||
|
||||
const ndn::Block&
|
||||
Adjacency::wireEncode() const
|
||||
|
||||
+13
-13
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -29,17 +29,17 @@
|
||||
#include <ndn-cxx/name.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace tlv {
|
||||
namespace tlv {
|
||||
|
||||
/**
|
||||
* @brief Data abstraction for Adjacency
|
||||
*
|
||||
* Adjacency := ADJACENCY-TYPE TLV-LENGTH
|
||||
* Name
|
||||
* Uri
|
||||
* Cost
|
||||
*
|
||||
* @sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
/*!
|
||||
\brief Data abstraction for Adjacency
|
||||
|
||||
Adjacency := ADJACENCY-TYPE TLV-LENGTH
|
||||
Name
|
||||
Uri
|
||||
Cost
|
||||
|
||||
\sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class Adjacency
|
||||
{
|
||||
@@ -101,9 +101,9 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<bool T>
|
||||
template<ndn::encoding::Tag TAG>
|
||||
size_t
|
||||
wireEncode(ndn::EncodingImpl<T>& block) const;
|
||||
wireEncode(ndn::EncodingImpl<TAG>& block) const;
|
||||
|
||||
const ndn::Block&
|
||||
wireEncode() const;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -44,9 +44,9 @@ CoordinateLsa::CoordinateLsa(const ndn::Block& block)
|
||||
wireDecode(block);
|
||||
}
|
||||
|
||||
template<bool T>
|
||||
template<ndn::encoding::Tag TAG>
|
||||
size_t
|
||||
CoordinateLsa::wireEncode(ndn::EncodingImpl<T>& block) const
|
||||
CoordinateLsa::wireEncode(ndn::EncodingImpl<TAG>& block) const
|
||||
{
|
||||
size_t totalLength = 0;
|
||||
size_t doubleLength = 10;
|
||||
@@ -70,10 +70,10 @@ CoordinateLsa::wireEncode(ndn::EncodingImpl<T>& block) const
|
||||
}
|
||||
|
||||
template size_t
|
||||
CoordinateLsa::wireEncode<true>(ndn::EncodingImpl<true>& block) const;
|
||||
CoordinateLsa::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& block) const;
|
||||
|
||||
template size_t
|
||||
CoordinateLsa::wireEncode<false>(ndn::EncodingImpl<false>& block) const;
|
||||
CoordinateLsa::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& block) const;
|
||||
|
||||
const ndn::Block&
|
||||
CoordinateLsa::wireEncode() const
|
||||
|
||||
+13
-13
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -31,17 +31,17 @@
|
||||
#include <ndn-cxx/name.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace tlv {
|
||||
namespace tlv {
|
||||
|
||||
/**
|
||||
* @brief Data abstraction for CoordinateLsa
|
||||
*
|
||||
* CoordinateLsa := COORDINATE-LSA-TYPE TLV-LENGTH
|
||||
* LsaInfo
|
||||
* HyperbolicRadius
|
||||
* HyperbolicAngle
|
||||
*
|
||||
* @sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
/*!
|
||||
\brief Data abstraction for CoordinateLsa
|
||||
|
||||
CoordinateLsa := COORDINATE-LSA-TYPE TLV-LENGTH
|
||||
LsaInfo
|
||||
HyperbolicRadius
|
||||
HyperbolicAngle
|
||||
|
||||
\sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class CoordinateLsa
|
||||
{
|
||||
@@ -103,9 +103,9 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<bool T>
|
||||
template<ndn::encoding::Tag TAG>
|
||||
size_t
|
||||
wireEncode(ndn::EncodingImpl<T>& block) const;
|
||||
wireEncode(ndn::EncodingImpl<TAG>& block) const;
|
||||
|
||||
const ndn::Block&
|
||||
wireEncode() const;
|
||||
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <ndn-cxx/encoding/block-helpers.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace tlv {
|
||||
namespace tlv {
|
||||
|
||||
BOOST_CONCEPT_ASSERT((ndn::WireEncodable<LsaInfo>));
|
||||
BOOST_CONCEPT_ASSERT((ndn::WireDecodable<LsaInfo>));
|
||||
@@ -47,9 +47,9 @@ LsaInfo::LsaInfo(const ndn::Block& block)
|
||||
wireDecode(block);
|
||||
}
|
||||
|
||||
template<bool T>
|
||||
template<ndn::encoding::Tag TAG>
|
||||
size_t
|
||||
LsaInfo::wireEncode(ndn::EncodingImpl<T>& encoder) const
|
||||
LsaInfo::wireEncode(ndn::EncodingImpl<TAG>& encoder) const
|
||||
{
|
||||
size_t totalLength = 0;
|
||||
|
||||
@@ -73,10 +73,10 @@ LsaInfo::wireEncode(ndn::EncodingImpl<T>& encoder) const
|
||||
}
|
||||
|
||||
template size_t
|
||||
LsaInfo::wireEncode<true>(ndn::EncodingImpl<true>& block) const;
|
||||
LsaInfo::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& block) const;
|
||||
|
||||
template size_t
|
||||
LsaInfo::wireEncode<false>(ndn::EncodingImpl<false>& block) const;
|
||||
LsaInfo::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& block) const;
|
||||
|
||||
const ndn::Block&
|
||||
LsaInfo::wireEncode() const
|
||||
@@ -109,7 +109,7 @@ LsaInfo::wireDecode(const ndn::Block& wire)
|
||||
std::stringstream error;
|
||||
error << "Expected LsaInfo Block, but Block is of a different type: #"
|
||||
<< m_wire.type();
|
||||
throw Error(error.str());
|
||||
BOOST_THROW_EXCEPTION(Error(error.str()));
|
||||
}
|
||||
|
||||
m_wire.parse();
|
||||
@@ -124,13 +124,13 @@ LsaInfo::wireDecode(const ndn::Block& wire)
|
||||
m_originRouter.wireDecode(*it);
|
||||
}
|
||||
else {
|
||||
throw Error("OriginRouter: Missing required Name field");
|
||||
BOOST_THROW_EXCEPTION(Error("OriginRouter: Missing required Name field"));
|
||||
}
|
||||
|
||||
++val;
|
||||
}
|
||||
else {
|
||||
throw Error("Missing required OriginRouter field");
|
||||
BOOST_THROW_EXCEPTION(Error("Missing required OriginRouter field"));
|
||||
}
|
||||
|
||||
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::SequenceNumber) {
|
||||
@@ -138,7 +138,7 @@ LsaInfo::wireDecode(const ndn::Block& wire)
|
||||
++val;
|
||||
}
|
||||
else {
|
||||
throw Error("Missing required SequenceNumber field");
|
||||
BOOST_THROW_EXCEPTION(Error("Missing required SequenceNumber field"));
|
||||
}
|
||||
|
||||
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::ExpirationPeriod) {
|
||||
|
||||
+14
-13
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -27,21 +27,22 @@
|
||||
#include <ndn-cxx/encoding/encoding-buffer.hpp>
|
||||
#include <ndn-cxx/encoding/tlv.hpp>
|
||||
#include <ndn-cxx/name.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#include "lsa.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
namespace tlv {
|
||||
namespace tlv {
|
||||
|
||||
/**
|
||||
* @brief Data abstraction for LsaInfo
|
||||
*
|
||||
* LsaInfo := LSA-TYPE TLV-LENGTH
|
||||
* OriginRouter
|
||||
* SequenceNumber
|
||||
* ExpirationPeriod?
|
||||
*
|
||||
* @sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
/*!
|
||||
\brief Data abstraction for LsaInfo
|
||||
|
||||
LsaInfo := LSA-TYPE TLV-LENGTH
|
||||
OriginRouter
|
||||
SequenceNumber
|
||||
ExpirationPeriod?
|
||||
|
||||
\sa https://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class LsaInfo
|
||||
{
|
||||
@@ -114,9 +115,9 @@ public:
|
||||
return m_hasInfiniteExpirationPeriod;
|
||||
}
|
||||
|
||||
template<bool T>
|
||||
template<ndn::encoding::Tag TAG>
|
||||
size_t
|
||||
wireEncode(ndn::EncodingImpl<T>& block) const;
|
||||
wireEncode(ndn::EncodingImpl<TAG>& block) const;
|
||||
|
||||
const ndn::Block&
|
||||
wireEncode() const;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -45,9 +45,9 @@ LsdbStatus::LsdbStatus(const ndn::Block& block)
|
||||
wireDecode(block);
|
||||
}
|
||||
|
||||
template<bool T>
|
||||
template<ndn::encoding::Tag TAG>
|
||||
size_t
|
||||
LsdbStatus::wireEncode(ndn::EncodingImpl<T>& block) const
|
||||
LsdbStatus::wireEncode(ndn::EncodingImpl<TAG>& block) const
|
||||
{
|
||||
size_t totalLength = 0;
|
||||
|
||||
@@ -73,10 +73,10 @@ LsdbStatus::wireEncode(ndn::EncodingImpl<T>& block) const
|
||||
}
|
||||
|
||||
template size_t
|
||||
LsdbStatus::wireEncode<true>(ndn::EncodingImpl<true>& block) const;
|
||||
LsdbStatus::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& block) const;
|
||||
|
||||
template size_t
|
||||
LsdbStatus::wireEncode<false>(ndn::EncodingImpl<false>& block) const;
|
||||
LsdbStatus::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& block) const;
|
||||
|
||||
const ndn::Block&
|
||||
LsdbStatus::wireEncode() const
|
||||
|
||||
+13
-13
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -35,17 +35,17 @@
|
||||
#include <list>
|
||||
|
||||
namespace nlsr {
|
||||
namespace tlv {
|
||||
namespace tlv {
|
||||
|
||||
/**
|
||||
* @brief Data abstraction for LsdbStatus
|
||||
*
|
||||
* LsdbStatus := LSDB-STATUS-TYPE TLV-LENGTH
|
||||
* AdjacencyLsa*
|
||||
* CoordinateLsa*
|
||||
* NameLsa*
|
||||
*
|
||||
* @sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
/*!
|
||||
\brief Data abstraction for LsdbStatus
|
||||
|
||||
LsdbStatus := LSDB-STATUS-TYPE TLV-LENGTH
|
||||
AdjacencyLsa*
|
||||
CoordinateLsa*
|
||||
NameLsa*
|
||||
|
||||
\sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class LsdbStatus
|
||||
{
|
||||
@@ -156,9 +156,9 @@ public:
|
||||
return m_hasNameLsas;
|
||||
}
|
||||
|
||||
template<bool T>
|
||||
template<ndn::encoding::Tag TAG>
|
||||
size_t
|
||||
wireEncode(ndn::EncodingImpl<T>& block) const;
|
||||
wireEncode(ndn::EncodingImpl<TAG>& block) const;
|
||||
|
||||
const ndn::Block&
|
||||
wireEncode() const;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -43,9 +43,9 @@ NameLsa::NameLsa(const ndn::Block& block)
|
||||
wireDecode(block);
|
||||
}
|
||||
|
||||
template<bool T>
|
||||
template<ndn::encoding::Tag TAG>
|
||||
size_t
|
||||
NameLsa::wireEncode(ndn::EncodingImpl<T>& block) const
|
||||
NameLsa::wireEncode(ndn::EncodingImpl<TAG>& block) const
|
||||
{
|
||||
size_t totalLength = 0;
|
||||
|
||||
@@ -63,10 +63,10 @@ NameLsa::wireEncode(ndn::EncodingImpl<T>& block) const
|
||||
}
|
||||
|
||||
template size_t
|
||||
NameLsa::wireEncode<true>(ndn::EncodingImpl<true>& block) const;
|
||||
NameLsa::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& block) const;
|
||||
|
||||
template size_t
|
||||
NameLsa::wireEncode<false>(ndn::EncodingImpl<false>& block) const;
|
||||
NameLsa::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& block) const;
|
||||
|
||||
const ndn::Block&
|
||||
NameLsa::wireEncode() const
|
||||
|
||||
Loaded 100 of 163 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user