Commit graph

112 commits

Author SHA1 Message Date
Felix Walter
afdd9fbdfb tools: Implement tool to send a bundle via MTCP
This is handy e.g. for testing custom source EIDs, not requiring an
additional BPA instance to be run for injecting bundles.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-08-29 14:51:50 +02:00
Felix Walter
53188b458a stylecheck: Ignore SPLIT_STRING
The JSON parser unit test heavily uses multiline strings so we can read
the embedded JSON properly. It seems there is no better way to make
checkpatch happy here.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02:00
Felix Walter
229f884a57 python-ud3tn-utils: Introduce JSON configuration format
This introduces a JSON contact configuration format for the
deterministic first-contact forwarding (DFCF) implementation as a modern
alternative to our homebrewn configuration messages. For now, it is only
supported in the external DFCF BDM, but integration into the "router
agent" is planned.

Example JSON configuration string (from our tests):

```
{

    "command": "ADD",
    "node_id": "dtn://ud3tn2.dtn/",
    "cla_addr": "mtcp:127.0.0.1:4223",
    "reachable_eids": [
        "ipn:1.0"
    ],
    "contact_list": [
        {
            "start": 1401519306972,
            "end": 1401519316972,
            "data_rate": 2400,
            "reachable_eids": [
                "dtn://66553/",
                "dtn://89326/"
            ]
        },
        {
            "start": 1401519506972,
            "end": 1401519516972,
            "data_rate": 1200,
            "reachable_eids": [
                "dtn://12349/",
                "dtn://89326/"
            ]
        }
    ]
}
```

Closes: #15

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02:00
Felix Walter
e5c7ecdf13 tools, mk: clang-{check,tidy}: Simplify invocation, add missing dirs
- This simplifies ithe invocation via Makefile and documents the arguments.
- We missed to add the storage CLA + agent and the compat. router
  directories there.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-09-11 10:10:43 +02:00
Felix Walter
784b3fe85f tools: stylecheck: Do not use strict mode and remove ignore flags for it
Strict mode activates some messages with `CHECK` level, which are not very
important. However, we cannot fulfil all of them, so we ignored a couple
of message types. It turns out that this also ignores messages with a
`WARNING` level and the same type (e.g., `LINE_SPACING`), which we want
to address in any case. Thus, we disable the strict checking option and
remove related ignore flags.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-09-11 10:10:43 +02:00
Felix Walter
5ee7dcc5dd CI: Add a test for max. bundle size enforcement
This also extends the MTCP sink script to allow writing to stdout so we
can check the returned payload.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-04 16:03:31 +02:00
Maximilian Nitsch
ada5f57efa nix: Add SPDX-License-Identifier
Adds a SPDX-License-Identifier to all nix files and adjust
`license-check.sh` to consider Nix files and the corresponding
directories.

Filtering directories that should not be checked is now performed in the
find command instead of in the iteration. In addition, the iteration
function is changed, as the for loop splits by spaces, which leads to an
error for file names with spaces — linebreaks are used instead.

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-07-01 11:04:04 +02:00
Maximilian Nitsch
fa6d159d10 python-ud3tn-utils: Add AAP + AAP2 tools
- Moves `tools/aap` + `tools/aap2` to `python-ud3tn-utils/aap*/bin/` to
  add the scripts to the python package
- Adds a `main()` function to each script to reference it
- Define `logger` as global variable
- Adds a symbolic link to keep compatibility with existing tooling
- Moves `tools/aap/aap_test.py` to `test/functional/`
- Adds additional dependencies (pyd3tn, cbor) to python-ud3tn-utils and
  the corresponding nix package
- Add scripts to python-ud3tn-utils `pyproject.toml`

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-07-01 10:10:56 +02:00
Felix Walter
48c3d19a43 tools/aap2: Prevent race condition on RPC socket in aap2_ping.py
We must use the context manager in the thread that actually accesses
the object (and, transitively, the AAP2 RPC socket).

