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

[ICD] Add ClientType support to the ICDManager and ICD Management cluster #33811

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6b6a555
update icdm xml
mkardous-silabs Jun 4, 2024
038a481
generated files
mkardous-silabs Jun 4, 2024
2703369
Add clientType to the ICDMonitoring table
mkardous-silabs Jun 4, 2024
728bd1a
Add client type buisness logic to ICDM cluster
mkardous-silabs Jun 4, 2024
5186a61
Add client type logic to the ICDManager
mkardous-silabs Jun 7, 2024
d9d271e
finish clean up
mkardous-silabs Jun 7, 2024
d1e6653
make ClientType arg mandatory
mkardous-silabs Jun 7, 2024
07f4253
generated files
mkardous-silabs Jun 7, 2024
e3b6066
Modify icdm cluster to make ClientType mandatory
mkardous-silabs Jun 7, 2024
eb2847b
Update ICDM 3.1 cert test
mkardous-silabs Jun 7, 2024
8b5d8b3
Update comissioning registration procedure for client type
mkardous-silabs Jun 10, 2024
40a6439
Added ClientType to ICDClientInfo
mkardous-silabs Jun 10, 2024
5f467da
Update ClusterCommand
mkardous-silabs Jun 10, 2024
6305f3b
restyle
mkardous-silabs Jun 10, 2024
aeae0d0
Use clientType in yaml tests instead of uint equivalent
mkardous-silabs Jun 10, 2024
d4512dc
remove address resolve change that are out of scope
mkardous-silabs Jun 10, 2024
4ee2101
Fix cluster command to store the correct nodeId
mkardous-silabs Jun 10, 2024
78868a4
Add client type to debug print out
mkardous-silabs Jun 10, 2024
4a6084e
Revert ClusterCommand and move fix to the PairingCommand
mkardous-silabs Jun 10, 2024
488088e
Add ClientType validation in ICDM cluster
mkardous-silabs Jun 10, 2024
46c4863
Update ICDM 3.4 test script
mkardous-silabs Jun 10, 2024
2ac0825
address review comments
mkardous-silabs Jun 12, 2024
f086829
Restyled by clang-format
restyled-commits Jun 12, 2024
a36e044
Preliminary support for the Android controller
mkardous-silabs Jun 17, 2024
001b07e
add out of range test
mkardous-silabs Jun 17, 2024
1d0c403
Add short conversion function
mkardous-silabs Jun 18, 2024
a237fbb
Fix jshort typo
mkardous-silabs Jun 18, 2024
1fb7c55
update header
mkardous-silabs Jun 18, 2024
8699c28
fix typo
mkardous-silabs Jun 18, 2024
51eea9b
fix return statement
mkardous-silabs Jun 18, 2024
6b4ff2d
Add missing setter call
mkardous-silabs Jun 18, 2024
857525b
Remove ICDM test
mkardous-silabs Jun 18, 2024
f712b2e
Fix JNI bug in clientType
yunhanw-google Jun 28, 2024
73219c2
regen
yunhanw-google Jun 29, 2024
315cb5a
fix the type for clienttype
yunhanw-google Jun 30, 2024
ea387fc
restyle generated file
yunhanw-google Jun 30, 2024
3053ee2
Zap regen with code formatting for kotlin
andy31415 Jun 30, 2024
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
7 changes: 6 additions & 1 deletion examples/chip-tool/commands/clusters/ClusterCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "DataModelLogger.h"
#include "ModelCommand.h"
#include <app/tests/suites/commands/interaction_model/InteractionModel.h>
#include <lib/core/ClusterEnums.h>

class ClusterCommand : public InteractionModelCommands, public ModelCommand, public chip::app::CommandSender::Callback
{
Expand Down Expand Up @@ -70,6 +71,7 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
ReturnErrorOnFailure(InteractionModelCommands::SendCommand(device, endpointId, clusterId, commandId, value));
mScopedNodeId = chip::ScopedNodeId(value.checkInNodeID, device->GetSecureSession().Value()->GetFabricIndex());
mMonitoredSubject = value.monitoredSubject;
mClientType = value.clientType;
memcpy(mICDSymmetricKey, value.key.data(), value.key.size());
return CHIP_NO_ERROR;
}
Expand Down Expand Up @@ -148,6 +150,7 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
clientInfo.peer_node = mScopedNodeId;
clientInfo.monitored_subject = mMonitoredSubject;
clientInfo.start_icd_counter = value.ICDCounter;
clientInfo.client_type = mClientType;

