• 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 
16 #include "trans_tcp_direct_tlv_mock.h"
17 
18 using namespace testing;
19 using namespace testing::ext;
20 
21 namespace OHOS {
22 void *g_transTcpDirectInterface;
TransTcpDirectInterfaceMock()23 TransTcpDirectInterfaceMock::TransTcpDirectInterfaceMock()
24 {
25     g_transTcpDirectInterface = reinterpret_cast<void *>(this);
26 }
27 
~TransTcpDirectInterfaceMock()28 TransTcpDirectInterfaceMock::~TransTcpDirectInterfaceMock()
29 {
30     g_transTcpDirectInterface = nullptr;
31 }
32 
GetTransTcpDirectInterface()33 static TransTcpDirectInterface *GetTransTcpDirectInterface()
34 {
35     return reinterpret_cast<TransTcpDirectInterface *>(g_transTcpDirectInterface);
36 }
37 
38 extern "C" {
TransAssembleTlvData(DataHead * pktHead,uint8_t type,uint8_t * buffer,uint8_t bufferLen,int32_t * bufferSize)39 int32_t TransAssembleTlvData(DataHead *pktHead, uint8_t type, uint8_t *buffer, uint8_t bufferLen, int32_t *bufferSize)
40 {
41     return GetTransTcpDirectInterface()->TransAssembleTlvData(pktHead, type, buffer, bufferLen, bufferSize);
42 }
43 
ClientGetSessionIdByChannelId(int32_t channelId,int32_t channelType,int32_t * sessionId,bool isClosing)44 int32_t ClientGetSessionIdByChannelId(int32_t channelId, int32_t channelType, int32_t *sessionId, bool isClosing)
45 {
46     return GetTransTcpDirectInterface()->ClientGetSessionIdByChannelId(channelId, channelType, sessionId, isClosing);
47 }
48 
ClientGetSessionCallbackAdapterById(int32_t sessionId,SessionListenerAdapter * callbackAdapter,bool * isServer)49 int32_t ClientGetSessionCallbackAdapterById(int32_t sessionId, SessionListenerAdapter *callbackAdapter, bool *isServer)
50 {
51     return GetTransTcpDirectInterface()->ClientGetSessionCallbackAdapterById(sessionId, callbackAdapter, isServer);
52 }
53 
DeleteDataSeqInfoList(uint32_t dataSeq,int32_t channelId)54 int32_t DeleteDataSeqInfoList(uint32_t dataSeq, int32_t channelId)
55 {
56     return GetTransTcpDirectInterface()->DeleteDataSeqInfoList(dataSeq, channelId);
57 }
58 
ClientGetSessionNameByChannelId(int32_t channelId,int32_t channelType,char * sessionName,int32_t len)59 int32_t ClientGetSessionNameByChannelId(int32_t channelId, int32_t channelType, char *sessionName, int32_t len)
60 {
61     return GetTransTcpDirectInterface()->ClientGetSessionNameByChannelId(channelId, channelType, sessionName, len);
62 }
63 
SetIpTos(int fd,uint32_t tos)64 int32_t SetIpTos(int fd, uint32_t tos)
65 {
66     return GetTransTcpDirectInterface()->SetIpTos(fd, tos);
67 }
68 
AddPendingPacket(int32_t channelId,int32_t seqNum,int32_t type)69 int32_t AddPendingPacket(int32_t channelId, int32_t seqNum, int32_t type)
70 {
71     return GetTransTcpDirectInterface()->AddPendingPacket(channelId, seqNum, type);
72 }
73 
GetSupportTlvAndNeedAckById(int32_t channelId,int32_t channelType,bool * supportTlv,bool * needAck)74 int32_t GetSupportTlvAndNeedAckById(int32_t channelId, int32_t channelType, bool *supportTlv, bool *needAck)
75 {
76     return GetTransTcpDirectInterface()->GetSupportTlvAndNeedAckById(channelId, channelType, supportTlv, needAck);
77 }
78 
ReleaseTlvValueBuffer(DataHead * pktHead)79 void ReleaseTlvValueBuffer(DataHead *pktHead)
80 {
81     return GetTransTcpDirectInterface()->ReleaseTlvValueBuffer(pktHead);
82 }
83 
DataSeqInfoListAddItem(uint32_t dataSeq,int32_t channelId,int32_t socketId,int32_t channelType)84 int32_t DataSeqInfoListAddItem(uint32_t dataSeq, int32_t channelId, int32_t socketId, int32_t channelType)
85 {
86     return GetTransTcpDirectInterface()->DataSeqInfoListAddItem(dataSeq, channelId, socketId, channelType);
87 }
88 
ClientTransTdcOnDataReceived(int32_t channelId,const void * data,uint32_t len,SessionPktType type)89 int32_t ClientTransTdcOnDataReceived(int32_t channelId, const void *data, uint32_t len, SessionPktType type)
90 {
91     return GetTransTcpDirectInterface()->ClientTransTdcOnDataReceived(channelId, data, len, type);
92 }
93 
SetMintpSocketTos(int32_t fd,uint32_t tos)94 int32_t SetMintpSocketTos(int32_t fd, uint32_t tos)
95 {
96     return GetTransTcpDirectInterface()->SetMintpSocketTos(fd, tos);
97 }
98 }
99 }
100