There are many use cases where status reports generated locally should
be delivered locally.
Note: As the bundles now need to be passed to `bundle_dispatch`, it would
have been needed to remove the `const` qualifier of that method, as it
mutates the BP state (for checking for duplicates and adding bundle fragments
to the reassembly list). To prevent this from being necessary, an alternative
function is introduced that does not perform such a check and does not
support fragments.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
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 function to decode JSON configuration via Jansson to the
router agent. The JSON functionality and, thus, the dependency on
Jansson, can be disabled during the build process by setting the
`DISABLE_JSON` compile-time flag (see `config.mk.example` for details).
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
Previously it was not possible to disable SQLite because of a linker
error. Also, `sqlite3.h` was always required to be present. This adds
an example to `config.mk.example` and fixes both issues.
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 EIDs and CLA addresses sent by the client may be empty, in which
case they will be assigned a NULL value. We must not use them in this
case. This also adds a second check in the bundle create functions so it
is ensured they never operate on NULL values.
Fixes: #240
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
As per RFC 5050, Section 4.5.1, this field must represent the *remaining*
length of the primary block, not the total length.
Fixes: #236
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
On specific CBOR decoding errors we called `free()` on the created EID
buffer but did not reset the pointer to `NULL`, which is expected by the
calling context. This means that a parser reset will double-free the
pointer.
Fixes: #233
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
If a TCP connection breaks under Linux, the result of `poll` will
indicate that there is data to read, despite a call to `recv` will read
zero bytes and, thus, indicate connection closure. As we are not calling
`recv` in case of a subscribing client, this condition led to the client
connection being considered alive even though it was not.
The check is extended to invoke `recv` on the socket, though, just to
check and report an issue if there is actual data to be read (which
would be an AAP 2.0 protocol violation for subscribing clients). All
subscribing client connections for which `poll` reports either an error
or data to be read at the time of the liveliness check will be closed
by the agent afterwards. This ensures that new clients can register.
It should be noted that it is anyways recommended to set a keepalive
interval when using TCP as a transpport for AAP 2.0.
Closes: #229
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
Previously the conversion to `enum bundle_block_type` could result in an
unsigned integer overflow, triggering the assertion in rare cases.
This change 1. adapts the assertion such that the check is performed
using the correct data type and 2. introduces a range check for the
bundle block type (only type codes 0-255 are defined).
Closes: #227
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
As AAP does not provide TLS support, a user exposing it on a TCP socket
should know what they are doing and set up appropriate firewall rules.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This allows for using AAP 2.0 over TCP, which the Python tools support
already. Note that the user must make sure that the socket is not
exposed externally.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This blocks the use of the persistent storage with our BDM: If we
restart µD3TN and the BDM after a bundle has been stored, then
reconfigure the contacts, and afterwards recall the stored bundles via
`aap2-storage-agent`, the BDM will try to store the bundles again after
they have been (re)scheduled and the storage CLA will report a
"transmission failure". See #210 why we should rather indicate success
here.
This checks the return value of `sqlite3_step` and, if it is
`SQLITE_CONSTRAINT`, returns success ("done") in the `cla_begin_packet`
handler. This way, the BDM received the proper notification that
everything is fine and continues sending the bundle after the contact
has started.
Closes: #210
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This was confusing users. We are adding a detailed explanation in the
man page and informing in the help text that the parameter refers to the
administrative endpoint of uD3TN.
Fixes: #213
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
Previously we did not update the pointer to the previous element when
*not* removing the current element. This may result in memory being
leaked if the following element is removed and the removal code assumes
that it is the first element in the list, setting the list head to the
element that follows.
The update of `prev->next` is removed as it should be set properly
anyway.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
We must break out of the `switch` statement there to keep the parser
status set to `PARSER_STATUS_DONE`. Somehow we even managed to
explicitly acknowledge the accidental fallthrough in uPCN v0.6.0.
We need tests for this. See: #219
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This improves const correctness, at least for pointers (making the
pointed-to data const where possible).
Some suppressions are added for false positive warnings, such as in
`simple_queue.c` where an arithmethic operation is used on the pointer
to calculate a non-const pointer that is returned (thus, the passed
pointer should also not point to const).
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
To prevent additional occupancy of a `contact_info_list` entry, new
contacts are first added to the list of added contacts and only later
shifted to the list of all current_contacts.
Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
In addition to the previous commit, the local variables `added_contacts`
and `removed_contacts` are now also represented by a linked list to
eliminate limitations of a static array.
Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
To eliminate the limitation of a statically allocated array to store
current contacts its replaced by a linked list.
Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
Three messages that are printed quite often but are barely relevant,
either because there is another INFO-level message about the same thing
and they only confirm processing or because the behavior can be expected
anyway, are downgraded to DEBUG level, so they are not shown by default
and disabled in release builds.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
The MTCP CLA drops a link parameter data structure from its hash table
in case it intends to create a new link and there is an existing one in
the process of being torn down (while the associated task is cleaning up
resources). In this case it might happen that the entry is removed by
`mtcp_start_scheduled_contact`, a new entry is created by
`launch_connection_management_task`, and this new entry is removed again
by the termination code in `mtcp_link_management_task`, "leaking" the
link management task and making it uncontrolled.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This fixes another potential deadlock: The BP calls the "start contact"
function of a CLA, which in turn discovers that the link is already
active and attempts to put a notification of link establishment into the
BP queue, which may be full and is not consumed as this is running in
the BP thread.
The solution here adds an extended return value for the start and end
contact functions in the CLA interface, enabling them to indicate to the
BP whether a link change has been initiated (and will be performed
asynchronously), is not necessary (the state is already the intended
one), or was performed synchronously.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This moves the information about a disconnected CLA link from the
`cla_end_scheduled_contact` implementation (in MTCP) to the generic
`cla_link_cleanup` routine that is typically executed in a dedicated
link management thread.
This prevents the call to `cla_end_scheduled_contact` from putting
something in the BP queue which may be blocked by the BP being busy
calling `cla_end_scheduled_contact`.
Fixes: #205
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
Sometimes we use CLA addresses such as "smtcp:" or "tcpclv3:", without
an actual next-hop address on the CL. In this case, we do not drop all
FIB entries referencing the "generic" CLA link if a FIB request for
deleting an entry is received.
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>
If an agent finds out it has a broken connection (the client
disconnected) on a liveliness check (e.g., if another client wants to
register the same agent ID), the agent manager will de-register it, as
it needs to register the new agent immediately and there is a race
condition otherwise. In this case, a warning was shown that should
however only be a debug information.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This makes aap-config / aap_config.py (AAPv1) work again in the default
configuration (debug build, default BDM, no secret set). This way,
pre-existing documentation (YouTube videos, ...) stays usable.
The security properties will not be impacted by this change as AAPv2
clients will be able to do administrative actions anyways if no secret
is set.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This adds a check for detecting EOF and differentiate such an "error"
from actual Protobuf decoding errors so people do not get confusing
log messages.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
Allowing both "cla:" and "cla" may lead to issues for single-connection
CLAs (those that do not use CLA-specific addresses): the FIB may contain
entries for both and only one may be marked as "up" if both forms are
used interchangeably.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This prefixes all compile-time options of the compat. router with
`ROUTER_` and adds them to config.mk.example so they can be easily
discovered and adapted.
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>