[border-agent] use separate DTLS transport and CoAP secure session (#11085)

This commit updates `BorderAgent` to utilize its own DTLS `Transport`
and CoAP `SecureSession`, separating it from the shared
`Tmf::SecureAgent` used by `Commissioner` and `Joiner` modules. This
change enables future support for multiple sessions within
`BorderAgent`.
This commit is contained in:
Abtin Keshavarzian
2024-12-27 16:53:29 -08:00
committed by GitHub
parent 6bb4b7c98d
commit 1024a1fdb9
4 changed files with 119 additions and 96 deletions
+10 -29
View File
@@ -276,9 +276,13 @@ SecureAgent::SecureAgent(Instance &aInstance)
: Coap::Dtls::Transport(aInstance, kNoLinkSecurity)
, Coap::SecureSession(aInstance, static_cast<Coap::Dtls::Transport &>(*this))
{
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE
SetResourceHandler(&HandleResource);
#endif
}
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE
bool SecureAgent::HandleResource(CoapBase &aCoapBase,
const char *aUriPath,
Message &aMessage,
@@ -289,43 +293,20 @@ bool SecureAgent::HandleResource(CoapBase &aCoapBase,
bool SecureAgent::HandleResource(const char *aUriPath, Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
{
OT_UNUSED_VARIABLE(aMessage);
OT_UNUSED_VARIABLE(aMessageInfo);
bool didHandle = true;
bool didHandle = false;
Uri uri = UriFromPath(aUriPath);
#define Case(kUri, Type) \
case kUri: \
Get<Type>().HandleTmf<kUri>(aMessage, aMessageInfo); \
break
switch (uri)
if (uri == kUriJoinerFinalize)
{
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE
Case(kUriJoinerFinalize, MeshCoP::Commissioner);
#endif
#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE
Case(kUriCommissionerPetition, MeshCoP::BorderAgent);
Case(kUriCommissionerKeepAlive, MeshCoP::BorderAgent);
Case(kUriRelayTx, MeshCoP::BorderAgent);
Case(kUriCommissionerGet, MeshCoP::BorderAgent);
Case(kUriActiveGet, MeshCoP::BorderAgent);
Case(kUriPendingGet, MeshCoP::BorderAgent);
Case(kUriProxyTx, MeshCoP::BorderAgent);
#endif
default:
didHandle = false;
break;
Get<MeshCoP::Commissioner>().HandleTmf<kUriJoinerFinalize>(aMessage, aMessageInfo);
didHandle = true;
}
#undef Case
return didHandle;
}
#endif // OPENTHREAD_FTD && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE
#endif // OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE
} // namespace Tmf