mirror of
https://github.com/espressif/openthread.git
synced 2026-08-12 21:57:47 +00:00
[mbedtls] guard allocator with accurate macro (#3575)
This commit guards using mbedTLS's buffer allocator API with a more accurate macro, so that even in single instance mode, we can use other memory allocator.
This commit is contained in:
@@ -434,8 +434,16 @@ if test "$enable_builtin_mbedtls" = "yes" -a ! "${MBEDTLS_CPPFLAGS}"; then
|
||||
MBEDTLS_CPPFLAGS="${MBEDTLS_CPPFLAGS} -I\${abs_top_srcdir}/third_party/mbedtls/repo/include"
|
||||
MBEDTLS_CPPFLAGS="${MBEDTLS_CPPFLAGS} -DMBEDTLS_CONFIG_FILE=\\\"mbedtls-config.h\\\""
|
||||
fi
|
||||
|
||||
if test "$enable_builtin_mbedtls" = "yes"; then
|
||||
OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS=1
|
||||
else
|
||||
OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS=0
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([whether mbed TLS should be enabled])
|
||||
AC_MSG_RESULT(${enable_builtin_mbedtls})
|
||||
AC_DEFINE_UNQUOTED([OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS], [${OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS}], [Define to 1 if you want to enable support for bultin-mbedtls.])
|
||||
AM_CONDITIONAL([OPENTHREAD_ENABLE_BUILTIN_MBEDTLS], [test "${enable_builtin_mbedtls}" = "yes"])
|
||||
|
||||
#
|
||||
|
||||
@@ -431,8 +431,10 @@ private:
|
||||
Settings mSettings;
|
||||
|
||||
#if !OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
#if OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS
|
||||
Crypto::MbedTls mMbedTls;
|
||||
Utils::Heap mHeap;
|
||||
#endif
|
||||
Utils::Heap mHeap;
|
||||
#endif
|
||||
|
||||
Ip6::Ip6 mIp6;
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
#include "common/instance.hpp"
|
||||
|
||||
#if !OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
#if !OPENTHREAD_ENABLE_MULTIPLE_INSTANCES && OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS
|
||||
|
||||
namespace ot {
|
||||
namespace Crypto {
|
||||
@@ -54,10 +54,14 @@ static void Free(void *aPointer)
|
||||
|
||||
MbedTls::MbedTls(void)
|
||||
{
|
||||
#ifdef MBEDTLS_DEBUG_C
|
||||
// mbedTLS's debug level is almost the same as OpenThread's
|
||||
mbedtls_debug_set_threshold(OPENTHREAD_CONFIG_LOG_LEVEL);
|
||||
#endif
|
||||
mbedtls_platform_set_calloc_free(CAlloc, Free);
|
||||
}
|
||||
|
||||
} // namespace Crypto
|
||||
} // namespace ot
|
||||
|
||||
#endif // #if !OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
#endif // !OPENTHREAD_ENABLE_MULTIPLE_INSTANCES && OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS
|
||||
|
||||
@@ -176,11 +176,6 @@ otError Dtls::Start(bool aClient,
|
||||
MBEDTLS_ENTROPY_SOURCE_STRONG);
|
||||
VerifyOrExit(rval == 0);
|
||||
|
||||
#ifdef MBEDTLS_DEBUG_C
|
||||
// mbedTLS's debug level is almost the same as OpenThread's
|
||||
mbedtls_debug_set_threshold(OPENTHREAD_CONFIG_LOG_LEVEL);
|
||||
#endif
|
||||
|
||||
{
|
||||
otExtAddress eui64;
|
||||
otPlatRadioGetIeeeEui64(&GetInstance(), eui64.m8);
|
||||
|
||||
@@ -679,6 +679,19 @@
|
||||
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_CRIT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS
|
||||
*
|
||||
* Define as 1 to enable bultin-mbedtls.
|
||||
*
|
||||
* Note that the OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS determines whether to use bultin-mbedtls as well as
|
||||
* whether to manage mbedTLS internally, such as memory allocation and debug.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS
|
||||
#define OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_DYNAMIC_LOG_LEVEL
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user