Skip to content

Commit

Permalink
Fix Session ID Allocation
Browse files Browse the repository at this point in the history
Secure session ID allocation currently suffers the following problems:

* fragmentation has worst case behavior where there may be as few as
  2 outsanding sessions, but the allocator will become full
* there is no formal coupling to the session manager object, but
  yet there can only be one allocator per session manager; the
  current solution is for the allocator to share static state
* IDs are proposed *to* the session manager, which means the session
  manager can only prevent collisions by failing on session creation
  or by evicting sessions; it currently does the latter
* session ID allocation is manual, so leaks are likely

This commit solves these problems by moving ID allocation into the
session manager and by leveraging the session table itself as the
source of truth for available IDs.  Whereas the old flow was:

* allocate session ID
* initiate PASE or CASE
* (on success) allocate sesion table entry

The new flow is:

* allocate session table entry with non-colliding ID
* initiate PASE or CASE
* activate the session in the table

Allocation uses a next-session-ID clue, which is 1 more than the most
recent allocation, and also searches the session table to make sure
a non-colliding value is returned.  Allocation time complexity is
O(kMaxSessionCount^2/64) in the current implementation.

Lifecycle of the pending session table entries also leverages the
SessionHolder object to alleviate our need to manually free resources.

Fixes: project-chip#7835, project-chip#12821

Testing:

* Added an allocation test to TestSessionManager
* All other code paths are heavily integrated into existing tests
* All existing unit tests pass
  • Loading branch information
