Skip to content

Commit dda34fa

Browse files
mkardous-silabsyunhanw-google
authored andcommitted
[ICD] Add ClientType support to the ICDManager and ICD Management cluster (project-chip#33811)
* update icdm xml * generated files * Add clientType to the ICDMonitoring table * Add client type buisness logic to ICDM cluster * Add client type logic to the ICDManager * finish clean up * make ClientType arg mandatory * regen --------- Co-authored-by: yunhanw <yunhanw@google.com>
1 parent c15984e commit dda34fa

File tree

64 files changed

+478
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+478
-59
lines changed

examples/chip-tool/commands/clusters/ClusterCommand.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "DataModelLogger.h"
2222
#include "ModelCommand.h"
2323
#include <app/tests/suites/commands/interaction_model/InteractionModel.h>
24+
#include <lib/core/ClusterEnums.h>
2425

2526
class ClusterCommand : public InteractionModelCommands, public ModelCommand, public chip::app::CommandSender::Callback
2627
{
@@ -70,6 +71,7 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
7071
ReturnErrorOnFailure(InteractionModelCommands::SendCommand(device, endpointId, clusterId, commandId, value));
7172
mScopedNodeId = chip::ScopedNodeId(value.checkInNodeID, device->GetSecureSession().Value()->GetFabricIndex());
7273
mMonitoredSubject = value.monitoredSubject;
74+
mClientType = value.clientType;
7375
memcpy(mICDSymmetricKey, value.key.data(), value.key.size());
7476
return CHIP_NO_ERROR;
7577
}
@@ -148,6 +150,7 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
148150
clientInfo.peer_node = mScopedNodeId;
149151
clientInfo.monitored_subject = mMonitoredSubject;
150152
clientInfo.start_icd_counter = value.ICDCounter;
153+
clientInfo.client_type = mClientType;
151154

152155
StoreICDEntryWithKey(clientInfo, chip::ByteSpan(mICDSymmetricKey));
153156
}
@@ -258,8 +261,10 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
258261
chip::ClusterId mClusterId;
259262
chip::CommandId mCommandId;
260263
chip::ScopedNodeId mScopedNodeId;
261-
uint64_t mMonitoredSubject = static_cast<uint64_t>(0);
264+
uint64_t mMonitoredSubject = static_cast<uint64_t>(0);
265+
chip::app::Clusters::IcdManagement::ClientTypeEnum mClientType = chip::app::Clusters::IcdManagement::ClientTypeEnum::kPermanent;
262266
uint8_t mICDSymmetricKey[chip::Crypto::kAES_CCM128_Key_Length];
267+
263268
CHIP_ERROR mError = CHIP_NO_ERROR;
264269
CustomArgument mPayload;
265270
};

examples/chip-tool/commands/icd/ICDCommand.cpp

+13-11
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <app/icd/client/DefaultICDClientStorage.h>
2222
#include <crypto/DefaultSessionKeystore.h>
2323
#include <crypto/RawKeySessionKeystore.h>
24+
#include <string>
2425

2526
using namespace ::chip;
2627
using namespace ::chip::app;
@@ -36,31 +37,32 @@ CHIP_ERROR ICDListCommand::RunCommand()
3637
return CHIP_ERROR_NO_MEMORY;
3738
}
3839
app::DefaultICDClientStorage::ICDClientInfoIteratorWrapper clientInfoIteratorWrapper(iter);
39-
fprintf(stderr, " +-----------------------------------------------------------------------------+\n");
40-
fprintf(stderr, " | %-75s |\n", "Known ICDs:");
41-
fprintf(stderr, " +-----------------------------------------------------------------------------+\n");
42-
fprintf(stderr, " | %20s | %15s | %15s | %16s |\n", "Fabric Index:Node ID", "Start Counter", "Counter Offset",
43-
"MonitoredSubject");
40+
fprintf(stderr, " +------------------------------------------------------------------------------------------+\n");
41+
fprintf(stderr, " | %-88s |\n", "Known ICDs:");
42+
fprintf(stderr, " +------------------------------------------------------------------------------------------+\n");
43+
fprintf(stderr, " | %20s | %15s | %15s | %16s | %10s |\n", "Fabric Index:Node ID", "Start Counter", "Counter Offset",
44+
"MonitoredSubject", "ClientType");
4445