See: #198
Fixes: #198

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-26 13:35:51 +02:00
Felix Walter
e711ad06cd tools/aap2: Add option to pass secret as environment variable
It should not appear in the process list.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-26 13:32:28 +02:00
Felix Walter
e61bfea6c7 tools: BDM: Gracefully handle invalid EIDs
Previously the BDM crashed if a config command contained an invalid EID.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-26 10:31:41 +02:00
Felix Walter
cbb2aec432 tools: BDM: Disallow insecure configuration
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-26 10:31:41 +02:00
Felix Walter
1ad0e83722 tools: Add aap2_config tool for configuring the compat. BDM securely
This is an equivalent of aap_config.py, but setting the proper
administrative credential.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-26 10:31:41 +02:00
Felix Walter
2dcf3b35d9 aap2: Secure the control of the storage and BDMs through AAP 2.0
With the addition of the storage agent and the compat. BDM we have the
issue that two new agents accept configuration through bundles, which
cannot check that those bundles come from trustworthy sources. In the
past we restricted contact configuration messages to local clients and
performed an "EID spoofing detection" so that we could check the source
EID - if it is the same as the local node ID, we allowed the
configuration bundle to be processed. With AAPv2 and potentially more
security-relevant components (such as BDMs) appearing in the future, we
need a new mechanism.

The idea behind the implemented mechanism is to reuse the existing AAP
2.0 shared-secret authentication that is applied for BDMs themselves
also for sending configuration messages: We add the possibility to
register an AAP 2.0 RPC agent (one that sends commands *toward* uD3TN)
with the "dispatch" authorization flag. This client can then request a
special flag to be added when sending bundles. The new flag is only
added internally by uD3TN to its in-memory data structure and is
delivered to all internal agents as well as AAP 2.0 clients receiving
the marked bundles. Those agents and clients (such as the sqlite/storage
agent) can then easily check for the flag to be present and thus
determine whether the bundle comes from an authenticated and authorized
source.

Note: The `adu_flags` field for the BundleADU AAP 2.0 message is now a
`repeated` field to represent the option of multiple flags being present
(Protobuf does not support bit fields for this purpose).

Fixes: #187

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-26 10:23:17 +02:00
Felix Walter
2a8209d83d tools: BDM: Format long function arguments on new line
This makes it more readable and keeps the diffs for future changes
smaller. See !170.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-25 10:25:14 +02:00
Felix Walter
3fc93b6507 aap2: Pass the next-hop node ID and CLA address to the BDM
When transmission had been attempted and generated a "TX
success/failure" result, the BDM will need the information which
transmission is affected by the generated dispatch. Additionally, the
term "DispatchRequest" is imprecise, as uD3TN does not require the BDM
to dispatch the bundle in any case (it can do so, but especially after
TX success/failure, oftentimes, it is intended to just proceed with
normal bundle processing).

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-25 10:25:12 +02:00
Felix Walter
d238804c6a
Merge branch 'hotfix/bundle-serializer-result'
See !167
2024-06-25 10:20:59 +02:00
Felix Walter
2dcc1387eb bundle6/serializer: Replace flow control in macro with condition var
The previous version may lead to hard-to-spot issues later on.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-24 14:30:26 +02:00
Felix Walter
7b959e4cb8 aap2, FIB: Implement direct dispatch
This adds a "flags" field to the FIB link, allowing for configuring a
link for "direct dispatch", i.e., to make it usable without first
contacting a BDM. It is important to make this optional as otherwise
contact-based routing and QoS could not be implemented properly via a
BDM.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 12:39:59 +02:00
Felix Walter
e8a319a277 TX: Allow the bundle serializers to indicate failure if CLA fails
If the write method of the CLA fails, the serailizers will now return
early and this failure is handled properly by the TX task.

In the case of the BPv6 serializer, we add the necessary flow control to
the `write_bytes` macro, to prevent needing a conditional for every
write* or serialize* statement.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 12:38:15 +02:00
Felix Walter
b627eb1f24 python: Join nested with statements with comma
Instead of

with a:
    with b:
        ...

we can use:

with a, b:
    ...

