Commit graph

34 commits

Author SHA1 Message Date
Felix Walter
868bac67b6 router_agent, mk: Add stub of JSON configuration feature
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>
2025-06-05 17:03:39 +02:00
Felix Walter
fb2d0b021c cla, mk: Fix disabling SQLite functionality
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>
2025-06-05 17:03:39 +02:00
Felix Walter
87be9749af Re-integrate v0.13.0 routing code as "integrated default BDM"
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>
2024-07-15 00:46:14 +02:00
Maximilian Nitsch
4ebe8ffa4c mk/posix: Set TOOLCHAIN ?= clang explicitly on Darwin (MacOS) systems
Previously we were relying on the availability of a symlink/redirection
for `gcc` that points to `clang`, which is present by default on macOS
if the XCode developer tools are installed. When using Nix on macOS,
this is not the case and the build fails. As Clang is the default for
all macOS systems, we should just proactively set the `TOOLCHAIN`
variable to that value.

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-07-01 11:04:04 +02:00
Maximilian Nitsch
1321c59c22 sqlite_agent: Add an agent to interact with the SQLiteCLA
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>
2024-06-03 13:41:58 +02:00
Maximilian Nitsch
218246e789 cla_sqlite: Add SQLite-based storage CLA skeleton
In order to prepare the implementation of a SQLite-based storage CLA, a
basic structure of this CLA with empty functions is created and
adjustments are made to the configuration/initialization functions and
the build system.

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-06-03 13:41:58 +02:00
Felix Walter
bef31704c5 aap2: Add an AAP2 implementation matching the current AAP feature set
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>
2023-11-08 15:11:52 +01:00
Felix Walter
81c3caba4b mk: Move generated PB components to generated/
We do not need the `components/` subdirectory and it makes the call to
the Protobuf compiler more complicated.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-11-08 15:11:52 +01:00
Felix Walter
1dd5961bc4 Add AAP 2.0 component stub with Protobuf support via Nanopb
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>
2023-11-08 15:11:52 +01:00
Felix Walter
e53a4b9ca3 CLA, mk: Make SO_REUSEPORT a documented compile-time option
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>
2023-10-26 14:44:49 +02:00
Felix Walter
08b4a1d34f Move definition of _POSIX_C_SOURCE and _DEFAULT_SOURCE to posix.mk
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>
2023-10-25 15:56:57 +02:00
Felix Walter
ab00791f2a mk: Document current build options in config.mk.example
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-09-29 14:36:25 +02:00
Felix Walter
f2fc65c33f
Merge branch 'feature/fuzzer-binary'
See !91
2023-07-14 10:09:47 +02:00
Felix Walter
5309ea171f mk: Disable unsupported LD options on MacOS
This does not pass the `--gc-sections,--sort-common,--as-needed` and
`-Wl,-z,relro,-z,now,-z,noexecstack` linker flags when using the MacOS
linker. The OS detection is moved to `posix.mk`, which is included
earlier.

Fixes: #135
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-06-05 12:43:58 +02:00
Felix Walter
8031d6be24 mk: Only add -march=native by default on x86[_64]
This option is commonly not available on other platforms.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-17 07:27:30 +02:00
Felix Walter
e16ec4c579 Enable building a BPv7 decoder binary
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>
2023-05-16 11:34:14 +02:00
Felix Walter
2889a17f23 mk: Simplify passing linker flags and pass them in correct order
On some systems (incl. our x86_64 Debian based CI), the change of the
linker argument order in 602c4ce0 broke the build, as the flag was then
passed after the library options (i.e. `-lc -lm -lpthread`).

This change removes the modifications to the `LDFLAGS` and `LDFLAGS_PRE`
variables in `build.mk` by making use of the `LDFLAGS_EXECUTABLE` and
`LDFLAGS_LIB` variables directly in dedicated linker commands.

An additional variable `LDFLAGS_PRE_LIB` is introduced for adding
preceding flags specifically for the library build (as `LDFLAGS_PRE` is
not touched anymore in `build.mk`).

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-15 15:26:57 +02:00
Felix Walter
1c6d91a1a0
Merge branch 'hotfix/mac-osx-compatibility'
See !105
2023-05-15 14:20:52 +02:00
Felix Walter
a5313fc9ac Revert "mk: Pass -pie flag only to linker"
This reverts commit 340e69165dd89bab9af9d607dda7ca3d8cb6b828.

