mirror of
https://github.com/espressif/openthread.git
synced 2026-07-30 15:47:46 +00:00
[config] coap (#4020)
This commit is contained in:
+3
-5
@@ -60,11 +60,11 @@ python --version || die
|
||||
-DOPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1 \
|
||||
-DOPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1 \
|
||||
-DOPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1 \
|
||||
-DOPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1"
|
||||
-DOPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1 \
|
||||
-DOPENTHREAD_CONFIG_COAP_API_ENABLE=1 \
|
||||
-DOPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=1"
|
||||
|
||||
scan-build ./configure \
|
||||
--enable-application-coap \
|
||||
--enable-application-coap-secure \
|
||||
--enable-builtin-mbedtls=no \
|
||||
--enable-cert-log \
|
||||
--enable-cli \
|
||||
@@ -95,8 +95,6 @@ python --version || die
|
||||
|
||||
# SPI transport
|
||||
scan-build ./configure \
|
||||
--enable-application-coap \
|
||||
--enable-application-coap-secure \
|
||||
--enable-builtin-mbedtls=no \
|
||||
--enable-cert-log \
|
||||
--enable-cli \
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ endif
|
||||
# Enable all optional features for CI tests.
|
||||
ifeq ($(TARGET_PRODUCT),generic)
|
||||
OPENTHREAD_COMMON_FLAGS += \
|
||||
-DOPENTHREAD_ENABLE_APPLICATION_COAP=1 \
|
||||
-DOPENTHREAD_CONFIG_COAP_API_ENABLE=1 \
|
||||
-DOPENTHREAD_ENABLE_COMMISSIONER=1 \
|
||||
-DOPENTHREAD_ENABLE_DHCP6_CLIENT=1 \
|
||||
-DOPENTHREAD_ENABLE_DHCP6_SERVER=1 \
|
||||
|
||||
@@ -32,8 +32,6 @@ AM_MAKEFLAGS = --no-print-directory
|
||||
|
||||
AM_DISTCHECK_CONFIGURE_FLAGS = \
|
||||
--enable-address-sanitizer \
|
||||
--enable-application-coap \
|
||||
--enable-application-coap-secure \
|
||||
--enable-cert-log \
|
||||
--enable-cli \
|
||||
--enable-commissioner \
|
||||
|
||||
@@ -839,37 +839,6 @@ AC_SUBST(OPENTHREAD_ENABLE_MTD_NETWORK_DIAGNOSTIC)
|
||||
AM_CONDITIONAL([OPENTHREAD_ENABLE_MTD_NETWORK_DIAGNOSTIC], [test "${enable_mtd_network_diagnostic}" = "yes"])
|
||||
AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_MTD_NETWORK_DIAGNOSTIC],[${OPENTHREAD_ENABLE_MTD_NETWORK_DIAGNOSTIC}],[Define to 1 to enable network diagnostic for MTD.])
|
||||
|
||||
#
|
||||
# Application CoAP Secure
|
||||
#
|
||||
|
||||
AC_ARG_ENABLE(application_coap_secure,
|
||||
[AS_HELP_STRING([--enable-application-coap-secure],[Enable CoAP Secure to an application.@<:@default=no@:>@.])],
|
||||
[
|
||||
case "${enableval}" in
|
||||
|
||||
no|yes)
|
||||
enable_application_coap_secure=${enableval}
|
||||
;;
|
||||
|
||||
*)
|
||||
AC_MSG_ERROR([Invalid value ${enable_application_coap_secure} for --enable-application-coap_secure])
|
||||
;;
|
||||
esac
|
||||
],
|
||||
[enable_application_coap_secure=no])
|
||||
|
||||
if test "$enable_application_coap_secure" = "yes"; then
|
||||
OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE=1
|
||||
enable_application_coap="yes"
|
||||
else
|
||||
OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE=0
|
||||
fi
|
||||
|
||||
AC_SUBST(OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE)
|
||||
AM_CONDITIONAL([OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE], [test "${enable_application_coap_secure}" = "yes"])
|
||||
AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE],[${OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE}],[Define to 1 if you want to enable CoAP Secure to an application.])
|
||||
|
||||
#
|
||||
# Platform UDP
|
||||
#
|
||||
@@ -1326,36 +1295,6 @@ AC_SUBST(OPENTHREAD_ENABLE_SNTP_CLIENT)
|
||||
AM_CONDITIONAL([OPENTHREAD_ENABLE_SNTP_CLIENT], [test "${enable_sntp_client}" = "yes"])
|
||||
AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_SNTP_CLIENT],[${OPENTHREAD_ENABLE_SNTP_CLIENT}],[Define to 1 if you want to enable SNTP Client])
|
||||
|
||||
#
|
||||
# Application CoAP
|
||||
#
|
||||
|
||||
AC_ARG_ENABLE(application_coap,
|
||||
[AS_HELP_STRING([--enable-application-coap],[Enable CoAP to an application.@<:@default=no@:>@.])],
|
||||
[
|
||||
case "${enableval}" in
|
||||
|
||||
no|yes)
|
||||
enable_application_coap=${enableval}
|
||||
;;
|
||||
|
||||
*)
|
||||
AC_MSG_ERROR([Invalid value ${enable_application_coap} for --enable-application-coap])
|
||||
;;
|
||||
esac
|
||||
],
|
||||
[enable_application_coap=no])
|
||||
|
||||
if test "$enable_application_coap" = "yes"; then
|
||||
OPENTHREAD_ENABLE_APPLICATION_COAP=1
|
||||
else
|
||||
OPENTHREAD_ENABLE_APPLICATION_COAP=0
|
||||
fi
|
||||
|
||||
AC_SUBST(OPENTHREAD_ENABLE_APPLICATION_COAP)
|
||||
AM_CONDITIONAL([OPENTHREAD_ENABLE_APPLICATION_COAP], [test "${enable_application_coap}" = "yes"])
|
||||
AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_APPLICATION_COAP],[${OPENTHREAD_ENABLE_APPLICATION_COAP}],[Define to 1 if you want to enable CoAP to an application.])
|
||||
|
||||
#
|
||||
# otLinkRaw API
|
||||
#
|
||||
@@ -1885,8 +1824,6 @@ AC_MSG_NOTICE([
|
||||
OpenThread DHCPv6 Client support : ${enable_dhcp6_client}
|
||||
OpenThread DNS Client support : ${enable_dns_client}
|
||||
OpenThread SNTP Client support : ${enable_sntp_client}
|
||||
OpenThread Application CoAP support : ${enable_application_coap}
|
||||
OpenThread Application CoAP Secure support: ${enable_application_coap_secure}
|
||||
OpenThread Raw Link-Layer support : ${enable_raw_link_api}
|
||||
OpenThread Service support : ${enable_service}
|
||||
OpenThread ECDSA support : ${enable_ecdsa}
|
||||
|
||||
@@ -75,11 +75,11 @@ COMMONCFLAGS += -DOPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1
|
||||
endif
|
||||
|
||||
ifeq ($(COAP),1)
|
||||
configure_OPTIONS += --enable-application-coap
|
||||
COMMONCFLAGS += -DOPENTHREAD_CONFIG_COAP_API_ENABLE=1
|
||||
endif
|
||||
|
||||
ifeq ($(COAPS),1)
|
||||
configure_OPTIONS += --enable-application-coap-secure
|
||||
COMMONCFLAGS += -DOPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=1
|
||||
endif
|
||||
|
||||
ifeq ($(COMMISSIONER),1)
|
||||
|
||||
@@ -50,8 +50,7 @@ extern "C" {
|
||||
* @brief
|
||||
* This module includes functions that control CoAP communication.
|
||||
*
|
||||
* The functions in this module are available when application-coap feature (`OPENTHREAD_ENABLE_APPLICATION_COAP`) is
|
||||
* enabled.
|
||||
* The functions in this module are available when CoAP API feature (`OPENTHREAD_CONFIG_COAP_API_ENABLE`) is enabled.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
|
||||
@@ -55,8 +55,8 @@ extern "C" {
|
||||
* @brief
|
||||
* This module includes functions that control CoAP Secure (CoAP over DTLS) communication.
|
||||
*
|
||||
* The functions in this module are available when application-coap-secure feature
|
||||
* (`OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE`) is enabled.
|
||||
* The functions in this module are available when CoAP Secure API feature
|
||||
* (`OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE`) is enabled.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
|
||||
+8
-8
@@ -100,10 +100,10 @@ const struct Command Interpreter::sCommands[] = {
|
||||
{"childmax", &Interpreter::ProcessChildMax},
|
||||
#endif
|
||||
{"childtimeout", &Interpreter::ProcessChildTimeout},
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#if OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
{"coap", &Interpreter::ProcessCoap},
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
{"coaps", &Interpreter::ProcessCoapSecure},
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
|
||||
@@ -231,10 +231,10 @@ Interpreter::Interpreter(Instance *aInstance)
|
||||
#endif
|
||||
, mUdp(*this)
|
||||
, mDataset(*this)
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#if OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
, mCoap(*this)
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
, mCoapSecure(*this)
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
|
||||
@@ -759,7 +759,7 @@ exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#if OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
|
||||
void Interpreter::ProcessCoap(int argc, char *argv[])
|
||||
{
|
||||
@@ -768,9 +768,9 @@ void Interpreter::ProcessCoap(int argc, char *argv[])
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#endif // OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
void Interpreter::ProcessCoapSecure(int argc, char *argv[])
|
||||
{
|
||||
@@ -779,7 +779,7 @@ void Interpreter::ProcessCoapSecure(int argc, char *argv[])
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
void Interpreter::ProcessContextIdReuseDelay(int argc, char *argv[])
|
||||
|
||||
+8
-8
@@ -49,11 +49,11 @@
|
||||
#include "cli/cli_joiner.hpp"
|
||||
#include "cli/cli_udp.hpp"
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#if OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
#include "cli/cli_coap.hpp"
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
#include "cli/cli_coap_secure.hpp"
|
||||
#endif
|
||||
|
||||
@@ -202,12 +202,12 @@ private:
|
||||
void ProcessChildMax(int argc, char *argv[]);
|
||||
#endif
|
||||
void ProcessChildTimeout(int argc, char *argv[]);
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#if OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
void ProcessCoap(int argc, char *argv[]);
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
void ProcessCoapSecure(int argc, char *argv[]);
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#endif // OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
|
||||
void ProcessCommissioner(int argc, char *argv[]);
|
||||
#endif
|
||||
@@ -389,11 +389,11 @@ private:
|
||||
UdpExample mUdp;
|
||||
Dataset mDataset;
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#if OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
Coap mCoap;
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
CoapSecure mCoapSecure;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#include "cli_coap.hpp"
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#if OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
@@ -385,4 +385,4 @@ void Coap::HandleResponse(otMessage *aMessage, const otMessageInfo *aMessageInfo
|
||||
} // namespace Cli
|
||||
} // namespace ot
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#endif // OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "openthread-core-config.h"
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#if OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
|
||||
#include "coap/coap_message.hpp"
|
||||
|
||||
@@ -106,6 +106,6 @@ private:
|
||||
} // namespace Cli
|
||||
} // namespace ot
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#endif // OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
|
||||
#endif // CLI_COAP_HPP_
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#include "cli_coap_secure.hpp"
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
#include <mbedtls/debug.h>
|
||||
#include <openthread/ip6.h>
|
||||
@@ -586,4 +586,4 @@ exit:
|
||||
} // namespace Cli
|
||||
} // namespace ot
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "openthread-core-config.h"
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
#include "coap/coap_message.hpp"
|
||||
#include "coap/coap_secure.hpp"
|
||||
@@ -130,6 +130,6 @@ private:
|
||||
} // namespace Cli
|
||||
} // namespace ot
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
#endif // CLI_COAP_SECURE_HPP_
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
||||
|
||||
/**SERVER
|
||||
@@ -103,7 +103,7 @@ extern "C" {
|
||||
"-----END CERTIFICATE-----\r\n"
|
||||
|
||||
#endif // MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -323,6 +323,7 @@ HEADERS_COMMON = \
|
||||
config/channel_manager.h \
|
||||
config/channel_monitor.h \
|
||||
config/child_supervision.h \
|
||||
config/coap.h \
|
||||
config/openthread-core-config-check.h \
|
||||
config/openthread-core-default-config.h \
|
||||
crypto/aes_ccm.hpp \
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "common/instance.hpp"
|
||||
#include "common/locator-getters.hpp"
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#if OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
|
||||
using namespace ot;
|
||||
|
||||
@@ -225,4 +225,4 @@ otError otCoapSendResponse(otInstance *aInstance, otMessage *aMessage, const otM
|
||||
*static_cast<const Ip6::MessageInfo *>(aMessageInfo));
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#endif // OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include "common/instance.hpp"
|
||||
#include "common/locator-getters.hpp"
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
using namespace ot;
|
||||
|
||||
@@ -239,4 +239,4 @@ otError otCoapSecureSendResponse(otInstance *aInstance, otMessage *aMessage, con
|
||||
*static_cast<const Ip6::MessageInfo *>(aMessageInfo));
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
@@ -207,7 +207,7 @@ void otMessageGetBufferInfo(otInstance *aInstance, otBufferInfo *aBufferInfo)
|
||||
aBufferInfo->mCoapSecureBuffers = 0;
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#if OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
instance.GetApplicationCoap().GetRequestMessages().GetInfo(aBufferInfo->mApplicationCoapMessages,
|
||||
aBufferInfo->mApplicationCoapBuffers);
|
||||
instance.GetApplicationCoap().GetCachedResponses().GetInfo(messages, buffers);
|
||||
|
||||
@@ -405,7 +405,7 @@ exit:
|
||||
return message;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#if OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
const char *Message::CodeToString(void) const
|
||||
{
|
||||
const char *codeString;
|
||||
@@ -500,7 +500,7 @@ const char *Message::CodeToString(void) const
|
||||
|
||||
return codeString;
|
||||
}
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#endif // OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
|
||||
} // namespace Coap
|
||||
} // namespace ot
|
||||
|
||||
@@ -188,7 +188,7 @@ public:
|
||||
*/
|
||||
void SetCode(Code aCode) { GetHelpData().mHeader.mCode = static_cast<uint8_t>(aCode); }
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#if OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
/**
|
||||
* This method returns the CoAP Code as human readable string.
|
||||
*
|
||||
@@ -196,7 +196,7 @@ public:
|
||||
*
|
||||
*/
|
||||
const char *CodeToString(void) const;
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#endif // OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
|
||||
/**
|
||||
* This method returns the Message ID value.
|
||||
|
||||
@@ -115,7 +115,7 @@ otError CoapSecure::SetPsk(const uint8_t *aPsk, uint8_t aPskLength)
|
||||
return mDtls.SetPsk(aPsk, aPskLength);
|
||||
}
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
#ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
otError CoapSecure::SetCertificate(const uint8_t *aX509Cert,
|
||||
@@ -160,7 +160,7 @@ void CoapSecure::SetSslAuthMode(bool aVerifyPeerCertificate)
|
||||
mDtls.SetSslAuthMode(aVerifyPeerCertificate);
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
otError CoapSecure::SendMessage(Message &aMessage, otCoapResponseHandler aHandler, void *aContext)
|
||||
{
|
||||
|
||||
@@ -160,7 +160,7 @@ public:
|
||||
*/
|
||||
otError SetPsk(const uint8_t *aPsk, uint8_t aPskLength);
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
#ifdef MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
|
||||
/**
|
||||
@@ -253,7 +253,7 @@ public:
|
||||
*/
|
||||
void SetSslAuthMode(bool aVerifyPeerCertificate);
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
/**
|
||||
* This method sends a CoAP message over secure DTLS connection.
|
||||
|
||||
@@ -71,10 +71,10 @@ Instance::Instance(void)
|
||||
, mEnergyScanCallbackContext(NULL)
|
||||
, mIp6(*this)
|
||||
, mThreadNetif(*this)
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#if OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
, mApplicationCoap(*this)
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
, mApplicationCoapSecure(*this, /* aLayerTwoSecurity */ true)
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE
|
||||
|
||||
@@ -259,7 +259,7 @@ public:
|
||||
Utils::Heap &GetHeap(void) { return mHeap; }
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#if OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
/**
|
||||
* This method returns a reference to application COAP object.
|
||||
*
|
||||
@@ -269,7 +269,7 @@ public:
|
||||
Coap::Coap &GetApplicationCoap(void) { return mApplicationCoap; }
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
/**
|
||||
* This method returns a reference to application COAP Secure object.
|
||||
*
|
||||
@@ -339,11 +339,11 @@ private:
|
||||
Ip6::Ip6 mIp6;
|
||||
ThreadNetif mThreadNetif;
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
#if OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
Coap::Coap mApplicationCoap;
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
Coap::CoapSecure mApplicationCoapSecure;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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 CoAP.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_COAP_H_
|
||||
#define CONFIG_COAP_H_
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_COAP_ACK_TIMEOUT
|
||||
*
|
||||
* Minimum spacing before first retransmission when ACK is not received (RFC7252 default value is 2).
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_COAP_ACK_TIMEOUT
|
||||
#define OPENTHREAD_CONFIG_COAP_ACK_TIMEOUT 2
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_COAP_ACK_RANDOM_FACTOR_NUMERATOR
|
||||
*
|
||||
* Numerator of ACK_RANDOM_FACTOR used to calculate maximum spacing before first retransmission when
|
||||
* ACK is not received (RFC7252 default value of ACK_RANDOM_FACTOR is 1.5, must not be decreased below 1).
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_COAP_ACK_RANDOM_FACTOR_NUMERATOR
|
||||
#define OPENTHREAD_CONFIG_COAP_ACK_RANDOM_FACTOR_NUMERATOR 3
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_COAP_ACK_RANDOM_FACTOR_DENOMINATOR
|
||||
*
|
||||
* Denominator of ACK_RANDOM_FACTOR used to calculate maximum spacing before first retransmission when
|
||||
* ACK is not received (RFC7252 default value of ACK_RANDOM_FACTOR is 1.5, must not be decreased below 1).
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_COAP_ACK_RANDOM_FACTOR_DENOMINATOR
|
||||
#define OPENTHREAD_CONFIG_COAP_ACK_RANDOM_FACTOR_DENOMINATOR 2
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_COAP_MAX_RETRANSMIT
|
||||
*
|
||||
* Maximum number of retransmissions for CoAP Confirmable messages (RFC7252 default value is 4).
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_COAP_MAX_RETRANSMIT
|
||||
#define OPENTHREAD_CONFIG_COAP_MAX_RETRANSMIT 4
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_COAP_SERVER_MAX_CACHED_RESPONSES
|
||||
*
|
||||
* Maximum number of cached responses for CoAP Confirmable messages.
|
||||
*
|
||||
* Cached responses are used for message deduplication.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_COAP_SERVER_MAX_CACHED_RESPONSES
|
||||
#define OPENTHREAD_CONFIG_COAP_SERVER_MAX_CACHED_RESPONSES 10
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
*
|
||||
* Define to 1 to enable the CoAP API.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
#define OPENTHREAD_CONFIG_COAP_API_ENABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
*
|
||||
* Define to 1 to enable the CoAP Secure API.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
#define OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE 0
|
||||
#endif
|
||||
|
||||
#endif // CONFIG_COAP_H_
|
||||
@@ -429,60 +429,6 @@
|
||||
#define OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_COAP_ACK_TIMEOUT
|
||||
*
|
||||
* Minimum spacing before first retransmission when ACK is not received (RFC7252 default value is 2).
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_COAP_ACK_TIMEOUT
|
||||
#define OPENTHREAD_CONFIG_COAP_ACK_TIMEOUT 2
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_COAP_ACK_RANDOM_FACTOR_NUMERATOR
|
||||
*
|
||||
* Numerator of ACK_RANDOM_FACTOR used to calculate maximum spacing before first retransmission when
|
||||
* ACK is not received (RFC7252 default value of ACK_RANDOM_FACTOR is 1.5, must not be decreased below 1).
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_COAP_ACK_RANDOM_FACTOR_NUMERATOR
|
||||
#define OPENTHREAD_CONFIG_COAP_ACK_RANDOM_FACTOR_NUMERATOR 3
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_COAP_ACK_RANDOM_FACTOR_DENOMINATOR
|
||||
*
|
||||
* Denominator of ACK_RANDOM_FACTOR used to calculate maximum spacing before first retransmission when
|
||||
* ACK is not received (RFC7252 default value of ACK_RANDOM_FACTOR is 1.5, must not be decreased below 1).
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_COAP_ACK_RANDOM_FACTOR_DENOMINATOR
|
||||
#define OPENTHREAD_CONFIG_COAP_ACK_RANDOM_FACTOR_DENOMINATOR 2
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_COAP_MAX_RETRANSMIT
|
||||
*
|
||||
* Maximum number of retransmissions for CoAP Confirmable messages (RFC7252 default value is 4).
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_COAP_MAX_RETRANSMIT
|
||||
#define OPENTHREAD_CONFIG_COAP_MAX_RETRANSMIT 4
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_COAP_SERVER_MAX_CACHED_RESPONSES
|
||||
*
|
||||
* Maximum number of cached responses for CoAP Confirmable messages.
|
||||
*
|
||||
* Cached responses are used for message deduplication.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_COAP_SERVER_MAX_CACHED_RESPONSES
|
||||
#define OPENTHREAD_CONFIG_COAP_SERVER_MAX_CACHED_RESPONSES 10
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_DNS_RESPONSE_TIMEOUT
|
||||
*
|
||||
@@ -1074,12 +1020,12 @@
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_HEAP_SIZE
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
#define OPENTHREAD_CONFIG_HEAP_SIZE (3072 * sizeof(void *))
|
||||
#else
|
||||
#define OPENTHREAD_CONFIG_HEAP_SIZE (1536 * sizeof(void *))
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_HEAP_SIZE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_HEAP_SIZE_NO_DTLS
|
||||
|
||||
+26
-26
@@ -78,7 +78,7 @@ Dtls::Dtls(Instance &aInstance, bool aLayerTwoSecurity)
|
||||
, mMessageSubType(Message::kSubTypeNone)
|
||||
, mMessageDefaultSubType(Message::kSubTypeNone)
|
||||
{
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
#ifdef MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
|
||||
mPreSharedKey = NULL;
|
||||
mPreSharedKeyIdentity = NULL;
|
||||
@@ -97,7 +97,7 @@ Dtls::Dtls(Instance &aInstance, bool aLayerTwoSecurity)
|
||||
memset(&mOwnCert, 0, sizeof(mOwnCert));
|
||||
memset(&mPrivateKey, 0, sizeof(mPrivateKey));
|
||||
#endif // MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
memset(mCipherSuites, 0, sizeof(mCipherSuites));
|
||||
memset(mPsk, 0, sizeof(mPsk));
|
||||
@@ -114,13 +114,13 @@ void Dtls::FreeMbedtls(void)
|
||||
#ifdef MBEDTLS_SSL_COOKIE_C
|
||||
mbedtls_ssl_cookie_free(&mCookieCtx);
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
#ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
mbedtls_x509_crt_free(&mCaChain);
|
||||
mbedtls_x509_crt_free(&mOwnCert);
|
||||
mbedtls_pk_free(&mPrivateKey);
|
||||
#endif // MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
mbedtls_ssl_config_free(&mConf);
|
||||
mbedtls_ssl_free(&mSsl);
|
||||
}
|
||||
@@ -254,19 +254,19 @@ otError Dtls::Setup(bool aClient)
|
||||
|
||||
mbedtls_ssl_init(&mSsl);
|
||||
mbedtls_ssl_config_init(&mConf);
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
#ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
mbedtls_x509_crt_init(&mCaChain);
|
||||
mbedtls_x509_crt_init(&mOwnCert);
|
||||
mbedtls_pk_init(&mPrivateKey);
|
||||
#endif // MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
rval = mbedtls_ssl_config_defaults(&mConf, aClient ? MBEDTLS_SSL_IS_CLIENT : MBEDTLS_SSL_IS_SERVER,
|
||||
MBEDTLS_SSL_TRANSPORT_DATAGRAM, MBEDTLS_SSL_PRESET_DEFAULT);
|
||||
VerifyOrExit(rval == 0);
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
if (mVerifyPeerCertificate && mCipherSuites[0] == MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8)
|
||||
{
|
||||
mbedtls_ssl_conf_authmode(&mConf, MBEDTLS_SSL_VERIFY_REQUIRED);
|
||||
@@ -277,7 +277,7 @@ otError Dtls::Setup(bool aClient)
|
||||
}
|
||||
#else
|
||||
OT_UNUSED_VARIABLE(mVerifyPeerCertificate);
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
mbedtls_ssl_conf_rng(&mConf, mbedtls_ctr_drbg_random, Random::Crypto::MbedTlsContextGet());
|
||||
mbedtls_ssl_conf_min_version(&mConf, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3);
|
||||
@@ -311,12 +311,12 @@ otError Dtls::Setup(bool aClient)
|
||||
{
|
||||
rval = mbedtls_ssl_set_hs_ecjpake_password(&mSsl, mPsk, mPskLength);
|
||||
}
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
else
|
||||
{
|
||||
rval = SetApplicationCoapSecureKeys();
|
||||
}
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
VerifyOrExit(rval == 0);
|
||||
|
||||
mReceiveMessage = NULL;
|
||||
@@ -327,12 +327,12 @@ otError Dtls::Setup(bool aClient)
|
||||
{
|
||||
otLogInfoMeshCoP("DTLS started");
|
||||
}
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
else
|
||||
{
|
||||
otLogInfoCoap("Application Coap Secure DTLS started");
|
||||
}
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
mState = kStateConnecting;
|
||||
|
||||
@@ -348,7 +348,7 @@ exit:
|
||||
return Crypto::MbedTls::MapError(rval);
|
||||
}
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
int Dtls::SetApplicationCoapSecureKeys(void)
|
||||
{
|
||||
int rval = 0;
|
||||
@@ -403,7 +403,7 @@ void Dtls::SetSslAuthMode(bool aVerifyPeerCertificate)
|
||||
mVerifyPeerCertificate = aVerifyPeerCertificate;
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
void Dtls::Close(void)
|
||||
{
|
||||
@@ -450,7 +450,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
#ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
|
||||
otError Dtls::SetCertificate(const uint8_t *aX509Certificate,
|
||||
@@ -535,7 +535,7 @@ exit:
|
||||
}
|
||||
|
||||
#endif // MBEDTLS_BASE64_C
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
#ifdef MBEDTLS_SSL_SRV_C
|
||||
otError Dtls::SetClientId(const uint8_t *aClientId, uint8_t aLength)
|
||||
@@ -591,12 +591,12 @@ int Dtls::HandleMbedtlsTransmit(const unsigned char *aBuf, size_t aLength)
|
||||
{
|
||||
otLogDebgMeshCoP("Dtls::HandleMbedtlsTransmit");
|
||||
}
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
else
|
||||
{
|
||||
otLogDebgCoap("Dtls::ApplicationCoapSecure HandleMbedtlsTransmit");
|
||||
}
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
error = HandleDtlsSend(aBuf, static_cast<uint16_t>(aLength), mMessageSubType);
|
||||
|
||||
@@ -635,12 +635,12 @@ int Dtls::HandleMbedtlsReceive(unsigned char *aBuf, size_t aLength)
|
||||
{
|
||||
otLogDebgMeshCoP("Dtls::HandleMbedtlsReceive");
|
||||
}
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
else
|
||||
{
|
||||
otLogDebgCoap("Dtls:: ApplicationCoapSecure HandleMbedtlsReceive");
|
||||
}
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
VerifyOrExit(mReceiveMessage != NULL && mReceiveLength != 0, rval = MBEDTLS_ERR_SSL_WANT_READ);
|
||||
|
||||
@@ -670,12 +670,12 @@ int Dtls::HandleMbedtlsGetTimer(void)
|
||||
{
|
||||
otLogDebgMeshCoP("Dtls::HandleMbedtlsGetTimer");
|
||||
}
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
else
|
||||
{
|
||||
otLogDebgCoap("Dtls:: ApplicationCoapSecure HandleMbedtlsGetTimer");
|
||||
}
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
if (!mTimerSet)
|
||||
{
|
||||
@@ -708,12 +708,12 @@ void Dtls::HandleMbedtlsSetTimer(uint32_t aIntermediate, uint32_t aFinish)
|
||||
{
|
||||
otLogDebgMeshCoP("Dtls::SetTimer");
|
||||
}
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
else
|
||||
{
|
||||
otLogDebgCoap("Dtls::ApplicationCoapSecure SetTimer");
|
||||
}
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
if (aFinish == 0)
|
||||
{
|
||||
@@ -760,12 +760,12 @@ int Dtls::HandleMbedtlsExportKeys(const unsigned char *aMasterSecret,
|
||||
{
|
||||
otLogDebgMeshCoP("Generated KEK");
|
||||
}
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
else
|
||||
{
|
||||
otLogDebgCoap("ApplicationCoapSecure Generated KEK");
|
||||
}
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -41,7 +41,7 @@
|
||||
#include <mbedtls/ssl.h>
|
||||
#include <mbedtls/ssl_cookie.h>
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
#ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
#include <mbedtls/base64.h>
|
||||
#include <mbedtls/x509.h>
|
||||
@@ -49,7 +49,7 @@
|
||||
#include <mbedtls/x509_crt.h>
|
||||
#include <mbedtls/x509_csr.h>
|
||||
#endif // MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
#include "common/locator.hpp"
|
||||
#include "common/message.hpp"
|
||||
@@ -71,11 +71,11 @@ public:
|
||||
{
|
||||
kPskMaxLength = 32,
|
||||
kGuardTimeNewConnectionMilli = 2000,
|
||||
#if !OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if !OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
kApplicationDataMaxLength = 512,
|
||||
#else
|
||||
kApplicationDataMaxLength = OPENTHREAD_CONFIG_DTLS_APPLICATION_DATA_MAX_LENGTH,
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
};
|
||||
|
||||
enum State
|
||||
@@ -247,7 +247,7 @@ public:
|
||||
*/
|
||||
otError SetPsk(const uint8_t *aPsk, uint8_t aPskLength);
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
#ifdef MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
|
||||
/**
|
||||
* This method sets the Pre-Shared Key (PSK) for DTLS sessions-
|
||||
@@ -333,7 +333,7 @@ public:
|
||||
*
|
||||
*/
|
||||
void SetSslAuthMode(bool aVerifyPeerCertificate);
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
#ifdef MBEDTLS_SSL_SRV_C
|
||||
/**
|
||||
@@ -393,7 +393,7 @@ private:
|
||||
void FreeMbedtls(void);
|
||||
otError Setup(bool aClient);
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
/**
|
||||
* Set keys and/or certificates for dtls session dependent of used cipher suite.
|
||||
*
|
||||
@@ -401,7 +401,7 @@ private:
|
||||
*
|
||||
*/
|
||||
int SetApplicationCoapSecureKeys(void);
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
static void HandleMbedtlsDebug(void *ctx, int level, const char *file, int line, const char *str);
|
||||
|
||||
@@ -450,7 +450,7 @@ private:
|
||||
uint8_t mPsk[kPskMaxLength];
|
||||
uint8_t mPskLength;
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
#ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
|
||||
const uint8_t * mCaChainSrc;
|
||||
@@ -470,7 +470,7 @@ private:
|
||||
uint16_t mPreSharedKeyLength;
|
||||
uint16_t mPreSharedKeyIdLength;
|
||||
#endif // MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif // OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
|
||||
bool mVerifyPeerCertificate;
|
||||
|
||||
|
||||
@@ -49,8 +49,9 @@
|
||||
#include "config/channel_manager.h"
|
||||
#include "config/channel_monitor.h"
|
||||
#include "config/child_supervision.h"
|
||||
#include "config/coap.h"
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE || OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE || \
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE || OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE || \
|
||||
OPENTHREAD_ENABLE_COMMISSIONER || OPENTHREAD_ENABLE_JOINER
|
||||
#define OPENTHREAD_CONFIG_DTLS_ENABLE 1
|
||||
#endif
|
||||
|
||||
Vendored
+3
-4
@@ -76,13 +76,12 @@
|
||||
#define MBEDTLS_SSL_PROTO_DTLS
|
||||
#define MBEDTLS_SSL_TLS_C
|
||||
|
||||
#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE || OPENTHREAD_ENABLE_COMMISSIONER || \
|
||||
OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE || OPENTHREAD_ENABLE_COMMISSIONER || OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
#define MBEDTLS_SSL_COOKIE_C
|
||||
#define MBEDTLS_SSL_SRV_C
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
|
||||
#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
#endif
|
||||
@@ -121,7 +120,7 @@
|
||||
#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
|
||||
#define MBEDTLS_SSL_MAX_CONTENT_LEN 900 /**< Maxium fragment length in bytes */
|
||||
#else
|
||||
#define MBEDTLS_SSL_MAX_CONTENT_LEN 768 /**< Maxium fragment length in bytes */
|
||||
|
||||
Reference in New Issue
Block a user