4546
while (iter->Next(info))
4647
{
47-
fprintf(stderr, " +-----------------------------------------------------------------------------+\n");
48-
fprintf(stderr, " | %3" PRIu32 ":" ChipLogFormatX64 " | %15" PRIu32 " | %15" PRIu32 " | " ChipLogFormatX64 " |\n",
48+
fprintf(stderr, " +------------------------------------------------------------------------------------------+\n");
49+
fprintf(stderr, " | %3" PRIu32 ":" ChipLogFormatX64 " | %15" PRIu32 " | %15" PRIu32 " | " ChipLogFormatX64 " | %10u |\n",
4950
static_cast<uint32_t>(info.peer_node.GetFabricIndex()), ChipLogValueX64(info.peer_node.GetNodeId()),
50-
info.start_icd_counter, info.offset, ChipLogValueX64(info.monitored_subject));
51+
info.start_icd_counter, info.offset, ChipLogValueX64(info.monitored_subject),
52+
static_cast<uint8_t>(info.client_type));
5153

5254
static_assert(std::is_same<decltype(CHIPCommand::sSessionKeystore), Crypto::RawKeySessionKeystore>::value,
5355
"The following BytesToHex can copy/encode the key bytes from sharedKey to hexadecimal format, which only "
5456
"works for RawKeySessionKeystore");
5557
Encoding::BytesToHex(info.aes_key_handle.As<Crypto::Symmetric128BitsKeyByteArray>(), Crypto::kAES_CCM128_Key_Length,
5658
icdAesKeyHex, sizeof(icdAesKeyHex), chip::Encoding::HexFlags::kNullTerminate);
57-
fprintf(stderr, " | aes key: %60s |\n", icdAesKeyHex);
59+
fprintf(stderr, " | aes key: %60s |\n", icdAesKeyHex);
5860
Encoding::BytesToHex(info.hmac_key_handle.As<Crypto::Symmetric128BitsKeyByteArray>(), Crypto::kHMAC_CCM128_Key_Length,
5961
icdHmacKeyHex, sizeof(icdHmacKeyHex), chip::Encoding::HexFlags::kNullTerminate);
60-
fprintf(stderr, " | hmac key: %60s |\n", icdHmacKeyHex);
62+
fprintf(stderr, " | hmac key: %60s |\n", icdHmacKeyHex);
6163
}
6264

63-
fprintf(stderr, " +-----------------------------------------------------------------------------+\n");
65+
fprintf(stderr, " +------------------------------------------------------------------------------------------+\n");
6466
SetCommandExitStatus(CHIP_NO_ERROR);
6567
return CHIP_NO_ERROR;
6668
}

examples/chip-tool/commands/pairing/PairingCommand.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ CommissioningParameters PairingCommand::GetCommissioningParameters()
157157
{
158158
mICDMonitoredSubject.SetValue(mICDCheckInNodeId.Value());
159159
}
160+
if (!mICDClientType.HasValue())
161+
{
162+
mICDClientType.SetValue(app::Clusters::IcdManagement::ClientTypeEnum::kPermanent);
163+
}
160164
// These Optionals must have values now.
161165
// The commissioner will verify these values.
162166
params.SetICDSymmetricKey(mICDSymmetricKey.Value());
@@ -166,6 +170,7 @@ CommissioningParameters PairingCommand::GetCommissioningParameters()
166170
}
167171
params.SetICDCheckInNodeId(mICDCheckInNodeId.Value());
168172
params.SetICDMonitoredSubject(mICDMonitoredSubject.Value());
173+
params.SetICDClientType(mICDClientType.Value());
169174
}
170175

171176
return params;
@@ -459,7 +464,7 @@ void PairingCommand::OnICDRegistrationComplete(ScopedNodeId nodeId, uint32_t icd
459464
sizeof(icdSymmetricKeyHex), chip::Encoding::HexFlags::kNullTerminate);
460465

461466
app::ICDClientInfo clientInfo;
462-
clientInfo.peer_node = nodeId;
467+
clientInfo.peer_node = chip::ScopedNodeId(mICDCheckInNodeId.Value(), nodeId.GetFabricIndex());
463468
clientInfo.monitored_subject = mICDMonitoredSubject.Value();
464469
clientInfo.start_icd_counter = icdCounter;
465470

examples/chip-tool/commands/pairing/PairingCommand.h

