Commit graph

25 commits

Author SHA1 Message Date
Felix Walter
c2fef74ea9 bundle: Allow 64-bit bundle payload lengths
The bundle block length, fragment offset, and total ADU length fields
were using 32-bit uint types, effectively reducing the maximum bundle
payload size to 4 GiB. This changes the field types to 64-bit uint, so
we can support larger bundles.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-15 00:46:10 +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
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
2adc3ab7e8 bundle_fragmenter: Always create new fragments with offset + length
Previously the fragmentation logic was very specific to uD3TN's
forwarding approach, modifying the original bundle in the process. With
BDMs supporting fragmentation we must make this more flexible. Thus, we
now pass an offset and length and always create a copy of the required
contents based on the original bundle.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
6d2f204af5 Replace integrated next-hop forwarding with AAP 2.0
This adds functionality to dispatch bundles and control the FIB to AAP
2.0 and the bundle processor, replacing the old "router" completely.
AAP 2.0 is extended slightly to enable fragmentation.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-17 13:33:32 +02:00
Felix Walter
26e91ad69e Remove config.h: Move all definitions to individual headers
This moves all definitions from config.h to individual header files and
makes them configurable (i.e., does not define when already defined).

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-09-29 14:43:21 +02:00
Felix Walter
7330c79b52 style: Spacing, indentation, long lines, continuations
This harmonizes several style issues found by `checkpatch.pl` when using
strict mode.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-07-25 13:15:05 +02:00
Felix Walter
de31d057ca Prevent side effects in macros
- Only access each argument once
- Use parentheses around macro arguments upon use

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-07-25 13:15:05 +02:00
Felix Walter
f07262b909 Rename fallthrough macro to fallthrough_ok to prevent conflict
There is the compiler attribute `fallthrough` already. This
re-definition makes checking for it using __has_attribute impossible.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-15 11:01:34 +02:00
Felix Walter
d9bd711c9a bundle6: Allow for receiving CBHE-encoded bundles
This also adds a test for it, sending bundles from within ION to uD3TN
in the "minimal forwarding test".

Fixes: #7

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-12 08:07:42 +02:00
Felix Walter
3cd89eb6a5 bundle, agents: Switch time unit to milliseconds
...to align with the general decision to make DTN timestamps
millisecond-based.

See: #53

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 16:59:13 +02:00
Felix Walter
2fc9e11b7e bundle: Fix potential uint wrap-around in expiration time calculation
We were taking the current time value in milliseconds and sometimes
subtracting larger values from it. This cleans up the calculations to
always determine the expiration time as uint64_t and compare it against
the current uint64_t timestamp.

It further removes the unnecessary "current timestamp" parameter in
`bundle_get_expiration_time_s` (we now store the reception time with the
bundle, so, do not need this anymore) and avoids a integer wrap-around
case in the function.

Note that the current time cancels out in the age block-based
calculation as we can use the reception timestamp there and offset it by
the calculated relative remaining lifetime.

Found by Clang's UB sanitizer.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 14:31:17 +02:00
Felix Walter
15996ae3f0 bundle6/parser: Avoid wrap-around of uint
We should not adjust the counter before we had a chance to determine the
length (i.e., before `PARSER_STAGE_BLOCK_LENGTH`) - it is simply
unnecessary there.

Found by UB sanitizer.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 14:26:41 +02:00
Felix Walter
3d619b126a Add sane behavior in release build where debug triggers assertion
This will gracefully handle cases where a debug build would abort the
program.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 11:22:51 +02:00
Felix Walter
00ab1577ab Explicitly check the maximum bundle size (and nothing more) in parsers
For BPv6 we had a "bundle quota" check, which is not present for BPv7
anymore and not possible after the removal of the bundle storage manager.
The AAP parser had an equivalent function, which was, however, not used
by the Application Agent.

