Line data Source code
1 : /*
2 : *
3 : * Copyright (c) 2020-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 : */
16 :
17 : #pragma once
18 :
19 : #include <lib/support/CodeUtils.h>
20 : #include <system/SystemPacketBuffer.h>
21 : #include <transport/raw/Base.h>
22 : #include <transport/raw/MessageHeader.h>
23 : #include <transport/raw/PeerAddress.h>
24 : #if INET_CONFIG_ENABLE_TCP_ENDPOINT
25 : #include <transport/raw/TCP.h>
26 : #endif // INET_CONFIG_ENABLE_TCP_ENDPOINT
27 :
28 : namespace chip {
29 :
30 : namespace Transport {
31 : class Base;
32 : }
33 :
34 : class TransportMgrDelegate;
35 :
36 : class TransportMgrBase : public Transport::RawTransportDelegate
37 : {
38 : public:
39 : CHIP_ERROR Init(Transport::Base * transport);
40 :
41 : CHIP_ERROR SendMessage(const Transport::PeerAddress & address, System::PacketBufferHandle && msgBuf);
42 :
43 : void Close();
44 :
45 : #if INET_CONFIG_ENABLE_TCP_ENDPOINT
46 : CHIP_ERROR TCPConnect(const Transport::PeerAddress & address, Transport::AppTCPConnectionCallbackCtxt * appState,
47 : Transport::ActiveTCPConnectionHolder & peerConnState);
48 :
49 : void HandleConnectionReceived(Transport::ActiveTCPConnectionState & conn) override;
50 :
51 : void HandleConnectionAttemptComplete(Transport::ActiveTCPConnectionHolder & conn, CHIP_ERROR conErr) override;
52 :
53 : void HandleConnectionClosed(Transport::ActiveTCPConnectionState & conn, CHIP_ERROR conErr) override;
54 : #endif // INET_CONFIG_ENABLE_TCP_ENDPOINT
55 :
56 457 : void SetSessionManager(TransportMgrDelegate * sessionManager) { mSessionManager = sessionManager; }
57 :
58 : TransportMgrDelegate * GetSessionManager() { return mSessionManager; };
59 :
60 : CHIP_ERROR MulticastGroupJoinLeave(const Transport::PeerAddress & address, bool join);
61 :
62 : void HandleMessageReceived(const Transport::PeerAddress & peerAddress, System::PacketBufferHandle && msg,
63 : Transport::MessageTransportContext * ctxt = nullptr) override;
64 :
65 : private:
66 : TransportMgrDelegate * mSessionManager = nullptr;
67 : Transport::Base * mTransport = nullptr;
68 : };
69 :
70 : } // namespace chip
|