├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── actions
│ ├── check-coverage
│ │ └── action.yml
│ ├── setup-osal
│ │ └── action.yml
│ └── setup-tinycbor
│ │ └── action.yml
├── pull_request_template.md
├── scripts
│ └── lcov-output.xslt
└── workflows
│ ├── static-analysis.yml
│ └── unit-test-functional.yml
├── .gitignore
├── CMakeLists.txt
├── CONTRIBUTING.md
├── LICENSE
├── Makefile
├── README.md
├── RELEASE.sh
├── app
├── CMakeLists.txt
└── bpcat.c
├── binding
└── lua
│ ├── Makefile
│ ├── analysis
│ ├── .gitignore
│ ├── performance.ipynb
│ └── pf_missed_contact.lua
│ ├── bp.lua
│ ├── bptest.lua
│ ├── lua_bplib.c
│ ├── lua_bplib.h
│ └── test
│ ├── test_runner.lua
│ ├── ut_active_table.lua
│ ├── ut_attributes.lua
│ ├── ut_bundle_timeout.lua
│ ├── ut_dacs_continuous.lua
│ ├── ut_dacs_skip.lua
│ ├── ut_eid2ipn.lua
│ ├── ut_expiration.lua
│ ├── ut_getset_opt.lua
│ ├── ut_high_loss.lua
│ ├── ut_ipn2eid.lua
│ ├── ut_memusage.lua
│ ├── ut_open_close.lua
│ ├── ut_recover.lua
│ ├── ut_route.lua
│ ├── ut_unittest.lua
│ └── ut_wrap_response.lua
├── cache
├── CMakeLists.txt
├── inc
│ └── v7_cache.h
├── src
│ ├── v7_cache.c
│ ├── v7_cache_custody.c
│ ├── v7_cache_fsm.c
│ └── v7_cache_internal.h
├── ut-coverage
│ ├── CMakeLists.txt
│ ├── test_bplib_cache.h
│ ├── test_bplib_cache_setup.c
│ ├── test_v7_cache.c
│ ├── test_v7_cache_custody.c
│ └── test_v7_cache_fsm.c
└── ut-stubs
│ ├── CMakeLists.txt
│ └── v7_cache_stubs.c
├── common
├── CMakeLists.txt
├── inc
│ ├── crc.h
│ └── v7_rbtree.h
├── src
│ ├── crc.c
│ ├── crc_private.h
│ └── v7_rbtree.c
├── ut-coverage
│ ├── CMakeLists.txt
│ ├── test_bplib_common.c
│ ├── test_bplib_common.h
│ ├── test_bplib_crc.c
│ └── test_bplib_v7_rbtree.c
├── ut-functional
│ ├── CMakeLists.txt
│ └── rbtest.c
└── ut-stubs
│ ├── CMakeLists.txt
│ ├── crc_stub_objs.c
│ ├── crc_stubs.c
│ └── v7_rbtree_stubs.c
├── doc
├── GSC_18318_Corp_CLA_form_1219.pdf
├── GSC_18318_Ind_CLA_form_1219.pdf
├── NOSA GSC-18318-1_0.pdf
├── analysis_ic_c1_flow.png
├── analysis_ic_c1_smooth.png
├── analysis_ic_c2_flow.png
├── analysis_ic_c2_smooth.png
├── bp_api_architecture.png
├── bpv6_notes.md
├── bpv7-prototype.pdf
├── dev_notes.md
├── diagrams.odg
├── dtn-storage-simple.png
├── dtn-storage-states.odg
├── parm_notes.md
└── perf_analysis_ic.md
├── inc
├── bplib.h
├── bplib_api_types.h
├── bplib_file_offload.h
└── bplib_routing.h
├── lib
├── CMakeLists.txt
├── inc
│ └── bplib_dataservice.h
├── src
│ ├── v7_base_internal.h
│ ├── v7_bplib.c
│ ├── v7_cla_api.c
│ ├── v7_dataservice_api.c
│ └── v7_routing.c
├── ut-coverage
│ ├── CMakeLists.txt
│ ├── test_bplib_base.h
│ ├── test_bplib_base_setup.c
│ ├── test_v7_bplib.c
│ ├── test_v7_cla_api.c
│ ├── test_v7_dataservice_api.c
│ └── test_v7_routing.c
└── ut-stubs
│ ├── CMakeLists.txt
│ └── bplib_dataservice_stubs.c
├── libabi.version
├── mpool
├── CMakeLists.txt
├── inc
│ ├── v7_mpool.h
│ ├── v7_mpool_bblocks.h
│ ├── v7_mpool_flows.h
│ ├── v7_mpool_job.h
│ ├── v7_mpool_ref.h
│ └── v7_mpstream.h
├── src
│ ├── v7_mpool.c
│ ├── v7_mpool_bblocks.c
│ ├── v7_mpool_flows.c
│ ├── v7_mpool_internal.h
│ ├── v7_mpool_job.c
│ ├── v7_mpool_ref.c
│ └── v7_mpstream.c
├── ut-coverage
│ ├── CMakeLists.txt
│ ├── test_bplib_mpool.h
│ ├── test_bplib_mpool_setup.c
│ ├── test_bplib_v7_mpool.c
│ ├── test_bplib_v7_mpool_bblocks.c
│ ├── test_bplib_v7_mpool_flows.c
│ ├── test_bplib_v7_mpool_job.c
│ ├── test_bplib_v7_mpool_ref.c
│ └── test_bplib_v7_mpstream.c
└── ut-stubs
│ ├── CMakeLists.txt
│ ├── v7_mpool_bblocks_stubs.c
│ ├── v7_mpool_flows_stubs.c
│ ├── v7_mpool_job_stubs.c
│ ├── v7_mpool_ref_stubs.c
│ ├── v7_mpool_stubs.c
│ └── v7_mpstream_stubs.c
├── os
├── CMakeLists.txt
├── inc
│ └── bplib_os.h
├── src
│ ├── cfe.c
│ ├── heap.c
│ ├── osal.c
│ └── posix.c
├── ut-coverage
│ ├── CMakeLists.txt
│ ├── inc
│ │ └── bplib_cs_stdlib.h
│ ├── libc_stdlib_stubs.c
│ ├── override_inc
│ │ └── stdlib.h
│ └── test_bplib_os.c
└── ut-stubs
│ ├── CMakeLists.txt
│ ├── bplib_os_handlers.c
│ └── bplib_os_stubs.c
├── posix.mk
├── release.mk
├── store
└── file_offload.c
├── ut-functional
├── CMakeLists.txt
└── sanity-test.c
├── ut-stubs
├── CMakeLists.txt
├── bplib_routing_stubs.c
└── bplib_stubs.c
├── v7
├── CMakeLists.txt
├── inc
│ ├── v7.h
│ ├── v7_codec.h
│ ├── v7_decode.h
│ ├── v7_encode.h
│ └── v7_types.h
├── src
│ ├── v7.c
│ ├── v7_bp_admin_record.c
│ ├── v7_bp_basetypes.c
│ ├── v7_bp_bitmap.c
│ ├── v7_bp_bundle_age_block.c
│ ├── v7_bp_canonical_block.c
│ ├── v7_bp_container.c
│ ├── v7_bp_crc.c
│ ├── v7_bp_endpointid.c
│ ├── v7_bp_hop_count_block.c
│ ├── v7_bp_previous_node_block.c
│ ├── v7_bp_primary_block.c
│ ├── v7_codec_common.c
│ ├── v7_codec_internal.h
│ ├── v7_custody_acknowledgement_record.c
│ ├── v7_custody_tracking_block.c
│ ├── v7_decode_api.c
│ ├── v7_decode_internal.h
│ ├── v7_encode_api.c
│ └── v7_encode_internal.h
├── ut-coverage
│ ├── CMakeLists.txt
│ ├── cbor_stubs.c
│ ├── test_bplib_v7.h
│ ├── test_bplib_v7_setup.c
│ ├── test_v7.c
│ ├── test_v7_bp_admin_record.c
│ ├── test_v7_bp_basetypes.c
│ ├── test_v7_bp_bitmap.c
│ ├── test_v7_bp_bundle_age_block.c
│ ├── test_v7_bp_canonical_block.c
│ ├── test_v7_bp_container.c
│ ├── test_v7_bp_crc.c
│ ├── test_v7_bp_endpointid.c
│ ├── test_v7_bp_hop_count_block.c
│ ├── test_v7_bp_previous_node_block.c
│ ├── test_v7_bp_primary_block.c
│ ├── test_v7_codec_common.c
│ ├── test_v7_custody_acknowledgement_record.c
│ ├── test_v7_custody_tracking_block.c
│ ├── test_v7_decode_api.c
│ └── test_v7_encode_api.c
└── ut-stubs
│ ├── CMakeLists.txt
│ ├── v7_codec_stubs.c
│ ├── v7_decode_stubs.c
│ ├── v7_encode_stubs.c
│ └── v7_stubs.c
└── version.txt
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Code snips**
24 | If applicable, add references to the software.
25 |
26 | **System observed on:**
27 | - Hardware
28 | - OS: [e.g. Linux 4.4]
29 | - Versions [e.g. cFE 6.6, OSAL 4.2, PSP 1.3 for mcp750, any related apps]
30 |
31 | **Additional context**
32 | Add any other context about the problem here.
33 |
34 | **Reporter Info**
35 | Full name and company/organization if applicable
36 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context about the feature request here.
21 |
22 | **Requester Info**
23 | Full name and company/organization if applicable
24 |
--------------------------------------------------------------------------------
/.github/actions/check-coverage/action.yml:
--------------------------------------------------------------------------------
1 | name: Check Coverage Results
2 | description: 'Extracts a summary of the code coverage results'
3 |
4 | inputs:
5 | binary-dir:
6 | description: 'Directory containing binary files'
7 | required: true
8 | source-dir:
9 | description: 'Directory containing source code files'
10 | default: ./source
11 |
12 | runs:
13 | using: 'composite'
14 | steps:
15 | - name: Capture Results
16 | shell: bash
17 | run: lcov
18 | --capture --rc lcov_branch_coverage=1
19 | --include '${{ github.workspace }}/*'
20 | --directory '${{ inputs.binary-dir }}'
21 | --output-file '${{ inputs.binary-dir }}/coverage.info'
22 |
23 | - name: Generate HTML
24 | shell: bash
25 | run: genhtml
26 | '${{ inputs.binary-dir }}/coverage.info'
27 | --branch-coverage
28 | --output-directory '${{ inputs.binary-dir }}/lcov-html'
29 |
30 | - name: Extract Summary
31 | shell: bash
32 | run: xsltproc --html
33 | '${{ inputs.source-dir }}/.github/scripts/lcov-output.xslt'
34 | '${{ inputs.binary-dir }}/lcov-html/index.html' > '${{ inputs.binary-dir }}/lcov-summary.xml'
35 |
--------------------------------------------------------------------------------
/.github/actions/setup-osal/action.yml:
--------------------------------------------------------------------------------
1 | name: Install OSAL
2 | description: 'Builds and installs NASA OSAL into the workflow filesystem'
3 |
4 | inputs:
5 | upstream-ref:
6 | description: 'Upstream ref to check out'
7 | default: main
8 | upstream-repo:
9 | description: 'Upstream repository to use'
10 | default: nasa/osal
11 | config-options:
12 | description: 'Configuration options to pass to CMake'
13 | default: -DCMAKE_BUILD_TYPE=Release -DOSAL_OMIT_DEPRECATED=TRUE -DENABLE_UNIT_TESTS=TRUE -DOSAL_CONFIG_DEBUG_PERMISSIVE_MODE=ON
14 | staging-dir:
15 | description: 'Directory to stage output'
16 | required: true
17 |
18 | runs:
19 | using: 'composite'
20 | steps:
21 | - name: Checkout OSAL
22 | uses: actions/checkout@v3
23 | with:
24 | repository: ${{ inputs.upstream-repo }}
25 | ref: ${{ inputs.upstream-ref }}
26 | path: osal-source
27 |
28 | - name: Set up OSAL build
29 | shell: bash
30 | run: cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DOSAL_SYSTEM_BSPTYPE=generic-linux ${{ inputs.config-options }} -S osal-source -B osal-build
31 |
32 | - name: Build and Install OSAL
33 | shell: bash
34 | working-directory: osal-build
35 | run: make DESTDIR=${{ inputs.staging-dir }} install
36 |
--------------------------------------------------------------------------------
/.github/actions/setup-tinycbor/action.yml:
--------------------------------------------------------------------------------
1 | name: Install TinyCBOR
2 | description: 'Builds and installs Intel TinyCBOR into the workflow filesystem'
3 |
4 | inputs:
5 | upstream-ref:
6 | description: 'Upstream ref to check out'
7 | default: v0.6.0
8 | upstream-repo:
9 | description: 'Upstream repository to use'
10 | default: intel/tinycbor
11 | staging-dir:
12 | description: 'Directory to stage output'
13 | required: true
14 |
15 | runs:
16 | using: 'composite'
17 | steps:
18 | - name: Checkout TinyCBOR
19 | uses: actions/checkout@v3
20 | with:
21 | repository: ${{ inputs.upstream-repo }}
22 | ref: ${{ inputs.upstream-ref }}
23 | path: tinycbor-source
24 |
25 | - name: Build and Install TinyCBOR
26 | working-directory: tinycbor-source
27 | shell: bash
28 | run: make all && make DESTDIR=${{ inputs.staging-dir }} install
29 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **Describe the contribution**
2 | A clear and concise description of what the contribution is.
3 | - Include explicitly what issue it addresses [e.g. Fixes #X]
4 |
5 | **Testing performed**
6 | Steps taken to test the contribution:
7 | 1. Build steps '...'
8 | 1. Execution steps '...'
9 |
10 | **Expected behavior changes**
11 | A clear and concise description of how this contribution will change behavior and level of impact.
12 | - API Change: xxx (if applicable)
13 | - Behavior Change: xxx (if applicable)
14 | - Or no impact to behavior
15 |
16 | **System(s) tested on**
17 | - Hardware: [e.g. PC, SP0, MCP750]
18 | - OS: [e.g. Ubuntu 18.04, RTEMS 4.11, VxWorks 6.9]
19 | - Versions: [e.g. cFE 6.6, OSAL 4.2, PSP 1.3 for mcp750, any related apps or tools]
20 |
21 | **Additional context**
22 | Add any other context about the contribution here.
23 |
24 | **Third party code**
25 | If included, identify any third party code and provide text file of license
26 |
27 | **Contributor Info - All information REQUIRED for consideration of pull request**
28 | Full name and company/organization/center of all contributors ("Personal" if individual work)
29 | - If NASA Civil Servant Employee or GSFC Contractor on SES III
30 | - Address/email/phone and contract/task information (if applicable) must be on file
31 | - Else if Company
32 | - **HAND SIGNED** Company CLA must be on file (once per release): [Company CLA](https://github.com/nasa/bplib/blob/main/doc/GSC_18318_Corp_CLA_form_1219.pdf)
33 | - Else if Individual
34 | - **HAND SIGNED** Individual CLA must be on file (once per release): [Individual CLA](https://github.com/nasa/bplib/blob/main/doc/GSC_18318_Ind_CLA_form_1219.pdf)
35 |
--------------------------------------------------------------------------------
/.github/scripts/lcov-output.xslt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | X
23 |
24 | |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 | LCOV Report
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/.github/workflows/static-analysis.yml:
--------------------------------------------------------------------------------
1 | name: Static Analysis
2 |
3 | # Run on pull requests and by dispatch
4 | on:
5 | workflow_dispatch:
6 | pull_request:
7 |
8 | jobs:
9 | static-analysis:
10 | name: Run cppcheck
11 | uses: nasa/cFS/.github/workflows/static-analysis.yml@main
12 | with:
13 | strict-dir-list:
14 | -Iinc -Icache/inc -Icommon/inc -Ilib/inc -Impool/inc -Ios/inc -Iv7/inc
15 | cache/src common/src lib/src mpool/src os/src v7/src store
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 | bp.out
3 | .vscode/
4 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | When submitting a pull request:
2 |
3 | **Describe the contribution**
4 | A clear and concise description of what the contribution is.
5 | - Include explicitly what issue it addresses [e.g. Fixes #X]
6 |
7 | **Testing performed**
8 | Steps taken to test the contribution:
9 | 1. Build steps '...'
10 | 1. Execution steps '...'
11 |
12 | **Expected behavior changes**
13 | A clear and concise description of how this contribution will change behavior and level of impact.
14 | - API Change: xxx (if applicable)
15 | - Behavior Change: xxx (if applicable)
16 | - Or no impact to behavior
17 |
18 | **System(s) tested on**
19 | - Hardware: [e.g. PC, SP0, MCP750]
20 | - OS: [e.g. Ubuntu 18.04, RTEMS 4.11, VxWorks 6.9]
21 | - Versions: [e.g. 0.2.2, any related apps or tools]
22 |
23 | **Additional context**
24 | Add any other context about the contribution here.
25 |
26 | **Third party code**
27 | If included, identify any third party code and provide text file of license
28 |
29 | **Contributor Info - All information REQUIRED for consideration of pull request**
30 | Full name and company/organization/center of all contributors ("Personal" if individual work)
31 | - If NASA Civil Servant Employee or GSFC Contractor on SES II
32 | - Address/email/phone and contract/task information (if applicable) must be on file
33 | - Else if Company
34 | - **HAND SIGNED** Company CLA must be on file (once per release): [Company CLA](doc/GSC_18318_Corp_CLA_form_1219.pdf)
35 | - Else if Individual
36 | - **HAND SIGNED** Individual CLA must be on file (once per release): [Individual CLA](doc/GSC_18318_Ind_CLA_form_1219.pdf)
37 |
--------------------------------------------------------------------------------
/RELEASE.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/sh
2 |
3 | #
4 | # Typical version identifier is x.y.z, e.g. 1.0.4
5 | # the version number is then prepended with 'v' for
6 | # the tags annotation in git.
7 | #
8 | VERSION=$1
9 | if git tag -l | grep -w v$VERSION; then
10 | echo Git tag already exists
11 | exit 1
12 | fi
13 |
14 | #
15 | # Clean up any previously attempted archives
16 | #
17 | rm bplib-$VERSION.tar.gz 2> /dev/null
18 |
19 | #
20 | # Update version in local repository
21 | #
22 | echo $VERSION > version.txt
23 | git add version.txt
24 | git commit -m "Version v$VERSION"
25 |
26 | #
27 | # Create tag and acrhive
28 | #
29 | git tag -a v$VERSION -m "version $VERSION"
30 | git archive --format=tar.gz --prefix=bplib/ v$VERSION > bplib-$VERSION.tar.gz
31 |
32 |
--------------------------------------------------------------------------------
/app/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # Bundle Protocol Library (BPLib) Test App CMake build recipe
4 | #
5 | # This file provides various test executables, including bpcat, that
6 | # can be used to initiate or terminate BP/DTN traffic from the
7 | # command line on a simulated node.
8 | #
9 | ##################################################################
10 |
11 | cmake_minimum_required(VERSION 3.5)
12 | project(BPLIB_TEST_APP C)
13 |
14 | # Sanity check: bpcat assumes a POSIX system
15 | # and uses pthread calls. If not POSIX, then
16 | # this tool will not build.
17 | if (NOT BPLIB_OS_LAYER STREQUAL POSIX)
18 | message(FATAL_ERROR "BPLib Test applications require POSIX")
19 | endif()
20 |
21 | set(BPAPP_COMPILE_FEATURES "c_std_99")
22 | set(BPAPP_COMPILE_OPTIONS "$<$:-Wall;-Werror>")
23 | set(BPAPP_LINK_LIBRARIES bplib)
24 |
25 | add_executable(bpcat bpcat.c)
26 |
27 | # compile this app as c99 (but this does not impose the same requirement on other users)
28 | target_compile_features(bpcat PRIVATE ${BPAPP_COMPILE_FEATURES})
29 |
30 | # If using GNU GCC, then also enable full warning reporting
31 | target_compile_options(bpcat PRIVATE ${BPAPP_COMPILE_OPTIONS})
32 |
33 | # Low level test apps may include "private" headers, whereas higher level tests should not
34 | target_include_directories(bpcat PRIVATE ${BPLIB_PRIVATE_INCLUDE_DIRS})
35 |
36 | # link with bplib
37 | target_link_libraries(bpcat ${BPAPP_LINK_LIBRARIES})
38 |
--------------------------------------------------------------------------------
/binding/lua/Makefile:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # File: Makefile
3 | #
4 | # Copyright 2019 United States Government as represented by the
5 | # Administrator of the National Aeronautics and Space Administration.
6 | # All Other Rights Reserved.
7 | #
8 | # This software was created at NASA's Goddard Space Flight Center.
9 | # This software is governed by the NASA Open Source Agreement and may be
10 | # used, distributed and modified only pursuant to the terms of that
11 | # agreement.
12 | #
13 | # Maintainer(s):
14 | # Joe-Paul Swinski, Code 582 NASA GSFC
15 | #
16 |
17 | ##############################################################################
18 | ## DEFINITIONS and CONFIGURATION (populated/overridden in application includes)
19 |
20 | # repository root directory
21 | ROOT := .
22 |
23 | # object files
24 | LUA_OBJ := lua_bplib.o
25 |
26 | # search path for extension objects (note this is a make system variable)
27 | VPATH := $(ROOT)
28 |
29 | # compiler options for search path for include headers (in form of -I_header_)
30 | INCLUDES := -I$(ROOT)
31 | INCLUDES += -I$(ROOT)/../../inc
32 | INCLUDES += -I$(ROOT)/../../unittest
33 |
34 | # user customized options
35 | MY_COPT ?=
36 | MY_LOPT ?=
37 |
38 | ###############################################################################
39 | ## CUSTOMIZATION
40 |
41 | # location of installed lua
42 | PREFIX ?= /opt/lua5.3
43 |
44 | # location to install extension
45 | LIBDIR ?= $(PREFIX)/lib/lua/5.3
46 |
47 | ###############################################################################
48 | ## DEFINES
49 |
50 | TGTEXT := bplib
51 | BLDDIR := build
52 |
53 | COPT := -g -O0 $(INCLUDES) $(MY_COPT)
54 | COPT += -I$(PREFIX)/include
55 | COPT += -Wall -Wextra -Wshadow
56 | COPT += -fPIC
57 |
58 | LOPT := $(MY_LOPT)
59 | LOPT += -L../../build
60 | LOPT += -lbp
61 |
62 | ###############################################################################
63 | ## COMPILER RULES
64 |
65 | ALL_OBJ := $(addprefix $(BLDDIR)/, $(LUA_OBJ))
66 | ALL_COPT := $(COPT)
67 | ALL_LOPT := $(LOPT)
68 |
69 | $(BLDDIR)/%.o: %.c
70 | $(CC) -c $(ALL_COPT) -o $@ $<
71 |
72 | ##############################################################################
73 | ## TARGET RULES
74 |
75 | all: clean $(BLDDIR) extension
76 |
77 | extension: $(BLDDIR) $(ALL_OBJ)
78 | $(CC) $(ALL_OBJ) $(ALL_LOPT) -shared -o $(BLDDIR)/$(TGTEXT).so
79 |
80 | install: $(PREFIX) $(LIBDIR)
81 | cp $(BLDDIR)/$(TGTEXT).so $(LIBDIR)
82 | chmod 644 $(LIBDIR)/$(TGTEXT).so
83 | cp bp.lua $(LIBDIR)
84 | cp bptest.lua $(LIBDIR)
85 |
86 | $(BLDDIR):
87 | -mkdir -p $(BLDDIR)
88 |
89 | $(PREFIX):
90 | -mkdir -p $(PREFIX)
91 |
92 | $(LIBDIR):
93 | -mkdir -p $(LIBDIR)
94 |
95 | clean ::
96 | ls
97 | -rm -R $(BLDDIR)
98 |
99 | # end of file
100 |
--------------------------------------------------------------------------------
/binding/lua/analysis/.gitignore:
--------------------------------------------------------------------------------
1 | *.csv*
2 | .ipynb_checkpoints/
3 |
--------------------------------------------------------------------------------
/binding/lua/lua_bplib.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | #ifndef LUA_BPLIB_H
22 | #define LUA_BPLIB_H
23 |
24 | /******************************************************************************
25 | INCLUDES
26 | ******************************************************************************/
27 |
28 | #include
29 |
30 | /******************************************************************************
31 | EXPORTED FUNCTIONS
32 | ******************************************************************************/
33 |
34 | int luaopen_bplib(lua_State *L);
35 |
36 | #endif /* LUA_BPLIB_H */
37 |
--------------------------------------------------------------------------------
/binding/lua/test/test_runner.lua:
--------------------------------------------------------------------------------
1 | local bplib = require("bplib")
2 | local runner = require("bptest")
3 | local rd = runner.rootdir(arg[0])
4 |
5 | --runner.set_exit_on_error(true)
6 |
7 | start_currmem, start_highmem = bplib.memstat()
8 |
9 | -- Run Unit Tests --
10 |
11 | runner.script(rd .. "ut_open_close.lua", {"RAM"})
12 | runner.script(rd .. "ut_open_close.lua", {"FILE"})
13 | runner.script(rd .. "ut_open_close.lua", {"FLASH"})
14 | runner.script(rd .. "ut_attributes.lua")
15 | runner.script(rd .. "ut_getset_opt.lua")
16 | runner.script(rd .. "ut_eid2ipn.lua")
17 | runner.script(rd .. "ut_ipn2eid.lua")
18 | runner.script(rd .. "ut_route.lua")
19 | runner.script(rd .. "ut_expiration.lua")
20 | runner.script(rd .. "ut_expiration.lua", {"FLASH"})
21 | runner.script(rd .. "ut_recover.lua", {"FLASH"})
22 | runner.script(rd .. "ut_memusage.lua", {"RAM"})
23 | runner.script(rd .. "ut_active_table.lua", {"RAM", "SMALLEST"})
24 | runner.script(rd .. "ut_active_table.lua", {"RAM", "OLDEST"})
25 | runner.script(rd .. "ut_active_table.lua", {"FLASH", "SMALLEST"})
26 | runner.script(rd .. "ut_active_table.lua", {"FLASH", "OLDEST"})
27 | runner.script(rd .. "ut_bundle_timeout.lua", {"RAM"})
28 | runner.script(rd .. "ut_bundle_timeout.lua", {"FILE"})
29 | runner.script(rd .. "ut_bundle_timeout.lua", {"FLASH"})
30 | runner.script(rd .. "ut_wrap_response.lua", {"RAM"})
31 | runner.script(rd .. "ut_wrap_response.lua", {"FILE"})
32 | runner.script(rd .. "ut_wrap_response.lua", {"FLASH"})
33 | runner.script(rd .. "ut_dacs_continuous.lua", {"RAM"})
34 | runner.script(rd .. "ut_dacs_continuous.lua", {"FILE"})
35 | runner.script(rd .. "ut_dacs_continuous.lua", {"FLASH"})
36 | runner.script(rd .. "ut_dacs_skip.lua", {"RAM"})
37 | runner.script(rd .. "ut_dacs_skip.lua", {"FILE"})
38 | runner.script(rd .. "ut_dacs_skip.lua", {"FLASH"})
39 | runner.script(rd .. "ut_high_loss.lua", {"RAM"})
40 | runner.script(rd .. "ut_high_loss.lua", {"FILE"})
41 | runner.script(rd .. "ut_high_loss.lua", {"FLASH", 100})
42 | runner.script(rd .. "ut_unittest.lua")
43 |
44 | -- Check for Memory Leaks --
45 |
46 | currmem, highmem = bplib.memstat()
47 | runner.check(currmem == start_currmem, string.format('Memory leak detected: %d!', currmem - start_currmem))
48 |
49 | -- Report Results --
50 |
51 | runner.report(bplib)
52 |
53 |
--------------------------------------------------------------------------------
/binding/lua/test/ut_active_table.lua:
--------------------------------------------------------------------------------
1 | local bplib = require("bplib")
2 | local runner = require("bptest")
3 | local bp = require("bp")
4 | local src = runner.srcscript()
5 |
6 | -- Setup --
7 |
8 | local store = arg[1] or "RAM"
9 | runner.setup(bplib, store)
10 |
11 | local retx_order = arg[2] or "SMALLEST"
12 | if retx_order == "SMALLEST" then
13 | retx_order = bp.RETX_SMALLEST_CID
14 | else
15 | retx_order = bp.RETX_OLDEST_BUNDLE
16 | end
17 |
18 | local src_node = 4
19 | local src_serv = 3
20 | local dst_node = 72
21 | local dst_serv = 43
22 |
23 | local num_bundles = 8
24 | local timeout = 1
25 | local cid_reuse = (retx_order == bp.RETX_SMALLEST_CID) and 0 or 1
26 | local attributes = {cid_reuse=cid_reuse, retransmit_order=retx_order, active_table_size=num_bundles, timeout=timeout}
27 |
28 | local sender = bplib.open(src_node, src_serv, dst_node, dst_serv, store, attributes)
29 |
30 | -- Test --
31 |
32 | -----------------------------------------------------------------------
33 | print(string.format('%s/%s: Test 1 - walk active bundle', store, src))
34 | for i=1,num_bundles do
35 | payload = string.format('HELLO WORLD %d', i)
36 | print("Generating... " .. payload)
37 |
38 | -- store payload --
39 | rc, flags = sender:store(payload, 1000)
40 | runner.check(rc)
41 | runner.check(bp.check_flags(flags, {}), "flags set on store")
42 |
43 | -- load bundle --
44 | rc, bundle, flags = sender:load(1000)
45 | runner.check(rc)
46 | runner.check(bundle ~= nil)
47 | runner.check(bp.check_flags(flags, {}), "flags set on load")
48 |
49 | -- check payload --
50 | runner.check(bp.find_payload(bundle, payload), string.format('Error - could not find payload: %s', payload))
51 |
52 | -- Timed-Out Load
53 | bplib.sleep(timeout + 1)
54 | for j=1,i do
55 | payload = string.format('HELLO WORLD %d', j)
56 |
57 | -- load bundle --
58 | rc, bundle, flags = sender:load(1000)
59 | runner.check(rc)
60 | runner.check(bundle ~= nil, string.format('Error - failed to load payload: %s', payload))
61 | runner.check(bp.check_flags(flags, {}), "flags set on load")
62 |
63 | -- check payload --
64 | if bundle then
65 | runner.check(bp.find_payload(bundle, payload), string.format('Error - could not find payload: %s', payload))
66 | end
67 | end
68 | end
69 |
70 | -- Clean Up --
71 |
72 | sender:flush()
73 | sender:close()
74 |
75 | runner.cleanup(bplib, store)
76 |
77 | -- Report Results --
78 |
79 | runner.report(bplib)
80 |
81 |
--------------------------------------------------------------------------------
/binding/lua/test/ut_attributes.lua:
--------------------------------------------------------------------------------
1 | local bplib = require("bplib")
2 | local runner = require("bptest")
3 | local bp = require("bp")
4 | local src = runner.srcscript()
5 | local rd = runner.rootdir(arg[0])
6 |
7 | -- Setup --
8 |
9 | store = arg[1] or "RAM"
10 | runner.setup(bplib, store)
11 |
12 | -- Test --
13 |
14 | -----------------------------------------------------------------------
15 | print(string.format('%s/%s: Test 1 - lifetime', store, src))
16 | lifetime = 100
17 | attributes = {lifetime=lifetime}
18 | ch = bplib.open(4, 3, 72, 43, store, attributes)
19 | runner.check(ch ~= nil)
20 | if ch then
21 | rc, d = ch:getopt("LIFETIME")
22 | runner.check(rc == true)
23 | runner.check(d == lifetime, string.format('Failed to set lifetime to %d, value was %d instead\n', lifetime, d))
24 | ch:close()
25 | end
26 |
27 | -----------------------------------------------------------------------
28 | print(string.format('%s/%s: Test 2 - active table size', store, src))
29 | active_table_size = 10
30 | attributes = {active_table_size=active_table_size}
31 | ch = bplib.open(4, 3, 72, 43, store, attributes)
32 | runner.check(ch ~= nil)
33 | if ch then
34 | -- fill table --
35 | for i=1,active_table_size do
36 | payload = string.format('HELLO WORLD %d', i)
37 |
38 | -- store payload --
39 | rc, flags = ch:store(payload, 1000)
40 | runner.check(rc)
41 | runner.check(bp.check_flags(flags, {}), "flags set on store")
42 |
43 | -- load bundle --
44 | rc, bundle, flags = ch:load(1000)
45 | runner.check(rc)
46 | runner.check(bundle ~= nil)
47 | runner.check(bp.check_flags(flags, {}), "flags set on load")
48 | end
49 |
50 | -- full table --
51 | rc, bundle, flags = ch:load(1000)
52 | runner.check(rc == false)
53 | runner.check(bundle == nil)
54 | runner.check(bp.check_flags(flags, {"activetablewrap"}))
55 |
56 | -- close channel --
57 | ch:flush()
58 | ch:close()
59 | end
60 |
61 | -- Clean Up --
62 |
63 | runner.cleanup(bplib, store)
64 |
65 | -- Report Results --
66 |
67 | runner.report(bplib)
68 |
69 |
--------------------------------------------------------------------------------
/binding/lua/test/ut_bundle_timeout.lua:
--------------------------------------------------------------------------------
1 | local bplib = require("bplib")
2 | local runner = require("bptest")
3 | local bp = require("bp")
4 | local rd = runner.rootdir(arg[0])
5 | local src = runner.srcscript()
6 |
7 | -- Setup --
8 |
9 | local store = arg[1] or "RAM"
10 | runner.setup(bplib, store)
11 |
12 | local src_node = 4
13 | local src_serv = 3
14 | local dst_node = 72
15 | local dst_serv = 43
16 |
17 | local num_bundles = 10
18 | local timeout = 5
19 |
20 | local sender = bplib.open(src_node, src_serv, dst_node, dst_serv, store)
21 |
22 | rc = sender:setopt("TIMEOUT", timeout)
23 | runner.check(rc)
24 |
25 | -- Test --
26 |
27 | -----------------------------------------------------------------------
28 | print(string.format('%s/%s: Test 1 - store bundles', store, src))
29 | for i=1,num_bundles do
30 | payload = string.format('HELLO WORLD %d', i)
31 |
32 | -- store payload --
33 | rc, flags = sender:store(payload, 1000)
34 | runner.check(rc)
35 | runner.check(bp.check_flags(flags, {}), "flags set on store")
36 | end
37 |
38 | -----------------------------------------------------------------------
39 | print(string.format('%s/%s: Test 2 - load bundles', store, src))
40 | for i=1,num_bundles do
41 | payload = string.format('HELLO WORLD %d', i)
42 |
43 | -- load bundle --
44 | rc, bundle, flags = sender:load(1000)
45 | runner.check(rc)
46 | runner.check(bundle ~= nil)
47 | runner.check(bp.check_flags(flags, {}), "flags set on load")
48 | runner.check(bp.find_payload(bundle, payload), string.format('Error - wrong payload when checking for %s', payload))
49 | end
50 |
51 | -----------------------------------------------------------------------
52 | print(string.format('%s/%s: Test 4 - no bundle', store, src))
53 | rc, bundle, flags = sender:load(1000)
54 | runner.check(rc == false)
55 | runner.check(bundle == nil)
56 |
57 | -----------------------------------------------------------------------
58 | print(string.format('%s/%s: Test 5 - timeout bundle', store, src))
59 | payload = string.format('HELLO WORLD %d', 1)
60 | bplib.sleep(timeout+1)
61 |
62 | -- load timedout bundle --
63 | rc, bundle, flags = sender:load(1000)
64 | runner.check(rc)
65 | runner.check(bundle ~= nil)
66 | runner.check(bp.check_flags(flags, {}), "flags set on load")
67 | runner.check(bp.find_payload(bundle, payload), string.format('Error - wrong payload when checking for %s', payload))
68 |
69 | -- Clean Up --
70 |
71 | sender:flush()
72 | sender:close()
73 |
74 | runner.cleanup(bplib, store)
75 |
76 | -- Report Results --
77 |
78 | runner.report(bplib)
79 |
80 |
--------------------------------------------------------------------------------
/binding/lua/test/ut_dacs_continuous.lua:
--------------------------------------------------------------------------------
1 | local bplib = require("bplib")
2 | local runner = require("bptest")
3 | local bp = require("bp")
4 | local rd = runner.rootdir(arg[0])
5 | local src = runner.srcscript()
6 |
7 | -- Setup --
8 |
9 | local store = arg[1] or "RAM"
10 | runner.setup(bplib, store)
11 |
12 | local src_node = 4
13 | local src_serv = 3
14 | local dst_node = 72
15 | local dst_serv = 43
16 |
17 | local num_bundles = 512
18 | local timeout = 10
19 |
20 | local sender = bplib.open(src_node, src_serv, dst_node, dst_serv, store)
21 | local receiver = bplib.open(dst_node, dst_serv, src_node, src_serv, store)
22 |
23 | rc = receiver:setopt("DACS_RATE", timeout)
24 | runner.check(rc)
25 |
26 | -- Test --
27 |
28 | -----------------------------------------------------------------------
29 | print(string.format('%s/%s: Test 1 - continuous sequence', store, src))
30 | for i=1,num_bundles do
31 | payload = string.format('HELLO WORLD %d', i)
32 |
33 | -- store payload --
34 | rc, flags = sender:store(payload, 1000)
35 | runner.check(rc)
36 | runner.check(bp.check_flags(flags, {}), "flags set on store")
37 |
38 | -- load bundle --
39 | rc, bundle, flags = sender:load(1000)
40 | runner.check(rc)
41 | runner.check(bundle ~= nil)
42 | runner.check(bp.check_flags(flags, {}), "flags set on load")
43 | runner.check(bp.find_payload(bundle, payload), string.format('Error - wrong payload when checking for %s', payload))
44 |
45 | -- process bundle --
46 | rc, flags = receiver:process(bundle, 1000)
47 | runner.check(rc)
48 | runner.check(bp.check_flags(flags, {}), "flags set on process")
49 | end
50 |
51 | -- check stats --
52 | rc, stats = receiver:stats()
53 | runner.check(bp.check_stats(stats, {stored_payloads=num_bundles}))
54 |
55 | for i=1,num_bundles do
56 | payload = string.format('HELLO WORLD %d', i)
57 |
58 | -- accept bundle --
59 | rc, app_payload, flags = receiver:accept(1000)
60 | runner.check(rc)
61 | runner.check(bp.check_flags(flags, {}))
62 | runner.check(bp.match_payload(app_payload, payload), string.format('Error - payload %s did not match: %s', app_payload, payload))
63 | end
64 |
65 | -- check stats --
66 | rc, stats = sender:stats()
67 | runner.check(bp.check_stats(stats, {transmitted_bundles=num_bundles, stored_bundles=num_bundles, active_bundles=num_bundles}))
68 | rc, stats = receiver:stats()
69 | runner.check(bp.check_stats(stats, {stored_payloads=0, received_bundles=num_bundles, delivered_payloads=num_bundles}))
70 |
71 | -- load DACS --
72 | bplib.sleep(timeout)
73 | rc, bundle, flags = receiver:load(1000)
74 | runner.check(rc)
75 | runner.check(bundle ~= nil)
76 | runner.check(bp.check_flags(flags, {"routeneeded"}))
77 |
78 | -- process DACS --
79 | rc, flags = sender:process(bundle, 1000)
80 | runner.check(rc, string.format('Error(%d) - failed to process DACS: %s', errno, rc))
81 | runner.check(bp.check_flags(flags, {}))
82 |
83 | -- timeout bundle --
84 | rc, bundle, flags = sender:load(1000)
85 | runner.check(rc == false)
86 | runner.check(bundle == nil)
87 | runner.check(bp.check_flags(flags, {}))
88 |
89 | -- check stats --
90 | rc, stats = sender:stats()
91 | runner.check(bp.check_stats(stats, {transmitted_bundles=num_bundles, stored_bundles=0, active_bundles=0, acknowledged_bundles=512, received_dacs=1}))
92 | rc, stats = receiver:stats()
93 | runner.check(bp.check_stats(stats, {stored_payloads=0, received_bundles=num_bundles, delivered_payloads=num_bundles, transmitted_dacs=1}))
94 |
95 | -- Clean Up --
96 |
97 | sender:close()
98 | receiver:close()
99 |
100 | runner.cleanup(bplib, store)
101 |
102 | -- Report Results --
103 |
104 | runner.report(bplib)
105 |
106 |
--------------------------------------------------------------------------------
/binding/lua/test/ut_eid2ipn.lua:
--------------------------------------------------------------------------------
1 | local bplib = require("bplib")
2 | local runner = require("bptest")
3 | local src = runner.srcscript()
4 |
5 | -- Setup --
6 |
7 | runner.setup(bplib, "RAM")
8 |
9 | -- Test --
10 |
11 | -----------------------------------------------------------------------
12 | print(string.format('%s: Test 1 - nominal', src))
13 | rc, node, serv = bplib.eid2ipn("ipn:4.3")
14 | runner.check('rc == true')
15 | runner.check('node == 4')
16 | runner.check('serv == 3')
17 |
18 | -----------------------------------------------------------------------
19 | print(string.format('%s: Test 2 - nominal', src))
20 | rc, node, serv = bplib.eid2ipn("ipn:72.43")
21 | runner.check('rc == true')
22 | runner.check('node == 72')
23 | runner.check('serv == 43')
24 |
25 | -----------------------------------------------------------------------
26 | print(string.format('%s: Test 3 - bad schema', src))
27 | rc, node, serv = bplib.eid2ipn("eid:72.43")
28 | runner.check('rc == false')
29 |
30 | -----------------------------------------------------------------------
31 | print(string.format('%s: Test 4 - bad node', src))
32 | rc, node, serv = bplib.eid2ipn("ipn:nasa.43")
33 | runner.check('rc == false')
34 |
35 | -----------------------------------------------------------------------
36 | print(string.format('%s: Test 5 - bad service', src))
37 | rc, node, serv = bplib.eid2ipn("ipn:72.nasa")
38 | runner.check('rc == false')
39 |
40 | -----------------------------------------------------------------------
41 | print(string.format('%s: Test 6 - no schema', src))
42 | rc, node, serv = bplib.eid2ipn("2343.343")
43 | runner.check('rc == false')
44 |
45 | -----------------------------------------------------------------------
46 | print(string.format('%s: Test 7 - too short', src))
47 | rc, node, serv = bplib.eid2ipn("ipn:23")
48 | runner.check('rc == false')
49 |
50 | -----------------------------------------------------------------------
51 | print(string.format('%s: Test 8 - too long', src))
52 | eid = "ipn:"
53 | for i=1,64,1 do eid = eid .. "123" end
54 | rc, node, serv = bplib.eid2ipn(eid)
55 | runner.check('rc == false')
56 |
57 | -- Clean Up --
58 |
59 | runner.cleanup(bplib, store)
60 |
61 | -- Report Results --
62 |
63 | runner.report(bplib)
64 |
65 |
--------------------------------------------------------------------------------
/binding/lua/test/ut_getset_opt.lua:
--------------------------------------------------------------------------------
1 | local bplib = require("bplib")
2 | local runner = require("bptest")
3 | local src = runner.srcscript()
4 |
5 | -- Setup --
6 |
7 | store = arg[1] or "RAM"
8 | runner.setup(bplib, store)
9 |
10 | src_node = 4
11 | src_serv = 3
12 | dst_node = 72
13 | dst_serv = 43
14 | rpt_node = 0
15 | rpt_serv = 0
16 | cst_node = 4
17 | cst_serv = 3
18 | dflt_paytype = 10
19 | dflt_timeout = 10
20 | dflt_bundlelen = 4096
21 | dflt_dacsrate = 5
22 | ch = bplib.open(src_node, src_serv, dst_node, dst_serv, store)
23 |
24 | local function check_option(opt, default, valid_new, invalid_new)
25 | default_val = default -- global for check
26 | valid_new_val = valid_new -- global for check
27 |
28 | rc, d = ch:getopt(opt)
29 | runner.check('rc == true')
30 | runner.check('d == default_val')
31 |
32 | rc = ch:setopt(opt, valid_new_val)
33 | runner.check('rc == true')
34 |
35 | rc, d = ch:getopt(opt)
36 | runner.check('rc == true')
37 | runner.check('d == valid_new_val')
38 |
39 | rc = ch:setopt(opt, invalid_new)
40 | runner.check('rc == false')
41 |
42 | rc, d = ch:getopt(opt)
43 | runner.check('rc == true')
44 | runner.check('d == valid_new_val')
45 |
46 | rc = ch:setopt(opt, default_val)
47 | runner.check('rc == true')
48 |
49 | rc, d = ch:getopt(opt)
50 | runner.check('rc == true')
51 | runner.check('d == default_val')
52 | end
53 |
54 | -- Test --
55 |
56 | -----------------------------------------------------------------------
57 | print(string.format('%s/%s: Test 1 - lifetime', store, src))
58 | check_option("LIFETIME", 86400, 100, "bob")
59 |
60 | -----------------------------------------------------------------------
61 | print(string.format('%s/%s: Test 2 - custody request', store, src))
62 | check_option("REQUEST_CUSTODY", true, false, "postman")
63 |
64 | -----------------------------------------------------------------------
65 | print(string.format('%s/%s: Test 3 - administrative record', store, src))
66 | check_option("ADMIN_RECORD", false, true, "dog")
67 |
68 | -----------------------------------------------------------------------
69 | print(string.format('%s/%s: Test 4 - integrity check', store, src))
70 | check_option("INTEGRITY_CHECK", true, false, "mailman")
71 |
72 | -----------------------------------------------------------------------
73 | print(string.format('%s/%s: Test 5 - allow fragmentation', store, src))
74 | check_option("ALLOW_FRAGMENTATION", false, true, "tightrope")
75 |
76 | -----------------------------------------------------------------------
77 | print(string.format('%s/%s: Test 6 - ignore expiration', store, src))
78 | check_option("IGNORE_EXPIRATION", false, true, "ballgame")
79 |
80 | -----------------------------------------------------------------------
81 | print(string.format('%s/%s: Test 7 - payload crc', store, src))
82 | check_option("CIPHER_SUITE", dflt_paytype, 3, "billy")
83 |
84 | -----------------------------------------------------------------------
85 | print(string.format('%s/%s: Test 8 - timeout', store, src))
86 | check_option("TIMEOUT", dflt_timeout, 50, "santa")
87 |
88 | -----------------------------------------------------------------------
89 | print(string.format('%s/%s: Test 9 - bundle length', store, src))
90 | check_option("MAX_LENGTH", dflt_bundlelen, 5000, "elves")
91 |
92 | -----------------------------------------------------------------------
93 | print(string.format('%s/%s: Test 10 - custody id reuse', store, src))
94 | check_option("CID_REUSE", false, true, "organ")
95 |
96 | -----------------------------------------------------------------------
97 | print(string.format('%s/%s: Test 11 - acs rate', store, src))
98 | check_option("DACS_RATE", dflt_dacsrate, 60, "tea")
99 |
100 | -- Clean Up --
101 |
102 | ch:close()
103 |
104 | runner.cleanup(bplib, store)
105 |
106 | -- Report Results --
107 |
108 | runner.report(bplib)
109 |
110 |
--------------------------------------------------------------------------------
/binding/lua/test/ut_ipn2eid.lua:
--------------------------------------------------------------------------------
1 | local bplib = require("bplib")
2 | local runner = require("bptest")
3 | local src = runner.srcscript()
4 |
5 | -- Setup --
6 |
7 | runner.setup(bplib, "RAM")
8 |
9 | -- Test --
10 |
11 | -----------------------------------------------------------------------
12 | print(string.format('%s: Test 1 - nominal', src))
13 | rc, eid = bplib.ipn2eid(4, 3)
14 | runner.check('rc == true')
15 | runner.check('eid == "ipn:4.3"')
16 |
17 | -----------------------------------------------------------------------
18 | print(string.format('%s: Test 2 - nominal', src))
19 | rc, eid = bplib.ipn2eid(72, 43)
20 | runner.check('rc == true')
21 | runner.check('eid == "ipn:72.43"')
22 |
23 | -----------------------------------------------------------------------
24 | print(string.format('%s: Test 3 - bad node parameter', src))
25 | rc, eid = bplib.ipn2eid("seventy two", 43)
26 | runner.check('rc == false')
27 |
28 | -----------------------------------------------------------------------
29 | print(string.format('%s: Test 4 - bad service parameter', src))
30 | rc, eid = bplib.ipn2eid(72, "forty three")
31 | runner.check('rc == false')
32 |
33 | -- Clean Up --
34 |
35 | runner.cleanup(bplib, store)
36 |
37 | -- Report Results --
38 |
39 | runner.report(bplib)
40 |
41 |
--------------------------------------------------------------------------------
/binding/lua/test/ut_memusage.lua:
--------------------------------------------------------------------------------
1 | local bplib = require("bplib")
2 | local runner = require("bptest")
3 | local bp = require("bp")
4 | local rd = runner.rootdir(arg[0])
5 | local src = runner.srcscript()
6 |
7 | -- Setup --
8 |
9 | local store = arg[1] or "RAM"
10 | runner.setup(bplib, store)
11 |
12 | local src_node = 4
13 | local src_serv = 3
14 | local dst_node = 72
15 | local dst_serv = 43
16 |
17 | local num_bundles = 128
18 | local timeout = 2
19 |
20 | -- Test --
21 |
22 | -----------------------------------------------------------------------
23 | print(string.format('%s/%s: Test 1 - store bundles and close', store, src))
24 |
25 | start_currmem, start_highmem = bplib.memstat()
26 | print(string.format('Before Open: %8d %8d', start_currmem, start_highmem))
27 |
28 | -- open channel --
29 | local sender = bplib.open(src_node, src_serv, dst_node, dst_serv, store)
30 | currmem, highmem = bplib.memstat()
31 | print(string.format('After Open: %8d %8d', currmem, highmem))
32 |
33 | -- store payloads --
34 | for i=1,num_bundles do
35 | payload = string.format('HELLO WORLD %d', i)
36 | rc, flags = sender:store(payload, 1000)
37 | end
38 | currmem, highmem = bplib.memstat()
39 | print(string.format('After Store: %8d %8d', currmem, highmem))
40 |
41 | -- close channel --
42 | sender:close()
43 | currmem, highmem = bplib.memstat()
44 | print(string.format('After Close: %8d %8d', currmem, highmem))
45 |
46 | -- check memory usage --
47 | runner.check(highmem ~= 0, "No memory allocated")
48 | runner.check(currmem == start_currmem, "Memory not cleaned up")
49 |
50 | -- Clean Up --
51 |
52 | runner.cleanup(bplib, store)
53 |
54 | -- Report Results --
55 |
56 | runner.report(bplib)
57 |
58 |
--------------------------------------------------------------------------------
/binding/lua/test/ut_open_close.lua:
--------------------------------------------------------------------------------
1 | local bplib = require("bplib")
2 | local runner = require("bptest")
3 | local src = runner.srcscript()
4 | local rd = runner.rootdir(arg[0])
5 |
6 | -- Setup --
7 |
8 | store = arg[1] or "RAM"
9 | runner.setup(bplib, store)
10 |
11 | max_channels = 4
12 | ch = {}
13 |
14 | -- Test --
15 |
16 | -----------------------------------------------------------------------
17 | print(string.format('%s/%s: Test 1 - nominal', store, src))
18 | ch[1] = bplib.open(4, 3, 72, 43, store)
19 | runner.check('ch[1]')
20 | ch[1]:close()
21 |
22 | -----------------------------------------------------------------------
23 | print(string.format('%s/%s: Test 2 - multiple channels', store, src))
24 | for i=1,max_channels do
25 | ch[i] = bplib.open(4, i, 72, 43, store)
26 | eval = string.format('ch[%d]', i)
27 | runner.check(eval)
28 | end
29 | for i=1,max_channels do
30 | ch[i]:close()
31 | end
32 |
33 | -----------------------------------------------------------------------
34 | print(string.format('%s/%s: Test 3 - out of order channel create', store, src))
35 | ch[1] = bplib.open(4, 1, 72, 43, store)
36 | runner.check('ch[1]')
37 | ch[2] = bplib.open(4, 2, 72, 43, store)
38 | runner.check('ch[2]')
39 | ch[3] = bplib.open(4, 3, 72, 43, store)
40 | runner.check('ch[3]')
41 | ch[4] = bplib.open(4, 4, 72, 43, store)
42 | runner.check('ch[4]')
43 | ch[2]:close()
44 | ch[4]:close()
45 | ch[2] = bplib.open(4, 2, 72, 43, store)
46 | runner.check('ch[2]')
47 | ch[4] = bplib.open(4, 4, 72, 43, store)
48 | runner.check('ch[4]')
49 | ch[1]:close()
50 | ch[2]:close()
51 | ch[3]:close()
52 | ch[4]:close()
53 |
54 | -----------------------------------------------------------------------
55 | print(string.format('%s/%s: Test 4 - closed channel access', store, src))
56 | ch[1] = bplib.open(4, 1, 72, 43, store)
57 | runner.check('ch[1]')
58 | ch[1]:close()
59 | rc, dstnode = ch[1]:getopt("TIMEOUT")
60 | runner.check('rc == false')
61 |
62 | -----------------------------------------------------------------------
63 | print(string.format('%s/%s: Test 5 - invalid store', store, src))
64 | ch[1] = bplib.open(4, 1, 72, 43, "PARSLEY")
65 | runner.check('ch[1] == nil')
66 |
67 | -- Clean Up --
68 |
69 | runner.cleanup(bplib, store)
70 |
71 | -- Report Results --
72 |
73 | runner.report(bplib)
74 |
75 |
--------------------------------------------------------------------------------
/binding/lua/test/ut_route.lua:
--------------------------------------------------------------------------------
1 | local bplib = require("bplib")
2 | local runner = require("bptest")
3 | local bp = require("bp")
4 | local src = runner.srcscript()
5 |
6 | -- Setup --
7 |
8 | local store = "RAM"
9 | runner.setup(bplib, store)
10 |
11 | local src_node = 4
12 | local src_serv = 3
13 | local dst_node = 72
14 | local dst_serv = 43
15 |
16 | local sender = bplib.open(src_node, src_serv, dst_node, dst_serv, store)
17 |
18 | rc, flags = sender:store("HELLO WORLD", 1000)
19 | runner.check(rc)
20 | rc, bundle, flags = sender:load(1000)
21 | runner.check(rc)
22 | runner.check(bp.check_flags(flags, {}))
23 |
24 | -- Test --
25 |
26 | -----------------------------------------------------------------------
27 | print(string.format('%s: Test 1 - nominal', src))
28 | rc, node, serv = bplib.route(bundle)
29 | runner.check(rc)
30 | runner.check(node == dst_node)
31 | runner.check(serv == dst_serv)
32 |
33 | -- Clean Up --
34 |
35 | sender:flush()
36 | sender:close()
37 |
38 | runner.cleanup(bplib, store)
39 |
40 | -- Report Results --
41 |
42 | runner.report(bplib)
43 |
44 |
--------------------------------------------------------------------------------
/binding/lua/test/ut_unittest.lua:
--------------------------------------------------------------------------------
1 | local bplib = require("bplib")
2 | local runner = require("bptest")
3 | local src = runner.srcscript()
4 |
5 | -- Setup --
6 |
7 | local test = arg[1] or "ALL"
8 | runner.setup(bplib, "RAM")
9 |
10 | -- Test --
11 |
12 | -----------------------------------------------------------------------
13 | print(string.format('\n%s: Test 1 - unittest(%s)', src, test))
14 | local numfails = bplib.unittest(test)
15 | runner.check(numfails == 0, string.format('Failures detected by bplib unittest: %d', numfails))
16 |
17 | -- Clean Up --
18 |
19 | runner.cleanup(bplib, store)
20 |
21 | -- Report Results --
22 |
23 | runner.report(bplib)
24 |
25 |
--------------------------------------------------------------------------------
/binding/lua/test/ut_wrap_response.lua:
--------------------------------------------------------------------------------
1 | local bplib = require("bplib")
2 | local runner = require("bptest")
3 | local bp = require("bp")
4 | local src = runner.srcscript()
5 |
6 | -- Setup --
7 |
8 | local store = arg[1] or "RAM"
9 | runner.setup(bplib, store)
10 |
11 | local retx_order = arg[2] or bp.RETX_SMALLEST_CID
12 |
13 | local src_node = 4
14 | local src_serv = 3
15 | local dst_node = 72
16 | local dst_serv = 43
17 |
18 | local num_bundles = 16384
19 | local timeout = 10
20 | local attributes = {retransmit_order=retx_order}
21 |
22 | local sender = bplib.open(src_node, src_serv, dst_node, dst_serv, store, attributes)
23 |
24 | local exp_stats = { lost = 0,
25 | expired = 0,
26 | unrecognized = 0,
27 | transmitted_bundles = 0,
28 | transmitted_dacs = 0,
29 | retransmitted_bundles = 0,
30 | delivered_payloads = 0,
31 | received_bundles = 0,
32 | forwarded_bundles = 0,
33 | received_dacs = 0,
34 | stored_bundles = 0,
35 | stored_payloads = 0,
36 | stored_dacs = 0,
37 | acknowledged_bundles = 0,
38 | active_bundles = 0 }
39 |
40 | runner.check(sender:setopt("TIMEOUT", timeout))
41 |
42 | -- Test --
43 |
44 | -----------------------------------------------------------------------
45 | print(string.format('%s/%s: Test 1 - store/load bundles', store, src))
46 | for i=1,num_bundles do
47 | payload = string.format('HELLO WORLD %d', i)
48 |
49 | -- store payload --
50 | rc, flags = sender:store(payload, 1000)
51 | runner.check(rc)
52 | runner.check(bp.check_flags(flags, {}), "flags set on store")
53 | rc, stats = sender:stats()
54 | runner.check(rc)
55 | exp_stats["stored_bundles"] = exp_stats["stored_bundles"] + 1
56 | runner.check(bp.check_stats(stats, exp_stats))
57 |
58 | -- load bundle --
59 | rc, bundle, flags = sender:load(1000)
60 | runner.check(rc)
61 | runner.check(bundle ~= nil)
62 | runner.check(bp.check_flags(flags, {}), "flags set on load")
63 | rc, stats = sender:stats()
64 | runner.check(rc)
65 | exp_stats["active_bundles"] = exp_stats["active_bundles"] + 1
66 | exp_stats["transmitted_bundles"] = exp_stats["transmitted_bundles"] + 1
67 | runner.check(bp.check_stats(stats, exp_stats))
68 |
69 | -- check payload --
70 | runner.check(bp.find_payload(bundle, payload), string.format('Error - could not find payload: %s', payload))
71 | end
72 |
73 | -----------------------------------------------------------------------
74 | print(string.format('%s/%s: Test 2 - timeout bundles', store, src))
75 | bplib.sleep(timeout + 1)
76 | for i=1,num_bundles do
77 | payload = string.format('HELLO WORLD %d', i)
78 |
79 | -- load bundle --
80 | rc, bundle, flags = sender:load(1000)
81 | runner.check(rc)
82 | runner.check(bundle ~= nil)
83 | runner.check(bp.check_flags(flags, {}))
84 | rc, stats = sender:stats()
85 | runner.check(rc)
86 | exp_stats["retransmitted_bundles"] = exp_stats["retransmitted_bundles"] + 1
87 | runner.check(bp.check_stats(stats, exp_stats))
88 |
89 | -- check payload --
90 | runner.check(bp.find_payload(bundle, payload), string.format('Error - could not find payload: %s', payload))
91 | end
92 |
93 | -----------------------------------------------------------------------
94 | print(string.format('%s/%s: Test 3 - wrap block', store, src))
95 |
96 | -- load new bundle, no room --
97 | rc, bundle, flags = sender:load(1000)
98 | runner.check(rc == false)
99 | runner.check(bundle == nil)
100 | runner.check(bp.check_flags(flags, {"activetablewrap"}))
101 | rc, stats = sender:stats()
102 | runner.check(rc)
103 | runner.check(bp.check_stats(stats, exp_stats))
104 |
105 | -- Clean Up --
106 |
107 | sender:flush()
108 | sender:close()
109 |
110 | runner.cleanup(bplib, store)
111 |
112 | -- Report Results --
113 |
114 | runner.report(bplib)
115 |
116 |
--------------------------------------------------------------------------------
/cache/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # Bundle Protocol Library (BPLib) CMake build recipe
4 | #
5 | # This is for the "cache" submodule, which applies only to the
6 | # v7 build.
7 | #
8 | ##################################################################
9 |
10 | add_library(bplib_cache OBJECT
11 | src/v7_cache.c
12 | src/v7_cache_custody.c
13 | src/v7_cache_fsm.c
14 | )
15 |
16 | target_include_directories(bplib_cache PRIVATE
17 | $
18 | $
19 | $
20 | )
21 | target_include_directories(bplib_cache PUBLIC
22 | ${CMAKE_CURRENT_SOURCE_DIR}/inc
23 | $
24 | $
25 | )
26 |
27 | # Add unit test coverage subdirectory
28 | if(BPLIB_ENABLE_UNIT_TESTS)
29 | add_subdirectory(ut-stubs)
30 | add_subdirectory(ut-coverage)
31 | endif(BPLIB_ENABLE_UNIT_TESTS)
32 |
--------------------------------------------------------------------------------
/cache/inc/v7_cache.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | #ifndef v7_cache_h
22 | #define v7_cache_h
23 |
24 | /******************************************************************************
25 | INCLUDES
26 | ******************************************************************************/
27 |
28 | #include "bplib.h"
29 | #include "bplib_os.h"
30 |
31 | #include "bplib_api_types.h"
32 |
33 | /******************************************************************************
34 | TYPEDEFS
35 | ******************************************************************************/
36 | typedef enum bplib_cache_module_type
37 | {
38 | bplib_cache_module_type_none,
39 | bplib_cache_module_type_internal,
40 | bplib_cache_module_type_offload
41 | } bplib_cache_module_type_t;
42 |
43 | typedef enum bplib_cache_module_valtype
44 | {
45 | bplib_cache_module_valtype_none,
46 | bplib_cache_module_valtype_integer,
47 | bplib_cache_module_valtype_string
48 | } bplib_cache_module_valtype_t;
49 |
50 | typedef enum bplib_cache_confkey
51 | {
52 | bplib_cache_confkey_none,
53 | bplib_cache_confkey_offload_base_dir,
54 | } bplib_cache_confkey_t;
55 |
56 | struct bplib_cache_module_api
57 | {
58 | bplib_cache_module_type_t module_type;
59 | bplib_mpool_block_t *(*instantiate)(bplib_mpool_ref_t parent_ref, void *init_arg);
60 | int (*configure)(bplib_mpool_block_t *svc, int key, bplib_cache_module_valtype_t vt, const void *val);
61 | int (*query)(bplib_mpool_block_t *svc, int key, bplib_cache_module_valtype_t vt, const void **val);
62 | int (*start)(bplib_mpool_block_t *svc);
63 | int (*stop)(bplib_mpool_block_t *svc);
64 | };
65 |
66 | typedef struct bplib_cache_offload_api
67 | {
68 | bplib_cache_module_api_t std;
69 | int (*offload)(bplib_mpool_block_t *svc, bp_sid_t *sid, bplib_mpool_block_t *pblk);
70 | int (*restore)(bplib_mpool_block_t *svc, bp_sid_t sid, bplib_mpool_block_t **pblk);
71 | int (*release)(bplib_mpool_block_t *svc, bp_sid_t sid);
72 | } bplib_cache_offload_api_t;
73 |
74 | /******************************************************************************
75 | PROTOTYPES
76 | ******************************************************************************/
77 |
78 | /* Service API */
79 | bp_handle_t bplib_cache_attach(bplib_routetbl_t *tbl, const bp_ipn_addr_t *service_addr);
80 | int bplib_cache_detach(bplib_routetbl_t *tbl, const bp_ipn_addr_t *service_addr);
81 |
82 | bp_handle_t bplib_cache_register_module_service(bplib_routetbl_t *tbl, bp_handle_t cache_intf_id,
83 | const bplib_cache_module_api_t *api, void *init_arg);
84 | int bplib_cache_configure(bplib_routetbl_t *tbl, bp_handle_t module_intf_id, int key, bplib_cache_module_valtype_t vt,
85 | const void *val);
86 | int bplib_cache_query(bplib_routetbl_t *tbl, bp_handle_t module_intf_id, int key, bplib_cache_module_valtype_t vt,
87 | const void **val);
88 | int bplib_cache_start(bplib_routetbl_t *tbl, bp_handle_t module_intf_id);
89 | int bplib_cache_stop(bplib_routetbl_t *tbl, bp_handle_t module_intf_id);
90 |
91 | void bplib_cache_debug_scan(bplib_routetbl_t *tbl, bp_handle_t intf_id);
92 |
93 | #endif /* v7_cache_h */
94 |
--------------------------------------------------------------------------------
/cache/ut-coverage/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # coverage test build recipe
4 | #
5 | # This CMake file contains the recipe for building the coverage tests.
6 | # It is invoked from the parent directory when unit tests are enabled.
7 | #
8 | ##################################################################
9 |
10 | add_library(utobj_bplib_cache OBJECT
11 | ../src/v7_cache.c
12 | ../src/v7_cache_custody.c
13 | ../src/v7_cache_fsm.c
14 | )
15 |
16 | target_compile_definitions(utobj_bplib_cache PRIVATE
17 | $
18 | $
19 | )
20 |
21 | target_compile_options(utobj_bplib_cache PRIVATE
22 | $
23 | $
24 | )
25 |
26 | target_include_directories(utobj_bplib_cache PRIVATE
27 | $
28 | $
29 | )
30 |
31 | # Add executable
32 | add_executable(coverage-bplib_cache-testrunner
33 | test_bplib_cache_setup.c
34 | test_v7_cache.c
35 | test_v7_cache_custody.c
36 | test_v7_cache_fsm.c
37 | $
38 | )
39 |
40 | target_include_directories(coverage-bplib_cache-testrunner PRIVATE
41 | ../src
42 | ${CMAKE_CURRENT_SOURCE_DIR}/inc
43 | $
44 | )
45 |
46 | target_link_libraries(coverage-bplib_cache-testrunner PUBLIC
47 | ut_coverage_link
48 | coverage-bplib-stubs
49 | bplib_base_stubs
50 | bplib_mpool_stubs
51 | bplib_common_stubs
52 | bplib_os_stubs
53 | bplib_v7_stubs
54 | ut_assert
55 | )
56 |
57 | add_test(coverage-bplib_cache-testrunner coverage-bplib_cache-testrunner)
58 |
59 | # Install the executables to a staging area for test in cross environments
60 | if (INSTALL_TARGET_LIST)
61 | foreach(TGT ${INSTALL_TARGET_LIST})
62 | install(TARGETS coverage-bplib_cache-testrunner DESTINATION ${TGT}/${UT_INSTALL_SUBDIR})
63 | endforeach()
64 | endif()
65 |
--------------------------------------------------------------------------------
/cache/ut-coverage/test_bplib_cache.h:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3 | *
4 | * Copyright (c) 2020 United States Government as represented by the
5 | * Administrator of the National Aeronautics and Space Administration.
6 | * All Rights Reserved.
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 | * not use this file except in compliance with the License. You may obtain
10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | ************************************************************************/
18 |
19 | #ifndef TEST_BPLIB_CACHE_H
20 | #define TEST_BPLIB_CACHE_H
21 |
22 | #include "utassert.h"
23 | #include "utstubs.h"
24 | #include "uttest.h"
25 | #include "bplib_api_types.h"
26 | #include "v7_cache_internal.h"
27 |
28 | void test_setup_cache_state(bplib_mpool_block_t *sblk);
29 | void UT_cache_sizet_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
30 | void UT_cache_uint64_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
31 | void UT_cache_AltHandler_PointerReturn(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
32 | void UT_cache_egress_AltHandler_PointerReturn(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
33 | void UT_cache_valid_bphandle_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
34 | void UT_cache_bool_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
35 | void UT_cache_GetTime_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
36 | void UT_cache_int8_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
37 | void TestBplibCacheCustody_Register(void);
38 | void TestBplibCacheFsm_Register(void);
39 | void TestBplibCache_Register(void);
40 | bplib_mpool_block_t *test_bplib_cache_instantiate_stub(bplib_mpool_ref_t parent_ref, void *init_arg);
41 | int test_bplib_cache_configure_stub(bplib_mpool_block_t *svc, int key, bplib_cache_module_valtype_t vt,
42 | const void *val);
43 | int test_bplib_cache_query_stub(bplib_mpool_block_t *svc, int key, bplib_cache_module_valtype_t vt, const void **val);
44 | int test_bplib_cache_startstop_stub(bplib_mpool_block_t *svc);
45 | int test_bplib_cache_offload_stub(bplib_mpool_block_t *svc, bp_sid_t *sid, bplib_mpool_block_t *pblk);
46 | int test_bplib_cache_restore_stub(bplib_mpool_block_t *svc, bp_sid_t sid, bplib_mpool_block_t **pblk);
47 | int test_bplib_cache_release_stub(bplib_mpool_block_t *svc, bp_sid_t sid);
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/cache/ut-stubs/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # Bundle Protocol Library (BPLib) CMake build recipe
4 | #
5 | # This is for the "cache" stub functions
6 | #
7 | ##################################################################
8 |
9 | add_library(bplib_cache_stubs STATIC
10 | v7_cache_stubs.c
11 | )
12 |
13 | target_include_directories(bplib_cache_stubs PUBLIC
14 | $
15 | )
16 |
17 | target_link_libraries(bplib_cache_stubs PUBLIC
18 | ut_assert
19 | )
20 |
--------------------------------------------------------------------------------
/common/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # Bundle Protocol Library (BPLib) CMake build recipe
4 | #
5 | # This is for the "common" submodule
6 | #
7 | ##################################################################
8 |
9 | set(bplib_common_SOURCES
10 | src/crc.c
11 | src/v7_rbtree.c
12 | )
13 |
14 | add_library(bplib_common OBJECT
15 | ${bplib_common_SOURCES}
16 | )
17 |
18 | target_include_directories(bplib_common PUBLIC
19 | ${CMAKE_CURRENT_SOURCE_DIR}/inc
20 | )
21 |
22 | target_include_directories(bplib_common PUBLIC
23 | $
24 | )
25 |
26 | if(BPLIB_ENABLE_UNIT_TESTS)
27 | add_subdirectory(ut-stubs)
28 | add_subdirectory(ut-coverage)
29 | add_subdirectory(ut-functional)
30 | endif(BPLIB_ENABLE_UNIT_TESTS)
31 |
--------------------------------------------------------------------------------
/common/inc/crc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | #ifndef CRC_H
22 | #define CRC_H
23 |
24 | /******************************************************************************
25 | INCLUDES
26 | ******************************************************************************/
27 |
28 | #include "bplib.h"
29 |
30 | /******************************************************************************
31 | DEFINES
32 | ******************************************************************************/
33 |
34 | /******************************************************************************
35 | TYPEDEFS
36 | ******************************************************************************/
37 |
38 | /* Standard parameters for calculating a CRC. */
39 | struct bplib_crc_parameters;
40 | typedef const struct bplib_crc_parameters bplib_crc_parameters_t;
41 |
42 | /*
43 | * CRC algorithms that are implemented in BPLIB
44 | * These definitions are always fixed/const
45 | */
46 | extern bplib_crc_parameters_t BPLIB_CRC_NONE;
47 | extern bplib_crc_parameters_t BPLIB_CRC16_X25;
48 | extern bplib_crc_parameters_t BPLIB_CRC32_CASTAGNOLI;
49 |
50 | /******************************************************************************
51 | PROTOTYPES
52 | ******************************************************************************/
53 |
54 | void bplib_crc_init(void);
55 |
56 | const char *bplib_crc_get_name(bplib_crc_parameters_t *params);
57 | uint8_t bplib_crc_get_width(bplib_crc_parameters_t *params);
58 | bp_crcval_t bplib_crc_initial_value(bplib_crc_parameters_t *params);
59 | bp_crcval_t bplib_crc_update(bplib_crc_parameters_t *params, bp_crcval_t crc, const void *data, size_t size);
60 | bp_crcval_t bplib_crc_finalize(bplib_crc_parameters_t *params, bp_crcval_t crc);
61 |
62 | bp_crcval_t bplib_crc_get(const void *data, const uint32_t length, bplib_crc_parameters_t *params);
63 |
64 | #endif /* CRC_H */
65 |
--------------------------------------------------------------------------------
/common/src/crc_private.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | #ifndef CRC_PRIVATE_H
22 | #define CRC_PRIVATE_H
23 |
24 | /******************************************************************************
25 | INCLUDES
26 | ******************************************************************************/
27 |
28 | #include "bplib.h"
29 | #include "crc.h"
30 |
31 | /******************************************************************************
32 | DEFINES
33 | ******************************************************************************/
34 |
35 | #define BPLIB_CRC16_X25_POLY 0x1021U
36 | #define BPLIB_CRC32_C_POLY 0x1EDC6F41U
37 |
38 | /******************************************************************************
39 | TYPEDEFS
40 | ******************************************************************************/
41 |
42 | /*
43 | * Definition of generic-ish CRC data digest function.
44 | * Updates the CRC based on the data in the given buffer.
45 | */
46 | typedef bp_crcval_t (*bplib_crc_digest_func_t)(bp_crcval_t crc, const void *data, size_t size);
47 |
48 | /*
49 | * Actual definition of CRC parameters
50 | */
51 | struct bplib_crc_parameters
52 | {
53 | const char *name; /* Name of the CRC. */
54 | uint8_t length; /* The number of bits in the CRC. */
55 | bool should_reflect_output; /* Whether to reflect the bits of the output crc. */
56 |
57 | const uint8_t *input_table; /* A ptr to a table for input translation (reflect or direct) */
58 | const void *xor_table; /* A ptr to a table with the precomputed XOR values. */
59 |
60 | bplib_crc_digest_func_t digest; /* externally-callable "digest" routine to update CRC with new data */
61 |
62 | bp_crcval_t initial_value; /* The value used to initialize a CRC (normalized). */
63 | bp_crcval_t final_xor; /* The final value to xor with the crc before returning (normalized). */
64 | };
65 |
66 | bp_crcval_t bplib_precompute_crc_byte(uint8_t width, uint8_t byte, bp_crcval_t polynomial);
67 | uint8_t bplib_precompute_reflection(uint8_t byte);
68 |
69 | extern uint8_t BPLIB_CRC_DIRECT_TABLE[256];
70 | extern uint8_t BPLIB_CRC_REFLECT_TABLE[256];
71 |
72 | #endif /* CRC_PRIVATE_H */
73 |
--------------------------------------------------------------------------------
/common/ut-coverage/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # coverage test build recipe
4 | #
5 | # This CMake file contains the recipe for building the coverage tests.
6 | # It is invoked from the parent directory when unit tests are enabled.
7 | #
8 | ##################################################################
9 |
10 | add_library(utobj_bplib_common OBJECT
11 | ../src/crc.c
12 | ../src/v7_rbtree.c
13 | )
14 |
15 | target_compile_definitions(utobj_bplib_common PRIVATE
16 | $
17 | $
18 | )
19 |
20 | target_compile_options(utobj_bplib_common PRIVATE
21 | $
22 | $
23 | )
24 |
25 | target_include_directories(utobj_bplib_common PRIVATE
26 | $
27 | $
28 | )
29 |
30 | # Add executable
31 | add_executable(coverage-bplib_common-testrunner
32 | test_bplib_common.c
33 | test_bplib_crc.c
34 | test_bplib_v7_rbtree.c
35 | $
36 | )
37 |
38 | target_include_directories(coverage-bplib_common-testrunner PRIVATE
39 | ../src
40 | $
41 | )
42 |
43 | target_link_libraries(coverage-bplib_common-testrunner PUBLIC
44 | ut_coverage_link
45 | ut_assert
46 | )
47 |
48 | add_test(coverage-bplib_common-testrunner coverage-bplib_common-testrunner)
49 |
50 | # Install the executables to a staging area for test in cross environments
51 | if (INSTALL_TARGET_LIST)
52 | foreach(TGT ${INSTALL_TARGET_LIST})
53 | install(TARGETS coverage-bplib_common-testrunner DESTINATION ${TGT}/${UT_INSTALL_SUBDIR})
54 | endforeach()
55 | endif()
56 |
--------------------------------------------------------------------------------
/common/ut-coverage/test_bplib_common.c:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3 | *
4 | * Copyright (c) 2020 United States Government as represented by the
5 | * Administrator of the National Aeronautics and Space Administration.
6 | * All Rights Reserved.
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 | * not use this file except in compliance with the License. You may obtain
10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | ************************************************************************/
18 |
19 | /*
20 | * Includes
21 | */
22 | #include "test_bplib_common.h"
23 |
24 | void UtTest_Setup(void)
25 | {
26 | UtTest_Add(TestBplibCommon_CRC_Execute, TestBplibCommon_CRC_Setup, NULL, "CRC");
27 |
28 | /* The RBT setup is only needed once, and serves for all RBT tests */
29 | UtTest_Add(NULL, TestBplibCommon_RBT_Setup, NULL, "RB Tree Setup");
30 | UtTest_Add(TestBplibCommon_RBT_Basics, NULL, NULL, "RB Tree Basic");
31 | UtTest_Add(TestBplibCommon_RBT_LeafNodeInsertDelete, NULL, NULL, "RB Tree Leaf Node Insert/Delete");
32 | UtTest_Add(TestBplibCommon_RBT_NonLeafDelete, NULL, NULL, "RB Tree Non Leaf Delete");
33 | UtTest_Add(TestBplibCommon_RBT_Unique, NULL, NULL, "RB Tree Unique Indices");
34 | UtTest_Add(TestBplibCommon_RBT_NonUnique, NULL, NULL, "RB Tree NonUnique Indices");
35 | UtTest_Add(TestBplibCommon_RBT_Iterator, NULL, NULL, "RB Tree Iterator");
36 | }
37 |
--------------------------------------------------------------------------------
/common/ut-coverage/test_bplib_common.h:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3 | *
4 | * Copyright (c) 2020 United States Government as represented by the
5 | * Administrator of the National Aeronautics and Space Administration.
6 | * All Rights Reserved.
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 | * not use this file except in compliance with the License. You may obtain
10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | ************************************************************************/
18 |
19 | #ifndef TEST_BPLIB_COMMON_H
20 | #define TEST_BPLIB_COMMON_H
21 |
22 | #include "utassert.h"
23 | #include "utstubs.h"
24 | #include "uttest.h"
25 |
26 | void TestBplibCommon_CRC_Setup(void);
27 | void TestBplibCommon_CRC_Execute(void);
28 |
29 | void TestBplibCommon_RBT_Setup(void);
30 | void TestBplibCommon_RBT_LeafNodeInsertDelete(void);
31 | void TestBplibCommon_RBT_NonLeafDelete(void);
32 | void TestBplibCommon_RBT_Basics(void);
33 | void TestBplibCommon_RBT_Unique(void);
34 | void TestBplibCommon_RBT_NonUnique(void);
35 | void TestBplibCommon_RBT_Iterator(void);
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/common/ut-functional/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # coverage test build recipe
4 | #
5 | # This CMake file contains the recipe for building the coverage tests.
6 | # It is invoked from the parent directory when unit tests are enabled.
7 | #
8 | ##################################################################
9 |
10 | # Add executable
11 | # this links with the normal FSW RB-Tree object, does not rebuild it
12 | add_executable(functional-bplib_rbtree-testrunner
13 | rbtest.c
14 | $
15 | )
16 |
17 | target_include_directories(functional-bplib_rbtree-testrunner PRIVATE
18 | $
19 | )
20 |
21 | target_link_libraries(functional-bplib_rbtree-testrunner PUBLIC
22 | ut_assert
23 | osal
24 | )
25 |
26 | add_test(functional-bplib_rbtree-testrunner functional-bplib_rbtree-testrunner)
27 |
28 | # Install the executables to a staging area for test in cross environments
29 | if (INSTALL_TARGET_LIST)
30 | foreach(TGT ${INSTALL_TARGET_LIST})
31 | install(TARGETS functional-bplib_rbtree-testrunner DESTINATION ${TGT}/${UT_INSTALL_SUBDIR})
32 | endforeach()
33 | endif()
34 |
--------------------------------------------------------------------------------
/common/ut-stubs/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # Bundle Protocol Library (BPLib) CMake build recipe
4 | #
5 | # This is for the "common" stub functions
6 | #
7 | ##################################################################
8 |
9 | add_library(bplib_common_stubs STATIC
10 | crc_stubs.c
11 | crc_stub_objs.c
12 | v7_rbtree_stubs.c
13 | )
14 |
15 | target_include_directories(bplib_common_stubs PUBLIC
16 | $
17 | )
18 |
19 | target_link_libraries(bplib_common_stubs PUBLIC
20 | ut_assert
21 | )
22 |
--------------------------------------------------------------------------------
/common/ut-stubs/crc_stub_objs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /**
22 | * @file
23 | *
24 | * Auto-Generated stub implementations for functions defined in crc header
25 | */
26 |
27 | #include "crc.h"
28 |
29 | struct bplib_crc_parameters
30 | {
31 | uint32_t stub;
32 | };
33 |
34 | bplib_crc_parameters_t BPLIB_CRC_NONE = {0};
35 | bplib_crc_parameters_t BPLIB_CRC16_X25 = {1};
36 | bplib_crc_parameters_t BPLIB_CRC32_CASTAGNOLI = {2};
37 |
--------------------------------------------------------------------------------
/doc/GSC_18318_Corp_CLA_form_1219.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nasa/bplib/08d80f67104d17655d522f4a048afb62095d5223/doc/GSC_18318_Corp_CLA_form_1219.pdf
--------------------------------------------------------------------------------
/doc/GSC_18318_Ind_CLA_form_1219.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nasa/bplib/08d80f67104d17655d522f4a048afb62095d5223/doc/GSC_18318_Ind_CLA_form_1219.pdf
--------------------------------------------------------------------------------
/doc/NOSA GSC-18318-1_0.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nasa/bplib/08d80f67104d17655d522f4a048afb62095d5223/doc/NOSA GSC-18318-1_0.pdf
--------------------------------------------------------------------------------
/doc/analysis_ic_c1_flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nasa/bplib/08d80f67104d17655d522f4a048afb62095d5223/doc/analysis_ic_c1_flow.png
--------------------------------------------------------------------------------
/doc/analysis_ic_c1_smooth.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nasa/bplib/08d80f67104d17655d522f4a048afb62095d5223/doc/analysis_ic_c1_smooth.png
--------------------------------------------------------------------------------
/doc/analysis_ic_c2_flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nasa/bplib/08d80f67104d17655d522f4a048afb62095d5223/doc/analysis_ic_c2_flow.png
--------------------------------------------------------------------------------
/doc/analysis_ic_c2_smooth.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nasa/bplib/08d80f67104d17655d522f4a048afb62095d5223/doc/analysis_ic_c2_smooth.png
--------------------------------------------------------------------------------
/doc/bp_api_architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nasa/bplib/08d80f67104d17655d522f4a048afb62095d5223/doc/bp_api_architecture.png
--------------------------------------------------------------------------------
/doc/bpv7-prototype.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nasa/bplib/08d80f67104d17655d522f4a048afb62095d5223/doc/bpv7-prototype.pdf
--------------------------------------------------------------------------------
/doc/dev_notes.md:
--------------------------------------------------------------------------------
1 | # Developer Notes
2 |
3 | [1. Directory Structure](#1-directory-structure)
4 | [2. Layered Architecture](#2-layered-architecture)
5 | [3. Customization and Extensions](#3-customization-and-extensions)
6 | [4. Coding Rules](#4-coding-rules)
7 |
8 |
9 | ## 1.0 Directory Structure
10 |
11 | ````
12 | bplib // library build system
13 | |-- binding // language bindings
14 | |-- lua // Lua scripting language
15 | |-- test // library unit test framework
16 | |-- common // utilities and data structures
17 | |-- doc // documentation
18 | |-- inc // public API headers
19 | |-- lib // high level protocol implementation
20 | |-- os // operating system abstractions
21 | |-- store // storage services
22 | |-- unittest // c-code unit tests
23 | |-- v6 // version 6 protocol implementation
24 | ````
25 |
26 | ## 2.0 Layered Architecture
27 |
28 | ````
29 | +-----------+
30 | | bplib |
31 | +-----------+
32 | |
33 | |
34 | +-----------+
35 | | v6 |
36 | +-----------+
37 | |________________________________________________
38 | || || | |
39 | +-----------+ +-----------+ +-----------+ +-----------+
40 | | pri | | pay | | bib | | cteb |
41 | +-----------+ +-----------+ +-----------+ +-----------+
42 | | |
43 | +-----------+ +-----------+
44 | | dacs | | sdnv |
45 | +-----------+ +-----------+
46 |
47 |
48 | +-----------+ +-----------+ +-----------+ +-----------+
49 | | rb_tree | | rh_hash | | cbuf | | crc |
50 | +-----------+ +-----------+ +-----------+ +-----------+
51 | ````
52 |
53 | ## 3.0 Customization and Extension
54 |
55 | #### Storage Service
56 |
57 | The storage service is provided at __run-time__ by the application. The storage service may be managed outside of the library and can contain its own application interfaces for
58 | configuring and statusing.
59 |
60 | #### Operating System Abstraction
61 |
62 | The operating system abstraction is provided at __compile-time__ and must supply all the functions exported by "bplib_os.h".
63 |
64 | Inside "bplib_os.h" there are two #defines that constrain the size of the numbers that the library supports:
65 | * BP_VAL_TYPE - the C type used to represent the largest integer value that can be used by the library.
66 | * BP_INDEX_TYPE - the C type used to represent an index into the active table.
67 |
68 | ## 4.0 Coding Rules
69 |
70 | #### Include Rules
71 |
72 | 1. An application may only include headers from the `inc/` directory.
73 |
74 | 2. All library modules may include "bplib.h" and "bundle_types.h".
75 |
76 | 3. The only inclusion of "bplib_os.h" occurs in "bplib.h"; library modules must include "bplib.h" to pull in "bplib_os.h".
77 |
78 | 4. A library module may only include headers from `common/` modules or from the modules in the layer directly below it in the architecture diagram.
79 |
80 | 5. No functions or data may be extern'ed in a header file (except in unit tests). All functions and data types should be pushed to the smallest scope of exposure as possible (i.e. functions only called within a module should be static, typedefs and defines only used within a module's source file should be defined in the source file instead of the header).
81 |
82 | #### Status Rules
83 |
84 | 1. All API functions return a return code as defined in the "bplib.h" list of return codes; and other value must be passed back through pointers.
85 |
86 | 2. Return codes are for use by application code, flags are for use by humans. An application should never need to look at the status flags.
87 |
88 | 3. Status flags are cumulative and should never be cleared in a library function, nor should they ever be used by a library function - they should only be set. The application is responsible for when the flags are cleared.
89 |
--------------------------------------------------------------------------------
/doc/diagrams.odg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nasa/bplib/08d80f67104d17655d522f4a048afb62095d5223/doc/diagrams.odg
--------------------------------------------------------------------------------
/doc/dtn-storage-simple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nasa/bplib/08d80f67104d17655d522f4a048afb62095d5223/doc/dtn-storage-simple.png
--------------------------------------------------------------------------------
/doc/dtn-storage-states.odg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nasa/bplib/08d80f67104d17655d522f4a048afb62095d5223/doc/dtn-storage-states.odg
--------------------------------------------------------------------------------
/inc/bplib_file_offload.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | #ifndef BPLIB_FILE_OFFLOAD_H
22 | #define BPLIB_FILE_OFFLOAD_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /******************************************************************************
29 | INCLUDES
30 | ******************************************************************************/
31 |
32 | #include "bplib.h"
33 | #include "bplib_os.h"
34 | #include "bplib_api_types.h"
35 |
36 | /******************************************************************************
37 | TYPEDEFS
38 | ******************************************************************************/
39 |
40 | /******************************************************************************
41 | PROTOTYPES
42 | ******************************************************************************/
43 |
44 | extern const bplib_cache_module_api_t *BPLIB_FILE_OFFLOAD_API;
45 |
46 | #ifdef __cplusplus
47 | } // extern "C"
48 | #endif
49 |
50 | #endif /* BPLIB_FILE_OFFLOAD_H */
51 |
--------------------------------------------------------------------------------
/lib/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # Bundle Protocol Library (BPLib) CMake build recipe
4 | #
5 | # This is for the "base" submodule
6 | #
7 | ##################################################################
8 |
9 | set(bplib_base_SOURCES
10 | src/v7_bplib.c
11 | src/v7_cla_api.c
12 | src/v7_dataservice_api.c
13 | src/v7_routing.c
14 | )
15 |
16 | add_library(bplib_base OBJECT
17 | ${bplib_base_SOURCES}
18 | )
19 |
20 | target_include_directories(bplib_base PUBLIC
21 | ${CMAKE_CURRENT_SOURCE_DIR}/inc
22 |
23 | $
24 | $
25 | )
26 |
27 | target_include_directories(bplib_base PRIVATE
28 | $
29 | $
30 | $
31 | )
32 |
33 | # Add unit test coverage subdirectory
34 | if(BPLIB_ENABLE_UNIT_TESTS)
35 | add_subdirectory(ut-stubs)
36 | add_subdirectory(ut-coverage)
37 | endif(BPLIB_ENABLE_UNIT_TESTS)
38 |
--------------------------------------------------------------------------------
/lib/inc/bplib_dataservice.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | #ifndef BPLIB_DATASERVICE_H
22 | #define BPLIB_DATASERVICE_H
23 |
24 | /******************************************************************************
25 | INCLUDES
26 | ******************************************************************************/
27 |
28 | #include "bplib_api_types.h"
29 | #include "v7_mpool.h"
30 |
31 | typedef enum
32 | {
33 | bplib_dataservice_type_undefined,
34 | bplib_dataservice_type_application,
35 | bplib_dataservice_type_storage,
36 | bplib_dataservice_type_max
37 | } bplib_dataservice_type_t;
38 |
39 | bp_handle_t bplib_dataservice_add_base_intf(bplib_routetbl_t *rtbl, bp_ipn_t node_number);
40 | bp_handle_t bplib_dataservice_attach(bplib_routetbl_t *tbl, const bp_ipn_addr_t *ipn, bplib_dataservice_type_t type,
41 | bplib_mpool_ref_t blkref);
42 | bplib_mpool_ref_t bplib_dataservice_detach(bplib_routetbl_t *tbl, const bp_ipn_addr_t *ipn);
43 |
44 | #endif /* BPLIB_DATASERVICE_H */
45 |
--------------------------------------------------------------------------------
/lib/src/v7_base_internal.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | #ifndef V7_BASE_INTERNAL_H
22 | #define V7_BASE_INTERNAL_H
23 |
24 | #include "bplib_api_types.h"
25 | #include "v7_rbtree.h"
26 | #include "v7_types.h"
27 | #include "v7_mpool.h"
28 |
29 | struct bp_socket
30 | {
31 | bplib_mpool_block_t fblk;
32 | };
33 |
34 | typedef struct bplib_cla_stats
35 | {
36 | uintmax_t ingress_byte_count;
37 | uintmax_t egress_byte_count;
38 |
39 | } bplib_cla_stats_t;
40 |
41 | typedef struct bplib_route_serviceintf_info
42 | {
43 | bp_ipn_t node_number;
44 | bplib_rbt_root_t service_index;
45 | bplib_mpool_ref_t storage_service;
46 |
47 | } bplib_route_serviceintf_info_t;
48 |
49 | typedef struct bplib_service_endpt bplib_service_endpt_t;
50 |
51 | struct bplib_service_endpt
52 | {
53 | bplib_rbt_link_t rbt_link; /* for storage in RB tree, must be first */
54 | bplib_mpool_block_t *self_ptr;
55 | bplib_mpool_ref_t subflow_ref;
56 | };
57 |
58 | typedef struct bplib_socket_info bplib_socket_info_t;
59 | struct bplib_socket_info
60 | {
61 | bplib_routetbl_t *parent_rtbl;
62 | bp_handle_t socket_intf_id;
63 | bplib_connection_t params;
64 | uintmax_t ingress_byte_count;
65 | uintmax_t egress_byte_count;
66 | bp_sequencenumber_t last_bundle_seq;
67 | };
68 |
69 | typedef struct bplib_routeentry
70 | {
71 | bp_ipn_t dest;
72 | bp_ipn_t mask;
73 | bp_handle_t intf_id;
74 | } bplib_routeentry_t;
75 |
76 | struct bplib_routetbl
77 | {
78 | uint32_t max_routes;
79 | uint32_t registered_routes;
80 | bp_handle_t activity_lock;
81 | volatile bool maint_request_flag;
82 | volatile bool maint_active_flag;
83 | uint8_t poll_count;
84 | uint64_t last_intf_poll;
85 | uintmax_t routing_success_count;
86 | uintmax_t routing_error_count;
87 | bplib_mpool_t *pool;
88 | bplib_mpool_block_t flow_list;
89 | bplib_routeentry_t *route_tbl;
90 | };
91 |
92 | int bplib_serviceflow_forward_ingress(void *arg, bplib_mpool_block_t *subq_src);
93 | int bplib_serviceflow_forward_egress(void *arg, bplib_mpool_block_t *subq_src);
94 | int bplib_dataservice_event_impl(void *arg, bplib_mpool_block_t *intf_block);
95 | int bplib_dataservice_base_construct(void *arg, bplib_mpool_block_t *blk);
96 | int bplib_cla_event_impl(void *arg, bplib_mpool_block_t *intf_block);
97 | int bplib_generic_bundle_ingress(bplib_mpool_ref_t flow_ref, const void *content, size_t size, uint64_t time_limit);
98 | int bplib_generic_bundle_egress(bplib_mpool_ref_t flow_ref, void *content, size_t *size, uint64_t time_limit);
99 |
100 | #endif /* V7_BASE_INTERNAL_H*/
--------------------------------------------------------------------------------
/lib/ut-coverage/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # coverage test build recipe
4 | #
5 | # This CMake file contains the recipe for building the coverage tests.
6 | # It is invoked from the parent directory when unit tests are enabled.
7 | #
8 | ##################################################################
9 |
10 | add_library(utobj_bplib_base OBJECT
11 | ../src/v7_bplib.c
12 | ../src/v7_cla_api.c
13 | ../src/v7_dataservice_api.c
14 | ../src/v7_routing.c
15 | )
16 |
17 | target_compile_definitions(utobj_bplib_base PRIVATE
18 | $
19 | $
20 | )
21 |
22 | target_compile_options(utobj_bplib_base PRIVATE
23 | $
24 | $
25 | )
26 |
27 | target_include_directories(utobj_bplib_base PRIVATE
28 | $
29 | $
30 | )
31 |
32 | # Add executable
33 | add_executable(coverage-bplib_base-testrunner
34 | test_bplib_base_setup.c
35 | test_v7_bplib.c
36 | test_v7_cla_api.c
37 | test_v7_dataservice_api.c
38 | test_v7_routing.c
39 | $
40 | )
41 |
42 | target_include_directories(coverage-bplib_base-testrunner PRIVATE
43 | $
44 | )
45 |
46 | target_link_libraries(coverage-bplib_base-testrunner PUBLIC
47 | ut_coverage_link
48 | bplib_common_stubs
49 | bplib_mpool_stubs
50 | bplib_cache_stubs
51 | bplib_v7_stubs
52 | bplib_os_stubs
53 | ut_assert
54 | )
55 |
56 | add_test(coverage-bplib_base-testrunner coverage-bplib_base-testrunner)
57 |
58 | # Install the executables to a staging area for test in cross environments
59 | if (INSTALL_TARGET_LIST)
60 | foreach(TGT ${INSTALL_TARGET_LIST})
61 | install(TARGETS coverage-bplib_base-testrunner DESTINATION ${TGT}/${UT_INSTALL_SUBDIR})
62 | endforeach()
63 | endif()
64 |
--------------------------------------------------------------------------------
/lib/ut-coverage/test_bplib_base.h:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3 | *
4 | * Copyright (c) 2020 United States Government as represented by the
5 | * Administrator of the National Aeronautics and Space Administration.
6 | * All Rights Reserved.
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 | * not use this file except in compliance with the License. You may obtain
10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | ************************************************************************/
18 |
19 | #ifndef TEST_BPLIB_MPOOL_H
20 | #define TEST_BPLIB_MPOOL_H
21 |
22 | #include "utassert.h"
23 | #include "utstubs.h"
24 | #include "uttest.h"
25 | #include "v7_mpool.h"
26 | #include "v7_types.h"
27 | #include "v7_rbtree.h"
28 | #include "v7_mpool_bblocks.h"
29 | #include "v7.h"
30 | #include "v7_mpool_ref.h"
31 | #include "v7_mpool_flows.h"
32 | #include "v7_cache.h"
33 | #include "v7_codec.h"
34 | #include "bplib_dataservice.h"
35 | #include "bplib_routing.h"
36 | #include "bplib.h"
37 | #include "bplib_os.h"
38 | #include "bplib_api_types.h"
39 | #include "../src/v7_base_internal.h"
40 | #include "../src/v7_mpool_internal.h"
41 |
42 | void UT_lib_ingress_AltHandler_PointerReturn(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
43 | void UT_lib_egress_AltHandler_PointerReturn(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
44 | void UT_lib_baseintf_AltHandler_PointerReturn(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
45 | void UT_lib_AltHandler_PointerReturn(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
46 | void UT_lib_sizet_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
47 | void UT_lib_uint64_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
48 | void UT_lib_int8_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
49 | void UT_lib_bool_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
50 | void TestBplibBase_Register(void);
51 | void TestBplibBase_ClaApi_Register(void);
52 | void TestBplibBase_DataServiceApi_Register(void);
53 | void TestBplibBase_Routing_Register(void);
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/lib/ut-coverage/test_bplib_base_setup.c:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3 | *
4 | * Copyright (c) 2020 United States Government as represented by the
5 | * Administrator of the National Aeronautics and Space Administration.
6 | * All Rights Reserved.
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 | * not use this file except in compliance with the License. You may obtain
10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | ************************************************************************/
18 |
19 | /*
20 | * Includes
21 | */
22 | #include "bplib_api_types.h"
23 | #include "test_bplib_base.h"
24 | #include "bplib_routing.h"
25 | #include "bplib.h"
26 |
27 | void UT_lib_ingress_AltHandler_PointerReturn(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
28 | {
29 | void *retval = NULL;
30 | int count = UT_GetStubCount(UT_KEY(bplib_mpool_flow_try_pull));
31 | if (count > 15)
32 | {
33 | UT_Stub_SetReturnValue(FuncKey, retval);
34 | }
35 | else
36 | {
37 | UT_Stub_SetReturnValue(FuncKey, UserObj);
38 | }
39 | }
40 |
41 | void UT_lib_egress_AltHandler_PointerReturn(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
42 | {
43 | void *retval = NULL;
44 | int count = UT_GetStubCount(UT_KEY(bplib_mpool_flow_try_pull));
45 | if (count > 20)
46 | {
47 | UT_Stub_SetReturnValue(FuncKey, retval);
48 | }
49 | else
50 | {
51 | UT_Stub_SetReturnValue(FuncKey, UserObj);
52 | }
53 | }
54 |
55 | void UT_lib_baseintf_AltHandler_PointerReturn(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
56 | {
57 | void *retval = NULL;
58 | int count = UT_GetStubCount(UT_KEY(bplib_mpool_flow_try_pull));
59 | if (count > 25)
60 | {
61 | UT_Stub_SetReturnValue(FuncKey, retval);
62 | }
63 | else
64 | {
65 | UT_Stub_SetReturnValue(FuncKey, UserObj);
66 | }
67 | }
68 |
69 | void UT_lib_AltHandler_PointerReturn(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
70 | {
71 | UT_Stub_SetReturnValue(FuncKey, UserObj);
72 | }
73 |
74 | void UT_lib_sizet_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
75 | {
76 | size_t retval = 0;
77 | UT_Stub_SetReturnValue(FuncKey, retval);
78 | }
79 |
80 | void UT_lib_uint64_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
81 | {
82 | int32 StatusCode;
83 | uint64_t Result;
84 |
85 | UT_Stub_GetInt32StatusCode(Context, &StatusCode);
86 |
87 | Result = StatusCode;
88 |
89 | UT_Stub_SetReturnValue(FuncKey, Result);
90 | }
91 |
92 | void UT_lib_int8_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
93 | {
94 | int8 retval = 0;
95 | UT_Stub_SetReturnValue(FuncKey, retval);
96 | }
97 |
98 | void UT_lib_bool_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
99 | {
100 | bool retval = true;
101 | UT_Stub_SetReturnValue(FuncKey, retval);
102 | }
103 |
104 | void UtTest_Setup(void)
105 | {
106 | TestBplibBase_Register();
107 | TestBplibBase_ClaApi_Register();
108 | TestBplibBase_DataServiceApi_Register();
109 | TestBplibBase_Routing_Register();
110 | }
111 |
--------------------------------------------------------------------------------
/lib/ut-stubs/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # Bundle Protocol Library (BPLib) CMake build recipe
4 | #
5 | # This is for the "base" stub functions
6 | #
7 | ##################################################################
8 |
9 | add_library(bplib_base_stubs STATIC
10 | bplib_dataservice_stubs.c
11 | )
12 |
13 | target_include_directories(bplib_base_stubs PUBLIC
14 | $
15 | )
16 |
17 | target_link_libraries(bplib_base_stubs PUBLIC
18 | ut_assert
19 | )
20 |
--------------------------------------------------------------------------------
/lib/ut-stubs/bplib_dataservice_stubs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /**
22 | * @file
23 | *
24 | * Auto-Generated stub implementations for functions defined in bplib_dataservice header
25 | */
26 |
27 | #include "bplib_dataservice.h"
28 | #include "utgenstub.h"
29 |
30 | /*
31 | * ----------------------------------------------------
32 | * Generated stub function for bplib_dataservice_add_base_intf()
33 | * ----------------------------------------------------
34 | */
35 | bp_handle_t bplib_dataservice_add_base_intf(bplib_routetbl_t *rtbl, bp_ipn_t node_number)
36 | {
37 | UT_GenStub_SetupReturnBuffer(bplib_dataservice_add_base_intf, bp_handle_t);
38 |
39 | UT_GenStub_AddParam(bplib_dataservice_add_base_intf, bplib_routetbl_t *, rtbl);
40 | UT_GenStub_AddParam(bplib_dataservice_add_base_intf, bp_ipn_t, node_number);
41 |
42 | UT_GenStub_Execute(bplib_dataservice_add_base_intf, Basic, NULL);
43 |
44 | return UT_GenStub_GetReturnValue(bplib_dataservice_add_base_intf, bp_handle_t);
45 | }
46 |
47 | /*
48 | * ----------------------------------------------------
49 | * Generated stub function for bplib_dataservice_attach()
50 | * ----------------------------------------------------
51 | */
52 | bp_handle_t bplib_dataservice_attach(bplib_routetbl_t *tbl, const bp_ipn_addr_t *ipn, bplib_dataservice_type_t type,
53 | bplib_mpool_ref_t blkref)
54 | {
55 | UT_GenStub_SetupReturnBuffer(bplib_dataservice_attach, bp_handle_t);
56 |
57 | UT_GenStub_AddParam(bplib_dataservice_attach, bplib_routetbl_t *, tbl);
58 | UT_GenStub_AddParam(bplib_dataservice_attach, const bp_ipn_addr_t *, ipn);
59 | UT_GenStub_AddParam(bplib_dataservice_attach, bplib_dataservice_type_t, type);
60 | UT_GenStub_AddParam(bplib_dataservice_attach, bplib_mpool_ref_t, blkref);
61 |
62 | UT_GenStub_Execute(bplib_dataservice_attach, Basic, NULL);
63 |
64 | return UT_GenStub_GetReturnValue(bplib_dataservice_attach, bp_handle_t);
65 | }
66 |
67 | /*
68 | * ----------------------------------------------------
69 | * Generated stub function for bplib_dataservice_detach()
70 | * ----------------------------------------------------
71 | */
72 | bplib_mpool_ref_t bplib_dataservice_detach(bplib_routetbl_t *tbl, const bp_ipn_addr_t *ipn)
73 | {
74 | UT_GenStub_SetupReturnBuffer(bplib_dataservice_detach, bplib_mpool_ref_t);
75 |
76 | UT_GenStub_AddParam(bplib_dataservice_detach, bplib_routetbl_t *, tbl);
77 | UT_GenStub_AddParam(bplib_dataservice_detach, const bp_ipn_addr_t *, ipn);
78 |
79 | UT_GenStub_Execute(bplib_dataservice_detach, Basic, NULL);
80 |
81 | return UT_GenStub_GetReturnValue(bplib_dataservice_detach, bplib_mpool_ref_t);
82 | }
83 |
--------------------------------------------------------------------------------
/libabi.version:
--------------------------------------------------------------------------------
1 | CODEABI_0.2.2
2 | {
3 | global: *bplib_*;
4 | local: *;
5 | };
6 |
--------------------------------------------------------------------------------
/mpool/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # Bundle Protocol Library (BPLib) CMake build recipe
4 | #
5 | # This is for the "mpool" submodule, which applies only to the
6 | # v7 build.
7 | #
8 | ##################################################################
9 |
10 | add_library(bplib_mpool OBJECT
11 | src/v7_mpool.c
12 | src/v7_mpool_ref.c
13 | src/v7_mpool_job.c
14 | src/v7_mpool_bblocks.c
15 | src/v7_mpool_flows.c
16 | src/v7_mpstream.c
17 | )
18 |
19 | target_include_directories(bplib_mpool PUBLIC
20 | ${CMAKE_CURRENT_SOURCE_DIR}/inc
21 |
22 | $
23 | $
24 | $
25 | )
26 |
27 | if(BPLIB_ENABLE_UNIT_TESTS)
28 | add_subdirectory(ut-stubs)
29 | add_subdirectory(ut-coverage)
30 | endif(BPLIB_ENABLE_UNIT_TESTS)
31 |
--------------------------------------------------------------------------------
/mpool/inc/v7_mpool_job.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | #ifndef V7_MPOOL_JOB_H
22 | #define V7_MPOOL_JOB_H
23 |
24 | #include
25 |
26 | #include "v7_mpool.h"
27 |
28 | typedef struct bplib_mpool_job
29 | {
30 | bplib_mpool_block_t link;
31 | bplib_mpool_callback_func_t handler;
32 | } bplib_mpool_job_t;
33 |
34 | typedef struct bplib_mpool_job_statechange
35 | {
36 | bplib_mpool_job_t base_job;
37 |
38 | /* JPHFIX: this single event handler may be separated into per-event-type handlers */
39 | bplib_mpool_callback_func_t event_handler;
40 | } bplib_mpool_job_statechange_t;
41 |
42 | /**
43 | * @brief Cast a block to a job type
44 | *
45 | * @param cb
46 | * @return bplib_mpool_job_t*
47 | */
48 | bplib_mpool_job_t *bplib_mpool_job_cast(bplib_mpool_block_t *cb);
49 |
50 | void bplib_mpool_job_init(bplib_mpool_block_t *base_block, bplib_mpool_job_t *jblk);
51 |
52 | /**
53 | * @brief Mark a given job as runnable
54 | *
55 | * This marks it so it will be processed during the next call to forward data
56 | *
57 | * @note This is handled automatically by functions which append to a flow subq, such
58 | * as bplib_mpool_flow_try_push() and bplib_mpool_flow_try_move_all().
59 | * Applictions only need to explicitly call this API to mark it as active if there is
60 | * some other factor that requires it to be processed again.
61 | *
62 | * @param job Job that is ready to run
63 | */
64 | void bplib_mpool_job_mark_active(bplib_mpool_job_t *job);
65 |
66 | /**
67 | * @brief Get the next active flow in the pool
68 | *
69 | * The given callback function will be invoked for all flows which are
70 | * currently marked as active
71 | *
72 | * @param pool
73 | * @return bplib_mpool_job_t *
74 | */
75 | bplib_mpool_job_t *bplib_mpool_job_get_next_active(bplib_mpool_t *pool);
76 |
77 | void bplib_mpool_job_run_all(bplib_mpool_t *pool, void *arg);
78 |
79 | #endif /* V7_MPOOL_JOB_H */
80 |
--------------------------------------------------------------------------------
/mpool/inc/v7_mpool_ref.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | #ifndef V7_MPOOL_REF_H
22 | #define V7_MPOOL_REF_H
23 |
24 | #include
25 |
26 | #include "bplib_api_types.h"
27 | #include "v7_mpool.h"
28 |
29 | /**
30 | * @brief Gets the actual block from a reference pointer (dereference)
31 | *
32 | * @param refptr
33 | * @return bplib_mpool_block_t*
34 | */
35 | static inline bplib_mpool_block_t *bplib_mpool_dereference(bplib_mpool_ref_t refptr)
36 | {
37 | return (bplib_mpool_block_t *)refptr;
38 | }
39 |
40 | /**
41 | * @brief Creates a lightweight reference to the data block
42 | *
43 | * This creates an opaque pointer that can be stored into another user object
44 | * A light reference increses the reference count on the target object, but does
45 | * not consume any pool memory directly itself. It will prevent the target
46 | * object from being garbage collected.
47 | *
48 | * References must be explicitly tracked and released by the user when
49 | * no longer needed, using bplib_mpool_ref_release()
50 | *
51 | * References may also be duplicated via bplib_mpool_ref_duplicate()
52 | *
53 | * After this call, the passed in blk becomes managed by the pool.
54 | *
55 | * @note If this function returns non-NULL, the calling application should no longer directly
56 | * use the blk pointer that was passed in. It should only use the reference pointers.
57 | *
58 | * @param blk
59 | * @return bplib_mpool_ref_t*
60 | */
61 | bplib_mpool_ref_t bplib_mpool_ref_create(bplib_mpool_block_t *blk);
62 |
63 | bplib_mpool_ref_t bplib_mpool_ref_duplicate(bplib_mpool_ref_t refptr);
64 | bplib_mpool_ref_t bplib_mpool_ref_from_block(bplib_mpool_block_t *rblk);
65 |
66 | /**
67 | * @brief Release a lightweight reference
68 | *
69 | * This must be invoked once a reference that was previously created by bplib_mpool_ref_create()
70 | * or bplib_mpool_ref_duplicate() is no longer needed by the software application.
71 | *
72 | * This decrements the reference count, and if the reference count reaches 0, it also recycles the
73 | * original object.
74 | *
75 | * @param refptr
76 | */
77 | void bplib_mpool_ref_release(bplib_mpool_ref_t refptr);
78 |
79 | /**
80 | * @brief Creates a separate block reference to the data block
81 | *
82 | * A block is allocated from the pool which refers to the original data block, and can stand in place
83 | * of the actual data block wherever a data block is expected, such as for queuing and storage.
84 | *
85 | * A reference of this type does not need to be explicitly released by the user, as it
86 | * will be automatically released when the block is recycled via bplib_mpool_recycle_block()
87 | * or bplib_mpool_recycle_all_blocks_in_list()
88 | *
89 | * @note This increments the refcount, so the calling application should call
90 | * bplib_mpool_ref_release() on the original ref if it does not keep it.
91 | *
92 | * @param refptr
93 | * @param magic_number
94 | * @param init_arg Opaque pointer to pass to initializer (may be NULL)
95 | * @return bplib_mpool_block_t*
96 | */
97 | bplib_mpool_block_t *bplib_mpool_ref_make_block(bplib_mpool_ref_t refptr, uint32_t magic_number, void *init_arg);
98 |
99 | #endif /* V7_MPOOL_REF_H */
100 |
--------------------------------------------------------------------------------
/mpool/inc/v7_mpstream.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | #ifndef V7_MPSTREAM_H
22 | #define V7_MPSTREAM_H
23 |
24 | #include
25 |
26 | #include "bplib_api_types.h"
27 | #include "v7_types.h"
28 | #include "v7_mpool.h"
29 | #include "crc.h"
30 |
31 | typedef enum bplib_mpool_stream_dir
32 | {
33 | bplib_mpool_stream_dir_undefined,
34 | bplib_mpool_stream_dir_write,
35 | bplib_mpool_stream_dir_read
36 | } bplib_mpool_stream_dir_t;
37 |
38 | typedef struct bplib_mpool_stream
39 | {
40 | bplib_mpool_stream_dir_t dir;
41 | bplib_mpool_t *pool;
42 | bplib_mpool_block_t *last_eblk;
43 | bplib_mpool_block_t head;
44 | size_t curr_pos;
45 | size_t curr_limit;
46 | size_t stream_position;
47 | } bplib_mpool_stream_t;
48 |
49 | void bplib_mpool_start_stream_init(bplib_mpool_stream_t *mps, bplib_mpool_t *pool, bplib_mpool_stream_dir_t dir);
50 | size_t bplib_mpool_stream_write(bplib_mpool_stream_t *mps, const void *data, size_t size);
51 | size_t bplib_mpool_stream_read(bplib_mpool_stream_t *mps, void *data, size_t size);
52 | size_t bplib_mpool_stream_seek(bplib_mpool_stream_t *mps, size_t target_position);
53 | void bplib_mpool_stream_attach(bplib_mpool_stream_t *mps, bplib_mpool_block_t *head);
54 | static inline size_t bplib_mpool_stream_tell(const bplib_mpool_stream_t *mps)
55 | {
56 | return mps->stream_position;
57 | }
58 | void bplib_mpool_stream_close(bplib_mpool_stream_t *mps);
59 |
60 | #endif /* V7_MPSTREAM_H */
61 |
--------------------------------------------------------------------------------
/mpool/ut-coverage/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # coverage test build recipe
4 | #
5 | # This CMake file contains the recipe for building the coverage tests.
6 | # It is invoked from the parent directory when unit tests are enabled.
7 | #
8 | ##################################################################
9 |
10 | add_library(utobj_bplib_mpool OBJECT
11 | ../src/v7_mpool_bblocks.c
12 | ../src/v7_mpool.c
13 | ../src/v7_mpool_flows.c
14 | ../src/v7_mpool_job.c
15 | ../src/v7_mpool_ref.c
16 | ../src/v7_mpstream.c
17 | )
18 |
19 | target_compile_definitions(utobj_bplib_mpool PRIVATE
20 | $
21 | $
22 | )
23 |
24 | target_compile_options(utobj_bplib_mpool PRIVATE
25 | $
26 | $
27 | )
28 |
29 | target_include_directories(utobj_bplib_mpool PRIVATE
30 | $
31 | $
32 | )
33 |
34 | # Add executable
35 | add_executable(coverage-bplib_mpool-testrunner
36 | test_bplib_mpool_setup.c
37 | test_bplib_v7_mpool_bblocks.c
38 | test_bplib_v7_mpool.c
39 | test_bplib_v7_mpool_flows.c
40 | test_bplib_v7_mpool_job.c
41 | test_bplib_v7_mpool_ref.c
42 | test_bplib_v7_mpstream.c
43 | $
44 | )
45 |
46 | target_include_directories(coverage-bplib_mpool-testrunner PRIVATE
47 | ../src
48 | $
49 | )
50 |
51 | target_link_libraries(coverage-bplib_mpool-testrunner PUBLIC
52 | ut_coverage_link
53 | bplib_common_stubs
54 | bplib_os_stubs
55 | ut_assert
56 | )
57 |
58 | add_test(coverage-bplib_mpool-testrunner coverage-bplib_mpool-testrunner)
59 |
60 | # Install the executables to a staging area for test in cross environments
61 | if (INSTALL_TARGET_LIST)
62 | foreach(TGT ${INSTALL_TARGET_LIST})
63 | install(TARGETS coverage-bplib_mpool-testrunner DESTINATION ${TGT}/${UT_INSTALL_SUBDIR})
64 | endforeach()
65 | endif()
66 |
--------------------------------------------------------------------------------
/mpool/ut-coverage/test_bplib_mpool.h:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3 | *
4 | * Copyright (c) 2020 United States Government as represented by the
5 | * Administrator of the National Aeronautics and Space Administration.
6 | * All Rights Reserved.
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 | * not use this file except in compliance with the License. You may obtain
10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | ************************************************************************/
18 |
19 | #ifndef TEST_BPLIB_MPOOL_H
20 | #define TEST_BPLIB_MPOOL_H
21 |
22 | #include "utassert.h"
23 | #include "utstubs.h"
24 | #include "uttest.h"
25 |
26 | #include "v7_mpool_internal.h"
27 |
28 | typedef struct
29 | {
30 | bplib_mpool_t pool;
31 | bplib_mpool_block_content_t blk[3];
32 | } UT_bplib_mpool_buf_t;
33 |
34 | /* helper functions used in multiple tests */
35 | void UT_AltHandler_PointerReturn(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
36 | int test_bplib_mpool_callback_stub(void *arg, bplib_mpool_block_t *blk);
37 | void test_make_singleton_link(bplib_mpool_t *parent_pool, bplib_mpool_block_t *b);
38 | void test_setup_mpblock(bplib_mpool_t *pool, bplib_mpool_block_content_t *b, bplib_mpool_blocktype_t blktype,
39 | uint32 sig);
40 | void test_setup_allocation(bplib_mpool_t *pool, bplib_mpool_block_content_t *db, bplib_mpool_block_content_t *apib);
41 |
42 | void TestBplibMpool_ResetTestEnvironment(void);
43 |
44 | /* Registration functions */
45 | void TestBplibMpoolBBlocks_Register(void);
46 | void TestBplibMpoolFlows_Register(void);
47 | void TestBplibMpoolJob_Register(void);
48 | void TestBplibMpoolRef_Register(void);
49 | void TestBplibMpoolBase_Register(void);
50 | void TestBplibMpoolMPStream_Register(void);
51 |
52 | #endif
53 |
--------------------------------------------------------------------------------
/mpool/ut-stubs/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # Bundle Protocol Library (BPLib) CMake build recipe
4 | #
5 | # This is for the "mpool" stub functions
6 | #
7 | ##################################################################
8 |
9 | add_library(bplib_mpool_stubs STATIC
10 | v7_mpool_stubs.c
11 | v7_mpool_ref_stubs.c
12 | v7_mpool_job_stubs.c
13 | v7_mpool_bblocks_stubs.c
14 | v7_mpool_flows_stubs.c
15 | v7_mpstream_stubs.c
16 | )
17 |
18 | target_include_directories(bplib_mpool_stubs PUBLIC
19 | $
20 | )
21 |
22 | target_link_libraries(bplib_mpool_stubs PUBLIC
23 | ut_assert
24 | )
25 |
--------------------------------------------------------------------------------
/mpool/ut-stubs/v7_mpool_job_stubs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /**
22 | * @file
23 | *
24 | * Auto-Generated stub implementations for functions defined in v7_mpool_job header
25 | */
26 |
27 | #include "v7_mpool_job.h"
28 | #include "utgenstub.h"
29 |
30 | /*
31 | * ----------------------------------------------------
32 | * Generated stub function for bplib_mpool_job_cast()
33 | * ----------------------------------------------------
34 | */
35 | bplib_mpool_job_t *bplib_mpool_job_cast(bplib_mpool_block_t *cb)
36 | {
37 | UT_GenStub_SetupReturnBuffer(bplib_mpool_job_cast, bplib_mpool_job_t *);
38 |
39 | UT_GenStub_AddParam(bplib_mpool_job_cast, bplib_mpool_block_t *, cb);
40 |
41 | UT_GenStub_Execute(bplib_mpool_job_cast, Basic, NULL);
42 |
43 | return UT_GenStub_GetReturnValue(bplib_mpool_job_cast, bplib_mpool_job_t *);
44 | }
45 |
46 | /*
47 | * ----------------------------------------------------
48 | * Generated stub function for bplib_mpool_job_get_next_active()
49 | * ----------------------------------------------------
50 | */
51 | bplib_mpool_job_t *bplib_mpool_job_get_next_active(bplib_mpool_t *pool)
52 | {
53 | UT_GenStub_SetupReturnBuffer(bplib_mpool_job_get_next_active, bplib_mpool_job_t *);
54 |
55 | UT_GenStub_AddParam(bplib_mpool_job_get_next_active, bplib_mpool_t *, pool);
56 |
57 | UT_GenStub_Execute(bplib_mpool_job_get_next_active, Basic, NULL);
58 |
59 | return UT_GenStub_GetReturnValue(bplib_mpool_job_get_next_active, bplib_mpool_job_t *);
60 | }
61 |
62 | /*
63 | * ----------------------------------------------------
64 | * Generated stub function for bplib_mpool_job_init()
65 | * ----------------------------------------------------
66 | */
67 | void bplib_mpool_job_init(bplib_mpool_block_t *base_block, bplib_mpool_job_t *jblk)
68 | {
69 | UT_GenStub_AddParam(bplib_mpool_job_init, bplib_mpool_block_t *, base_block);
70 | UT_GenStub_AddParam(bplib_mpool_job_init, bplib_mpool_job_t *, jblk);
71 |
72 | UT_GenStub_Execute(bplib_mpool_job_init, Basic, NULL);
73 | }
74 |
75 | /*
76 | * ----------------------------------------------------
77 | * Generated stub function for bplib_mpool_job_mark_active()
78 | * ----------------------------------------------------
79 | */
80 | void bplib_mpool_job_mark_active(bplib_mpool_job_t *job)
81 | {
82 | UT_GenStub_AddParam(bplib_mpool_job_mark_active, bplib_mpool_job_t *, job);
83 |
84 | UT_GenStub_Execute(bplib_mpool_job_mark_active, Basic, NULL);
85 | }
86 |
87 | /*
88 | * ----------------------------------------------------
89 | * Generated stub function for bplib_mpool_job_run_all()
90 | * ----------------------------------------------------
91 | */
92 | void bplib_mpool_job_run_all(bplib_mpool_t *pool, void *arg)
93 | {
94 | UT_GenStub_AddParam(bplib_mpool_job_run_all, bplib_mpool_t *, pool);
95 | UT_GenStub_AddParam(bplib_mpool_job_run_all, void *, arg);
96 |
97 | UT_GenStub_Execute(bplib_mpool_job_run_all, Basic, NULL);
98 | }
99 |
--------------------------------------------------------------------------------
/os/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # Bundle Protocol Library (BPLib) CMake build recipe
4 | #
5 | # This is for the "os" submodule
6 | #
7 | ##################################################################
8 |
9 | set(bplib_os_SOURCES
10 | src/heap.c
11 | )
12 |
13 | if (BPLIB_OS_LAYER STREQUAL OSAL)
14 |
15 | if (IS_CFS_ARCH_BUILD)
16 | list(APPEND bplib_os_SOURCES src/cfe.c)
17 | endif()
18 |
19 | list(APPEND bplib_os_SOURCES src/osal.c)
20 |
21 | elseif(BPLIB_OS_LAYER STREQUAL POSIX)
22 |
23 | list(APPEND bplib_os_SOURCES src/posix.c)
24 |
25 | else()
26 | message(FATAL_ERROR "Unknown OS adapter: ${BPLIB_OS_LAYER}")
27 | endif()
28 |
29 | add_library(bplib_os OBJECT
30 | ${bplib_os_SOURCES}
31 | )
32 |
33 | target_include_directories(bplib_os PUBLIC
34 | ${CMAKE_CURRENT_SOURCE_DIR}/inc
35 | $
36 | )
37 |
38 | if(BPLIB_ENABLE_UNIT_TESTS)
39 | add_subdirectory(ut-stubs)
40 | add_subdirectory(ut-coverage)
41 | endif(BPLIB_ENABLE_UNIT_TESTS)
42 |
--------------------------------------------------------------------------------
/os/inc/bplib_os.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | #ifndef BPLIB_OS_H
22 | #define BPLIB_OS_H
23 |
24 | /******************************************************************************
25 | INCLUDES
26 | ******************************************************************************/
27 |
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 |
38 | #include "bplib_api_types.h"
39 |
40 | /******************************************************************************
41 | COMPILE TIME CONFIGURATION SETTINGS
42 | ******************************************************************************/
43 |
44 | /******************************************************************************
45 | DEFINES
46 | ******************************************************************************/
47 |
48 | /* Macros */
49 | #define bplog(flags, evt, ...) bplib_os_log(__FILE__, __LINE__, flags, evt, __VA_ARGS__)
50 |
51 | /******************************************************************************
52 | TYPEDEFS
53 | ******************************************************************************/
54 |
55 | /******************************************************************************
56 | PROTOTYPES
57 | ******************************************************************************/
58 |
59 | void bplib_os_init(void);
60 | void bplib_os_enable_log_flags(uint32_t enable_mask);
61 | int bplib_os_log(const char *file, unsigned int line, uint32_t *flags, uint32_t event, const char *fmt, ...);
62 | int bplib_os_systime(unsigned long *sysnow); /* seconds */
63 | uint64_t bplib_os_get_dtntime_ms(void);
64 | void bplib_os_sleep(int seconds);
65 | uint32_t bplib_os_random(void);
66 | bp_handle_t bplib_os_createlock(void);
67 | void bplib_os_destroylock(bp_handle_t h);
68 | void bplib_os_lock(bp_handle_t h);
69 | void bplib_os_unlock(bp_handle_t h);
70 | void bplib_os_broadcast_signal(bp_handle_t h);
71 | void bplib_os_broadcast_signal_and_unlock(bp_handle_t h);
72 | void bplib_os_signal(bp_handle_t h);
73 | int bplib_os_waiton(bp_handle_t h, int timeout_ms);
74 | int bplib_os_wait_until_ms(bp_handle_t h, uint64_t abs_dtntime_ms);
75 | void *bplib_os_calloc(size_t size);
76 | void bplib_os_free(void *ptr);
77 |
78 | #endif /* BPLIB_OS_H */
79 |
--------------------------------------------------------------------------------
/os/src/heap.c:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /******************************************************************************
22 | INCLUDES
23 | ******************************************************************************/
24 |
25 | #include
26 | #include
27 | #include
28 |
29 | #include "bplib.h"
30 | #include "bplib_os.h"
31 |
32 | /*----------------------------------------------------------------------------
33 | * bplib_os_calloc
34 | *----------------------------------------------------------------------------*/
35 | void *bplib_os_calloc(size_t size)
36 | {
37 | /* Allocate Memory Block */
38 | return calloc(size, 1);
39 | }
40 |
41 | /*----------------------------------------------------------------------------
42 | * bplib_os_free
43 | *----------------------------------------------------------------------------*/
44 | void bplib_os_free(void *ptr)
45 | {
46 | /* Free Memory Block */
47 | free(ptr);
48 | }
49 |
--------------------------------------------------------------------------------
/os/ut-coverage/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # coverage test build recipe
4 | #
5 | # This CMake file contains the recipe for building the coverage tests.
6 | # It is invoked from the parent directory when unit tests are enabled.
7 | #
8 | ##################################################################
9 |
10 | add_library(utobj_bplib_os OBJECT
11 | ../src/osal.c
12 | ../src/heap.c
13 | )
14 |
15 | # the "override_inc" dir contains replacement versions of the C-library include files.
16 | # This is only applied to the source files that strictly need this (i.e. those that call
17 | # c library functions directly)
18 | set_source_files_properties(../src/heap.c PROPERTIES INCLUDE_DIRECTORIES
19 | ${CMAKE_CURRENT_SOURCE_DIR}/override_inc
20 | )
21 |
22 |
23 | target_compile_definitions(utobj_bplib_os PRIVATE
24 | $
25 | $
26 | )
27 |
28 | target_compile_options(utobj_bplib_os PRIVATE
29 | $
30 | $
31 | )
32 |
33 | target_include_directories(utobj_bplib_os PRIVATE
34 | ${CMAKE_CURRENT_SOURCE_DIR}/inc
35 | $
36 | $
37 | )
38 |
39 | # Add executable
40 | add_executable(coverage-bplib_os-testrunner
41 | test_bplib_os.c
42 | libc_stdlib_stubs.c
43 | $
44 | )
45 |
46 | target_include_directories(coverage-bplib_os-testrunner PRIVATE
47 | ${CMAKE_CURRENT_SOURCE_DIR}/inc
48 | $
49 | )
50 |
51 | target_link_libraries(coverage-bplib_os-testrunner PUBLIC
52 | ut_coverage_link
53 | ut_osapi_stubs
54 | ut_assert
55 | )
56 |
57 | add_test(coverage-bplib_os-testrunner coverage-bplib_os-testrunner)
58 |
59 | # Install the executables to a staging area for test in cross environments
60 | if (INSTALL_TARGET_LIST)
61 | foreach(TGT ${INSTALL_TARGET_LIST})
62 | install(TARGETS coverage-bplib_os-testrunner DESTINATION ${TGT}/${UT_INSTALL_SUBDIR})
63 | endforeach()
64 | endif()
65 |
--------------------------------------------------------------------------------
/os/ut-coverage/inc/bplib_cs_stdlib.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /**
22 | * \file
23 | *
24 | * BPLib coverage stub replacement for stdlib.h
25 | */
26 |
27 | #ifndef BPLIB_CS_STDLIB_H
28 | #define BPLIB_CS_STDLIB_H
29 |
30 | /* This uses the host system size_t which cannot be overridden */
31 | #include
32 |
33 | /* ----------------------------------------- */
34 | /* constants normally defined in stdlib.h */
35 | /* ----------------------------------------- */
36 |
37 | /* ----------------------------------------- */
38 | /* types normally defined in stdlib.h */
39 | /* ----------------------------------------- */
40 |
41 | /* ----------------------------------------- */
42 | /* prototypes normally declared in stdlib.h */
43 | /* ----------------------------------------- */
44 |
45 | extern void *BPLIB_CS_calloc(size_t nmemb, size_t sz);
46 | extern void BPLIB_CS_free(void *ptr);
47 |
48 | #endif /* OCS_STDLIB_H */
49 |
--------------------------------------------------------------------------------
/os/ut-coverage/libc_stdlib_stubs.c:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3 | *
4 | * Copyright (c) 2020 United States Government as represented by the
5 | * Administrator of the National Aeronautics and Space Administration.
6 | * All Rights Reserved.
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 | * not use this file except in compliance with the License. You may obtain
10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | ************************************************************************/
18 |
19 | /* OSAL coverage stub replacement for stdlib.h */
20 | #include
21 | #include
22 | #include
23 | #include "utstubs.h"
24 | #include "utassert.h"
25 |
26 | #include "bplib_cs_stdlib.h"
27 |
28 | void *BPLIB_CS_calloc(size_t nmemb, size_t sz)
29 | {
30 | int32 Status;
31 | void *PoolPtr;
32 | size_t PoolSize;
33 | size_t BlockSize;
34 |
35 | BlockSize = nmemb * sz;
36 | UT_GetDataBuffer(UT_KEY(BPLIB_CS_calloc), &PoolPtr, &PoolSize, NULL);
37 |
38 | Status = UT_DEFAULT_IMPL(BPLIB_CS_calloc);
39 |
40 | if (Status != 0)
41 | {
42 | return NULL;
43 | }
44 |
45 | if (BlockSize > PoolSize)
46 | {
47 | /*
48 | * This indicates that the application is trying to allocate
49 | * a block larger than the pool. It typically means that the
50 | * emulated heap size is too small, so it is prudent to generate
51 | * a message.
52 | */
53 | UtAssert_Failed("BPLIB_CS_calloc() heap has been exhausted");
54 | return NULL;
55 | }
56 |
57 | return (void *)PoolPtr;
58 | }
59 |
60 | void BPLIB_CS_free(void *ptr)
61 | {
62 | void *PoolPtr;
63 | size_t PoolSize;
64 | int32 Status;
65 |
66 | /*
67 | * If there is a data buffer associated with free() then this
68 | * will sanity-check that the block being freed came from that heap.
69 | */
70 | UT_GetDataBuffer(UT_KEY(BPLIB_CS_free), &PoolPtr, &PoolSize, NULL);
71 |
72 | Status = UT_DEFAULT_IMPL(BPLIB_CS_free);
73 | if (Status == 0 && PoolPtr != NULL && PoolPtr != ptr)
74 | {
75 | UtAssert_Failed("BPLIB_CS_free(): Heap corruption -- pointer not correct");
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/os/ut-coverage/override_inc/stdlib.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /**
22 | * \file
23 | *
24 | * BPLib coverage stub replacement for stdlib.h
25 | */
26 |
27 | #ifndef OVERRIDE_STDLIB_H
28 | #define OVERRIDE_STDLIB_H
29 |
30 | #include "bplib_cs_stdlib.h"
31 |
32 | /* ----------------------------------------- */
33 | /* mappings for declarations in stdlib.h */
34 | /* ----------------------------------------- */
35 |
36 | #define calloc BPLIB_CS_calloc
37 | #define free BPLIB_CS_free
38 |
39 | #endif /* OVERRIDE_STDLIB_H */
40 |
--------------------------------------------------------------------------------
/os/ut-stubs/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # Bundle Protocol Library (BPLib) CMake build recipe
4 | #
5 | # This is for the "os" stub functions
6 | #
7 | ##################################################################
8 |
9 | add_library(bplib_os_stubs STATIC
10 | bplib_os_handlers.c
11 | bplib_os_stubs.c
12 | )
13 |
14 | target_include_directories(bplib_os_stubs PUBLIC
15 | $
16 | )
17 |
18 | target_link_libraries(bplib_os_stubs PUBLIC
19 | ut_assert
20 | )
21 |
--------------------------------------------------------------------------------
/os/ut-stubs/bplib_os_handlers.c:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /**
22 | * @file
23 | *
24 | * Handler companions for generated BPLib OS stubs
25 | */
26 |
27 | /* UT includes */
28 | #include "uttest.h"
29 | #include "utstubs.h"
30 | #include "utgenstub.h"
31 |
32 | /*----------------------------------------------------------------
33 | *
34 | * This just translates the 32-bit return status into a 64-bit
35 | *
36 | *-----------------------------------------------------------------*/
37 | void UT_DefaultHandler_bplib_os_get_dtntime_ms(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
38 | {
39 | int32 StatusCode;
40 | uint64_t Result;
41 |
42 | UT_Stub_GetInt32StatusCode(Context, &StatusCode);
43 |
44 | Result = StatusCode;
45 |
46 | UT_Stub_SetReturnValue(FuncKey, Result);
47 | }
48 |
--------------------------------------------------------------------------------
/posix.mk:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # File: posix.mk
3 | #
4 | # Copyright 2019 United States Government as represented by the
5 | # Administrator of the National Aeronautics and Space Administration.
6 | # All Other Rights Reserved.
7 | #
8 | # This software was created at NASA's Goddard Space Flight Center.
9 | # This software is governed by the NASA Open Source Agreement and may be
10 | # used, distributed and modified only pursuant to the terms of that
11 | # agreement.
12 | #
13 | # Maintainer(s):
14 | # Joe-Paul Swinski, Code 582 NASA GSFC
15 | #
16 | # Note:
17 | # See 'Makefile' in same directory for where this is included
18 | ###############################################################################
19 |
20 | ###############################################################################
21 | ## PLATFORM SPECIFIC OBJECTS
22 |
23 | APP_OBJ += posix.o
24 |
25 | ###############################################################################
26 | ## OPTIONS
27 |
28 | # Optimization Level #
29 | APP_COPT += -O0
30 |
31 | # Build Unit Tests #
32 | BUILD_UNITTESTS=1
33 | APP_COPT += -DUNITTESTS
34 | APP_COPT += -DBP_LOCAL_SCOPE="" # removes static designator so that local functions can be unit tested
35 |
36 | # GNU Code Coverage #
37 | APP_COPT += -fprofile-arcs -ftest-coverage
38 | APP_LOPT += -lgcov --coverage
39 |
40 | # Enable Stack Checker #
41 | APP_COPT += -fstack-protector-all
42 |
43 | # Enable Toolchain Specific Checks #
44 | ifeq ($(CC), cc)
45 | APP_COPT += -Wlogical-op
46 | endif
47 |
48 |
--------------------------------------------------------------------------------
/release.mk:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # File: release.mk
3 | #
4 | # Copyright 2019 United States Government as represented by the
5 | # Administrator of the National Aeronautics and Space Administration.
6 | # All Other Rights Reserved.
7 | #
8 | # This software was created at NASA's Goddard Space Flight Center.
9 | # This software is governed by the NASA Open Source Agreement and may be
10 | # used, distributed and modified only pursuant to the terms of that
11 | # agreement.
12 | #
13 | # Maintainer(s):
14 | # Joe-Paul Swinski, Code 582 NASA GSFC
15 | #
16 | # Note:
17 | # See 'Makefile' in same directory for where this is included
18 | ###############################################################################
19 |
20 | ###############################################################################
21 | ## PLATFORM SPECIFIC OBJECTS
22 |
23 | APP_OBJ += posix.o
24 |
25 | ###############################################################################
26 | ## OPTIONS
27 |
28 | # Optimization Level #
29 | APP_COPT += -O3
30 |
31 | # Disable Asserts #
32 | APP_COPT += -DNDEBUG
33 |
--------------------------------------------------------------------------------
/ut-functional/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # coverage test build recipe
4 | #
5 | # This CMake file contains the recipe for building the coverage tests.
6 | # It is invoked from the parent directory when unit tests are enabled.
7 | #
8 | ##################################################################
9 |
10 | # Add executable
11 | add_executable(functional-bplib_sanity-testrunner
12 | sanity-test.c
13 | )
14 |
15 | target_compile_features(functional-bplib_sanity-testrunner PUBLIC c_std_99)
16 | target_compile_options(functional-bplib_sanity-testrunner PUBLIC ${BPLIB_COMMON_COMPILE_OPTIONS})
17 |
18 | # Allow backdoor function calls, in some submodules, for now
19 | # The sanity check is currently calling some submodule functions directly
20 | # These are public at the submodule scope, but not external to bplib
21 | target_include_directories(functional-bplib_sanity-testrunner PRIVATE
22 | $
23 | $
24 | )
25 |
26 | target_link_libraries(functional-bplib_sanity-testrunner PUBLIC
27 | bplib
28 | ut_assert
29 | osal
30 | )
31 |
32 | add_test(functional-bplib_sanity-testrunner functional-bplib_sanity-testrunner)
33 |
34 | # Install the executables to a staging area for test in cross environments
35 | if (INSTALL_TARGET_LIST)
36 | foreach(TGT ${INSTALL_TARGET_LIST})
37 | install(TARGETS functional-bplib_sanity-testrunner DESTINATION ${TGT}/${UT_INSTALL_SUBDIR})
38 | endforeach()
39 | endif()
40 |
--------------------------------------------------------------------------------
/ut-stubs/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(coverage-bplib-stubs
2 | bplib_stubs.c
3 | bplib_routing_stubs.c
4 | )
5 | target_include_directories(coverage-bplib-stubs PUBLIC
6 | $
7 | )
8 | target_link_libraries(coverage-bplib-stubs PUBLIC
9 | ut_assert
10 | )
11 |
--------------------------------------------------------------------------------
/v7/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # Bundle Protocol Library (BPLib) CMake build recipe
4 | #
5 | # This is for the "mpool" submodule, which applies only to the
6 | # v7 build.
7 | #
8 | ##################################################################
9 |
10 | # The BPv7 codec code currently uses the TinyCBOR external library
11 | # Use pkg-config to locate tinycbor dependency (for now)
12 | find_package(PkgConfig)
13 | pkg_search_module(TINYCBOR tinycbor REQUIRED)
14 | message(STATUS "Found tinycbor version ${TINYCBOR_VERSION}")
15 |
16 | add_library(bplib_v7 OBJECT
17 | src/v7_codec_common.c
18 | src/v7_encode_api.c
19 | src/v7_decode_api.c
20 | src/v7_bp_basetypes.c
21 | src/v7_bp_container.c
22 | src/v7_bp_bitmap.c
23 | src/v7_bp_crc.c
24 | src/v7_bp_endpointid.c
25 | src/v7_bp_primary_block.c
26 | src/v7_bp_admin_record.c
27 | src/v7_bp_canonical_block.c
28 | src/v7_bp_bundle_age_block.c
29 | src/v7_bp_hop_count_block.c
30 | src/v7_bp_previous_node_block.c
31 | src/v7_custody_tracking_block.c
32 | src/v7_custody_acknowledgement_record.c
33 | src/v7.c
34 | )
35 |
36 | target_include_directories(bplib_v7 PRIVATE
37 | # nothing outside of here should directly call TinyCBOR, so this
38 | # can be considered private to this submodule
39 | ${TINYCBOR_INCLUDE_DIRS}
40 | $
41 | )
42 |
43 | target_include_directories(bplib_v7 PUBLIC
44 | # Local include files
45 | ${CMAKE_CURRENT_SOURCE_DIR}/inc
46 |
47 | # other bplib submodules used by this submodule
48 | $
49 | $
50 | $
51 | $
52 | $
53 | )
54 |
55 | # Add unit test coverage subdirectory
56 | if(BPLIB_ENABLE_UNIT_TESTS)
57 | add_subdirectory(ut-stubs)
58 | add_subdirectory(ut-coverage)
59 | endif(BPLIB_ENABLE_UNIT_TESTS)
60 |
--------------------------------------------------------------------------------
/v7/inc/v7.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | #ifndef v7_h
22 | #define v7_h
23 |
24 | /******************************************************************************
25 | INCLUDES
26 | ******************************************************************************/
27 |
28 | #include "v7_types.h"
29 |
30 | /******************************************************************************
31 | DEFINES
32 | ******************************************************************************/
33 |
34 | /******************************************************************************
35 | EXPORTED FUNCTIONS
36 | ******************************************************************************/
37 |
38 | bp_dtntime_t v7_get_current_time(void);
39 | void v7_set_eid(bp_endpointid_buffer_t *eid, const bp_ipn_addr_t *bp_addr);
40 | void v7_get_eid(bp_ipn_addr_t *bp_addr, const bp_endpointid_buffer_t *eid);
41 |
42 | static inline int v7_compare_numeric(bp_val_t n1, bp_val_t n2)
43 | {
44 | if (n1 == n2)
45 | {
46 | return 0;
47 | }
48 | if (n1 > n2)
49 | {
50 | return 1;
51 | }
52 | return -1;
53 | }
54 |
55 | /* A generic strcmp-like call to compare an IPN address to a BP endpoint ID value */
56 | int v7_compare_ipn2eid(const bp_ipn_addr_t *ipn, const bp_endpointid_buffer_t *eid);
57 | /* A generic strcmp-like call to compare two IPN addresses */
58 | int v7_compare_ipn2ipn(const bp_ipn_addr_t *ipn1, const bp_ipn_addr_t *ipn2);
59 |
60 | #endif /* v7_h */
61 |
--------------------------------------------------------------------------------
/v7/inc/v7_codec.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | #ifndef V7_CODEC_H
22 | #define V7_CODEC_H
23 |
24 | /******************************************************************************
25 | INCLUDES
26 | ******************************************************************************/
27 |
28 | #include "bplib.h"
29 | #include "v7_mpool.h"
30 | #include "v7_types.h"
31 | #include "v7_decode.h"
32 | #include "v7_encode.h"
33 |
34 | size_t v7_compute_full_bundle_size(bplib_mpool_bblock_primary_t *cpb);
35 | size_t v7_copy_full_bundle_out(bplib_mpool_bblock_primary_t *cpb, void *buffer, size_t buf_sz);
36 | size_t v7_copy_full_bundle_in(bplib_mpool_bblock_primary_t *cpb, const void *buffer, size_t buf_sz);
37 |
38 | #endif /* V7_CODEC_H */
39 |
--------------------------------------------------------------------------------
/v7/inc/v7_decode.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | #ifndef V7_DECODE_H
22 | #define V7_DECODE_H
23 |
24 | /******************************************************************************
25 | INCLUDES
26 | ******************************************************************************/
27 |
28 | #include "bplib.h"
29 | #include "v7_mpool.h"
30 | #include "v7_types.h"
31 |
32 | /*
33 | * On the decode side of things, the bundle buffer is passed in from the network/CLA and all that is known will
34 | * be a pointer and size. The first block is always supposed to be primary (per BP) and every block thereafter
35 | * can be assumed canonical. Payload of the bundle will be recorded as an offset and size into that block, there
36 | * is no separate output.
37 | */
38 | int v7_block_decode_pri(bplib_mpool_bblock_primary_t *cpb, const void *data_ptr, size_t data_size);
39 | int v7_block_decode_canonical(bplib_mpool_bblock_canonical_t *ccb, const void *data_ptr, size_t data_size,
40 | bp_blocktype_t payload_block_hint);
41 |
42 | #endif /* V7_DECODE_H */
43 |
--------------------------------------------------------------------------------
/v7/inc/v7_encode.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | #ifndef V7_ENCODE_H
22 | #define V7_ENCODE_H
23 |
24 | /******************************************************************************
25 | INCLUDES
26 | ******************************************************************************/
27 |
28 | #include "bplib.h"
29 | #include "v7_mpool.h"
30 | #include "v7_types.h"
31 |
32 | /*
33 | * On the encode side of things, the block types are known ahead of time. Encoding of a payload block is separate
34 | * because the data needs to be passed in, but for all other canonical block types all the information should already be
35 | * in the logical data - so nothing extra is needed (but this may change as more block types get implemented, too).
36 | * One possible option would be to pass in NULL/0 for the block types that do not have separate data, to keep the APIs
37 | * more consistent.
38 | */
39 | int v7_block_encode_pri(bplib_mpool_bblock_primary_t *cpb);
40 | int v7_block_encode_pay(bplib_mpool_bblock_canonical_t *ccb, const void *data_ptr, size_t data_size);
41 |
42 | int v7_block_encode_canonical(bplib_mpool_bblock_canonical_t *ccb);
43 |
44 | #endif /* V7_ENCODE_H */
45 |
--------------------------------------------------------------------------------
/v7/src/v7.c:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /******************************************************************************
22 | INCLUDES
23 | ******************************************************************************/
24 |
25 | #include
26 |
27 | #include
28 |
29 | #include "bplib.h"
30 | #include "bplib_os.h"
31 | #include "crc.h"
32 | #include "v7.h"
33 | #include "v7_types.h"
34 | #include "v7_codec.h"
35 | #include "v7_mpool.h"
36 |
37 | /******************************************************************************
38 | DEFINES
39 | ******************************************************************************/
40 |
41 | /******************************************************************************
42 | TYPEDEFS
43 | ******************************************************************************/
44 |
45 | typedef struct bp_blocks
46 | {
47 | bplib_mpool_block_t pblk;
48 | } bp_v7block_t;
49 |
50 | /******************************************************************************
51 | FUNCTIONS
52 | ******************************************************************************/
53 |
54 | void v7_init_ipn_eid(bp_endpointid_buffer_t *eid, bp_ipn_t node, bp_ipn_t service)
55 | {
56 | eid->scheme = bp_endpointid_scheme_ipn;
57 | eid->ssp.ipn.node_number = node;
58 | eid->ssp.ipn.service_number = service;
59 | }
60 |
61 | void v7_set_eid(bp_endpointid_buffer_t *eid, const bp_ipn_addr_t *bp_addr)
62 | {
63 | eid->scheme = bp_endpointid_scheme_ipn;
64 | eid->ssp.ipn.node_number = bp_addr->node_number;
65 | eid->ssp.ipn.service_number = bp_addr->service_number;
66 | }
67 |
68 | void v7_get_eid(bp_ipn_addr_t *bp_addr, const bp_endpointid_buffer_t *eid)
69 | {
70 | if (eid->scheme == bp_endpointid_scheme_ipn)
71 | {
72 | bp_addr->node_number = eid->ssp.ipn.node_number;
73 | bp_addr->service_number = eid->ssp.ipn.service_number;
74 | }
75 | else
76 | {
77 | bp_addr->node_number = 0;
78 | bp_addr->service_number = 0;
79 | }
80 | }
81 |
82 | int v7_compare_ipn2eid(const bp_ipn_addr_t *ipn, const bp_endpointid_buffer_t *eid)
83 | {
84 | int result;
85 |
86 | result = v7_compare_numeric(eid->scheme, bp_endpointid_scheme_ipn);
87 | if (result == 0)
88 | {
89 | result = v7_compare_numeric(ipn->node_number, eid->ssp.ipn.node_number);
90 | if (result == 0)
91 | {
92 | result = v7_compare_numeric(ipn->service_number, eid->ssp.ipn.service_number);
93 | }
94 | }
95 |
96 | return result;
97 | }
98 |
99 | int v7_compare_ipn2ipn(const bp_ipn_addr_t *ipn1, const bp_ipn_addr_t *ipn2)
100 | {
101 | int result;
102 |
103 | result = v7_compare_numeric(ipn1->node_number, ipn2->node_number);
104 | if (result == 0)
105 | {
106 | result = v7_compare_numeric(ipn1->service_number, ipn2->service_number);
107 | }
108 |
109 | return result;
110 | }
111 |
112 | bp_dtntime_t v7_get_current_time(void)
113 | {
114 | return bplib_os_get_dtntime_ms();
115 | }
116 |
--------------------------------------------------------------------------------
/v7/src/v7_bp_bitmap.c:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /******************************************************************************
22 | INCLUDES
23 | ******************************************************************************/
24 |
25 | #include "v7_decode_internal.h"
26 | #include "v7_encode_internal.h"
27 |
28 | /*
29 | * -----------------------------------------------------------------------------------
30 | * IMPLEMENTATION
31 | * Helpers for encoding/decoding of individual protocol elements
32 | * -----------------------------------------------------------------------------------
33 | */
34 |
35 | void v7_encode_bitmap(v7_encode_state_t *enc, const uint8_t *v, const v7_bitmap_table_t *ptbl)
36 | {
37 | bp_integer_t value;
38 |
39 | value = 0;
40 | while (ptbl->mask != 0)
41 | {
42 | if (v[ptbl->offset])
43 | {
44 | value |= ptbl->mask;
45 | }
46 | ++ptbl;
47 | }
48 |
49 | v7_encode_bp_integer(enc, &value);
50 | }
51 |
52 | void v7_decode_bitmap(v7_decode_state_t *dec, uint8_t *v, const v7_bitmap_table_t *ptbl)
53 | {
54 | bp_integer_t value;
55 |
56 | v7_decode_bp_integer(dec, &value);
57 | while (ptbl->mask != 0)
58 | {
59 | v[ptbl->offset] = (value & ptbl->mask) != 0;
60 | ++ptbl;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/v7/src/v7_bp_bundle_age_block.c:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /******************************************************************************
22 | INCLUDES
23 | ******************************************************************************/
24 |
25 | #include "v7_decode_internal.h"
26 | #include "v7_encode_internal.h"
27 |
28 | /*
29 | * -----------------------------------------------------------------------------------
30 | * Helpers for encoding/decoding of individual protocol elements
31 | *
32 | * Each type used in the bpv7 protocol structures should get a separate encode/decode
33 | * routine here. However these are not expected to be called externally, because one
34 | * must know what structure should be occuring at this specific position in the CBOR
35 | * stream. The only externally-callable routines should operate at the block level.
36 | *
37 | * If a failure occurs, these set the "error" flag within the state struct. Such
38 | * an error probably means any further decoding/encoding is not possible because
39 | * it may throw off the position in the CBOR stream.
40 | * -----------------------------------------------------------------------------------
41 | */
42 |
43 | void v7_encode_bp_bundle_age_block(v7_encode_state_t *enc, const bp_bundle_age_block_t *v)
44 | {
45 | v7_encode_bp_dtntime(enc, &v->age);
46 | }
47 |
48 | void v7_decode_bp_bundle_age_block(v7_decode_state_t *dec, bp_bundle_age_block_t *v)
49 | {
50 | v7_decode_bp_dtntime(dec, &v->age);
51 | }
52 |
--------------------------------------------------------------------------------
/v7/src/v7_bp_hop_count_block.c:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /******************************************************************************
22 | INCLUDES
23 | ******************************************************************************/
24 |
25 | #include "v7_decode_internal.h"
26 | #include "v7_encode_internal.h"
27 |
28 | typedef enum bp_hop_count_field
29 | {
30 | bp_hop_count_field_undef,
31 | bp_hop_count_field_limit,
32 | bp_hop_count_field_count,
33 | bp_hop_count_field_done
34 | } bp_hop_count_field_t;
35 |
36 | /*
37 | * -----------------------------------------------------------------------------------
38 | * IMPLEMENTATION
39 | * Helpers for encoding/decoding of individual protocol elements
40 | * -----------------------------------------------------------------------------------
41 | */
42 |
43 | void v7_encode_bp_hop_count_block_impl(v7_encode_state_t *enc, const void *arg)
44 | {
45 | const bp_hop_count_block_t *v = arg;
46 | bp_hop_count_field_t field_id = bp_hop_count_field_undef;
47 |
48 | while (field_id < bp_hop_count_field_done && !enc->error)
49 | {
50 | switch (field_id)
51 | {
52 | case bp_hop_count_field_limit:
53 | v7_encode_bp_integer(enc, &v->hopLimit);
54 | break;
55 | case bp_hop_count_field_count:
56 | v7_encode_bp_integer(enc, &v->hopCount);
57 | break;
58 | default:
59 | break;
60 | }
61 |
62 | ++field_id;
63 | }
64 | }
65 |
66 | void v7_encode_bp_hop_count_block(v7_encode_state_t *enc, const bp_hop_count_block_t *v)
67 | {
68 | v7_encode_container(enc, 2, v7_encode_bp_hop_count_block_impl, v);
69 | }
70 |
71 | void v7_decode_bp_hop_count_block_impl(v7_decode_state_t *dec, void *arg)
72 | {
73 | bp_hop_count_block_t *v = arg;
74 | bp_hop_count_field_t field_id = bp_hop_count_field_undef;
75 |
76 | while (field_id < bp_hop_count_field_done && !dec->error && !cbor_value_at_end(dec->cbor))
77 | {
78 | switch (field_id)
79 | {
80 | case bp_hop_count_field_limit:
81 | v7_decode_bp_integer(dec, &v->hopLimit);
82 | break;
83 | case bp_hop_count_field_count:
84 | v7_decode_bp_integer(dec, &v->hopCount);
85 | break;
86 | default:
87 | break;
88 | }
89 |
90 | ++field_id;
91 | }
92 | }
93 |
94 | void v7_decode_bp_hop_count_block(v7_decode_state_t *dec, bp_hop_count_block_t *v)
95 | {
96 | v7_decode_container(dec, 2, v7_decode_bp_hop_count_block_impl, v);
97 | }
98 |
--------------------------------------------------------------------------------
/v7/src/v7_bp_previous_node_block.c:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /******************************************************************************
22 | INCLUDES
23 | ******************************************************************************/
24 |
25 | #include "v7_encode_internal.h"
26 | #include "v7_decode_internal.h"
27 |
28 | /*
29 | * -----------------------------------------------------------------------------------
30 | * IMPLEMENTATION
31 | * Helpers for encoding/decoding of individual protocol elements
32 | * -----------------------------------------------------------------------------------
33 | */
34 | void v7_encode_bp_previous_node_block(v7_encode_state_t *enc, const bp_previous_node_block_t *v)
35 | {
36 | v7_encode_bp_endpointid_buffer(enc, &v->nodeId);
37 | }
38 |
39 | void v7_decode_bp_previous_node_block(v7_decode_state_t *dec, bp_previous_node_block_t *v)
40 | {
41 | v7_decode_bp_endpointid_buffer(dec, &v->nodeId);
42 | }
43 |
--------------------------------------------------------------------------------
/v7/src/v7_codec_internal.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | #ifndef V7_CODEC_INTERNAL_H
22 | #define V7_CODEC_INTERNAL_H
23 |
24 | /******************************************************************************
25 | INCLUDES
26 | ******************************************************************************/
27 |
28 | #include "bplib.h"
29 | #include "v7_mpool.h"
30 | #include "v7_types.h"
31 | #include "v7_decode.h"
32 | #include "v7_encode.h"
33 | #include "v7_codec.h"
34 | #include "v7_mpool_bblocks.h"
35 | #include "v7_mpstream.h"
36 | #include "crc.h"
37 |
38 | typedef struct
39 | {
40 | const bp_canonical_bundle_block_t *encode_block;
41 | bp_canonical_bundle_block_t *decode_block;
42 | const void *content_vptr;
43 | size_t *content_offset_out;
44 | size_t content_size;
45 |
46 | } v7_canonical_block_info_t;
47 |
48 | typedef struct v7_bitmap_table
49 | {
50 | size_t offset;
51 | bp_integer_t mask;
52 | } v7_bitmap_table_t;
53 |
54 | bplib_crc_parameters_t *v7_codec_get_crc_algorithm(bp_crctype_t crctype);
55 | size_t v7_sum_preencoded_size(bplib_mpool_block_t *list);
56 | void v7_init_ipn_eid(bp_endpointid_buffer_t *eid, bp_ipn_t node, bp_ipn_t service);
57 | size_t v7_sum_preencoded_size(bplib_mpool_block_t *list);
58 | #endif /* V7_CODEC_INTERNAL_H */
59 |
--------------------------------------------------------------------------------
/v7/src/v7_custody_acknowledgement_record.c:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /******************************************************************************
22 | INCLUDES
23 | ******************************************************************************/
24 |
25 | #include "v7_decode_internal.h"
26 | #include "v7_encode_internal.h"
27 |
28 | /*
29 | * -----------------------------------------------------------------------------------
30 | * IMPLEMENTATION
31 | * Helpers for encoding/decoding of individual protocol elements
32 | * -----------------------------------------------------------------------------------
33 | */
34 |
35 | void v7_encode_bp_custody_acceptance_seqlist_impl(v7_encode_state_t *enc, const void *arg)
36 | {
37 | const bp_custody_accept_payload_block_t *v = arg;
38 | bp_integer_t n;
39 |
40 | for (n = 0; n < v->num_entries && !enc->error; ++n)
41 | {
42 | v7_encode_bp_integer(enc, &v->sequence_nums[n]);
43 | }
44 | }
45 |
46 | static void v7_encode_bp_custody_acknowledement_record_impl(v7_encode_state_t *enc, const void *arg)
47 | {
48 | const bp_custody_accept_payload_block_t *v = arg;
49 |
50 | v7_encode_bp_endpointid_buffer(enc, &v->flow_source_eid);
51 | v7_encode_container(enc, v->num_entries, v7_encode_bp_custody_acceptance_seqlist_impl, v);
52 | }
53 |
54 | void v7_encode_bp_custody_acknowledement_record(v7_encode_state_t *enc, const bp_custody_accept_payload_block_t *v)
55 | {
56 | v7_encode_container(enc, 2, v7_encode_bp_custody_acknowledement_record_impl, v);
57 | }
58 |
59 | void v7_decode_bp_custody_acceptance_seqlist_impl(v7_decode_state_t *dec, void *arg)
60 | {
61 | bp_custody_accept_payload_block_t *v = arg;
62 |
63 | while (!cbor_value_at_end(dec->cbor) && v->num_entries < BP_DACS_MAX_SEQ_PER_PAYLOAD)
64 | {
65 | v7_decode_bp_integer(dec, &v->sequence_nums[v->num_entries]);
66 | if (dec->error)
67 | {
68 | break;
69 | }
70 |
71 | ++v->num_entries;
72 | }
73 | }
74 |
75 | void v7_decode_bp_custody_acknowledement_record_impl(v7_decode_state_t *dec, void *arg)
76 | {
77 | bp_custody_accept_payload_block_t *v = arg;
78 |
79 | v7_decode_bp_endpointid_buffer(dec, &v->flow_source_eid);
80 | v7_decode_container(dec, CborIndefiniteLength, v7_decode_bp_custody_acceptance_seqlist_impl, v);
81 | }
82 |
83 | void v7_decode_bp_custody_acknowledement_record(v7_decode_state_t *dec, bp_custody_accept_payload_block_t *v)
84 | {
85 | v7_decode_container(dec, 2, v7_decode_bp_custody_acknowledement_record_impl, v);
86 | }
87 |
--------------------------------------------------------------------------------
/v7/src/v7_custody_tracking_block.c:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /******************************************************************************
22 | INCLUDES
23 | ******************************************************************************/
24 |
25 | #include "v7_decode_internal.h"
26 | #include "v7_encode_internal.h"
27 |
28 | /*
29 | * -----------------------------------------------------------------------------------
30 | * IMPLEMENTATION
31 | * Helpers for encoding/decoding of individual protocol elements
32 | * -----------------------------------------------------------------------------------
33 | */
34 |
35 | void v7_encode_bp_custody_tracking_block(v7_encode_state_t *enc, const bp_custody_tracking_block_t *v)
36 | {
37 | v7_encode_bp_endpointid_buffer(enc, &v->current_custodian);
38 | }
39 |
40 | void v7_decode_bp_custody_tracking_block(v7_decode_state_t *dec, bp_custody_tracking_block_t *v)
41 | {
42 | v7_decode_bp_endpointid_buffer(dec, &v->current_custodian);
43 | }
44 |
--------------------------------------------------------------------------------
/v7/ut-coverage/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # coverage test build recipe
4 | #
5 | # This CMake file contains the recipe for building the coverage tests.
6 | # It is invoked from the parent directory when unit tests are enabled.
7 | #
8 | ##################################################################
9 |
10 | add_library(utobj_bplib_v7 OBJECT
11 | ../src/v7.c
12 | ../src/v7_codec_common.c
13 | ../src/v7_encode_api.c
14 | ../src/v7_decode_api.c
15 | ../src/v7_bp_basetypes.c
16 | ../src/v7_bp_container.c
17 | ../src/v7_bp_bitmap.c
18 | ../src/v7_bp_crc.c
19 | ../src/v7_bp_endpointid.c
20 | ../src/v7_bp_primary_block.c
21 | ../src/v7_bp_admin_record.c
22 | ../src/v7_bp_canonical_block.c
23 | ../src/v7_bp_bundle_age_block.c
24 | ../src/v7_bp_hop_count_block.c
25 | ../src/v7_bp_previous_node_block.c
26 | ../src/v7_custody_tracking_block.c
27 | ../src/v7_custody_acknowledgement_record.c
28 | )
29 |
30 | target_compile_definitions(utobj_bplib_v7 PRIVATE
31 | $
32 | $
33 | )
34 |
35 | target_compile_options(utobj_bplib_v7 PRIVATE
36 | $
37 | $
38 | )
39 |
40 | target_include_directories(utobj_bplib_v7 PRIVATE
41 | $
42 | $
43 | )
44 |
45 | # Add executable
46 | add_executable(coverage-bplib_v7-testrunner
47 | test_bplib_v7_setup.c
48 | cbor_stubs.c
49 | test_v7.c
50 | test_v7_bp_admin_record.c
51 | test_v7_bp_basetypes.c
52 | test_v7_bp_bitmap.c
53 | test_v7_bp_bundle_age_block.c
54 | test_v7_bp_canonical_block.c
55 | test_v7_bp_container.c
56 | test_v7_bp_crc.c
57 | test_v7_bp_endpointid.c
58 | test_v7_bp_hop_count_block.c
59 | test_v7_bp_previous_node_block.c
60 | test_v7_bp_primary_block.c
61 | test_v7_codec_common.c
62 | test_v7_custody_acknowledgement_record.c
63 | test_v7_custody_tracking_block.c
64 | test_v7_decode_api.c
65 | test_v7_encode_api.c
66 | $
67 | )
68 |
69 | target_include_directories(coverage-bplib_v7-testrunner PRIVATE
70 | ../src
71 | $
72 | )
73 |
74 | target_link_libraries(coverage-bplib_v7-testrunner PUBLIC
75 | ut_coverage_link
76 | bplib_mpool_stubs
77 | bplib_common_stubs
78 | bplib_os_stubs
79 | ut_assert
80 | )
81 |
82 | add_test(coverage-bplib_v7-testrunner coverage-bplib_v7-testrunner)
83 |
84 | # Install the executables to a staging area for test in cross environments
85 | if (INSTALL_TARGET_LIST)
86 | foreach(TGT ${INSTALL_TARGET_LIST})
87 | install(TARGETS coverage-bplib_v7-testrunner DESTINATION ${TGT}/${UT_INSTALL_SUBDIR})
88 | endforeach()
89 | endif()
90 |
--------------------------------------------------------------------------------
/v7/ut-coverage/test_bplib_v7.h:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3 | *
4 | * Copyright (c) 2020 United States Government as represented by the
5 | * Administrator of the National Aeronautics and Space Administration.
6 | * All Rights Reserved.
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 | * not use this file except in compliance with the License. You may obtain
10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | ************************************************************************/
18 |
19 | #ifndef TEST_BPLIB_V7_H
20 | #define TEST_BPLIB_V7_H
21 |
22 | #include "utassert.h"
23 | #include "utstubs.h"
24 | #include "uttest.h"
25 | #include "cbor.h"
26 | #include "v7.h"
27 | #include "v7_codec.h"
28 | #include "v7_mpool_bblocks.h"
29 | #include "v7_codec_internal.h"
30 | #include "v7_decode_internal.h"
31 | #include "v7_encode_internal.h"
32 | #include "bplib_os.h"
33 |
34 | void UT_V7_AltHandler_PointerReturn(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
35 | void UT_V7_GetTime_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
36 | void UT_V7_sizet_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
37 | void UT_V7_uint64_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
38 | void UT_V7_int8_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
39 | void UT_V7_uint8_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context);
40 | int test_bplib_v7_writer_func_stub(void *arg, const void *data_ptr, size_t data_len);
41 | void test_bplib_v7_encode_func_stub(v7_encode_state_t *enc, const void *arg);
42 | void test_bplib_v7_decode_func_stub(v7_decode_state_t *dec, void *arg);
43 |
44 | void TestBpV7_Register(void);
45 | void TestBpV7AdminRecord_Register(void);
46 | void TestBpV7Basetypes_Register(void);
47 | void TestBpV7Bitmap_Register(void);
48 | void TestBpV7BundleAgeBlock_Register(void);
49 | void TestBpV7CanonicalBlock_Rgister(void);
50 | void TestV7BpContainer_Rgister(void);
51 | void TestV7BpCrc_Rgister(void);
52 | void TestV7BpEndpointid_Rgister(void);
53 | void TestV7BpHopCountBlock_Rgister(void);
54 | void TestV7BpPreviousNodeBlock_Rgister(void);
55 | void TestV7BpPrimaryBlock_Rgister(void);
56 | void TestV7CodecCommon_Rgister(void);
57 | void TestV7CustodyAcknowledgementRecord_Rgister(void);
58 | void TestV7CustodyTrackingRecord_Rgister(void);
59 | void TestV7DecodecApi_Rgister(void);
60 | void TestV7EncodeApi_Rgister(void);
61 |
62 | #endif
63 |
--------------------------------------------------------------------------------
/v7/ut-coverage/test_bplib_v7_setup.c:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3 | *
4 | * Copyright (c) 2020 United States Government as represented by the
5 | * Administrator of the National Aeronautics and Space Administration.
6 | * All Rights Reserved.
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 | * not use this file except in compliance with the License. You may obtain
10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | ************************************************************************/
18 |
19 | /*
20 | * Includes
21 | */
22 | #include "test_bplib_v7.h"
23 |
24 | void UT_V7_AltHandler_PointerReturn(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
25 | {
26 | UT_Stub_SetReturnValue(FuncKey, UserObj);
27 | }
28 |
29 | void UT_V7_GetTime_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
30 | {
31 | uint64_t retval = 0;
32 | UT_Stub_SetReturnValue(FuncKey, retval);
33 | }
34 |
35 | void UT_V7_sizet_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
36 | {
37 | size_t retval = 0;
38 | UT_Stub_SetReturnValue(FuncKey, retval);
39 | }
40 |
41 | void UT_V7_uint64_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
42 | {
43 | int32 StatusCode;
44 | uint64_t Result;
45 |
46 | UT_Stub_GetInt32StatusCode(Context, &StatusCode);
47 |
48 | Result = StatusCode;
49 |
50 | UT_Stub_SetReturnValue(FuncKey, Result);
51 | }
52 |
53 | void UT_V7_int8_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
54 | {
55 | int8 retval = 0;
56 | UT_Stub_SetReturnValue(FuncKey, retval);
57 | }
58 |
59 | void UT_V7_uint8_Handler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
60 | {
61 | int32 StatusCode;
62 | uint8_t Result;
63 |
64 | UT_Stub_GetInt32StatusCode(Context, &StatusCode);
65 |
66 | Result = StatusCode;
67 |
68 | UT_Stub_SetReturnValue(FuncKey, Result);
69 | }
70 |
71 | int test_bplib_v7_writer_func_stub(void *arg, const void *data_ptr, size_t data_len)
72 | {
73 | return UT_DEFAULT_IMPL(test_bplib_v7_writer_func_stub);
74 | }
75 |
76 | void test_bplib_v7_encode_func_stub(v7_encode_state_t *enc, const void *arg) {}
77 |
78 | void test_bplib_v7_decode_func_stub(v7_decode_state_t *dec, void *arg) {}
79 |
80 | void UtTest_Setup(void)
81 | {
82 | TestBpV7_Register();
83 | TestBpV7AdminRecord_Register();
84 | TestBpV7Basetypes_Register();
85 | TestBpV7Bitmap_Register();
86 | TestBpV7BundleAgeBlock_Register();
87 | TestBpV7CanonicalBlock_Rgister();
88 | TestV7BpContainer_Rgister();
89 | TestV7BpCrc_Rgister();
90 | TestV7BpEndpointid_Rgister();
91 | TestV7BpHopCountBlock_Rgister();
92 | TestV7BpPreviousNodeBlock_Rgister();
93 | TestV7BpPrimaryBlock_Rgister();
94 | TestV7CodecCommon_Rgister();
95 | TestV7CustodyAcknowledgementRecord_Rgister();
96 | TestV7CustodyTrackingRecord_Rgister();
97 | TestV7DecodecApi_Rgister();
98 | TestV7EncodeApi_Rgister();
99 | }
100 |
--------------------------------------------------------------------------------
/v7/ut-coverage/test_v7_bp_bitmap.c:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3 | *
4 | * Copyright (c) 2020 United States Government as represented by the
5 | * Administrator of the National Aeronautics and Space Administration.
6 | * All Rights Reserved.
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 | * not use this file except in compliance with the License. You may obtain
10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | ************************************************************************/
18 |
19 | /*
20 | * Includes
21 | */
22 | #include "test_bplib_v7.h"
23 |
24 | void test_v7_encode_bitmap(void)
25 | {
26 | /* Test function for:
27 | * void v7_encode_bitmap(v7_encode_state_t *enc, const uint8_t *v, const v7_bitmap_table_t *ptbl)
28 | */
29 | v7_encode_state_t enc;
30 | uint8_t v[5] = { 1, 0, 1, 0, 1 };
31 | v7_bitmap_table_t ptbl[2] = {{0}, {0}};
32 |
33 | memset(&enc, 0, sizeof(v7_decode_state_t));
34 | enc.error = true;
35 | ptbl[0].mask = 1;
36 |
37 | UtAssert_VOIDCALL(v7_encode_bitmap(&enc, v, ptbl));
38 | }
39 |
40 | void test_v7_decode_bitmap(void)
41 | {
42 | /* Test function for:
43 | * void v7_decode_bitmap(v7_decode_state_t *dec, uint8_t *v, const v7_bitmap_table_t *ptbl)
44 | */
45 | v7_decode_state_t dec;
46 | uint8_t v;
47 | v7_bitmap_table_t ptbl[2] = {{0}, {0}};
48 |
49 | memset(&dec, 0, sizeof(v7_decode_state_t));
50 | memset(&v, 0, sizeof(uint8_t));
51 | dec.error = true;
52 | ptbl[0].mask = 1;
53 |
54 | UtAssert_VOIDCALL(v7_decode_bitmap(&dec, &v, ptbl));
55 | }
56 |
57 | void TestBpV7Bitmap_Register(void)
58 | {
59 | UtTest_Add(test_v7_encode_bitmap, NULL, NULL, "Test v7_decode_bitmap");
60 | UtTest_Add(test_v7_decode_bitmap, NULL, NULL, "Test v7_decode_bitmap");
61 | }
62 |
--------------------------------------------------------------------------------
/v7/ut-coverage/test_v7_bp_bundle_age_block.c:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3 | *
4 | * Copyright (c) 2020 United States Government as represented by the
5 | * Administrator of the National Aeronautics and Space Administration.
6 | * All Rights Reserved.
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 | * not use this file except in compliance with the License. You may obtain
10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | ************************************************************************/
18 |
19 | /*
20 | * Includes
21 | */
22 | #include "test_bplib_v7.h"
23 |
24 | void test_v7_decode_bp_bundle_age_block(void)
25 | {
26 | /* Test function for:
27 | * void v7_decode_bp_bundle_age_block(v7_decode_state_t *dec, bp_bundle_age_block_t *v)
28 | */
29 | v7_decode_state_t dec;
30 | bp_bundle_age_block_t v;
31 |
32 | memset(&dec, 0, sizeof(v7_decode_state_t));
33 | memset(&v, 0, sizeof(bp_bundle_age_block_t));
34 | dec.error = true;
35 |
36 | UtAssert_VOIDCALL(v7_decode_bp_bundle_age_block(&dec, &v));
37 | }
38 |
39 | void TestBpV7BundleAgeBlock_Register(void)
40 | {
41 | UtTest_Add(test_v7_decode_bp_bundle_age_block, NULL, NULL, "Test v7_decode_bp_bundle_age_block");
42 | }
43 |
--------------------------------------------------------------------------------
/v7/ut-coverage/test_v7_bp_container.c:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3 | *
4 | * Copyright (c) 2020 United States Government as represented by the
5 | * Administrator of the National Aeronautics and Space Administration.
6 | * All Rights Reserved.
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 | * not use this file except in compliance with the License. You may obtain
10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | ************************************************************************/
18 |
19 | /*
20 | * Includes
21 | */
22 | #include "test_bplib_v7.h"
23 |
24 | void test_v7_encode_container(void)
25 | {
26 | /* Test function for:
27 | * void v7_encode_container(v7_encode_state_t *enc, size_t entries, v7_encode_func_t func, const void *arg)
28 | */
29 | v7_encode_state_t enc;
30 | size_t entries = 1;
31 | v7_encode_func_t func = test_bplib_v7_encode_func_stub;
32 | void *arg = NULL;
33 | CborEncoder cval;
34 |
35 | memset(&enc, 0, sizeof(v7_encode_state_t));
36 | memset(&cval, 0, sizeof(CborEncoder));
37 |
38 | enc.cbor = &cval;
39 | enc.error = false;
40 | UT_SetDefaultReturnValue(UT_KEY(cbor_encoder_close_container), CborUnknownError);
41 | UtAssert_VOIDCALL(v7_encode_container(&enc, entries, func, &arg));
42 |
43 | enc.error = false;
44 | UT_SetDefaultReturnValue(UT_KEY(cbor_encoder_create_array), CborUnknownError);
45 | UtAssert_VOIDCALL(v7_encode_container(&enc, entries, func, &arg));
46 | }
47 |
48 | void test_v7_decode_container(void)
49 | {
50 | /* Test function for:
51 | * void v7_decode_container(v7_decode_state_t *dec, size_t entries, v7_decode_func_t func, void *arg)
52 | */
53 | v7_decode_state_t dec;
54 | size_t entries = 1;
55 | v7_decode_func_t func = test_bplib_v7_decode_func_stub;
56 | void *arg = NULL;
57 | CborValue cval;
58 |
59 | memset(&dec, 0, sizeof(v7_decode_state_t));
60 | memset(&cval, 0, sizeof(CborValue));
61 |
62 | dec.cbor = &cval;
63 | dec.error = false;
64 | UtAssert_VOIDCALL(v7_decode_container(&dec, entries, func, &arg));
65 |
66 | dec.error = false;
67 | cval.remaining = 10;
68 | cval.type = CborArrayType;
69 | UT_SetDefaultReturnValue(UT_KEY(cbor_value_enter_container), CborUnknownError);
70 | UtAssert_VOIDCALL(v7_decode_container(&dec, entries, func, &arg));
71 |
72 | dec.error = false;
73 | UT_SetDefaultReturnValue(UT_KEY(cbor_value_enter_container), CborNoError);
74 | UT_SetDefaultReturnValue(UT_KEY(cbor_value_leave_container), CborUnknownError);
75 | UtAssert_VOIDCALL(v7_decode_container(&dec, entries, func, &arg));
76 | }
77 |
78 | void TestV7BpContainer_Rgister(void)
79 | {
80 | UtTest_Add(test_v7_encode_container, NULL, NULL, "Test v7_encode_container");
81 | UtTest_Add(test_v7_decode_container, NULL, NULL, "Test v7_decode_container");
82 | }
83 |
--------------------------------------------------------------------------------
/v7/ut-coverage/test_v7_bp_crc.c:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3 | *
4 | * Copyright (c) 2020 United States Government as represented by the
5 | * Administrator of the National Aeronautics and Space Administration.
6 | * All Rights Reserved.
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 | * not use this file except in compliance with the License. You may obtain
10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | ************************************************************************/
18 |
19 | /*
20 | * Includes
21 | */
22 | #include "test_bplib_v7.h"
23 |
24 | void test_v7_encode_crc(void)
25 | {
26 | /* Test function for:
27 | * void v7_encode_crc(v7_encode_state_t *enc)
28 | */
29 | v7_encode_state_t enc;
30 |
31 | memset(&enc, 0, sizeof(v7_encode_state_t));
32 |
33 | UT_SetDefaultReturnValue(UT_KEY(cbor_encode_byte_string), CborUnknownError);
34 | UtAssert_VOIDCALL(v7_encode_crc(&enc));
35 |
36 | UT_SetHandlerFunction(UT_KEY(bplib_crc_get_width), UT_V7_uint8_Handler, NULL);
37 | UT_SetDefaultReturnValue(UT_KEY(bplib_crc_get_width), 40);
38 | UtAssert_VOIDCALL(v7_encode_crc(&enc));
39 | }
40 |
41 | void test_v7_decode_crc(void)
42 | {
43 | /* Test function for:
44 | * void v7_decode_crc(v7_decode_state_t *dec, bp_crcval_t *v)
45 | */
46 | v7_decode_state_t dec;
47 | bp_crcval_t v;
48 | CborValue cval;
49 |
50 | memset(&dec, 0, sizeof(v7_decode_state_t));
51 | memset(&v, 0, sizeof(bp_crcval_t));
52 | memset(&cval, 0, sizeof(CborValue));
53 | dec.error = false;
54 | dec.cbor = &cval;
55 | cval.remaining = 10;
56 |
57 | UtAssert_VOIDCALL(v7_decode_crc(&dec, &v));
58 |
59 | dec.error = false;
60 | cval.type = CborByteStringType;
61 | UT_SetDefaultReturnValue(UT_KEY(_cbor_value_copy_string), CborUnknownError);
62 | UtAssert_VOIDCALL(v7_decode_crc(&dec, &v));
63 |
64 | dec.error = false;
65 | UT_SetDefaultReturnValue(UT_KEY(_cbor_value_copy_string), CborNoError);
66 | UT_SetDefaultReturnValue(UT_KEY(cbor_value_advance), CborUnknownError);
67 | UtAssert_VOIDCALL(v7_decode_crc(&dec, &v));
68 |
69 | dec.error = false;
70 | UT_SetDefaultReturnValue(UT_KEY(cbor_value_advance), CborNoError);
71 | UtAssert_VOIDCALL(v7_decode_crc(&dec, &v));
72 | }
73 |
74 | void TestV7BpCrc_Rgister(void)
75 | {
76 | UtTest_Add(test_v7_encode_crc, NULL, NULL, "Test v7_encode_crc");
77 | UtTest_Add(test_v7_decode_crc, NULL, NULL, "Test v7_decode_crc");
78 | }
79 |
--------------------------------------------------------------------------------
/v7/ut-coverage/test_v7_bp_hop_count_block.c:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3 | *
4 | * Copyright (c) 2020 United States Government as represented by the
5 | * Administrator of the National Aeronautics and Space Administration.
6 | * All Rights Reserved.
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 | * not use this file except in compliance with the License. You may obtain
10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | ************************************************************************/
18 |
19 | /*
20 | * Includes
21 | */
22 | #include "test_bplib_v7.h"
23 |
24 | void test_v7_encode_bp_hop_count_block_impl(void)
25 | {
26 | /* Test function for:
27 | * void v7_encode_bp_hop_count_block_impl(v7_encode_state_t *enc, const void *arg)
28 | */
29 | v7_encode_state_t enc;
30 | bp_hop_count_block_t arg;
31 |
32 | memset(&enc, 0, sizeof(v7_encode_state_t));
33 | memset(&arg, 0, sizeof(bp_hop_count_block_t));
34 |
35 | enc.error = true;
36 | UtAssert_VOIDCALL(v7_encode_bp_hop_count_block_impl(&enc, &arg));
37 | }
38 |
39 | void test_v7_decode_bp_hop_count_block_impl(void)
40 | {
41 | /* Test function for:
42 | * void v7_decode_bp_hop_count_block_impl(v7_decode_state_t *dec, void *arg)
43 | */
44 | v7_decode_state_t dec;
45 | bp_hop_count_block_t arg;
46 | CborValue cval;
47 |
48 | memset(&dec, 0, sizeof(v7_decode_state_t));
49 | memset(&arg, 0, sizeof(bp_hop_count_block_t));
50 | memset(&cval, 0, sizeof(CborValue));
51 |
52 | dec.error = false;
53 | dec.cbor = &cval;
54 | UtAssert_VOIDCALL(v7_decode_bp_hop_count_block_impl(&dec, &arg));
55 | }
56 |
57 | void test_v7_decode_bp_hop_count_block(void)
58 | {
59 | /* Test function for:
60 | * void v7_decode_bp_hop_count_block(v7_decode_state_t *dec, bp_hop_count_block_t *v)
61 | */
62 | v7_decode_state_t dec;
63 | bp_hop_count_block_t v;
64 |
65 | memset(&dec, 0, sizeof(v7_decode_state_t));
66 | memset(&v, 0, sizeof(bp_hop_count_block_t));
67 |
68 | dec.error = true;
69 | UtAssert_VOIDCALL(v7_decode_bp_hop_count_block(&dec, &v));
70 | }
71 |
72 | void TestV7BpHopCountBlock_Rgister(void)
73 | {
74 | UtTest_Add(test_v7_encode_bp_hop_count_block_impl, NULL, NULL, "Test v7_encode_bp_hop_count_block_impl");
75 | UtTest_Add(test_v7_decode_bp_hop_count_block_impl, NULL, NULL, "Test v7_decode_bp_hop_count_block_impl");
76 | UtTest_Add(test_v7_decode_bp_hop_count_block, NULL, NULL, "Test v7_decode_bp_hop_count_block");
77 | }
78 |
--------------------------------------------------------------------------------
/v7/ut-coverage/test_v7_bp_previous_node_block.c:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3 | *
4 | * Copyright (c) 2020 United States Government as represented by the
5 | * Administrator of the National Aeronautics and Space Administration.
6 | * All Rights Reserved.
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 | * not use this file except in compliance with the License. You may obtain
10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | ************************************************************************/
18 |
19 | /*
20 | * Includes
21 | */
22 | #include "test_bplib_v7.h"
23 |
24 | void test_v7_decode_bp_previous_node_block(void)
25 | {
26 | /* Test function for:
27 | * void v7_decode_bp_previous_node_block(v7_decode_state_t *dec, bp_previous_node_block_t *v)
28 | */
29 | v7_decode_state_t dec;
30 | bp_previous_node_block_t v;
31 |
32 | memset(&dec, 0, sizeof(v7_decode_state_t));
33 | memset(&v, 0, sizeof(bp_previous_node_block_t));
34 |
35 | dec.error = true;
36 | UtAssert_VOIDCALL(v7_decode_bp_previous_node_block(&dec, &v));
37 | }
38 |
39 | void TestV7BpPreviousNodeBlock_Rgister(void)
40 | {
41 | UtTest_Add(test_v7_decode_bp_previous_node_block, NULL, NULL, "Test v7_decode_bp_previous_node_block");
42 | }
43 |
--------------------------------------------------------------------------------
/v7/ut-coverage/test_v7_custody_tracking_block.c:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3 | *
4 | * Copyright (c) 2020 United States Government as represented by the
5 | * Administrator of the National Aeronautics and Space Administration.
6 | * All Rights Reserved.
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 | * not use this file except in compliance with the License. You may obtain
10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | ************************************************************************/
18 |
19 | /*
20 | * Includes
21 | */
22 | #include "test_bplib_v7.h"
23 |
24 | void test_v7_decode_bp_custody_tracking_block(void)
25 | {
26 | /* Test function for:
27 | * void v7_decode_bp_custody_tracking_block(v7_decode_state_t *dec, bp_custody_tracking_block_t *v)
28 | */
29 | v7_decode_state_t dec;
30 | bp_custody_tracking_block_t v;
31 | CborValue cval;
32 |
33 | memset(&dec, 0, sizeof(v7_decode_state_t));
34 | memset(&v, 0, sizeof(bp_custody_tracking_block_t));
35 | memset(&cval, 0, sizeof(CborValue));
36 |
37 | dec.cbor = &cval;
38 | UtAssert_VOIDCALL(v7_decode_bp_custody_tracking_block(&dec, &v));
39 | }
40 |
41 | void TestV7CustodyTrackingRecord_Rgister(void)
42 | {
43 | UtTest_Add(test_v7_decode_bp_custody_tracking_block, NULL, NULL, "Test v7_decode_bp_custody_tracking_block");
44 | }
45 |
--------------------------------------------------------------------------------
/v7/ut-coverage/test_v7_decode_api.c:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3 | *
4 | * Copyright (c) 2020 United States Government as represented by the
5 | * Administrator of the National Aeronautics and Space Administration.
6 | * All Rights Reserved.
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 | * not use this file except in compliance with the License. You may obtain
10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | ************************************************************************/
18 |
19 | /*
20 | * Includes
21 | */
22 | #include "test_bplib_v7.h"
23 |
24 | void test_v7_block_decode_pri(void)
25 | {
26 | /* Test function for:
27 | * int v7_block_decode_pri(bplib_mpool_bblock_primary_t *cpb, const void *data_ptr, size_t data_size)
28 | */
29 | bplib_mpool_bblock_primary_t cpb;
30 | uint8_t data;
31 | size_t data_size = 100 * sizeof(uint8_t);
32 |
33 | memset(&cpb, 0, sizeof(bplib_mpool_bblock_primary_t));
34 | memset(&data, 0, sizeof(uint8_t));
35 |
36 | UT_SetDefaultReturnValue(UT_KEY(cbor_parser_init), CborUnknownError);
37 | UtAssert_INT32_NEQ(v7_block_decode_pri(&cpb, &data, data_size), 0);
38 |
39 | UT_SetDefaultReturnValue(UT_KEY(cbor_parser_init), CborNoError);
40 | UtAssert_INT32_NEQ(v7_block_decode_pri(&cpb, &data, data_size), 0);
41 | }
42 |
43 | void test_v7_block_decode_canonical(void)
44 | {
45 | /* Test function for:
46 | * int v7_block_decode_canonical(bplib_mpool_bblock_canonical_t *ccb, const void *data_ptr, size_t data_size,
47 | * bp_blocktype_t payload_block_hint)
48 | */
49 | bplib_mpool_bblock_canonical_t ccb;
50 | uint8_t data[100] = {0};
51 | size_t data_size = 100 * sizeof(uint8_t);
52 | bp_blocktype_t payload_block_hint = bp_blocktype_ciphertextPayloadBlock;
53 |
54 | memset(&ccb, 0, sizeof(bplib_mpool_bblock_canonical_t));
55 |
56 | UT_SetDefaultReturnValue(UT_KEY(cbor_parser_init), CborNoError);
57 | UtAssert_INT32_NEQ(v7_block_decode_canonical(&ccb, data, data_size, payload_block_hint), 0);
58 |
59 | UT_SetDefaultReturnValue(UT_KEY(cbor_parser_init), CborUnknownError);
60 | UtAssert_INT32_NEQ(v7_block_decode_canonical(&ccb, data, data_size, payload_block_hint), 0);
61 | }
62 |
63 | void test_v7_save_and_verify_block(void)
64 | {
65 | /* Test function for:
66 | * size_t v7_save_and_verify_block(bplib_mpool_block_t *head, const uint8_t *block_base, size_t block_size,
67 | * bp_crctype_t crc_type, bp_crcval_t crc_check)
68 | */
69 | bplib_mpool_block_t head;
70 | uint8_t block_base;
71 | size_t block_size;
72 | bp_crctype_t crc_type;
73 | bp_crcval_t crc_check;
74 |
75 | memset(&head, 0, sizeof(bplib_mpool_block_t));
76 | memset(&block_base, 0, sizeof(uint8_t));
77 | block_size = 100;
78 | crc_type = 0;
79 | crc_check = 0;
80 |
81 | UT_SetDefaultReturnValue(UT_KEY(bplib_mpool_stream_write), 100);
82 | UT_SetHandlerFunction(UT_KEY(bplib_mpool_stream_write), UT_V7_uint64_Handler, NULL);
83 | UT_SetHandlerFunction(UT_KEY(bplib_crc_get_width), UT_V7_int8_Handler, NULL);
84 | UtAssert_INT32_NEQ(v7_save_and_verify_block(&head, &block_base, block_size, crc_type, crc_check), 0);
85 | }
86 |
87 | void TestV7DecodecApi_Rgister(void)
88 | {
89 | UtTest_Add(test_v7_block_decode_pri, NULL, NULL, "Test v7 block_decode_pri");
90 | UtTest_Add(test_v7_block_decode_canonical, NULL, NULL, "Test v7_block_decode_canonical");
91 | UtTest_Add(test_v7_save_and_verify_block, NULL, NULL, "Test v7_save_and_verify_block");
92 | }
93 |
--------------------------------------------------------------------------------
/v7/ut-stubs/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ##################################################################
2 | #
3 | # Bundle Protocol Library (BPLib) CMake build recipe
4 | #
5 | # This is for the "v7" stub functions
6 | #
7 | ##################################################################
8 |
9 | add_library(bplib_v7_stubs STATIC
10 | v7_stubs.c
11 | v7_codec_stubs.c
12 | v7_encode_stubs.c
13 | v7_decode_stubs.c
14 | )
15 |
16 | target_include_directories(bplib_v7_stubs PUBLIC
17 | $
18 | )
19 |
20 | target_link_libraries(bplib_v7_stubs PUBLIC
21 | ut_assert
22 | )
23 |
--------------------------------------------------------------------------------
/v7/ut-stubs/v7_codec_stubs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /**
22 | * @file
23 | *
24 | * Auto-Generated stub implementations for functions defined in v7_codec header
25 | */
26 |
27 | #include "v7_codec.h"
28 | #include "utgenstub.h"
29 |
30 | /*
31 | * ----------------------------------------------------
32 | * Generated stub function for v7_compute_full_bundle_size()
33 | * ----------------------------------------------------
34 | */
35 | size_t v7_compute_full_bundle_size(bplib_mpool_bblock_primary_t *cpb)
36 | {
37 | UT_GenStub_SetupReturnBuffer(v7_compute_full_bundle_size, size_t);
38 |
39 | UT_GenStub_AddParam(v7_compute_full_bundle_size, bplib_mpool_bblock_primary_t *, cpb);
40 |
41 | UT_GenStub_Execute(v7_compute_full_bundle_size, Basic, NULL);
42 |
43 | return UT_GenStub_GetReturnValue(v7_compute_full_bundle_size, size_t);
44 | }
45 |
46 | /*
47 | * ----------------------------------------------------
48 | * Generated stub function for v7_copy_full_bundle_in()
49 | * ----------------------------------------------------
50 | */
51 | size_t v7_copy_full_bundle_in(bplib_mpool_bblock_primary_t *cpb, const void *buffer, size_t buf_sz)
52 | {
53 | UT_GenStub_SetupReturnBuffer(v7_copy_full_bundle_in, size_t);
54 |
55 | UT_GenStub_AddParam(v7_copy_full_bundle_in, bplib_mpool_bblock_primary_t *, cpb);
56 | UT_GenStub_AddParam(v7_copy_full_bundle_in, const void *, buffer);
57 | UT_GenStub_AddParam(v7_copy_full_bundle_in, size_t, buf_sz);
58 |
59 | UT_GenStub_Execute(v7_copy_full_bundle_in, Basic, NULL);
60 |
61 | return UT_GenStub_GetReturnValue(v7_copy_full_bundle_in, size_t);
62 | }
63 |
64 | /*
65 | * ----------------------------------------------------
66 | * Generated stub function for v7_copy_full_bundle_out()
67 | * ----------------------------------------------------
68 | */
69 | size_t v7_copy_full_bundle_out(bplib_mpool_bblock_primary_t *cpb, void *buffer, size_t buf_sz)
70 | {
71 | UT_GenStub_SetupReturnBuffer(v7_copy_full_bundle_out, size_t);
72 |
73 | UT_GenStub_AddParam(v7_copy_full_bundle_out, bplib_mpool_bblock_primary_t *, cpb);
74 | UT_GenStub_AddParam(v7_copy_full_bundle_out, void *, buffer);
75 | UT_GenStub_AddParam(v7_copy_full_bundle_out, size_t, buf_sz);
76 |
77 | UT_GenStub_Execute(v7_copy_full_bundle_out, Basic, NULL);
78 |
79 | return UT_GenStub_GetReturnValue(v7_copy_full_bundle_out, size_t);
80 | }
81 |
--------------------------------------------------------------------------------
/v7/ut-stubs/v7_decode_stubs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /**
22 | * @file
23 | *
24 | * Auto-Generated stub implementations for functions defined in v7_decode header
25 | */
26 |
27 | #include "v7_decode.h"
28 | #include "utgenstub.h"
29 |
30 | /*
31 | * ----------------------------------------------------
32 | * Generated stub function for v7_block_decode_canonical()
33 | * ----------------------------------------------------
34 | */
35 | int v7_block_decode_canonical(bplib_mpool_bblock_canonical_t *ccb, const void *data_ptr, size_t data_size,
36 | bp_blocktype_t payload_block_hint)
37 | {
38 | UT_GenStub_SetupReturnBuffer(v7_block_decode_canonical, int);
39 |
40 | UT_GenStub_AddParam(v7_block_decode_canonical, bplib_mpool_bblock_canonical_t *, ccb);
41 | UT_GenStub_AddParam(v7_block_decode_canonical, const void *, data_ptr);
42 | UT_GenStub_AddParam(v7_block_decode_canonical, size_t, data_size);
43 | UT_GenStub_AddParam(v7_block_decode_canonical, bp_blocktype_t, payload_block_hint);
44 |
45 | UT_GenStub_Execute(v7_block_decode_canonical, Basic, NULL);
46 |
47 | return UT_GenStub_GetReturnValue(v7_block_decode_canonical, int);
48 | }
49 |
50 | /*
51 | * ----------------------------------------------------
52 | * Generated stub function for v7_block_decode_pri()
53 | * ----------------------------------------------------
54 | */
55 | int v7_block_decode_pri(bplib_mpool_bblock_primary_t *cpb, const void *data_ptr, size_t data_size)
56 | {
57 | UT_GenStub_SetupReturnBuffer(v7_block_decode_pri, int);
58 |
59 | UT_GenStub_AddParam(v7_block_decode_pri, bplib_mpool_bblock_primary_t *, cpb);
60 | UT_GenStub_AddParam(v7_block_decode_pri, const void *, data_ptr);
61 | UT_GenStub_AddParam(v7_block_decode_pri, size_t, data_size);
62 |
63 | UT_GenStub_Execute(v7_block_decode_pri, Basic, NULL);
64 |
65 | return UT_GenStub_GetReturnValue(v7_block_decode_pri, int);
66 | }
67 |
--------------------------------------------------------------------------------
/v7/ut-stubs/v7_encode_stubs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /**
22 | * @file
23 | *
24 | * Auto-Generated stub implementations for functions defined in v7_encode header
25 | */
26 |
27 | #include "v7_encode.h"
28 | #include "utgenstub.h"
29 |
30 | /*
31 | * ----------------------------------------------------
32 | * Generated stub function for v7_block_encode_canonical()
33 | * ----------------------------------------------------
34 | */
35 | int v7_block_encode_canonical(bplib_mpool_bblock_canonical_t *ccb)
36 | {
37 | UT_GenStub_SetupReturnBuffer(v7_block_encode_canonical, int);
38 |
39 | UT_GenStub_AddParam(v7_block_encode_canonical, bplib_mpool_bblock_canonical_t *, ccb);
40 |
41 | UT_GenStub_Execute(v7_block_encode_canonical, Basic, NULL);
42 |
43 | return UT_GenStub_GetReturnValue(v7_block_encode_canonical, int);
44 | }
45 |
46 | /*
47 | * ----------------------------------------------------
48 | * Generated stub function for v7_block_encode_pay()
49 | * ----------------------------------------------------
50 | */
51 | int v7_block_encode_pay(bplib_mpool_bblock_canonical_t *ccb, const void *data_ptr, size_t data_size)
52 | {
53 | UT_GenStub_SetupReturnBuffer(v7_block_encode_pay, int);
54 |
55 | UT_GenStub_AddParam(v7_block_encode_pay, bplib_mpool_bblock_canonical_t *, ccb);
56 | UT_GenStub_AddParam(v7_block_encode_pay, const void *, data_ptr);
57 | UT_GenStub_AddParam(v7_block_encode_pay, size_t, data_size);
58 |
59 | UT_GenStub_Execute(v7_block_encode_pay, Basic, NULL);
60 |
61 | return UT_GenStub_GetReturnValue(v7_block_encode_pay, int);
62 | }
63 |
64 | /*
65 | * ----------------------------------------------------
66 | * Generated stub function for v7_block_encode_pri()
67 | * ----------------------------------------------------
68 | */
69 | int v7_block_encode_pri(bplib_mpool_bblock_primary_t *cpb)
70 | {
71 | UT_GenStub_SetupReturnBuffer(v7_block_encode_pri, int);
72 |
73 | UT_GenStub_AddParam(v7_block_encode_pri, bplib_mpool_bblock_primary_t *, cpb);
74 |
75 | UT_GenStub_Execute(v7_block_encode_pri, Basic, NULL);
76 |
77 | return UT_GenStub_GetReturnValue(v7_block_encode_pri, int);
78 | }
79 |
--------------------------------------------------------------------------------
/v7/ut-stubs/v7_stubs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
3 | * System Application (BP) v6.5”
4 | *
5 | * Copyright © 2020 United States Government as represented by the Administrator of
6 | * the National Aeronautics and Space Administration. All Rights Reserved.
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | *
19 | */
20 |
21 | /**
22 | * @file
23 | *
24 | * Auto-Generated stub implementations for functions defined in v7 header
25 | */
26 |
27 | #include "v7.h"
28 | #include "utgenstub.h"
29 |
30 | /*
31 | * ----------------------------------------------------
32 | * Generated stub function for v7_compare_ipn2eid()
33 | * ----------------------------------------------------
34 | */
35 | int v7_compare_ipn2eid(const bp_ipn_addr_t *ipn, const bp_endpointid_buffer_t *eid)
36 | {
37 | UT_GenStub_SetupReturnBuffer(v7_compare_ipn2eid, int);
38 |
39 | UT_GenStub_AddParam(v7_compare_ipn2eid, const bp_ipn_addr_t *, ipn);
40 | UT_GenStub_AddParam(v7_compare_ipn2eid, const bp_endpointid_buffer_t *, eid);
41 |
42 | UT_GenStub_Execute(v7_compare_ipn2eid, Basic, NULL);
43 |
44 | return UT_GenStub_GetReturnValue(v7_compare_ipn2eid, int);
45 | }
46 |
47 | /*
48 | * ----------------------------------------------------
49 | * Generated stub function for v7_compare_ipn2ipn()
50 | * ----------------------------------------------------
51 | */
52 | int v7_compare_ipn2ipn(const bp_ipn_addr_t *ipn1, const bp_ipn_addr_t *ipn2)
53 | {
54 | UT_GenStub_SetupReturnBuffer(v7_compare_ipn2ipn, int);
55 |
56 | UT_GenStub_AddParam(v7_compare_ipn2ipn, const bp_ipn_addr_t *, ipn1);
57 | UT_GenStub_AddParam(v7_compare_ipn2ipn, const bp_ipn_addr_t *, ipn2);
58 |
59 | UT_GenStub_Execute(v7_compare_ipn2ipn, Basic, NULL);
60 |
61 | return UT_GenStub_GetReturnValue(v7_compare_ipn2ipn, int);
62 | }
63 |
64 | /*
65 | * ----------------------------------------------------
66 | * Generated stub function for v7_get_current_time()
67 | * ----------------------------------------------------
68 | */
69 | bp_dtntime_t v7_get_current_time(void)
70 | {
71 | UT_GenStub_SetupReturnBuffer(v7_get_current_time, bp_dtntime_t);
72 |
73 | UT_GenStub_Execute(v7_get_current_time, Basic, NULL);
74 |
75 | return UT_GenStub_GetReturnValue(v7_get_current_time, bp_dtntime_t);
76 | }
77 |
78 | /*
79 | * ----------------------------------------------------
80 | * Generated stub function for v7_get_eid()
81 | * ----------------------------------------------------
82 | */
83 | void v7_get_eid(bp_ipn_addr_t *bp_addr, const bp_endpointid_buffer_t *eid)
84 | {
85 | UT_GenStub_AddParam(v7_get_eid, bp_ipn_addr_t *, bp_addr);
86 | UT_GenStub_AddParam(v7_get_eid, const bp_endpointid_buffer_t *, eid);
87 |
88 | UT_GenStub_Execute(v7_get_eid, Basic, NULL);
89 | }
90 |
91 | /*
92 | * ----------------------------------------------------
93 | * Generated stub function for v7_set_eid()
94 | * ----------------------------------------------------
95 | */
96 | void v7_set_eid(bp_endpointid_buffer_t *eid, const bp_ipn_addr_t *bp_addr)
97 | {
98 | UT_GenStub_AddParam(v7_set_eid, bp_endpointid_buffer_t *, eid);
99 | UT_GenStub_AddParam(v7_set_eid, const bp_ipn_addr_t *, bp_addr);
100 |
101 | UT_GenStub_Execute(v7_set_eid, Basic, NULL);
102 | }
103 |
--------------------------------------------------------------------------------
/version.txt:
--------------------------------------------------------------------------------
1 | 0.2.2
2 |
--------------------------------------------------------------------------------