mirror of
https://github.com/espressif/openthread.git
synced 2026-08-19 08:59:52 +00:00
[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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user