+3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class PairingCommand : public CHIPCommand,
7474
"The check-in node id for the ICD, default: node id of the commissioner.");
7575
AddArgument("icd-monitored-subject", 0, UINT64_MAX, &mICDMonitoredSubject,
7676
"The monitored subject of the ICD, default: The node id used for icd-check-in-nodeid.");
77+
AddArgument("icd-client-type", 0, 1, &mICDClientType,
78+
"The ClientType of the client registering, default: Permanent client - 0");
7779
AddArgument("icd-symmetric-key", &mICDSymmetricKey, "The 16 bytes ICD symmetric key, default: randomly generated.");
7880
AddArgument("icd-stay-active-duration", 0, UINT32_MAX, &mICDStayActiveDurationMsec,
7981
"If set, a LIT ICD that is commissioned will be requested to stay active for this many milliseconds");
@@ -245,6 +247,7 @@ class PairingCommand : public CHIPCommand,
245247
chip::Optional<NodeId> mICDCheckInNodeId;
246248
chip::Optional<chip::ByteSpan> mICDSymmetricKey;
247249
chip::Optional<uint64_t> mICDMonitoredSubject;
250+
chip::Optional<chip::app::Clusters::IcdManagement::ClientTypeEnum> mICDClientType;
248251
chip::Optional<uint32_t> mICDStayActiveDurationMsec;
249252
chip::app::DataModel::List<chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type> mTimeZoneList;
250253
TypedComplexArgument<chip::app::DataModel::List<chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type>>

examples/contact-sensor-app/nxp/zap-lit/contact-sensor-app.matter

