├── waf ├── tests ├── unit │ ├── util │ │ ├── config-file-malformed-home │ │ │ └── .ndn │ │ │ │ └── client.conf │ │ ├── config-file-home │ │ │ └── .ndn │ │ │ │ └── client.conf │ │ ├── log-module1.cpp │ │ ├── log-module2.cpp │ │ ├── log-filter-module.cpp │ │ ├── placeholders2.t.cpp │ │ ├── placeholders.t.cpp │ │ └── concepts.t.cpp │ ├── security │ │ ├── tmp-home │ │ │ └── .ndn │ │ │ │ └── client.conf │ │ ├── config-file.README.txt │ │ ├── validator-config │ │ │ └── common.hpp │ │ └── tpm │ │ │ └── back-end-wrapper-mem.hpp │ ├── wscript │ ├── main.cpp │ ├── io-key-chain-fixture.hpp │ ├── unit-tests-pch.hpp │ ├── io-fixture.hpp │ ├── tag.t.cpp │ ├── ndebug.t.cpp │ ├── test-home-env-saver.hpp │ ├── lp │ │ └── fields.t.cpp │ └── clock-fixture.cpp ├── benchmarks │ ├── wscript │ └── timed-execute.hpp ├── integration │ └── wscript ├── wscript ├── boost-test.hpp ├── tests-pch.hpp └── test-common.cpp ├── docs ├── release-notes.rst ├── requirements.txt ├── doxygen-logo.css ├── specs.rst ├── tutorials.rst ├── manpages.rst ├── release-notes │ ├── release-notes-0.4.1.rst │ ├── release-notes-0.3.2.rst │ ├── release-notes-0.3.1.rst │ ├── release-notes-0.6.2.rst │ └── release-notes-0.6.1.rst ├── manpages │ ├── ndnsec-import.rst │ ├── ndnsec-set-default.rst │ ├── ndnsec-delete.rst │ ├── ndnsec-cert-install.rst │ ├── ndnsec-get-default.rst │ ├── ndnsec.rst │ ├── ndnsec-export.rst │ ├── ndnsec-sign-req.rst │ └── ndnsec-key-gen.rst └── specs │ └── safe-bag.rst ├── .jenkins.d ├── 09-cleanup.sh ├── 20-tests.sh ├── 40-headers-check.sh ├── 30-coverage.sh ├── README.md ├── 10-build.sh └── 00-deps.sh ├── ndn-cxx ├── detail │ ├── README.md │ ├── asio-fwd.hpp │ ├── cancel-handle.cpp │ ├── packet-base.cpp │ └── packet-base.hpp ├── impl │ ├── README.md │ └── lp-field-tag.hpp ├── encoding │ ├── buffer.cpp │ ├── tlv-security.hpp │ ├── buffer-stream.cpp │ └── encoding-buffer.hpp ├── util │ ├── signal.hpp │ ├── regex.hpp │ ├── signal │ │ ├── connection.cpp │ │ └── scoped-connection.cpp │ ├── impl │ │ ├── logger-android.hpp │ │ └── steady-timer.hpp │ ├── exception.cpp │ ├── scope.hpp │ ├── regex │ │ ├── regex-pseudo-matcher.cpp │ │ ├── regex-pseudo-matcher.hpp │ │ ├── regex-backref-manager.cpp │ │ ├── regex-backref-matcher.hpp │ │ ├── regex-backref-manager.hpp │ │ ├── regex-pattern-list-matcher.hpp │ │ ├── regex-repeat-matcher.hpp │ │ └── regex-backref-matcher.cpp │ └── span.hpp ├── mgmt │ ├── nfd │ │ ├── control-response.hpp │ │ ├── command-options.cpp │ │ └── route-flags-traits.hpp │ └── control-parameters-base.hpp ├── lp │ ├── sequence.hpp │ ├── empty-value.hpp │ ├── nack.cpp │ └── pit-token.cpp ├── security │ ├── transform │ │ ├── step-source.cpp │ │ ├── bool-sink.cpp │ │ ├── stream-sink.cpp │ │ ├── buffer-source.cpp │ │ ├── strip-space.cpp │ │ └── stream-sink.hpp │ ├── validator-null.hpp │ ├── validator-null.cpp │ ├── tpm │ │ ├── impl │ │ │ ├── key-ref-osx.hpp │ │ │ └── key-handle-osx.cpp │ │ └── key-handle.cpp │ ├── validator-config │ │ ├── common.hpp │ │ └── name-relation.hpp │ ├── certificate-fetcher-offline.cpp │ ├── certificate-fetcher-offline.hpp │ ├── validation-policy-simple-hierarchy.hpp │ ├── validation-policy-accept-all.hpp │ ├── signing-helpers.cpp │ ├── validation-callback.hpp │ ├── transform.hpp │ └── certificate-request.hpp ├── ims │ ├── in-memory-storage-entry.cpp │ └── in-memory-storage-persistent.hpp ├── net │ └── impl │ │ ├── link-type-helper.cpp │ │ ├── link-type-helper.hpp │ │ ├── linux-if-constants.cpp │ │ └── network-monitor-impl-noop.hpp └── transport │ └── transport.cpp ├── .github └── workflows │ ├── release.yml │ ├── ci.yml │ ├── docs.yml │ └── docker.yml ├── libndn-cxx.pc.in ├── .dockerignore ├── .mailmap ├── .gitignore ├── .editorconfig ├── examples ├── trust-schema.conf └── wscript ├── .waf-tools ├── coverage.py ├── cross.py ├── sanitizers.py ├── sqlite3.py └── osx-frameworks.py ├── tools ├── ndnsec │ ├── wscript │ ├── ndnsec-pch.hpp │ └── ndnsec.hpp ├── wscript └── README.md ├── client.conf.sample ├── Dockerfile └── .jenkins /waf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data/ndn-cxx/HEAD/waf -------------------------------------------------------------------------------- /tests/unit/util/config-file-malformed-home/.ndn/client.conf: -------------------------------------------------------------------------------- 1 | a 2 | -------------------------------------------------------------------------------- /tests/unit/util/config-file-home/.ndn/client.conf: -------------------------------------------------------------------------------- 1 | a=/path/to/nowhere 2 | b=some-othervalue.01 3 | -------------------------------------------------------------------------------- /docs/release-notes.rst: -------------------------------------------------------------------------------- 1 | Release Notes 2 | ============= 3 | 4 | .. include:: release-notes/release-notes-0.9.0.rst 5 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | docutils>=0.20 2 | furo==2025.9.25 3 | sphinx>=7.0.1,<9 4 | sphinxcontrib-doxylink~=1.13 5 | -------------------------------------------------------------------------------- /docs/doxygen-logo.css: -------------------------------------------------------------------------------- 1 | #projectlogo { vertical-align: middle; } 2 | #projectlogo img { height: 50px; width: 200px; } 3 | -------------------------------------------------------------------------------- /tests/unit/security/tmp-home/.ndn/client.conf: -------------------------------------------------------------------------------- 1 | pib=pib-sqlite3:/tmp/test/ndn-cxx/keychain 2 | tpm=tpm-file:/tmp/test/ndn-cxx/keychain -------------------------------------------------------------------------------- /docs/specs.rst: -------------------------------------------------------------------------------- 1 | Specifications 2 | ============== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | specs/safe-bag 8 | specs/signed-interest 9 | -------------------------------------------------------------------------------- /docs/tutorials.rst: -------------------------------------------------------------------------------- 1 | Tutorials 2 | ========= 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | tutorials/utils-ndn-regex 8 | tutorials/security-validator-config 9 | -------------------------------------------------------------------------------- /docs/manpages.rst: -------------------------------------------------------------------------------- 1 | Man pages 2 | ========= 3 | 4 | .. toctree:: 5 | :glob: 6 | :maxdepth: 1 7 | 8 | ndn-client.conf 9 | ndn-log: ndn-cxx logging 10 | manpages/ndnsec* 11 | -------------------------------------------------------------------------------- /.jenkins.d/09-cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -exo pipefail 3 | 4 | PROJ=ndn-cxx 5 | 6 | sudo rm -f /usr/local/bin/ndnsec* 7 | sudo rm -fr /usr/local/include/"$PROJ" 8 | sudo rm -f /usr/local/lib{,64}/lib"$PROJ"* 9 | sudo rm -f /usr/local/lib{,64}/pkgconfig/{,lib}"$PROJ".pc 10 | -------------------------------------------------------------------------------- /ndn-cxx/detail/README.md: -------------------------------------------------------------------------------- 1 | # Implementation Detail 2 | 3 | This folder contains implementation detail of ndn-cxx library. 4 | Declarations contained in these files are not considered public API and they can change without notice. 5 | 6 | Headers in this folder are installed to the target system. 7 | -------------------------------------------------------------------------------- /ndn-cxx/impl/README.md: -------------------------------------------------------------------------------- 1 | # Implementation Detail 2 | 3 | This folder contains implementation detail of ndn-cxx library. 4 | Declarations contained in these files are not considered public API and they can change without notice. 5 | 6 | Headers in this folder are not installed to the target system. 7 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | on: 3 | push: 4 | tags: 5 | - 'ndn-cxx-[0-9]+*' 6 | workflow_dispatch: 7 | 8 | permissions: 9 | attestations: write 10 | contents: write 11 | id-token: write 12 | 13 | jobs: 14 | release: 15 | uses: named-data/actions/.github/workflows/release.yml@v1 16 | -------------------------------------------------------------------------------- /libndn-cxx.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libndn-cxx 7 | Description: NDN C++ Library 8 | Version: @VERSION@ 9 | Libs: -L${libdir} @EXTRA_LINKFLAGS@ @EXTRA_LDFLAGS@ -lndn-cxx @EXTRA_LIBS@ @EXTRA_FRAMEWORKS@ 10 | Cflags: -I${includedir} @EXTRA_CXXFLAGS@ @EXTRA_INCLUDES@ 11 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | # Waf build system 2 | build/ 3 | .waf-*-*/ 4 | .waf3-*-*/ 5 | .lock-waf* 6 | 7 | # Compiled python code 8 | **/__pycache__/ 9 | **/*.py[cod] 10 | 11 | # Qt Creator 12 | *.creator 13 | *.creator.user 14 | .qtc_clangd/ 15 | 16 | # Visual Studio Code 17 | .vscode/ 18 | 19 | # macOS 20 | **/.DS_Store 21 | **/.AppleDouble 22 | **/.LSOverride 23 | **/._* 24 | 25 | # Other 26 | Dockerfile 27 | VERSION.info 28 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Teng Liang 6 | 7 | Hila Ben Abraham 8 | Laqin Fan 9 | Jeremy Clark 10 | -------------------------------------------------------------------------------- /tests/benchmarks/wscript: -------------------------------------------------------------------------------- 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- 2 | 3 | top = '../..' 4 | 5 | def build(bld): 6 | for file in bld.path.ant_glob('*.cpp'): 7 | name = file.change_ext('').path_from(bld.path.get_bld()) 8 | bld.program( 9 | name=f'bench-{name}', 10 | target=name, 11 | source=[file], 12 | use='BOOST_TESTS ndn-cxx', 13 | install_path=None) 14 | -------------------------------------------------------------------------------- /tests/integration/wscript: -------------------------------------------------------------------------------- 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- 2 | 3 | top = '../..' 4 | 5 | def build(bld): 6 | for file in bld.path.ant_glob('*.cpp'): 7 | name = file.change_ext('').path_from(bld.path.get_bld()) 8 | bld.program( 9 | name=f'integ-test-{name}', 10 | target=name, 11 | source=[file], 12 | use='tests-common', 13 | install_path=None) 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Backup files 2 | *~ 3 | *.bak 4 | *.orig 5 | *.rej 6 | 7 | # Waf build system 8 | /build/ 9 | .waf-*-*/ 10 | .waf3-*-*/ 11 | .lock-waf* 12 | 13 | # Compiled python code 14 | __pycache__/ 15 | *.py[cod] 16 | 17 | # Emacs 18 | \#*\# 19 | /.emacs.desktop 20 | /.emacs.desktop.lock 21 | *.elc 22 | .\#* 23 | 24 | # Visual Studio Code 25 | .vscode/ 26 | 27 | # macOS 28 | .DS_Store 29 | .AppleDouble 30 | .LSOverride 31 | ._* 32 | 33 | # Other 34 | /VERSION.info 35 | /examples/example-trust-anchor.cert 36 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: 5 | - '**' 6 | paths-ignore: 7 | - '*.conf.sample*' 8 | - 'Dockerfile' 9 | - '.dockerignore' 10 | - 'docs/**' 11 | - '.editorconfig' 12 | - '.gitignore' 13 | - '.mailmap' 14 | - '*.md' 15 | workflow_dispatch: 16 | 17 | permissions: {} 18 | 19 | jobs: 20 | Ubuntu: 21 | uses: named-data/actions/.github/workflows/jenkins-script-ubuntu.yml@v1 22 | macOS: 23 | uses: named-data/actions/.github/workflows/jenkins-script-macos.yml@v1 24 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | 8 | [*.{cpp,hpp}] 9 | indent_style = space 10 | indent_size = 2 11 | trim_trailing_whitespace = true 12 | 13 | [{*.{py,sh},.jenkins,wscript}] 14 | indent_style = space 15 | indent_size = 4 16 | trim_trailing_whitespace = true 17 | 18 | [*.md] 19 | indent_style = space 20 | trim_trailing_whitespace = false 21 | 22 | [*.rst] 23 | indent_style = space 24 | trim_trailing_whitespace = true 25 | 26 | [*.{yaml,yml}] 27 | indent_style = space 28 | indent_size = 2 29 | trim_trailing_whitespace = true 30 | -------------------------------------------------------------------------------- /.github/workflows/docs.yml: -------------------------------------------------------------------------------- 1 | name: Docs 2 | on: 3 | push: 4 | workflow_dispatch: 5 | inputs: 6 | skip-deploy: 7 | description: 'Skip deployment?' 8 | required: true 9 | type: boolean 10 | 11 | permissions: {} 12 | 13 | jobs: 14 | html: 15 | uses: named-data/actions/.github/workflows/docs-html.yml@v1 16 | with: 17 | # Deploy only the master branch and release tags 18 | deploy: ${{ !inputs.skip-deploy && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/ndn-cxx-')) }} 19 | secrets: inherit 20 | man: 21 | uses: named-data/actions/.github/workflows/docs-man.yml@v1 22 | -------------------------------------------------------------------------------- /examples/trust-schema.conf: -------------------------------------------------------------------------------- 1 | rule 2 | { 3 | id "Example rule" 4 | for data 5 | filter 6 | { 7 | type name 8 | name /example/testApp 9 | relation is-prefix-of 10 | } 11 | checker 12 | { 13 | type customized 14 | sig-type ecdsa-sha256 15 | key-locator 16 | { 17 | type name 18 | hyper-relation 19 | { 20 | k-regex ^(<>*)<><>?<>?$ 21 | k-expand \\1 22 | h-relation is-prefix-of 23 | p-regex ^(<>*)<>*$ 24 | p-expand \\1 25 | } 26 | } 27 | } 28 | } 29 | 30 | trust-anchor 31 | { 32 | type file 33 | file-name "example-trust-anchor.cert" 34 | } 35 | -------------------------------------------------------------------------------- /tests/wscript: -------------------------------------------------------------------------------- 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- 2 | 3 | top = '..' 4 | 5 | def build(bld): 6 | if bld.env.WITH_INTEGRATION_TESTS or bld.env.WITH_UNIT_TESTS: 7 | bld.objects( 8 | target='tests-common', 9 | source=bld.path.ant_glob('*.cpp'), 10 | features='pch', 11 | headers='tests-pch.hpp', 12 | use='BOOST_TESTS ndn-cxx') 13 | 14 | if bld.env.WITH_BENCHMARKS: 15 | bld.recurse('benchmarks') 16 | 17 | if bld.env.WITH_INTEGRATION_TESTS: 18 | bld.recurse('integration') 19 | 20 | if bld.env.WITH_UNIT_TESTS: 21 | bld.recurse('unit') 22 | -------------------------------------------------------------------------------- /.github/workflows/docker.yml: -------------------------------------------------------------------------------- 1 | name: Docker 2 | on: 3 | push: 4 | tags: 5 | - 'ndn-cxx-[0-9]+*' 6 | schedule: 7 | # twice a month 8 | - cron: '20 4 5,20 * *' 9 | workflow_dispatch: 10 | 11 | permissions: 12 | attestations: write 13 | id-token: write 14 | packages: write 15 | 16 | jobs: 17 | ndn-cxx-build: 18 | uses: named-data/actions/.github/workflows/docker-image.yml@v1 19 | with: 20 | name: ndn-cxx-build 21 | target: build 22 | ndn-cxx-runtime: 23 | needs: ndn-cxx-build 24 | uses: named-data/actions/.github/workflows/docker-image.yml@v1 25 | with: 26 | name: ndn-cxx-runtime 27 | target: runtime 28 | contexts: build=docker-image://${{ needs.ndn-cxx-build.outputs.image }} 29 | -------------------------------------------------------------------------------- /tests/unit/security/config-file.README.txt: -------------------------------------------------------------------------------- 1 | In tests, we set a test-specific HOME, which causes macOS Keychain to look for 2 | the default keychain of a "different" user. If the default keychain does not 3 | exist, all subsequent calls to macOS Keychain will fail. User interaction 4 | (such as entering the password) is required to create a keychain. However, 5 | user interaction is not feasible in automated tests. 6 | 7 | This problem is caused by macOS's assumption that a user must have a login 8 | keychain, which is also the user's default keychain, because a user account is 9 | always created with a login keychain by default. Thus, macOS infers the user 10 | according to the HOME env, and does not expect the user to change the HOME env 11 | during normal use. 12 | -------------------------------------------------------------------------------- /.waf-tools/coverage.py: -------------------------------------------------------------------------------- 1 | from waflib import TaskGen 2 | 3 | def options(opt): 4 | opt.add_option('--with-coverage', action='store_true', default=False, 5 | help='Add compiler flags to enable code coverage information') 6 | 7 | def configure(conf): 8 | if conf.options.with_coverage: 9 | if not conf.options.debug: 10 | conf.fatal('Code coverage flags require debug mode compilation (add --debug)') 11 | conf.check_cxx(cxxflags=['-fprofile-arcs', '-ftest-coverage', '-fPIC'], 12 | linkflags=['-fprofile-arcs'], uselib_store='GCOV', mandatory=True) 13 | 14 | @TaskGen.feature('cxx','cc') 15 | @TaskGen.after('process_source') 16 | def add_coverage(self): 17 | if getattr(self, 'use', ''): 18 | self.use += ' GCOV' 19 | else: 20 | self.use = 'GCOV' 21 | -------------------------------------------------------------------------------- /tools/ndnsec/wscript: -------------------------------------------------------------------------------- 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- 2 | 3 | top = '../..' 4 | 5 | def build(bld): 6 | bld.objects(target='ndnsec-objects', 7 | source=bld.path.ant_glob('*.cpp', excl=['main.cpp']), 8 | features='pch', 9 | headers='ndnsec-pch.hpp', 10 | use='BOOST_TOOLS ndn-cxx') 11 | 12 | bld.program(name='ndnsec', 13 | target=f'{top}/bin/ndnsec', 14 | source=['main.cpp'], 15 | use='ndnsec-objects') 16 | 17 | # create convenience symlinks 18 | for cmd in ('list', 'get-default', 'set-default', 'delete', 19 | 'key-gen', 'sign-req', 'cert-gen', 'cert-dump', 20 | 'cert-install', 'export', 'import'): 21 | bld.symlink_as('${BINDIR}/ndnsec-%s' % cmd, 'ndnsec') 22 | -------------------------------------------------------------------------------- /.jenkins.d/20-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | # https://github.com/google/sanitizers/wiki/SanitizerCommonFlags 5 | # https://github.com/google/sanitizers/wiki/AddressSanitizerFlags 6 | ASAN_OPTIONS="color=always" 7 | ASAN_OPTIONS+=":strip_path_prefix=${PWD}/" 8 | ASAN_OPTIONS+=":check_initialization_order=1" 9 | ASAN_OPTIONS+=":detect_stack_use_after_return=1" 10 | ASAN_OPTIONS+=":strict_init_order=1" 11 | ASAN_OPTIONS+=":strict_string_checks=1" 12 | ASAN_OPTIONS+=":detect_invalid_pointer_pairs=2" 13 | export ASAN_OPTIONS 14 | 15 | # https://www.boost.org/doc/libs/release/libs/test/doc/html/boost_test/runtime_config/summary.html 16 | export BOOST_TEST_BUILD_INFO=1 17 | export BOOST_TEST_COLOR_OUTPUT=1 18 | export BOOST_TEST_DETECT_MEMORY_LEAK=0 19 | export BOOST_TEST_LOGGER=HRF,test_suite,stdout:XML,all,build/xunit-log.xml 20 | 21 | set -x 22 | 23 | # Prepare environment 24 | rm -rf ~/.ndn 25 | 26 | # Run unit tests 27 | ./build/unit-tests 28 | -------------------------------------------------------------------------------- /examples/wscript: -------------------------------------------------------------------------------- 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- 2 | 3 | top = '..' 4 | 5 | def build(bld): 6 | # List all .cpp files (whole example in one .cpp) 7 | for ex in bld.path.ant_glob('*.cpp'): 8 | name = ex.change_ext('').path_from(bld.path.get_bld()) 9 | bld.program(name=f'example-{name}', 10 | target=name, 11 | source=[ex], 12 | use='ndn-cxx', 13 | install_path=None) 14 | 15 | # List all directories (example can have multiple .cpp in the directory) 16 | for subdir in bld.path.ant_glob('*', dir=True, src=False): 17 | name = subdir.path_from(bld.path) 18 | bld.program(name=f'example-{name}', 19 | target=name, 20 | source=subdir.ant_glob('**/*.cpp'), 21 | use='ndn-cxx', 22 | includes=name, 23 | install_path=None) 24 | -------------------------------------------------------------------------------- /.waf-tools/cross.py: -------------------------------------------------------------------------------- 1 | from waflib import Utils 2 | 3 | def options(opt): 4 | opt.add_option('--build', default=Utils.unversioned_sys_platform(), 5 | help='Build platform that is doing the actual compilation (e.g., darwin)') 6 | opt.add_option('--host', default=Utils.unversioned_sys_platform(), 7 | help='Host platform on which the compiled binary will run (e.g., android)') 8 | # opt.add_option('--target', default=Utils.unversioned_sys_platform(), 9 | # help='Target platform on which the compiled binary's output will run') 10 | 11 | def configure(conf): 12 | conf.env.BUILD = conf.options.build 13 | conf.env.HOST = conf.options.host 14 | # conf.env.TARGET = conf.options.target 15 | 16 | conf.start_msg('Build platform') 17 | conf.end_msg(conf.env.BUILD) 18 | 19 | conf.start_msg('Host platform') 20 | conf.end_msg(conf.env.HOST) 21 | 22 | # conf.start_msg('Target platform') 23 | # conf.end_msg(conf.env.TARGET) 24 | -------------------------------------------------------------------------------- /.waf-tools/sanitizers.py: -------------------------------------------------------------------------------- 1 | # Davide Pesavento (LIP6), 2016 2 | 3 | def options(opt): 4 | opt.add_option('--with-sanitizer', action='store', default='', dest='sanitizers', 5 | help='Comma-separated list of compiler sanitizers to enable [default=none]') 6 | 7 | def configure(conf): 8 | for san in conf.options.sanitizers.split(','): 9 | if not san: 10 | continue 11 | 12 | sanflag = '-fsanitize=%s' % san 13 | conf.start_msg('Checking if compiler supports %s' % sanflag) 14 | 15 | if conf.check_cxx(cxxflags=['-Werror', sanflag, '-fno-omit-frame-pointer'], 16 | linkflags=[sanflag], mandatory=False): 17 | conf.end_msg('yes') 18 | conf.env.append_unique('CXXFLAGS', [sanflag, '-fno-omit-frame-pointer']) 19 | conf.env.append_unique('LINKFLAGS', [sanflag]) 20 | else: 21 | conf.end_msg('no', color='RED') 22 | conf.fatal('%s sanitizer is not supported by the current compiler' % san) 23 | -------------------------------------------------------------------------------- /client.conf.sample: -------------------------------------------------------------------------------- 1 | ; "transport" specifies the default transport connection used by the client-side face to communicate 2 | ; with a (local or remote) NDN forwarder. The value must be a Face URI with a Unix or TCP scheme. 3 | ; 4 | ; For example: 5 | ; unix:///tmp/nfd/nfd.sock 6 | ; tcp://192.0.2.1 7 | ; tcp4://example.com:6363 8 | ; tcp6://[2001:db8::1]:6363 9 | ; 10 | ; The default value of this field is platform-dependent, being "unix:///run/nfd/nfd.sock" on Linux 11 | ; and "unix:///var/run/nfd/nfd.sock" on other platforms. 12 | ; 13 | ;transport=unix:///var/run/nfd/nfd.sock 14 | 15 | ; "pib" determines which Public Information Base (PIB) should used by default in applications. 16 | ; Currently, the only supported value for "pib" is: 17 | ; - "pib-sqlite3" (default if not specified) 18 | ; 19 | ;pib=pib-sqlite3 20 | 21 | ; "tpm" determines which Trusted Platform Module (TPM) should used by default in applications. 22 | ; The supported values for "tpm" are: 23 | ; - "tpm-file" (default if not specified) 24 | ; - "tpm-osxkeychain" 25 | ; 26 | ;tpm=tpm-file 27 | -------------------------------------------------------------------------------- /docs/release-notes/release-notes-0.4.1.rst: -------------------------------------------------------------------------------- 1 | ndn-cxx version 0.4.1 2 | --------------------- 3 | 4 | Release date: March 25, 2016 5 | 6 | Changes since version 0.4.0: 7 | 8 | Improvements and bug fixes 9 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | - Improved support for ECDSA signatures (:issue:`3438`, :issue:`3439`) 12 | 13 | - Support for MustBeFresh selector processing in InMemoryStorage (:issue:`3274`) 14 | 15 | - Use InMemoryStorage for StatusDataset and Notification produced by managers based on 16 | Dispatcher class (:issue:`2182`) 17 | 18 | Removed 19 | ^^^^^^^ 20 | 21 | - Deprecated ``tlvdump`` command-line tool (use ``ndn-dissect`` tool from `NDN Essential Tools 22 | `__ instead 23 | 24 | Planned features for future releases 25 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | 27 | - Introduce new API to simplify security transformations (:issue:`3009`) 28 | 29 | - NDN trust schema as a description of application trust model, which can help automate data 30 | and interest packet signing and authentication (:issue:`2829`) 31 | 32 | - Refactored KeyChain abstraction (:issue:`2926`) 33 | -------------------------------------------------------------------------------- /tests/unit/wscript: -------------------------------------------------------------------------------- 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- 2 | 3 | top = '../..' 4 | 5 | def build(bld): 6 | tmpdir = 'UNIT_TESTS_TMPDIR="%s"' % bld.bldnode.make_node('tests-tmp') 7 | 8 | srcFiles = bld.path.ant_glob('**/*.cpp', 9 | excl=['main.cpp', 10 | '**/*-osx.t.cpp', 11 | '**/*-sqlite3.t.cpp']) 12 | 13 | if bld.env.HAVE_OSX_FRAMEWORKS: 14 | srcFiles += bld.path.ant_glob('**/*-osx.t.cpp') 15 | 16 | # In case we want to make it optional later 17 | srcFiles += bld.path.ant_glob('**/*-sqlite3.t.cpp') 18 | 19 | # unit test objects 20 | bld.objects( 21 | target='unit-tests-objects', 22 | source=srcFiles, 23 | features='pch', 24 | headers='unit-tests-pch.hpp', 25 | use='tests-common', 26 | defines=[tmpdir]) 27 | 28 | # unit test binary 29 | bld.program( 30 | target=f'{top}/unit-tests', 31 | name='unit-tests', 32 | source=['main.cpp'], 33 | use='unit-tests-objects', 34 | install_path=None) 35 | -------------------------------------------------------------------------------- /tests/unit/main.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2020 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #define BOOST_TEST_MODULE ndn-cxx 23 | #include "tests/boost-test.hpp" 24 | -------------------------------------------------------------------------------- /docs/manpages/ndnsec-import.rst: -------------------------------------------------------------------------------- 1 | ndnsec-import 2 | ============= 3 | 4 | Synopsis 5 | -------- 6 | 7 | **ndnsec import** [**-h**] [**-P** *passphrase*] *file* 8 | 9 | Description 10 | ----------- 11 | 12 | Import a certificate and its private key from a file in **SafeBag** format. 13 | The command will interactively ask for a passphrase to be used for decrypting the private key. 14 | If *file* is "-", the **SafeBag** data will be read from the standard input. 15 | 16 | :program:`ndnsec-export` can be used to create a file in the expected format. 17 | 18 | Options 19 | ------- 20 | 21 | .. option:: -P , --password 22 | 23 | Passphrase to use for decryption. If empty or not specified, the user is 24 | interactively asked to type the passphrase on the terminal. Note that 25 | specifying the passphrase via this option is insecure, as it can potentially 26 | end up in the shell's history, be visible in :command:`ps` output, and so on. 27 | 28 | Examples 29 | -------- 30 | 31 | Import a certificate and private key from a file:: 32 | 33 | $ ndnsec import alice.ndnkey 34 | 35 | See Also 36 | -------- 37 | 38 | :manpage:`ndnsec-cert-install(1)`, 39 | :manpage:`ndnsec-export(1)` 40 | -------------------------------------------------------------------------------- /docs/manpages/ndnsec-set-default.rst: -------------------------------------------------------------------------------- 1 | ndnsec-set-default 2 | ================== 3 | 4 | Synopsis 5 | -------- 6 | 7 | **ndnsec set-default** [**-h**] [**-k**\|\ **-c**] *name* 8 | 9 | Description 10 | ----------- 11 | 12 | This command allows changing the default security settings. 13 | 14 | Without any options, *name*, which must refer to an existing NDN identity, is set as the 15 | default identity for the current user. 16 | 17 | Options 18 | ------- 19 | 20 | .. option:: -k, --default-key 21 | 22 | Set *name*, which must be a key name, as the default key for the corresponding identity. 23 | 24 | .. option:: -c, --default-cert 25 | 26 | Set *name*, which must be a certificate name, as the default certificate for the 27 | corresponding key. 28 | 29 | Examples 30 | -------- 31 | 32 | Set a key's default certificate:: 33 | 34 | $ ndnsec set-default -c /ndn/test/KEY/alice/ksk-1394129695025/ID-CERT/%FD%01D%98%9A%F2%3F 35 | 36 | Set an identity's default key:: 37 | 38 | $ ndnsec set-default -k /ndn/test/alice/ksk-1394129695025 39 | 40 | Set the user's default identity:: 41 | 42 | $ ndnsec set-default /ndn/test/alice 43 | 44 | See Also 45 | -------- 46 | 47 | :manpage:`ndnsec-get-default(1)`, 48 | :manpage:`ndnsec-list(1)` 49 | -------------------------------------------------------------------------------- /ndn-cxx/detail/asio-fwd.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_DETAIL_ASIO_FWD_HPP 23 | #define NDN_CXX_DETAIL_ASIO_FWD_HPP 24 | 25 | namespace boost::asio { 26 | class io_context; 27 | } // namespace boost::asio 28 | 29 | #endif // NDN_CXX_DETAIL_ASIO_FWD_HPP 30 | -------------------------------------------------------------------------------- /docs/manpages/ndnsec-delete.rst: -------------------------------------------------------------------------------- 1 | ndnsec-delete 2 | ============= 3 | 4 | Synopsis 5 | -------- 6 | 7 | **ndnsec delete** [**-h**] [**-k**\|\ **-c**] *name* 8 | 9 | Description 10 | ----------- 11 | 12 | This command allows deleting security data from both the 13 | **Public Information Base (PIB)** and the **Trusted Platform Module (TPM)**. 14 | 15 | By default, *name* is interpreted as an identity name. 16 | If an identity is deleted, all keys and certificates belonging to that identity 17 | will be deleted as well. If a key is deleted, all certificates associated with 18 | that key will be deleted as well. 19 | 20 | Options 21 | ------- 22 | 23 | .. option:: -k, --delete-key 24 | 25 | Interpret *name* as a key name and delete the key and its associated data. 26 | 27 | .. option:: -c, --delete-cert 28 | 29 | Interpret *name* as a certificate name and delete the certificate. 30 | 31 | Exit Status 32 | ----------- 33 | 34 | Normally, the exit status is 0 if the requested entity is deleted successfully. 35 | If the entity to be deleted does not exist, the exit status is 1. 36 | For any other errors, the exit status is 2. 37 | 38 | Examples 39 | -------- 40 | 41 | Delete all data related to the identity ``/ndn/test/david``:: 42 | 43 | $ ndnsec delete /ndn/test/david 44 | 45 | See Also 46 | -------- 47 | 48 | :manpage:`ndnsec-list(1)` 49 | -------------------------------------------------------------------------------- /tools/ndnsec/ndnsec-pch.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2021 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_TOOLS_NDNSEC_NDNSEC_PCH_HPP 23 | #define NDN_CXX_TOOLS_NDNSEC_NDNSEC_PCH_HPP 24 | 25 | #include "util.hpp" 26 | 27 | #include 28 | 29 | #endif // NDN_CXX_TOOLS_NDNSEC_NDNSEC_PCH_HPP 30 | -------------------------------------------------------------------------------- /.jenkins.d/40-headers-check.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | # It's intentional not to use `set -x`, because this script explicitly prints useful information 4 | # and should not run in trace mode. 5 | 6 | PROJ=ndn-cxx 7 | PCFILE=libndn-cxx 8 | 9 | if [[ -n $DISABLE_HEADERS_CHECK ]]; then 10 | echo 'Skipping headers check.' 11 | exit 0 12 | fi 13 | 14 | if [[ $ID_LIKE == *linux* && -d /usr/local/lib64/pkgconfig ]]; then 15 | export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig 16 | fi 17 | 18 | CXX=${CXX:-g++} 19 | STD=-std=c++17 20 | CXXFLAGS="-O2 -Wall -Wno-unknown-warning-option -Wno-enum-constexpr-conversion -Wno-unused-const-variable $(pkgconf --cflags libndn-cxx $PCFILE)" 21 | INCLUDEDIR="$(pkgconf --variable=includedir $PCFILE)"/$PROJ 22 | 23 | echo "Using: $CXX $STD $CXXFLAGS" 24 | 25 | NCHECKED=0 26 | NERRORS=0 27 | while IFS= read -r -d '' H; do 28 | echo "Checking header ${H#${INCLUDEDIR}/}" 29 | "$CXX" -xc++ $STD $CXXFLAGS -c -o /dev/null "$H" || : $((NERRORS++)) 30 | : $((NCHECKED++)) 31 | done < <(find "$INCLUDEDIR" -name '*.hpp' -type f -print0 2>/dev/null) 32 | 33 | if [[ $NCHECKED -eq 0 ]]; then 34 | echo "No headers found. Is $PROJ installed?" 35 | exit 1 36 | else 37 | echo "$NCHECKED headers checked." 38 | fi 39 | 40 | if [[ $NERRORS -gt 0 ]]; then 41 | echo "$NERRORS headers could not be compiled." 42 | exit 1 43 | fi 44 | -------------------------------------------------------------------------------- /ndn-cxx/detail/cancel-handle.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/detail/cancel-handle.hpp" 23 | 24 | namespace ndn::detail { 25 | 26 | void 27 | CancelHandle::cancel() const 28 | { 29 | if (m_cancel != nullptr) { 30 | m_cancel(); 31 | m_cancel = nullptr; 32 | } 33 | } 34 | 35 | } // namespace ndn::detail 36 | -------------------------------------------------------------------------------- /ndn-cxx/encoding/buffer.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2020 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/encoding/buffer.hpp" 23 | #include "ndn-cxx/util/string-helper.hpp" 24 | 25 | namespace ndn { 26 | 27 | std::ostream& 28 | boost_test_print_type(std::ostream& os, const Buffer& buf) 29 | { 30 | printHex(os, buf, false); 31 | return os; 32 | } 33 | 34 | } // namespace ndn 35 | -------------------------------------------------------------------------------- /.jenkins.d/30-coverage.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | [[ $JOB_NAME == *code-coverage ]] || exit 0 5 | 6 | export FORCE_COLOR=1 7 | export UV_NO_MANAGED_PYTHON=1 8 | 9 | set -x 10 | 11 | # Generate a detailed HTML report and an XML report in Cobertura format using gcovr 12 | # Note: trailing slashes are important in the paths below. Do not remove them! 13 | uvx --from 'git+https://github.com/gcovr/gcovr@99b82e7' gcovr \ 14 | --decisions \ 15 | --filter ndn-cxx/ \ 16 | --exclude ndn-cxx/detail/nonstd/ \ 17 | --exclude-throw-branches \ 18 | --exclude-unreachable-branches \ 19 | --cobertura build/coverage.xml \ 20 | --html-details build/gcovr/ \ 21 | --txt-summary \ 22 | build 23 | 24 | # Generate a detailed HTML report using lcov 25 | lcov \ 26 | --quiet \ 27 | --capture \ 28 | --directory . \ 29 | --include "$PWD/ndn-cxx/*" \ 30 | --exclude "$PWD/ndn-cxx/detail/nonstd/*" \ 31 | --branch-coverage \ 32 | --rc no_exception_branch=1 \ 33 | --ignore-errors inconsistent,mismatch,mismatch \ 34 | --output-file build/coverage.info 35 | 36 | genhtml \ 37 | --quiet \ 38 | --branch-coverage \ 39 | --demangle-cpp \ 40 | --legend \ 41 | --missed \ 42 | --show-proportion \ 43 | --title "ndn-cxx $(cat VERSION.info)" \ 44 | --ignore-errors inconsistent,inconsistent \ 45 | --output-directory build/lcov \ 46 | build/coverage.info 47 | -------------------------------------------------------------------------------- /ndn-cxx/util/signal.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2021 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_UTIL_SIGNAL_HPP 23 | #define NDN_CXX_UTIL_SIGNAL_HPP 24 | 25 | #include "ndn-cxx/util/signal/signal.hpp" 26 | #include "ndn-cxx/util/signal/emit.hpp" 27 | #include "ndn-cxx/util/signal/connection.hpp" 28 | #include "ndn-cxx/util/signal/scoped-connection.hpp" 29 | 30 | #endif // NDN_CXX_UTIL_SIGNAL_HPP 31 | -------------------------------------------------------------------------------- /ndn-cxx/util/regex.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2021 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | * 21 | * @author Yingdi Yu 22 | */ 23 | 24 | #ifndef NDN_CXX_UTIL_REGEX_HPP 25 | #define NDN_CXX_UTIL_REGEX_HPP 26 | 27 | #include "ndn-cxx/util/regex/regex-top-matcher.hpp" 28 | 29 | namespace ndn { 30 | 31 | using Regex = RegexTopMatcher; 32 | 33 | } // namespace ndn 34 | 35 | #endif // NDN_CXX_UTIL_REGEX_HPP 36 | -------------------------------------------------------------------------------- /ndn-cxx/mgmt/nfd/control-response.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_MGMT_NFD_CONTROL_RESPONSE_HPP 23 | #define NDN_CXX_MGMT_NFD_CONTROL_RESPONSE_HPP 24 | 25 | #include "ndn-cxx/mgmt/control-response.hpp" 26 | 27 | namespace ndn::nfd { 28 | 29 | using ControlResponse = mgmt::ControlResponse; 30 | 31 | } // namespace ndn::nfd 32 | 33 | #endif // NDN_CXX_MGMT_NFD_CONTROL_RESPONSE_HPP 34 | -------------------------------------------------------------------------------- /tests/boost-test.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2024 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_TESTS_BOOST_TEST_HPP 23 | #define NDN_CXX_TESTS_BOOST_TEST_HPP 24 | 25 | // suppress warnings from Boost.Test 26 | #pragma GCC system_header 27 | #pragma clang system_header 28 | 29 | #define BOOST_TEST_DYN_LINK 30 | #include 31 | 32 | namespace ut = boost::unit_test; 33 | 34 | #endif // NDN_CXX_TESTS_BOOST_TEST_HPP 35 | -------------------------------------------------------------------------------- /.waf-tools/sqlite3.py: -------------------------------------------------------------------------------- 1 | from waflib.Configure import conf 2 | 3 | def options(opt): 4 | opt.add_option('--with-sqlite3', type='string', default=None, dest='sqlite3_dir', 5 | help='directory where SQLite3 is installed, e.g., /usr/local') 6 | 7 | @conf 8 | def check_sqlite3(self, *k, **kw): 9 | root = k and k[0] or kw.get('path', self.options.sqlite3_dir) 10 | mandatory = kw.get('mandatory', True) 11 | var = kw.get('uselib_store', 'SQLITE3') 12 | 13 | if root: 14 | self.check_cxx(lib='sqlite3', 15 | msg='Checking for SQLite3 library', 16 | define_name='HAVE_%s' % var, 17 | uselib_store=var, 18 | mandatory=mandatory, 19 | includes='%s/include' % root, 20 | libpath='%s/lib' % root) 21 | else: 22 | try: 23 | self.check_cfg(package='sqlite3', 24 | args=['--cflags', '--libs'], 25 | global_define=True, 26 | define_name='HAVE_%s' % var, 27 | uselib_store='SQLITE3', 28 | mandatory=True) 29 | except: 30 | self.check_cxx(lib='sqlite3', 31 | msg='Checking for SQLite3 library', 32 | define_name='HAVE_%s' % var, 33 | uselib_store=var, 34 | mandatory=mandatory) 35 | -------------------------------------------------------------------------------- /ndn-cxx/lp/sequence.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | * 21 | * @author Eric Newberry 22 | */ 23 | 24 | #ifndef NDN_CXX_LP_SEQUENCE_HPP 25 | #define NDN_CXX_LP_SEQUENCE_HPP 26 | 27 | #include 28 | 29 | namespace ndn::lp { 30 | 31 | /** 32 | * \brief Represents a sequence number. 33 | */ 34 | using Sequence = uint64_t; 35 | 36 | } // namespace ndn::lp 37 | 38 | #endif // NDN_CXX_LP_SEQUENCE_HPP 39 | -------------------------------------------------------------------------------- /ndn-cxx/lp/empty-value.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | * 21 | * @author Teng Liang 22 | */ 23 | 24 | #ifndef NDN_CXX_LP_TLV_EMPTY_VALUE_HPP 25 | #define NDN_CXX_LP_TLV_EMPTY_VALUE_HPP 26 | 27 | namespace ndn::lp { 28 | 29 | /** 30 | * \brief Represents a zero-length TLV-VALUE. 31 | */ 32 | struct EmptyValue 33 | { 34 | }; 35 | 36 | } // namespace ndn::lp 37 | 38 | #endif // NDN_CXX_LP_TLV_EMPTY_VALUE_HPP 39 | -------------------------------------------------------------------------------- /ndn-cxx/lp/nack.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | * 21 | * @author Eric Newberry 22 | */ 23 | 24 | #include "ndn-cxx/lp/nack.hpp" 25 | 26 | namespace ndn::lp { 27 | 28 | Nack::Nack() = default; 29 | 30 | Nack::Nack(const Interest& interest) 31 | : m_interest(interest) 32 | { 33 | } 34 | 35 | Nack::Nack(Interest&& interest) 36 | : m_interest(std::move(interest)) 37 | { 38 | } 39 | 40 | } // namespace ndn::lp 41 | -------------------------------------------------------------------------------- /tests/unit/util/log-module1.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/util/logger.hpp" 23 | 24 | NDN_LOG_INIT(Module1); 25 | 26 | namespace ndn::tests { 27 | 28 | void 29 | logFromModule1() 30 | { 31 | NDN_LOG_TRACE("trace" << 1); 32 | NDN_LOG_DEBUG("debug" << 1); 33 | NDN_LOG_INFO("info" << 1); 34 | NDN_LOG_WARN("warn" << 1); 35 | NDN_LOG_ERROR("error" << 1); 36 | NDN_LOG_FATAL("fatal" << 1); 37 | } 38 | 39 | } // namespace ndn::tests 40 | -------------------------------------------------------------------------------- /tests/unit/util/log-module2.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/util/logger.hpp" 23 | 24 | NDN_LOG_INIT(Module2); 25 | 26 | namespace ndn::tests { 27 | 28 | void 29 | logFromModule2() 30 | { 31 | NDN_LOG_TRACE("trace" << 2); 32 | NDN_LOG_DEBUG("debug" << 2); 33 | NDN_LOG_INFO("info" << 2); 34 | NDN_LOG_WARN("warn" << 2); 35 | NDN_LOG_ERROR("error" << 2); 36 | NDN_LOG_FATAL("fatal" << 2); 37 | } 38 | 39 | } // namespace ndn::tests 40 | -------------------------------------------------------------------------------- /ndn-cxx/security/transform/step-source.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/security/transform/step-source.hpp" 23 | 24 | namespace ndn::security::transform { 25 | 26 | size_t 27 | StepSource::write(span buf) 28 | { 29 | return m_next->write(buf); 30 | } 31 | 32 | void 33 | StepSource::end() 34 | { 35 | m_next->end(); 36 | } 37 | 38 | void 39 | StepSource::doPump() 40 | { 41 | } 42 | 43 | } // namespace ndn::security::transform 44 | -------------------------------------------------------------------------------- /tests/unit/util/log-filter-module.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/util/logger.hpp" 23 | 24 | NDN_LOG_INIT(fm.FilterModule); 25 | 26 | namespace ndn::tests { 27 | 28 | void 29 | logFromFilterModule() 30 | { 31 | NDN_LOG_TRACE("traceFM"); 32 | NDN_LOG_DEBUG("debugFM"); 33 | NDN_LOG_INFO("infoFM"); 34 | NDN_LOG_WARN("warnFM"); 35 | NDN_LOG_ERROR("errorFM"); 36 | NDN_LOG_FATAL("fatalFM"); 37 | } 38 | 39 | } // namespace ndn::tests 40 | 41 | -------------------------------------------------------------------------------- /ndn-cxx/util/signal/connection.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/util/signal/connection.hpp" 23 | 24 | namespace ndn::signal { 25 | 26 | Connection::Connection(weak_ptr disconnect) noexcept 27 | : m_disconnect(std::move(disconnect)) 28 | { 29 | } 30 | 31 | void 32 | Connection::disconnect() 33 | { 34 | auto f = m_disconnect.lock(); 35 | if (f != nullptr) { 36 | (*f)(); 37 | } 38 | } 39 | 40 | } // namespace ndn::signal 41 | -------------------------------------------------------------------------------- /tests/tests-pch.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2024 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_TESTS_TESTS_PCH_HPP 23 | #define NDN_CXX_TESTS_TESTS_PCH_HPP 24 | 25 | #include "ndn-cxx/impl/common-pch.hpp" 26 | 27 | #include "ndn-cxx/data.hpp" 28 | #include "ndn-cxx/interest.hpp" 29 | #include "ndn-cxx/lp/nack.hpp" 30 | #include "ndn-cxx/security/key-chain.hpp" 31 | 32 | #include "tests/boost-test.hpp" 33 | 34 | #include 35 | #include 36 | 37 | #endif // NDN_CXX_TESTS_TESTS_PCH_HPP 38 | -------------------------------------------------------------------------------- /tests/unit/io-key-chain-fixture.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_TESTS_UNIT_IO_KEY_CHAIN_FIXTURE_HPP 23 | #define NDN_CXX_TESTS_UNIT_IO_KEY_CHAIN_FIXTURE_HPP 24 | 25 | #include "tests/key-chain-fixture.hpp" 26 | #include "tests/unit/io-fixture.hpp" 27 | 28 | namespace ndn::tests { 29 | 30 | class IoKeyChainFixture : public IoFixture, public KeyChainFixture 31 | { 32 | }; 33 | 34 | } // namespace ndn::tests 35 | 36 | #endif // NDN_CXX_TESTS_UNIT_IO_KEY_CHAIN_FIXTURE_HPP 37 | -------------------------------------------------------------------------------- /ndn-cxx/ims/in-memory-storage-entry.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2024 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/ims/in-memory-storage-entry.hpp" 23 | 24 | namespace ndn { 25 | 26 | void 27 | InMemoryStorageEntry::release() 28 | { 29 | m_dataPacket.reset(); 30 | m_markStaleEventId.cancel(); 31 | } 32 | 33 | void 34 | InMemoryStorageEntry::scheduleMarkStale(Scheduler& sched, time::nanoseconds after) 35 | { 36 | m_markStaleEventId = sched.schedule(after, [this] { m_isFresh = false; }); 37 | } 38 | 39 | } // namespace ndn 40 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1 2 | 3 | FROM ubuntu:24.04 AS build 4 | 5 | RUN apt-get install -Uy --no-install-recommends \ 6 | dpkg-dev \ 7 | g++ \ 8 | git \ 9 | libboost-chrono-dev \ 10 | libboost-dev \ 11 | libboost-log-dev \ 12 | libboost-program-options-dev \ 13 | libboost-stacktrace-dev \ 14 | libboost-thread-dev \ 15 | libsqlite3-dev \ 16 | libssl-dev \ 17 | pkgconf \ 18 | python3 \ 19 | && apt-get distclean 20 | 21 | ARG JOBS 22 | ARG SOURCE_DATE_EPOCH 23 | RUN --mount=rw,target=/src < ndn-cxx 41 | EOF 42 | 43 | 44 | FROM ubuntu:24.04 AS runtime 45 | 46 | RUN --mount=from=build,source=/deps,target=/deps \ 47 | apt-get install -Uy --no-install-recommends \ 48 | $(cat /deps/ndn-cxx) \ 49 | && apt-get distclean 50 | 51 | RUN --mount=from=build,source=/usr,target=/build \ 52 | cp -av /build/lib/libndn-cxx.so.* /usr/lib/ \ 53 | && cp -av /build/bin/ndnsec* /usr/bin/ 54 | -------------------------------------------------------------------------------- /ndn-cxx/net/impl/link-type-helper.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/net/impl/link-type-helper.hpp" 23 | #include "ndn-cxx/detail/config.hpp" 24 | 25 | #ifdef NDN_CXX_HAVE_OSX_FRAMEWORKS 26 | // implemented in link-type-helper-osx.mm 27 | #else 28 | 29 | namespace ndn::net::detail { 30 | 31 | ndn::nfd::LinkType 32 | getLinkType(const std::string& ifName) 33 | { 34 | return nfd::LINK_TYPE_NONE; 35 | } 36 | 37 | } // namespace ndn::net::detail 38 | 39 | #endif // NDN_CXX_HAVE_OSX_FRAMEWORKS 40 | -------------------------------------------------------------------------------- /ndn-cxx/util/impl/logger-android.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_UTIL_IMPL_LOGGER_ANDROID_HPP 23 | #define NDN_CXX_UTIL_IMPL_LOGGER_ANDROID_HPP 24 | 25 | #include "ndn-cxx/util/logger.hpp" 26 | 27 | #ifndef __ANDROID__ 28 | #error "This file should not be compiled ..." 29 | #endif 30 | 31 | namespace ndn::util::detail { 32 | 33 | boost::shared_ptr 34 | makeAndroidLogger(); 35 | 36 | } // namespace ndn::util::detail 37 | 38 | #endif // NDN_CXX_UTIL_IMPL_LOGGER_ANDROID_HPP 39 | -------------------------------------------------------------------------------- /tests/unit/util/placeholders2.t.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2020 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | // Bug 2109 test case 23 | 24 | // interest.hpp includes common.hpp; common.hpp is an implementation detail and should not 25 | // be directly included from an external program 26 | #include "ndn-cxx/interest.hpp" 27 | 28 | #include 29 | 30 | void 31 | placeholders2TestFunction(int) 32 | { 33 | } 34 | 35 | int 36 | placeholders2TestMain() 37 | { 38 | auto f = boost::bind(&placeholders2TestFunction, _1); 39 | f(1); 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /ndn-cxx/net/impl/link-type-helper.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_NET_IMPL_LINK_TYPE_HELPER_HPP 23 | #define NDN_CXX_NET_IMPL_LINK_TYPE_HELPER_HPP 24 | 25 | #include "ndn-cxx/encoding/nfd-constants.hpp" 26 | 27 | #include 28 | 29 | namespace ndn::net::detail { 30 | 31 | /** 32 | * @brief Obtain information about WiFi link type 33 | */ 34 | ndn::nfd::LinkType 35 | getLinkType(const std::string& ifName); 36 | 37 | } // namespace ndn::net::detail 38 | 39 | #endif // NDN_CXX_NET_IMPL_LINK_TYPE_HELPER_HPP 40 | -------------------------------------------------------------------------------- /ndn-cxx/util/exception.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/util/exception.hpp" 23 | 24 | #include 25 | 26 | namespace ndn::exception { 27 | 28 | #ifdef NDN_CXX_HAVE_STACKTRACE 29 | std::string 30 | to_string(const errinfo_stacktrace& x) 31 | { 32 | if (x.value().empty()) 33 | return ""; 34 | 35 | std::ostringstream out; 36 | out << "===== Stacktrace =====\n" 37 | << x.value() 38 | << "======================\n"; 39 | return out.str(); 40 | } 41 | #endif 42 | 43 | } // namespace ndn::exception 44 | -------------------------------------------------------------------------------- /ndn-cxx/encoding/tlv-security.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_ENCODING_TLV_SECURITY_HPP 23 | #define NDN_CXX_ENCODING_TLV_SECURITY_HPP 24 | 25 | #include 26 | 27 | namespace ndn::tlv::security { 28 | 29 | /** 30 | * @brief TLV-TYPE numbers for SafeBag and related elements. 31 | * @sa SafeBag Format 32 | */ 33 | enum : uint32_t { 34 | SafeBag = 128, 35 | EncryptedKey = 129, 36 | }; 37 | 38 | } // namespace ndn::tlv::security 39 | 40 | #endif // NDN_CXX_ENCODING_TLV_SECURITY_HPP 41 | -------------------------------------------------------------------------------- /ndn-cxx/security/transform/bool-sink.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2024 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/security/transform/bool-sink.hpp" 23 | 24 | namespace ndn::security::transform { 25 | 26 | size_t 27 | BoolSink::doWrite(span buf) 28 | { 29 | if (!m_hasValue && !buf.empty()) { 30 | m_value = (buf.front() != 0); 31 | m_hasValue = true; 32 | } 33 | return buf.size(); 34 | } 35 | 36 | unique_ptr 37 | boolSink(bool& value) 38 | { 39 | return make_unique(value); 40 | } 41 | 42 | } // namespace ndn::security::transform 43 | -------------------------------------------------------------------------------- /ndn-cxx/util/scope.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2024 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_UTIL_SCOPE_HPP 23 | #define NDN_CXX_UTIL_SCOPE_HPP 24 | 25 | #define scope_CONFIG_SELECT_SCOPE scope_SCOPE_NONSTD 26 | #include "ndn-cxx/detail/nonstd/scope-lite.hpp" 27 | 28 | namespace ndn { 29 | 30 | using ::nonstd::scope_exit; 31 | using ::nonstd::scope_fail; 32 | using ::nonstd::scope_success; 33 | 34 | using ::nonstd::make_scope_exit; 35 | using ::nonstd::make_scope_fail; 36 | using ::nonstd::make_scope_success; 37 | 38 | } // namespace ndn 39 | 40 | #endif // NDN_CXX_UTIL_SCOPE_HPP 41 | -------------------------------------------------------------------------------- /tests/unit/unit-tests-pch.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2020 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_TESTS_UNIT_UNIT_TESTS_PCH_HPP 23 | #define NDN_CXX_TESTS_UNIT_UNIT_TESTS_PCH_HPP 24 | 25 | #include "tests/tests-pch.hpp" 26 | 27 | #include "ndn-cxx/face.hpp" 28 | #include "ndn-cxx/ims/in-memory-storage.hpp" 29 | #include "ndn-cxx/security/transform.hpp" 30 | #include "ndn-cxx/security/validator.hpp" 31 | #include "ndn-cxx/util/config-file.hpp" 32 | 33 | #include "tests/key-chain-fixture.hpp" 34 | 35 | #include 36 | 37 | #endif // NDN_CXX_TESTS_UNIT_UNIT_TESTS_PCH_HPP 38 | -------------------------------------------------------------------------------- /ndn-cxx/transport/transport.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2024 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/transport/transport.hpp" 23 | 24 | namespace ndn { 25 | 26 | Transport::Error::Error(const boost::system::error_code& ec, const std::string& msg) 27 | : std::runtime_error(msg + (ec ? " (" + ec.message() + ")" : "")) 28 | { 29 | } 30 | 31 | void 32 | Transport::connect(boost::asio::io_context& ioCtx, ReceiveCallback receiveCallback) 33 | { 34 | BOOST_ASSERT(receiveCallback != nullptr); 35 | 36 | m_ioCtx = &ioCtx; 37 | m_receiveCallback = std::move(receiveCallback); 38 | } 39 | 40 | } // namespace ndn 41 | -------------------------------------------------------------------------------- /ndn-cxx/util/regex/regex-pseudo-matcher.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | * 21 | * @author Yingdi Yu 22 | */ 23 | 24 | #include "ndn-cxx/util/regex/regex-pseudo-matcher.hpp" 25 | 26 | namespace ndn { 27 | 28 | RegexPseudoMatcher::RegexPseudoMatcher() 29 | : RegexMatcher("", EXPR_PSEUDO) 30 | { 31 | } 32 | 33 | void 34 | RegexPseudoMatcher::setMatchResult(const std::string& str) 35 | { 36 | m_matchResult.emplace_back(str); 37 | } 38 | 39 | void 40 | RegexPseudoMatcher::resetMatchResult() 41 | { 42 | m_matchResult.clear(); 43 | } 44 | 45 | } // namespace ndn 46 | -------------------------------------------------------------------------------- /.jenkins.d/README.md: -------------------------------------------------------------------------------- 1 | # Continuous Integration Scripts 2 | 3 | ## Environment Variables 4 | 5 | - `ID`: lower-case string that identifies the operating system, for example: `ID=ubuntu`, 6 | `ID=centos`. See [os-release(5)] for more information. On macOS, where `os-release` is 7 | not available, we emulate it by setting `ID=macos`. 8 | 9 | - `ID_LIKE`: space-separated list of operating system identifiers that are closely related 10 | to the running OS. See [os-release(5)] for more information. The listed values are used 11 | by the CI scripts to select the proper behavior for different platforms and OS flavors. 12 | 13 | Examples: 14 | 15 | - On CentOS, `ID_LIKE="centos rhel fedora linux"` 16 | - On Ubuntu, `ID_LIKE="ubuntu debian linux"` 17 | 18 | - `VERSION_ID`: identifies the operating system version, excluding any release code names. 19 | See [os-release(5)] for more information. Examples: `VERSION_ID=42`, `VERSION_ID=22.04`. 20 | 21 | - `JOB_NAME`: defines the type of the current CI job. Depending on the job type, the CI 22 | scripts can perform different tasks. 23 | 24 | Supported values: 25 | 26 | - empty: default build task 27 | - `code-coverage`: debug build with tests and code coverage analysis 28 | - `limited-build`: only a single debug build with tests 29 | 30 | - `CACHE_DIR`: directory containing cached files from previous builds, e.g., a compiled 31 | version of ndn-cxx. If not set, `/tmp` is used. 32 | 33 | - `DISABLE_ASAN`: disable building with AddressSanitizer. This is automatically set for 34 | the `code-coverage` job type. 35 | 36 | [os-release(5)]: https://www.freedesktop.org/software/systemd/man/os-release.html 37 | -------------------------------------------------------------------------------- /ndn-cxx/security/validator-null.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_SECURITY_VALIDATOR_NULL_HPP 23 | #define NDN_CXX_SECURITY_VALIDATOR_NULL_HPP 24 | 25 | #include "ndn-cxx/security/validator.hpp" 26 | 27 | namespace ndn::security { 28 | 29 | /** 30 | * @brief Validator with "accept-all" policy and offline certificate fetcher 31 | */ 32 | class ValidatorNull : public Validator 33 | { 34 | public: 35 | ValidatorNull(); 36 | }; 37 | 38 | Validator& 39 | getAcceptAllValidator(); 40 | 41 | } // namespace ndn::security 42 | 43 | #endif // NDN_CXX_SECURITY_VALIDATOR_NULL_HPP 44 | -------------------------------------------------------------------------------- /docs/manpages/ndnsec-cert-install.rst: -------------------------------------------------------------------------------- 1 | ndnsec-cert-install 2 | =================== 3 | 4 | Synopsis 5 | -------- 6 | 7 | **ndnsec cert-install** [**-h**] [**-I**\|\ **-K**\|\ **-N**] *file* 8 | 9 | Description 10 | ----------- 11 | 12 | This command allows importing a certificate into the **Public Information Base (PIB)**. 13 | By default, the installed certificate will be set as the default certificate for the 14 | corresponding identity and the identity will be set as the user's default identity. 15 | 16 | *file* is a path to a file that contains the certificate to install. 17 | If *file* is "-", the certificate will be read from the standard input. 18 | The certificate should be in Base64 encoding. 19 | 20 | Options 21 | ------- 22 | 23 | .. option:: -I, --identity-default 24 | 25 | Set the certificate as the default certificate for the corresponding identity, 26 | but do not change the user's default identity. 27 | 28 | .. option:: -K, --key-default 29 | 30 | Set the certificate as the default certificate for the corresponding key, but 31 | do not change the identity's default key or the user's default identity. 32 | 33 | .. option:: -N, --no-default 34 | 35 | Install the certificate but do not change any default settings. 36 | 37 | Examples 38 | -------- 39 | 40 | Install a certificate and set it as the default certificate:: 41 | 42 | $ ndnsec cert-install cert_file.cert 43 | 44 | Install a certificate but do not change any default settings:: 45 | 46 | $ ndnsec cert-install -N cert_file.cert 47 | 48 | See Also 49 | -------- 50 | 51 | :manpage:`ndnsec-cert-dump(1)`, 52 | :manpage:`ndnsec-cert-gen(1)`, 53 | :manpage:`ndnsec-import(1)` 54 | -------------------------------------------------------------------------------- /ndn-cxx/security/validator-null.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/security/validator-null.hpp" 23 | #include "ndn-cxx/security/validation-policy-accept-all.hpp" 24 | #include "ndn-cxx/security/certificate-fetcher-offline.hpp" 25 | 26 | namespace ndn::security { 27 | 28 | ValidatorNull::ValidatorNull() 29 | : Validator(make_unique(), make_unique()) 30 | { 31 | } 32 | 33 | Validator& 34 | getAcceptAllValidator() 35 | { 36 | static ValidatorNull validator; 37 | return validator; 38 | } 39 | 40 | } // namespace ndn::security 41 | -------------------------------------------------------------------------------- /tests/benchmarks/timed-execute.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_TESTS_BENCHMARKS_TIMED_EXECUTE_HPP 23 | #define NDN_CXX_TESTS_BENCHMARKS_TIMED_EXECUTE_HPP 24 | 25 | #include "ndn-cxx/util/time.hpp" 26 | 27 | namespace ndn::tests { 28 | 29 | template 30 | time::nanoseconds 31 | timedExecute(F&& f) 32 | { 33 | auto before = time::steady_clock::now(); 34 | std::invoke(std::forward(f)); 35 | auto after = time::steady_clock::now(); 36 | return after - before; 37 | } 38 | 39 | } // namespace ndn::tests 40 | 41 | #endif // NDN_CXX_TESTS_BENCHMARKS_TIMED_EXECUTE_HPP 42 | -------------------------------------------------------------------------------- /ndn-cxx/detail/packet-base.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2025 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/detail/packet-base.hpp" 23 | #include "ndn-cxx/lp/tags.hpp" 24 | 25 | namespace ndn { 26 | 27 | uint64_t 28 | PacketBase::getCongestionMark() const 29 | { 30 | auto mark = this->getTag(); 31 | return mark ? *mark : 0; 32 | } 33 | 34 | void 35 | PacketBase::setCongestionMark(uint64_t mark) 36 | { 37 | if (mark != 0) { 38 | this->setTag(make_shared(mark)); 39 | } 40 | else { 41 | this->removeTag(); 42 | } 43 | } 44 | 45 | } // namespace ndn 46 | -------------------------------------------------------------------------------- /.jenkins.d/10-build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | if [[ -z $DISABLE_ASAN ]]; then 5 | ASAN="--with-sanitizer=address" 6 | fi 7 | if [[ -n $GITHUB_ACTIONS && $ID == macos && ${VERSION_ID%%.*} -le 13 ]]; then 8 | KEYCHAIN="--with-osx-keychain" 9 | fi 10 | 11 | set -x 12 | 13 | if [[ $JOB_NAME != *code-coverage && $JOB_NAME != *limited-build ]]; then 14 | # Build static library in release mode with tests and without precompiled headers 15 | ./waf --color=yes configure --enable-static --disable-shared --with-tests --without-pch 16 | ./waf --color=yes build 17 | 18 | # Cleanup 19 | ./waf --color=yes distclean 20 | 21 | # Build shared library in release mode with examples and benchmarks 22 | ./waf --color=yes configure --disable-static --enable-shared --with-examples --with-benchmarks 23 | ./waf --color=yes build 24 | 25 | # Cleanup 26 | ./waf --color=yes distclean 27 | fi 28 | 29 | if [[ $JOB_NAME == *code-coverage ]]; then 30 | # Build for coverage testing: enable instrumentation and unit tests only 31 | ./waf --color=yes configure --debug --with-coverage --with-unit-tests --without-tools 32 | ./waf --color=yes build 33 | else 34 | # Build shared library in debug mode with tests 35 | ./waf --color=yes configure --disable-static --enable-shared --debug --with-tests $ASAN $KEYCHAIN 36 | ./waf --color=yes build 37 | fi 38 | 39 | # Install 40 | sudo ./waf --color=yes install 41 | 42 | if [[ $ID_LIKE == *linux* ]]; then 43 | if [[ $(uname -m) == x86_64 && -d /usr/lib64 ]]; then 44 | sudo tee /etc/ld.so.conf.d/ndn.conf >/dev/null <<< /usr/local/lib64 45 | fi 46 | sudo ldconfig 47 | fi 48 | -------------------------------------------------------------------------------- /ndn-cxx/security/tpm/impl/key-ref-osx.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_SECURITY_TPM_IMPL_KEY_REF_OSX_HPP 23 | #define NDN_CXX_SECURITY_TPM_IMPL_KEY_REF_OSX_HPP 24 | 25 | #include "ndn-cxx/detail/common.hpp" 26 | 27 | #ifndef NDN_CXX_HAVE_OSX_FRAMEWORKS 28 | #error "This file should not be compiled ..." 29 | #endif 30 | 31 | #include "ndn-cxx/detail/cf-releaser-osx.hpp" 32 | 33 | #include 34 | 35 | namespace ndn::security::tpm { 36 | 37 | using KeyRefOsx = detail::CFReleaser; 38 | 39 | } // namespace ndn::security::tpm 40 | 41 | #endif // NDN_CXX_SECURITY_TPM_IMPL_KEY_REF_OSX_HPP 42 | -------------------------------------------------------------------------------- /.jenkins: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | case $(uname) in 5 | Linux) 6 | if [[ -e /etc/os-release ]]; then 7 | source /etc/os-release 8 | else 9 | source /usr/lib/os-release 10 | fi 11 | export ID VERSION_ID 12 | export ID_LIKE="${ID} ${ID_LIKE} linux" 13 | if [[ -z $GITHUB_ACTIONS ]]; then 14 | export PATH="${HOME}/.local/bin${PATH:+:}${PATH}" 15 | fi 16 | ;; 17 | Darwin) 18 | # Emulate a subset of os-release(5) 19 | export ID=macos 20 | export VERSION_ID=$(sw_vers -productVersion) 21 | if [[ -z $GITHUB_ACTIONS ]]; then 22 | export PATH="/usr/local/bin${PATH:+:}${PATH}" 23 | fi 24 | if [[ -x /opt/homebrew/bin/brew ]]; then 25 | eval "$(/opt/homebrew/bin/brew shellenv)" 26 | elif [[ -x /usr/local/bin/brew ]]; then 27 | eval "$(/usr/local/bin/brew shellenv)" 28 | fi 29 | ;; 30 | esac 31 | 32 | export CACHE_DIR=${CACHE_DIR:-/tmp} 33 | 34 | if [[ $JOB_NAME == *code-coverage ]]; then 35 | export DISABLE_ASAN=1 36 | export DISABLE_HEADERS_CHECK=1 37 | fi 38 | 39 | # https://reproducible-builds.org/docs/source-date-epoch/ 40 | export SOURCE_DATE_EPOCH=$(git log -1 --format=%ct) 41 | 42 | for file in .jenkins.d/*; do 43 | [[ -f $file && -x $file ]] || continue 44 | 45 | if [[ -n $GITHUB_ACTIONS ]]; then 46 | label=$(basename "$file" | sed -E 's/[[:digit:]]+-(.*)\..*/\1/') 47 | echo "::group::${label}" 48 | fi 49 | 50 | echo "\$ $file" 51 | "$file" 52 | 53 | if [[ -n $GITHUB_ACTIONS ]]; then 54 | echo "::endgroup::" 55 | fi 56 | done 57 | -------------------------------------------------------------------------------- /tests/unit/io-fixture.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_TESTS_UNIT_IO_FIXTURE_HPP 23 | #define NDN_CXX_TESTS_UNIT_IO_FIXTURE_HPP 24 | 25 | #include "tests/unit/clock-fixture.hpp" 26 | 27 | #include 28 | 29 | namespace ndn::tests { 30 | 31 | class IoFixture : public ClockFixture 32 | { 33 | private: 34 | void 35 | afterTick() final 36 | { 37 | if (m_io.stopped()) { 38 | m_io.restart(); 39 | } 40 | m_io.poll(); 41 | } 42 | 43 | protected: 44 | boost::asio::io_context m_io; 45 | }; 46 | 47 | } // namespace ndn::tests 48 | 49 | #endif // NDN_CXX_TESTS_UNIT_IO_FIXTURE_HPP 50 | -------------------------------------------------------------------------------- /ndn-cxx/util/regex/regex-pseudo-matcher.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2021 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | * 21 | * @author Yingdi Yu 22 | */ 23 | 24 | #ifndef NDN_CXX_UTIL_REGEX_REGEX_PSEUDO_MATCHER_HPP 25 | #define NDN_CXX_UTIL_REGEX_REGEX_PSEUDO_MATCHER_HPP 26 | 27 | #include "ndn-cxx/util/regex/regex-matcher.hpp" 28 | 29 | namespace ndn { 30 | 31 | class RegexPseudoMatcher : public RegexMatcher 32 | { 33 | public: 34 | RegexPseudoMatcher(); 35 | 36 | void 37 | setMatchResult(const std::string& str); 38 | 39 | void 40 | resetMatchResult(); 41 | }; 42 | 43 | } // namespace ndn 44 | 45 | #endif // NDN_CXX_UTIL_REGEX_REGEX_PSEUDO_MATCHER_HPP 46 | -------------------------------------------------------------------------------- /tests/unit/tag.t.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/tag.hpp" 23 | 24 | #include "tests/boost-test.hpp" 25 | 26 | namespace ndn::tests { 27 | 28 | BOOST_AUTO_TEST_SUITE(TestTag) 29 | 30 | BOOST_AUTO_TEST_CASE(SimpleTag) 31 | { 32 | using MyTag = ndn::SimpleTag; 33 | 34 | BOOST_CHECK_EQUAL(MyTag::getTypeId(), 3); 35 | MyTag tag(23361); // explicitly convertible from value type 36 | int value = tag; // implicitly convertible to value type 37 | BOOST_CHECK_EQUAL(value, 23361); 38 | BOOST_CHECK_EQUAL(tag.get(), 23361); 39 | } 40 | 41 | BOOST_AUTO_TEST_SUITE_END() // TestTag 42 | 43 | } // namespace ndn::tests 44 | -------------------------------------------------------------------------------- /docs/specs/safe-bag.rst: -------------------------------------------------------------------------------- 1 | SafeBag Format for Exported Credentials 2 | ======================================= 3 | 4 | Sometimes it may be necessary to export an identity's credentials (i.e., private key and associated 5 | certificate) from one machine and import them into another. This requires a secure container to 6 | carry the sensitive information. For this purpose, we define the **SafeBag** format, which contains 7 | an `NDN certificate `__ and the 8 | corresponding private key in encrypted form. The private key is formatted as a DER-encoded 9 | :rfc:`EncryptedPrivateKeyInfo <5208#section-6>` structure as described in PKCS #8. 10 | 11 | The TLV encoding of ``SafeBag`` is defined as follows: 12 | 13 | .. code-block:: abnf 14 | 15 | SafeBag = SAFE-BAG-TYPE TLV-LENGTH 16 | Certificate 17 | EncryptedKey 18 | 19 | EncryptedKey = ENCRYPTED-KEY-TYPE TLV-LENGTH 20 | *OCTET ; PKCS #8 EncryptedPrivateKeyInfo 21 | 22 | +---------------------------------------------+------------------+-----------------+ 23 | | Type | Assigned number | Assigned number | 24 | | | (decimal) | (hexadecimal) | 25 | +=============================================+==================+=================+ 26 | | SafeBag | 128 | 0x80 | 27 | +---------------------------------------------+------------------+-----------------+ 28 | | EncryptedKey | 129 | 0x81 | 29 | +---------------------------------------------+------------------+-----------------+ 30 | -------------------------------------------------------------------------------- /ndn-cxx/util/regex/regex-backref-manager.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2018 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | * 21 | * @author Yingdi Yu 22 | */ 23 | 24 | #include "ndn-cxx/util/regex/regex-backref-manager.hpp" 25 | 26 | namespace ndn { 27 | 28 | size_t 29 | RegexBackrefManager::pushRef(const shared_ptr& matcher) 30 | { 31 | auto last = m_backrefs.size(); 32 | m_backrefs.emplace_back(matcher); 33 | return last; 34 | } 35 | 36 | shared_ptr 37 | RegexBackrefManager::getBackref(size_t i) const 38 | { 39 | auto backref = m_backrefs[i].lock(); 40 | BOOST_ASSERT(backref != nullptr); 41 | return backref; 42 | } 43 | 44 | } // namespace ndn 45 | -------------------------------------------------------------------------------- /ndn-cxx/util/regex/regex-backref-matcher.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2021 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | * 21 | * @author Yingdi Yu 22 | */ 23 | 24 | #ifndef NDN_CXX_UTIL_REGEX_REGEX_BACKREF_MATCHER_HPP 25 | #define NDN_CXX_UTIL_REGEX_REGEX_BACKREF_MATCHER_HPP 26 | 27 | #include "ndn-cxx/util/regex/regex-matcher.hpp" 28 | 29 | namespace ndn { 30 | 31 | class RegexBackrefMatcher : public RegexMatcher 32 | { 33 | public: 34 | RegexBackrefMatcher(const std::string& expr, 35 | shared_ptr backrefManager); 36 | 37 | void 38 | compile(); 39 | }; 40 | 41 | } // namespace ndn 42 | 43 | #endif // NDN_CXX_UTIL_REGEX_REGEX_BACKREF_MATCHER_HPP 44 | -------------------------------------------------------------------------------- /ndn-cxx/util/span.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2022 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_UTIL_SPAN_HPP 23 | #define NDN_CXX_UTIL_SPAN_HPP 24 | 25 | #define span_CONFIG_SELECT_SPAN span_SPAN_NONSTD 26 | #ifdef NDEBUG 27 | #define span_CONFIG_CONTRACT_LEVEL_OFF 1 28 | #else 29 | #define span_CONFIG_CONTRACT_LEVEL_ON 1 30 | #endif 31 | #define span_FEATURE_WITH_INITIALIZER_LIST_P2447 1 32 | #define span_FEATURE_MEMBER_BACK_FRONT 1 33 | #define span_FEATURE_MAKE_SPAN 1 34 | #include "ndn-cxx/detail/nonstd/span-lite.hpp" 35 | 36 | namespace ndn { 37 | 38 | using ::nonstd::span; 39 | using ::nonstd::dynamic_extent; 40 | using ::nonstd::make_span; 41 | 42 | } // namespace ndn 43 | 44 | #endif // NDN_CXX_UTIL_SPAN_HPP 45 | -------------------------------------------------------------------------------- /ndn-cxx/mgmt/control-parameters-base.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2025 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_MGMT_CONTROL_PARAMETERS_BASE_HPP 23 | #define NDN_CXX_MGMT_CONTROL_PARAMETERS_BASE_HPP 24 | 25 | #include "ndn-cxx/encoding/block.hpp" 26 | 27 | namespace ndn::mgmt { 28 | 29 | /** 30 | * \brief Base class for a struct that contains the parameters for a ControlCommand. 31 | */ 32 | class ControlParametersBase 33 | { 34 | public: 35 | virtual 36 | ~ControlParametersBase() = default; 37 | 38 | virtual void 39 | wireDecode(const Block& wire) = 0; 40 | 41 | virtual Block 42 | wireEncode() const = 0; 43 | }; 44 | 45 | } // namespace ndn::mgmt 46 | 47 | #endif // NDN_CXX_MGMT_CONTROL_PARAMETERS_BASE_HPP 48 | -------------------------------------------------------------------------------- /ndn-cxx/security/validator-config/common.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | * 21 | * @author Yingdi Yu 22 | */ 23 | 24 | #ifndef NDN_CXX_SECURITY_VALIDATOR_CONFIG_COMMON_HPP 25 | #define NDN_CXX_SECURITY_VALIDATOR_CONFIG_COMMON_HPP 26 | 27 | #include "ndn-cxx/detail/common.hpp" 28 | 29 | #include 30 | 31 | namespace ndn::security::validator_config { 32 | 33 | using ConfigSection = boost::property_tree::ptree; 34 | 35 | class Error : public std::runtime_error 36 | { 37 | public: 38 | using std::runtime_error::runtime_error; 39 | }; 40 | 41 | } // namespace ndn::security::validator_config 42 | 43 | #endif // NDN_CXX_SECURITY_VALIDATOR_CONFIG_COMMON_HPP 44 | -------------------------------------------------------------------------------- /docs/manpages/ndnsec-get-default.rst: -------------------------------------------------------------------------------- 1 | ndnsec-get-default 2 | ================== 3 | 4 | Synopsis 5 | -------- 6 | 7 | **ndnsec get-default** [**-h**] [**-k**\|\ **-c**] [**-i** *identity*\|\ **-K** *key*] 8 | [**-q**] 9 | 10 | Description 11 | ----------- 12 | 13 | This command shows the default settings of the local **Public Information Base (PIB)** 14 | or those of a specific PIB identity or key. 15 | 16 | By default, if neither :option:`-i` nor :option:`-K` is given, the command displays 17 | the default identity or the default key/certificate of the default identity. 18 | 19 | Options 20 | ------- 21 | 22 | .. option:: -k, --default-key 23 | 24 | Display the chosen entity's default key name. 25 | 26 | .. option:: -c, --default-cert 27 | 28 | Display the chosen entity's default certificate name. 29 | 30 | .. option:: -i , --identity 31 | 32 | Display default settings of *identity*. 33 | 34 | .. option:: -K , --key 35 | 36 | Display default settings of *key*. 37 | 38 | .. option:: -q, --quiet 39 | 40 | Disable printing the trailing newline character. 41 | 42 | Examples 43 | -------- 44 | 45 | Display an identity's default key name:: 46 | 47 | $ ndnsec get-default -k -i /ndn/test/alice 48 | /ndn/test/alice/ksk-1394129695025 49 | 50 | Display an identity's default certificate name:: 51 | 52 | $ ndnsec get-default -c -i /ndn/test/alice 53 | /ndn/test/KEY/alice/ksk-1394129695025/ID-CERT/%FD%01D%98%9A%F2%3F 54 | 55 | Display a key's default certificate name:: 56 | 57 | $ ndnsec get-default -c -K /ndn/test/alice/ksk-1394129695025 58 | /ndn/test/KEY/alice/ksk-1394129695025/ID-CERT/%FD%01D%98%9A%F2%3F 59 | 60 | See Also 61 | -------- 62 | 63 | :manpage:`ndnsec-list(1)`, 64 | :manpage:`ndnsec-set-default(1)` 65 | -------------------------------------------------------------------------------- /docs/release-notes/release-notes-0.3.2.rst: -------------------------------------------------------------------------------- 1 | ndn-cxx version 0.3.2 2 | --------------------- 3 | 4 | Release date: May 12, 2015 5 | 6 | Changes since version 0.3.1: 7 | 8 | New features 9 | ^^^^^^^^^^^^ 10 | 11 | - Add Link abstraction (:issue:`2587`) 12 | 13 | - Add Link and SelectedDelegation fields to the Interest abstraction (:issue:`2587`) 14 | 15 | - Initial implementation of several components for the upcoming PIB feature (:issue:`2451`): 16 | 17 | * User-facing PIB implementation and implementation-specific PIB interface 18 | * In-memory PIB implementation 19 | * Define new abstraction for identity, key, and certificate 20 | 21 | Updates and bug fixes 22 | ^^^^^^^^^^^^^^^^^^^^^ 23 | 24 | - Enable decoding Exclude containing ImplicitSha256DigestComponent (:issue:`2629`) 25 | 26 | - Update waf build system to version 1.8.9 (:issue:`2209`, :issue:`2657`, :issue:`2792`) 27 | 28 | - Avoid duplicating output in IndentedStream (:issue:`2723`) 29 | 30 | - Fix skipping empty name component `(...)` during URI decoding (:issue:`2725`) 31 | 32 | - Enable ability to exclude empty name component (:issue:`2660`) 33 | 34 | - Fix bug with TLV-LENGTH processing in `Block::fromStream` (:issue:`2728`, :issue:`2729`) 35 | 36 | - Disable precompiled headers on OS X with clang < 6.1.0 (:issue:`2804`) 37 | 38 | Deprecated 39 | ^^^^^^^^^^ 40 | 41 | - `Block::fromBuffer` overloads with output parameter (:issue:`2553`) 42 | 43 | Removed 44 | ^^^^^^^ 45 | 46 | - Delete deprecated Controller functions: 47 | 48 | * `Controller::start` overloads, except the overload taking CommandOptions 49 | * `Controller::Sign` typedef 50 | * `Controller::getDefaultCommandTimeout` 51 | * `ControlCommand::getPrefix` 52 | * `ControlCommand::getRequestName(ControlParameters)` 53 | * `Controller::Controller(Face&)` 54 | -------------------------------------------------------------------------------- /ndn-cxx/lp/pit-token.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/lp/pit-token.hpp" 23 | #include "ndn-cxx/encoding/tlv.hpp" 24 | #include "ndn-cxx/util/string-helper.hpp" 25 | 26 | namespace ndn::lp { 27 | 28 | constexpr size_t LENGTH_MIN = 1; 29 | constexpr size_t LENGTH_MAX = 32; 30 | 31 | void 32 | PitToken::validate() const 33 | { 34 | if (size() < LENGTH_MIN || size() > LENGTH_MAX) { 35 | NDN_THROW(ndn::tlv::Error("PitToken length must be between " + 36 | to_string(LENGTH_MIN) + " and " + to_string(LENGTH_MAX))); 37 | } 38 | } 39 | 40 | std::ostream& 41 | operator<<(std::ostream& os, const PitToken& pitToken) 42 | { 43 | printHex(os, pitToken, false); 44 | return os; 45 | } 46 | 47 | } // namespace ndn::lp 48 | -------------------------------------------------------------------------------- /ndn-cxx/mgmt/nfd/command-options.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/mgmt/nfd/command-options.hpp" 23 | 24 | namespace ndn::nfd { 25 | 26 | CommandOptions& 27 | CommandOptions::setTimeout(time::milliseconds timeout) 28 | { 29 | if (timeout <= 0_ms) { 30 | NDN_THROW(std::out_of_range("Timeout must be positive")); 31 | } 32 | m_timeout = timeout; 33 | return *this; 34 | } 35 | 36 | CommandOptions& 37 | CommandOptions::setPrefix(Name prefix) 38 | { 39 | m_prefix = std::move(prefix); 40 | return *this; 41 | } 42 | 43 | CommandOptions& 44 | CommandOptions::setSigningInfo(security::SigningInfo signingInfo) 45 | { 46 | m_signingInfo = std::move(signingInfo); 47 | return *this; 48 | } 49 | 50 | } // namespace ndn::nfd 51 | -------------------------------------------------------------------------------- /ndn-cxx/security/certificate-fetcher-offline.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/security/certificate-fetcher-offline.hpp" 23 | #include "ndn-cxx/security/certificate-request.hpp" 24 | #include "ndn-cxx/security/validation-state.hpp" 25 | 26 | namespace ndn::security { 27 | 28 | void 29 | CertificateFetcherOffline::doFetch(const shared_ptr& certRequest, 30 | const shared_ptr& state, 31 | const ValidationContinuation&) 32 | { 33 | state->fail({ValidationError::CANNOT_RETRIEVE_CERT, 34 | "Cannot fetch `" + certRequest->interest.getName().toUri() + "` in offline mode"}); 35 | } 36 | 37 | } // namespace ndn::security 38 | -------------------------------------------------------------------------------- /tests/unit/util/placeholders.t.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2018 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | // Bug 2109 test case 23 | 24 | // interest.hpp includes common.hpp; common.hpp shouldn't be used from external program 25 | #include "ndn-cxx/interest.hpp" 26 | 27 | // util/config-file.hpp indirectly includes 28 | // which in turn imports Boost placeholders 29 | #include "ndn-cxx/util/config-file.hpp" 30 | 31 | // It's intentional to write "using namespace", 32 | // to simulate an external program linked against ndn-cxx. 33 | using namespace ndn; 34 | 35 | void 36 | placeholdersTestFunction(int i) 37 | { 38 | } 39 | 40 | int 41 | placeholdersTestMain() 42 | { 43 | auto f = std::bind(&placeholdersTestFunction, _1); 44 | f(1); 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /ndn-cxx/detail/packet-base.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2025 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_DETAIL_PACKET_BASE_HPP 23 | #define NDN_CXX_DETAIL_PACKET_BASE_HPP 24 | 25 | #include "ndn-cxx/detail/tag-host.hpp" 26 | 27 | #include 28 | 29 | namespace ndn { 30 | 31 | /** 32 | * \brief Base class to allow simple management of common packet tags. 33 | */ 34 | class PacketBase : public TagHost 35 | { 36 | public: 37 | /** 38 | * \brief Get the value of the CongestionMark tag. 39 | */ 40 | uint64_t 41 | getCongestionMark() const; 42 | 43 | /** 44 | * \brief Set the CongestionMark tag to the specified value. 45 | */ 46 | void 47 | setCongestionMark(uint64_t mark); 48 | }; 49 | 50 | } // namespace ndn 51 | 52 | #endif // NDN_CXX_DETAIL_PACKET_BASE_HPP 53 | -------------------------------------------------------------------------------- /tools/wscript: -------------------------------------------------------------------------------- 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- 2 | 3 | top = '..' 4 | 5 | def build(bld): 6 | # Single object tools: 7 | # tools/foo.cpp is a self-contained tool with a main() function 8 | # and is built as build/bin/foo. These tools cannot be unit-tested. 9 | for tool in bld.path.ant_glob('*.cpp'): 10 | name = tool.change_ext('').path_from(bld.path.get_bld()) 11 | bld.program(name=name, 12 | target=f'{top}/bin/{name}', 13 | source=[tool], 14 | use='ndn-cxx') 15 | 16 | # Sub-directory tools: 17 | # tools/foo/**/*.cpp are compiled and linked into build/bin/foo. 18 | # tools/foo/main.cpp must exist and must contain the main() function. 19 | # All other objects are collected into 'foo-objects' and can be unit-tested. 20 | for subdir in bld.path.ant_glob('*', dir=True, src=False): 21 | name = subdir.path_from(bld.path) 22 | subWscript = subdir.find_node('wscript') 23 | if subWscript: 24 | # if the subdir has a wscript, delegate to it 25 | bld.recurse(name) 26 | continue 27 | 28 | mainFile = subdir.find_node('main.cpp') 29 | if mainFile is None: 30 | # not a C++ tool, skip the subdir 31 | continue 32 | 33 | srcFiles = subdir.ant_glob('**/*.cpp', excl=['main.cpp']) 34 | srcObjects = '' 35 | if srcFiles: 36 | srcObjects = f'{name}-objects' 37 | bld.objects(target=srcObjects, 38 | source=srcFiles, 39 | use='ndn-cxx') 40 | bld.program(name=name, 41 | target=f'{top}/bin/{name}', 42 | source=[mainFile], 43 | use=f'ndn-cxx {srcObjects}') 44 | -------------------------------------------------------------------------------- /tests/unit/ndebug.t.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2024 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/detail/common.hpp" 23 | 24 | #include "tests/boost-test.hpp" 25 | 26 | namespace ndn::tests { 27 | 28 | BOOST_AUTO_TEST_SUITE(TestNdebug) 29 | 30 | BOOST_AUTO_TEST_CASE(Assert) 31 | { 32 | BOOST_TEST(BOOST_IS_DEFINED(BOOST_ASSERT_IS_VOID) == BOOST_IS_DEFINED(NDEBUG)); 33 | 34 | #ifdef NDEBUG 35 | // in release builds, assertion shouldn't execute 36 | BOOST_ASSERT(false); 37 | BOOST_VERIFY(false); 38 | #endif 39 | } 40 | 41 | BOOST_AUTO_TEST_CASE(SideEffect) 42 | { 43 | int a = 1; 44 | BOOST_ASSERT((a = 2) > 0); 45 | #ifdef NDEBUG 46 | BOOST_TEST(a == 1); 47 | #else 48 | BOOST_TEST(a == 2); 49 | #endif 50 | } 51 | 52 | BOOST_AUTO_TEST_SUITE_END() // TestNdebug 53 | 54 | } // namespace ndn::tests 55 | -------------------------------------------------------------------------------- /tests/unit/security/validator-config/common.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_TESTS_UNIT_SECURITY_VALIDATOR_CONFIG_COMMON_HPP 23 | #define NDN_CXX_TESTS_UNIT_SECURITY_VALIDATOR_CONFIG_COMMON_HPP 24 | 25 | #include "ndn-cxx/security/validator-config/common.hpp" 26 | 27 | #include 28 | 29 | namespace ndn::tests { 30 | 31 | using ndn::security::validator_config::ConfigSection; 32 | 33 | inline ConfigSection 34 | makeSection(const std::string& config) 35 | { 36 | std::istringstream inputStream(config); 37 | ConfigSection section; 38 | boost::property_tree::read_info(inputStream, section); 39 | return section; 40 | } 41 | 42 | } // namespace ndn::tests 43 | 44 | #endif // NDN_CXX_TESTS_UNIT_SECURITY_VALIDATOR_CONFIG_COMMON_HPP 45 | -------------------------------------------------------------------------------- /tests/unit/test-home-env-saver.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_TESTS_UNIT_TEST_HOME_ENV_SAVER_HPP 23 | #define NDN_CXX_TESTS_UNIT_TEST_HOME_ENV_SAVER_HPP 24 | 25 | #include 26 | #include 27 | 28 | namespace ndn::tests { 29 | 30 | class TestHomeEnvSaver 31 | { 32 | public: 33 | TestHomeEnvSaver() 34 | { 35 | if (std::getenv("TEST_HOME") != nullptr) 36 | m_HOME = std::getenv("TEST_HOME"); 37 | } 38 | 39 | virtual 40 | ~TestHomeEnvSaver() 41 | { 42 | if (!m_HOME.empty()) 43 | setenv("TEST_HOME", m_HOME.data(), 1); 44 | else 45 | unsetenv("TEST_HOME"); 46 | } 47 | 48 | private: 49 | std::string m_HOME; 50 | }; 51 | 52 | } // namespace ndn::tests 53 | 54 | #endif // NDN_CXX_TESTS_UNIT_TEST_HOME_ENV_SAVER_HPP 55 | -------------------------------------------------------------------------------- /ndn-cxx/security/certificate-fetcher-offline.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_SECURITY_CERTIFICATE_FETCHER_OFFLINE_HPP 23 | #define NDN_CXX_SECURITY_CERTIFICATE_FETCHER_OFFLINE_HPP 24 | 25 | #include "ndn-cxx/security/certificate-fetcher.hpp" 26 | 27 | namespace ndn::security { 28 | 29 | /** 30 | * @brief Certificate fetcher realization that does not fetch keys (always offline) 31 | */ 32 | class CertificateFetcherOffline : public CertificateFetcher 33 | { 34 | protected: 35 | void 36 | doFetch(const shared_ptr& certRequest, const shared_ptr& state, 37 | const ValidationContinuation& continueValidation) override; 38 | }; 39 | 40 | } // namespace ndn::security 41 | 42 | #endif // NDN_CXX_SECURITY_CERTIFICATE_FETCHER_OFFLINE_HPP 43 | -------------------------------------------------------------------------------- /docs/release-notes/release-notes-0.3.1.rst: -------------------------------------------------------------------------------- 1 | ndn-cxx version 0.3.1 2 | --------------------- 3 | 4 | Release date: March 3, 2015 5 | 6 | Changes since version 0.3.0: 7 | 8 | New features 9 | ^^^^^^^^^^^^ 10 | 11 | - **Management** 12 | 13 | - Add isConnected() in :ndn-cxx:`signal::Connection` and :ndn-cxx:`signal::ScopedConnection` 14 | (:issue:`2308`) 15 | 16 | - Extend :ndn-cxx:`DummyClientFace` to process ``LocalControlHeader`` (:issue:`2510`) 17 | 18 | - Add CachingPolicy to ``LocalControlHeader`` (:issue:`2183`) 19 | 20 | Updates and bug fixes 21 | ^^^^^^^^^^^^^^^^^^^^^ 22 | 23 | - **Wire encoding** 24 | 25 | - Refactoring of :ndn-cxx:`EncodingImpl` class template (``EncodingBuffer`` and 26 | ``EncodingEstimator``) (:issue:`2494`, :issue:`2490`) 27 | 28 | - Change :ndn-cxx:`Block::fromBuffer` return type (:issue:`2553`) 29 | 30 | - **Miscellaneous tools** 31 | 32 | - Mark ``Digest::operator==`` as unsuitable in a security sensitive context 33 | (:issue:`2395`) 34 | 35 | - Restrict destruction of Signal from handler (:issue:`2313`) 36 | 37 | - **Documentation** 38 | 39 | - Correct function names in security library tutorial (:issue:`2474`) 40 | 41 | - Remind users to reinstall ports after OSX upgrade (:issue:`2284`) 42 | 43 | - **Tests** 44 | 45 | - Fix global buffer overflow in ``ImplicitSha256Digest`` test case (:issue:`2307`) 46 | 47 | - Change naming conventions for unit test files and test suite names (:issue:`2497`) 48 | 49 | - **Build** 50 | 51 | - Explicitly define ``_GLIBCXX_USE_NANOSLEEP``, necessary for gcc < 4.8 in some environments 52 | (:issue:`2499`) 53 | 54 | Removed 55 | ^^^^^^^ 56 | 57 | - Delete deprecated ``Block(std::istream&)`` constructor (:issue:`2241`) 58 | 59 | - Delete deprecated ``ndn::ptr_lib``, ``ndn::func_lib`` (:issue:`2110`) 60 | 61 | - Delete deprecated ``MetaInfo::TYPE_*`` (:issue:`2170`) 62 | -------------------------------------------------------------------------------- /ndn-cxx/security/transform/stream-sink.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/security/transform/stream-sink.hpp" 23 | 24 | #include 25 | 26 | namespace ndn::security::transform { 27 | 28 | StreamSink::StreamSink(std::ostream& os) 29 | : m_os(os) 30 | { 31 | } 32 | 33 | size_t 34 | StreamSink::doWrite(span buf) 35 | { 36 | m_os.write(reinterpret_cast(buf.data()), buf.size()); 37 | 38 | if (m_os.bad()) 39 | NDN_THROW(Error(getIndex(), "Fail to write data into output stream")); 40 | 41 | return buf.size(); 42 | } 43 | 44 | void 45 | StreamSink::doEnd() 46 | { 47 | m_os.flush(); 48 | } 49 | 50 | unique_ptr 51 | streamSink(std::ostream& os) 52 | { 53 | return make_unique(os); 54 | } 55 | 56 | } // namespace ndn::security::transform 57 | -------------------------------------------------------------------------------- /.waf-tools/osx-frameworks.py: -------------------------------------------------------------------------------- 1 | from waflib import Logs, Utils, TaskGen 2 | from waflib.Configure import conf 3 | 4 | @conf 5 | def check_osx_framework_cxx(conf, fw_name, **kw): 6 | conf.check_cxx(framework_name=fw_name, 7 | uselib_store='OSX_' + fw_name.upper(), 8 | fragment='#include <{0}/{0}.h>\nint main() {{}}'.format(fw_name), 9 | **kw) 10 | 11 | @conf 12 | def check_osx_framework_mm(conf, fw_name, **kw): 13 | conf.check_cxx(framework_name=fw_name, 14 | uselib_store='OSX_' + fw_name.upper(), 15 | fragment='#import <{0}/{0}.h>\nint main() {{}}'.format(fw_name), 16 | compile_filename='test.mm', 17 | **kw) 18 | 19 | @conf 20 | def check_osx_frameworks(conf, *k, **kw): 21 | if Utils.unversioned_sys_platform() == 'darwin': 22 | try: 23 | conf.check_osx_framework_cxx('CoreFoundation', mandatory=True) 24 | conf.check_osx_framework_cxx('Security', use='OSX_COREFOUNDATION', mandatory=True) 25 | conf.check_osx_framework_cxx('SystemConfiguration', use='OSX_COREFOUNDATION', mandatory=True) 26 | 27 | conf.check_osx_framework_mm('Foundation', mandatory=True) 28 | conf.check_osx_framework_mm('CoreWLAN', use='OSX_FOUNDATION', mandatory=True) 29 | 30 | conf.define('HAVE_OSX_FRAMEWORKS', 1) 31 | conf.env['HAVE_OSX_FRAMEWORKS'] = True 32 | except: 33 | Logs.warn('Building on macOS, but one or more required frameworks are not functional.') 34 | Logs.warn('Note that the frameworks are known to work only with the Apple clang compiler.') 35 | 36 | @TaskGen.extension('.mm') 37 | def m_hook(self, node): 38 | '''Alias .mm files to be compiled the same as .cpp files, clang will do the right thing.''' 39 | return self.create_compiled_task('cxx', node) 40 | -------------------------------------------------------------------------------- /.jenkins.d/00-deps.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | APT_PKGS=( 5 | dpkg-dev 6 | g++ 7 | libboost-chrono-dev 8 | libboost-date-time-dev 9 | libboost-dev 10 | libboost-log-dev 11 | libboost-program-options-dev 12 | libboost-stacktrace-dev 13 | libboost-test-dev 14 | libboost-thread-dev 15 | libsqlite3-dev 16 | libssl-dev 17 | pkgconf 18 | python3 19 | ) 20 | DNF_PKGS=( 21 | boost-devel 22 | gcc-c++ 23 | libasan 24 | lld 25 | openssl-devel 26 | pkgconf 27 | python3 28 | sqlite-devel 29 | ) 30 | FORMULAE=(boost openssl pkgconf) 31 | case $JOB_NAME in 32 | *code-coverage) 33 | APT_PKGS+=(lcov libjson-xs-perl) 34 | ;; 35 | *Docs) 36 | APT_PKGS+=(doxygen graphviz) 37 | FORMULAE+=(doxygen graphviz) 38 | ;; 39 | esac 40 | 41 | install_uv() { 42 | if [[ -z $GITHUB_ACTIONS && $ID_LIKE == *debian* ]]; then 43 | sudo apt-get install -qy --no-install-recommends pipx 44 | pipx upgrade uv || pipx install uv 45 | fi 46 | } 47 | 48 | set -x 49 | 50 | if [[ $ID == macos ]]; then 51 | export HOMEBREW_COLOR=1 52 | export HOMEBREW_NO_ENV_HINTS=1 53 | if [[ -n $GITHUB_ACTIONS ]]; then 54 | export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 55 | fi 56 | brew update 57 | brew install --formula "${FORMULAE[@]}" 58 | elif [[ $ID_LIKE == *debian* ]]; then 59 | sudo apt-get update -qq 60 | sudo apt-get install -qy --no-install-recommends "${APT_PKGS[@]}" 61 | elif [[ $ID_LIKE == *fedora* ]]; then 62 | sudo dnf install -y "${DNF_PKGS[@]}" 63 | fi 64 | 65 | case $JOB_NAME in 66 | *code-coverage) 67 | install_uv 68 | ;; 69 | *Docs) 70 | install_uv 71 | export FORCE_COLOR=1 72 | export UV_NO_MANAGED_PYTHON=1 73 | uv tool install sphinx --upgrade --with-requirements docs/requirements.txt 74 | ;; 75 | esac 76 | -------------------------------------------------------------------------------- /ndn-cxx/security/tpm/key-handle.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/security/tpm/key-handle.hpp" 23 | 24 | namespace ndn::security::tpm { 25 | 26 | KeyHandle::~KeyHandle() = default; 27 | 28 | ConstBufferPtr 29 | KeyHandle::sign(DigestAlgorithm digestAlgorithm, const InputBuffers& bufs) const 30 | { 31 | return doSign(digestAlgorithm, bufs); 32 | } 33 | 34 | bool 35 | KeyHandle::verify(DigestAlgorithm digestAlgorithm, const InputBuffers& bufs, 36 | span sig) const 37 | { 38 | return doVerify(digestAlgorithm, bufs, sig); 39 | } 40 | 41 | ConstBufferPtr 42 | KeyHandle::decrypt(span cipherText) const 43 | { 44 | return doDecrypt(cipherText); 45 | } 46 | 47 | ConstBufferPtr 48 | KeyHandle::derivePublicKey() const 49 | { 50 | return doDerivePublicKey(); 51 | } 52 | 53 | } // namespace ndn::security::tpm 54 | -------------------------------------------------------------------------------- /ndn-cxx/impl/lp-field-tag.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2021 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_IMPL_LP_FIELD_TAG_HPP 23 | #define NDN_CXX_IMPL_LP_FIELD_TAG_HPP 24 | 25 | #include "ndn-cxx/lp/packet.hpp" 26 | #include "ndn-cxx/lp/tags.hpp" 27 | 28 | namespace ndn { 29 | 30 | template 31 | void 32 | addFieldFromTag(lp::Packet& lpPacket, const Packet& packet) 33 | { 34 | shared_ptr tag = static_cast(packet).getTag(); 35 | if (tag != nullptr) { 36 | lpPacket.add(*tag); 37 | } 38 | } 39 | 40 | template 41 | void 42 | addTagFromField(Packet& packet, const lp::Packet& lpPacket) 43 | { 44 | if (lpPacket.has()) { 45 | packet.setTag(make_shared(lpPacket.get())); 46 | } 47 | } 48 | 49 | } // namespace ndn 50 | 51 | #endif // NDN_CXX_IMPL_LP_FIELD_TAG_HPP 52 | -------------------------------------------------------------------------------- /docs/manpages/ndnsec.rst: -------------------------------------------------------------------------------- 1 | ndnsec 2 | ====== 3 | 4 | Synopsis 5 | -------- 6 | 7 | **ndnsec** *command* [*argument*]... 8 | 9 | **ndnsec-**\ *command* [*argument*]... 10 | 11 | Description 12 | ----------- 13 | 14 | :program:`ndnsec` is a command-line toolkit to perform various NDN security 15 | management operations. 16 | 17 | The NDN security data are stored in two places: **Public Information Base** 18 | (PIB) and **Trusted Platform Module** (TPM). The :program:`ndnsec` toolkit 19 | provides a command-line interface for managing and using the NDN security data. 20 | 21 | Commands 22 | -------- 23 | 24 | The following commands are understood: 25 | 26 | :doc:`list ` 27 | List all known identities/keys/certificates. 28 | 29 | :doc:`get-default ` 30 | Show the default identity/key/certificate. 31 | 32 | :doc:`set-default ` 33 | Change the default identity/key/certificate. 34 | 35 | :doc:`delete ` 36 | Delete an identity/key/certificate. 37 | 38 | :doc:`key-gen ` 39 | Generate a key for an identity. 40 | 41 | :doc:`sign-req ` 42 | Generate a certificate signing request. 43 | 44 | :doc:`cert-gen ` 45 | Create a certificate for an identity. 46 | 47 | :doc:`cert-dump ` 48 | Export a certificate. 49 | 50 | :doc:`cert-install ` 51 | Import a certificate from a file. 52 | 53 | :doc:`export ` 54 | Export an identity as a SafeBag. 55 | 56 | :doc:`import ` 57 | Import an identity from a SafeBag. 58 | 59 | Exit Status 60 | ----------- 61 | 62 | Generally, :program:`ndnsec` commands exit with status 0 if the requested 63 | operation was completed successfully. On error, a nonzero status is returned. 64 | Individual commands may use certain nonzero exit codes to indicate that a 65 | more specific error has occurred. Please consult the respective man pages 66 | for more information. 67 | -------------------------------------------------------------------------------- /ndn-cxx/security/transform/buffer-source.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/security/transform/buffer-source.hpp" 23 | 24 | namespace ndn::security::transform { 25 | 26 | BufferSource::BufferSource(span buffer) 27 | : m_bufs({buffer}) 28 | { 29 | } 30 | 31 | BufferSource::BufferSource(std::string_view string) 32 | : m_bufs({{reinterpret_cast(string.data()), string.size()}}) 33 | { 34 | } 35 | 36 | BufferSource::BufferSource(InputBuffers buffers) 37 | : m_bufs(std::move(buffers)) 38 | { 39 | } 40 | 41 | void 42 | BufferSource::doPump() 43 | { 44 | BOOST_ASSERT(m_next != nullptr); 45 | 46 | for (auto buffer : m_bufs) { 47 | while (!buffer.empty()) { 48 | size_t nBytesWritten = m_next->write(buffer); 49 | buffer = buffer.subspan(nBytesWritten); 50 | } 51 | } 52 | 53 | m_next->end(); 54 | } 55 | 56 | } // namespace ndn::security::transform 57 | -------------------------------------------------------------------------------- /ndn-cxx/util/regex/regex-backref-manager.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2021 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | * 21 | * @author Yingdi Yu 22 | */ 23 | 24 | #ifndef NDN_CXX_UTIL_REGEX_REGEX_BACKREF_MANAGER_HPP 25 | #define NDN_CXX_UTIL_REGEX_REGEX_BACKREF_MANAGER_HPP 26 | 27 | #include "ndn-cxx/detail/common.hpp" 28 | 29 | #include 30 | 31 | namespace ndn { 32 | 33 | class RegexMatcher; 34 | 35 | class RegexBackrefManager 36 | { 37 | public: 38 | size_t 39 | pushRef(const shared_ptr& matcher); 40 | 41 | void 42 | popRef() 43 | { 44 | m_backrefs.pop_back(); 45 | } 46 | 47 | size_t 48 | size() const 49 | { 50 | return m_backrefs.size(); 51 | } 52 | 53 | shared_ptr 54 | getBackref(size_t i) const; 55 | 56 | private: 57 | std::vector> m_backrefs; 58 | }; 59 | 60 | } // namespace ndn 61 | 62 | #endif // NDN_CXX_UTIL_REGEX_REGEX_BACKREF_MANAGER_HPP 63 | -------------------------------------------------------------------------------- /tests/unit/lp/fields.t.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/lp/fields.hpp" 23 | 24 | namespace ndn::tests { 25 | 26 | using namespace ndn::lp; 27 | 28 | BOOST_CONCEPT_ASSERT((Field)); 29 | BOOST_CONCEPT_ASSERT((Field)); 30 | BOOST_CONCEPT_ASSERT((Field)); 31 | BOOST_CONCEPT_ASSERT((Field)); 32 | BOOST_CONCEPT_ASSERT((Field)); 33 | BOOST_CONCEPT_ASSERT((Field)); 34 | BOOST_CONCEPT_ASSERT((Field)); 35 | BOOST_CONCEPT_ASSERT((Field)); 36 | BOOST_CONCEPT_ASSERT((Field)); 37 | BOOST_CONCEPT_ASSERT((Field)); 38 | BOOST_CONCEPT_ASSERT((Field)); 39 | BOOST_CONCEPT_ASSERT((Field)); 40 | BOOST_CONCEPT_ASSERT((Field)); 41 | BOOST_CONCEPT_ASSERT((Field)); 42 | 43 | } // namespace ndn::tests 44 | -------------------------------------------------------------------------------- /ndn-cxx/encoding/buffer-stream.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2024 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/encoding/buffer-stream.hpp" 23 | 24 | namespace ndn { 25 | namespace detail { 26 | 27 | BufferSink::BufferSink(Buffer& container) 28 | : m_container(container) 29 | { 30 | } 31 | 32 | std::streamsize 33 | BufferSink::write(const char_type* s, std::streamsize n) 34 | { 35 | m_container.insert(m_container.end(), s, s + n); 36 | return n; 37 | } 38 | 39 | } // namespace detail 40 | 41 | OBufferStream::OBufferStream() 42 | : m_buffer(std::make_shared()) 43 | { 44 | open(detail::BufferSink{*m_buffer}); 45 | } 46 | 47 | OBufferStream::~OBufferStream() noexcept 48 | { 49 | try { 50 | close(); 51 | } 52 | catch (...) { 53 | // ignore 54 | } 55 | } 56 | 57 | std::shared_ptr 58 | OBufferStream::buf() 59 | { 60 | if (is_open()) { 61 | flush(); 62 | } 63 | return m_buffer; 64 | } 65 | 66 | } // namespace ndn 67 | -------------------------------------------------------------------------------- /tests/unit/security/tpm/back-end-wrapper-mem.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_TESTS_UNIT_SECURITY_TPM_BACK_END_WRAPPER_MEM_HPP 23 | #define NDN_CXX_TESTS_UNIT_SECURITY_TPM_BACK_END_WRAPPER_MEM_HPP 24 | 25 | #include "ndn-cxx/security/tpm/impl/back-end-mem.hpp" 26 | 27 | namespace ndn::tests { 28 | 29 | /** 30 | * @brief A wrapper of tpm::BackEndMem for unit test template. 31 | */ 32 | class BackEndWrapperMem 33 | { 34 | public: 35 | BackEndWrapperMem() 36 | : m_impl(make_unique()) 37 | { 38 | } 39 | 40 | security::tpm::BackEnd& 41 | getTpm() 42 | { 43 | return *m_impl; 44 | } 45 | 46 | std::string 47 | getScheme() const 48 | { 49 | return "tpm-memory"; 50 | } 51 | 52 | private: 53 | const unique_ptr m_impl; 54 | }; 55 | 56 | } // namespace ndn::tests 57 | 58 | #endif // NDN_CXX_TESTS_UNIT_SECURITY_TPM_BACK_END_WRAPPER_MEM_HPP 59 | -------------------------------------------------------------------------------- /ndn-cxx/util/regex/regex-pattern-list-matcher.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2021 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | * 21 | * @author Yingdi Yu 22 | */ 23 | 24 | #ifndef NDN_CXX_UTIL_REGEX_REGEX_PATTERN_LIST_MATCHER_HPP 25 | #define NDN_CXX_UTIL_REGEX_REGEX_PATTERN_LIST_MATCHER_HPP 26 | 27 | #include "ndn-cxx/util/regex/regex-matcher.hpp" 28 | 29 | namespace ndn { 30 | 31 | class RegexPatternListMatcher : public RegexMatcher 32 | { 33 | public: 34 | RegexPatternListMatcher(const std::string& expr, 35 | shared_ptr backrefManager); 36 | 37 | private: 38 | void 39 | compile(); 40 | 41 | bool 42 | extractPattern(size_t index, size_t* next); 43 | 44 | size_t 45 | extractSubPattern(const char left, const char right, size_t index); 46 | 47 | size_t 48 | extractRepetition(size_t index); 49 | }; 50 | 51 | } // namespace ndn 52 | 53 | #endif // NDN_CXX_UTIL_REGEX_REGEX_PATTERN_LIST_MATCHER_HPP 54 | -------------------------------------------------------------------------------- /docs/manpages/ndnsec-export.rst: -------------------------------------------------------------------------------- 1 | ndnsec-export 2 | ============= 3 | 4 | Synopsis 5 | -------- 6 | 7 | **ndnsec export** [**-h**] [**-o** *file*] [**-P** *passphrase*] 8 | [**-i**\|\ **-k**\|\ **-c**] *name* 9 | 10 | Description 11 | ----------- 12 | 13 | Export a certificate from the local **Public Information Base (PIB)** and its private key to 14 | a file in **SafeBag** format. 15 | The command will interactively ask for a passphrase to be used for encrypting the private key. 16 | 17 | The resulting file can be later imported using :program:`ndnsec-import`. 18 | 19 | Options 20 | ------- 21 | 22 | .. option:: -i, --identity 23 | 24 | Interpret *name* as an identity name. 25 | The default certificate of the identity will be exported. 26 | This is the default unless :option:`-k` or :option:`-c` is specified. 27 | 28 | .. option:: -k, --key 29 | 30 | Interpret *name* as a key name. 31 | The default certificate of the key will be exported. 32 | 33 | .. option:: -c, --cert 34 | 35 | Interpret *name* as a certificate name. 36 | 37 | .. option:: -o , --output 38 | 39 | Write to the specified output file instead of the standard output. 40 | 41 | .. option:: -P , --password 42 | 43 | Passphrase to use for encryption. If empty or not specified, the user is 44 | interactively asked to type the passphrase on the terminal. Note that 45 | specifying the passphrase via this option is insecure, as it can potentially 46 | end up in the shell's history, be visible in :command:`ps` output, and so on. 47 | 48 | Examples 49 | -------- 50 | 51 | Export an identity's default certificate and private key to a file:: 52 | 53 | $ ndnsec export -o alice.ndnkey /ndn/test/alice 54 | 55 | Export a specific certificate and its private key to the standard output:: 56 | 57 | $ ndnsec export -c /ndn/edu/ucla/alice/KEY/1%5D%A7g%90%B2%CF%AA/self/%FD%00%00%01r-%D3%DC%2A 58 | 59 | See Also 60 | -------- 61 | 62 | :manpage:`ndnsec-cert-dump(1)`, 63 | :manpage:`ndnsec-import(1)` 64 | -------------------------------------------------------------------------------- /tests/unit/clock-fixture.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2024 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "tests/unit/clock-fixture.hpp" 23 | 24 | namespace ndn::tests { 25 | 26 | ClockFixture::ClockFixture() 27 | : m_steadyClock(std::make_shared()) 28 | , m_systemClock(std::make_shared()) 29 | { 30 | time::setCustomClocks(m_steadyClock, m_systemClock); 31 | } 32 | 33 | ClockFixture::~ClockFixture() 34 | { 35 | time::setCustomClocks(nullptr, nullptr); 36 | } 37 | 38 | void 39 | ClockFixture::advanceClocks(time::nanoseconds tick, time::nanoseconds total) 40 | { 41 | BOOST_ASSERT(tick > time::nanoseconds::zero()); 42 | BOOST_ASSERT(total >= time::nanoseconds::zero()); 43 | 44 | while (total > time::nanoseconds::zero()) { 45 | auto t = std::min(tick, total); 46 | m_steadyClock->advance(t); 47 | m_systemClock->advance(t); 48 | total -= t; 49 | 50 | afterTick(); 51 | } 52 | } 53 | 54 | } // namespace ndn::tests 55 | -------------------------------------------------------------------------------- /tools/ndnsec/ndnsec.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2025 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_TOOLS_NDNSEC_NDNSEC_HPP 23 | #define NDN_CXX_TOOLS_NDNSEC_NDNSEC_HPP 24 | 25 | namespace ndn::ndnsec { 26 | 27 | // TODO: convert to tool registry (maybe) 28 | 29 | int 30 | ndnsec_list(int argc, char** argv); 31 | 32 | int 33 | ndnsec_get_default(int argc, char** argv); 34 | 35 | int 36 | ndnsec_set_default(int argc, char** argv); 37 | 38 | int 39 | ndnsec_key_gen(int argc, char** argv); 40 | 41 | int 42 | ndnsec_sign_req(int argc, char** argv); 43 | 44 | int 45 | ndnsec_cert_gen(int argc, char** argv); 46 | 47 | int 48 | ndnsec_cert_dump(int argc, char** argv); 49 | 50 | int 51 | ndnsec_cert_install(int argc, char** argv); 52 | 53 | int 54 | ndnsec_delete(int argc, char** argv); 55 | 56 | int 57 | ndnsec_export(int argc, char** argv); 58 | 59 | int 60 | ndnsec_import(int argc, char** argv); 61 | 62 | } // namespace ndn::ndnsec 63 | 64 | #endif // NDN_CXX_TOOLS_NDNSEC_NDNSEC_HPP 65 | -------------------------------------------------------------------------------- /ndn-cxx/security/validation-policy-simple-hierarchy.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_SECURITY_VALIDATION_POLICY_SIMPLE_HIERARCHY_HPP 23 | #define NDN_CXX_SECURITY_VALIDATION_POLICY_SIMPLE_HIERARCHY_HPP 24 | 25 | #include "ndn-cxx/security/validation-policy.hpp" 26 | 27 | namespace ndn::security { 28 | 29 | /** 30 | * @brief Validation policy for a simple hierarchical trust model 31 | */ 32 | class ValidationPolicySimpleHierarchy : public ValidationPolicy 33 | { 34 | public: 35 | void 36 | checkPolicy(const Data& data, const shared_ptr& state, 37 | const ValidationContinuation& continueValidation) override; 38 | 39 | void 40 | checkPolicy(const Interest& interest, const shared_ptr& state, 41 | const ValidationContinuation& continueValidation) override; 42 | }; 43 | 44 | } // namespace ndn::security 45 | 46 | #endif // NDN_CXX_SECURITY_VALIDATION_POLICY_SIMPLE_HIERARCHY_HPP 47 | -------------------------------------------------------------------------------- /ndn-cxx/util/signal/scoped-connection.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/util/signal/scoped-connection.hpp" 23 | 24 | namespace ndn::signal { 25 | 26 | ScopedConnection::ScopedConnection(Connection connection) noexcept 27 | : m_connection(std::move(connection)) 28 | { 29 | } 30 | 31 | ScopedConnection& 32 | ScopedConnection::operator=(Connection connection) 33 | { 34 | if (m_connection != connection) { 35 | disconnect(); 36 | m_connection = std::move(connection); 37 | } 38 | return *this; 39 | } 40 | 41 | ScopedConnection::~ScopedConnection() 42 | { 43 | disconnect(); 44 | } 45 | 46 | void 47 | ScopedConnection::disconnect() 48 | { 49 | m_connection.disconnect(); 50 | } 51 | 52 | bool 53 | ScopedConnection::isConnected() const noexcept 54 | { 55 | return m_connection.isConnected(); 56 | } 57 | 58 | void 59 | ScopedConnection::release() noexcept 60 | { 61 | m_connection = {}; 62 | } 63 | 64 | } // namespace ndn::signal 65 | -------------------------------------------------------------------------------- /ndn-cxx/security/transform/strip-space.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/security/transform/strip-space.hpp" 23 | 24 | namespace ndn::security::transform { 25 | 26 | const char* const StripSpace::DEFAULT_WHITESPACES = " \f\n\r\t\v"; 27 | 28 | StripSpace::StripSpace(const char* whitespaces) 29 | { 30 | for (const char* i = whitespaces; *i != '\0'; ++i) { 31 | m_isWhitespace.set(*i); 32 | } 33 | } 34 | 35 | size_t 36 | StripSpace::convert(span data) 37 | { 38 | auto buffer = make_unique(); 39 | buffer->reserve(data.size()); 40 | 41 | for (auto ch : data) { 42 | if (!m_isWhitespace[ch]) { 43 | buffer->push_back(ch); 44 | } 45 | } 46 | 47 | setOutputBuffer(std::move(buffer)); 48 | return data.size(); 49 | } 50 | 51 | unique_ptr 52 | stripSpace(const char* whitespaces) 53 | { 54 | return make_unique(whitespaces); 55 | } 56 | 57 | } // namespace ndn::security::transform 58 | -------------------------------------------------------------------------------- /ndn-cxx/util/impl/steady-timer.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_UTIL_IMPL_STEADY_TIMER_HPP 23 | #define NDN_CXX_UTIL_IMPL_STEADY_TIMER_HPP 24 | 25 | #include "ndn-cxx/util/time.hpp" 26 | 27 | #include 28 | #include 29 | 30 | namespace boost::asio { 31 | 32 | template<> 33 | struct wait_traits 34 | { 35 | static ndn::time::steady_clock::duration 36 | to_wait_duration(const ndn::time::steady_clock::duration& d) 37 | { 38 | return ndn::time::steady_clock::to_wait_duration(d); 39 | } 40 | }; 41 | 42 | } // namespace boost::asio 43 | 44 | namespace ndn::detail { 45 | 46 | class SteadyTimer : public boost::asio::basic_waitable_timer 47 | { 48 | public: 49 | using boost::asio::basic_waitable_timer::basic_waitable_timer; 50 | }; 51 | 52 | } // namespace ndn::detail 53 | 54 | #endif // NDN_CXX_UTIL_IMPL_STEADY_TIMER_HPP 55 | -------------------------------------------------------------------------------- /ndn-cxx/net/impl/linux-if-constants.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | * 21 | * @author Davide Pesavento 22 | */ 23 | 24 | #ifdef __linux__ 25 | 26 | #include "ndn-cxx/net/impl/linux-if-constants.hpp" 27 | 28 | #include 29 | #include 30 | 31 | namespace ndn::net::linux_if { 32 | 33 | const uint32_t FLAG_LOWER_UP = IFF_LOWER_UP; 34 | const uint32_t FLAG_DORMANT = IFF_DORMANT; 35 | const uint32_t FLAG_ECHO = IFF_ECHO; 36 | 37 | const uint8_t OPER_STATE_UNKNOWN = IF_OPER_UNKNOWN; 38 | const uint8_t OPER_STATE_NOTPRESENT = IF_OPER_NOTPRESENT; 39 | const uint8_t OPER_STATE_DOWN = IF_OPER_DOWN; 40 | const uint8_t OPER_STATE_LOWERLAYERDOWN = IF_OPER_LOWERLAYERDOWN; 41 | const uint8_t OPER_STATE_TESTING = IF_OPER_TESTING; 42 | const uint8_t OPER_STATE_DORMANT = IF_OPER_DORMANT; 43 | const uint8_t OPER_STATE_UP = IF_OPER_UP; 44 | 45 | } // namespace ndn::net::linux_if 46 | 47 | #endif // __linux__ 48 | -------------------------------------------------------------------------------- /docs/release-notes/release-notes-0.6.2.rst: -------------------------------------------------------------------------------- 1 | ndn-cxx version 0.6.2 2 | --------------------- 3 | 4 | Release date: May 4, 2018 5 | 6 | New features 7 | ^^^^^^^^^^^^ 8 | 9 | - Initial support for `NDN packet format version 0.3 10 | `__ (:issue:`4527`) 11 | 12 | * Recognize typed name components, allow typed name component in ``FinalBlockId`` 13 | (:issue:`4526`) 14 | 15 | * Recognize Interest in Packet Format v0.3 (:issue:`4527`) 16 | 17 | In this release, ``Interest::wireDecode`` accepts both v0.2 and v0.3 formats, but 18 | ``Interest::wireEncode`` only encodes into v0.2 format. A future release of the 19 | library will switch the encoding to v0.3 format. 20 | 21 | * Recognize Data in Packet Format v0.3 (:issue:`4568`) 22 | 23 | In this release, ``Data::wireDecode`` accepts both v0.2 and v0.3 formats, but 24 | ``Data::wireEncode`` only encodes into v0.2 format. A future release of the library 25 | will switch the encoding to v0.3 format. 26 | 27 | - Library support for cs/erase command of NFD Management (:issue:`4318`) 28 | 29 | - A convenience function to print out ``Block`` structures (:issue:`2225`) 30 | 31 | Improvements and bug fixes 32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | 34 | - Change encoding of NDNLPv2 sequence number from nonNegativeInteger to fixed-width 35 | integer (8 bytes in network order) (:issue:`4403`) 36 | 37 | - Fix compilation with Boost 1.67 (:issue:`4584`) 38 | 39 | - Upgrade build environment to latest version of ``waf`` and other improvements 40 | 41 | - Logging system improvements (:issue:`4552`) 42 | 43 | Deprecated 44 | ^^^^^^^^^^ 45 | 46 | - Selectors (:issue:`4527`) 47 | 48 | NDN Packet Format v0.3 replaces Selectors with ``CanBePrefix`` and ``MustBeFresh`` elements. 49 | This commit deprecates getter/setter for Selectors in Interest class. Getter/setter for 50 | CanBePrefix and MustBeFresh are mapped to the closest v0.2 semantics and encoded as 51 | selectors. 52 | 53 | - ``Data::get/setFinalBlockId()`` in favor of ``Data::get/setFinalBlock()`` 54 | -------------------------------------------------------------------------------- /docs/manpages/ndnsec-sign-req.rst: -------------------------------------------------------------------------------- 1 | ndnsec-sign-req 2 | =============== 3 | 4 | Synopsis 5 | -------- 6 | 7 | **ndnsec sign-req** [**-h**] [**-k**] *name* 8 | 9 | Description 10 | ----------- 11 | 12 | Generate a signing request for a key and print it to the standard output in Base64 13 | encoding. Note that a signing request is essentially just a self-signed certificate. 14 | 15 | By default, *name* is interpreted as an identity name, and the signing request is 16 | generated for that identity's default key. 17 | 18 | Options 19 | ------- 20 | 21 | .. option:: -k, --key 22 | 23 | Interpret *name* as a key name, instead of an identity name. 24 | 25 | Examples 26 | -------- 27 | 28 | Create a signing request for an identity's default key:: 29 | 30 | $ ndnsec sign-req /ndn/test/david 31 | Bv0BUAc5CANuZG4IBHRlc3QIBWRhdmlkCANLRVkICLe4LjaLILlwCAxjZXJ0LXJl 32 | cXVlc3Q2CAAAAZBBKKWTFAkYAQIZBAA27oAVWzBZMBMGByqGSM49AgEGCCqGSM49 33 | AwEHA0IABJxGmknWpDMKlPKO+xffd9b39bGilN2gTB8xkQ04L3rRgHuD8syFbHXT 34 | Czht6djEg7YQuKtbQ1npa7lVS7N/KN8WYhsBAxwzBzEIA25kbggEdGVzdAgFZGF2 35 | aWQIA0tFWQgIt7guNosguXAIBHNlbGY2CAAAAZBBJUwR/QD9Jv0A/g8yMDI0MDYy 36 | MlQxODE1MDH9AP8PMjAyNDA3MDJUMTgxNTAxF0cwRQIgGewzD5ZXsu49hnB/pJ+V 37 | RR8JJZf9v29T/cqoEpYbf7sCIQCMySY9yqs2NybIQMVJQsJceEbOFPSjWIc9bwye 38 | 7Ecuyw== 39 | 40 | Create a signing request for a particular key:: 41 | 42 | $ ndnsec sign-req -k /ndn/test/david/KEY/%BDA%0F%EE%F55%D8%F4 43 | Bv0BUQc5CANuZG4IBHRlc3QIBWRhdmlkCANLRVkICL1BD+71Ndj0CAxjZXJ0LXJl 44 | cXVlc3Q2CAAAAZBBLUzJFAkYAQIZBAA27oAVWzBZMBMGByqGSM49AgEGCCqGSM49 45 | AwEHA0IABO99nylhohJt0WnKNiVj6G1XNYxEgM7ESNXcpwgWB7gyeNywzG5JMfDs 46 | GBlPZ4C4kshOzzw8uu4qmwexNUROWBgWYhsBAxwzBzEIA25kbggEdGVzdAgFZGF2 47 | aWQIA0tFWQgIvUEP7vU12PQIBHNlbGY2CAAAAZBBLCFq/QD9Jv0A/g8yMDI0MDYy 48 | MlQxODIwMDb9AP8PMjAyNDA3MDJUMTgyMDA2F0gwRgIhANjJjB3OkFY1idr83rgc 49 | jqusnrWe9kFs4Fai/GmteqDlAiEA3z0LYmLG0+k0Q1jLNzrZwKuVk+MUxtChXTUg 50 | NKXukzg= 51 | 52 | See Also 53 | -------- 54 | 55 | :manpage:`ndnsec-cert-gen(1)`, 56 | :manpage:`ndnsec-key-gen(1)` 57 | -------------------------------------------------------------------------------- /ndn-cxx/net/impl/network-monitor-impl-noop.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | * 21 | * @author Davide Pesavento 22 | */ 23 | 24 | #ifndef NDN_CXX_NET_NETWORK_MONITOR_IMPL_NOOP_HPP 25 | #define NDN_CXX_NET_NETWORK_MONITOR_IMPL_NOOP_HPP 26 | 27 | #include "ndn-cxx/net/network-monitor.hpp" 28 | 29 | namespace ndn::net { 30 | 31 | class NetworkMonitorImplNoop final : public NetworkMonitorImpl 32 | { 33 | public: 34 | explicit 35 | NetworkMonitorImplNoop(boost::asio::io_context&) 36 | { 37 | } 38 | 39 | uint32_t 40 | getCapabilities() const final 41 | { 42 | return NetworkMonitor::CAP_NONE; 43 | } 44 | 45 | shared_ptr 46 | getNetworkInterface(const std::string&) const final 47 | { 48 | return {}; 49 | } 50 | 51 | std::vector> 52 | listNetworkInterfaces() const final 53 | { 54 | return {}; 55 | } 56 | }; 57 | 58 | } // namespace ndn::net 59 | 60 | #endif // NDN_CXX_NET_NETWORK_MONITOR_IMPL_NOOP_HPP 61 | -------------------------------------------------------------------------------- /ndn-cxx/mgmt/nfd/route-flags-traits.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_MGMT_NFD_ROUTE_FLAGS_TRAITS_HPP 23 | #define NDN_CXX_MGMT_NFD_ROUTE_FLAGS_TRAITS_HPP 24 | 25 | #include "ndn-cxx/encoding/nfd-constants.hpp" 26 | 27 | namespace ndn::nfd { 28 | 29 | /** 30 | * \ingroup management 31 | * \brief Defines getters for each route inheritance flag. 32 | * 33 | * \tparam T class containing a RouteFlags field and implementing 34 | * a `RouteFlags getFlags() const` member function 35 | */ 36 | template 37 | class RouteFlagsTraits 38 | { 39 | public: 40 | bool 41 | isChildInherit() const 42 | { 43 | return static_cast(this)->getFlags() & ROUTE_FLAG_CHILD_INHERIT; 44 | } 45 | 46 | bool 47 | isRibCapture() const 48 | { 49 | return static_cast(this)->getFlags() & ROUTE_FLAG_CAPTURE; 50 | } 51 | 52 | protected: 53 | RouteFlagsTraits() = default; 54 | }; 55 | 56 | } // namespace ndn::nfd 57 | 58 | #endif // NDN_CXX_MGMT_NFD_ROUTE_FLAGS_TRAITS_HPP 59 | -------------------------------------------------------------------------------- /ndn-cxx/util/regex/regex-repeat-matcher.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2021 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | * 21 | * @author Yingdi Yu 22 | */ 23 | 24 | #ifndef NDN_CXX_UTIL_REGEX_REGEX_REPEAT_MATCHER_HPP 25 | #define NDN_CXX_UTIL_REGEX_REGEX_REPEAT_MATCHER_HPP 26 | 27 | #include "ndn-cxx/util/regex/regex-matcher.hpp" 28 | 29 | namespace ndn { 30 | 31 | class RegexRepeatMatcher : public RegexMatcher 32 | { 33 | public: 34 | RegexRepeatMatcher(const std::string& expr, 35 | shared_ptr backrefManager, 36 | size_t indicator); 37 | 38 | bool 39 | match(const Name& name, size_t offset, size_t len) override; 40 | 41 | private: 42 | void 43 | compile(); 44 | 45 | void 46 | parseRepetition(); 47 | 48 | bool 49 | recursiveMatch(size_t repeat, const Name& name, size_t offset, size_t len); 50 | 51 | private: 52 | size_t m_indicator; 53 | size_t m_repeatMin = 0; 54 | size_t m_repeatMax = 0; 55 | }; 56 | 57 | } // namespace ndn 58 | 59 | #endif // NDN_CXX_UTIL_REGEX_REGEX_REPEAT_MATCHER_HPP 60 | -------------------------------------------------------------------------------- /ndn-cxx/security/transform/stream-sink.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_SECURITY_TRANSFORM_STREAM_SINK_HPP 23 | #define NDN_CXX_SECURITY_TRANSFORM_STREAM_SINK_HPP 24 | 25 | #include "ndn-cxx/security/transform/transform-base.hpp" 26 | 27 | namespace ndn::security::transform { 28 | 29 | /** 30 | * @brief A sink which directs output to an std::ostream. 31 | */ 32 | class StreamSink : public Sink 33 | { 34 | public: 35 | /** 36 | * @brief Create a stream sink which outputs to @p os. 37 | */ 38 | explicit 39 | StreamSink(std::ostream& os); 40 | 41 | private: 42 | /** 43 | * @brief Write data into the stream. 44 | * 45 | * @return Number of bytes that have been written into the stream. 46 | */ 47 | size_t 48 | doWrite(span buf) final; 49 | 50 | void 51 | doEnd() final; 52 | 53 | private: 54 | std::ostream& m_os; 55 | }; 56 | 57 | unique_ptr 58 | streamSink(std::ostream& os); 59 | 60 | } // namespace ndn::security::transform 61 | 62 | #endif // NDN_CXX_SECURITY_TRANSFORM_STREAM_SINK_HPP 63 | -------------------------------------------------------------------------------- /ndn-cxx/security/validation-policy-accept-all.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_SECURITY_VALIDATION_POLICY_ACCEPT_ALL_HPP 23 | #define NDN_CXX_SECURITY_VALIDATION_POLICY_ACCEPT_ALL_HPP 24 | 25 | #include "ndn-cxx/security/validation-policy.hpp" 26 | 27 | namespace ndn::security { 28 | 29 | /** 30 | * @brief A validator policy that accepts any signature of data and interest packets 31 | */ 32 | class ValidationPolicyAcceptAll : public ValidationPolicy 33 | { 34 | public: 35 | void 36 | checkPolicy(const Data& data, const shared_ptr& state, 37 | const ValidationContinuation& continueValidation) final 38 | { 39 | continueValidation(nullptr, state); 40 | } 41 | 42 | void 43 | checkPolicy(const Interest& interest, const shared_ptr& state, 44 | const ValidationContinuation& continueValidation) final 45 | { 46 | continueValidation(nullptr, state); 47 | } 48 | }; 49 | 50 | } // namespace ndn::security 51 | 52 | #endif // NDN_CXX_SECURITY_VALIDATION_POLICY_ACCEPT_ALL_HPP 53 | -------------------------------------------------------------------------------- /ndn-cxx/security/validator-config/name-relation.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_SECURITY_VALIDATOR_CONFIG_NAME_RELATION_HPP 23 | #define NDN_CXX_SECURITY_VALIDATOR_CONFIG_NAME_RELATION_HPP 24 | 25 | #include "ndn-cxx/name.hpp" 26 | #include "ndn-cxx/security/validator-config/common.hpp" 27 | 28 | namespace ndn::security::validator_config { 29 | 30 | enum class NameRelation { 31 | EQUAL, 32 | IS_PREFIX_OF, 33 | IS_STRICT_PREFIX_OF 34 | }; 35 | 36 | std::ostream& 37 | operator<<(std::ostream& os, NameRelation relation); 38 | 39 | /** 40 | * @brief Check whether @p name1 and @p name2 satisfies @p relation. 41 | */ 42 | bool 43 | checkNameRelation(NameRelation relation, const Name& name1, const Name& name2); 44 | 45 | /** 46 | * @brief Convert @p relationString to NameRelation. 47 | * @throw Error if @p relationString cannot be converted 48 | */ 49 | NameRelation 50 | getNameRelationFromString(const std::string& relationString); 51 | 52 | } // namespace ndn::security::validator_config 53 | 54 | #endif // NDN_CXX_SECURITY_VALIDATOR_CONFIG_NAME_RELATION_HPP 55 | -------------------------------------------------------------------------------- /docs/manpages/ndnsec-key-gen.rst: -------------------------------------------------------------------------------- 1 | ndnsec-key-gen 2 | ============== 3 | 4 | Synopsis 5 | -------- 6 | 7 | **ndnsec key-gen** [**-h**] [**-n**] [**-t** *type*] 8 | [**-k** *keyidtype*\|\ **\--keyid** *keyid*] *identity* 9 | 10 | Description 11 | ----------- 12 | 13 | Generate a public/private key pair for the specified *identity* and set the newly generated 14 | public key as the identity's default key. 15 | Unless :option:`-n` is specified, the identity is also set as the user's default identity. 16 | 17 | This command will automatically create a signing request for the generated key. 18 | The signing request will be written to the standard output in Base64 encoding. 19 | 20 | Options 21 | ------- 22 | 23 | .. option:: -n, --not-default 24 | 25 | Do not set the identity as the user's default identity. 26 | 27 | Note that if no other identity/key/certificate exists, then the identity 28 | will become the default regardless of this option. 29 | 30 | .. option:: -t , --type 31 | 32 | Type of key to generate. "r" for RSA, "e" for ECDSA (the default). 33 | 34 | .. option:: -k , --keyid-type 35 | 36 | Type of KeyId for the generated key. "r" for a 64-bit random number (the default 37 | unless :option:`--keyid` is specified), "h" for the SHA-256 of the public key. 38 | 39 | .. option:: --keyid 40 | 41 | User-specified KeyId. Must be a non-empty generic name component. 42 | 43 | Examples 44 | -------- 45 | 46 | Generate a new default key for the identity ``/ndn/test/david``:: 47 | 48 | $ ndnsec key-gen /ndn/test/david 49 | Bv0BNwcxCANuZG4IBHRlc3QIBWRhdmlkCANLRVkICLe4LjaLILlwCARzZWxmNggA 50 | AAGQQSVMERQJGAECGQQANu6AFVswWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASc 51 | RppJ1qQzCpTyjvsX33fW9/WxopTdoEwfMZENOC960YB7g/LMhWx10ws4benYxIO2 52 | ELirW0NZ6Wu5VUuzfyjfFlIbAQMcIwchCANuZG4IBHRlc3QIBWRhdmlkCANLRVkI 53 | CLe4LjaLILlw/QD9Jv0A/g8yMDI0MDYyMlQxODExMjH9AP8PMjA0NDA2MTdUMTgx 54 | MTIxF0YwRAIgLJWFpcWrmaOuXW5W+im9al+7TinaEqodve+vrJ2VE5sCIHyrWB+5 55 | g2bl11aVNycEnMvG8KRSJoHRvNkx7+6RV33s 56 | 57 | See Also 58 | -------- 59 | 60 | :manpage:`ndnsec-cert-gen(1)`, 61 | :manpage:`ndnsec-sign-req(1)` 62 | -------------------------------------------------------------------------------- /docs/release-notes/release-notes-0.6.1.rst: -------------------------------------------------------------------------------- 1 | ndn-cxx version 0.6.1 2 | --------------------- 3 | 4 | Release date: February 19, 2018 5 | 6 | New features 7 | ^^^^^^^^^^^^ 8 | 9 | - (potentially breaking change) :ndn-cxx:`expressInterest` now by default loopbacks Interests to 10 | producer callbacks on the same :ndn-cxx:`Face`. When undesired, use 11 | ``InterestFilter::allowLoopback(false)`` (:issue:`3979`) 12 | 13 | - New signal in :ndn-cxx:`SegmentFetcher` to notify retrieval of Data segments 14 | (:issue:`4438`) 15 | 16 | - Initial support for the Content Store management protocol (:issue:`4050`) 17 | 18 | - Literal operators for ``time::duration`` types, such as ``1_s``, ``42_ms``, ``30_days`` 19 | (:issue:`4468`) 20 | 21 | - Support for BLAKE2 hash function (requires OpenSSL >= 1.1.0) 22 | 23 | - An ``escape()`` helper function complementing the existing ``unescape()`` (:issue:`4484`) 24 | 25 | Improvements and bug fixes 26 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | 28 | - ``ndnsec key-gen`` command line now allows customization of key ID (:issue:`4294`) 29 | 30 | - Fixed encoding of ``'~'`` and ``'+'`` in ``name::Component::toUri()`` (:issue:`4484`) 31 | 32 | - Fixed handling of large dates when converting to/from string (:issue:`4478`, :issue:`3915`) 33 | 34 | - Fixed error handling in ``KeyChain::importSafeBag()`` (:issue:`4359`) 35 | 36 | - Fixed parsing of IPv6 addresses with scope-id (:issue:`4474`) 37 | 38 | - ``io::load()`` now handles empty files properly (:issue:`4434`) 39 | 40 | - Switched to using ``boost::asio::basic_waitable_timer`` (:issue:`4431`) 41 | 42 | - Allow linking multiple :ndn-cxx:`DummyClientFace` instances together to emulate a broadcast 43 | medium (:issue:`3913`) 44 | 45 | - Fixed build when ``std::to_string`` is not available (:issue:`4393`) 46 | 47 | - Avoid undefined behavior when casting to :ndn-cxx:`tlv::SignatureTypeValue` (:issue:`4370`) 48 | 49 | - Fixed compilation with Boost 1.66.0 (:issue:`4422`) 50 | 51 | - Various documentation updates 52 | (:issue:`3918`, :issue: `4184`, :issue: `4275`) 53 | 54 | Removed 55 | ^^^^^^^ 56 | 57 | - Removed obsolete TLV-TYPE constants (:issue:`4055`, :issue:`3098`, :issue: `3755`) 58 | -------------------------------------------------------------------------------- /ndn-cxx/ims/in-memory-storage-persistent.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_IMS_IN_MEMORY_STORAGE_PERSISTENT_HPP 23 | #define NDN_CXX_IMS_IN_MEMORY_STORAGE_PERSISTENT_HPP 24 | 25 | #include "ndn-cxx/ims/in-memory-storage.hpp" 26 | 27 | namespace ndn { 28 | 29 | /** 30 | * @brief Provides application cache with persistent storage, of which no replacement policy will 31 | * be employed. Entries will only be deleted by explicit application control. 32 | */ 33 | class InMemoryStoragePersistent : public InMemoryStorage 34 | { 35 | public: 36 | InMemoryStoragePersistent() = default; 37 | 38 | explicit 39 | InMemoryStoragePersistent(boost::asio::io_context& ioCtx) 40 | : InMemoryStorage(ioCtx) 41 | { 42 | } 43 | 44 | NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED: 45 | /** 46 | * @brief Do nothing. 47 | * 48 | * This storage is persistent, and thus does not support eviction. 49 | */ 50 | bool 51 | evictItem() override 52 | { 53 | return false; 54 | } 55 | }; 56 | 57 | } // namespace ndn 58 | 59 | #endif // NDN_CXX_IMS_IN_MEMORY_STORAGE_PERSISTENT_HPP 60 | -------------------------------------------------------------------------------- /tests/unit/util/concepts.t.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2014-2023 Regents of the University of California, 4 | * Arizona Board of Regents, 5 | * Colorado State University, 6 | * University Pierre & Marie Curie, Sorbonne University, 7 | * Washington University in St. Louis, 8 | * Beijing Institute of Technology, 9 | * The University of Memphis. 10 | * 11 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 12 | * 13 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 14 | * terms of the GNU Lesser General Public License as published by the Free Software 15 | * Foundation, either version 3 of the License, or (at your option) any later version. 16 | * 17 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 18 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 19 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 20 | * 21 | * You should have received copies of the GNU General Public License and GNU Lesser 22 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 23 | * . 24 | * 25 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 26 | */ 27 | 28 | #include "ndn-cxx/util/concepts.hpp" 29 | 30 | namespace ndn::tests { 31 | 32 | class WireEncodableType 33 | { 34 | public: 35 | const Block& 36 | wireEncode(); 37 | }; 38 | BOOST_CONCEPT_ASSERT((WireEncodable)); 39 | 40 | class WireEncodableType2 41 | { 42 | public: 43 | Block 44 | wireEncode(); 45 | }; 46 | BOOST_CONCEPT_ASSERT((WireEncodable)); 47 | 48 | class WireDecodableType 49 | { 50 | public: 51 | explicit 52 | WireDecodableType(const Block& wire); 53 | 54 | void 55 | wireDecode(const Block& wire); 56 | }; 57 | BOOST_CONCEPT_ASSERT((WireDecodable)); 58 | 59 | } // namespace ndn::tests 60 | -------------------------------------------------------------------------------- /ndn-cxx/security/signing-helpers.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/security/signing-helpers.hpp" 23 | 24 | namespace ndn::security { 25 | 26 | SigningInfo 27 | signingByIdentity(const Name& identityName) 28 | { 29 | return SigningInfo(SigningInfo::SIGNER_TYPE_ID, identityName); 30 | } 31 | 32 | SigningInfo 33 | signingByIdentity(const Identity& identity) 34 | { 35 | return SigningInfo(identity); 36 | } 37 | 38 | SigningInfo 39 | signingByKey(const Name& keyName) 40 | { 41 | return SigningInfo(SigningInfo::SIGNER_TYPE_KEY, keyName); 42 | } 43 | 44 | SigningInfo 45 | signingByKey(const Key& key) 46 | { 47 | return SigningInfo(key); 48 | } 49 | 50 | SigningInfo 51 | signingByCertificate(const Name& certName) 52 | { 53 | return SigningInfo(SigningInfo::SIGNER_TYPE_CERT, certName); 54 | } 55 | 56 | SigningInfo 57 | signingByCertificate(const Certificate& cert) 58 | { 59 | return SigningInfo(SigningInfo::SIGNER_TYPE_CERT, cert.getName()); 60 | } 61 | 62 | SigningInfo 63 | signingWithSha256() 64 | { 65 | return SigningInfo(SigningInfo::SIGNER_TYPE_SHA256); 66 | } 67 | 68 | } // namespace ndn::security 69 | -------------------------------------------------------------------------------- /ndn-cxx/util/regex/regex-backref-matcher.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2021 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | * 21 | * @author Yingdi Yu 22 | */ 23 | 24 | #include "ndn-cxx/util/regex/regex-backref-matcher.hpp" 25 | #include "ndn-cxx/util/regex/regex-pattern-list-matcher.hpp" 26 | 27 | namespace ndn { 28 | 29 | RegexBackrefMatcher::RegexBackrefMatcher(const std::string& expr, 30 | shared_ptr backrefManager) 31 | : RegexMatcher(expr, EXPR_BACKREF, std::move(backrefManager)) 32 | { 33 | } 34 | 35 | void 36 | RegexBackrefMatcher::compile() 37 | { 38 | if (m_expr.size() < 2) { 39 | NDN_THROW(Error("Invalid capture group syntax: " + m_expr)); 40 | } 41 | 42 | size_t lastIndex = m_expr.size() - 1; 43 | if ('(' == m_expr[0] && ')' == m_expr[lastIndex]) { 44 | m_matchers.push_back(make_shared(m_expr.substr(1, lastIndex - 1), 45 | m_backrefManager)); 46 | } 47 | else { 48 | NDN_THROW(Error("Invalid capture group syntax: " + m_expr)); 49 | } 50 | } 51 | 52 | } // namespace ndn 53 | -------------------------------------------------------------------------------- /ndn-cxx/security/tpm/impl/key-handle-osx.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "ndn-cxx/security/tpm/impl/key-handle-osx.hpp" 23 | #include "ndn-cxx/security/tpm/impl/back-end-osx.hpp" 24 | 25 | namespace ndn::security::tpm { 26 | 27 | KeyHandleOsx::KeyHandleOsx(const KeyRefOsx& key) 28 | : m_key(key) 29 | { 30 | if (m_key.get() == 0) 31 | NDN_THROW(Error("Key is not set")); 32 | } 33 | 34 | ConstBufferPtr 35 | KeyHandleOsx::doSign(DigestAlgorithm digestAlgorithm, const InputBuffers& bufs) const 36 | { 37 | return BackEndOsx::sign(m_key, digestAlgorithm, bufs); 38 | } 39 | 40 | bool 41 | KeyHandleOsx::doVerify(DigestAlgorithm, const InputBuffers&, span) const 42 | { 43 | NDN_THROW(Error("Signature verification is not supported with macOS Keychain-based TPM")); 44 | } 45 | 46 | ConstBufferPtr 47 | KeyHandleOsx::doDecrypt(span cipherText) const 48 | { 49 | return BackEndOsx::decrypt(m_key, cipherText); 50 | } 51 | 52 | ConstBufferPtr 53 | KeyHandleOsx::doDerivePublicKey() const 54 | { 55 | return BackEndOsx::derivePublicKey(m_key); 56 | } 57 | 58 | } // namespace ndn::security::tpm 59 | -------------------------------------------------------------------------------- /tests/test-common.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #include "tests/test-common.hpp" 23 | 24 | namespace ndn::tests { 25 | 26 | shared_ptr 27 | makeInterest(const Name& name, bool canBePrefix, std::optional lifetime, 28 | std::optional nonce) 29 | { 30 | auto interest = std::make_shared(name); 31 | interest->setCanBePrefix(canBePrefix); 32 | if (lifetime) { 33 | interest->setInterestLifetime(*lifetime); 34 | } 35 | interest->setNonce(nonce); 36 | return interest; 37 | } 38 | 39 | shared_ptr 40 | makeData(const Name& name) 41 | { 42 | auto data = std::make_shared(name); 43 | return signData(data); 44 | } 45 | 46 | Data& 47 | signData(Data& data) 48 | { 49 | data.setSignatureInfo(SignatureInfo(tlv::NullSignature)); 50 | data.setSignatureValue(std::make_shared()); 51 | data.wireEncode(); 52 | return data; 53 | } 54 | 55 | lp::Nack 56 | makeNack(Interest interest, lp::NackReason reason) 57 | { 58 | lp::Nack nack(std::move(interest)); 59 | nack.setReason(reason); 60 | return nack; 61 | } 62 | 63 | } // namespace ndn::tests 64 | -------------------------------------------------------------------------------- /ndn-cxx/security/validation-callback.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_SECURITY_VALIDATION_CALLBACK_HPP 23 | #define NDN_CXX_SECURITY_VALIDATION_CALLBACK_HPP 24 | 25 | #include "ndn-cxx/data.hpp" 26 | #include "ndn-cxx/interest.hpp" 27 | #include "ndn-cxx/security/validation-error.hpp" 28 | 29 | namespace ndn::security { 30 | 31 | /** 32 | * @brief Callback to report a successful Data validation. 33 | */ 34 | using DataValidationSuccessCallback = std::function; 35 | 36 | /** 37 | * @brief Callback to report a failed Data validation. 38 | */ 39 | using DataValidationFailureCallback = std::function; 40 | 41 | /** 42 | * @brief Callback to report a successful Interest validation. 43 | */ 44 | using InterestValidationSuccessCallback = std::function; 45 | 46 | /** 47 | * @brief Callback to report a failed Interest validation. 48 | */ 49 | using InterestValidationFailureCallback = std::function; 50 | 51 | } // namespace ndn::security 52 | 53 | #endif // NDN_CXX_SECURITY_VALIDATION_CALLBACK_HPP 54 | -------------------------------------------------------------------------------- /ndn-cxx/security/transform.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2019 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_SECURITY_TRANSFORM_HPP 23 | #define NDN_CXX_SECURITY_TRANSFORM_HPP 24 | 25 | #include "ndn-cxx/security/transform/buffer-source.hpp" 26 | #include "ndn-cxx/security/transform/step-source.hpp" 27 | #include "ndn-cxx/security/transform/stream-source.hpp" 28 | 29 | #include "ndn-cxx/security/transform/bool-sink.hpp" 30 | #include "ndn-cxx/security/transform/stream-sink.hpp" 31 | 32 | #include "ndn-cxx/security/transform/base64-decode.hpp" 33 | #include "ndn-cxx/security/transform/base64-encode.hpp" 34 | #include "ndn-cxx/security/transform/hex-decode.hpp" 35 | #include "ndn-cxx/security/transform/hex-encode.hpp" 36 | #include "ndn-cxx/security/transform/strip-space.hpp" 37 | 38 | #include "ndn-cxx/security/transform/block-cipher.hpp" 39 | #include "ndn-cxx/security/transform/digest-filter.hpp" 40 | #include "ndn-cxx/security/transform/private-key.hpp" 41 | #include "ndn-cxx/security/transform/public-key.hpp" 42 | #include "ndn-cxx/security/transform/signer-filter.hpp" 43 | #include "ndn-cxx/security/transform/verifier-filter.hpp" 44 | 45 | #endif // NDN_CXX_SECURITY_TRANSFORM_HPP 46 | -------------------------------------------------------------------------------- /tools/README.md: -------------------------------------------------------------------------------- 1 | ndn-cxx tools 2 | ============= 3 | 4 | Unless disabled with `--without-tools` configuration option, files in `tools/` directory 5 | are automatically build and installed to `${PREFIX}/bin` folder. 6 | 7 | There are two ways to add new tools, depending on their complexity: 8 | 9 | 1. Tools with a single translation unit 10 | 11 | For simple tools that have a single translation unit, the `.cpp` file can be directly put 12 | in `tools/` folder and it will be automatically compiled on the next run of `./waf`. Name 13 | of the compiled binary will be determined by the base name of the `.cpp` file. For example, 14 | `tools/foo.cpp` will be compiled into binary `foo` in `/bin/` folder: 15 | 16 | echo "int main() { return 0; }" > tools/foo.cpp 17 | ./waf 18 | # ... Compiling tools/foo.cpp 19 | # ... Linking build/bin/foo 20 | 21 | sudo ./waf install 22 | # ... install /usr/local/bin/foo (from build/bin/foo) 23 | 24 | # To run the tool 25 | /usr/local/bin/foo 26 | 27 | 2. Tools with multiple translation units 28 | 29 | For more complex tools that contain multiple translation units, one can use 30 | the following directory structure: 31 | 32 | - Create a directory under `tools/` folder (e.g., `tools/bar`). 33 | The name of this directory will determine the name of the compiled binary 34 | (`/bin/bar`) 35 | 36 | - Place any number of translation units (e.g., `tools/bar/a.cpp`, `tools/bar/b.cpp`, 37 | ...) in this directory. All `.cpp` files in this directory will be compiled and linked 38 | together to produce the binary of the tool. One of the .cpp files should contain 39 | the `main()` function. 40 | 41 | For example: 42 | 43 | mkdir tools/bar 44 | echo "int bar(); int main() { return bar(); }" > tools/bar/a.cpp 45 | echo "int bar() { return 10; } " > tools/bar/b.cpp 46 | ./waf 47 | # ... Compiling tools/bar/a.cpp 48 | # ... Compiling tools/bar/b.cpp 49 | # ... Linking build/bin/bar 50 | 51 | sudo ./waf install 52 | # ... install /usr/local/bin/bar (from build/bin/bar) 53 | 54 | # To run the tool 55 | /usr/local/bin/bar 56 | -------------------------------------------------------------------------------- /ndn-cxx/security/certificate-request.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_SECURITY_CERTIFICATE_REQUEST_HPP 23 | #define NDN_CXX_SECURITY_CERTIFICATE_REQUEST_HPP 24 | 25 | #include "ndn-cxx/interest.hpp" 26 | 27 | namespace ndn::security { 28 | 29 | /** 30 | * @brief Request for a certificate, associated with the number of attempts. 31 | */ 32 | class CertificateRequest : noncopyable 33 | { 34 | public: 35 | CertificateRequest() = default; 36 | 37 | explicit 38 | CertificateRequest(const Interest& interest) 39 | : interest(interest) 40 | , nRetriesLeft(3) 41 | { 42 | } 43 | 44 | explicit 45 | CertificateRequest(const Name& name) 46 | : CertificateRequest(Interest(name).setCanBePrefix(true)) 47 | { 48 | } 49 | 50 | public: 51 | /// The name for the requested certificate. 52 | Interest interest; 53 | /// The number of remaining retries after a timeout or Nack. 54 | int nRetriesLeft = 0; 55 | /// The amount of time to wait before sending the next Interest after a Nack. 56 | time::milliseconds waitAfterNack = 500_ms; 57 | }; 58 | 59 | } // namespace ndn::security 60 | 61 | #endif // NDN_CXX_SECURITY_CERTIFICATE_REQUEST_HPP 62 | -------------------------------------------------------------------------------- /ndn-cxx/encoding/encoding-buffer.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2013-2023 Regents of the University of California. 4 | * 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). 6 | * 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the 8 | * terms of the GNU Lesser General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later version. 10 | * 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | * 15 | * You should have received copies of the GNU General Public License and GNU Lesser 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see 17 | * . 18 | * 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. 20 | */ 21 | 22 | #ifndef NDN_CXX_ENCODING_ENCODING_BUFFER_HPP 23 | #define NDN_CXX_ENCODING_ENCODING_BUFFER_HPP 24 | 25 | #include "ndn-cxx/encoding/encoding-buffer-fwd.hpp" 26 | #include "ndn-cxx/encoding/encoder.hpp" 27 | #include "ndn-cxx/encoding/estimator.hpp" 28 | 29 | namespace ndn::encoding { 30 | 31 | /** 32 | * @brief EncodingImpl specialization for actual TLV encoding 33 | */ 34 | template<> 35 | class EncodingImpl : public Encoder 36 | { 37 | public: 38 | explicit 39 | EncodingImpl(size_t totalReserve = MAX_NDN_PACKET_SIZE, size_t reserveFromBack = 400) 40 | : Encoder(totalReserve, reserveFromBack) 41 | { 42 | } 43 | 44 | explicit 45 | EncodingImpl(const Block& block) 46 | : Encoder(block) 47 | { 48 | } 49 | }; 50 | 51 | /** 52 | * @brief EncodingImpl specialization for TLV size estimation 53 | */ 54 | template<> 55 | class EncodingImpl : public Estimator 56 | { 57 | public: 58 | explicit 59 | EncodingImpl(size_t totalReserve = 0, size_t totalFromBack = 0) 60 | { 61 | } 62 | }; 63 | 64 | } // namespace ndn::encoding 65 | 66 | #endif // NDN_CXX_ENCODING_ENCODING_BUFFER_HPP 67 | --------------------------------------------------------------------------------