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
diff --git a/src/include/platform/CHIPDeviceEvent.h b/src/include/platform/CHIPDeviceEvent.h
index 67809ad..437b20e 100644
--- a/src/include/platform/CHIPDeviceEvent.h
+++ b/src/include/platform/CHIPDeviceEvent.h
@@ -250,6 +250,11 @@
* Signals that BLE is deinitialized.
*/
kBLEDeinitialized,
+
+ /**
+ * Signals that secure session is established.
+ */
+ kSecureSessionEstablished,
};
/**
@@ -533,6 +538,15 @@
{
OtaState newState;
} OtaStateChanged;
+
+ struct
+ {
+ uint64_t PeerNodeId;
+ uint8_t FabricIndex;
+ uint8_t SecureSessionType;
+ uint8_t TransportType;
+ uint16_t LocalSessionId;
+ } SecureSessionEstablished;
};
bool IsPublic() const { return DeviceEventType::IsPublic(Type); }
diff --git a/src/protocols/secure_channel/PairingSession.cpp b/src/protocols/secure_channel/PairingSession.cpp
index ae4ca27..6176d09 100644
--- a/src/protocols/secure_channel/PairingSession.cpp
+++ b/src/protocols/secure_channel/PairingSession.cpp
@@ -22,6 +22,9 @@
#include <lib/core/CHIPConfig.h>
#include <lib/core/TLVTypes.h>
#include <lib/support/SafeInt.h>
+#include <lib/support/TypeTraits.h>
+#include <platform/CHIPDeviceEvent.h>
+#include <platform/PlatformManager.h>
#include <transport/SessionManager.h>
namespace chip {
@@ -78,6 +81,18 @@
if (err == CHIP_NO_ERROR)
{
VerifyOrDie(mSecureSessionHolder);
+ DeviceLayer::ChipDeviceEvent event;
+ event.Type = DeviceLayer::DeviceEventType::kSecureSessionEstablished;
+ event.SecureSessionEstablished.TransportType = to_underlying(address.GetTransportType());
+ event.SecureSessionEstablished.SecureSessionType =
+ to_underlying(mSecureSessionHolder->AsSecureSession()->GetSecureSessionType());
+ event.SecureSessionEstablished.LocalSessionId = mSecureSessionHolder->AsSecureSession()->GetLocalSessionId();
+ event.SecureSessionEstablished.PeerNodeId = mSecureSessionHolder->GetPeer().GetNodeId();
+ event.SecureSessionEstablished.FabricIndex = mSecureSessionHolder->GetPeer().GetFabricIndex();
+ if (DeviceLayer::PlatformMgr().PostEvent(&event) != CHIP_NO_ERROR)
+ {
+ ChipLogError(SecureChannel, "Failed to post Secure Session established event");
+ }
// Make sure to null out mDelegate so we don't send it any other
// notifications.
auto * delegate = mDelegate;