1 /*
2 * Copyright (c) 2021-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 "wifi_hal.h"
17 #include <stdbool.h>
18 #include "securec.h"
19 #include "unistd.h"
20 #include "hdf_log.h"
21 #include "wifi_hal_cmd.h"
22 #include "wifi_hal_common.h"
23 #include "wifi_hal_util.h"
24 #include "wifi_driver_client.h"
25
26 #ifdef __cplusplus
27 #if __cplusplus
28 extern "C" {
29 #endif
30 #endif
31
32 static bool g_wifiIsStarted = false;
33
StartInner(const struct IWiFi * iwifi)34 static int32_t StartInner(const struct IWiFi *iwifi)
35 {
36 int32_t ret;
37
38 if (iwifi == NULL) {
39 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
40 return HDF_ERR_INVALID_PARAM;
41 }
42 if (g_wifiIsStarted) {
43 HDF_LOGE("%s: wifi has started already, line: %d", __FUNCTION__, __LINE__);
44 return HDF_FAILURE;
45 }
46 ret = WifiDriverClientInit();
47 if (ret != HDF_SUCCESS) {
48 HDF_LOGE("%s: WifiDriverClientInit failed, line: %d, error no: %d", __FUNCTION__, __LINE__, ret);
49 return ret;
50 }
51
52 ret = HalCmdGetAvailableNetwork();
53 if (ret != HDF_SUCCESS) {
54 HDF_LOGE("%s: HalCmdGetAvailableNetwork failed, line: %d, error no: %d", __FUNCTION__, __LINE__, ret);
55 WifiDriverClientDeinit();
56 return ret;
57 }
58 g_wifiIsStarted = true;
59 return ret;
60 }
61
StopInner(const struct IWiFi * iwifi)62 static int32_t StopInner(const struct IWiFi *iwifi)
63 {
64 if (iwifi == NULL) {
65 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
66 return HDF_ERR_INVALID_PARAM;
67 }
68 if (!g_wifiIsStarted) {
69 HDF_LOGE("%s: wifi has stopped already, line: %d", __FUNCTION__, __LINE__);
70 return HDF_FAILURE;
71 }
72 WifiDriverClientDeinit();
73 ClearIWiFiList();
74 g_wifiIsStarted = false;
75 return HDF_SUCCESS;
76 }
77
GetSupportFeatureInner(uint8_t * supType,uint32_t size)78 static int32_t GetSupportFeatureInner(uint8_t *supType, uint32_t size)
79 {
80 if (supType == NULL || size <= PROTOCOL_80211_IFTYPE_NUM) {
81 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
82 return HDF_ERR_INVALID_PARAM;
83 }
84 return HalCmdGetSupportType(supType);
85 }
86
GetSupportComboInner(uint64_t * combo,uint32_t size)87 static int32_t GetSupportComboInner(uint64_t *combo, uint32_t size)
88 {
89 if (combo == NULL) {
90 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
91 return HDF_ERR_INVALID_PARAM;
92 }
93 return HalCmdGetSupportCombo(combo, size);
94 }
95
InitFeatureByType(int32_t type,struct IWiFiBaseFeature ** ifeature)96 static int32_t InitFeatureByType(int32_t type, struct IWiFiBaseFeature **ifeature)
97 {
98 int32_t ret;
99
100 switch (type) {
101 case PROTOCOL_80211_IFTYPE_AP:
102 *ifeature = (struct IWiFiBaseFeature *)malloc(sizeof(struct IWiFiAp));
103 if (*ifeature == NULL) {
104 HDF_LOGE("%s: malloc failed, line: %d", __FUNCTION__, __LINE__);
105 return HDF_FAILURE;
106 }
107 (void)memset_s(*ifeature, sizeof(struct IWiFiAp), 0, sizeof(struct IWiFiAp));
108 ret = InitApFeature((struct IWiFiAp **)ifeature);
109 break;
110 case PROTOCOL_80211_IFTYPE_STATION:
111 *ifeature = (struct IWiFiBaseFeature *)malloc(sizeof(struct IWiFiSta));
112 if (*ifeature == NULL) {
113 HDF_LOGE("%s: malloc failed, line: %d", __FUNCTION__, __LINE__);
114 return HDF_FAILURE;
115 }
116 (void)memset_s(*ifeature, sizeof(struct IWiFiSta), 0, sizeof(struct IWiFiSta));
117 ret = InitStaFeature((struct IWiFiSta **)ifeature);
118 break;
119 default:
120 HDF_LOGE("%s: type not support, line: %d", __FUNCTION__, __LINE__);
121 return HDF_FAILURE;
122 }
123 if (ret != HDF_SUCCESS) {
124 free(*ifeature);
125 *ifeature = NULL;
126 }
127 return ret;
128 }
129
FindValidNetwork(int32_t type,struct IWiFiBaseFeature ** feature)130 static int32_t FindValidNetwork(int32_t type, struct IWiFiBaseFeature **feature)
131 {
132 struct DListHead *networkHead = GetNetworkHead();
133 struct IWiFiList *networkNode = NULL;
134
135 DLIST_FOR_EACH_ENTRY(networkNode, networkHead, struct IWiFiList, entry) {
136 if (networkNode->ifeature == NULL && networkNode->supportMode[type] == 1) {
137 if (memcpy_s((*feature)->ifName, IFNAME_MAX_LEN, networkNode->ifName, strlen(networkNode->ifName)) != EOK) {
138 HDF_LOGE("%s: memcpy_s failed, line: %d", __FUNCTION__, __LINE__);
139 return HDF_FAILURE;
140 }
141 (*feature)->type = type;
142 networkNode->ifeature = *feature;
143 return HDF_SUCCESS;
144 }
145 }
146 HDF_LOGE("%s: cannot find available network, line: %d", __FUNCTION__, __LINE__);
147 return HDF_FAILURE;
148 }
149
CreateFeatureInner(int32_t type,struct IWiFiBaseFeature ** ifeature)150 static int32_t CreateFeatureInner(int32_t type, struct IWiFiBaseFeature **ifeature)
151 {
152 int32_t ret;
153
154 if (ifeature == NULL) {
155 HDF_LOGE("%s: ifeature is null, line: %d", __FUNCTION__, __LINE__);
156 return HDF_FAILURE;
157 }
158 ret = InitFeatureByType(type, ifeature);
159 if (ret != HDF_SUCCESS) {
160 HDF_LOGE("%s: init feature failed, line: %d, error no: %d", __FUNCTION__, __LINE__, ret);
161 return ret;
162 }
163
164 ret = FindValidNetwork(type, ifeature);
165 if (ret != HDF_SUCCESS) {
166 HDF_LOGE("%s: create feature failed, line: %d, error no: %d", __FUNCTION__, __LINE__, ret);
167 if (*ifeature != NULL) {
168 free(*ifeature);
169 *ifeature = NULL;
170 }
171 return ret;
172 }
173 return HDF_SUCCESS;
174 }
175
GetFeatureByIfNameInner(const char * ifName,struct IWiFiBaseFeature ** ifeature)176 static int32_t GetFeatureByIfNameInner(const char *ifName, struct IWiFiBaseFeature **ifeature)
177 {
178 struct DListHead *networkHead = GetNetworkHead();
179 struct IWiFiList *networkNode = NULL;
180
181 if (ifName == NULL) {
182 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
183 return HDF_ERR_INVALID_PARAM;
184 }
185 DLIST_FOR_EACH_ENTRY(networkNode, networkHead, struct IWiFiList, entry) {
186 if (strcmp(networkNode->ifName, ifName) == HDF_SUCCESS) {
187 *ifeature = networkNode->ifeature;
188 return HDF_SUCCESS;
189 }
190 }
191 HDF_LOGE("%s: cannot find feature by ifName, line: %d", __FUNCTION__, __LINE__);
192 return HDF_FAILURE;
193 }
194
DestroyFeatureInner(struct IWiFiBaseFeature * ifeature)195 static int32_t DestroyFeatureInner(struct IWiFiBaseFeature *ifeature)
196 {
197 struct DListHead *networkHead = GetNetworkHead();
198 struct IWiFiList *networkNode = NULL;
199
200 if (ifeature == NULL) {
201 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
202 return HDF_ERR_INVALID_PARAM;
203 }
204
205 DLIST_FOR_EACH_ENTRY(networkNode, networkHead, struct IWiFiList, entry) {
206 if (strcmp(networkNode->ifName, ifeature->ifName) == HDF_SUCCESS) {
207 free(ifeature);
208 networkNode->ifeature = NULL;
209 return HDF_SUCCESS;
210 }
211 }
212 HDF_LOGE("%s: cannot find feature to destroy, line: %d", __FUNCTION__, __LINE__);
213 return HDF_FAILURE;
214 }
215
RegisterEventCallbackInner(OnReceiveFunc onRecFunc,const char * ifName)216 static int32_t RegisterEventCallbackInner(OnReceiveFunc onRecFunc, const char *ifName)
217 {
218 if (onRecFunc == NULL || ifName == NULL) {
219 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
220 return HDF_ERR_INVALID_PARAM;
221 }
222 if (WifiRegisterEventCallback(onRecFunc, WIFI_KERNEL_TO_HAL_CLIENT, ifName) != HDF_SUCCESS) {
223 HDF_LOGE("%s: callback function has been registered, line: %d", __FUNCTION__, __LINE__);
224 return HDF_FAILURE;
225 }
226 return HDF_SUCCESS;
227 }
228
UnregisterEventCallbackInner(OnReceiveFunc onRecFunc,const char * ifName)229 static int32_t UnregisterEventCallbackInner(OnReceiveFunc onRecFunc, const char *ifName)
230 {
231 if (onRecFunc == NULL || ifName == NULL) {
232 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
233 return HDF_ERR_INVALID_PARAM;
234 }
235 WifiUnregisterEventCallback(onRecFunc, WIFI_KERNEL_TO_HAL_CLIENT, ifName);
236 return HDF_SUCCESS;
237 }
238
RegisterHid2dCallbackInner(Hid2dCallback func,const char * ifName)239 static int32_t RegisterHid2dCallbackInner(Hid2dCallback func, const char *ifName)
240 {
241 int32_t ret;
242 if (func == NULL || ifName == NULL) {
243 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
244 return HDF_ERR_INVALID_PARAM;
245 }
246 ret = WifiRegisterHid2dCallback(func, ifName);
247 if (ret != HDF_SUCCESS) {
248 HDF_LOGE("%s: register hid2d callback fail!", __FUNCTION__);
249 }
250 return ret;
251 }
252
UnregisterHid2dCallbackInner(Hid2dCallback func,const char * ifName)253 static int32_t UnregisterHid2dCallbackInner(Hid2dCallback func, const char *ifName)
254 {
255 if (func == NULL || ifName == NULL) {
256 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
257 return HDF_ERR_INVALID_PARAM;
258 }
259 WifiUnregisterHid2dCallback(func, ifName);
260 return HDF_SUCCESS;
261 }
262
ResetDriverInner(uint8_t chipId,const char * ifName)263 static int32_t ResetDriverInner(uint8_t chipId, const char *ifName)
264 {
265 if (ifName == NULL || chipId >= MAX_WLAN_DEVICE) {
266 HDF_LOGE("%s: input parameter invalid, line: %d, chipId = %d", __FUNCTION__, __LINE__, chipId);
267 return HDF_ERR_INVALID_PARAM;
268 }
269 return HalCmdSetResetDriver(chipId, ifName);
270 }
271
GetNetDevInfoInner(struct NetDeviceInfoResult * netDeviceInfoResult)272 static int32_t GetNetDevInfoInner(struct NetDeviceInfoResult *netDeviceInfoResult)
273 {
274 if (netDeviceInfoResult == NULL) {
275 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
276 return HDF_ERR_INVALID_PARAM;
277 }
278 return GetNetDeviceInfo(netDeviceInfoResult);
279 }
280
GetPowerModeInner(const char * ifName,uint8_t * mode)281 static int32_t GetPowerModeInner(const char *ifName, uint8_t *mode)
282 {
283 if (ifName == NULL || mode == NULL) {
284 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
285 return HDF_ERR_INVALID_PARAM;
286 }
287
288 return GetCurrentPowerMode(ifName, mode);
289 }
290
SetPowerModeInner(const char * ifName,uint8_t mode)291 static int32_t SetPowerModeInner(const char *ifName, uint8_t mode)
292 {
293 if (ifName == NULL || mode >= WIFI_POWER_MODE_NUM) {
294 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
295 return HDF_ERR_INVALID_PARAM;
296 }
297 return SetPowerMode(ifName, mode);
298 }
299
StartChannelMeasInner(const char * ifName,const struct MeasParam * measParam)300 static int32_t StartChannelMeasInner(const char *ifName, const struct MeasParam *measParam)
301 {
302 if (ifName == NULL || measParam == NULL) {
303 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
304 return HDF_ERR_INVALID_PARAM;
305 }
306 return StartChannelMeas(ifName, measParam);
307 }
308
GetChannelMeasResultInner(const char * ifName,struct MeasResult * measResult)309 static int32_t GetChannelMeasResultInner(const char *ifName, struct MeasResult *measResult)
310 {
311 if (ifName == NULL || measResult == NULL) {
312 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
313 return HDF_ERR_INVALID_PARAM;
314 }
315 return HDF_ERR_NOT_SUPPORT;
316 }
317
SetProjectionScreenParamInner(const char * ifName,const ProjScrnCmdParam * param)318 static int32_t SetProjectionScreenParamInner(const char *ifName, const ProjScrnCmdParam *param)
319 {
320 if (ifName == NULL || param == NULL) {
321 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
322 return HDF_ERR_INVALID_PARAM;
323 }
324 return SetProjectionScreenParam(ifName, param);
325 }
326
SendCmdIoctlInner(const char * ifName,int32_t cmdId,const int8_t * paramBuf,uint32_t paramBufLen)327 static int32_t SendCmdIoctlInner(const char *ifName, int32_t cmdId, const int8_t *paramBuf, uint32_t paramBufLen)
328 {
329 if (ifName == NULL || paramBuf == NULL) {
330 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
331 return HDF_ERR_INVALID_PARAM;
332 }
333 return SendCmdIoctl(ifName, cmdId, paramBuf, paramBufLen);
334 }
335
GetStationInfoInner(const char * ifName,StationInfo * info,const uint8_t * mac,uint32_t macLen)336 static int32_t GetStationInfoInner(const char *ifName, StationInfo *info, const uint8_t *mac, uint32_t macLen)
337 {
338 if (ifName == NULL || info == NULL || mac == NULL || macLen < ETH_ADDR_LEN) {
339 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
340 return HDF_ERR_INVALID_PARAM;
341 }
342 return GetStationInfo(ifName, info, mac, macLen);
343 }
344
Start(struct IWiFi * iwifi)345 static int32_t Start(struct IWiFi *iwifi)
346 {
347 HalMutexLock();
348 int32_t ret = StartInner(iwifi);
349 HalMutexUnlock();
350 return ret;
351 }
352
Stop(struct IWiFi * iwifi)353 static int32_t Stop(struct IWiFi *iwifi)
354 {
355 HalMutexLock();
356 int32_t ret = StopInner(iwifi);
357 HalMutexUnlock();
358 return ret;
359 }
360
GetSupportFeature(uint8_t * supType,uint32_t size)361 static int32_t GetSupportFeature(uint8_t *supType, uint32_t size)
362 {
363 HalMutexLock();
364 int32_t ret = GetSupportFeatureInner(supType, size);
365 HalMutexUnlock();
366 return ret;
367 }
368
GetSupportCombo(uint64_t * combo,uint32_t size)369 static int32_t GetSupportCombo(uint64_t *combo, uint32_t size)
370 {
371 HalMutexLock();
372 int32_t ret = GetSupportComboInner(combo, size);
373 HalMutexUnlock();
374 return ret;
375 }
376
CreateFeature(int32_t type,struct IWiFiBaseFeature ** ifeature)377 static int32_t CreateFeature(int32_t type, struct IWiFiBaseFeature **ifeature)
378 {
379 HalMutexLock();
380 int32_t ret = CreateFeatureInner(type, ifeature);
381 HalMutexUnlock();
382 return ret;
383 }
384
GetFeatureByIfName(const char * ifName,struct IWiFiBaseFeature ** ifeature)385 static int32_t GetFeatureByIfName(const char *ifName, struct IWiFiBaseFeature **ifeature)
386 {
387 HalMutexLock();
388 int32_t ret = GetFeatureByIfNameInner(ifName, ifeature);
389 HalMutexUnlock();
390 return ret;
391 }
392
DestroyFeature(struct IWiFiBaseFeature * ifeature)393 static int32_t DestroyFeature(struct IWiFiBaseFeature *ifeature)
394 {
395 HalMutexLock();
396 int32_t ret = DestroyFeatureInner(ifeature);
397 HalMutexUnlock();
398 return ret;
399 }
400
HalRegisterEventCallback(OnReceiveFunc onRecFunc,const char * ifName)401 static int32_t HalRegisterEventCallback(OnReceiveFunc onRecFunc, const char *ifName)
402 {
403 HalMutexLock();
404 int32_t ret = RegisterEventCallbackInner(onRecFunc, ifName);
405 HalMutexUnlock();
406 return ret;
407 }
408
HalUnregisterEventCallback(OnReceiveFunc onRecFunc,const char * ifName)409 static int32_t HalUnregisterEventCallback(OnReceiveFunc onRecFunc, const char *ifName)
410 {
411 HalMutexLock();
412 int32_t ret = UnregisterEventCallbackInner(onRecFunc, ifName);
413 HalMutexUnlock();
414 return ret;
415 }
416
HalRegisterHid2dCallback(Hid2dCallback func,const char * ifName)417 static int32_t HalRegisterHid2dCallback(Hid2dCallback func, const char *ifName)
418 {
419 HalMutexLock();
420 int32_t ret = RegisterHid2dCallbackInner(func, ifName);
421 HalMutexUnlock();
422 return ret;
423 }
424
HalUnregisterHid2dCallback(Hid2dCallback func,const char * ifName)425 static int32_t HalUnregisterHid2dCallback(Hid2dCallback func, const char *ifName)
426 {
427 HalMutexLock();
428 int32_t ret = UnregisterHid2dCallbackInner(func, ifName);
429 HalMutexUnlock();
430 return ret;
431 }
432
ResetDriver(const uint8_t chipId,const char * ifName)433 static int32_t ResetDriver(const uint8_t chipId, const char *ifName)
434 {
435 HalMutexLock();
436 int32_t ret = ResetDriverInner(chipId, ifName);
437 HalMutexUnlock();
438 return ret;
439 }
440
GetNetDevInfo(struct NetDeviceInfoResult * netDeviceInfoResult)441 static int32_t GetNetDevInfo(struct NetDeviceInfoResult *netDeviceInfoResult)
442 {
443 HalMutexLock();
444 int32_t ret = GetNetDevInfoInner(netDeviceInfoResult);
445 HalMutexUnlock();
446 return ret;
447 }
448
WifiGetPowerMode(const char * ifName,uint8_t * mode)449 static int32_t WifiGetPowerMode(const char *ifName, uint8_t *mode)
450 {
451 HalMutexLock();
452 int32_t ret = GetPowerModeInner(ifName, mode);
453 HalMutexUnlock();
454 return ret;
455 }
456
WifiSetPowerMode(const char * ifName,uint8_t mode)457 static int32_t WifiSetPowerMode(const char *ifName, uint8_t mode)
458 {
459 HalMutexLock();
460 int32_t ret = SetPowerModeInner(ifName, mode);
461 HalMutexUnlock();
462 return ret;
463 }
464
WifiStartChannelMeas(const char * ifName,const struct MeasParam * measParam)465 static int32_t WifiStartChannelMeas(const char *ifName, const struct MeasParam *measParam)
466 {
467 HalMutexLock();
468 int32_t ret = StartChannelMeasInner(ifName, measParam);
469 HalMutexUnlock();
470 return ret;
471 }
472
WifiGetChannelMeasResult(const char * ifName,struct MeasResult * measResult)473 static int32_t WifiGetChannelMeasResult(const char *ifName, struct MeasResult *measResult)
474 {
475 HalMutexLock();
476 int32_t ret = GetChannelMeasResultInner(ifName, measResult);
477 HalMutexUnlock();
478 return ret;
479 }
480
WifiSetProjectionScreenParam(const char * ifName,const ProjScrnCmdParam * param)481 static int32_t WifiSetProjectionScreenParam(const char *ifName, const ProjScrnCmdParam *param)
482 {
483 HalMutexLock();
484 int32_t ret = SetProjectionScreenParamInner(ifName, param);
485 HalMutexUnlock();
486 return ret;
487 }
488
WifiSendCmdIoctl(const char * ifName,int32_t cmdId,const int8_t * paramBuf,uint32_t paramBufLen)489 static int32_t WifiSendCmdIoctl(const char *ifName, int32_t cmdId, const int8_t *paramBuf, uint32_t paramBufLen)
490 {
491 HalMutexLock();
492 int32_t ret = SendCmdIoctlInner(ifName, cmdId, paramBuf, paramBufLen);
493 HalMutexUnlock();
494 return ret;
495 }
496
WifiGetStationInfo(const char * ifName,StationInfo * info,const uint8_t * mac,uint32_t macLen)497 static int32_t WifiGetStationInfo(const char *ifName, StationInfo *info, const uint8_t *mac, uint32_t macLen)
498 {
499 HalMutexLock();
500 int32_t ret = GetStationInfoInner(ifName, info, mac, macLen);
501 HalMutexUnlock();
502 return ret;
503 }
504
WifiConstruct(struct IWiFi ** wifiInstance)505 int32_t WifiConstruct(struct IWiFi **wifiInstance)
506 {
507 static bool isInited = false;
508 static struct IWiFi singleWifiInstance;
509
510 if (!isInited) {
511 if (HalMutexInit() != HDF_SUCCESS) {
512 HDF_LOGE("%s: HalMutexInit failed, line: %d", __FUNCTION__, __LINE__);
513 return HDF_FAILURE;
514 }
515
516 singleWifiInstance.start = Start;
517 singleWifiInstance.stop = Stop;
518 singleWifiInstance.getSupportFeature = GetSupportFeature;
519 singleWifiInstance.getSupportCombo = GetSupportCombo;
520 singleWifiInstance.createFeature = CreateFeature;
521 singleWifiInstance.getFeatureByIfName = GetFeatureByIfName;
522 singleWifiInstance.destroyFeature = DestroyFeature;
523 singleWifiInstance.registerEventCallback = HalRegisterEventCallback;
524 singleWifiInstance.unregisterEventCallback = HalUnregisterEventCallback;
525 singleWifiInstance.resetDriver = ResetDriver;
526 singleWifiInstance.getNetDevInfo = GetNetDevInfo;
527 singleWifiInstance.getPowerMode = WifiGetPowerMode;
528 singleWifiInstance.setPowerMode = WifiSetPowerMode;
529 singleWifiInstance.startChannelMeas = WifiStartChannelMeas;
530 singleWifiInstance.getChannelMeasResult = WifiGetChannelMeasResult;
531 singleWifiInstance.setProjectionScreenParam = WifiSetProjectionScreenParam;
532 singleWifiInstance.sendCmdIoctl = WifiSendCmdIoctl;
533 singleWifiInstance.registerHid2dCallback = HalRegisterHid2dCallback;
534 singleWifiInstance.unregisterHid2dCallback = HalUnregisterHid2dCallback;
535 singleWifiInstance.getStationInfo = WifiGetStationInfo;
536 InitIWiFiList();
537 isInited = true;
538 }
539 (*wifiInstance) = &singleWifiInstance;
540 return HDF_SUCCESS;
541 }
542
WifiDestruct(struct IWiFi ** wifiInstance)543 int32_t WifiDestruct(struct IWiFi **wifiInstance)
544 {
545 if (wifiInstance == NULL) {
546 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
547 return HDF_ERR_INVALID_PARAM;
548 }
549 *wifiInstance = NULL;
550 if (HalMutexDestroy() != HDF_SUCCESS) {
551 HDF_LOGE("%s: HalMutexDestroy failed, line: %d", __FUNCTION__, __LINE__);
552 return HDF_FAILURE;
553 }
554 return HDF_SUCCESS;
555 }
556
557 #ifdef __cplusplus
558 #if __cplusplus
559 }
560 #endif
561 #endif
562