• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #include "g_enhance_trans_func_pack.h"
16 
17 #include "g_enhance_trans_func.h"
18 #include "softbus_error_code.h"
19 #include "softbus_init_common.h"
20 
SetDefaultQdiscPacked(void)21 int32_t SetDefaultQdiscPacked(void)
22 {
23     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
24     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->setDefaultQdisc) != SOFTBUS_OK) {
25         return SOFTBUS_OK;
26     }
27     return pfnTransEnhanceFuncList->setDefaultQdisc();
28 }
29 
InitQosPacked(void)30 int32_t InitQosPacked(void)
31 {
32     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
33     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->initQos) != SOFTBUS_OK) {
34         return SOFTBUS_OK;
35     }
36     return pfnTransEnhanceFuncList->initQos();
37 }
38 
NotifyQosChannelClosedPacked(int32_t channelId,int32_t channelType)39 void NotifyQosChannelClosedPacked(int32_t channelId, int32_t channelType)
40 {
41     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
42     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->notifyQosChannelClosed) != SOFTBUS_OK) {
43         return;
44     }
45     return pfnTransEnhanceFuncList->notifyQosChannelClosed(channelId, channelType);
46 }
47 
GetExtQosInfoPacked(const SessionParam * param,QosInfo * qosInfo,uint32_t index,AllocExtendInfo * extendInfo)48 void GetExtQosInfoPacked(const SessionParam *param, QosInfo *qosInfo, uint32_t index, AllocExtendInfo *extendInfo)
49 {
50     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
51     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->getExtQosInfo) != SOFTBUS_OK) {
52         return;
53     }
54     return pfnTransEnhanceFuncList->getExtQosInfo(param, qosInfo, index, extendInfo);
55 }
56 
NotifyQosChannelOpenedPacked(const ChannelInfo * chanInfo)57 int32_t NotifyQosChannelOpenedPacked(const ChannelInfo *chanInfo)
58 {
59     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
60     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->notifyQosChannelOpened) != SOFTBUS_OK) {
61         return SOFTBUS_OK;
62     }
63     return pfnTransEnhanceFuncList->notifyQosChannelOpened(chanInfo);
64 }
65 
TransReversePullUpPacked(const uint32_t chatMode,const uint32_t businessFlag,const char * pkgName)66 int32_t TransReversePullUpPacked(const uint32_t chatMode, const uint32_t businessFlag, const char *pkgName)
67 {
68     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
69     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->transReversePullUp) != SOFTBUS_OK) {
70         return SOFTBUS_OK;
71     }
72     return pfnTransEnhanceFuncList->transReversePullUp(chatMode, businessFlag, pkgName);
73 }
74 
TransGetPkgnameByBusinessFlagPacked(const uint32_t businessFlag,char * pkgName,const uint32_t pkgLen)75 int32_t TransGetPkgnameByBusinessFlagPacked(const uint32_t businessFlag, char *pkgName, const uint32_t pkgLen)
76 {
77     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
78     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->transGetPkgnameByBusinessFlag) != SOFTBUS_OK) {
79         return SOFTBUS_OK;
80     }
81     return pfnTransEnhanceFuncList->transGetPkgnameByBusinessFlag(businessFlag, pkgName, pkgLen);
82 }
83 
InitSoftbusPagingResPullPacked(void)84 int32_t InitSoftbusPagingResPullPacked(void)
85 {
86     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
87     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->initSoftbusPagingResPull) != SOFTBUS_OK) {
88         return SOFTBUS_OK;
89     }
90     return pfnTransEnhanceFuncList->initSoftbusPagingResPull();
91 }
92 
DeInitSoftbusPagingResPullPacked(void)93 void DeInitSoftbusPagingResPullPacked(void)
94 {
95     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
96     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->deInitSoftbusPagingResPull) != SOFTBUS_OK) {
97         return;
98     }
99     return pfnTransEnhanceFuncList->deInitSoftbusPagingResPull();
100 }
101 
InitSoftbusPagingPacked(void)102 int32_t InitSoftbusPagingPacked(void)
103 {
104     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
105     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->initSoftbusPaging) != SOFTBUS_OK) {
106         return SOFTBUS_OK;
107     }
108     return pfnTransEnhanceFuncList->initSoftbusPaging();
109 }
110 
DeInitSoftbusPagingPacked(void)111 void DeInitSoftbusPagingPacked(void)
112 {
113     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
114     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->deInitSoftbusPaging) != SOFTBUS_OK) {
115         return;
116     }
117     return pfnTransEnhanceFuncList->deInitSoftbusPaging();
118 }
119 
TransPagingDeathCallbackPacked(const char * pkgName,int32_t pid)120 void TransPagingDeathCallbackPacked(const char *pkgName, int32_t pid)
121 {
122     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
123     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->transPagingDeathCallback) != SOFTBUS_OK) {
124         return;
125     }
126     return pfnTransEnhanceFuncList->transPagingDeathCallback(pkgName, pid);
127 }
128 
TransHasAndUpdatePagingListenPacked(ProxyChannelInfo * info)129 bool TransHasAndUpdatePagingListenPacked(ProxyChannelInfo *info)
130 {
131     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
132     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->transHasAndUpdatePagingListen) != SOFTBUS_OK) {
133         return true;
134     }
135     return pfnTransEnhanceFuncList->transHasAndUpdatePagingListen(info);
136 }
137 
TransPagingGetPidAndDataByFlgPacked(bool isClient,uint32_t businessFlag,int32_t * pid,char * data,uint32_t * len)138 int32_t TransPagingGetPidAndDataByFlgPacked(
139     bool isClient, uint32_t businessFlag, int32_t *pid, char *data, uint32_t *len)
140 {
141     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
142     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->transPagingGetPidAndDataByFlg) != SOFTBUS_OK) {
143         return SOFTBUS_OK;
144     }
145     return pfnTransEnhanceFuncList->transPagingGetPidAndDataByFlg(isClient, businessFlag, pid, data, len);
146 }
147 
TransDelPagingInfoByBusinessFlagPacked(uint32_t businessFlag)148 int32_t TransDelPagingInfoByBusinessFlagPacked(uint32_t businessFlag)
149 {
150     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
151     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->transDelPagingInfoByBusinessFlag) != SOFTBUS_OK) {
152         return SOFTBUS_OK;
153     }
154     return pfnTransEnhanceFuncList->transDelPagingInfoByBusinessFlag(businessFlag);
155 }
156 
ClientOpenHtpChannelPacked(int32_t channelId,int64_t requestId,const char * localMac,const char * remoteMac)157 int32_t ClientOpenHtpChannelPacked(int32_t channelId, int64_t requestId, const char *localMac, const char *remoteMac)
158 {
159     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
160     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->clientOpenHtpChannel) != SOFTBUS_OK) {
161         return SOFTBUS_OK;
162     }
163     return pfnTransEnhanceFuncList->clientOpenHtpChannel(channelId, requestId, localMac, remoteMac);
164 }
165 
ServerOpenHtpChannelPacked(const char * remoteIp,int64_t flIdentity)166 int32_t ServerOpenHtpChannelPacked(const char *remoteIp, int64_t flIdentity)
167 {
168     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
169     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->serverOpenHtpChannel) != SOFTBUS_OK) {
170         return SOFTBUS_OK;
171     }
172     return pfnTransEnhanceFuncList->serverOpenHtpChannel(remoteIp, flIdentity);
173 }
174 
CloseHtpChannelPacked(int32_t channelId)175 int32_t CloseHtpChannelPacked(int32_t channelId)
176 {
177     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
178     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->closeHtpChannel) != SOFTBUS_OK) {
179         return SOFTBUS_OK;
180     }
181     return pfnTransEnhanceFuncList->closeHtpChannel(channelId);
182 }
183 
ServerUpdateHtpChannelPacked(int64_t flIdentity,int32_t channelId)184 void ServerUpdateHtpChannelPacked(int64_t flIdentity, int32_t channelId)
185 {
186     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
187     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->serverUpdateHtpChannel) != SOFTBUS_OK) {
188         return;
189     }
190     return pfnTransEnhanceFuncList->serverUpdateHtpChannel(flIdentity, channelId);
191 }
192 
CheckHtpPermissionPacked(int32_t uid)193 bool CheckHtpPermissionPacked(int32_t uid)
194 {
195     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
196     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->checkHtpPermission) != SOFTBUS_OK) {
197         return false;
198     }
199     return pfnTransEnhanceFuncList->checkHtpPermission(uid);
200 }
201 
TransProcessGroupTalkieInfoPacked(const char * pkgName)202 void TransProcessGroupTalkieInfoPacked(const char *pkgName)
203 {
204     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
205     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->transProcessGroupTalkieInfo) != SOFTBUS_OK) {
206         return;
207     }
208     return pfnTransEnhanceFuncList->transProcessGroupTalkieInfo(pkgName);
209 }
210 
IsInWhitelistPacked(const char * app)211 bool IsInWhitelistPacked(const char *app)
212 {
213     TransEnhanceFuncList *pfnTransEnhanceFuncList = TransEnhanceFuncListGet();
214     if (pfnTransEnhanceFuncList == NULL) {
215         return true;
216     }
217     if (TransCheckFuncPointer((void *)pfnTransEnhanceFuncList->isInWhitelist) != SOFTBUS_OK) {
218         return true;
219     }
220     return pfnTransEnhanceFuncList->isInWhitelist(app);
221 }