StoreICDEntryWithKey(clientInfo, chip::ByteSpan(mICDSymmetricKey));
}
Expand Down Expand Up @@ -258,8 +261,10 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
chip::ClusterId mClusterId;
chip::CommandId mCommandId;
chip::ScopedNodeId mScopedNodeId;
uint64_t mMonitoredSubject = static_cast<uint64_t>(0);
uint64_t mMonitoredSubject = static_cast<uint64_t>(0);
chip::app::Clusters::IcdManagement::ClientTypeEnum mClientType = chip::app::Clusters::IcdManagement::ClientTypeEnum::kPermanent;
uint8_t mICDSymmetricKey[chip::Crypto::kAES_CCM128_Key_Length];

CHIP_ERROR mError = CHIP_NO_ERROR;
CustomArgument mPayload;
};
24 changes: 13 additions & 11 deletions examples/chip-tool/commands/icd/ICDCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <app/icd/client/DefaultICDClientStorage.h>
#include <crypto/DefaultSessionKeystore.h>
#include <crypto/RawKeySessionKeystore.h>
#include <string>

using namespace ::chip;
using namespace ::chip::app;
Expand All @@ -36,31 +37,32 @@ CHIP_ERROR ICDListCommand::RunCommand()
return CHIP_ERROR_NO_MEMORY;
}
app::DefaultICDClientStorage::ICDClientInfoIteratorWrapper clientInfoIteratorWrapper(iter);
fprintf(stderr, " +-----------------------------------------------------------------------------+\n");
fprintf(stderr, " | %-75s |\n", "Known ICDs:");
fprintf(stderr, " +-----------------------------------------------------------------------------+\n");
fprintf(stderr, " | %20s | %15s | %15s | %16s |\n", "Fabric Index:Node ID", "Start Counter", "Counter Offset",
"MonitoredSubject");
fprintf(stderr, " +------------------------------------------------------------------------------------------+\n");
fprintf(stderr, " | %-88s |\n", "Known ICDs:");
fprintf(stderr, " +------------------------------------------------------------------------------------------+\n");
fprintf(stderr, " | %20s | %15s | %15s | %16s | %10s |\n", "Fabric Index:Node ID", "Start Counter", "Counter Offset",
"MonitoredSubject", "ClientType");

while (iter->Next(info))
{
fprintf(stderr, " +-----------------------------------------------------------------------------+\n");
fprintf(stderr, " | %3" PRIu32 ":" ChipLogFormatX64 " | %15" PRIu32 " | %15" PRIu32 " | " ChipLogFormatX64 " |\n",
fprintf(stderr, " +------------------------------------------------------------------------------------------+\n");
fprintf(stderr, " | %3" PRIu32 ":" ChipLogFormatX64 " | %15" PRIu32 " | %15" PRIu32 " | " ChipLogFormatX64 " | %10u |\n",
static_cast<uint32_t>(info.peer_node.GetFabricIndex()), ChipLogValueX64(info.peer_node.GetNodeId()),
info.start_icd_counter, info.offset, ChipLogValueX64(info.monitored_subject));
info.start_icd_counter, info.offset, ChipLogValueX64(info.monitored_subject),
static_cast<uint8_t>(info.client_type));

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

fprintf(stderr, " +-----------------------------------------------------------------------------+\n");
fprintf(stderr, " +------------------------------------------------------------------------------------------+\n");
SetCommandExitStatus(CHIP_NO_ERROR);
return CHIP_NO_ERROR;
}
Expand Down
7 changes: 6 additions & 1 deletion examples/chip-tool/commands/pairing/PairingCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ CommissioningParameters PairingCommand::GetCommissioningParameters()
{
mICDMonitoredSubject.SetValue(mICDCheckInNodeId.Value());
}
if (!mICDClientType.HasValue())
{
mICDClientType.SetValue(app::Clusters::IcdManagement::ClientTypeEnum::kPermanent);
}
// These Optionals must have values now.
// The commissioner will verify these values.
params.SetICDSymmetricKey(mICDSymmetricKey.Value());
Expand All @@ -166,6 +170,7 @@ CommissioningParameters PairingCommand::GetCommissioningParameters()
}
params.SetICDCheckInNodeId(mICDCheckInNodeId.Value());
params.SetICDMonitoredSubject(mICDMonitoredSubject.Value());
params.SetICDClientType(mICDClientType.Value());
}

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

