[border-agent] rename callback to HandleLeaderResponseToFwdTmf (#12119)

The `HandleCoapResponse` callback in `CoapDtlsSession` is renamed to
`HandleLeaderResponseToFwdTmf`.

The new name more clearly indicates that this callback is used to
handle the response from the leader for a forwarded TMF message.
This improves code readability and makes the role of the callback
more explicit.
This commit is contained in:
Abtin Keshavarzian
2025-11-07 10:33:28 -08:00
committed by GitHub
parent 959dcc258a
commit 324f27dd44
2 changed files with 20 additions and 18 deletions
+13 -13
View File
@@ -950,7 +950,7 @@ void Manager::CoapDtlsSession::Cleanup(void)
{
ForwardContext *forwardContext = mForwardContexts.Pop();
IgnoreError(Get<Tmf::Agent>().AbortTransaction(HandleCoapResponse, forwardContext));
IgnoreError(Get<Tmf::Agent>().AbortTransaction(HandleLeaderResponseToFwdTmf, forwardContext));
}
mTimer.Stop();
@@ -1076,13 +1076,13 @@ Error Manager::CoapDtlsSession::ForwardToLeader(const Coap::Message &aMessage
messageInfo.SetSockPortToTmf();
// On success the message ownership is transferred.
SuccessOrExit(error =
Get<Tmf::Agent>().SendMessage(*message, messageInfo, HandleCoapResponse, forwardContext.Get()));
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo, HandleLeaderResponseToFwdTmf,
forwardContext.Get()));
message.Release();
// Release the ownership of `forwardContext` since `SendMessage()`
// will own it. We take back ownership from `HandleCoapResponse()`
// callback.
// will own it. We take back ownership when the callback
// `HandleLeaderResponseToFwdTmf()` is invoked.
mForwardContexts.Push(*forwardContext.Release());
@@ -1099,21 +1099,21 @@ exit:
return error;
}
void Manager::CoapDtlsSession::HandleCoapResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
otError aResult)
void Manager::CoapDtlsSession::HandleLeaderResponseToFwdTmf(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
otError aResult)
{
OT_UNUSED_VARIABLE(aMessageInfo);
OwnedPtr<ForwardContext> forwardContext(static_cast<ForwardContext *>(aContext));
forwardContext->mSession.HandleCoapResponse(*forwardContext.Get(), AsCoapMessagePtr(aMessage), aResult);
forwardContext->mSession.HandleLeaderResponseToFwdTmf(*forwardContext.Get(), AsCoapMessagePtr(aMessage), aResult);
}
void Manager::CoapDtlsSession::HandleCoapResponse(const ForwardContext &aForwardContext,
const Coap::Message *aResponse,
Error aResult)
void Manager::CoapDtlsSession::HandleLeaderResponseToFwdTmf(const ForwardContext &aForwardContext,
const Coap::Message *aResponse,
Error aResult)
{
OwnedPtr<Coap::Message> forwardMessage;
Error error;
+7 -5
View File
@@ -331,11 +331,13 @@ private:
static void HandleConnected(ConnectEvent aEvent, void *aContext);
void HandleConnected(ConnectEvent aEvent);
static void HandleCoapResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
otError aResult);
void HandleCoapResponse(const ForwardContext &aForwardContext, const Coap::Message *aResponse, Error aResult);
static void HandleLeaderResponseToFwdTmf(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
otError aResult);
void HandleLeaderResponseToFwdTmf(const ForwardContext &aForwardContext,
const Coap::Message *aResponse,
Error aResult);
static bool HandleUdpReceive(void *aContext, const otMessage *aMessage, const otMessageInfo *aMessageInfo);
bool HandleUdpReceive(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
static bool HandleResource(CoapBase &aCoapBase,