Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post SecureSessionEstablished event when secure session is established #34051

Merged
merged 4 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 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,14 @@ struct ChipDeviceEvent final
{
OtaState newState;
} OtaStateChanged;

struct
{
uint64_t PeerNodeId;
uint8_t FabricIndex;
uint8_t SecureSessionType;
uint8_t TransportType;
} SecureSessionEstablished;
};

bool IsPublic() const { return DeviceEventType::IsPublic(Type); }
Expand Down
17 changes: 17 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,20 @@ 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());
if (mSecureSessionHolder->AsSecureSession()->GetSecureSessionType() == Transport::SecureSession::Type::kCASE)
{
event.SecureSessionEstablished.PeerNodeId = mSecureSessionHolder->GetPeer().GetNodeId();
event.SecureSessionEstablished.FabricIndex = mSecureSessionHolder->GetPeer().GetFabricIndex();
wqx6 marked this conversation as resolved.
Show resolved Hide resolved
}
wqx6 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading