1 /*
2  * Copyright (c) 2021-2024 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_PROXYCHANNEL_TRANSCEIVER_H
17 #define SOFTBUS_PROXYCHANNEL_TRANSCEIVER_H
18 
19 #include "common_list.h"
20 #include "softbus_app_info.h"
21 #include "softbus_conn_interface.h"
22 #include "softbus_proxychannel_message.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 typedef struct {
29     ListNode node;
30     uint32_t requestId;
31     ConnectOption connInfo;
32     uint32_t connId;
33     int32_t ref;
34     uint32_t state;
35     bool isServerSide;
36 } ProxyConnInfo;
37 
38 void TransProxyPostResetPeerMsgToLoop(const ProxyChannelInfo *chan);
39 void TransProxyPostHandshakeMsgToLoop(int32_t channelId);
40 void TransProxyPostDisConnectMsgToLoop(uint32_t connId, bool isServer, const ProxyChannelInfo *chan);
41 void TransProxyPostOpenClosedMsgToLoop(const ProxyChannelInfo *chan);
42 void TransProxyPostOpenFailMsgToLoop(const ProxyChannelInfo *chan, int32_t errCode);
43 void TransProxyPostKeepAliveMsgToLoop(const ProxyChannelInfo *chan);
44 void TransProxyPostAuthNegoMsgToLooperDelay(uint32_t authRequestId, int32_t channelId, uint32_t delayTime);
45 int32_t TransProxyTransInit(void);
46 int32_t TransProxyCloseConnChannel(uint32_t connectionId, bool isServer);
47 int32_t TransProxyCloseConnChannelReset(uint32_t connectionId, bool isDisconnect, bool isServer, bool deviceType);
48 int32_t TransProxyOpenConnChannel(const AppInfo *appInfo, const ConnectOption *connInfo, int32_t *channelId);
49 int32_t TransProxyTransSendMsg(uint32_t connectionId, uint8_t *buf, uint32_t len, int32_t priority, int32_t pid);
50 void TransCreateConnByConnId(uint32_t connId, bool isServer);
51 int32_t TransDecConnRefByConnId(uint32_t connId, bool isServer);
52 int32_t TransAddConnRefByConnId(uint32_t connId, bool isServer);
53 int32_t TransProxyGetConnInfoByConnId(uint32_t connId, ConnectOption *connInfo);
54 int32_t TransDelConnByReqId(uint32_t requestId);
55 int32_t CheckIsProxyAuthChannel(ConnectOption *connInfo);
56 
57 #ifdef __cplusplus
58 }
59 #endif
60 
61 #endif
62