Commit graph

13 commits

Author SHA1 Message Date
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
b4e3e5aae9 bundle7/parser: Add note why status is set to DONE even if CRC is invalid
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-12 09:14:37 +02:00
Felix Walter
112fc969a7 bundle7/parser: Remove unnecessary string duplication
This is a remnant from our "EID manager" with which we were trying to
reduce copies of strings in memory. This module has long been removed as
it lead to only small gains while complicating everything. However, it
seems that during the removal process we introduced an unnecessary
strdup() here, which is removed by this change.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-12 09:14:37 +02:00
Felix Walter
b2ecb9a117 bundle7: Ensure that the currently-constructed block is never overwritten
It may be the case that `block_type` is invoked directly at a chunk
boundary, leading to it returning CborErrorUnexpectedEOF.
This ensures that the already-constructed block entry is reused when, in
this case, `block_type` is invoked again after filling up the chunk
buffer.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 15:07:16 +02:00
Felix Walter
8b0a5ed644 bundle7: Update tinycbor dependency
This also fixes some NULL pointer additions (UB).

Found by Clang's UB sanitizer.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 14:32:47 +02:00
Felix Walter
7d97e0a4f8 bundle7/parser: Truncate to uint16 before implicit conversion
The function call argument is already a uint16.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 14:24:31 +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
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
3d82861fdc bundle7: Do not attempt to re-init parser before bulk read
For arbitrarily-long data such as block payload data, a "BULK_READ" operation
is requested, normally to be handled by the RX task. Though, sometimes we can
handle this on our own (if we have enough data in the current buffer).
Thus, we first check whether, given the bytes in the buffer, we can perform
the bulk read operation on our own. However, before doing this, we
sometimes attempted to re-initialize the TinyCBOR parser (in case
cbor_value_at_end returned true), which resulted in an error if the head
of the current buffer points to some binary data that is not valid
CBOR. With this change we always perform the "BULK_READ" first and
re-initialize the parser only after it is done.

Fixes: #49

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2020-12-11 20:57:02 +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