This makes the code more compact.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 11:16:07 +02:00
Felix Walter
4a5c1d749a python: Move get_node_id function to pyd3tn
We use this function in all BDMs - thus, we should move it to a common
library. This also adds a test, ported from the unit test for the
corresponding function in uD3TN's eid.c.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
b07407112a sqlite: Remove destination EID from compund bundle ID
It is not part of the unique bundle identifier as per RFC 9171.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
a7c5d50bae tools: BDM: Use tagged groups in config parser regex
This makes the process more readable and understandable what is being
decoded.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
6c62b8e68d tools: BDM: Implement re-scheduling and proper fragment handling
- Fix the handling of bundles that have been already fragmented: include
  the offsets provided by uD3TN in the scheduling decision. We extend
  the bundle ID representation by some fields not used for hashing and
  comparison to keep the necessary data in memory.
- Implement the re-schedule routine to try to re-schedule fragments and
  drop bundles if they cannot be re-scheduled.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
830dca0650 tools: BDM: Fix unit tests for config parser
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
642e55cf8b tools: BDM: Reflect uD3TN v0.13 behavior, make preventing loops optional
This cleans up the intermediate bundle ID storage automatically, making
recognition of looping bundles optional and enabling the stress test to
work as-is. If one wants to filter looping bundles, a new command line
argument is added for that purpose.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
3e53bac9e1 python/aap2: Implement a "Compatibility BDM" doing uD3TN v0.13 forwarding
This adds a Python BDM which implements the forwarding approach of uD3TN
v0.13 (the latest release). It listens to the config endpoint and is
thus compatible with `aap_config.py`.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
673eb2751a python/aap2: Implement a BDM with static forwarding table
This is a simple forwarding module that only supports ongoing /
persistent contacts and forwards according to a provided JSON mapping
table.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
ec00f0d89e Add AAP2 link configuration tool
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
271ff4aa4f agent_manager: Extend by FIB and BDM mgmt., simplify, make testable
- Implement management of FIB and BDM agents:
  * add administrative secret which is required for registering FIB and
    BDM agents
  * allow registering reverse-direction agents for TX/RX of ADUs when
    passing the admin secret
  * add cmdline option to pass the admin secret via an env variable
  * make administrative secret optional in debug builds
- Register agents by number, as FIB and BDM agents may not have a sink
  ID. Numbers are allocated by the agent_register function.
- Remove global state, add function to de-allocate everything.
- Add comprehensive unit tests.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-17 13:33:31 +02:00
Maximilian Nitsch
85ca529b4d aap2_storage_agent: Add compound-bundle-id argument
To identify a specific bundle, a command line argument is added to
specify the composite bundle ID based on source, destination, creation
timestamp, sequence number, fragment offset and payload length.

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-06-03 13:41:58 +02:00
Maximilian Nitsch
b7ce5ef89b SQLiteCLA+Agent: Extend StorageCall Protobuf definition
- Introduces a CompoundBundleId to filter exactly one bundle
- Filter bundles either by their ID or selected metadata
- Transfer the entire StorageCall object to the CLA via the agent queue

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-06-03 13:41:58 +02:00
Maximilian Nitsch
840ca7cc84 tools/aap2: AAP2 client to interact with a StorageAgent
Enables simple interaction with a StorageAgent, such as "push" and
"delete" of bundles from the storage, using the command line.

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-06-03 13:41:58 +02:00
Maximilian Nitsch
8b381bf494 tools/aap: AAP client to interact with a StorageAgent
Enables simple interaction with a StorageAgent, such as "push" and
"delete" of bundles from the storage, using the command line.

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-06-03 13:41:58 +02:00
Felix Walter
f816360cb5 Update whole-package license to AGPLv3 and add contribution info
For protecting µD3TN from proprietary forks that do not give back to the
open-source project, we decided to re-license the µD3TN project under
the GNU Affero General Public License v3.0 (AGPLv3).

To still enable proprietary projects to use µD3TN, D3TN will start to
offer proprietary licenses. To ensure that all future contributions are
compatible with this dual licensing scheme, all external contributions
will still be accepted under the terms of the Apache 2.0 license.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-03 13:10:58 +02:00
Felix Walter
7a24fae363 tools: Use isinstance instead of equality for type
Found by flake8: We now check for the value being a tuple using the
proper `isinstance()` function.

Tested using:

