Commit graph

59 commits

Author SHA1 Message Date
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
Oleksandr Nazymko
06b937452c Add code coverage report
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>
2023-05-12 11:30:27 +02:00
Felix Walter
afb91e562c tools/analysis: Exclude clang-analyzer-valist checks in clang-tidy
There is a false positive in clang-tidy that keeps happening in various
places. I checked all usages of valist and they are properly allocated,
used, and freed anytime. This disables the broken checks.

Note the removed single quotes around the extra arguments to clang-tidy:
bash somehow double-quoted the arguments when adding these and
clang-tidy did not process the filter consequently (checked via set -x).

See: https://github.com/llvm/llvm-project/issues/40656
See: https://github.com/llvm/llvm-project/issues/55009
See: https://reviews.llvm.org/D124239

Fixes: #117

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 17:08:39 +02:00
Felix Walter
2fc9c6c03e aap_receive, tests: Print a line feed after every received bundle
This makes the testing logs prettier and may help in decoding the
responses received by aap_receive.py.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 14:37:11 +02:00
Felix Walter
71fb7e2b24 Make Clang check script more flexible and fix clang-tidy job
This allows the user to specify the checker binary and fixes the
"clang-tidy" CI job by using a newer version and directly invoking the
script.

Fixes: #43

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 11:22:51 +02:00
Felix Walter
3d619b126a Add sane behavior in release build where debug triggers assertion
This will gracefully handle cases where a debug build would abort the
program.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 11:22:51 +02:00
Felix Walter
113968a4d6 aap_test.py: Pass aap_client variable explicitly
This is much cleaner than implicit operation via the global variable
inside the `with` statement.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-02-23 17:19:22 +01:00
Felix Walter
9c1a437dd7 pyd3tn: Do not specify the event loop in the async TCPCLv3 client
The argument has been deprecated in newer Python versions.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-01-30 18:00:17 +01:00
Felix Walter
729338ba73
Merge branch 'hotfix/aap-send-bibe'
See !73
2022-11-23 12:22:39 +01:00
Felix Walter
f0ba0b086e tools: aap_send: Reduce code duplication
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-11-14 10:42:51 +01:00
Felix Walter
62dffc0af6 tools: aap_send: Fix generation of BIBE bundles
Previously we were sending the whole outer bundle binary data, however,
the AppAgent expects only the BPDU binary data.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-11-14 10:41:24 +01:00
Felix Walter
0251abfa14 Replace usage of deprecated Logger.warn method
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-11-11 11:28:47 +01:00
Felix Walter
86bc28c205 aap_ping: Make log message about unknown bundle a warning
We register an own endpoint for the ping, so can expect only ping
bundles to come back. If we receive anything else, it should be a warning.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-11-11 10:15:03 +01:00
Felix Walter
476422f9ff tools/aap: Allow aap_send and aap_receive to work with bytes
Sometimes we may send around data that are not UTF-8 encoded. These
previously led to a crash of aap_receive. Also, we could not easily
inject such data via aap_send, even when reading from stdin.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-11-09 12:33:01 +01:00
Felix Walter
ec196d8f76 tools/aap: Add tool to send and receive via the same AAP registration
We sometimes want to send a "request" bundle and receive a "response".
For this purpose, a combination of aap_send.py and aap_receive.py is not
always suitable, because the reception process can only be started with
a delay after the sending process.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-11-09 10:19:03 +01:00
Felix Walter
26abaaef9e tools/aap: Use proper logging facilities in tools
This adds a common function to initialize a logger from the Python
`logging` module and uses it in all tools (except aap_test.py, which is
deliberately kept minimal). Each tool chooses in its initialization
routine whether WARN or INFO is the default log level, simply by either
adding 1 to the verbosity parameter or not.

