• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 CLIENT_TRANS_PROXY_CHANNEL_H
17 #define CLIENT_TRANS_PROXY_CHANNEL_H
18 
19 #include "client_trans_file_listener.h"
20 #include "client_trans_session_callback.h"
21 #include "softbus_def.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 typedef struct {
28     int32_t isEncrypted;
29     int32_t sequence;
30     char sessionKey[SESSION_KEY_LENGTH];
31 }ProxyChannelInfoDetail;
32 
33 typedef struct {
34     ListNode node;
35     int32_t channelId;
36     ProxyChannelInfoDetail detail;
37 }ClientProxyChannelInfo;
38 
39 typedef struct {
40     int32_t active;
41     int32_t timeout;
42     int32_t sliceNumber;
43     int32_t expectedSeq;
44     int32_t dataLen;
45     int32_t bufLen;
46     char *data;
47 }SliceProcessor;
48 
49 typedef enum {
50     PROXY_CHANNEL_PRORITY_MESSAGE = 0,
51     PROXY_CHANNEL_PRORITY_BYTES = 1,
52     PROXY_CHANNEL_PRORITY_FILE = 2,
53     PROXY_CHANNEL_PRORITY_BUTT = 3,
54 } ProxyChannelPriority;
55 
56 typedef struct {
57     ListNode head;
58     int32_t channelId;
59     SliceProcessor processor[PROXY_CHANNEL_PRORITY_BUTT];
60 }ChannelSliceProcessor;
61 
62 int32_t ClientTransProxyInit(const IClientSessionCallBack *cb);
63 
64 void ClientTransProxyDeinit(void);
65 
66 int32_t ClientTransProxyGetInfoByChannelId(int32_t channelId, ProxyChannelInfoDetail *info);
67 
68 int32_t ClientTransProxyAddChannelInfo(ClientProxyChannelInfo *info);
69 
70 int32_t ClientTransProxyDelChannelInfo(int32_t channelId);
71 
72 int32_t ClientTransProxyOnChannelOpened(const char *sessionName, const ChannelInfo *channel);
73 
74 int32_t ClientTransProxyOnChannelClosed(int32_t channelId);
75 
76 int32_t ClientTransProxyOnChannelOpenFailed(int32_t channelId, int32_t errCode);
77 
78 int32_t ClientTransProxyOnDataReceived(int32_t channelId,
79     const void *data, uint32_t len, SessionPktType type);
80 
81 void ClientTransProxyCloseChannel(int32_t channelId);
82 
83 int32_t TransProxyPackAndSendData(int32_t channelId, const void *data, uint32_t len,
84     ProxyChannelInfoDetail* info, SessionPktType pktType);
85 
86 int32_t TransProxyChannelSendBytes(int32_t channelId, const void *data, uint32_t len);
87 
88 int32_t TransProxyChannelSendMessage(int32_t channelId, const void *data, uint32_t len);
89 
90 int32_t TransProxyChannelSendFile(int32_t channelId, const char *sFileList[], const char *dFileList[],
91     uint32_t fileCnt);
92 
93 int32_t ProcessFileFrameData(int32_t sessionId, int32_t channelId, const char *data, uint32_t len, int32_t type);
94 
95 #ifdef __cplusplus
96 }
97 #endif
98 #endif