app::ICDClientInfo clientInfo;
clientInfo.peer_node = nodeId;
clientInfo.peer_node = chip::ScopedNodeId(mICDCheckInNodeId.Value(), nodeId.GetFabricIndex());
clientInfo.monitored_subject = mICDMonitoredSubject.Value();
clientInfo.start_icd_counter = icdCounter;

Expand Down
3 changes: 3 additions & 0 deletions examples/chip-tool/commands/pairing/PairingCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class PairingCommand : public CHIPCommand,
"The check-in node id for the ICD, default: node id of the commissioner.");
AddArgument("icd-monitored-subject", 0, UINT64_MAX, &mICDMonitoredSubject,
"The monitored subject of the ICD, default: The node id used for icd-check-in-nodeid.");
AddArgument("icd-client-type", 0, 1, &mICDClientType,
"The ClientType of the client registering, default: Permanent client - 0");
AddArgument("icd-symmetric-key", &mICDSymmetricKey, "The 16 bytes ICD symmetric key, default: randomly generated.");
AddArgument("icd-stay-active-duration", 0, UINT32_MAX, &mICDStayActiveDurationMsec,
"If set, a LIT ICD that is commissioned will be requested to stay active for this many milliseconds");
Expand Down Expand Up @@ -245,6 +247,7 @@ class PairingCommand : public CHIPCommand,
chip::Optional<NodeId> mICDCheckInNodeId;
chip::Optional<chip::ByteSpan> mICDSymmetricKey;
chip::Optional<uint64_t> mICDMonitoredSubject;
chip::Optional<chip::app::Clusters::IcdManagement::ClientTypeEnum> mICDClientType;
chip::Optional<uint32_t> mICDStayActiveDurationMsec;
chip::app::DataModel::List<chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type> mTimeZoneList;
TypedComplexArgument<chip::app::DataModel::List<chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,11 @@ cluster BooleanState = 69 {
cluster IcdManagement = 70 {
revision 2;

enum ClientTypeEnum : enum8 {
kPermanent = 0;
kEphemeral = 1;
}

enum OperatingModeEnum : enum8 {
kSIT = 0;
kLIT = 1;
Expand Down Expand Up @@ -1349,6 +1354,7 @@ cluster IcdManagement = 70 {
fabric_scoped struct MonitoringRegistrationStruct {
fabric_sensitive node_id checkInNodeID = 1;
fabric_sensitive int64u monitoredSubject = 2;
fabric_sensitive ClientTypeEnum clientType = 4;
fabric_idx fabricIndex = 254;
}

Expand All @@ -1373,6 +1379,7 @@ cluster IcdManagement = 70 {
int64u monitoredSubject = 1;
octet_string<16> key = 2;
optional octet_string<16> verificationKey = 3;
ClientTypeEnum clientType = 4;
}

response struct RegisterClientResponse = 1 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,11 @@ cluster BooleanState = 69 {
cluster IcdManagement = 70 {
revision 2;

enum ClientTypeEnum : enum8 {
kPermanent = 0;
kEphemeral = 1;
}

enum OperatingModeEnum : enum8 {
kSIT = 0;
kLIT = 1;
Expand Down Expand Up @@ -1349,6 +1354,7 @@ cluster IcdManagement = 70 {
fabric_scoped struct MonitoringRegistrationStruct {
fabric_sensitive node_id checkInNodeID = 1;
fabric_sensitive int64u monitoredSubject = 2;
fabric_sensitive ClientTypeEnum clientType = 4;
fabric_idx fabricIndex = 254;
}

Expand All @@ -1373,6 +1379,7 @@ cluster IcdManagement = 70 {
int64u monitoredSubject = 1;
octet_string<16> key = 2;
optional octet_string<16> verificationKey = 3;
ClientTypeEnum clientType = 4;
}

response struct RegisterClientResponse = 1 {
Expand Down
7 changes: 6 additions & 1 deletion examples/fabric-admin/commands/pairing/PairingCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ CommissioningParameters PairingCommand::GetCommissioningParameters()
{
mICDMonitoredSubject.SetValue(mICDCheckInNodeId.Value());
}
if (!mICDClientType.HasValue())
{
mICDClientType.SetValue(app::Clusters::IcdManagement::ClientTypeEnum::kPermanent);
}
// These Optionals must have values now.
// The commissioner will verify these values.
params.SetICDSymmetricKey(mICDSymmetricKey.Value());
Expand All @@ -166,6 +170,7 @@ CommissioningParameters PairingCommand::GetCommissioningParameters()
}
params.SetICDCheckInNodeId(mICDCheckInNodeId.Value());
params.SetICDMonitoredSubject(mICDMonitoredSubject.Value());
params.SetICDClientType(mICDClientType.Value());
}

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

app::ICDClientInfo clientInfo;
clientInfo.peer_node = nodeId;
clientInfo.peer_node = chip::ScopedNodeId(mICDCheckInNodeId.Value(), nodeId.GetFabricIndex());
clientInfo.monitored_subject = mICDMonitoredSubject.Value();
clientInfo.start_icd_counter = icdCounter;

Expand Down
3 changes: 3 additions & 0 deletions examples/fabric-admin/commands/pairing/PairingCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class PairingCommand : public CHIPCommand,
"The check-in node id for the ICD, default: node id of the commissioner.");
AddArgument("icd-monitored-subject", 0, UINT64_MAX, &mICDMonitoredSubject,
"The monitored subject of the ICD, default: The node id used for icd-check-in-nodeid.");
AddArgument("icd-client-type", 0, 1, &mICDClientType,
"The ClientType of the client registering, default: Permanent client - 0");
AddArgument("icd-symmetric-key", &mICDSymmetricKey, "The 16 bytes ICD symmetric key, default: randomly generated.");
AddArgument("icd-stay-active-duration", 0, UINT32_MAX, &mICDStayActiveDurationMsec,
"If set, a LIT ICD that is commissioned will be requested to stay active for this many milliseconds");
Expand Down Expand Up @@ -258,6 +260,7 @@ class PairingCommand : public CHIPCommand,
chip::Optional<char *> mCountryCode;
chip::Optional<bool> mICDRegistration;
chip::Optional<NodeId> mICDCheckInNodeId;
chip::Optional<chip::app::Clusters::IcdManagement::ClientTypeEnum> mICDClientType;
chip::Optional<chip::ByteSpan> mICDSymmetricKey;
chip::Optional<uint64_t> mICDMonitoredSubject;
chip::Optional<uint32_t> mICDStayActiveDurationMsec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1939,6 +1939,11 @@ cluster UserLabel = 65 {
cluster IcdManagement = 70 {
revision 2;

enum ClientTypeEnum : enum8 {
kPermanent = 0;
kEphemeral = 1;
}

enum OperatingModeEnum : enum8 {
kSIT = 0;
kLIT = 1;
Expand Down Expand Up @@ -1973,6 +1978,7 @@ cluster IcdManagement = 70 {
fabric_scoped struct MonitoringRegistrationStruct {
fabric_sensitive node_id checkInNodeID = 1;
fabric_sensitive int64u monitoredSubject = 2;
fabric_sensitive ClientTypeEnum clientType = 4;
fabric_idx fabricIndex = 254;
}

Expand All @@ -1997,6 +2003,7 @@ cluster IcdManagement = 70 {
int64u monitoredSubject = 1;
octet_string<16> key = 2;
optional octet_string<16> verificationKey = 3;
ClientTypeEnum clientType = 4;
}

response struct RegisterClientResponse = 1 {
Expand Down
7 changes: 7 additions & 0 deletions examples/light-switch-app/qpg/zap/switch.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1736,6 +1736,11 @@ cluster UserLabel = 65 {
cluster IcdManagement = 70 {
revision 2;

enum ClientTypeEnum : enum8 {
kPermanent = 0;
kEphemeral = 1;
}

enum OperatingModeEnum : enum8 {
kSIT = 0;
kLIT = 1;
Expand Down Expand Up @@ -1770,6 +1775,7 @@ cluster IcdManagement = 70 {
fabric_scoped struct MonitoringRegistrationStruct {
fabric_sensitive node_id checkInNodeID = 1;
fabric_sensitive int64u monitoredSubject = 2;
fabric_sensitive ClientTypeEnum clientType = 4;
fabric_idx fabricIndex = 254;
}

Expand All @@ -1794,6 +1800,7 @@ cluster IcdManagement = 70 {
int64u monitoredSubject = 1;
octet_string<16> key = 2;
optional octet_string<16> verificationKey = 3;
ClientTypeEnum clientType = 4;
}

response struct RegisterClientResponse = 1 {
Expand Down
7 changes: 7 additions & 0 deletions examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,11 @@ cluster BooleanState = 69 {
cluster IcdManagement = 70 {
revision 2;

enum ClientTypeEnum : enum8 {
kPermanent = 0;
kEphemeral = 1;
}

enum OperatingModeEnum : enum8 {
kSIT = 0;
kLIT = 1;
Expand Down Expand Up @@ -1447,6 +1452,7 @@ cluster IcdManagement = 70 {
fabric_scoped struct MonitoringRegistrationStruct {
fabric_sensitive node_id checkInNodeID = 1;
fabric_sensitive int64u monitoredSubject = 2;
fabric_sensitive ClientTypeEnum clientType = 4;
fabric_idx fabricIndex = 254;
}

Expand All @@ -1471,6 +1477,7 @@ cluster IcdManagement = 70 {
int64u monitoredSubject = 1;
octet_string<16> key = 2;
optional octet_string<16> verificationKey = 3;
ClientTypeEnum clientType = 4;
}

response struct RegisterClientResponse = 1 {
Expand Down
7 changes: 7 additions & 0 deletions examples/lock-app/lock-common/lock-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1756,6 +1756,11 @@ cluster UserLabel = 65 {
cluster IcdManagement = 70 {
revision 2;

enum ClientTypeEnum : enum8 {
kPermanent = 0;
kEphemeral = 1;
}

enum OperatingModeEnum : enum8 {
kSIT = 0;
kLIT = 1;
Expand Down Expand Up @@ -1790,6 +1795,7 @@ cluster IcdManagement = 70 {
fabric_scoped struct MonitoringRegistrationStruct {
fabric_sensitive node_id checkInNodeID = 1;
fabric_sensitive int64u monitoredSubject = 2;
fabric_sensitive ClientTypeEnum clientType = 4;
fabric_idx fabricIndex = 254;
}

Expand All @@ -1814,6 +1820,7 @@ cluster IcdManagement = 70 {
int64u monitoredSubject = 1;
octet_string<16> key = 2;
optional octet_string<16> verificationKey = 3;
ClientTypeEnum clientType = 4;
}

response struct RegisterClientResponse = 1 {
Expand Down
7 changes: 7 additions & 0 deletions examples/lock-app/qpg/zap/lock.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,11 @@ cluster UserLabel = 65 {
cluster IcdManagement = 70 {
revision 2;

enum ClientTypeEnum : enum8 {
kPermanent = 0;
kEphemeral = 1;
}

enum OperatingModeEnum : enum8 {
kSIT = 0;
kLIT = 1;
Expand Down Expand Up @@ -1446,6 +1451,7 @@ cluster IcdManagement = 70 {
fabric_scoped struct MonitoringRegistrationStruct {
fabric_sensitive node_id checkInNodeID = 1;
fabric_sensitive int64u monitoredSubject = 2;
fabric_sensitive ClientTypeEnum clientType = 4;
fabric_idx fabricIndex = 254;
}

Expand All @@ -1470,6 +1476,7 @@ cluster IcdManagement = 70 {
int64u monitoredSubject = 1;
octet_string<16> key = 2;
optional octet_string<16> verificationKey = 3;
ClientTypeEnum clientType = 4;
}

response struct RegisterClientResponse = 1 {
Expand Down
Loading
Loading