1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *    http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef SOFTBUS_TCP_CONNECT_MANAGER_H
17 #define SOFTBUS_TCP_CONNECT_MANAGER_H
18 
19 #include <sys/select.h>
20 
21 #include "common_list.h"
22 #include "softbus_conn_interface.h"
23 #include "softbus_conn_manager.h"
24 #include "softbus_base_listener.h"
25 
26 #ifdef __cplusplus
27 #if __cplusplus
28 extern "C" {
29 #endif
30 #endif
31 
32 uint32_t CalTcpConnectionId(int32_t fd);
33 
34 uint32_t TcpGetConnNum(void);
35 
36 int32_t TcpConnectDevice(const ConnectOption *option, uint32_t requestId, const ConnectResult *result);
37 
38 int32_t TcpDisconnectDevice(uint32_t connectionId);
39 
40 int32_t TcpDisconnectDeviceNow(const ConnectOption *option);
41 
42 int32_t TcpPostBytes(
43     uint32_t connectionId, uint8_t *data, uint32_t len, int32_t pid, int32_t flag, int32_t module, int64_t seq);
44 
45 int32_t TcpGetConnectionInfo(uint32_t connectionId, ConnectionInfo *Info);
46 
47 int32_t TcpStartListening(const LocalListenerInfo *info);
48 
49 int32_t TcpStopListening(const LocalListenerInfo *info);
50 
51 ConnectFuncInterface *ConnInitTcp(const ConnectCallback *callback);
52 
53 int32_t ConnGetSocketError(int32_t fd);
54 
55 #ifdef __cplusplus
56 #if __cplusplus
57 }
58 #endif /* __cplusplus */
59 #endif /* __cplusplus */
60 
61 #endif