Line data Source code
1 : /*
2 : * Copyright (c) 2024 Project CHIP Authors
3 : * All rights reserved.
4 : *
5 : * Licensed under the Apache License, Version 2.0 (the "License");
6 : * you may not use this file except in compliance with the License.
7 : * You may obtain a copy of the License at
8 : *
9 : * http://www.apache.org/licenses/LICENSE-2.0
10 : *
11 : * Unless required by applicable law or agreed to in writing, software
12 : * distributed under the License is distributed on an "AS IS" BASIS,
13 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 : * See the License for the specific language governing permissions and
15 : * limitations under the License.
16 : */
17 : #pragma once
18 :
19 : #include <access/SubjectDescriptor.h>
20 : #include <app/ConcreteAttributePath.h>
21 : #include <app/ConcreteCommandPath.h>
22 : #include <lib/core/DataModelTypes.h>
23 : #include <lib/support/BitFlags.h>
24 :
25 : #include <cstdint>
26 : #include <optional>
27 :
28 : namespace chip {
29 : namespace app {
30 : namespace DataModel {
31 :
32 : /// This information is available for ALL interactions: read/write/invoke
33 : struct OperationRequest
34 : {
35 : /// Current authentication data.
36 : const chip::Access::SubjectDescriptor & subjectDescriptor;
37 :
38 : /// Accessing fabric index is the subjectDescriptor fabric index (if any).
39 : /// This is a readability convenience function.
40 220 : FabricIndex GetAccessingFabricIndex() const { return subjectDescriptor.fabricIndex; }
41 :
42 : protected:
43 13379 : OperationRequest(const Access::SubjectDescriptor & aSubjectDescriptor) : subjectDescriptor(aSubjectDescriptor) {}
44 : };
45 :
46 : enum class ReadFlags : uint32_t
47 : {
48 : kFabricFiltered = 0x0001, // reading is performed fabric-filtered
49 : kAllowsLargePayload = 0x0002, // reading is performed over a transport supporting large payload
50 : };
51 :
52 : enum class ListWriteOperation : uint8_t
53 : {
54 : kListWriteBegin = 0,
55 : kListWriteSuccess,
56 : kListWriteFailure
57 : };
58 :
59 : struct ReadAttributeRequest : OperationRequest
60 : {
61 : ConcreteAttributePath path;
62 : BitFlags<ReadFlags> readFlags;
63 :
64 6723 : ReadAttributeRequest(const ConcreteAttributePath & aPath, const Access::SubjectDescriptor & aSubjectDescriptor) :
65 6723 : OperationRequest(aSubjectDescriptor), path(aPath)
66 6723 : {}
67 : };
68 :
69 : enum class WriteFlags : uint32_t
70 : {
71 : kTimed = 0x0001, // Write is a timed write (i.e. a Timed Request Action preceeded it)
72 : };
73 :
74 : struct WriteAttributeRequest : OperationRequest
75 : {
76 : ConcreteDataAttributePath path; // NOTE: this also contains LIST operation options (i.e. "data" path type)
77 : BitFlags<WriteFlags> writeFlags;
78 :
79 5900 : WriteAttributeRequest(const ConcreteDataAttributePath & aPath, const Access::SubjectDescriptor & aSubjectDescriptor) :
80 5900 : OperationRequest(aSubjectDescriptor), path(aPath)
81 5900 : {}
82 : };
83 :
84 : enum class InvokeFlags : uint32_t
85 : {
86 : kTimed = 0x0001, // Command received as part of a timed invoke interaction.
87 : };
88 :
89 : struct InvokeRequest : OperationRequest
90 : {
91 : ConcreteCommandPath path;
92 : BitFlags<InvokeFlags> invokeFlags;
93 :
94 756 : InvokeRequest(const ConcreteCommandPath & aPath, const Access::SubjectDescriptor & aSubjectDescriptor) :
95 756 : OperationRequest(aSubjectDescriptor), path(aPath)
96 756 : {}
97 : };
98 :
99 : } // namespace DataModel
100 : } // namespace app
101 : } // namespace chip
|