Skip to content

Commit

Permalink
Remove SetCounter for local counter (#11590)
Browse files Browse the repository at this point in the history
  • Loading branch information
kghost authored and pull[bot] committed Feb 7, 2022
1 parent 81f2f0f commit 4d29832
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 31 deletions.
13 changes: 0 additions & 13 deletions src/controller/CommissioneeDeviceProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,6 @@ void CommissioneeDeviceProxy::OnNewConnection(SessionHandle session)
{
mState = ConnectionState::SecureConnected;
mSecureSession.SetValue(session);

// Reset the message counters here because this is the first time we get a handle to the secure session.
// Since CHIPDevices can be serialized/deserialized in the middle of what is conceptually a single PASE session
// we need to restore the session counters along with the session information.
Transport::SecureSession * secureSession = mSessionManager->GetSecureSession(mSecureSession.Value());
VerifyOrReturn(secureSession != nullptr);
MessageCounter & localCounter = secureSession->GetSessionMessageCounter().GetLocalMessageCounter();
if (localCounter.SetCounter(mLocalMessageCounter) != CHIP_NO_ERROR)
{
ChipLogError(Controller, "Unable to restore local counter to %" PRIu32, mLocalMessageCounter);
}
Transport::PeerMessageCounter & peerCounter = secureSession->GetSessionMessageCounter().GetPeerMessageCounter();
peerCounter.SetCounter(mPeerMessageCounter);
}

void CommissioneeDeviceProxy::OnConnectionExpired(SessionHandle session)
Expand Down
3 changes: 0 additions & 3 deletions src/controller/CommissioneeDeviceProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,6 @@ class CommissioneeDeviceProxy : public DeviceProxy, Messaging::ExchangeDelegate

uint8_t mSequenceNumber = 0;

uint32_t mLocalMessageCounter = 0;
uint32_t mPeerMessageCounter = 0;

/**
* @brief
* This function loads the secure session object from the serialized operational
Expand Down
18 changes: 3 additions & 15 deletions src/transport/MessageCounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ class MessageCounter

virtual ~MessageCounter() = default;

virtual Type GetType() = 0;
virtual uint32_t Value() = 0; /** Get current value */
virtual CHIP_ERROR Advance() = 0; /** Advance the counter */
virtual CHIP_ERROR SetCounter(uint32_t count) = 0; /** Set the counter to the specified value */
virtual Type GetType() = 0;
virtual uint32_t Value() = 0; /** Get current value */
virtual CHIP_ERROR Advance() = 0; /** Advance the counter */
};

class GlobalUnencryptedMessageCounter : public MessageCounter
Expand All @@ -67,11 +66,6 @@ class GlobalUnencryptedMessageCounter : public MessageCounter
++value;
return CHIP_NO_ERROR;
}
CHIP_ERROR SetCounter(uint32_t count) override
{
value = count;
return CHIP_NO_ERROR;
}

private:
uint32_t value;
Expand All @@ -86,7 +80,6 @@ class GlobalEncryptedMessageCounter : public MessageCounter
Type GetType() override { return GlobalEncrypted; }
uint32_t Value() override { return persisted.GetValue(); }
CHIP_ERROR Advance() override { return persisted.Advance(); }
CHIP_ERROR SetCounter(uint32_t count) override { return CHIP_ERROR_NOT_IMPLEMENTED; }

private:
#if CONFIG_DEVICE_LAYER
Expand Down Expand Up @@ -123,11 +116,6 @@ class LocalSessionMessageCounter : public MessageCounter
++value;
return CHIP_NO_ERROR;
}
CHIP_ERROR SetCounter(uint32_t count) override
{
value = count;
return CHIP_NO_ERROR;
}

private:
uint32_t value;
Expand Down

0 comments on commit 4d29832

Please sign in to comment.