Sometimes the parser does not read any data and goes into the error
state. In this case we get an infinite loop as `buffer_read` resets the
parsers but does not hand back control to the caller.
Signed-off-by: Felix Walter <felix.walter@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>
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>
This is basically an extended `aap_test.py` as part of the integration
tests, which verifies the received AAP messages and also checks the
returned bundle ID if it contains a well-formed timestamp and sequence
number.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
If the implementation of `hal_queue` changes at some point, we want the
conversion from `uint64_t` to `int64_t` still to be safe here.
If the condition is always true, compiler optimizations will remove it
automatically.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
It is important that the "next contact time" always exceeds the current
timestamp. Otherwise, an infinite loop and DoS can occur.
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>
The nanoseconds field in struct timespec must not exceed 1000 million,
i.e., one second. As we add to an absolute time we might exceed this in
some cases. Thus, we need to check for it and reflect the additional
second in the seconds field of struct timespec.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This reverts commit 340e69165dd89bab9af9d607dda7ca3d8cb6b828.
Breaks build on some Linux with clang.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
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>
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>
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>
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>
Some constants we use are not available when building on Mac, see #126.
- ENONET: Should not occur on these systems
- EHOSTDOWN: Should not occur on these systems
- NI_MAXHOST: Just a sensible default present on Linux, so we set our
sensible default.
- NI_MAXSERV: Same as the above.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
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>
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>
This fixes a small bug in `bundle.c` in `bundle_dup` function which caused an endless loop.
Signed-off-by: Oleksandr Nazymko <oleksandr.nazymko@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 integrates code coverage report into gitlab CI. Also adds an option for generating code coverage
report after running unit tests to the Makefile.
Signed-off-by: Oleksandr Nazymko <oleksandr.nazymko@d3tn.com>
A simple call of `make` will now also build the libraries.
Please note:
We have a quite specific way to re-execute `make` inside the Makefile with
a specific `PLATFORM` set. If we specify multiple targets outside of
this, `make` will execute itself twice concurrently if a `-j` option is
set, leading to race conditions. Thus, we add a new `posix-all` target
that is used to invoke the "inner" `make` process with the proper
`posix` and `posix-lib` targets.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
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>
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 is a remnant from our "EID manager" with which we were trying to
reduce copies of strings in memory. This module has long been removed as
it lead to only small gains while complicating everything. However, it
seems that during the removal process we introduced an unnecessary
strdup() here, which is removed by this change.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
If there is an error the parser will try to reset the "in-progress
bundle". If an EID field is set to *some* pointer (except NULL), it will
be free()'d, leading to a double free if the `parse_eid` operation fails.
Signed-off-by: Felix Walter <felix.walter@d3tn.com>