• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 CLIENT_TRANS_SESSION_OPERATE_H
17 #define CLIENT_TRANS_SESSION_OPERATE_H
18 
19 #include "inner_socket.h"
20 
21 #include "client_trans_session_manager.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 typedef struct {
28     ListNode node;
29     int32_t socketId;
30     int32_t channelId;
31     int32_t seq;
32     int32_t channelType;
33     uint32_t timeout;
34     bool isMessage;
35 } DataSeqInfo;
36 
37 int32_t GenerateSessionId(void);
38 
39 void DestroySessionId(void);
40 
41 bool IsValidSessionParam(const SessionParam *param);
42 
43 SessionInfo *CreateNewSession(const SessionParam *param);
44 
45 NO_SANITIZE("cfi") DestroySessionInfo *CreateDestroySessionNode(SessionInfo *sessionNode,
46     const ClientSessionServer *server);
47 
48 NO_SANITIZE("cfi") void ClientDestroySession(const ListNode *destroyList, ShutdownReason reason);
49 
50 void DestroyClientSessionServer(ClientSessionServer *server, ListNode *destroyList);
51 
52 ClientSessionServer *GetNewSessionServer(SoftBusSecType type, const char *sessionName,
53     const char *pkgName, const ISessionListener *listener);
54 
55 SessionInfo *CreateNonEncryptSessionInfo(const char *sessionName);
56 
57 void DestroyAllClientSession(const ClientSessionServer *server, ListNode *destroyList);
58 
59 void DestroyClientSessionByNetworkId(const ClientSessionServer *server,
60     const char *networkId, int32_t type, ListNode *destroyList);
61 
62 SessionServerInfo *CreateSessionServerInfoNode(const ClientSessionServer *clientSessionServer);
63 
64 ClientSessionServer *GetNewSocketServer(SoftBusSecType type, const char *sessionName, const char *pkgName);
65 
66 bool IsDistributedDataSession(const char *sessionName);
67 
68 bool IsDifferentDataType(const SessionInfo *sessionInfo, int dataType, bool isEncyptedRawStream);
69 
70 SessionInfo *CreateNewSocketSession(const SessionParam *param);
71 
72 int32_t CheckBindSocketInfo(const SessionInfo *session);
73 
74 void FillSessionParam(SessionParam *param, SessionAttribute *tmpAttr,
75     ClientSessionServer *serverNode, SessionInfo *sessionNode);
76 
77 void ClientConvertRetVal(int32_t socket, int32_t *retOut);
78 
79 void ClientCleanUpIdleTimeoutSocket(const ListNode *destroyList);
80 
81 void ClientCheckWaitTimeOut(const ClientSessionServer *serverNode, SessionInfo *sessionNode,
82     int32_t waitOutSocket[], uint32_t capacity, uint32_t *num);
83 
84 void ClientCleanUpWaitTimeoutSocket(int32_t waitOutSocket[], uint32_t waitOutNum);
85 
86 void ClientUpdateIdleTimeout(const ClientSessionServer *serverNode, SessionInfo *sessionNode, ListNode *destroyList);
87 
88 int32_t ClientDeleteSocketSession(int32_t sessionId);
89 
90 int32_t ClientRemovePermission(const char *busName);
91 
92 int32_t ClientGrantPermission(int uid, int pid, const char *busName);
93 
94 int32_t GetQosValue(const QosTV *qos, uint32_t qosCount, QosType type, int32_t *value, int32_t defVal);
95 
96 int32_t ReCreateSessionServerToServer(ListNode *sessionServerInfoList);
97 
98 void FillDfsSocketParam(
99     SessionParam *param, SessionAttribute *tmpAttr, ClientSessionServer *serverNode, SessionInfo *sessionNode);
100 
101 void PrivilegeDestroyAllClientSession(
102     const ClientSessionServer *server, ListNode *destroyList, const char *peerNetworkId);
103 
104 int32_t ClientRegisterRelationChecker(IFeatureAbilityRelationChecker *relationChecker);
105 
106 int32_t ClientTransCheckCollabRelation(
107     const CollabInfo *sourceInfo, const CollabInfo *sinkInfo, int32_t channelId, int32_t channelType);
108 
109 void DestroyRelationChecker(void);
110 
111 int32_t LockClientDataSeqInfoList(void);
112 
113 void UnlockClientDataSeqInfoList(void);
114 
115 int32_t TransDataSeqInfoListInit(void);
116 
117 void TransDataSeqInfoListDeinit(void);
118 
119 int32_t DataSeqInfoListAddItem(uint32_t dataSeq, int32_t channelId, int32_t socketId, int32_t channelType);
120 
121 int32_t DeleteDataSeqInfoList(uint32_t dataSeq, int32_t channelId);
122 
123 void TransAsyncSendBytesTimeoutProc(void);
124 
125 int32_t GeneratePagingId(void);
126 
127 void DestroyPagingId(void);
128 
129 int32_t ClientDeletePagingSession(int32_t sessionId);
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 #endif // CLIENT_TRANS_SESSION_OPERATE_H
135