Skip to content

Commit

Permalink
Merge branch 'tinydtls-defaults' into stdio-coap
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysn committed Feb 28, 2023
2 parents 4fa0928 + d4f1079 commit 8596269
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/tinydtls/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ config DTLS_CONTEXT_MAX

config DTLS_PEER_MAX
int "Max number of peers"
default 2 if KCONFIG_USEMODULE_GCOAP_DTLS
default 1
help
The maximum number of DTLS peers.
Expand Down
6 changes: 6 additions & 0 deletions pkg/tinydtls/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ endif
PEER_MAX := $(or $(CONFIG_DTLS_PEER_MAX),$(patsubst -DCONFIG_DTLS_PEER_MAX=%,%,$(filter -DCONFIG_DTLS_PEER_MAX=%,$(CFLAGS))))
ifneq (,$(PEER_MAX))
CFLAGS += -DDTLS_PEER_MAX=$(PEER_MAX)
else ifneq (,$(filter gcoap_dtls,$(USEMODULE)))
# The default value in sys/include/net/dtls.h for CONFIG_DTLS_PEER_MAX is 2
# when gcoap_dtls is active, otherwise 1. As the default in tinydtls is 1,
# we need to set it explicitly if the dtls.h default value deviates from
# the tinydtls default.
CFLAGS += -DDTLS_PEER_MAX=2
endif

HANDSHAKE_MAX := $(or $(CONFIG_DTLS_HANDSHAKE_MAX),$(patsubst -DCONFIG_DTLS_HANDSHAKE_MAX=%,%,$(filter -DCONFIG_DTLS_HANDSHAKE_MAX=%,$(CFLAGS))))
Expand Down
6 changes: 6 additions & 0 deletions sys/include/net/dtls.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#ifndef NET_DTLS_H
#define NET_DTLS_H

#include "modules.h"

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -44,8 +46,12 @@ extern "C" {
* @brief The maximum number DTLS peers (i.e. sessions)
*/
#ifndef CONFIG_DTLS_PEER_MAX
#if IS_USED(MODULE_GCOAP_DTLS)
#define CONFIG_DTLS_PEER_MAX (2)
#else
#define CONFIG_DTLS_PEER_MAX (1)
#endif
#endif

#ifdef __cplusplus
}
Expand Down

0 comments on commit 8596269

Please sign in to comment.