Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/tinydtls: allow to set buffer size from application again #19892

Merged
merged 3 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions pkg/tinydtls/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions pkg/tinydtls/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
4 changes: 4 additions & 0 deletions sys/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions sys/net/application_layer/gcoap/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 4 additions & 0 deletions sys/net/application_layer/nanocoap/Makefile.include
Original file line number Diff line number Diff line change
@@ -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)
benpicco marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handshake buffer size does not depend on the block size

endif