• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 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_SESSION_MANAGER_H
17 #define CLIENT_TRANS_SESSION_MANAGER_H
18 
19 #include "client_trans_session_adapter.h"
20 #include "client_trans_session_manager_struct.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 int32_t ClientAddNewSession(const char *sessionName, SessionInfo *session);
27 
28 /**
29  * @brief Add session.
30  * @return if the operation is successful, return SOFTBUS_OK.
31  * @return if session already added, return SOFTBUS_TRANS_SESSION_REPEATED.
32  * @return return other error codes.
33  */
34 int32_t ClientAddSession(const SessionParam *param, int32_t *sessionId, SessionEnableStatus *isEnabled);
35 
36 int32_t ClientAddAuthSession(const char *sessionName, int32_t *sessionId);
37 
38 int32_t ClientDeleteSessionServer(SoftBusSecType type, const char *sessionName);
39 
40 int32_t ClientDeleteSession(int32_t sessionId);
41 
42 int32_t ClientGetSessionDataById(int32_t sessionId, char *data, uint16_t len, TransSessionKey key);
43 
44 int32_t ClientGetSessionIntegerDataById(int32_t sessionId, int *data, TransSessionKey key);
45 
46 int32_t ClientGetChannelBySessionId(
47     int32_t sessionId, int32_t *channelId, int32_t *type, SessionEnableStatus *enableStatus);
48 
49 int32_t ClientSetChannelBySessionId(int32_t sessionId, TransInfo *transInfo);
50 
51 int32_t ClientGetChannelBusinessTypeBySessionId(int32_t sessionId, int32_t *businessType);
52 
53 int32_t GetEncryptByChannelId(int32_t channelId, int32_t channelType, int32_t *data);
54 
55 int32_t GetSupportTlvAndNeedAckById(int32_t channelId, int32_t channelType, bool *supportTlv, bool *needAck);
56 
57 int32_t ClientGetSessionStateByChannelId(int32_t channelId, int32_t channelType, SessionState *sessionState);
58 
59 int32_t ClientGetSessionIdByChannelId(int32_t channelId, int32_t channelType, int32_t *sessionId, bool isClosing);
60 
61 int32_t ClientGetSessionIsD2DByChannelId(int32_t channelId, int32_t channelType, bool *isD2D);
62 
63 int32_t ClientGetSessionIsAsyncBySessionId(int32_t sessionId, bool *isAsync);
64 
65 int32_t ClientGetRouteTypeByChannelId(int32_t channelId, int32_t channelType, int32_t *routeType);
66 
67 int32_t ClientGetDataConfigByChannelId(int32_t channelId, int32_t channelType, uint32_t *dataConfig);
68 
69 int32_t ClientEnableSessionByChannelId(const ChannelInfo *channel, int32_t *sessionId);
70 
71 int32_t ClientGetSessionCallbackById(int32_t sessionId, ISessionListener *callback);
72 
73 int32_t ClientGetSessionCallbackByName(const char *sessionName, ISessionListener *callback);
74 
75 int32_t ClientAddSessionServer(SoftBusSecType type, const char *pkgName, const char *sessionName,
76     const ISessionListener *listener, uint64_t *timestamp);
77 
78 int32_t ClientGetSessionSide(int32_t sessionId);
79 
80 int32_t ClientGetFileConfigInfoById(int32_t sessionId, int32_t *fileEncrypt, int32_t *algorithm, int32_t *crc);
81 
82 int TransClientInit(void);
83 void TransClientDeinit(void);
84 
85 void ClientTransRegLnnOffline(void);
86 
87 void ClientTransOnUserSwitch(void);
88 
89 void ClientTransOnLinkDown(const char *networkId, int32_t routeType);
90 
91 void ClientCleanAllSessionWhenServerDeath(ListNode *sessionServerInfoList);
92 
93 int32_t CheckPermissionState(int32_t sessionId);
94 
95 void PermissionStateChange(const char *pkgName, int32_t state);
96 
97 int32_t ClientAddSocketServer(SoftBusSecType type, const char *pkgName, const char *sessionName, uint64_t *timestamp);
98 
99 int32_t ClientAddSocketSession(
100     const SessionParam *param, bool isEncyptedRawStream, int32_t *sessionId, SessionEnableStatus *isEnabled);
101 
102 int32_t ClientSetListenerBySessionId(int32_t sessionId, const ISocketListener *listener, bool isServer);
103 
104 int32_t ClientIpcOpenSession(
105     int32_t sessionId, const QosTV *qos, uint32_t qosCount, TransInfo *transInfo, bool isAsync);
106 
107 int32_t ClientSetActionIdBySessionId(int32_t sessionId, uint32_t actionId);
108 
109 int32_t ClientSetSocketState(int32_t socket, uint32_t maxIdleTimeout, SessionRole role);
110 
111 int32_t ClientGetSessionCallbackAdapterByName(const char *sessionName, SessionListenerAdapter *callbackAdapter);
112 
113 int32_t ClientGetSessionCallbackAdapterById(int32_t sessionId, SessionListenerAdapter *callbackAdapter, bool *isServer);
114 
115 int32_t ClientGetPeerSocketInfoById(int32_t sessionId, PeerSocketInfo *peerSocketInfo);
116 
117 bool IsSessionExceedLimit(void);
118 
119 int32_t ClientResetIdleTimeoutById(int32_t sessionId);
120 
121 int32_t ClientGetSessionNameByChannelId(int32_t channelId, int32_t channelType, char *sessionName, int32_t len);
122 
123 int32_t ClientRawStreamEncryptDefOptGet(const char *sessionName, bool *isEncrypt);
124 
125 int32_t ClientRawStreamEncryptOptGet(int32_t sessionId, int32_t channelId, int32_t channelType, bool *isEncrypt);
126 
127 int32_t SetSessionIsAsyncById(int32_t sessionId, bool isAsync);
128 
129 int32_t ClientTransSetChannelInfo(const char *sessionName, int32_t sessionId, int32_t channelId, int32_t channelType);
130 
131 void DelSessionStateClosing(void);
132 
133 void AddSessionStateClosing(void);
134 
135 int32_t ClientHandleBindWaitTimer(int32_t socket, uint32_t maxWaitTime, TimerAction action);
136 
IsValidQosInfo(const QosTV qos[],uint32_t qosCount)137 inline bool IsValidQosInfo(const QosTV qos[], uint32_t qosCount)
138 {
139     return (qos == NULL) ? (qosCount == 0) : (qosCount <= QOS_TYPE_BUTT);
140 }
141 
142 int32_t SetSessionInitInfoById(int32_t sessionId);
143 
144 int32_t ClientSetEnableStatusBySocket(int32_t socket, SessionEnableStatus enableStatus);
145 
146 int32_t TryDeleteEmptySessionServer(const char *pkgName, const char *sessionName);
147 
148 int32_t DeleteSocketSession(int32_t sessionId, char *pkgName, char *sessionName);
149 
150 int32_t SetSessionStateBySessionId(int32_t sessionId, SessionState sessionState, int32_t optional);
151 
152 int32_t GetSocketLifecycleAndSessionNameBySessionId(
153     int32_t sessionId, char *sessionName, SocketLifecycleData *lifecycle);
154 
155 int32_t ClientWaitSyncBind(int32_t socket);
156 
157 int32_t ClientSignalSyncBind(int32_t socket, int32_t errCode);
158 
159 int32_t ClientDfsIpcOpenSession(int32_t sessionId, TransInfo *transInfo);
160 
161 void SocketServerStateUpdate(const char *sessionName);
162 
163 int32_t ClientCancelAuthSessionTimer(int32_t sessionId);
164 
165 int32_t ClientSetStatusClosingBySocket(int32_t socket, bool isClosing);
166 
167 int32_t ClientGetChannelOsTypeBySessionId(int32_t sessionId, int32_t *osType);
168 
169 int32_t ClientCacheQosEvent(int32_t socket, QoSEvent event, const QosTV *qos, uint32_t count);
170 
171 int32_t ClientGetCachedQosEventBySocket(int32_t socket, CachedQosEvent *cachedQosEvent);
172 
173 int32_t GetMaxIdleTimeBySocket(int32_t socket, uint32_t *maxIdleTime);
174 
175 int32_t SetMaxIdleTimeBySocket(int32_t socket, uint32_t maxIdleTime);
176 
177 void ClientTransOnPrivilegeClose(const char *peerNetworkId);
178 
179 int32_t TransGetSupportTlvBySocket(int32_t socket, bool *supportTlv, int32_t *optValueSize);
180 
181 int32_t TransSetNeedAckBySocket(int32_t socket, bool needAck);
182 
183 int32_t GetLogicalBandwidth(int32_t socket, int32_t *optValue, int32_t *optValueSize);
184 
185 bool IsRawAuthSession(const char *sessionName);
186 
187 int32_t ClientGetSessionNameBySessionId(int32_t sessionId, char *sessionName);
188 
189 int32_t GetIsAsyncAndTokenTypeBySessionId(int32_t sessionId, bool *isAsync, int32_t *tokenType);
190 
191 int32_t ClientSetLowLatencyBySocket(int32_t socket);
192 
193 int32_t DeletePagingSession(int32_t sessionId, char *pkgName, char *sessionName);
194 
195 int32_t CreatePagingSession(const char *sessionName, int32_t businessType, int32_t socketId,
196     const ISocketListener *socketListener, bool isClient);
197 
198 int32_t ClientGetChannelIdAndTypeBySocketId(int32_t socket, int32_t *type, int32_t *channelId, char *socketName);
199 
200 int32_t ClientForkSocketByChannelId(int32_t socketId, BusinessType type, int32_t *newSocket);
201 
202 int32_t ClientGetChannelBusinessTypeByChannelId(int32_t channelId, int32_t *businessType);
203 
204 int32_t ClientCheckIsD2DBySessionId(int32_t sessionId, bool *isD2D);
205 
206 int32_t ClientGetSessionTypeBySocket(int32_t socket, int32_t *sessionType);
207 
208 int32_t ClientSetFLTos(int32_t socket, TransFlowInfo *flowInfo);
209 
210 #ifdef __cplusplus
211 }
212 #endif
213 #endif // CLIENT_TRANS_SESSION_MANAGER_H
214