```
build/posix/ud3tn -e ipn:1.0 -p 4242 &
python tools/aap/aap_contact_plan_reader.py \
  --plan <(echo "a contact +1 +3600 1 2 10000") \
  --nodes <(echo "1 mtcp:localhost:4224 tcp localhost 4242\n2 mtcp:localhost:4225 socket ud3tn.socket")
```

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-12-22 11:30:17 +01:00
Maximilian Nitsch
5c8cfedf33 python: Update pinned dependencies
- pyd3tn: Fix pinned cbor version
- python-ud3tn-utils: Update protobuf to version 2.24.4
- tools: Update flake8 to version 6.1.0

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2023-12-22 11:22:31 +01:00
Oleksandr Nazymko
0ef3836015 Adjust clang-check script
This adds an adjustment to `clang-check.sh` script so that it checks subdirectories too.

Signed-off-by: Oleksandr Nazymko <oleksandr.nazymko@d3tn.com>
2023-12-19 13:51:05 +01:00
Felix Walter
dfbec5d175 tools/analysis: Pin Python package versions
See also: #145

This ensures that the analysis jobs will not break in the future.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-11-09 14:33:48 +01:00
Felix Walter
5e6cfb5f7e tools/aap2: Move keepalive argparse argument to common helpers
We now perform the range check via argparse and provide a function to
add the parser argument like with other common parser arguments.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-11-08 15:11:53 +01:00
Felix Walter
aef2b668c6 style: Fix style of typedef usage in aap2_client.c
This adds the AAP 2.0 typedefs to the checkpatch list, so it will not
complain about style when declaring a variable or function argument as
`<typedef> *const <name>`.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-11-08 15:11:53 +01:00
Felix Walter
036545f0d9 aap2: Implement keepalive for receiving bundles in Python tooling
This adds the option to enable keepalive messages for AAPv2 in the
aap_receive and aap_ping tooling, so that the AAPv2 connections stay
alive until bundles are received.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-11-08 15:11:52 +01:00
Felix Walter
b7461b6a01 tools/aap2: Remove code redundancy in aap2_receive.py
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-11-08 15:11:52 +01:00
Felix Walter
a0b2fe8909 aap2: Receive response from bundle subscribers
We specify AAP 2.0 to be an RPC protocol whereas the direction of calls
can be switched during configuration. Each call needs to be answered.
This change adds the answer for bundle reception by a client.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-11-08 15:11:52 +01:00
Felix Walter
346387eb7e tools/analysis: Adapt checks to new files and directories
- We have files generated from Protobuf in the codebase, which do not
  contain the license header.
- We have a new component directory (`aap2`).
- The license header check is extended to the `proto` and `options`
  files.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-11-08 15:11:52 +01:00
Felix Walter
a81f481e22 python-ud3tn-utils, tools: Add basic AAP2 tooling (send, receive, ping)
This adds adapted versions of `aap_send.py`, `aap_receive.py`, and
`aap_ping.py` for AAP2 and implements the required client classes in
the `ud3tn_utils` module.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-11-08 15:11:52 +01:00
Felix Walter
1dd5961bc4 Add AAP 2.0 component stub with Protobuf support via Nanopb
This adds the Nanopb library as submodule under `external/` and adds
corresponding build configuration to the Makefiles. Additionally, a
Protobuf stub for AAP 2.0 is included along with a `make` target to
build the corresponding C language files (`aap2-proto-headers`).

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-11-08 15:11:52 +01:00
Felix Walter
2a10d81b37 stylecheck: Enable strict mode partially
This enables a set of "strict" diagnostics from `checkpatch.pl` but
disables some that would cause excessive refactoring or do only apply to
the Kernel.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-07-25 13:15:05 +02:00
Felix Walter
92a5e7f680 stylecheck: Update line length and ignored checks
This...
- sets the line length limit to 100 chars in accordance with the new
  Linux kernel line length limit
- ignores things we have no control or which do not apply to us: camel
  case (used via TinyCBOR, simplequeue, and FreeRTOS), and macros and types
  we have not implemented (things only part of the Linux kernel)

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-07-25 13:15:05 +02:00