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 : /**
19 : * @file
20 : * This file defines ExchangeMessageDispatch class. The object of this
21 : * class can be used by CHIP protocols to send and receive messages.
22 : */
23 :
24 : #pragma once
25 :
26 : #include <messaging/Flags.h>
27 : #include <protocols/Protocols.h>
28 : #include <transport/SessionManager.h>
29 :
30 : namespace chip {
31 : namespace Messaging {
32 :
33 : class ReliableMessageContext;
34 :
35 : class ExchangeMessageDispatch
36 : {
37 : public:
38 10 : ExchangeMessageDispatch() {}
39 10 : virtual ~ExchangeMessageDispatch() {}
40 :
41 721 : virtual bool IsEncryptionRequired() const { return true; }
42 :
43 : CHIP_ERROR SendMessage(SessionManager * sessionManager, const SessionHandle & session, uint16_t exchangeId, bool isInitiator,
44 : ReliableMessageContext * reliableMessageContext, bool isReliableTransmission, Protocols::Id protocol,
45 : uint8_t type, System::PacketBufferHandle && message);
46 :
47 : virtual bool MessagePermitted(Protocols::Id protocol, uint8_t type) = 0;
48 :
49 : // TODO: remove IsReliableTransmissionAllowed, this function should be provided over session.
50 1504 : virtual bool IsReliableTransmissionAllowed() const { return true; }
51 :
52 : private:
53 : CHIP_ERROR PrepareAndSendNonMRPMessage(SessionManager * sessionManager, const SessionHandle & session,
54 : PayloadHeader & payloadHeader, System::PacketBufferHandle && message);
55 : };
56 :
57 : } // namespace Messaging
58 : } // namespace chip
|