Skip to content

Commit a4607d3

Browse files
authored
Remove SetCounter for local counter (project-chip#11590)
1 parent eb03a25 commit a4607d3

File tree

3 files changed

+3
-31
lines changed

3 files changed

+3
-31
lines changed

src/controller/CommissioneeDeviceProxy.cpp

-13
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,6 @@ void CommissioneeDeviceProxy::OnNewConnection(SessionHandle session)
9090
{
9191
mState = ConnectionState::SecureConnected;
9292
mSecureSession.SetValue(session);
93-
94-
// Reset the message counters here because this is the first time we get a handle to the secure session.
95-
// Since CHIPDevices can be serialized/deserialized in the middle of what is conceptually a single PASE session
96-
// we need to restore the session counters along with the session information.
97-
Transport::SecureSession * secureSession = mSessionManager->GetSecureSession(mSecureSession.Value());
98-
VerifyOrReturn(secureSession != nullptr);
99-
MessageCounter & localCounter = secureSession->GetSessionMessageCounter().GetLocalMessageCounter();
100-
if (localCounter.SetCounter(mLocalMessageCounter) != CHIP_NO_ERROR)
101-
{
102-
ChipLogError(Controller, "Unable to restore local counter to %" PRIu32, mLocalMessageCounter);
103-
}
104-
Transport::PeerMessageCounter & peerCounter = secureSession->GetSessionMessageCounter().GetPeerMessageCounter();
105-
peerCounter.SetCounter(mPeerMessageCounter);
10693
}
10794

10895
void CommissioneeDeviceProxy::OnConnectionExpired(SessionHandle session)

src/controller/CommissioneeDeviceProxy.h

-3
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,6 @@ class CommissioneeDeviceProxy : public DeviceProxy, Messaging::ExchangeDelegate
347347

348348
uint8_t mSequenceNumber = 0;
349349

350-
uint32_t mLocalMessageCounter = 0;
351-
uint32_t mPeerMessageCounter = 0;
352-
353350
/**
354351
* @brief
355352
* This function loads the secure session object from the serialized operational

src/transport/MessageCounter.h

+3-15
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@ class MessageCounter
4747

4848
virtual ~MessageCounter() = default;
4949

50-
virtual Type GetType() = 0;
51-
virtual uint32_t Value() = 0; /** Get current value */
52-
virtual CHIP_ERROR Advance() = 0; /** Advance the counter */
53-
virtual CHIP_ERROR SetCounter(uint32_t count) = 0; /** Set the counter to the specified value */
50+
virtual Type GetType() = 0;
51+
virtual uint32_t Value() = 0; /** Get current value */
52+
virtual CHIP_ERROR Advance() = 0; /** Advance the counter */
5453
};
5554

5655
class GlobalUnencryptedMessageCounter : public MessageCounter
@@ -67,11 +66,6 @@ class GlobalUnencryptedMessageCounter : public MessageCounter
6766
++value;
6867
return CHIP_NO_ERROR;
6968
}
70-
CHIP_ERROR SetCounter(uint32_t count) override
71-
{
72-
value = count;
73-
return CHIP_NO_ERROR;
74-
}
7569

7670
private:
7771
uint32_t value;
@@ -86,7 +80,6 @@ class GlobalEncryptedMessageCounter : public MessageCounter
8680
Type GetType() override { return GlobalEncrypted; }
8781
uint32_t Value() override { return persisted.GetValue(); }
8882
CHIP_ERROR Advance() override { return persisted.Advance(); }
89-
CHIP_ERROR SetCounter(uint32_t count) override { return CHIP_ERROR_NOT_IMPLEMENTED; }
9083

9184
private:
9285
#if CONFIG_DEVICE_LAYER
@@ -123,11 +116,6 @@ class LocalSessionMessageCounter : public MessageCounter
123116
++value;
124117
return CHIP_NO_ERROR;
125118
}
126-
CHIP_ERROR SetCounter(uint32_t count) override
127-
{
128-
value = count;
129-
return CHIP_NO_ERROR;
130-
}
131119

132120
private:
133121
uint32_t value;

0 commit comments

Comments
 (0)