Skip to content

Commit f62d3bf

Browse files
authored
Post SecureSessionEstablished event when secure session is established (#34051)
* Post SecureSessionEstablished event when secure session is established * initialized the node id and fabric index of event data for PASE session * add local session id to the event data
1 parent beb2bed commit f62d3bf

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/include/platform/CHIPDeviceEvent.h

+14
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ enum PublicEventTypes
250250
* Signals that BLE is deinitialized.
251251
*/
252252
kBLEDeinitialized,
253+
254+
/**
255+
* Signals that secure session is established.
256+
*/
257+
kSecureSessionEstablished,
253258
};
254259

255260
/**
@@ -533,6 +538,15 @@ struct ChipDeviceEvent final
533538
{
534539
OtaState newState;
535540
} OtaStateChanged;
541+
542+
struct
543+
{
544+
uint64_t PeerNodeId;
545+
uint8_t FabricIndex;
546+
uint8_t SecureSessionType;
547+
uint8_t TransportType;
548+
uint16_t LocalSessionId;
549+
} SecureSessionEstablished;
536550
};
537551

538552
bool IsPublic() const { return DeviceEventType::IsPublic(Type); }

src/protocols/secure_channel/PairingSession.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
#include <lib/core/CHIPConfig.h>
2323
#include <lib/core/TLVTypes.h>
2424
#include <lib/support/SafeInt.h>
25+
#include <lib/support/TypeTraits.h>
26+
#include <platform/CHIPDeviceEvent.h>
27+
#include <platform/PlatformManager.h>
2528
#include <transport/SessionManager.h>
2629

2730
namespace chip {
@@ -78,6 +81,18 @@ void PairingSession::Finish()
7881
if (err == CHIP_NO_ERROR)
7982
{
8083
VerifyOrDie(mSecureSessionHolder);
84+
DeviceLayer::ChipDeviceEvent event;
85+
event.Type = DeviceLayer::DeviceEventType::kSecureSessionEstablished;
86+
event.SecureSessionEstablished.TransportType = to_underlying(address.GetTransportType());
87+
event.SecureSessionEstablished.SecureSessionType =
88+
to_underlying(mSecureSessionHolder->AsSecureSession()->GetSecureSessionType());
89+
event.SecureSessionEstablished.LocalSessionId = mSecureSessionHolder->AsSecureSession()->GetLocalSessionId();
90+
event.SecureSessionEstablished.PeerNodeId = mSecureSessionHolder->GetPeer().GetNodeId();
91+
event.SecureSessionEstablished.FabricIndex = mSecureSessionHolder->GetPeer().GetFabricIndex();
92+
if (DeviceLayer::PlatformMgr().PostEvent(&event) != CHIP_NO_ERROR)
93+
{
94+
ChipLogError(SecureChannel, "Failed to post Secure Session established event");
95+
}
8196
// Make sure to null out mDelegate so we don't send it any other
8297
// notifications.
8398
auto * delegate = mDelegate;

0 commit comments

Comments
 (0)