From 5b6bac000aeef59496862473e526c8593914e6d4 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 5 Feb 2025 11:10:28 +0100 Subject: [PATCH 1/3] sys/net/nanocoap: drop typedef hack There is an `typdef void sock_udp_ep_t` hack in `nanocoap.h` that tries allow using parts of nanocoap without a RIOT network stack. There is a similar hack to allow it to be used without RIOT at all. This has been used in the early days during development on Linux directly. This however has not been tested and left bit rotting. Both hacks are remove and nanocoap now just depends on sock/udp.h. In a future cleanup, the CoAP packet parsing and building code of nanocoap can be separated from the part that does the transmission and reception of UDP packets. That way, using nanocoap's packet parsing and building will again be available without using a network stack. Until then, let's drop the hacks and just depend on a network stack. --- sys/include/net/nanocoap.h | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/sys/include/net/nanocoap.h b/sys/include/net/nanocoap.h index 4ae8107736..50d1c51075 100644 --- a/sys/include/net/nanocoap.h +++ b/sys/include/net/nanocoap.h @@ -85,24 +85,14 @@ #include #include -#ifdef RIOT_VERSION #include "bitarithm.h" #include "bitfield.h" #include "byteorder.h" #include "iolist.h" #include "macros/utils.h" -#include "net/coap.h" #include "modules.h" -#else -#include "coap.h" -#include -#endif - -#if defined(MODULE_SOCK_UDP) || defined(DOXYGEN) +#include "net/coap.h" #include "net/sock/udp.h" -#else -typedef void sock_udp_ep_t; -#endif #if defined(MODULE_NANOCOAP_RESOURCES) #include "xfa.h" From e22e3573745647ff115f0c98df7161963b3192ec Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 5 Feb 2025 15:01:47 +0100 Subject: [PATCH 2/3] tests/unittests: add hack for nanocoap nanocoap depends on sock_udp, which in turn needs `sock_types.h` to be available. When no network stack is in use, that sadly is not the case. To work around the issue, we just manually add the include paths if `gnrc_sock` is not used. This fixes an issue with compilation of only the nanocoap unit tests without also including the GNRC tests. --- tests/unittests/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/unittests/Makefile b/tests/unittests/Makefile index cc9bdd0217..86f91d7639 100644 --- a/tests/unittests/Makefile +++ b/tests/unittests/Makefile @@ -61,3 +61,9 @@ ifeq (, $(UNIT_TESTS)) else CFLAGS += -DTEST_SUITES='$(subst $() $(),$(comma),$(UNIT_TESTS:tests-%=%))' endif + +# Hack: If GNRC is not used, still provide access to sock_types.h to allow +# building nanocoap +ifeq (,$(filter gnrc_sock,$(USEMODULE))) + CFLAGS +=-I$(RIOTBASE)/sys/net/gnrc/sock/include +endif From c700ead7e9077fddbc0de8e8ced08e708deade53 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 5 Feb 2025 11:37:53 +0100 Subject: [PATCH 3/3] sys/suit: include `nanocoap.h` only when used --- sys/include/suit/transport/worker.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/include/suit/transport/worker.h b/sys/include/suit/transport/worker.h index f1013bbd2a..b19b3d35d0 100644 --- a/sys/include/suit/transport/worker.h +++ b/sys/include/suit/transport/worker.h @@ -25,7 +25,9 @@ #ifndef SUIT_TRANSPORT_WORKER_H #define SUIT_TRANSPORT_WORKER_H -#include "net/nanocoap.h" +#if MODULE_NANOCOAP +# include "net/nanocoap.h" +#endif #ifdef __cplusplus extern "C" {