Breaks build on some Linux with clang.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-15 11:39:29 +02:00
Felix Walter
35b295e8dd mk: Only add the unittest libs and includes to testud3tn
This is just a cleanup change - we do not want to include that stuff in
our main library and executable.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-15 11:39:29 +02:00
Felix Walter
62d563449f test: Remove the Unity wrappers for memory allocation functions
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>
2023-05-15 11:39:29 +02:00
Felix Walter
c40fa97226 mk: Add a warning that testud3tn does not build on MacOS
The `--wrap` option is not present in the Darwin linker. Thus, we cannot
build the tests on MacOS.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-15 11:01:34 +02:00
Felix Walter
52b1fa41e8 mk: Use -all_load linker flag instead of --whole-archive on MacOS
The latter is not supported there, but we need to include everything
from all static archives provided to the linker, so we use -all_load as
per the Darwin linker docs.

See: https://gcc.gnu.org/onlinedocs/gcc-3.3.6/gcc/Darwin-Options.html
See: https://github.com/bioinformatics-centre/kaiju/issues/30

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-15 11:01:34 +02:00
Felix Walter
e94481e0d2 mk: Pass -pie flag only to linker
clang will otherwise warn on MacOS that the flag is unused during
compilation.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-15 11:01:34 +02:00
Felix Walter
ee101e80dc mk: Make linker groups conditional based on detected OS
The MacOS linker does not support linker groups, but the GNU / Linux
linker requires them in our case.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-15 11:01:34 +02:00
Felix Walter
602c4ce00a mk: Only link dynamic library with --whole-archive
For the executable we should not use this option as it unnecessarily
increases binary size.

There might also be incompatibilities with Mac, see #126

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-15 11:01:34 +02:00
Felix Walter
e58181818e mk: Do not output map file during linking
This was only necessary for STM32 and it seems that there are
compatibility issues with LLVM on Mac.

See: #126

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-15 11:01:34 +02:00
Felix Walter
6f0de0c7f0 mk: Also build a static library
This combines the static libraries into one libud3tn.a that can be used
for static linking. It shall be noted that we are using a "thin" archive
(containing symlinks) for maximum compatibility - e.g., the ARM version
of ar does not support conversion and we cannot always assume libtool to
be present. The main objective is to build a library usable for linking
it into uD3TN-NG.

See: https://stackoverflow.com/a/23621751

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-12 10:44:10 +02:00
Felix Walter
b2c95e89d8 Add flags to enable ASAN and UBSAN in build process
You can now specify `sanitize=yes` to the `make` command, which enables
the address and UB sanitizers. For Clang builds, it enables checks for
unsigned integer ovewrflow and implicit conversions, additionally. Thus,
it is advised to compile as follows:

    make TOOLCHAIN=clang sanitize=yes

There also is the option to pass `sanitize-strict=yes`, which will set
`-fno-sanitize-recover=` such that the program execution aborts in case
the sanitizers detect something.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-12 09:00:27 +02:00
Marius Feldmann
691b7c3172 Remove STM32/FreeRTOS support from uD3TN
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>
2022-03-22 00:05:13 +01:00
Felix Walter
4f873a66c3 mk: Fix build of shared library
Previously, none of the object files were linked into the shared object
libud3tn.so. This adds the appropriate linker flags (--whole-archive) to
add everything to the shared library. -fPIE cannot be used with libs,
thus, is replaced with -fPIC. Finally, the GC options (link-time removal
of unneccessary sections) are only applied for linking the executable.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2021-11-07 22:23:58 +01:00
Felix Walter
4679c9efdf mk: Add missing source file for tinycbor
This resulted in linker errors when including everything in an
executable/library.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2021-11-07 22:23:45 +01:00
Felix Walter
bc271aa444 Rename binary, main component, and config defaults "ud3tn"
This changes the core component name as well as the output binary names
(including the library and test binaries) from "upcn" to "ud3tn".
Additionally, the default configuration for the created socket and the
used EID is adapted.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2020-11-17 15:51:10 +01:00
Felix Walter
0ce4bee910
Initial import of uPCN v0.8.0 source code
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>
2020-11-14 11:56:40 +01:00