mirror of
https://github.com/espressif/openthread.git
synced 2026-07-29 23:27:46 +00:00
[border-agent] inline ForwardContext::ToHeader() (#12118)
Remove the `CoapDtlsSession::ForwardContext::ToHeader()` helper method and move its logic directly into the `HandleCoapResponse()` method. This simplifies the implementation by removing an unnecessary function call for a single-use case. Additionally, convert `ForwardContext` from a `class` to a `struct`. This change makes the constructor public, removing the need for a `friend` declaration for `Heap::Allocatable`, and better reflects its role as a simple data structure.
This commit is contained in:
@@ -1106,7 +1106,9 @@ void Manager::CoapDtlsSession::HandleLeaderResponseToFwdTmf(const ForwardContext
|
||||
}
|
||||
}
|
||||
|
||||
SuccessOrExit(error = aForwardContext.ToHeader(*forwardMessage, aResponse->GetCode()));
|
||||
forwardMessage->Init(Coap::kTypeNonConfirmable, static_cast<Coap::Code>(aResponse->GetCode()));
|
||||
|
||||
SuccessOrExit(error = forwardMessage->SetToken(aForwardContext.mToken, aForwardContext.mTokenLength));
|
||||
|
||||
if (aResponse->GetLength() > aResponse->GetOffset())
|
||||
{
|
||||
@@ -1357,13 +1359,6 @@ Manager::CoapDtlsSession::ForwardContext::ForwardContext(CoapDtlsSession &aS
|
||||
memcpy(mToken, aMessage.GetToken(), mTokenLength);
|
||||
}
|
||||
|
||||
Error Manager::CoapDtlsSession::ForwardContext::ToHeader(Coap::Message &aMessage, uint8_t aCode) const
|
||||
{
|
||||
aMessage.Init(Coap::kTypeNonConfirmable, static_cast<Coap::Code>(aCode));
|
||||
|
||||
return aMessage.SetToken(mToken, mTokenLength);
|
||||
}
|
||||
|
||||
} // namespace BorderAgent
|
||||
} // namespace MeshCoP
|
||||
} // namespace ot
|
||||
|
||||
@@ -262,23 +262,17 @@ private:
|
||||
uint64_t GetAllocationTime(void) const { return mAllocationTime; }
|
||||
|
||||
private:
|
||||
class ForwardContext : public ot::LinkedListEntry<ForwardContext>,
|
||||
public Heap::Allocatable<ForwardContext>,
|
||||
private ot::NonCopyable
|
||||
struct ForwardContext : public ot::LinkedListEntry<ForwardContext>,
|
||||
public Heap::Allocatable<ForwardContext>,
|
||||
private ot::NonCopyable
|
||||
{
|
||||
friend class Heap::Allocatable<ForwardContext>;
|
||||
|
||||
public:
|
||||
Error ToHeader(Coap::Message &aMessage, uint8_t aCode) const;
|
||||
ForwardContext(CoapDtlsSession &aSession, const Coap::Message &aMessage, Uri aUri);
|
||||
|
||||
CoapDtlsSession &mSession;
|
||||
ForwardContext *mNext;
|
||||
Uri mUri;
|
||||
uint8_t mTokenLength;
|
||||
uint8_t mToken[Coap::Message::kMaxTokenLength];
|
||||
|
||||
private:
|
||||
ForwardContext(CoapDtlsSession &aSession, const Coap::Message &aMessage, Uri aUri);
|
||||
};
|
||||
|
||||
CoapDtlsSession(Instance &aInstance, Dtls::Transport &aDtlsTransport);
|
||||
|
||||
Reference in New Issue
Block a user