mirror of
https://github.com/espressif/openthread.git
synced 2026-08-12 13:47:47 +00:00
[dtls] make the max dtls buffer length configurable (#6233)
On systems where OpenThread share mbedtls configuration with HTTPS and other TLS based protocols. The TLS max content length can be way larger than OpenThread requires. Add an OpenThread config macro to reduce stack consumption under such circumstance.
This commit is contained in:
@@ -669,6 +669,7 @@ source_set("libopenthread_core_config") {
|
||||
"config/diag.h",
|
||||
"config/dns_client.h",
|
||||
"config/dnssd_server.h",
|
||||
"config/dtls.h",
|
||||
"config/ip6.h",
|
||||
"config/joiner.h",
|
||||
"config/link_quality.h",
|
||||
|
||||
@@ -407,6 +407,7 @@ HEADERS_COMMON = \
|
||||
config/diag.h \
|
||||
config/dns_client.h \
|
||||
config/dnssd_server.h \
|
||||
config/dtls.h \
|
||||
config/ip6.h \
|
||||
config/joiner.h \
|
||||
config/link_quality.h \
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2021, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file includes compile-time configurations for DTLS.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_DTLS_H_
|
||||
#define CONFIG_DTLS_H_
|
||||
|
||||
#include "config/border_router.h"
|
||||
#include "config/coap.h"
|
||||
#include "config/commissioner.h"
|
||||
#include "config/joiner.h"
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_DTLS_MAX_CONTENT_LEN
|
||||
*
|
||||
* The max length of the OpenThread dtls content buffer.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_DTLS_MAX_CONTENT_LEN
|
||||
#define OPENTHREAD_CONFIG_DTLS_MAX_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE || OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE || \
|
||||
OPENTHREAD_CONFIG_COMMISSIONER_ENABLE || OPENTHREAD_CONFIG_JOINER_ENABLE
|
||||
#define OPENTHREAD_CONFIG_DTLS_ENABLE 1
|
||||
#else
|
||||
#define OPENTHREAD_CONFIG_DTLS_ENABLE 0
|
||||
#endif
|
||||
|
||||
#endif // CONFIG_DTLS_H_
|
||||
@@ -781,7 +781,7 @@ void Dtls::HandleTimer(void)
|
||||
|
||||
void Dtls::Process(void)
|
||||
{
|
||||
uint8_t buf[MBEDTLS_SSL_MAX_CONTENT_LEN];
|
||||
uint8_t buf[OPENTHREAD_CONFIG_DTLS_MAX_CONTENT_LEN];
|
||||
bool shouldDisconnect = false;
|
||||
int rval;
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
#include "config/diag.h"
|
||||
#include "config/dns_client.h"
|
||||
#include "config/dnssd_server.h"
|
||||
#include "config/dtls.h"
|
||||
#include "config/ip6.h"
|
||||
#include "config/joiner.h"
|
||||
#include "config/link_quality.h"
|
||||
@@ -82,13 +83,6 @@
|
||||
#include "config/time_sync.h"
|
||||
#include "config/tmf.h"
|
||||
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE || OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE || \
|
||||
OPENTHREAD_CONFIG_COMMISSIONER_ENABLE || OPENTHREAD_CONFIG_JOINER_ENABLE
|
||||
#define OPENTHREAD_CONFIG_DTLS_ENABLE 1
|
||||
#else
|
||||
#define OPENTHREAD_CONFIG_DTLS_ENABLE 0
|
||||
#endif
|
||||
|
||||
#undef OPENTHREAD_CORE_CONFIG_H_IN
|
||||
|
||||
#include "config/openthread-core-config-check.h"
|
||||
|
||||
Reference in New Issue
Block a user