Messages that were previously printed to the terminal using print() are
changed into log statements.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-11-09 10:12:17 +01:00
Felix Walter
bf7b6c3fce
Merge branch 'feature/aap-contact-plan-reader'
See !59
2022-05-24 14:24:56 +02:00
Oleksandr Nazymko
d3c5de957b Add node number format check
Signed-off-by: Oleksandr Nazymko <oleksandr.nazymko@d3tn.com>
2022-05-18 17:12:33 +02:00
Oleksandr Nazymko
46f07b6745 Change to ipn EID scheme form and edit readme
This changes the supported EID schemes format of uD3TN nodes
from `dtn` to `ipn' form according to the ION format. It also adds
small fixes and edits `readme_contact_plan_reader.md` file.

Signed-off-by: Oleksandr Nazymko <oleksandr.nazymko@d3tn.com>
2022-05-15 12:14:05 +02:00
Oleksandr Nazymko
a2f4b9484e Simplify time parsing
This removes `parse_contact_time_span` and adds `create_contact` functions.
The last one converts time input in DTN timestamps for the ConfigMessage.

Signed-off-by: Oleksandr Nazymko <oleksandr.nazymko@d3tn.com>
2022-05-13 11:35:08 +02:00
Oleksandr Nazymko
6eab5f9706 tools: Implement aap_contact_plan_reader and add readme.md for it
This implements the `aap_contact_plan_reader.py` Python tool that reads
contact plans in ION format and which configures the uD3TN nodes by
scheduling contacts between them. It also adds a small documentation on
how it can be used.

Signed-off-by: Oleksandr Nazymko <oleksandr.nazymko@d3tn.com>
2022-05-12 10:30:41 +02:00
Felix Walter
3b18be70d5 tools: aap_test: Support socket options
Previously we only supported uD3TN's default settings (UNIX socket with
default name). This adds the same socket options as used by the other
AAP tools to aap_test.py.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-05-02 10:19:31 +02:00
Felix Walter
d41bab7f77 tools: Use getaddrinfo() for establishing TCP connections
This allows us to support IPv6 properly. A slight re-structuring was
necessary as we have to attempt multiple connections with different
sockets one after another. Thus, the socket instance is created in
connect() instead of __init__ and we use abc.ABC to prevent
instantiating the AAPClient without overriding the connect() method.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-05-02 10:19:31 +02:00
Felix Walter
76b3cabe9d
Merge branch 'feature/79-aap-ping'
See !54
2022-05-02 09:04:33 +02:00
Felix Walter
e5e7bb2810 tools: aap_ping: Fix displayed "expected" count when running with -c 0
When invoking aap_ping with the defaults (`--count 0`) the calculation
added in the previous commit is faulty as the minimum will always be
zero.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-04-26 10:59:08 +02:00
Oleksandr Nazymko
57a55f4623 Fix two typos and simplify the exception handling
Correct two typographical errors. Remove try ... except construct
to not drop all the details about the errors that may occur.

Signed-off-by: Oleksandr Nazymko <oleksandr.nazymko@d3tn.com>
2022-04-20 18:35:09 +02:00
Felix Walter
ec20046304 tools: Add a "count" argument to aap_ping
Like the well-known "ping" utility this gives aap_ping the capability to
stop operation after a specified number of bundles and report success or
failure (i.e., whether all sent bundles have been received) with its
exit status.

Note that the utility terminates latest after (count * (interval+1))
seconds - we cannot know until when a response is expected and, thus,
assume that the interval is chosen appropriately by the user.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-04-20 18:15:38 +02:00
Felix Walter
3739298f96 tools: Fix race condition in aap_ping
aap_ping did only handle SIGINT (KeyboardInterrupt) in case it was raised
during a receive operation. This moves the handler outside of the while
loop and moves the receiving code into a dedicated function.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-04-20 17:54:55 +02:00
Felix Walter
fe042358ac tools: Gracefully terminate aap_ping.py on errors
This prints an appropriate error message in case the connection to uD3TN
breaks and, additionally, gracefully terminates the sending thread which
would otherwise access an invalid file descriptor.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-04-20 17:22:31 +02:00
Oleksandr Nazymko
0de5650206 Implemented aap_echo function
It implements a simple AAP application that connects to a DTN-node and sends
an "echo" of the received bundles back to the sender. This tool works well with
a companion aap_ping function "ping" receiving "ping bundles" and sending
them back(like in the ICMP echos).

Resolves: #80
See also: #79

Signed-off-by: Oleksandr Nazymko <oleksandr.nazymko@d3tn.com>
2022-04-20 16:47:55 +02:00
Felix Walter
c18609b236 tools: Add a "ping" utility
This provides aap_ping.py, a simple tool to send bundles containing just
some information about when they were sent plus a sequence number.
The contained information is printed as soon as the bundles are received
back, similar to the "ping" utility for IP networks. This can be used to
check connectivity and proper operation of an AAP-capable bundle agent
(like uD3TN) and, in combination with a "bundle echo" tool, connectivity
to some arbitrary destination node.

Closes: #79

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-04-14 12:00:10 +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
Georg Alexander Murzik
e114bfcf84 Add license-check script and CI job
The script checks that the SPDX expression in LICENSE is present in
most of our source code files.

Signed-off-by: Georg Alexander Murzik <georg.murzik@d3tn.com>
2022-02-20 16:24:38 +01:00
Georg Alexander Murzik
298431c68f Insert SPDX license expression comments into our .c, .h, .py, and .sh code
ud3tn is available under multiple licenses and we want to reflect this in
our source code. But which license information should appear first and how
can we manage this efficiently in the future? The Linux Kernel uses SPDX
expressions instead of boilerplate sections. This seems to be a great
approach, so we do the same here.

Signed-off-by: Georg Alexander Murzik <georg.murzik@d3tn.com>
2022-02-20 16:24:38 +01:00
Felix Walter
56a97d0d24 tools: Use a more robust approach to determine the config endpoint ID
Previously we always used simple string concatenation. This change first
obtains the EID prefix representing the bundle node and, then, adds the
config endpoint to it.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-02-01 12:51:18 +01:00
Felix Walter
7c10d22b32 test: BIBE: Add trailing slashes to dtn EIDs without demux
As per the BPv7 specification.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-01-28 10:55:38 +01:00
Felix Walter
4d92d1ff33 tools: aap_config: Support uD3TN instance with ipn-scheme EID
This determines the config endpoint according to uD3TN default settings
properly even if uD3TN uses the ipn EID scheme.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-01-26 21:05:42 +01:00
Felix Walter
68d73cfd2c test & tools: Fixup used EID format
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-01-26 21:05:42 +01:00
Felix Walter
37e39104aa Fix EID validation for dtn and ipn according to BPv7 draft 31
-> https://datatracker.ietf.org/doc/html/draft-ietf-dtn-bpbis-31#section-4.2.5

The previous validation methods were not sufficient to check validity of
dtn as well as ipn EIDs. This adds further functions to easily detect
the EID scheme and validate dtn plus ipn EIDs. Tests for the most common
cases where validity checks should be successful and where they might
fail are added as well.

Due to this change the default EID of uD3TN gets a slash appended, as
dtn EIDs always have to contain the name delimiter '/'.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-01-26 21:05:41 +01:00
Tobias Nöthlich
10028924d6 Refactor Python components
This commit fixes typos and indentation issues and simplifies parts
of the bundle7.py, aap_message.py and aap_receive.py files.

Signed-off-by: Tobias Nöthlich <tobias.noethlich@d3tn.com>
2022-01-26 21:04:02 +01:00
Tobias Nöthlich
ab955d4b17 Add compatibility to older BIBE versions to PyD3TN
This commit remedies the issue of having to modifiy the bundle7.py before
being able to run the automated ION interoperability test by introducing
the --compatibility switch to bibe_over_mtcp_test.py. This command line
argument forces the generated BIBE bundle to use the administrative
record type code 7 instead of 3, ensuring compatibility to ION'S BIBE
implementation.

Signed-off-by: Tobias Nöthlich <tobias.noethlich@d3tn.com>
2021-12-21 10:04:59 +01:00
Tobias Nöthlich
3d228f6a46 Adapt bibe_over_mtcp_test.py to the documentation
Changed default value of --outer from dtn://ud3tn.dtn to
dtn://lower.dtn, to match the description in the BIBE documentation.

Signed-off-by: Tobias Nöthlich <tobias.noethlich@d3tn.com>
2021-12-10 10:37:03 +01:00
Tobias Nöthlich
60813aa49e Fix python-stylecheck warnings and errors
This commit remedies code smells introduced to pyd3tn and the python
tools while implementing the BIBE CLA.

Signed-off-by: Tobias Nöthlich <tobias.noethlich@d3tn.com>
2021-11-29 13:29:31 +01:00
Tobias Nöthlich
682a646f5a Refactor bibe_over_mtcp_test.py
This commit renames the --outer_destination and --inner_destination
commandline parameters to --outer and --inner respectively. It also
adds short forms (-o and -i).

Signed-off-by: Tobias Nöthlich <tobias.noethlich@d3tn.com>
2021-11-29 11:51:05 +01:00
Tobias Nöthlich
d7d1da136f Fix minor issues in bibe_over_mtcp_test.py
The default port the script connected to was 4222 instead
of the mtcp port (4224). Also the destinations of the inner and outer
bundles were hardcoded and not changeable via commandline parameters.

This commit fixes those issues by changing the default port and adding
the outer_destination and inner_destination commandline arguments.

Signed-off-by: Tobias Nöthlich <tobias.noethlich@d3tn.com>
2021-11-12 14:52:50 +01:00
Tobias Nöthlich
f771d494b6 Adapt aap_receive.py to work with revised ADU BIBE payload
By changing the the way BIBE bundles are handled in the bundle processor
(discarding the administrative record and just forwarding the BPDU)
aap_receive.py had to be modified to work with the new payload format.

Signed-off-by: Tobias Nöthlich <tobias.noethlich@d3tn.com>
2021-11-02 15:26:22 +01:00
Tobias Nöthlich
fe5d08f2b0 Add sending/receiving BIBE AAP messages using Python
This commit modifies aap_send.py, aap_receive.py and aap_client.py to
allow for sending SENDBIBE messages using the Python uD3TN utils.

The clear distinction between regular SENDBUNDLE messages and SENDBIBE
messages allows for a rework of the crude check of the message type
performed in aap_receive.py, which is also implemented by this commit.

Signed-off-by: Tobias Nöthlich <tobias.noethlich@d3tn.com>
2021-11-02 10:02:35 +01:00
Tobias Nöthlich
d95c8a369c Update aap_receive.py to work with new AR parser
The aap_receive.py file has been modified to support the new parser for
administrative records. This will facilitate testing of sending ARs over
AAP.

Signed-off-by: Tobias Nöthlich <tobias.noethlich@d3tn.com>
2021-10-27 11:58:54 +02:00
Tobias Nöthlich
26076872ce Update aap_receive.py to work with BIBE bundles
To allow for receiving and parsing BIBE bundles, the parser implemented
in a previous commit is used. Also in order to differentiate BIBE bundles
from AAP messages, a simple check has been added. This check might need
some refinement if other administrative record types are to be supported
in the future, but it works reliably for BIBE bundles.

Signed-off-by: Tobias Nöthlich <tobias.noethlich@d3tn.com>
2021-10-26 15:54:00 +02:00
Tobias Nöthlich
2fad5c0fe4 Update aap_send.py to allow for sending BIBE bundles
When using the command line parameter --bibe, aap_send.py will now
encapsulate the bundle containing the chosen payload in a BIBE PDU
before sending.

Signed-off-by: Tobias Nöthlich <tobias.noethlich@d3tn.com>
2021-10-26 15:44:42 +02:00