This adds a custom header that does explicitly not include the Unity
wrappers for malloc, free, etc. by defining the guard used by that header
file. This way we can remove the wrappers provided via the linker
altogether.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
We cannot easily support this on MacOS, but we do not use it except in
tests. Thus, remove it and make the tests only run on Linux and use
`sem_getvalue` directly.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This removes the `hal_time` dependency of the `routing_table`, as it now
assumes that the provided `struct node` is ordered, free of conflicts,
and has valid contact timestamps. This is ensured by invoking
`node_prepare_and_verify` beforehand, in `router_process_command`.
The tests are updated accordingly.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
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>
This changes the "from" and "to" fields in the contact struct to
milliseconds-based timestamps and adapts all dependent code. The contact
data format is kept second-based for backward compatibility.
The commit also introduces a new function to work with millisecond
timestamps in the remaining capacity calculation and modifies the tests
related to the latter such that they do not need to change the timestamp.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
`hal_task_create` returned a reference to the new task allocated on the
heap via `malloc`. We commonly used the pattern to `free` this reference
from the new thread which, however, could result in race conditions and
other synchronization issues. We added a fix using a semaphore in the
application agent, but this would have been needed in other places (CLA,
...) as well. As we do not make use of the task reference anywhere
besides in the CLA for error handling, we can remove the heap-allocated
value altogether and replace it with an `enum ud3tn_result` to simplify
things and circumvent the named synchronization issues.
In the case of the CLA function `cla_link_init`, logic is introduced to
request the RX task to exit immediately in case the TX task cannot be
launched.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This test was prone to off-by-one errors if the time advanced between
calls. It is also unnecessary as we do not use a special clock
implementation anymore and !85 will fully remove the function to mock
the system time.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
We have two test cases that are randomly influenced by the system they
are running on. This makes the checks in these tests more forgiving to
random variations that may occur.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
There was a rare memory leak if the contact was not found in the target
list (e.g., already deleted earlier).
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
Do not return a reference to a non-thread-safe global variable:
ctime() is not thread safe. As we only use the function in logging, we
can directly print the return value, protected by a mutex.
This also adapts the tests and makes the initialization routine always
run. To use the system time again, UINT64_MAX can be passed.
Found by Clang's thread (data race) sanitizer.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
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>
Previously we would simply ignore any contact that was overlapping. This
changes the routing table's behavior such that overlapping contacts with
the same node are merged and overlapping contacts with multiple
different nodes are just allowed and added alongside each other. The
maximum number of contacts defined by `MAX_CONCURRENT_CONTACTS` now is
just a limitation of the Contact Manager which will not process more
than that number of contacts at the same time. (If one of them ends, a
concurrent contact that was not handled can be added.)
This change requires, however, that overlapping contacts are properly
rejected in router commands. This is achieved by a corresponding update
of the add/update/delete functions and an extension of the preliminary
checks.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This refactors the Router Task into synchronous functions called by the
BP, preventing the need of circular notifications between them.
The router queue is replaced by new signals in the BP queue.
This additionally removes the global state in the bundle processor.
Closes: #11
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
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>
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>
The node and service number are 64 bit unsigned integers. This fixes the
validation and EID serialized size calculation and adds appropriate
tests to the serializer unit tests.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
We do not need to parse the timecode to drop SPP frames that do not
belong to us. This makes the SPP parser return on every change of its
internal state (as it is called again by the CLA methods, this is a
totally valid mode of operation) and check the APID early in the CLA
methods.
By that we also support receiving SPPs that use different formats to
other APIDs (e.g., without any timecode in case we are expecting a
timecode).
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
If the service number of a bundle7 EID was set to zero, this resulted in
an EID like "ipn:xxx." instead of "ipn:xxx.0", because the allocated
length was determined in the wrong manner for the special case of zero.
This also adds tests for the "zero" case and the case of UINT64_MAX.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
Former releases of uD3TN have included support for STM32/FreeRTOS.
Having this support from the first moment on was a good thing in
order to optimize for platforms with limited resources. As this
platform is not used in current uD3TN setups and as it results in quite
some maintenance work, it is removed with this commit. The removed parts
cover the implementation itself, tests, tools, documentation, parts of
the build/make scripts as well as licensing information.
Signed-off-by: Marius Feldmann <marius.feldmann@d3tn.com>
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>
Previously, we disallowed these EIDs completely, considering them not
valid. Though, this breaks interoperability with ION and seems like an
unnecessary restriction. Local EIDs (the ones uD3TN is initialized with)
still have to contain a trailing slash in any case, the requirements are
just relaxed for processing other EIDs (in the forwarding tables and in
bundle headers).
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
The BPv7 implementation was still using uin32_t for the node and service
numbers in ipn EIDs in several places.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
AAP does not care about the EID format, thus, we do not want to check it
there. Additionally, uD3TN can be easily made independent of EID schemes
for bundle forwarding (source, destination, forwarding table). We should
not add more logic than necessary and make it more inflexible in the
course.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This adds a function for extracting the node ID from dtn as well as ipn
EIDs. The function replaces previous parsing of dtn EIDs in the router.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
We don't want raw memcmp if we have utility functions.
This further exposes the function to parse and validate ipn EID node and
service numbers to replace error-prone checks for those.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
-> https://datatracker.ietf.org/doc/html/draft-ietf-dtn-bpbis-31#section-4.2.5
The previous validation methods were not sufficient to check validity of
dtn as well as ipn EIDs. This adds further functions to easily detect
the EID scheme and validate dtn plus ipn EIDs. Tests for the most common
cases where validity checks should be successful and where they might
fail are added as well.
Due to this change the default EID of uD3TN gets a slash appended, as
dtn EIDs always have to contain the name delimiter '/'.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
Previously uD3TN implicitly assumed string EID in many places such as
the agent manager. This adds proper handling for ipn-scheme EIDs,
using numerical service numbers as agent IDs in case uD3TN is started
with an ipn-scheme EID. If the ipn scheme is used, uD3TN always has to
be configured with the service number 0. The config and management agent
IDs can be configured in config.h and are 9000 and 9001, respectively,
to keep the lower range of service numbers free. It is intentional that
agents can register with a service number of zero - uD3TN does not
provide specific functionality under this service number.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This commit adds unit tests covering the BIBE parser in bibe_proto.c
as well as the BIBE validator in bundle7/reports.c.
Signed-off-by: Tobias Nöthlich <tobias.noethlich@d3tn.com>
Due to changing the payload data of SENDBIBE messages from complete ARs
to BPDUs, the BIBE encoder unit test always failed.
This commit fixes this issue by changing the expected header length and
the valid header bytes to reflect the removal of the AR data from the
header.
Signed-off-by: Tobias Nöthlich <tobias.noethlich@d3tn.com>
This commit renames the struct containing the BIBE header to bibe_header
to reduce ambiguousness.
Signed-off-by: Tobias Nöthlich <tobias.noethlich@d3tn.com>
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>
This commit adds two tests regarding Bundle-in-Bundle Encapsulation.
The first test starts four µD3TN instances and tests whether sending
and receiving BIBE messages works as expected, whereas the second
test specifically checks the encoding of BIBE messages by the
bibe_proto.c file.
Signed-off-by: Tobias Nöthlich <tobias.noethlich@d3tn.com>