Skip to content

Commit

Permalink
Post SecureSessionEstablished event when secure session is established (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
wqx6 authored and pull[bot] committed Oct 3, 2024
1 parent 5784fa8 commit 5693777
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/include/platform/CHIPDeviceEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ enum PublicEventTypes
* Signals that BLE is deinitialized.
*/
kBLEDeinitialized,

/**
* Signals that secure session is established.
*/
kSecureSessionEstablished,
};

/**
Expand Down Expand Up @@ -533,6 +538,15 @@ struct ChipDeviceEvent final
{
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); }
Expand Down
15 changes: 15 additions & 0 deletions src/protocols/secure_channel/PairingSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -78,6 +81,18 @@ void PairingSession::Finish()
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;
Expand Down

0 comments on commit 5693777

Please sign in to comment.