[secure-transport] support multiple sessions on the same transport (#11092)

This commit updates `SecureTransport` to support multiple
`SecureSession`s on the same transport. The transport tracks a list
of sessions that it owns and manages. Two new callbacks are
introduced:

- `AcceptCallback`: Used to accept a new connection request, providing
  the `SecureSession` instance to use (passing ownership of the
  session to the transport).
- `RemoveSessionCallback`: Signals that a session is removed,
  releasing ownership of the session.

`BorderAgent`, `Tmf::SecureAgent`, and `ApplicationCoapSecure` are
updated to adopt the new model.

This commit also updates the Nexus `test_dtls`, adding
`TestDtlsMultiSession` to validate multiple session support
behavior.
This commit is contained in:
Abtin Keshavarzian
2025-01-08 13:43:05 -08:00
committed by GitHub
parent 70d315af23
commit 2ae1ce5293
11 changed files with 672 additions and 129 deletions
+14
View File
@@ -276,11 +276,25 @@ SecureAgent::SecureAgent(Instance &aInstance)
: Coap::Dtls::Transport(aInstance, kNoLinkSecurity)
, Coap::SecureSession(aInstance, static_cast<Coap::Dtls::Transport &>(*this))
{
SetAcceptCallback(&HandleDtlsAccept, this);
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE
SetResourceHandler(&HandleResource);
#endif
}
MeshCoP::SecureSession *SecureAgent::HandleDtlsAccept(void *aContext, const Ip6::MessageInfo &aMessageInfo)
{
OT_UNUSED_VARIABLE(aMessageInfo);
return static_cast<SecureAgent *>(aContext)->HandleDtlsAccept();
}
Coap::SecureSession *SecureAgent::HandleDtlsAccept(void)
{
return IsSessionInUse() ? nullptr : static_cast<Coap::SecureSession *>(this);
}
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE
bool SecureAgent::HandleResource(CoapBase &aCoapBase,