msandstedt committed Mar 31, 2022
1 parent bbbf7ce commit afeafab
Show file tree
Hide file tree
Showing 40 changed files with 490 additions and 659 deletions.
10 changes: 4 additions & 6 deletions src/app/CASEClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ CHIP_ERROR CASEClient::EstablishSession(PeerId peer, const Transport::PeerAddres
Optional<SessionHandle> session = mInitParams.sessionManager->CreateUnauthenticatedSession(peerAddress, mrpConfig);
VerifyOrReturnError(session.HasValue(), CHIP_ERROR_NO_MEMORY);

uint16_t keyID = 0;
ReturnErrorOnFailure(mInitParams.idAllocator->Allocate(keyID));
SessionHolder secureSessionHolder = mInitParams.sessionManager->AllocateSession();
VerifyOrReturnError(secureSessionHolder, CHIP_ERROR_NO_MEMORY);

// Allocate the exchange immediately before calling CASESession::EstablishSession.
//
Expand All @@ -47,8 +47,8 @@ CHIP_ERROR CASEClient::EstablishSession(PeerId peer, const Transport::PeerAddres
Messaging::ExchangeContext * exchange = mInitParams.exchangeMgr->NewContext(session.Value(), &mCASESession);
VerifyOrReturnError(exchange != nullptr, CHIP_ERROR_INTERNAL);

ReturnErrorOnFailure(mCASESession.EstablishSession(peerAddress, mInitParams.fabricInfo, peer.GetNodeId(), keyID, exchange, this,
mInitParams.mrpLocalConfig));
ReturnErrorOnFailure(mCASESession.EstablishSession(peerAddress, mInitParams.fabricInfo, peer.GetNodeId(), secureSessionHolder,
exchange, this, mInitParams.mrpLocalConfig));
mConnectionSuccessCallback = onConnection;
mConnectionFailureCallback = onFailure;
mConectionContext = context;
Expand All @@ -60,8 +60,6 @@ CHIP_ERROR CASEClient::EstablishSession(PeerId peer, const Transport::PeerAddres

void CASEClient::OnSessionEstablishmentError(CHIP_ERROR error)
{
mInitParams.idAllocator->Free(mCASESession.GetLocalSessionId());

if (mConnectionFailureCallback)
{
mConnectionFailureCallback(mConectionContext, this, error);
Expand Down
2 changes: 0 additions & 2 deletions src/app/CASEClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <messaging/ExchangeMgr.h>
#include <messaging/ReliableMessageProtocolConfig.h>
#include <protocols/secure_channel/CASESession.h>
#include <protocols/secure_channel/SessionIDAllocator.h>

namespace chip {

Expand All @@ -33,7 +32,6 @@ struct CASEClientInitParams
{
SessionManager * sessionManager = nullptr;
Messaging::ExchangeManager * exchangeMgr = nullptr;
SessionIDAllocator * idAllocator = nullptr;
FabricInfo * fabricInfo = nullptr;

Optional<ReliableMessageProtocolConfig> mrpLocalConfig = Optional<ReliableMessageProtocolConfig>::Missing();
Expand Down
4 changes: 2 additions & 2 deletions src/app/OperationalDeviceProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ bool OperationalDeviceProxy::GetAddress(Inet::IPAddress & addr, uint16_t & port)

CHIP_ERROR OperationalDeviceProxy::EstablishConnection()
{
mCASEClient = mInitParams.clientPool->Allocate(CASEClientInitParams{
mInitParams.sessionManager, mInitParams.exchangeMgr, mInitParams.idAllocator, mFabricInfo, mInitParams.mrpLocalConfig });
mCASEClient = mInitParams.clientPool->Allocate(
CASEClientInitParams{ mInitParams.sessionManager, mInitParams.exchangeMgr, mFabricInfo, mInitParams.mrpLocalConfig });
ReturnErrorCodeIf(mCASEClient == nullptr, CHIP_ERROR_NO_MEMORY);
CHIP_ERROR err =
mCASEClient->EstablishSession(mPeerId, mDeviceAddress, mMRPConfig, HandleCASEConnected, HandleCASEConnectionFailure, this);
Expand Down
3 changes: 0 additions & 3 deletions src/app/OperationalDeviceProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include <messaging/ExchangeMgr.h>
#include <messaging/Flags.h>
#include <protocols/secure_channel/CASESession.h>
#include <protocols/secure_channel/SessionIDAllocator.h>
#include <system/SystemLayer.h>
#include <transport/SessionManager.h>
#include <transport/TransportMgr.h>
Expand All @@ -50,7 +49,6 @@ struct DeviceProxyInitParams
{
SessionManager * sessionManager = nullptr;
Messaging::ExchangeManager * exchangeMgr = nullptr;
SessionIDAllocator * idAllocator = nullptr;
FabricTable * fabricTable = nullptr;
CASEClientPoolDelegate * clientPool = nullptr;

Expand All @@ -60,7 +58,6 @@ struct DeviceProxyInitParams
{
ReturnErrorCodeIf(sessionManager == nullptr, CHIP_ERROR_INCORRECT_STATE);
ReturnErrorCodeIf(exchangeMgr == nullptr, CHIP_ERROR_INCORRECT_STATE);
ReturnErrorCodeIf(idAllocator == nullptr, CHIP_ERROR_INCORRECT_STATE);
ReturnErrorCodeIf(fabricTable == nullptr, CHIP_ERROR_INCORRECT_STATE);
ReturnErrorCodeIf(clientPool == nullptr, CHIP_ERROR_INCORRECT_STATE);

Expand Down
15 changes: 8 additions & 7 deletions src/app/server/CommissioningWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ CHIP_ERROR CommissioningWindowManager::AdvertiseAndListenForPASE()
{
VerifyOrReturnError(mCommissioningTimeoutTimerArmed, CHIP_ERROR_INCORRECT_STATE);

uint16_t keyID = 0;
ReturnErrorOnFailure(mIDAllocator->Allocate(keyID));
SessionHolder secureSessionHolder = mServer->GetSecureSessionManager().AllocateSession();
VerifyOrReturnError(secureSessionHolder, CHIP_ERROR_NO_MEMORY);

mPairingSession.Clear();

Expand All @@ -188,9 +188,9 @@ CHIP_ERROR CommissioningWindowManager::AdvertiseAndListenForPASE()
if (mUseECM)
{
ReturnErrorOnFailure(SetTemporaryDiscriminator(mECMDiscriminator));
ReturnErrorOnFailure(
mPairingSession.WaitForPairing(mECMPASEVerifier, mECMIterations, ByteSpan(mECMSalt, mECMSaltLength), keyID,
Optional<ReliableMessageProtocolConfig>::Value(GetLocalMRPConfig()), this));
ReturnErrorOnFailure(mPairingSession.WaitForPairing(
mECMPASEVerifier, mECMIterations, ByteSpan(mECMSalt, mECMSaltLength), secureSessionHolder,
Optional<ReliableMessageProtocolConfig>::Value(GetLocalMRPConfig()), this));
}
else
{
Expand All @@ -211,8 +211,9 @@ CHIP_ERROR CommissioningWindowManager::AdvertiseAndListenForPASE()

ReturnErrorOnFailure(verifier.Deserialize(ByteSpan(serializedVerifier)));

ReturnErrorOnFailure(mPairingSession.WaitForPairing(
verifier, iterationCount, saltSpan, keyID, Optional<ReliableMessageProtocolConfig>::Value(GetLocalMRPConfig()), this));
ReturnErrorOnFailure(mPairingSession.WaitForPairing(verifier, iterationCount, saltSpan, secureSessionHolder,
Optional<ReliableMessageProtocolConfig>::Value(GetLocalMRPConfig()),
this));
}

ReturnErrorOnFailure(StartAdvertisement());
Expand Down
4 changes: 0 additions & 4 deletions src/app/server/CommissioningWindowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <lib/dnssd/Advertiser.h>
#include <platform/CHIPDeviceConfig.h>
#include <protocols/secure_channel/RendezvousParameters.h>
#include <protocols/secure_channel/SessionIDAllocator.h>
#include <system/SystemClock.h>

namespace chip {
Expand Down Expand Up @@ -65,8 +64,6 @@ class CommissioningWindowManager : public SessionEstablishmentDelegate, public a

void SetAppDelegate(AppDelegate * delegate) { mAppDelegate = delegate; }

void SetSessionIDAllocator(SessionIDAllocator * idAllocator) { mIDAllocator = idAllocator; }

/**
* Open the pairing window using default configured parameters.
*/
Expand Down Expand Up @@ -146,7 +143,6 @@ class CommissioningWindowManager : public SessionEstablishmentDelegate, public a

bool mIsBLE = true;

SessionIDAllocator * mIDAllocator = nullptr;
PASESession mPairingSession;

uint8_t mFailedCommissioningAttempts = 0;
Expand Down
2 changes: 0 additions & 2 deletions src/app/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ Server::Server() :
.sessionInitParams = {
.sessionManager = &mSessions,
.exchangeMgr = &mExchangeMgr,
.idAllocator = &mSessionIDAllocator,
.fabricTable = &mFabrics,
.clientPool = &mCASEClientPool,
},
Expand All @@ -126,7 +125,6 @@ CHIP_ERROR Server::Init(AppDelegate * delegate, uint16_t secureServicePort, uint

SuccessOrExit(err = mCommissioningWindowManager.Init(this));
mCommissioningWindowManager.SetAppDelegate(delegate);
mCommissioningWindowManager.SetSessionIDAllocator(&mSessionIDAllocator);

// Set up attribute persistence before we try to bring up the data model
// handler.
Expand Down
4 changes: 0 additions & 4 deletions src/app/server/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ class Server

Messaging::ExchangeManager & GetExchangeManager() { return mExchangeMgr; }

SessionIDAllocator & GetSessionIDAllocator() { return mSessionIDAllocator; }

SessionManager & GetSecureSessionManager() { return mSessions; }

TransportMgrBase & GetTransportManager() { return mTransports; }
Expand Down Expand Up @@ -247,12 +245,10 @@ class Server

Messaging::ExchangeManager mExchangeMgr;
FabricTable mFabrics;
SessionIDAllocator mSessionIDAllocator;
secure_channel::MessageCounterManager mMessageCounterManager;
#if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT
chip::Protocols::UserDirectedCommissioning::UserDirectedCommissioningClient gUDCClient;
#endif // CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT
SecurePairingUsingTestSecret mTestPairing;
CommissioningWindowManager mCommissioningWindowManager;

// Both PersistentStorageDelegate, and GroupDataProvider should be injected by the applications
Expand Down
3 changes: 0 additions & 3 deletions src/app/tests/TestOperationalDeviceProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <lib/support/UnitTestRegistration.h>
#include <nlunit-test.h>
#include <protocols/secure_channel/MessageCounterManager.h>
#include <protocols/secure_channel/SessionIDAllocator.h>
#include <system/SystemLayerImpl.h>
#include <transport/SessionManager.h>
#include <transport/TransportMgr.h>
Expand Down Expand Up @@ -52,7 +51,6 @@ void TestOperationalDeviceProxy_EstablishSessionDirectly(nlTestSuite * inSuite,
FabricInfo * fabric = fabrics->FindFabricWithIndex(1);
secure_channel::MessageCounterManager messageCounterManager;
chip::TestPersistentStorageDelegate deviceStorage;
SessionIDAllocator idAllocator;

systemLayer.Init();
udpEndPointManager.Init(systemLayer);
Expand All @@ -64,7 +62,6 @@ void TestOperationalDeviceProxy_EstablishSessionDirectly(nlTestSuite * inSuite,
DeviceProxyInitParams params = {
.sessionManager = &sessionManager,
.exchangeMgr = &exchangeMgr,
.idAllocator = &idAllocator,
.fabricInfo = fabric,
};
NodeId mockNodeId = 1;
Expand Down
1 change: 1 addition & 0 deletions src/app/tests/integration/chip_im_initiator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ CHIP_ERROR EstablishSecureSession()

chip::SecurePairingUsingTestSecret * testSecurePairingSecret = chip::Platform::New<chip::SecurePairingUsingTestSecret>();
VerifyOrExit(testSecurePairingSecret != nullptr, err = CHIP_ERROR_NO_MEMORY);
testSecurePairingSecret->Init(gSessionManager);

// Attempt to connect to the peer.
err = gSessionManager.NewPairing(gSession,
Expand Down
1 change: 1 addition & 0 deletions src/app/tests/integration/chip_im_responder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ int main(int argc, char * argv[])

InitializeEventLogging(&gExchangeManager);

gTestPairing.Init(gSessionManager);
err = gSessionManager.NewPairing(gSession, peer, chip::kTestControllerNodeId, &gTestPairing,
chip::CryptoContext::SessionRole::kResponder, gFabricIndex);
SuccessOrExit(err);
Expand Down
10 changes: 4 additions & 6 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ ControllerDeviceInitParams DeviceController::GetControllerDeviceInitParams()
.exchangeMgr = mSystemState->ExchangeMgr(),
.udpEndPointManager = mSystemState->UDPEndPointManager(),
.storageDelegate = mStorageDelegate,
.idAllocator = mSystemState->SessionIDAlloc(),
.fabricsTable = mSystemState->Fabrics(),
};
}
Expand Down Expand Up @@ -610,8 +609,7 @@ CHIP_ERROR DeviceCommissioner::EstablishPASEConnection(NodeId remoteDeviceId, Re

Messaging::ExchangeContext * exchangeCtxt = nullptr;
Optional<SessionHandle> session;

uint16_t keyID = 0;
SessionHolder secureSessionHolder;

VerifyOrExit(mState == State::Initialized, err = CHIP_ERROR_INCORRECT_STATE);
VerifyOrExit(mDeviceInPASEEstablishment == nullptr, err = CHIP_ERROR_INCORRECT_STATE);
Expand Down Expand Up @@ -677,8 +675,8 @@ CHIP_ERROR DeviceCommissioner::EstablishPASEConnection(NodeId remoteDeviceId, Re
session = mSystemState->SessionMgr()->CreateUnauthenticatedSession(params.GetPeerAddress(), device->GetMRPConfig());
VerifyOrExit(session.HasValue(), err = CHIP_ERROR_NO_MEMORY);

err = mSystemState->SessionIDAlloc()->Allocate(keyID);
SuccessOrExit(err);
secureSessionHolder = mSystemState->SessionMgr()->AllocateSession();
VerifyOrExit(secureSessionHolder, CHIP_ERROR_NO_MEMORY);

// TODO - Remove use of SetActive/IsActive from CommissioneeDeviceProxy
device->SetActive(true);
Expand All @@ -692,7 +690,7 @@ CHIP_ERROR DeviceCommissioner::EstablishPASEConnection(NodeId remoteDeviceId, Re
exchangeCtxt = mSystemState->ExchangeMgr()->NewContext(session.Value(), &device->GetPairing());
VerifyOrExit(exchangeCtxt != nullptr, err = CHIP_ERROR_INTERNAL);

err = device->GetPairing().Pair(params.GetPeerAddress(), params.GetSetupPINCode(), keyID,
err = device->GetPairing().Pair(params.GetPeerAddress(), params.GetSetupPINCode(), secureSessionHolder,
Optional<ReliableMessageProtocolConfig>::Value(GetLocalMRPConfig()), exchangeCtxt, this);
SuccessOrExit(err);

Expand Down
9 changes: 1 addition & 8 deletions src/controller/CHIPDeviceControllerFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,12 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params)
chip::app::DnssdServer::Instance().StartServer();
}

stateParams.sessionIDAllocator = Platform::New<SessionIDAllocator>();
stateParams.operationalDevicePool = Platform::New<DeviceControllerSystemStateParams::OperationalDevicePool>();
stateParams.caseClientPool = Platform::New<DeviceControllerSystemStateParams::CASEClientPool>();

DeviceProxyInitParams deviceInitParams = {
.sessionManager = stateParams.sessionMgr,
.exchangeMgr = stateParams.exchangeMgr,
.idAllocator = stateParams.sessionIDAllocator,
.fabricTable = stateParams.fabricTable,
.clientPool = stateParams.caseClientPool,
.mrpLocalConfig = Optional<ReliableMessageProtocolConfig>::Value(GetLocalMRPConfig()),
Expand Down Expand Up @@ -329,13 +327,8 @@ CHIP_ERROR DeviceControllerSystemState::Shutdown()
mCASESessionManager = nullptr;
}

// mSessionIDAllocator, mCASEClientPool, and mDevicePool must be deallocated
// mCASEClientPool and mDevicePool must be deallocated
// after mCASESessionManager, which uses them.
if (mSessionIDAllocator != nullptr)
{
Platform::Delete(mSessionIDAllocator);
mSessionIDAllocator = nullptr;
}

if (mOperationalDevicePool != nullptr)
{
Expand Down
9 changes: 2 additions & 7 deletions src/controller/CHIPDeviceControllerSystemState.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <lib/core/CHIPConfig.h>
#include <protocols/secure_channel/CASEServer.h>
#include <protocols/secure_channel/MessageCounterManager.h>
#include <protocols/secure_channel/SessionIDAllocator.h>

#include <transport/TransportMgr.h>
#include <transport/raw/UDP.h>
Expand Down Expand Up @@ -87,7 +86,6 @@ struct DeviceControllerSystemStateParams
FabricTable * fabricTable = nullptr;
CASEServer * caseServer = nullptr;
CASESessionManager * caseSessionManager = nullptr;
SessionIDAllocator * sessionIDAllocator = nullptr;
OperationalDevicePool * operationalDevicePool = nullptr;
CASEClientPool * caseClientPool = nullptr;
};
Expand All @@ -107,8 +105,7 @@ class DeviceControllerSystemState
mUDPEndPointManager(params.udpEndPointManager), mTransportMgr(params.transportMgr), mSessionMgr(params.sessionMgr),
mExchangeMgr(params.exchangeMgr), mMessageCounterManager(params.messageCounterManager), mFabrics(params.fabricTable),
mCASEServer(params.caseServer), mCASESessionManager(params.caseSessionManager),
mSessionIDAllocator(params.sessionIDAllocator), mOperationalDevicePool(params.operationalDevicePool),
mCASEClientPool(params.caseClientPool)
mOperationalDevicePool(params.operationalDevicePool), mCASEClientPool(params.caseClientPool)
{
#if CONFIG_NETWORK_LAYER_BLE
mBleLayer = params.bleLayer;
Expand Down Expand Up @@ -141,7 +138,7 @@ class DeviceControllerSystemState
{
return mSystemLayer != nullptr && mUDPEndPointManager != nullptr && mTransportMgr != nullptr && mSessionMgr != nullptr &&
mExchangeMgr != nullptr && mMessageCounterManager != nullptr && mFabrics != nullptr && mCASESessionManager != nullptr &&
mSessionIDAllocator != nullptr && mOperationalDevicePool != nullptr && mCASEClientPool != nullptr;
mOperationalDevicePool != nullptr && mCASEClientPool != nullptr;
};

System::Layer * SystemLayer() { return mSystemLayer; };
Expand All @@ -156,7 +153,6 @@ class DeviceControllerSystemState
Ble::BleLayer * BleLayer() { return mBleLayer; };
#endif
CASESessionManager * CASESessionMgr() const { return mCASESessionManager; }
SessionIDAllocator * SessionIDAlloc() const { return mSessionIDAllocator; }

private:
DeviceControllerSystemState(){};
Expand All @@ -174,7 +170,6 @@ class DeviceControllerSystemState
FabricTable * mFabrics = nullptr;
CASEServer * mCASEServer = nullptr;
CASESessionManager * mCASESessionManager = nullptr;
SessionIDAllocator * mSessionIDAllocator = nullptr;
OperationalDevicePool * mOperationalDevicePool = nullptr;
CASEClientPool * mCASEClientPool = nullptr;

Expand Down
5 changes: 0 additions & 5 deletions src/controller/CommissioneeDeviceProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include <messaging/ExchangeMgr.h>
#include <messaging/Flags.h>
#include <protocols/secure_channel/PASESession.h>
#include <protocols/secure_channel/SessionIDAllocator.h>
#include <transport/SessionHolder.h>
#include <transport/SessionManager.h>
#include <transport/TransportMgr.h>
Expand Down Expand Up @@ -69,7 +68,6 @@ struct ControllerDeviceInitParams
Messaging::ExchangeManager * exchangeMgr = nullptr;
Inet::EndPointManager<Inet::UDPEndPoint> * udpEndPointManager = nullptr;
PersistentStorageDelegate * storageDelegate = nullptr;
SessionIDAllocator * idAllocator = nullptr;
#if CONFIG_NETWORK_LAYER_BLE
Ble::BleLayer * bleLayer = nullptr;
#endif
Expand Down Expand Up @@ -120,7 +118,6 @@ class CommissioneeDeviceProxy : public DeviceProxy, public SessionReleaseDelegat
mExchangeMgr = params.exchangeMgr;
mUDPEndPointManager = params.udpEndPointManager;
mFabricIndex = fabric;
mIDAllocator = params.idAllocator;
#if CONFIG_NETWORK_LAYER_BLE
mBleLayer = params.bleLayer;
#endif
Expand Down Expand Up @@ -287,8 +284,6 @@ class CommissioneeDeviceProxy : public DeviceProxy, public SessionReleaseDelegat
CHIP_ERROR LoadSecureSessionParametersIfNeeded(bool & didLoad);

FabricIndex mFabricIndex = kUndefinedFabricIndex;

SessionIDAllocator * mIDAllocator = nullptr;
};

} // namespace chip
8 changes: 8 additions & 0 deletions src/messaging/tests/MessagingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,21 @@ CHIP_ERROR MessagingContext::ShutdownAndRestoreExisting(MessagingContext & exist

CHIP_ERROR MessagingContext::CreateSessionBobToAlice()
{
if (!mPairingBobToAlice.GetSecureSessionHolder())
{
mPairingBobToAlice.Init(mSessionManager);
}
return mSessionManager.NewPairing(mSessionBobToAlice, Optional<Transport::PeerAddress>::Value(mAliceAddress),
GetAliceFabric()->GetNodeId(), &mPairingBobToAlice, CryptoContext::SessionRole::kInitiator,
mBobFabricIndex);
}

CHIP_ERROR MessagingContext::CreateSessionAliceToBob()
{
if (!mPairingAliceToBob.GetSecureSessionHolder())
{
mPairingAliceToBob.Init(mSessionManager);
}
return mSessionManager.NewPairing(mSessionAliceToBob, Optional<Transport::PeerAddress>::Value(mBobAddress),
GetBobFabric()->GetNodeId(), &mPairingAliceToBob, CryptoContext::SessionRole::kResponder,
mAliceFabricIndex);
Expand Down
Loading

0 comments on commit afeafab

Please sign in to comment.