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

Restyle Remove SetCounter for local counter #11591

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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: 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