From 252ec917824aaeefd76f82c4e45364b5e8d01dfa Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Mon, 21 Aug 2023 09:33:52 +0200 Subject: [PATCH 1/3] pkg/tinydtls: allow to set buffer size from application again --- pkg/tinydtls/Makefile | 15 --------------- pkg/tinydtls/Makefile.include | 3 +++ 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/pkg/tinydtls/Makefile b/pkg/tinydtls/Makefile index 093ed79ab8f6..8f314cb772c1 100644 --- a/pkg/tinydtls/Makefile +++ b/pkg/tinydtls/Makefile @@ -19,21 +19,6 @@ ifeq (llvm,$(TOOLCHAIN)) CFLAGS += -Wno-format-nonliteral endif -ifneq (,$(filter gcoap,$(USEMODULE))) - # Configuring the buffer large enough that a full Gcoap packet can be - # encrypted or decrypted. - - # This is the default in gcoap.h, which we don't have access to, so it is copied over. - CONFIG_GCOAP_PDU_BUF_SIZE := $(or $(CONFIG_GCOAP_PDU_BUF_SIZE),128) - - # If there were another way to set up DTLS_MAX_BUF, we'd need to set the - # maximum of these here. - # - # 29 bytes are the overhead measured with Wireshark on packets exchanged in - # default configuration; adding some to be safe against variable size fields. - CFLAGS += "-DDTLS_MAX_BUF=($(CONFIG_GCOAP_PDU_BUF_SIZE) + 36)" -endif - # TinyDTLS emits several messages during connection establishment at the info # level; this is way more verbose than common in RIOT. TINYDTLS_LOG_LEVEL ?= LOG_WARNING diff --git a/pkg/tinydtls/Makefile.include b/pkg/tinydtls/Makefile.include index 79245a2b986a..9d4add6ccfc8 100644 --- a/pkg/tinydtls/Makefile.include +++ b/pkg/tinydtls/Makefile.include @@ -75,3 +75,6 @@ HANDSHAKE_MAX := $(or $(CONFIG_DTLS_HANDSHAKE_MAX),$(patsubst -DCONFIG_DTLS_HAND ifneq (,$(HANDSHAKE_MAX)) CFLAGS += -DDTLS_HANDSHAKE_MAX=$(HANDSHAKE_MAX) endif + +DTLS_MAX_BUF ?= 200 +CFLAGS += "-DDTLS_MAX_BUF=$(DTLS_MAX_BUF)" From 91001468f90c71e1f5e7d3bb271bace089153ff2 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Mon, 21 Aug 2023 13:43:33 +0200 Subject: [PATCH 2/3] sys/net/nanocoap: configure DTLS buffer --- sys/Makefile.include | 4 ++++ sys/net/application_layer/nanocoap/Makefile.include | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 sys/net/application_layer/nanocoap/Makefile.include diff --git a/sys/Makefile.include b/sys/Makefile.include index b1ba246995bd..b2d5ac2c2702 100644 --- a/sys/Makefile.include +++ b/sys/Makefile.include @@ -188,3 +188,7 @@ endif ifneq (,$(filter gcoap,$(USEMODULE))) include $(RIOTBASE)/sys/net/application_layer/gcoap/Makefile.include endif + +ifneq (,$(filter nanocoap,$(USEMODULE))) + include $(RIOTBASE)/sys/net/application_layer/nanocoap/Makefile.include +endif diff --git a/sys/net/application_layer/nanocoap/Makefile.include b/sys/net/application_layer/nanocoap/Makefile.include new file mode 100644 index 000000000000..c8b8b33d8a95 --- /dev/null +++ b/sys/net/application_layer/nanocoap/Makefile.include @@ -0,0 +1,4 @@ +ifneq (,$(filter nanocoap_dtls,$(USEMODULE))) + CONFIG_NANOCOAP_BLOCKSIZE_DEFAULT := $(or $(CONFIG_NANOCOAP_BLOCKSIZE_DEFAULT),2) + DTLS_MAX_BUF ?= ((1 << ($(CONFIG_NANOCOAP_BLOCKSIZE_DEFAULT) + 3)) + 36) +endif From e65f1c41fe6a313a4d00e768dbab0765b3405187 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Mon, 21 Aug 2023 13:43:47 +0200 Subject: [PATCH 3/3] sys/net/gcoap: configure DTLS buffer --- sys/net/application_layer/gcoap/Makefile.include | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/net/application_layer/gcoap/Makefile.include b/sys/net/application_layer/gcoap/Makefile.include index 5be3bbb663dc..4cb403e57cd0 100644 --- a/sys/net/application_layer/gcoap/Makefile.include +++ b/sys/net/application_layer/gcoap/Makefile.include @@ -2,3 +2,6 @@ ifeq (2, $(words $(filter ipv4 ipv6, $(USEMODULE)))) $(shell $(COLOR_ECHO) "$(COLOR_YELLOW)Due to limitations in the gcoap API it is currently not \ possible to use a dual stack setup$(COLOR_RESET)" 1>&2) endif + +CONFIG_GCOAP_PDU_BUF_SIZE := $(or $(CONFIG_GCOAP_PDU_BUF_SIZE),128) +DTLS_MAX_BUF ?= ($(CONFIG_GCOAP_PDU_BUF_SIZE) + 36)