From 2457ba7c1835c470cb4bd57477163f5803e79309 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Wed, 18 Oct 2023 16:11:25 -0700 Subject: [PATCH] [netdata] simplify parsing of Commissioning Dataset sub-TLVs (#9541) This commit contains changes related to parsing of Commissioning Dataset sub-TLVs in `NetworkData::Leader`: - Adds `FindInCommisioningData` to search for a given `SubTlvType` in Commissioning Data. - Adds `FindCommissioningSessionId()`, `FindBorderAgentRloc()`, and `FindJoinerUdpPort()` to parse and get get the info from Commissioning Dataset. --- src/core/backbone_router/bbr_manager.cpp | 7 +- src/core/meshcop/dataset_manager_ftd.cpp | 21 ++---- src/core/meshcop/joiner_router.cpp | 24 ++++--- src/core/meshcop/joiner_router.hpp | 5 +- src/core/meshcop/meshcop.cpp | 16 +---- src/core/meshcop/meshcop.hpp | 12 ---- src/core/meshcop/meshcop_leader.cpp | 3 +- src/core/thread/energy_scan_server.cpp | 4 +- src/core/thread/mesh_forwarder_ftd.cpp | 2 +- src/core/thread/mle_router.cpp | 10 +-- src/core/thread/network_data_leader.cpp | 74 +++++++++++++------- src/core/thread/network_data_leader.hpp | 76 +++++++++++++++------ src/core/thread/network_data_leader_ftd.cpp | 4 +- 13 files changed, 144 insertions(+), 114 deletions(-) diff --git a/src/core/backbone_router/bbr_manager.cpp b/src/core/backbone_router/bbr_manager.cpp index 09c1c76561c..c78fd16d256 100644 --- a/src/core/backbone_router/bbr_manager.cpp +++ b/src/core/backbone_router/bbr_manager.cpp @@ -176,11 +176,10 @@ void Manager::HandleMulticastListenerRegistration(const Coap::Message &aMessage, if (Tlv::Find(aMessage, commissionerSessionId) == kErrorNone) { - const MeshCoP::CommissionerSessionIdTlv *commissionerSessionIdTlv = As( - Get().GetCommissioningDataSubTlv(MeshCoP::Tlv::kCommissionerSessionId)); + uint16_t localSessionId; - VerifyOrExit(commissionerSessionIdTlv != nullptr && - commissionerSessionIdTlv->GetCommissionerSessionId() == commissionerSessionId, + VerifyOrExit((Get().FindCommissioningSessionId(localSessionId) == kErrorNone) && + (localSessionId == commissionerSessionId), status = ThreadStatusTlv::kMlrGeneralFailure); hasCommissionerSessionIdTlv = true; diff --git a/src/core/meshcop/dataset_manager_ftd.cpp b/src/core/meshcop/dataset_manager_ftd.cpp index 0fe978d30a2..22488d308af 100644 --- a/src/core/meshcop/dataset_manager_ftd.cpp +++ b/src/core/meshcop/dataset_manager_ftd.cpp @@ -167,14 +167,12 @@ Error DatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo // check commissioner session id if (Tlv::Find(aMessage, sessionId) == kErrorNone) { - const CommissionerSessionIdTlv *localId; + uint16_t localSessionId; isUpdateFromCommissioner = true; - localId = As( - Get().GetCommissioningDataSubTlv(Tlv::kCommissionerSessionId)); - - VerifyOrExit(localId != nullptr && localId->GetCommissionerSessionId() == sessionId); + SuccessOrExit(Get().FindCommissioningSessionId(localSessionId)); + VerifyOrExit(localSessionId == sessionId); } // verify an MGMT_ACTIVE_SET.req from a Commissioner does not affect connectivity @@ -240,16 +238,11 @@ Error DatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo // notify commissioner if update is from thread device if (!isUpdateFromCommissioner) { - const CommissionerSessionIdTlv *localSessionId; - Ip6::Address destination; - - localSessionId = As( - Get().GetCommissioningDataSubTlv(Tlv::kCommissionerSessionId)); - VerifyOrExit(localSessionId != nullptr); - - SuccessOrExit( - Get().GetCommissionerAloc(destination, localSessionId->GetCommissionerSessionId())); + uint16_t localSessionId; + Ip6::Address destination; + SuccessOrExit(Get().FindCommissioningSessionId(localSessionId)); + SuccessOrExit(Get().GetCommissionerAloc(destination, localSessionId)); Get().SendDatasetChanged(destination); } diff --git a/src/core/meshcop/joiner_router.cpp b/src/core/meshcop/joiner_router.cpp index 09616023c39..78fc270cf41 100644 --- a/src/core/meshcop/joiner_router.cpp +++ b/src/core/meshcop/joiner_router.cpp @@ -75,7 +75,7 @@ void JoinerRouter::Start(void) { VerifyOrExit(Get().IsFullThreadDevice()); - if (Get().IsJoiningEnabled()) + if (Get().IsJoiningAllowed()) { uint16_t port = GetJoinerUdpPort(); @@ -99,20 +99,24 @@ void JoinerRouter::Start(void) return; } -uint16_t JoinerRouter::GetJoinerUdpPort(void) +uint16_t JoinerRouter::GetJoinerUdpPort(void) const { - uint16_t rval = OPENTHREAD_CONFIG_JOINER_UDP_PORT; - const JoinerUdpPortTlv *joinerUdpPort; + uint16_t port; - VerifyOrExit(!mIsJoinerPortConfigured, rval = mJoinerUdpPort); + if (mIsJoinerPortConfigured) + { + ExitNow(port = mJoinerUdpPort); + } - joinerUdpPort = As(Get().GetCommissioningDataSubTlv(Tlv::kJoinerUdpPort)); - VerifyOrExit(joinerUdpPort != nullptr); + if (Get().FindJoinerUdpPort(port) == kErrorNone) + { + ExitNow(); + } - rval = joinerUdpPort->GetUdpPort(); + port = kDefaultJoinerUdpPort; exit: - return rval; + return port; } void JoinerRouter::SetJoinerUdpPort(uint16_t aJoinerUdpPort) @@ -137,7 +141,7 @@ void JoinerRouter::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &a LogInfo("JoinerRouter::HandleUdpReceive"); - SuccessOrExit(error = GetBorderAgentRloc(Get(), borderAgentRloc)); + SuccessOrExit(error = Get().FindBorderAgentRloc(borderAgentRloc)); message = Get().NewPriorityNonConfirmablePostMessage(kUriRelayRx); VerifyOrExit(message != nullptr, error = kErrorNoBufs); diff --git a/src/core/meshcop/joiner_router.hpp b/src/core/meshcop/joiner_router.hpp index d17c6429068..bc76297baa3 100644 --- a/src/core/meshcop/joiner_router.hpp +++ b/src/core/meshcop/joiner_router.hpp @@ -71,10 +71,10 @@ class JoinerRouter : public InstanceLocator, private NonCopyable /** * Returns the Joiner UDP Port. * - * @returns The Joiner UDP Port number . + * @returns The Joiner UDP Port number. * */ - uint16_t GetJoinerUdpPort(void); + uint16_t GetJoinerUdpPort(void) const; /** * Sets the Joiner UDP Port. @@ -85,6 +85,7 @@ class JoinerRouter : public InstanceLocator, private NonCopyable void SetJoinerUdpPort(uint16_t aJoinerUdpPort); private: + static constexpr uint16_t kDefaultJoinerUdpPort = OPENTHREAD_CONFIG_JOINER_UDP_PORT; static constexpr uint32_t kJoinerEntrustTxDelay = 50; // in msec struct JoinerEntrustMetadata diff --git a/src/core/meshcop/meshcop.cpp b/src/core/meshcop/meshcop.cpp index 9dd65663c76..da000d5639c 100644 --- a/src/core/meshcop/meshcop.cpp +++ b/src/core/meshcop/meshcop.cpp @@ -1,3 +1,4 @@ + /* * Copyright (c) 2017, The OpenThread Authors. * All rights reserved. @@ -300,21 +301,6 @@ void ComputeJoinerId(const Mac::ExtAddress &aEui64, Mac::ExtAddress &aJoinerId) aJoinerId.SetLocal(true); } -Error GetBorderAgentRloc(ThreadNetif &aNetif, uint16_t &aRloc) -{ - Error error = kErrorNone; - const BorderAgentLocatorTlv *borderAgentLocator; - - borderAgentLocator = As( - aNetif.Get().GetCommissioningDataSubTlv(Tlv::kBorderAgentLocator)); - VerifyOrExit(borderAgentLocator != nullptr, error = kErrorNotFound); - - aRloc = borderAgentLocator->GetBorderAgentLocator(); - -exit: - return error; -} - #if OPENTHREAD_FTD Error GeneratePskc(const char *aPassPhrase, const NetworkName &aNetworkName, diff --git a/src/core/meshcop/meshcop.hpp b/src/core/meshcop/meshcop.hpp index 7bf6f7806ce..c2a8b7d4353 100644 --- a/src/core/meshcop/meshcop.hpp +++ b/src/core/meshcop/meshcop.hpp @@ -434,18 +434,6 @@ Error GeneratePskc(const char *aPassPhrase, */ void ComputeJoinerId(const Mac::ExtAddress &aEui64, Mac::ExtAddress &aJoinerId); -/** - * Gets the border agent RLOC. - * - * @param[in] aNetIf A reference to the thread interface. - * @param[out] aRloc Border agent RLOC. - * - * @retval kErrorNone Successfully got the Border Agent Rloc. - * @retval kErrorNotFound Border agent is not available. - * - */ -Error GetBorderAgentRloc(ThreadNetif &aNetIf, uint16_t &aRloc); - #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_WARN) /** * Emits a log message indicating an error during a MeshCoP action. diff --git a/src/core/meshcop/meshcop_leader.cpp b/src/core/meshcop/meshcop_leader.cpp index 922a1539ef1..c4f0676d6e0 100644 --- a/src/core/meshcop/meshcop_leader.cpp +++ b/src/core/meshcop/meshcop_leader.cpp @@ -150,8 +150,7 @@ template <> void Leader::HandleTmf(Coap::Message &aMessage, SuccessOrExit(Tlv::Find(aMessage, sessionId)); - borderAgentLocator = - As(Get().GetCommissioningDataSubTlv(Tlv::kBorderAgentLocator)); + borderAgentLocator = Get().FindInCommissioningData(); if ((borderAgentLocator == nullptr) || (sessionId != mSessionId)) { diff --git a/src/core/thread/energy_scan_server.cpp b/src/core/thread/energy_scan_server.cpp index c207ef9f3ad..da5fa171a82 100644 --- a/src/core/thread/energy_scan_server.cpp +++ b/src/core/thread/energy_scan_server.cpp @@ -207,8 +207,10 @@ void EnergyScanServer::SendReport(void) void EnergyScanServer::HandleNotifierEvents(Events aEvents) { + uint16_t borderAgentRloc; + if (aEvents.Contains(kEventThreadNetdataChanged) && (mReportMessage != nullptr) && - Get().GetCommissioningData() == nullptr) + Get().FindBorderAgentRloc(borderAgentRloc) != kErrorNone) { mReportMessage->Free(); mReportMessage = nullptr; diff --git a/src/core/thread/mesh_forwarder_ftd.cpp b/src/core/thread/mesh_forwarder_ftd.cpp index 8ac143804be..12accafa433 100644 --- a/src/core/thread/mesh_forwarder_ftd.cpp +++ b/src/core/thread/mesh_forwarder_ftd.cpp @@ -534,7 +534,7 @@ Error MeshForwarder::UpdateIp6RouteFtd(const Ip6::Header &aIp6Header, Message &a } else if (aloc16 <= Mle::kAloc16CommissionerEnd) { - SuccessOrExit(error = MeshCoP::GetBorderAgentRloc(Get(), mMeshDest)); + SuccessOrExit(error = Get().FindBorderAgentRloc(mMeshDest)); } #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index 97d05581bff..99a98fc4f6b 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -2740,7 +2740,7 @@ void MleRouter::HandleDiscoveryRequest(RxInfo &aRxInfo) else // if steering data is not set out of band, fall back to network data #endif { - VerifyOrExit(Get().IsJoiningEnabled(), error = kErrorSecurity); + VerifyOrExit(Get().IsJoiningAllowed(), error = kErrorSecurity); } } } @@ -2821,13 +2821,13 @@ Error MleRouter::SendDiscoveryResponse(const Ip6::Address &aDestination, const M else #endif { - const MeshCoP::Tlv *steeringData; + const MeshCoP::SteeringDataTlv *steeringDataTlv; - steeringData = Get().GetCommissioningDataSubTlv(MeshCoP::Tlv::kSteeringData); + steeringDataTlv = Get().FindInCommissioningData(); - if (steeringData != nullptr) + if (steeringDataTlv != nullptr) { - SuccessOrExit(error = steeringData->AppendTo(*message)); + SuccessOrExit(error = steeringDataTlv->AppendTo(*message)); } } diff --git a/src/core/thread/network_data_leader.cpp b/src/core/thread/network_data_leader.cpp index 707d25b1c71..28799555422 100644 --- a/src/core/thread/network_data_leader.cpp +++ b/src/core/thread/network_data_leader.cpp @@ -453,50 +453,76 @@ Error LeaderBase::SetCommissioningData(const void *aValue, uint8_t aValueLength) return error; } -const CommissioningDataTlv *LeaderBase::GetCommissioningData(void) const +const CommissioningDataTlv *LeaderBase::FindCommissioningData(void) const { return NetworkDataTlv::Find(GetTlvsStart(), GetTlvsEnd()); } -const MeshCoP::Tlv *LeaderBase::GetCommissioningDataSubTlv(MeshCoP::Tlv::Type aType) const +const MeshCoP::Tlv *LeaderBase::FindCommissioningDataSubTlv(uint8_t aType) const { - const MeshCoP::Tlv *rval = nullptr; - const NetworkDataTlv *commissioningDataTlv; + const MeshCoP::Tlv *subTlv = nullptr; + const NetworkDataTlv *dataTlv = FindCommissioningData(); - commissioningDataTlv = GetCommissioningData(); - VerifyOrExit(commissioningDataTlv != nullptr); + VerifyOrExit(dataTlv != nullptr); + subTlv = As(Tlv::FindTlv(dataTlv->GetValue(), dataTlv->GetLength(), aType)); - rval = As(Tlv::FindTlv(commissioningDataTlv->GetValue(), commissioningDataTlv->GetLength(), aType)); +exit: + return subTlv; +} + +Error LeaderBase::ReadCommissioningDataUint16SubTlv(MeshCoP::Tlv::Type aType, uint16_t &aValue) const +{ + Error error = kErrorNone; + const MeshCoP::Tlv *subTlv = FindCommissioningDataSubTlv(aType); + + VerifyOrExit(subTlv != nullptr, error = kErrorNotFound); + VerifyOrExit(subTlv->GetLength() >= sizeof(uint16_t), error = kErrorParse); + aValue = Encoding::BigEndian::ReadUint16(subTlv->GetValue()); exit: - return rval; + return error; +} + +Error LeaderBase::FindBorderAgentRloc(uint16_t &aRloc16) const +{ + return ReadCommissioningDataUint16SubTlv(MeshCoP::Tlv::kBorderAgentLocator, aRloc16); +} + +Error LeaderBase::FindCommissioningSessionId(uint16_t &aSessionId) const +{ + return ReadCommissioningDataUint16SubTlv(MeshCoP::Tlv::kCommissionerSessionId, aSessionId); } -bool LeaderBase::IsJoiningEnabled(void) const +Error LeaderBase::FindJoinerUdpPort(uint16_t &aPort) const { - const MeshCoP::Tlv *steeringData; - bool rval = false; + return ReadCommissioningDataUint16SubTlv(MeshCoP::Tlv::kJoinerUdpPort, aPort); +} + +bool LeaderBase::IsJoiningAllowed(void) const +{ + bool isAllowed = false; + const MeshCoP::SteeringDataTlv *steeringDataTlv; - VerifyOrExit(GetCommissioningDataSubTlv(MeshCoP::Tlv::kBorderAgentLocator) != nullptr); + VerifyOrExit(FindInCommissioningData() != nullptr); - steeringData = GetCommissioningDataSubTlv(MeshCoP::Tlv::kSteeringData); - VerifyOrExit(steeringData != nullptr); + steeringDataTlv = FindInCommissioningData(); + VerifyOrExit(steeringDataTlv != nullptr); - for (int i = 0; i < steeringData->GetLength(); i++) + for (int i = 0; i < steeringDataTlv->GetLength(); i++) { - if (steeringData->GetValue()[i] != 0) + if (steeringDataTlv->GetValue()[i] != 0) { - ExitNow(rval = true); + ExitNow(isAllowed = true); } } exit: - return rval; + return isAllowed; } void LeaderBase::RemoveCommissioningData(void) { - CommissioningDataTlv *tlv = GetCommissioningData(); + CommissioningDataTlv *tlv = FindCommissioningData(); VerifyOrExit(tlv != nullptr); RemoveTlv(tlv); @@ -507,14 +533,14 @@ void LeaderBase::RemoveCommissioningData(void) Error LeaderBase::SteeringDataCheck(const FilterIndexes &aFilterIndexes) const { - Error error = kErrorNone; - const MeshCoP::Tlv *steeringDataTlv; - MeshCoP::SteeringData steeringData; + Error error = kErrorNone; + const MeshCoP::SteeringDataTlv *steeringDataTlv; + MeshCoP::SteeringData steeringData; - steeringDataTlv = GetCommissioningDataSubTlv(MeshCoP::Tlv::kSteeringData); + steeringDataTlv = FindInCommissioningData(); VerifyOrExit(steeringDataTlv != nullptr, error = kErrorInvalidState); - As(steeringDataTlv)->CopyTo(steeringData); + steeringDataTlv->CopyTo(steeringData); VerifyOrExit(steeringData.Contains(aFilterIndexes), error = kErrorNotFound); diff --git a/src/core/thread/network_data_leader.hpp b/src/core/thread/network_data_leader.hpp index bf25963b0b0..b94cdaf2661 100644 --- a/src/core/thread/network_data_leader.hpp +++ b/src/core/thread/network_data_leader.hpp @@ -182,53 +182,77 @@ class LeaderBase : public MutableNetworkData uint16_t aLength); /** - * Returns a pointer to the Commissioning Data. + * Searches for given sub-TLV in Commissioning Data TLV. * - * @returns A pointer to the Commissioning Data or `nullptr` if no Commissioning Data exists. + * @tparam SubTlvType The sub-TLV type to search for. + * + * @returns A pointer to the Commissioning Data Sub-TLV or `nullptr` if no such sub-TLV exists. * */ - CommissioningDataTlv *GetCommissioningData(void) { return AsNonConst(AsConst(this)->GetCommissioningData()); } + template const SubTlvType *FindInCommissioningData(void) const + { + return As(FindCommissioningDataSubTlv(SubTlvType::kType)); + } /** - * Returns a pointer to the Commissioning Data. + * Searches for given sub-TLV in Commissioning Data TLV. + * + * @tparam SubTlvType The sub-TLV type to search for. * - * @returns A pointer to the Commissioning Data or `nullptr` if no Commissioning Data exists. + * @returns A pointer to the Commissioning Data Sub-TLV or `nullptr` if no such sub-TLV exists. * */ - const CommissioningDataTlv *GetCommissioningData(void) const; + template SubTlvType *FindInCommissioningData(void) + { + return As(FindCommissioningDataSubTlv(SubTlvType::kType)); + } /** - * Returns a pointer to the Commissioning Data Sub-TLV. + * Finds and reads the Commissioning Session ID in Commissioning Data TLV. * - * @param[in] aType The TLV type value. + * @param[out] aSessionId A reference to return the read session ID. * - * @returns A pointer to the Commissioning Data Sub-TLV or `nullptr` if no Sub-TLV exists. + * @retval kErrorNone Successfully read the session ID, @p aSessionId is updated. + * @retval kErrorNotFound Did not find Session ID sub-TLV. + * @retval kErrorParse Failed to parse Commissioning Data TLV (invalid format). * */ - MeshCoP::Tlv *GetCommissioningDataSubTlv(MeshCoP::Tlv::Type aType) - { - return AsNonConst(AsConst(this)->GetCommissioningDataSubTlv(aType)); - } + Error FindCommissioningSessionId(uint16_t &aSessionId) const; /** - * Returns a pointer to the Commissioning Data Sub-TLV. + * Finds and reads the Border Agent RLOC16 in Commissioning Data TLV. * - * @param[in] aType The TLV type value. + * @param[out] aRloc16 A reference to return the read RLOC16. * - * @returns A pointer to the Commissioning Data Sub-TLV or `nullptr` if no Sub-TLV exists. + * @retval kErrorNone Successfully read the Border Agent RLOC16, @p aRloc16 is updated. + * @retval kErrorNotFound Did not find Border Agent RLOC16 sub-TLV. + * @retval kErrorParse Failed to parse Commissioning Data TLV (invalid format). * */ - const MeshCoP::Tlv *GetCommissioningDataSubTlv(MeshCoP::Tlv::Type aType) const; + Error FindBorderAgentRloc(uint16_t &aRloc16) const; /** - * Indicates whether or not the Commissioning Data TLV indicates Joining is enabled. + * Finds and reads the Joiner UDP Port in Commissioning Data TLV. * - * Joining is enabled if a Border Agent Locator TLV exist and the Steering Data TLV is non-zero. + * @param[out] aPort A reference to return the read port number. * - * @returns TRUE if the Commissioning Data TLV says Joining is enabled, FALSE otherwise. + * @retval kErrorNone Successfully read the Joiner UDP port, @p aPort is updated. + * @retval kErrorNotFound Did not find Joiner UDP Port sub-TLV. + * @retval kErrorParse Failed to parse Commissioning Data TLV (invalid format). * */ - bool IsJoiningEnabled(void) const; + Error FindJoinerUdpPort(uint16_t &aPort) const; + + /** + * Indicates whether or not the Commissioning Data TLV indicates Joining is allowed. + * + * Joining is allowed if a Border Agent Locator TLV exist and the Steering Data TLV is non-zero. + * + * @retval TRUE If joining is allowed. + * @retval FALSE If joining is not allowed. + * + */ + bool IsJoiningAllowed(void) const; /** * Adds Commissioning Data to the Thread Network Data. @@ -298,7 +322,9 @@ class LeaderBase : public MutableNetworkData Error GetPreferredNat64Prefix(ExternalRouteConfig &aConfig) const; protected: - void SignalNetDataChanged(void); + void SignalNetDataChanged(void); + const CommissioningDataTlv *FindCommissioningData(void) const; + CommissioningDataTlv *FindCommissioningData(void) { return AsNonConst(AsConst(this)->FindCommissioningData()); } uint8_t mStableVersion; uint8_t mVersion; @@ -320,6 +346,12 @@ class LeaderBase : public MutableNetworkData Error DefaultRouteLookup(const PrefixTlv &aPrefix, uint16_t &aRloc16) const; Error SteeringDataCheck(const FilterIndexes &aFilterIndexes) const; void GetContextForMeshLocalPrefix(Lowpan::Context &aContext) const; + Error ReadCommissioningDataUint16SubTlv(MeshCoP::Tlv::Type aType, uint16_t &aValue) const; + const MeshCoP::Tlv *FindCommissioningDataSubTlv(uint8_t aType) const; + MeshCoP::Tlv *FindCommissioningDataSubTlv(uint8_t aType) + { + return AsNonConst(AsConst(this)->FindCommissioningDataSubTlv(aType)); + } uint8_t mTlvBuffer[kMaxSize]; uint8_t mMaxLength; diff --git a/src/core/thread/network_data_leader_ftd.cpp b/src/core/thread/network_data_leader_ftd.cpp index c3f219a9cd7..d877d205069 100644 --- a/src/core/thread/network_data_leader_ftd.cpp +++ b/src/core/thread/network_data_leader_ftd.cpp @@ -248,7 +248,7 @@ template <> void Leader::HandleTmf(Coap::Message &aMessage, VerifyOrExit(hasValidTlv); // Find Commissioning Data TLV - commDataTlv = GetCommissioningData(); + commDataTlv = FindCommissioningData(); if (commDataTlv != nullptr) { @@ -312,7 +312,7 @@ void Leader::SendCommissioningGetResponse(const Coap::Message &aRequest, message = Get().NewPriorityResponseMessage(aRequest); VerifyOrExit(message != nullptr, error = kErrorNoBufs); - commDataTlv = GetCommissioningData(); + commDataTlv = FindCommissioningData(); if (commDataTlv != nullptr) {