Skip to content

Commit

Permalink
change Dtls class name to SecureTransport
Browse files Browse the repository at this point in the history
  • Loading branch information
canisLupus1313 committed Sep 29, 2023
1 parent f2671cf commit 349d1e7
Show file tree
Hide file tree
Showing 21 changed files with 209 additions and 196 deletions.
6 changes: 3 additions & 3 deletions src/core/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,6 @@ openthread_core_files = [
"meshcop/dataset_manager_ftd.cpp",
"meshcop/dataset_updater.cpp",
"meshcop/dataset_updater.hpp",
"meshcop/dtls.cpp",
"meshcop/dtls.hpp",
"meshcop/energy_scan_client.cpp",
"meshcop/energy_scan_client.hpp",
"meshcop/extended_panid.cpp",
Expand All @@ -535,6 +533,8 @@ openthread_core_files = [
"meshcop/network_name.hpp",
"meshcop/panid_query_client.cpp",
"meshcop/panid_query_client.hpp",
"meshcop/secure_transport.cpp",
"meshcop/secure_transport.hpp",
"meshcop/tcat_agent.cpp",
"meshcop/tcat_agent.hpp",
"meshcop/timestamp.cpp",
Expand Down Expand Up @@ -799,7 +799,6 @@ source_set("libopenthread_core_config") {
"config/dns_client.h",
"config/dns_dso.h",
"config/dnssd_server.h",
"config/dtls.h",
"config/history_tracker.h",
"config/ip6.h",
"config/joiner.h",
Expand All @@ -821,6 +820,7 @@ source_set("libopenthread_core_config") {
"config/platform.h",
"config/power_calibration.h",
"config/radio_link.h",
"config/secure_transport.h",
"config/sntp_client.h",
"config/srp_client.h",
"config/srp_server.h",
Expand Down
2 changes: 1 addition & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ set(COMMON_SOURCES
meshcop/dataset_manager.cpp
meshcop/dataset_manager_ftd.cpp
meshcop/dataset_updater.cpp
meshcop/dtls.cpp
meshcop/energy_scan_client.cpp
meshcop/extended_panid.cpp
meshcop/joiner.cpp
Expand All @@ -159,6 +158,7 @@ set(COMMON_SOURCES
meshcop/meshcop_tlvs.cpp
meshcop/network_name.cpp
meshcop/panid_query_client.cpp
meshcop/secure_transport.cpp
meshcop/tcat_agent.cpp
meshcop/timestamp.cpp
net/checksum.cpp
Expand Down
10 changes: 5 additions & 5 deletions src/core/coap/coap_secure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@

#include "coap_secure.hpp"

#if OPENTHREAD_CONFIG_DTLS_ENABLE
#if OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE

#include "common/instance.hpp"
#include "common/locator_getters.hpp"
#include "common/log.hpp"
#include "common/new.hpp"
#include "meshcop/dtls.hpp"
#include "meshcop/secure_transport.hpp"
#include "thread/thread_netif.hpp"

/**
Expand Down Expand Up @@ -67,7 +67,7 @@ Error CoapSecure::Start(uint16_t aPort)
return error;
}

Error CoapSecure::Start(MeshCoP::Dtls::TransportCallback aCallback, void *aContext)
Error CoapSecure::Start(MeshCoP::SecureTransport::TransportCallback aCallback, void *aContext)
{
Error error = kErrorNone;

Expand Down Expand Up @@ -98,7 +98,7 @@ Error CoapSecure::Connect(const Ip6::SockAddr &aSockAddr, ConnectedCallback aCal
void CoapSecure::SetPsk(const MeshCoP::JoinerPskd &aPskd)
{
static_assert(static_cast<uint16_t>(MeshCoP::JoinerPskd::kMaxLength) <=
static_cast<uint16_t>(MeshCoP::Dtls::kPskMaxLength),
static_cast<uint16_t>(MeshCoP::SecureTransport::kPskMaxLength),
"The maximum length of DTLS PSK is smaller than joiner PSKd");

SuccessOrAssert(mDtls.SetPsk(reinterpret_cast<const uint8_t *>(aPskd.GetAsCString()), aPskd.GetLength()));
Expand Down Expand Up @@ -224,4 +224,4 @@ void CoapSecure::HandleTransmit(void)
} // namespace Coap
} // namespace ot

#endif // OPENTHREAD_CONFIG_DTLS_ENABLE
#endif // OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE
12 changes: 6 additions & 6 deletions src/core/coap/coap_secure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@

#include "openthread-core-config.h"

#if OPENTHREAD_CONFIG_DTLS_ENABLE
#if OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE

#include "coap/coap.hpp"
#include "common/callback.hpp"
#include "meshcop/dtls.hpp"
#include "meshcop/meshcop.hpp"
#include "meshcop/secure_transport.hpp"

#include <openthread/coap_secure.h>

Expand Down Expand Up @@ -91,7 +91,7 @@ class CoapSecure : public CoapBase
* @retval kErrorAlready Already started.
*
*/
Error Start(MeshCoP::Dtls::TransportCallback aCallback, void *aContext);
Error Start(MeshCoP::SecureTransport::TransportCallback aCallback, void *aContext);

/**
* Sets connected callback of this secure CoAP agent.
Expand Down Expand Up @@ -153,7 +153,7 @@ class CoapSecure : public CoapBase
* @returns A reference to the DTLS object.
*
*/
MeshCoP::Dtls &GetDtls(void) { return mDtls; }
MeshCoP::SecureTransport &GetDtls(void) { return mDtls; }

/**
* Gets the UDP port of this agent.
Expand Down Expand Up @@ -409,7 +409,7 @@ class CoapSecure : public CoapBase
static void HandleTransmit(Tasklet &aTasklet);
void HandleTransmit(void);

MeshCoP::Dtls mDtls;
MeshCoP::SecureTransport mDtls;
Callback<ConnectedCallback> mConnectedCallback;
ot::MessageQueue mTransmitQueue;
TaskletContext mTransmitTask;
Expand All @@ -418,6 +418,6 @@ class CoapSecure : public CoapBase
} // namespace Coap
} // namespace ot

#endif // OPENTHREAD_CONFIG_DTLS_ENABLE
#endif // OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE

#endif // COAP_SECURE_HPP_
4 changes: 2 additions & 2 deletions src/core/common/instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Instance::Instance(void)
#if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD
, mCommissioner(*this)
#endif
#if OPENTHREAD_CONFIG_DTLS_ENABLE
#if OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE
, mTmfSecureAgent(*this)
#endif
#if OPENTHREAD_CONFIG_JOINER_ENABLE
Expand Down Expand Up @@ -426,7 +426,7 @@ void Instance::GetBufferInfo(BufferInfo &aInfo)
Get<Tmf::Agent>().GetRequestMessages().GetInfo(aInfo.mCoapQueue);
Get<Tmf::Agent>().GetCachedResponses().GetInfo(aInfo.mCoapQueue);

#if OPENTHREAD_CONFIG_DTLS_ENABLE
#if OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE
Get<Tmf::SecureAgent>().GetRequestMessages().GetInfo(aInfo.mCoapSecureQueue);
Get<Tmf::SecureAgent>().GetCachedResponses().GetInfo(aInfo.mCoapSecureQueue);
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/core/common/instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ class Instance : public otInstance, private NonCopyable
MeshCoP::Commissioner mCommissioner;
#endif

#if OPENTHREAD_CONFIG_DTLS_ENABLE
#if OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE
Tmf::SecureAgent mTmfSecureAgent;
#endif

Expand Down Expand Up @@ -806,7 +806,7 @@ template <> inline Ip6::Mpl &Instance::Get(void) { return mIp6.mMpl; }

template <> inline Tmf::Agent &Instance::Get(void) { return mTmfAgent; }

#if OPENTHREAD_CONFIG_DTLS_ENABLE
#if OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE
template <> inline Tmf::SecureAgent &Instance::Get(void) { return mTmfSecureAgent; }
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/core/config/openthread-core-config-check.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
#endif

#ifdef OPENTHREAD_ENABLE_DTLS
#error "OPENTHREAD_ENABLE_DTLS was replaced by OPENTHREAD_CONFIG_DTLS_ENABLE."
#error "OPENTHREAD_ENABLE_DTLS was replaced by OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE."
#endif

#ifdef OPENTHREAD_ENABLE_JAM_DETECTION
Expand Down
20 changes: 12 additions & 8 deletions src/core/config/dtls.h → src/core/config/secure_transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@

/**
* @file
* This file includes compile-time configurations for DTLS.
* This file includes compile-time configurations for TLS/DTLS.
*
*/

#ifndef CONFIG_DTLS_H_
#define CONFIG_DTLS_H_
#ifndef CONFIG_SECURE_TRANSPORT_H_
#define CONFIG_SECURE_TRANSPORT_H_

#include "config/border_agent.h"
#include "config/coap.h"
Expand All @@ -51,15 +51,19 @@
#endif

/**
* @def OPENTHREAD_CONFIG_DTLS_ENABLE
* @def OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE
*
* Define to 1 to enable DTLS.
* Define to 1 to enable DTLS/TLS.
*
*/
#ifndef OPENTHREAD_CONFIG_DTLS_ENABLE
#define OPENTHREAD_CONFIG_DTLS_ENABLE \
#ifndef OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE
#define OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE \
(OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE || OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE || \
OPENTHREAD_CONFIG_COMMISSIONER_ENABLE || OPENTHREAD_CONFIG_JOINER_ENABLE || OPENTHREAD_CONFIG_BLE_TCAT_ENABLE)
#endif

#endif // CONFIG_DTLS_H_
#if OPENTHREAD_CONFIG_DTLS_ENABLE
#error "OPENTHREAD_CONFIG_DTLS_ENABLE is deprecated please use OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE instead"
#endif

#endif // CONFIG_SECURE_TRANSPORT_H_
2 changes: 1 addition & 1 deletion src/core/meshcop/commissioner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
#include "common/timer.hpp"
#include "mac/mac_types.hpp"
#include "meshcop/announce_begin_client.hpp"
#include "meshcop/dtls.hpp"
#include "meshcop/energy_scan_client.hpp"
#include "meshcop/panid_query_client.hpp"
#include "meshcop/secure_transport.hpp"
#include "net/ip6_address.hpp"
#include "net/udp6.hpp"
#include "thread/key_manager.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/core/meshcop/joiner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
#include "common/message.hpp"
#include "common/non_copyable.hpp"
#include "mac/mac_types.hpp"
#include "meshcop/dtls.hpp"
#include "meshcop/meshcop.hpp"
#include "meshcop/meshcop_tlvs.hpp"
#include "meshcop/secure_transport.hpp"
#include "thread/discover_scanner.hpp"
#include "thread/tmf.hpp"

Expand Down
Loading

0 comments on commit 349d1e7

Please sign in to comment.