See: #267
This adds a compile-time flag to reject such bundles, if needed.
Making this part of the validation routines all the time breaks our
interoperability with DTN7 (at least in the configuration we are using
in our interop. test).
Note that we cannot currently check the security targets, which is an
unordered CBOR array part of the BIB payload data. Thus, bundles without
CRC and with a BIB targeting *any* block, even if this excludes the
primary block, will be accepted when the option is turned on. See
follow-up issue #273.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
ION uses a 32-bit unsigned integer length field as header for the MTCP
packets. To be compatible with that, we add a compile-time setting
`CLA_MTCP_ION_STCP_COMPATIBILITY`.
Closes: #202
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This extends the conversion and validation functions for ipn EID strings
to implement support for the RFC9758 3-element format.
The only point that changes behavioral-wise by default is that now
`eid_to_string` returns the "ipn:a.n.s" for all EIDs with FQNN > 2^32-1,
except if the new compile-time configuration option
`EID_IPN_FORCE_2_ELEMENT` is enabled.
This also introduces a variant of `eid_to_string` with a second argument
to enforce the use of the 2-element format, which is used in the BPv6
implementation for constructing outgoing bundles (there is no 3-element
format in BPv6).
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>
The defaults for the AAP and AAP 2.0 TCP ports were the same. Thus, if
we specify a TCP host for both, µD3TN will terminate on startup as the
port is already in use by one agent but it tries to bind to it with
both.
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 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>
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 ensures that internal counters do not overflow and we can prevent
DoS by BDM responses containing lots of next hops (e.g. in case of BDM
bugs) to some extent.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
The main reason here is to not initialize a CLA that has a hard limit on
the maximum bundle size (TCPSPP) by default. TCPSPP is rarely used anyway,
so we can disable it and save some memory in the default configuration.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
Adds support for a volatile in-memory database by enabling support for
URI-based database file names. Since the in-memory DB can only be
accessed within the process, the integration tests are changed so that
external SQL queries are only performed when a persistent DB file is
used.
Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
Some CLAs may block sending to the underlying layer, e.g., the storage
CLA may wait for the DB to become ready. This increases the default
queue length to prevent blocking the BP in such cases.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
Read transactions need a short, blocking, lock for the database, during
which no write transaction can be started - this means the interaction
of the agent, TX, and RX tasks may block each other if anything takes
longer than 1 ms. Thus, we increase the timeout for blocking locks to
100 ms to significantly reduce that probability.
See: https://www.sqlite.org/src/doc/204dbc15a682125c/doc/wal-lock.md
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This enables a clean termination of all agent connections on program
exit without memory leaks that might previously occur due to the "pipe
queue" still holding some data (pointer to allocated memory) when
close() is called on the pipe. For that purpose, the "pipe queue" is
replaced by our standard hal_queue implementation, which also has a
higher performance as it does not require a syscall on every read/write
operation.
As hal_queue does not support poll() (it does not provide a fd), we
cannot check whether the socket has been closed by a subscribing AAP2
client while concurrently waiting for the internal queue. As an
alternative, this implements a liveliness check, which checks the sub.
connection opportunistically from the agent manager: When a new
registration is requested, existing registrations are first
"health-checked" and removed if down, so the new connection can take
over if an old one is down and this was not detected previously.
Based on the new infrastructure, a clean termination routine is
implemented that terminates all tasks transitively by terminating the
listener.
An AAP2 connection handler ("comm task") can terminate in two ways:
1. During runtime, when the connection is closed, it must clean up its own
resources.
2. On program termination, all connections must be cleanly closed and
all outstanding mesages handled.
For 1., we keep using detached threads and allow them to release all the
resources. This commit mainly introduces a mechanism for 2.: A list
tracking all comm. tasks is added that can be used to terminate and wait
for all of them on program termination. A "termination flag" indicates
whether tasks should clean up by themselves or the listener task takes
it over. Everything needs to be protected by mutexes for safe
concurrency.
There is specific handling for macOS, which does not signal other
threads clocking on a socket that the socket has been closed when
calling shutdown() but only when calling close() - thus, close() is
executed earlier on macOS. Also, macOS does not unblock poll() when the
socket is close()d, so we do not use it anymore to wait for data on an
RPC connection, but rather set SO_RCVTIMEO for active-client (RPC)
connections to enforce the keepalive timeout.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This makes it much more unlikely that the queue fills up, even under
high load. We however still need a long-term solution for the loop
issues sketched in #189.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This is required to allow bundles being forwarded to storage by
specifying the storage node (a configuration parameter) as next hop.
The CLA initialization is modified slightly to register the CLA before
executing `cla_launch` to ensure that the bundle processor knows about
it when it is executed.
This also moves the Sqlite CLA initialization to the `sqlite_launch`
function because the CLA has to be known ("registered") before we send
a signal to the BP (which is done during link creation).
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>
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>
The backlog configuration option is renamed to indicate up front that it
is intended to be passed to listen().
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
The SQLiteAgent enables SQLiteCLA to read packages from the database and
return them to μD3TN. For this purpose, the SQLiteAgent writes commands
to the queue that SQLiteCLA is waiting for.
The SQLiteAgent itself can be controlled by protobuf messages that
describe which action is to be applied to which set of bundles.
Currently the operations "Push" and "Delete" are implemented and a
filter based on a destination EID pattern.
Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
The SQLiteCLA makes it possible to write bundles, that are to be sent
via this CLA, to an SQLite database in order to persist them over a
longer period of time and also a restart of μD3TN.
The bundles are saved together with selected metadata (source EID,
destination EID, creation timestamp) in the "bundles" table. A
combination of source EID and creation timestamp is used as the primary
key.
To return bundles to μD3TN, they are read from the database and injected
via the cla_read() function, just like other CLAs that receive bundles.
To trigger this, commands are read from a queue that specify which
bundles are to be read from the database.
Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
We only used it for thread naming - the hal_platform malloc analysis
support was removed a long time ago. As we do not really need thread
naming and removed it when cleaning up hal_task, we do not need this
define anymore.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
As we are ensuring that retries happen with a delay in between we can
infinitely retry connections during a contact. This ensures we can
establish a connection even if the peer becomes available significantly
later than the contact starts on our side. The setting can be configured
in `config.mk`.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
uD3TN can continue to run in this case, just without the given CLA. This
introduces a compile-time switch to select whether we want to kill uD3TN
in case a CLA finally fails.
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 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>
Previously we were setting this every time that it was defined. The
switch from defining _POSIX_C_SOURCE in some files to defining
_XOPEN_SOURCE in the build system made the symbol disappear on Linux
with GCC, thus, making our current AAP test (which reuses ports) fail.
As SO_REUSEPORT is probably unintended in most cases and may rather lead
to unexpected behavior or even security issues, we should disable it by
default. #144
This commit re-introduces _DEFAULT_SOURCE as feature-test macro to
provide the Linux- and BSD-specific API SO_REUSEPORT, which is not
available otherwise.
Fixes: #144
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This allows us to enable some options that were intended as CLI
arguments to `make` also via `config.mk` and documents those options in
`config.mk.example`.
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>
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>