From 874b6beca8c0ce09f2d296652d234c0d011ad1d1 Mon Sep 17 00:00:00 2001 From: Kangping Date: Tue, 9 May 2023 00:09:46 +0800 Subject: [PATCH] [border-agent] fix BorderAgentId compile and enable it in CI tests (#9030) --- script/cmake-build | 1 + src/core/common/settings.hpp | 7 ++++--- src/core/meshcop/border_agent.cpp | 2 -- src/core/meshcop/border_agent.hpp | 5 +---- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/script/cmake-build b/script/cmake-build index 727984305..169c550ed 100755 --- a/script/cmake-build +++ b/script/cmake-build @@ -73,6 +73,7 @@ readonly OT_PLATFORMS OT_POSIX_SIM_COMMON_OPTIONS=( "-DOT_ANYCAST_LOCATOR=ON" "-DOT_BORDER_AGENT=ON" + "-DOT_BORDER_AGENT_ID=ON" "-DOT_BORDER_ROUTER=ON" "-DOT_CHANNEL_MANAGER=ON" "-DOT_CHANNEL_MONITOR=ON" diff --git a/src/core/common/settings.hpp b/src/core/common/settings.hpp index 7b7362613..4b307d01c 100644 --- a/src/core/common/settings.hpp +++ b/src/core/common/settings.hpp @@ -36,6 +36,7 @@ #include "openthread-core-config.h" +#include #include #include "common/clearable.hpp" @@ -47,7 +48,6 @@ #include "common/settings_driver.hpp" #include "crypto/ecdsa.hpp" #include "mac/mac_types.hpp" -#include "meshcop/border_agent.hpp" #include "meshcop/dataset.hpp" #include "net/ip6_address.hpp" #include "thread/version.hpp" @@ -779,7 +779,8 @@ public: friend class Clearable; public: - static constexpr Key kKey = kKeyBorderAgentId; ///< The associated key. + static constexpr Key kKey = kKeyBorderAgentId; ///< The associated key. + static constexpr uint8_t kLength = OT_BORDER_AGENT_ID_LENGTH; /** * This method initializes the `BorderAgentId` object. @@ -815,7 +816,7 @@ public: private: void Log(Action aAction) const; - uint8_t mId[MeshCoP::BorderAgent::kIdLength]; + uint8_t mId[kLength]; } OT_TOOL_PACKED_END; #endif // OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE diff --git a/src/core/meshcop/border_agent.cpp b/src/core/meshcop/border_agent.cpp index fb3a061d4..73c6c0d8d 100644 --- a/src/core/meshcop/border_agent.cpp +++ b/src/core/meshcop/border_agent.cpp @@ -237,8 +237,6 @@ Error BorderAgent::GetId(uint8_t *aId, uint16_t &aLength) { Error error = kErrorNone; - static_assert(sizeof(mId) == kIdLength, "Invalid Border Agent ID size"); - VerifyOrExit(aLength >= sizeof(mId), error = kErrorInvalidArgs); VerifyOrExit(!mIdInitialized, error = kErrorNone); diff --git a/src/core/meshcop/border_agent.hpp b/src/core/meshcop/border_agent.hpp index 26025c986..4a047a5e2 100644 --- a/src/core/meshcop/border_agent.hpp +++ b/src/core/meshcop/border_agent.hpp @@ -44,6 +44,7 @@ #include "common/locator.hpp" #include "common/non_copyable.hpp" #include "common/notifier.hpp" +#include "common/settings.hpp" #include "net/udp6.hpp" #include "thread/tmf.hpp" #include "thread/uri_paths.hpp" @@ -59,10 +60,6 @@ class BorderAgent : public InstanceLocator, private NonCopyable friend class Tmf::SecureAgent; public: -#if OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE - static constexpr uint8_t kIdLength = OT_BORDER_AGENT_ID_LENGTH; -#endif - /** * This enumeration defines the Border Agent state. *