From 64f9aa58c1bb4224a4b01d8e1b846e785f58ac4c Mon Sep 17 00:00:00 2001 From: chrysn Date: Mon, 27 Feb 2023 21:52:23 +0100 Subject: [PATCH 1/2] pkg/tinydtls: Set buffer size as required for gcoap --- pkg/tinydtls/Makefile.include | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/tinydtls/Makefile.include b/pkg/tinydtls/Makefile.include index fda2825bd6ef..3283906710e1 100644 --- a/pkg/tinydtls/Makefile.include +++ b/pkg/tinydtls/Makefile.include @@ -69,3 +69,18 @@ HANDSHAKE_MAX := $(or $(CONFIG_DTLS_HANDSHAKE_MAX),$(patsubst -DCONFIG_DTLS_HAND ifneq (,$(HANDSHAKE_MAX)) CFLAGS += -DDTLS_HANDSHAKE_MAX=$(HANDSHAKE_MAX) 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 From 8e3a266b691f3729472c3551125e09976567b6f6 Mon Sep 17 00:00:00 2001 From: chrysn Date: Mon, 27 Feb 2023 21:52:41 +0100 Subject: [PATCH 2/2] tinydtls: Reduce default verbosity --- pkg/tinydtls/Makefile.include | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/tinydtls/Makefile.include b/pkg/tinydtls/Makefile.include index 3283906710e1..1bcdeec1f9be 100644 --- a/pkg/tinydtls/Makefile.include +++ b/pkg/tinydtls/Makefile.include @@ -84,3 +84,7 @@ ifneq (,$(filter gcoap,$(USEMODULE))) # 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. +CFLAGS += -DLOG_LEVEL=LOG_WARNING