+7
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,11 @@ cluster BooleanState = 69 {
13151315
cluster IcdManagement = 70 {
13161316
revision 2;
13171317

1318+
enum ClientTypeEnum : enum8 {
1319+
kPermanent = 0;
1320+
kEphemeral = 1;
1321+
}
1322+
13181323
enum OperatingModeEnum : enum8 {
13191324
kSIT = 0;
13201325
kLIT = 1;
@@ -1349,6 +1354,7 @@ cluster IcdManagement = 70 {
13491354
fabric_scoped struct MonitoringRegistrationStruct {
13501355
fabric_sensitive node_id checkInNodeID = 1;
13511356
fabric_sensitive int64u monitoredSubject = 2;
1357+
fabric_sensitive ClientTypeEnum clientType = 4;
13521358
fabric_idx fabricIndex = 254;
13531359
}
13541360

@@ -1373,6 +1379,7 @@ cluster IcdManagement = 70 {
13731379
int64u monitoredSubject = 1;
13741380
octet_string<16> key = 2;
13751381
optional octet_string<16> verificationKey = 3;
1382+
ClientTypeEnum clientType = 4;
13761383
}
13771384

13781385
response struct RegisterClientResponse = 1 {

examples/contact-sensor-app/nxp/zap-sit/contact-sensor-app.matter

+7
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,11 @@ cluster BooleanState = 69 {
13151315
cluster IcdManagement = 70 {
13161316
revision 2;
13171317

1318+
enum ClientTypeEnum : enum8 {
1319+
kPermanent = 0;
1320+
kEphemeral = 1;
1321+
}
1322+
13181323
enum OperatingModeEnum : enum8 {
13191324
kSIT = 0;
13201325
kLIT = 1;
@@ -1349,6 +1354,7 @@ cluster IcdManagement = 70 {
13491354
fabric_scoped struct MonitoringRegistrationStruct {
13501355
fabric_sensitive node_id checkInNodeID = 1;
13511356
fabric_sensitive int64u monitoredSubject = 2;
1357+
fabric_sensitive ClientTypeEnum clientType = 4;
13521358
fabric_idx fabricIndex = 254;
13531359
}
13541360

@@ -1373,6 +1379,7 @@ cluster IcdManagement = 70 {
13731379
int64u monitoredSubject = 1;
13741380
octet_string<16> key = 2;
13751381
optional octet_string<16> verificationKey = 3;
1382+
ClientTypeEnum clientType = 4;
13761383
}
13771384

13781385
response struct RegisterClientResponse = 1 {

examples/fabric-admin/commands/pairing/PairingCommand.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ CommissioningParameters PairingCommand::GetCommissioningParameters()
157157
{
158158
mICDMonitoredSubject.SetValue(mICDCheckInNodeId.Value());
159159
}
160+
if (!mICDClientType.HasValue())
161+
{
162+
mICDClientType.SetValue(app::Clusters::IcdManagement::ClientTypeEnum::kPermanent);
163+
}
160164
// These Optionals must have values now.
161165
// The commissioner will verify these values.
162166
params.SetICDSymmetricKey(mICDSymmetricKey.Value());
@@ -166,6 +170,7 @@ CommissioningParameters PairingCommand::GetCommissioningParameters()
166170
}
167171
params.SetICDCheckInNodeId(mICDCheckInNodeId.Value());
168172
params.SetICDMonitoredSubject(mICDMonitoredSubject.Value());
173+
params.SetICDClientType(mICDClientType.Value());
169174
}
170175

171176
return params;
@@ -459,7 +464,7 @@ void PairingCommand::OnICDRegistrationComplete(ScopedNodeId nodeId, uint32_t icd
459464
sizeof(icdSymmetricKeyHex), chip::Encoding::HexFlags::kNullTerminate);
460465

461466
app::ICDClientInfo clientInfo;
462-
clientInfo.peer_node = nodeId;
467+
clientInfo.peer_node = chip::ScopedNodeId(mICDCheckInNodeId.Value(), nodeId.GetFabricIndex());
463468
clientInfo.monitored_subject = mICDMonitoredSubject.Value();
464469
clientInfo.start_icd_counter = icdCounter;
465470

examples/fabric-admin/commands/pairing/PairingCommand.h

+3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ class PairingCommand : public CHIPCommand,
8484
"The check-in node id for the ICD, default: node id of the commissioner.");
8585
AddArgument("icd-monitored-subject", 0, UINT64_MAX, &mICDMonitoredSubject,
8686
"The monitored subject of the ICD, default: The node id used for icd-check-in-nodeid.");
87+
AddArgument("icd-client-type", 0, 1, &mICDClientType,
88+
"The ClientType of the client registering, default: Permanent client - 0");
8789
AddArgument("icd-symmetric-key", &mICDSymmetricKey, "The 16 bytes ICD symmetric key, default: randomly generated.");
8890
AddArgument("icd-stay-active-duration", 0, UINT32_MAX, &mICDStayActiveDurationMsec,
8991
"If set, a LIT ICD that is commissioned will be requested to stay active for this many milliseconds");
@@ -258,6 +260,7 @@ class PairingCommand : public CHIPCommand,
258260
chip::Optional<char *> mCountryCode;
259261
chip::Optional<bool> mICDRegistration;
260262
chip::Optional<NodeId> mICDCheckInNodeId;
263+
chip::Optional<chip::app::Clusters::IcdManagement::ClientTypeEnum> mICDClientType;
261264
chip::Optional<chip::ByteSpan> mICDSymmetricKey;
262265
chip::Optional<uint64_t> mICDMonitoredSubject;
263266
chip::Optional<uint32_t> mICDStayActiveDurationMsec;

examples/light-switch-app/light-switch-common/light-switch-app.matter

+7
Original file line numberDiff line numberDiff line change
@@ -1939,6 +1939,11 @@ cluster UserLabel = 65 {
19391939
cluster IcdManagement = 70 {
19401940
revision 2;
19411941

1942+
enum ClientTypeEnum : enum8 {
1943+
kPermanent = 0;
1944+
kEphemeral = 1;
1945+
}
1946+
19421947
enum OperatingModeEnum : enum8 {
19431948
kSIT = 0;
19441949
kLIT = 1;
@@ -1973,6 +1978,7 @@ cluster IcdManagement = 70 {
19731978
fabric_scoped struct MonitoringRegistrationStruct {
19741979
fabric_sensitive node_id checkInNodeID = 1;
19751980
fabric_sensitive int64u monitoredSubject = 2;
1981+
fabric_sensitive ClientTypeEnum clientType = 4;
19761982
fabric_idx fabricIndex = 254;
19771983
}
19781984

@@ -1997,6 +2003,7 @@ cluster IcdManagement = 70 {
19972003
int64u monitoredSubject = 1;
19982004
octet_string<16> key = 2;
19992005
optional octet_string<16> verificationKey = 3;
2006+
ClientTypeEnum clientType = 4;
20002007
}
20012008

20022009
response struct RegisterClientResponse = 1 {

examples/light-switch-app/qpg/zap/switch.matter

+7
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,11 @@ cluster UserLabel = 65 {
17361736
cluster IcdManagement = 70 {
17371737
revision 2;
17381738

1739+
enum ClientTypeEnum : enum8 {
1740+
kPermanent = 0;
1741+
kEphemeral = 1;
1742+
}
1743+
17391744
enum OperatingModeEnum : enum8 {
17401745
kSIT = 0;
17411746
kLIT = 1;
@@ -1770,6 +1775,7 @@ cluster IcdManagement = 70 {
17701775
fabric_scoped struct MonitoringRegistrationStruct {
17711776
fabric_sensitive node_id checkInNodeID = 1;
17721777
fabric_sensitive int64u monitoredSubject = 2;
1778+
fabric_sensitive ClientTypeEnum clientType = 4;
17731779
fabric_idx fabricIndex = 254;
17741780
}
17751781

@@ -1794,6 +1800,7 @@ cluster IcdManagement = 70 {
17941800
int64u monitoredSubject = 1;
17951801
octet_string<16> key = 2;
17961802
optional octet_string<16> verificationKey = 3;
1803+
ClientTypeEnum clientType = 4;
17971804
}
17981805

17991806
response struct RegisterClientResponse = 1 {

examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter

+7
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,11 @@ cluster BooleanState = 69 {
14131413
cluster IcdManagement = 70 {
14141414
revision 2;
14151415

1416+
enum ClientTypeEnum : enum8 {
1417+
kPermanent = 0;
1418+
kEphemeral = 1;
1419+
}
1420+
14161421
enum OperatingModeEnum : enum8 {
14171422
kSIT = 0;
14181423
kLIT = 1;
@@ -1447,6 +1452,7 @@ cluster IcdManagement = 70 {
14471452
fabric_scoped struct MonitoringRegistrationStruct {
14481453
fabric_sensitive node_id checkInNodeID = 1;
14491454
fabric_sensitive int64u monitoredSubject = 2;
1455+
fabric_sensitive ClientTypeEnum clientType = 4;
14501456
fabric_idx fabricIndex = 254;
14511457
}
14521458

@@ -1471,6 +1477,7 @@ cluster IcdManagement = 70 {
14711477
int64u monitoredSubject = 1;
14721478
octet_string<16> key = 2;
14731479
optional octet_string<16> verificationKey = 3;
1480+
ClientTypeEnum clientType = 4;
14741481
}
14751482

14761483
response struct RegisterClientResponse = 1 {

examples/lock-app/lock-common/lock-app.matter

+7
Original file line numberDiff line numberDiff line change
@@ -1756,6 +1756,11 @@ cluster UserLabel = 65 {
17561756
cluster IcdManagement = 70 {
17571757
revision 2;
17581758

1759+
enum ClientTypeEnum : enum8 {
1760+
kPermanent = 0;
1761+
kEphemeral = 1;
1762+
}
1763+
17591764
enum OperatingModeEnum : enum8 {
17601765
kSIT = 0;
17611766
kLIT = 1;
@@ -1790,6 +1795,7 @@ cluster IcdManagement = 70 {
17901795
fabric_scoped struct MonitoringRegistrationStruct {
17911796
fabric_sensitive node_id checkInNodeID = 1;
17921797
fabric_sensitive int64u monitoredSubject = 2;
1798+
fabric_sensitive ClientTypeEnum clientType = 4;
17931799
fabric_idx fabricIndex = 254;
17941800
}
17951801

@@ -1814,6 +1820,7 @@ cluster IcdManagement = 70 {
18141820
int64u monitoredSubject = 1;
18151821
octet_string<16> key = 2;
18161822
optional octet_string<16> verificationKey = 3;
1823+
ClientTypeEnum clientType = 4;
18171824
}
18181825

18191826
response struct RegisterClientResponse = 1 {

examples/lock-app/qpg/zap/lock.matter

+7
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,11 @@ cluster UserLabel = 65 {
14121412
cluster IcdManagement = 70 {
14131413
revision 2;
14141414

1415+
enum ClientTypeEnum : enum8 {
1416+
kPermanent = 0;
1417+
kEphemeral = 1;
1418+
}
1419+
14151420
enum OperatingModeEnum : enum8 {
14161421
kSIT = 0;
14171422
kLIT = 1;
@@ -1446,6 +1451,7 @@ cluster IcdManagement = 70 {
14461451
fabric_scoped struct MonitoringRegistrationStruct {
14471452
fabric_sensitive node_id checkInNodeID = 1;
14481453
fabric_sensitive int64u monitoredSubject = 2;
1454+
fabric_sensitive ClientTypeEnum clientType = 4;
14491455
fabric_idx fabricIndex = 254;
14501456
}
14511457

@@ -1470,6 +1476,7 @@ cluster IcdManagement = 70 {
14701476
int64u monitoredSubject = 1;
14711477
octet_string<16> key = 2;
14721478
optional octet_string<16> verificationKey = 3;
1479+
ClientTypeEnum clientType = 4;
14731480
}
14741481

14751482
response struct RegisterClientResponse = 1 {

0 commit comments

Comments
 (0)