1 /*
2 * Copyright (c) 2022 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 "distribute_net_ledger_mock.h"
17 #include "softbus_error_code.h"
18
19 using namespace testing;
20 using namespace testing::ext;
21
22 namespace OHOS {
23 void *g_distriLedgerInterface;
24
DistributeLedgerInterfaceMock()25 DistributeLedgerInterfaceMock::DistributeLedgerInterfaceMock()
26 {
27 g_distriLedgerInterface = reinterpret_cast<void *>(this);
28 }
29
~DistributeLedgerInterfaceMock()30 DistributeLedgerInterfaceMock::~DistributeLedgerInterfaceMock()
31 {
32 g_distriLedgerInterface = nullptr;
33 }
34
GetDistriLedgerInterface()35 static DistributeLedgerInterface *GetDistriLedgerInterface()
36 {
37 return reinterpret_cast<DistributeLedgerInterfaceMock *>(g_distriLedgerInterface);
38 }
39
40 extern "C" {
LnnGetDLHeartbeatTimestamp(const char * networkId,uint64_t * timestamp)41 int32_t LnnGetDLHeartbeatTimestamp(const char *networkId, uint64_t *timestamp)
42 {
43 return GetDistriLedgerInterface()->LnnGetDLHeartbeatTimestamp(networkId, timestamp);
44 }
45
LnnSetDLHeartbeatTimestamp(const char * networkId,const uint64_t timestamp)46 int32_t LnnSetDLHeartbeatTimestamp(const char *networkId, const uint64_t timestamp)
47 {
48 return GetDistriLedgerInterface()->LnnSetDLHeartbeatTimestamp(networkId, timestamp);
49 }
50
LnnGetRemoteStrInfo(const char * netWorkId,InfoKey key,char * info,uint32_t len)51 int32_t LnnGetRemoteStrInfo(const char *netWorkId, InfoKey key, char *info, uint32_t len)
52 {
53 return GetDistriLedgerInterface()->LnnGetRemoteStrInfo(netWorkId, key, info, len);
54 }
LnnGetOnlineStateById(const char * id,IdCategory type)55 bool LnnGetOnlineStateById(const char *id, IdCategory type)
56 {
57 return GetDistriLedgerInterface()->LnnGetOnlineStateById(id, type);
58 }
LnnConvertDLidToUdid(const char * id,IdCategory type)59 const char *LnnConvertDLidToUdid(const char *id, IdCategory type)
60 {
61 return GetDistriLedgerInterface()->LnnConvertDLidToUdid(id, type);
62 }
LnnGetRemoteNumU64Info(const char * networkId,InfoKey key,uint64_t * info)63 int32_t LnnGetRemoteNumU64Info(const char *networkId, InfoKey key, uint64_t *info)
64 {
65 return GetDistriLedgerInterface()->LnnGetRemoteNumU64Info(networkId, key, info);
66 }
ConvertBtMacToBinary(const char * strMac,uint32_t strMacLen,uint8_t * binMac,uint32_t binMacLen)67 int32_t ConvertBtMacToBinary(const char *strMac, uint32_t strMacLen, uint8_t *binMac, uint32_t binMacLen)
68 {
69 return GetDistriLedgerInterface()->ConvertBtMacToBinary(strMac, strMacLen, binMac, binMacLen);
70 }
71 }
72 } // namespace OHOS