• 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 <securec.h>
16 #include "disc_nstackx_adapter_mock.h"
17 #include "softbus_error_code.h"
18 
AdapterMock()19 AdapterMock::AdapterMock()
20 {
21     mock.store(this);
22 }
23 
~AdapterMock()24 AdapterMock::~AdapterMock()
25 {
26     mock.store(nullptr);
27 }
28 
NSTACKX_Init(const NSTACKX_Parameter * parameter)29 int32_t NSTACKX_Init(const NSTACKX_Parameter *parameter)
30 {
31     return AdapterMock::ActionOfNstackInit(parameter);
32 }
33 
NSTACKX_RegisterCapability(uint32_t capabilityBitmapNum,uint32_t capabilityBitmap[])34 int32_t NSTACKX_RegisterCapability(uint32_t capabilityBitmapNum, uint32_t capabilityBitmap[])
35 {
36     return SOFTBUS_OK;
37 }
38 
NSTACKX_SetFilterCapability(uint32_t capabilityBitmapNum,uint32_t capabilityBitmap[])39 int32_t NSTACKX_SetFilterCapability(uint32_t capabilityBitmapNum, uint32_t capabilityBitmap[])
40 {
41     return SOFTBUS_OK;
42 }
43 
NSTACKX_SendDiscoveryRsp(const NSTACKX_ResponseSettings * responseSettings)44 int32_t NSTACKX_SendDiscoveryRsp(const NSTACKX_ResponseSettings *responseSettings)
45 {
46     return SOFTBUS_OK;
47 }
48 
LnnGetLocalStrInfoByIfnameIdx(InfoKey key,char * info,uint32_t len,int32_t ifIdx)49 int32_t LnnGetLocalStrInfoByIfnameIdx(InfoKey key, char *info, uint32_t len, int32_t ifIdx)
50 {
51     return AdapterMock::ActionOfLnnGetLocalStrInfoByIfnameIdx(key, info, len, ifIdx);
52 }
53 
ActionOfNstackInit(const NSTACKX_Parameter * parameter)54 int32_t AdapterMock::ActionOfNstackInit(const NSTACKX_Parameter *parameter)
55 {
56     deviceFoundCallback_ = *parameter;
57     return SOFTBUS_OK;
58 }
59 
ActionOfLnnGetLocalStrInfoByIfnameIdx(InfoKey key,char * info,uint32_t len,int32_t ifIdx)60 int32_t AdapterMock::ActionOfLnnGetLocalStrInfoByIfnameIdx(InfoKey key, char *info, uint32_t len, int32_t ifIdx)
61 {
62     if (info == NULL) {
63         return SOFTBUS_INVALID_PARAM;
64     }
65 
66     (void)strncpy_s(info, len, "wlan0", strlen("wlan0"));
67     return SOFTBUS_OK;
68 }
69 
InjectDeviceFoundEvent(const NSTACKX_DeviceInfo * deviceInfo,uint32_t deviceCount)70 void AdapterMock::InjectDeviceFoundEvent(const NSTACKX_DeviceInfo *deviceInfo, uint32_t deviceCount)
71 {
72     if (deviceFoundCallback_.onDeviceListChanged) {
73         deviceFoundCallback_.onDeviceListChanged(deviceInfo, deviceCount);
74     }
75 }
76