| /* |
| * |
| * Copyright (c) 2022 Project CHIP Authors |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| // THIS FILE IS GENERATED BY ZAP |
| // This file is generated from clusters-Commands.ipp.zapt |
| |
| #include <clusters/TlsCertificateManagement/Commands.h> |
| |
| #include <app/data-model/Decode.h> |
| #include <app/data-model/StructDecodeIterator.h> |
| #include <app/data-model/WrappedStructEncoder.h> |
| |
| namespace chip { |
| namespace app { |
| namespace Clusters { |
| namespace TlsCertificateManagement { |
| namespace Commands { |
| namespace ProvisionRootCertificate { |
| |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kCertificate), certificate); |
| encoder.Encode(to_underlying(Fields::kCaid), caid); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader, FabricIndex aAccessingFabricIndex) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kCertificate)) |
| { |
| err = DataModel::Decode(reader, certificate); |
| } |
| else if (__context_tag == to_underlying(Fields::kCaid)) |
| { |
| err = DataModel::Decode(reader, caid); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace ProvisionRootCertificate. |
| namespace ProvisionRootCertificateResponse { |
| |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kCaid), caid); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kCaid)) |
| { |
| err = DataModel::Decode(reader, caid); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace ProvisionRootCertificateResponse. |
| namespace FindRootCertificate { |
| |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kCaid), caid); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader, FabricIndex aAccessingFabricIndex) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kCaid)) |
| { |
| err = DataModel::Decode(reader, caid); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace FindRootCertificate. |
| namespace FindRootCertificateResponse { |
| |
| CHIP_ERROR Type::EncodeForRead(TLV::TLVWriter & aWriter, TLV::Tag aTag, FabricIndex aAccessingFabricIndex) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.EncodeForRead(to_underlying(Fields::kCertificateDetails), aAccessingFabricIndex, certificateDetails); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR Type::EncodeForWrite(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.EncodeForWrite(to_underlying(Fields::kCertificateDetails), certificateDetails); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kCertificateDetails)) |
| { |
| err = DataModel::Decode(reader, certificateDetails); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace FindRootCertificateResponse. |
| namespace LookupRootCertificate { |
| |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kFingerprint), fingerprint); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader, FabricIndex aAccessingFabricIndex) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kFingerprint)) |
| { |
| err = DataModel::Decode(reader, fingerprint); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace LookupRootCertificate. |
| namespace LookupRootCertificateResponse { |
| |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kCaid), caid); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kCaid)) |
| { |
| err = DataModel::Decode(reader, caid); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace LookupRootCertificateResponse. |
| namespace RemoveRootCertificate { |
| |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kCaid), caid); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader, FabricIndex aAccessingFabricIndex) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kCaid)) |
| { |
| err = DataModel::Decode(reader, caid); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace RemoveRootCertificate. |
| namespace TLSClientCSR { |
| |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kNonce), nonce); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader, FabricIndex aAccessingFabricIndex) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kNonce)) |
| { |
| err = DataModel::Decode(reader, nonce); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace TLSClientCSR. |
| namespace TLSClientCSRResponse { |
| |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kCcdid), ccdid); |
| encoder.Encode(to_underlying(Fields::kCsr), csr); |
| encoder.Encode(to_underlying(Fields::kNonce), nonce); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kCcdid)) |
| { |
| err = DataModel::Decode(reader, ccdid); |
| } |
| else if (__context_tag == to_underlying(Fields::kCsr)) |
| { |
| err = DataModel::Decode(reader, csr); |
| } |
| else if (__context_tag == to_underlying(Fields::kNonce)) |
| { |
| err = DataModel::Decode(reader, nonce); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace TLSClientCSRResponse. |
| namespace ProvisionClientCertificate { |
| |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kCcdid), ccdid); |
| encoder.EncodeForWrite(to_underlying(Fields::kClientCertificateDetails), clientCertificateDetails); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader, FabricIndex aAccessingFabricIndex) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kCcdid)) |
| { |
| err = DataModel::Decode(reader, ccdid); |
| } |
| else if (__context_tag == to_underlying(Fields::kClientCertificateDetails)) |
| { |
| err = DataModel::Decode(reader, clientCertificateDetails); |
| if (err == CHIP_NO_ERROR) |
| { |
| clientCertificateDetails.SetFabricIndex(aAccessingFabricIndex); |
| } |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace ProvisionClientCertificate. |
| namespace FindClientCertificate { |
| |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kCcdid), ccdid); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader, FabricIndex aAccessingFabricIndex) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kCcdid)) |
| { |
| err = DataModel::Decode(reader, ccdid); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace FindClientCertificate. |
| namespace FindClientCertificateResponse { |
| |
| CHIP_ERROR Type::EncodeForRead(TLV::TLVWriter & aWriter, TLV::Tag aTag, FabricIndex aAccessingFabricIndex) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.EncodeForRead(to_underlying(Fields::kCertificateDetails), aAccessingFabricIndex, certificateDetails); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR Type::EncodeForWrite(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.EncodeForWrite(to_underlying(Fields::kCertificateDetails), certificateDetails); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kCertificateDetails)) |
| { |
| err = DataModel::Decode(reader, certificateDetails); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace FindClientCertificateResponse. |
| namespace LookupClientCertificate { |
| |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kFingerprint), fingerprint); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader, FabricIndex aAccessingFabricIndex) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kFingerprint)) |
| { |
| err = DataModel::Decode(reader, fingerprint); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace LookupClientCertificate. |
| namespace LookupClientCertificateResponse { |
| |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kCcdid), ccdid); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kCcdid)) |
| { |
| err = DataModel::Decode(reader, ccdid); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace LookupClientCertificateResponse. |
| namespace RemoveClientCertificate { |
| |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kCcdid), ccdid); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader, FabricIndex aAccessingFabricIndex) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kCcdid)) |
| { |
| err = DataModel::Decode(reader, ccdid); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace RemoveClientCertificate. |
| } // namespace Commands |
| } // namespace TlsCertificateManagement |
| } // namespace Clusters |
| } // namespace app |
| } // namespace chip |