This enables AAP 2.0 clients to receive status reports with a new ADU
flag (as we already deliver BIBE bundles). Moreover, it allows clients
to set a report-to EID and sets all of the status report flags on newly
created bundles in case a report-to EID is provided.
Closes: #241
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This adds the JSON parser logic as an alternative to the custom legacy
format and also adds necessary tests.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This adds a `bundle_is_valid` function checking for further MUST
constraints defined by the spec., which further processing inside uD3TN
may depend on.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
The FIB fulfils two purposes: 1) map node IDs to next-hop CLA addresses
and 2) store the current status of a link associated with a given CLA
address.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This makes µD3TN behave the same as v0.13.0 when executed without an
additional commandline argument. A new commandline argument `-d` /
`--external-dispatch` is added, which enables the use of external BDMs.
The default forwarding implementation is now again provided using the
v0.13 code, extracted from e1621765a4 and
adapted to the new agent-based forwarding implementation.
Central changes to the old code include:
- A new "Routing Agent" that handles incoming configuration commands,
FIB updates, and BDM dispatch requests.
- The use of the BDM authorization flag to authorize contact
configuration commands.
- The Contact Manager now only triggers the creation and removal of
links / FIB entries; bundle dispatch is triggered through the FIB and
BDM callback functions of the Routing Agent.
- The fragmentation logic is adapted to store the original bundle along
with an offset and length value, instead of pre-creating and storing
the fragments.
- The bundle re-scheduling logic integrated into the Routing Agent is
simplified and does not support changing the fragmentation parameters.
A new function is added to the Router that searches for a new route
for such fragments that were already scheduled at some point,
considering them as un-fragmentable bundle with overridden fragment
offset and length.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This adds the code from e1621765a4 back
into the tree unchanged, but moved into two new directories, in
preparation of the following commit, which adds a routing agent on this
basis, to make it possible to review the diff properly.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
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>
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>
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>
If an existing agent has set an empty secret, we now disallow the
registration of another agent under the same sink to make secure
operation the default.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
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>
This enables us to check if an agent connection went down synchronously
when trying to register a new agent, removing the need to wait until
uD3TN detects it on its own (if it even can).
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
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>
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>
- 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>
This first version only supports a single CLA link per node ID. Apart
from this, multiple mappings from node ID to CLA address (N:1) can be added.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This implements `htab_update` for replacing existing values.
htab_update will replace the value and return the old value if it was
found. If not, the value will be inserted under the specified key.
The return value is equivalent to `htab_add`.
Additionally, simplehtab now gracefully handles `malloc()` failures
everywhere: On future microcontroller platforms it is well possible that
`malloc()` returns NULL.
Interface documentation is added to `simplehtab.h` for all functions and
data structures intended to be used publicly.
The unit tests are extended to cover the new functionalities and the
*_known functions that are exposed publicly (though they are only
intended for very performance-critical cases).
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
Adds a parameter to the `hal_task_create()` function to allow
non-detached threads and a second parameter to pass the thread
identifier.
Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
This removes the parameters for task name, priority, and stack size,
which were mostly relevant for FreeRTOS on STM32.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
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>
- remove comments on "callback-style" serialization (not needed)
- define magic number in Python AAP 2.0 client via descriptive var
- make `secret` in Python AAP 2.0 client a private variable (used
nowhere else and should not be a class property)
- add missing Python docstrings
- add some comments explaining behavior
- language enhancements and fixes in docs and comments
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>
validate_ipn_eid() has the option to pass pointers to variables that
should store the node and service numbers after successful execution of
the function. If it fails, we do not want to change those fields.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
Having a slash in the dtn demux is allowed and should be tested to
prevent regressions in the handling of slashes in the EID validation and
processing functions.
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>
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>
The tests treated the linked bundle list as array (whereas it was
intended to check the payload data array instead) and used sizeof()
wrongly for determining the count of elements.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
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>