Rules that have been applied:
- ERROR: Anything that is or may be problematic for the program to
continue running.
- WARN: Anything abnormal but definitely not critical for program
continuation, especially issues encountered when interacting with
clients (e.g. AAP).
- INFO: All state changes not corresponding to the "normal" processing of
individual data or messages/bundles, as well as further informative and
helpful messages. Includea errors that occur during normal data
processing.
- DEBUG: Messages to trace what happens with individual bundles and
other fine-grained information about internal processes.
At the moment, `LOG_ERRNO` always emits messages with the "ERROR" level.
We might want to change this in the future to better differentiate WARN
and ERROR in this regard also.
Closes: #140
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This reduced unnecessary clutter by default if we do not want to debug
uD3TN. Should also slightly increase performance by issuing less
`printf` statements.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This resolves the race condition documented in #139.
The log macros now each call only a single function which locks
a binary semaphore during execution.
Fixes: #139
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
If there is already an agent registered for the other direction of
communication, registration will fail as long as the provided secrets do
not match.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This simplifies the function signatures and enables easy extension
without adapting them in the future.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This prevents the need for passing unset fields as NULL and removes the
need to change the function signature everytime the structs are
extended.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
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>
This is a "meta-agent" based on the current AAPv1 implementation
(`application_agent.c`), which runs the new AAP2 protocol that is
implemented via Protobuf (using NanoPB). Please refer to the
corresponding design documents for further information on the protocol
itself.
Beside the on-wire encoding and future extension capabilities, the primary
difference from AAPv1 to AAP2 is that a connection is now a
unidirectional RPC-like channel. This ensures that acknowledgments
cannot be easily get out of order and makes client implementations
simpler. However, it also means that now a shared secret needs to be
passed by clients to enable registering for the same agent ID.
The following limitations of this first implementation are present:
- Only sending and receiving ADUs is supported.
- The shared secret is not checked - any app can register for the same
agent ID as long as no other app has yet registered for the requested
direction (subscribe or non-subscribe).
- Only one client per direction is supported at the moment. (It is at
least planned to support multiplke subscribers for an agent ID.)
- The server does not expect acknowledgments from clients when they
receive ADUs.
- The keepalive mechanism is not implemented.
In general, this reflects the feature set of AAPv1, but with massive
extension opportunities.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This adds a second type of agent registration for agents that do not
receive any bundles or events. It is the first step toward splitting all
agent registrations in two parts, depending on the direction of data
flow. In the future, a shared secret will need to be provided to ensure
that an agent is authorized for a given registered agent ID.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
All supported EID schemes currently have the "agent ID" (i.e., the `dtn`
demux part or the `ipn` service number) right at the end of the EID.
Thus, we can provide a function to return a pointer to it for quickly
and efficiently working with the agent ID.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
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>
We want to be able to use POSIX extensions such as `strdup` and should
not define this in every individual source file. It is similar to the
definition of which C standard to use and should thus be defined in the
makefiles.
We use the X/Open feature test macro to include all needed functionality
also under other platforms such as BSD.
See also: https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
For two settings previously defined in `hal_config.h` it makes sense to
make them changeable via `config.mk`. The AAP setting is moved to the
appropriate header and the Linux-specific APU define gets a guard so it
can be changed at compile time.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
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>
This adds trailing parts to the "local EID" specified on the command line
when required, so the user interface is more tolerant to abbreviated
representations such as 'dtn://node.dtn' and 'ipn:1'.
Closes: #129
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This is a safeguard against potential buffer/int overflows. Realistically,
we should never see such long EIDs.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
It is better to do that explicitly and the macros were reusing the macro
arguments, which may lead to side effects. We were using this in only
one place which is substituted by an explicit loop to free the list.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This removes the `DEBUG` log statements when compiling with `type=release`
for better performance.
Signed-off-by: Oleksandr Nazymko <oleksandr.nazymko@d3tn.com>
This adds log level to `ud3tn_cmdline_options` struct so that command line parser passes the value to `init.c` and has no side effects. Also adjusts log message format
for printing out current log level.
Signed-off-by: Oleksandr Nazymko <oleksandr.nazymko@d3tn.com>
This adds generic log function `LOGF_GENERIC` which accepts logging level as argument. Also adds different log messages for different logging levels.
Signed-off-by: Oleksandr Nazymko <oleksandr.nazymko@d3tn.com>
This adds a target `data-decoder` which builds a binary to decode a
specified binary file using uD3TN's parsing logic (based on the CLA RX
subsystem) and print details about it. In this first version only the
decoding of BPv7 bundles is implemented.
This binary can be used, e.g., for fuzz testing.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
Previously the maximum waiting time was just over 24 days. In a DTN
setup we may want to wait longer, e.g., for contacts to occur. This
allows for waiting about 292 years. If the provided delay exceeds this
threshold, an infinite delay is assumed.
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>
Unnamed semaphores are unsupported there, which is why we were seeing
segfaults.
See also: https://stackoverflow.com/a/27847103
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
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>
So far the contact interval check was done in the
config parser. As this is a semantical and not
syntactical check it is moved to the RoutingTable.
Modified @ 2022-12-21 by Felix Walter to adapt to new state of codebase,
adding the check to `node_prepare_and_verify` in `node.c` instead.
Closes: #47
Signed-off-by: Marius Feldmann <marius.feldmann@d3tn.com>
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This removes all external functions currently unused in uD3TN.
We may re-introduce esp. JSON at a later point in time, but should
include updated libraries anyway.
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>
This introduces a function to work with milliseconds-based timestamps
also in case of the expiration time.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This removes the need to send them via the queue which might result in a
deadlock as described in #115. The bundle processor context is passed as
an opaque pointer that can be used for calling BP functions from agent
callbacks (which run inside the BP thread).
Fixes: #115
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This may cause a deadlock which we observed sometimes in the routing
integration test in CI as one slot in the BP queue is always needed to
finish processing the Bundle in the BP (that causes `agent_forward` in
this case).
This makes the config agent directly invoke the BP function.
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>