From 2fc554b8fcd37e589448010ff4dfab4affff2af4 Mon Sep 17 00:00:00 2001 From: Michael Scott Date: Mon, 4 Dec 2017 21:55:16 -0800 Subject: [PATCH] crypto: config: config-coap: add CONFIG for setting max content length The CoAP samples use an MBEDTLS config "config-coap.h" which could be re-used by the LwM2M sample, except that most servers use a larger maximum content length setting of 1500 bytes. Let's add a CONFIG to set this for users of the CoAP lib and set the CONFIG value for the samples to the 256 size currently used. Signed-off-by: Michael Scott --- ext/lib/crypto/mbedtls/configs/config-coap.h | 6 +++++- samples/net/coaps_client/prj.conf | 1 + samples/net/coaps_server/prj.conf | 1 + subsys/net/lib/coap/Kconfig | 10 ++++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ext/lib/crypto/mbedtls/configs/config-coap.h b/ext/lib/crypto/mbedtls/configs/config-coap.h index e92b3456fb8..1dd09925956 100644 --- a/ext/lib/crypto/mbedtls/configs/config-coap.h +++ b/ext/lib/crypto/mbedtls/configs/config-coap.h @@ -95,7 +95,11 @@ * both ends of the connection! (See comments in "mbedtls/ssl.h".) * The optimal size here depends on the typical size of records. */ -#define MBEDTLS_SSL_MAX_CONTENT_LEN 256 +#ifndef CONFIG_COAP_MBEDTLS_SSL_MAX_CONTENT_LEN +#define MBEDTLS_SSL_MAX_CONTENT_LEN 1500 +#else +#define MBEDTLS_SSL_MAX_CONTENT_LEN CONFIG_COAP_MBEDTLS_SSL_MAX_CONTENT_LEN +#endif #include "mbedtls/check_config.h" diff --git a/samples/net/coaps_client/prj.conf b/samples/net/coaps_client/prj.conf index 4fc6728ae02..e69d9242f73 100644 --- a/samples/net/coaps_client/prj.conf +++ b/samples/net/coaps_client/prj.conf @@ -21,6 +21,7 @@ CONFIG_MBEDTLS_BUILTIN=y CONFIG_MBEDTLS_CFG_FILE="config-coap.h" CONFIG_COAP=y +CONFIG_COAP_MBEDTLS_SSL_MAX_CONTENT_LEN=256 CONFIG_NET_APP_SETTINGS=y CONFIG_NET_APP_MY_IPV6_ADDR="2001:db8::3" diff --git a/samples/net/coaps_server/prj.conf b/samples/net/coaps_server/prj.conf index 5a322a4efeb..626bbbaee24 100644 --- a/samples/net/coaps_server/prj.conf +++ b/samples/net/coaps_server/prj.conf @@ -17,6 +17,7 @@ CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=5 CONFIG_NET_MAX_CONTEXTS=10 CONFIG_COAP=y +CONFIG_COAP_MBEDTLS_SSL_MAX_CONTENT_LEN=256 CONFIG_MBEDTLS=y CONFIG_MBEDTLS_BUILTIN=y diff --git a/subsys/net/lib/coap/Kconfig b/subsys/net/lib/coap/Kconfig index 1bc6de6781b..a6c9ea98463 100644 --- a/subsys/net/lib/coap/Kconfig +++ b/subsys/net/lib/coap/Kconfig @@ -62,6 +62,16 @@ config COAP_EXTENDED_OPTIONS_LEN_VALUE COAP_EXTENDED_OPTIONS_LEN is enabled. Define the value according to user requirement. +config COAP_MBEDTLS_SSL_MAX_CONTENT_LEN + int "CoAP MBEDTLS maximum content length value" + default 1500 + range 256 16384 + depends on MBEDTLS + help + This option sets the value of the MBEDTLS_SSL_MAX_CONTENT_LEN option + in ext/lib/crypto/mbedtls/configs/config-coap.h For client/server + communication to work these values need to be the same on both sides. + config NET_DEBUG_COAP bool "Debug COAP" default n