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 : Optional<ReliableMessageProtocolConfig> mrpLocalConfig = Optional<ReliableMessageProtocolConfig>::Missing(); 38 : 39 2 : CHIP_ERROR Validate() const 40 : { 41 : // sessionResumptionStorage can be nullptr when resumption is disabled. 42 : // certificateValidityPolicy is optional, too. 43 2 : ReturnErrorCodeIf(sessionManager == nullptr, CHIP_ERROR_INCORRECT_STATE); 44 2 : ReturnErrorCodeIf(exchangeMgr == nullptr, CHIP_ERROR_INCORRECT_STATE); 45 2 : ReturnErrorCodeIf(fabricTable == nullptr, CHIP_ERROR_INCORRECT_STATE); 46 2 : ReturnErrorCodeIf(groupDataProvider == nullptr, CHIP_ERROR_INCORRECT_STATE); 47 : 48 2 : return CHIP_NO_ERROR; 49 : } 50 : }; 51 : 52 : class DLL_EXPORT CASEClient 53 : { 54 : public: 55 : void SetRemoteMRPIntervals(const ReliableMessageProtocolConfig & remoteMRPConfig); 56 : 57 : const ReliableMessageProtocolConfig & GetRemoteMRPIntervals(); 58 : 59 : CHIP_ERROR EstablishSession(const CASEClientInitParams & params, const ScopedNodeId & peer, 60 : const Transport::PeerAddress & peerAddress, const ReliableMessageProtocolConfig & remoteMRPConfig, 61 : SessionEstablishmentDelegate * delegate); 62 : 63 : private: 64 : CASESession mCASESession; 65 : }; 66 : 67 : } // namespace chip