Line data Source code
1 : /*
2 : *
3 : * Copyright (c) 2021 Project CHIP Authors
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 :
18 : #pragma once
19 :
20 : #include <credentials/GroupDataProvider.h>
21 : #include <messaging/ExchangeMgr.h>
22 : #include <messaging/ReliableMessageProtocolConfig.h>
23 : #include <protocols/secure_channel/CASESession.h>
24 :
25 : namespace chip {
26 :
27 : class CASEClient;
28 :
29 : struct CASEClientInitParams
30 : {
31 : SessionManager * sessionManager = nullptr;
32 : SessionResumptionStorage * sessionResumptionStorage = nullptr;
33 : Credentials::CertificateValidityPolicy * certificateValidityPolicy = nullptr;
34 : Messaging::ExchangeManager * exchangeMgr = nullptr;
35 : FabricTable * fabricTable = nullptr;
36 : Credentials::GroupDataProvider * groupDataProvider = nullptr;
37 :
38 : // mrpLocalConfig should not generally be set to anything other than
39 : // NullOptional. Doing that can lead to different parts of the system
40 : // claiming different MRP parameters for the same node.
41 : Optional<ReliableMessageProtocolConfig> mrpLocalConfig = NullOptional;
42 :
43 2 : CHIP_ERROR Validate() const
44 : {
45 : // sessionResumptionStorage can be nullptr when resumption is disabled.
46 : // certificateValidityPolicy is optional, too.
47 2 : VerifyOrReturnError(sessionManager != nullptr, CHIP_ERROR_INCORRECT_STATE);
48 2 : VerifyOrReturnError(exchangeMgr != nullptr, CHIP_ERROR_INCORRECT_STATE);
49 2 : VerifyOrReturnError(fabricTable != nullptr, CHIP_ERROR_INCORRECT_STATE);
50 2 : VerifyOrReturnError(groupDataProvider != nullptr, CHIP_ERROR_INCORRECT_STATE);
51 :
52 2 : return CHIP_NO_ERROR;
53 : }
54 : };
55 :
56 : class DLL_EXPORT CASEClient
57 : {
58 : public:
59 : void SetRemoteMRPIntervals(const ReliableMessageProtocolConfig & remoteMRPConfig);
60 :
61 : const ReliableMessageProtocolConfig & GetRemoteMRPIntervals();
62 :
63 : CHIP_ERROR EstablishSession(const CASEClientInitParams & params, const ScopedNodeId & peer,
64 : const Transport::PeerAddress & peerAddress, const ReliableMessageProtocolConfig & remoteMRPConfig,
65 : SessionEstablishmentDelegate * delegate);
66 :
67 : private:
68 : CASESession mCASESession;
69 : };
70 :
71 : } // namespace chip
|