A more flexible implementation and a new "bundle quota" check are
tracked by issue #105.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-12-07 17:42:21 +01:00
Felix Walter
cd959647f8 Remove bundle ID and storage and replace the ID by the bundle pointer
This removes the unnecessary bundle storage manager that was built for
persistent storage but never used for that purpose. We will implement a
proper persistent storage in the new Rust version. For simplifying the
following adaptations this removes everything storage-related and
replaces the used bundle ID by the pointer.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-12-07 17:42:21 +01:00
Felix Walter
081871945f bundle_processor: Fix memleak and CBOR issue in BIBE AR handling
There were actually two issues here:
- The latter part of `adu.payload` was copied and the field just
  replaced by the copy (`buf`) without freeing the previous value.
- Always a constant length of 2 bytes were skipped, but one of the
  fields skipped is the record type code which is a CBOR unsigned
  integer with valid values up to 255, thus, _either_ one or two bytes
  long.

This adds a pointer to the first byte of record-specific data in the
parsed byte string and leverages its value to skip the correct amount of
bytes using `memmove`. (As we do not need the ADU afterwards, we can
destructively overwrite it and hand the remaining BPDU to the BIBE
agent.)

See: https://www.rfc-editor.org/rfc/rfc9171#name-administrative-records

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-08-26 12:41:01 +02:00
Georg Alexander Murzik
298431c68f Insert SPDX license expression comments into our .c, .h, .py, and .sh code
ud3tn is available under multiple licenses and we want to reflect this in
our source code. But which license information should appear first and how
can we manage this efficiently in the future? The Linux Kernel uses SPDX
expressions instead of boilerplate sections. This seems to be a great
approach, so we do the same here.

Signed-off-by: Georg Alexander Murzik <georg.murzik@d3tn.com>
2022-02-20 16:24:38 +01:00
Felix Walter
26580de896 Remove the hal_time dependencies in bundle6 and bundle7
Based on a contribution by @mnitsch, 351e1dae9.

This removes `hal_*` dependencies in the bundle processing components,
with the goal that these parts can be re-used without depending on the
uD3TN core functions and underlying system state. The required variables
are passed as function arguments from the uD3TN core components.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-01-22 11:12:32 +01:00
Felix Walter
6e54d35fda Pass a proper sequence number upon local bundle creation
This adds the bundle sequence number as an argument to the bundle
creation functions and passes a sequence number which increases when
multiple bundles are generated by the application agent with the same
creation timestamp.

Fixes: #59

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2021-07-22 17:51:26 +02:00
Maximilian Nitsch
2a981e86e2 Change DTN timestamp to milliseconds
To be compatible with the latest version of BPv7, the internal
representation of DTN timestamps, for both uD3TN and the Python library,
is changed to milliseconds.
For compatibility reasons, a conversion to seconds is performed during
the de-/serialization of BPv6.
Furthermore, additional test cases are added and the creation_time_ms of
the test bundle is set to a non-trivial timestamp.

Also, the Python functions for converting POSIX timestamps to DTN
timestamps are removed, as there is now a distinction between BPv6 and
BPv7 DTN timestamps. The conversion is now done in the corresponding BP
implementations themselves.

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2021-01-14 14:42:55 +01:00
Felix Walter
7587d97b96 Fix indentation in function signatures returning ud3tn_result
The re-name to "enum ud3tn_result" broke the indentation in some
function signatures, which is fixed by this commit.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2020-11-18 12:31:38 +01:00
Felix Walter
288b99069c Replace enum upcn_result by enum ud3tn_result
This renames the enum and its two constants `UPCN_OK` and `UPCN_FAIL`
accordingly.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2020-11-17 15:51:10 +01:00
Felix Walter
fb4238a97d Adapt core include path from upcn/ to ud3tn/
This moves all headers from upcn/ to ud3tn/ and adapts the #include
statements accordingly.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2020-11-17 15:51:10 +01:00
Felix Walter
0ce4bee910
Initial import of uPCN v0.8.0 source code
This is the initial commit for uD3TN. uD3TN is a fork of uPCN v0.8.0,
which will be developed and maintained in a public Git repository.

For questions concerning the history of and code provided with uPCN,
please get in touch with us via: contact <at> d3tn <dot> com

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2020-11-14 11:56:40 +01:00