1 /*
2 * Copyright (c) 2021-2023 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_LOGI("%s: wifi has started already, line: %d", __FUNCTION__, __LINE__);
44 return HDF_SUCCESS;
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_LOGI("%s: wifi has stopped already, line: %d", __FUNCTION__, __LINE__);
70 return HDF_SUCCESS;
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 == NULL) {
137 HDF_LOGE("%s: networkNode is NULL, line: %d", __FUNCTION__, __LINE__);
138 break;
139 }
140 if (networkNode->ifeature != NULL && networkNode->ifeature->type == type) {
141 HDF_LOGI("%s: feature is existed. type: %d", __FUNCTION__, type);
142 *feature = networkNode->ifeature;
143 return HDF_SUCCESS;
144 }
145 if (networkNode->ifeature == NULL && networkNode->supportMode[type] == 1) {
146 if (memcpy_s((*feature)->ifName, IFNAME_MAX_LEN, networkNode->ifName, strlen(networkNode->ifName)) != EOK) {
147 HDF_LOGE("%s: memcpy_s failed, line: %d", __FUNCTION__, __LINE__);
148 return HDF_FAILURE;
149 }
150 (*feature)->type = type;
151 networkNode->ifeature = *feature;
152 return HDF_SUCCESS;
153 }
154 }
155 HDF_LOGE("%s: cannot find available network, line: %d", __FUNCTION__, __LINE__);
156 return HDF_FAILURE;
157 }
158
CreateFeatureInner(int32_t type,struct IWiFiBaseFeature ** ifeature)159 static int32_t CreateFeatureInner(int32_t type, struct IWiFiBaseFeature **ifeature)
160 {
161 int32_t ret;
162
163 if (ifeature == NULL) {
164 HDF_LOGE("%s: ifeature is null, line: %d", __FUNCTION__, __LINE__);
165 return HDF_FAILURE;
166 }
167 ret = InitFeatureByType(type, ifeature);
168 if (ret != HDF_SUCCESS) {
169 HDF_LOGE("%s: init feature failed, line: %d, error no: %d", __FUNCTION__, __LINE__, ret);
170 return ret;
171 }
172
173 ret = FindValidNetwork(type, ifeature);
174 if (ret != HDF_SUCCESS) {
175 HDF_LOGE("%s: create feature failed, line: %d, error no: %d", __FUNCTION__, __LINE__, ret);
176 if (*ifeature != NULL) {
177 free(*ifeature);
178 *ifeature = NULL;
179 }
180 return ret;
181 }
182 return HDF_SUCCESS;
183 }
184
GetFeatureByIfNameInner(const char * ifName,struct IWiFiBaseFeature ** ifeature)185 static int32_t GetFeatureByIfNameInner(const char *ifName, struct IWiFiBaseFeature **ifeature)
186 {
187 struct DListHead *networkHead = GetNetworkHead();
188 struct IWiFiList *networkNode = NULL;
189
190 if (ifName == NULL) {
191 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
192 return HDF_ERR_INVALID_PARAM;
193 }
194 DLIST_FOR_EACH_ENTRY(networkNode, networkHead, struct IWiFiList, entry) {
195 if (strcmp(networkNode->ifName, ifName) == HDF_SUCCESS) {
196 *ifeature = networkNode->ifeature;
197 return HDF_SUCCESS;
198 }
199 }
200 HDF_LOGE("%s: cannot find feature by ifName, line: %d", __FUNCTION__, __LINE__);
201 return HDF_FAILURE;
202 }
203
DestroyFeatureInner(struct IWiFiBaseFeature * ifeature)204 static int32_t DestroyFeatureInner(struct IWiFiBaseFeature *ifeature)
205 {
206 struct DListHead *networkHead = GetNetworkHead();
207 struct IWiFiList *networkNode = NULL;
208
209 if (ifeature == NULL) {
210 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
211 return HDF_ERR_INVALID_PARAM;
212 }
213
214 DLIST_FOR_EACH_ENTRY(networkNode, networkHead, struct IWiFiList, entry) {
215 if (strcmp(networkNode->ifName, ifeature->ifName) == HDF_SUCCESS) {
216 free(ifeature);
217 networkNode->ifeature = NULL;
218 return HDF_SUCCESS;
219 }
220 }
221 HDF_LOGE("%s: cannot find feature to destroy, line: %d", __FUNCTION__, __LINE__);
222 return HDF_FAILURE;
223 }
224
RegisterEventCallbackInner(OnReceiveFunc onRecFunc,const char * ifName)225 static int32_t RegisterEventCallbackInner(OnReceiveFunc onRecFunc, const char *ifName)
226 {
227 if (onRecFunc == NULL || ifName == NULL) {
228 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
229 return HDF_ERR_INVALID_PARAM;
230 }
231 if (WifiRegisterEventCallback(onRecFunc, WIFI_KERNEL_TO_HAL_CLIENT, ifName) != HDF_SUCCESS) {
232 HDF_LOGE("%s: callback function has been registered, line: %d", __FUNCTION__, __LINE__);
233 return HDF_FAILURE;
234 }
235 return HDF_SUCCESS;
236 }
237
UnregisterEventCallbackInner(OnReceiveFunc onRecFunc,const char * ifName)238 static int32_t UnregisterEventCallbackInner(OnReceiveFunc onRecFunc, const char *ifName)
239 {
240 if (onRecFunc == NULL || ifName == NULL) {
241 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
242 return HDF_ERR_INVALID_PARAM;
243 }
244 WifiUnregisterEventCallback(onRecFunc, WIFI_KERNEL_TO_HAL_CLIENT, ifName);
245 return HDF_SUCCESS;
246 }
247
RegisterHid2dCallbackInner(Hid2dCallback func,const char * ifName)248 static int32_t RegisterHid2dCallbackInner(Hid2dCallback func, const char *ifName)
249 {
250 int32_t ret;
251 if (func == NULL || ifName == NULL) {
252 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
253 return HDF_ERR_INVALID_PARAM;
254 }
255 ret = WifiRegisterHid2dCallback(func, ifName);
256 if (ret != HDF_SUCCESS) {
257 HDF_LOGE("%s: register hid2d callback fail!", __FUNCTION__);
258 }
259 return ret;
260 }
261
UnregisterHid2dCallbackInner(Hid2dCallback func,const char * ifName)262 static int32_t UnregisterHid2dCallbackInner(Hid2dCallback func, const char *ifName)
263 {
264 if (func == NULL || ifName == NULL) {
265 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
266 return HDF_ERR_INVALID_PARAM;
267 }
268 WifiUnregisterHid2dCallback(func, ifName);
269 return HDF_SUCCESS;
270 }
271
ResetDriverInner(uint8_t chipId,const char * ifName)272 static int32_t ResetDriverInner(uint8_t chipId, const char *ifName)
273 {
274 if (ifName == NULL || chipId >= MAX_WLAN_DEVICE) {
275 HDF_LOGE("%s: input parameter invalid, line: %d, chipId = %d", __FUNCTION__, __LINE__, chipId);
276 return HDF_ERR_INVALID_PARAM;
277 }
278 return HalCmdSetResetDriver(chipId, ifName);
279 }
280
GetNetDevInfoInner(struct NetDeviceInfoResult * netDeviceInfoResult)281 static int32_t GetNetDevInfoInner(struct NetDeviceInfoResult *netDeviceInfoResult)
282 {
283 if (netDeviceInfoResult == NULL) {
284 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
285 return HDF_ERR_INVALID_PARAM;
286 }
287 return GetNetDeviceInfo(netDeviceInfoResult);
288 }
289
GetPowerModeInner(const char * ifName,uint8_t * mode)290 static int32_t GetPowerModeInner(const char *ifName, uint8_t *mode)
291 {
292 if (ifName == NULL || mode == NULL) {
293 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
294 return HDF_ERR_INVALID_PARAM;
295 }
296
297 return GetCurrentPowerMode(ifName, mode);
298 }
299
SetPowerModeInner(const char * ifName,uint8_t mode)300 static int32_t SetPowerModeInner(const char *ifName, uint8_t mode)
301 {
302 if (ifName == NULL || mode >= WIFI_POWER_MODE_NUM) {
303 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
304 return HDF_ERR_INVALID_PARAM;
305 }
306 return SetPowerMode(ifName, mode);
307 }
308
StartChannelMeasInner(const char * ifName,const struct MeasParam * measParam)309 static int32_t StartChannelMeasInner(const char *ifName, const struct MeasParam *measParam)
310 {
311 if (ifName == NULL || measParam == NULL) {
312 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
313 return HDF_ERR_INVALID_PARAM;
314 }
315 return StartChannelMeas(ifName, measParam);
316 }
317
GetChannelMeasResultInner(const char * ifName,struct MeasResult * measResult)318 static int32_t GetChannelMeasResultInner(const char *ifName, struct MeasResult *measResult)
319 {
320 if (ifName == NULL || measResult == NULL) {
321 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
322 return HDF_ERR_INVALID_PARAM;
323 }
324 return HDF_ERR_NOT_SUPPORT;
325 }
326
SetProjectionScreenParamInner(const char * ifName,const ProjectionScreenParam * param)327 static int32_t SetProjectionScreenParamInner(const char *ifName, const ProjectionScreenParam *param)
328 {
329 if (ifName == NULL || param == NULL) {
330 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
331 return HDF_ERR_INVALID_PARAM;
332 }
333 return SetProjectionScreenParam(ifName, param);
334 }
335
SendCmdIoctlInner(const char * ifName,int32_t cmdId,const int8_t * paramBuf,uint32_t paramBufLen)336 static int32_t SendCmdIoctlInner(const char *ifName, int32_t cmdId, const int8_t *paramBuf, uint32_t paramBufLen)
337 {
338 if (ifName == NULL || paramBuf == NULL) {
339 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
340 return HDF_ERR_INVALID_PARAM;
341 }
342 return SendCmdIoctl(ifName, cmdId, paramBuf, paramBufLen);
343 }
344
GetStationInfoInner(const char * ifName,StationInfo * info,const uint8_t * mac,uint32_t macLen)345 static int32_t GetStationInfoInner(const char *ifName, StationInfo *info, const uint8_t *mac, uint32_t macLen)
346 {
347 if (ifName == NULL || info == NULL || mac == NULL || macLen < ETH_ADDR_LEN) {
348 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
349 return HDF_ERR_INVALID_PARAM;
350 }
351 return GetStationInfo(ifName, info, mac, macLen);
352 }
353
Start(struct IWiFi * iwifi)354 static int32_t Start(struct IWiFi *iwifi)
355 {
356 HalMutexLock();
357 int32_t ret = StartInner(iwifi);
358 HalMutexUnlock();
359 return ret;
360 }
361
Stop(struct IWiFi * iwifi)362 static int32_t Stop(struct IWiFi *iwifi)
363 {
364 HalMutexLock();
365 int32_t ret = StopInner(iwifi);
366 HalMutexUnlock();
367 return ret;
368 }
369
GetSupportFeature(uint8_t * supType,uint32_t size)370 static int32_t GetSupportFeature(uint8_t *supType, uint32_t size)
371 {
372 HalMutexLock();
373 int32_t ret = GetSupportFeatureInner(supType, size);
374 HalMutexUnlock();
375 return ret;
376 }
377
GetSupportCombo(uint64_t * combo,uint32_t size)378 static int32_t GetSupportCombo(uint64_t *combo, uint32_t size)
379 {
380 HalMutexLock();
381 int32_t ret = GetSupportComboInner(combo, size);
382 HalMutexUnlock();
383 return ret;
384 }
385
CreateFeature(int32_t type,struct IWiFiBaseFeature ** ifeature)386 static int32_t CreateFeature(int32_t type, struct IWiFiBaseFeature **ifeature)
387 {
388 HalMutexLock();
389 int32_t ret = CreateFeatureInner(type, ifeature);
390 HalMutexUnlock();
391 return ret;
392 }
393
GetFeatureByIfName(const char * ifName,struct IWiFiBaseFeature ** ifeature)394 static int32_t GetFeatureByIfName(const char *ifName, struct IWiFiBaseFeature **ifeature)
395 {
396 HalMutexLock();
397 int32_t ret = GetFeatureByIfNameInner(ifName, ifeature);
398 HalMutexUnlock();
399 return ret;
400 }
401
DestroyFeature(struct IWiFiBaseFeature * ifeature)402 static int32_t DestroyFeature(struct IWiFiBaseFeature *ifeature)
403 {
404 HalMutexLock();
405 int32_t ret = DestroyFeatureInner(ifeature);
406 HalMutexUnlock();
407 return ret;
408 }
409
HalRegisterEventCallback(OnReceiveFunc onRecFunc,const char * ifName)410 static int32_t HalRegisterEventCallback(OnReceiveFunc onRecFunc, const char *ifName)
411 {
412 HalMutexLock();
413 int32_t ret = RegisterEventCallbackInner(onRecFunc, ifName);
414 HalMutexUnlock();
415 return ret;
416 }
417
HalUnregisterEventCallback(OnReceiveFunc onRecFunc,const char * ifName)418 static int32_t HalUnregisterEventCallback(OnReceiveFunc onRecFunc, const char *ifName)
419 {
420 HalMutexLock();
421 int32_t ret = UnregisterEventCallbackInner(onRecFunc, ifName);
422 HalMutexUnlock();
423 return ret;
424 }
425
HalRegisterHid2dCallback(Hid2dCallback func,const char * ifName)426 static int32_t HalRegisterHid2dCallback(Hid2dCallback func, const char *ifName)
427 {
428 HalMutexLock();
429 int32_t ret = RegisterHid2dCallbackInner(func, ifName);
430 HalMutexUnlock();
431 return ret;
432 }
433
HalUnregisterHid2dCallback(Hid2dCallback func,const char * ifName)434 static int32_t HalUnregisterHid2dCallback(Hid2dCallback func, const char *ifName)
435 {
436 HalMutexLock();
437 int32_t ret = UnregisterHid2dCallbackInner(func, ifName);
438 HalMutexUnlock();
439 return ret;
440 }
441
ResetDriver(const uint8_t chipId,const char * ifName)442 static int32_t ResetDriver(const uint8_t chipId, const char *ifName)
443 {
444 HalMutexLock();
445 int32_t ret = ResetDriverInner(chipId, ifName);
446 HalMutexUnlock();
447 return ret;
448 }
449
GetNetDevInfo(struct NetDeviceInfoResult * netDeviceInfoResult)450 static int32_t GetNetDevInfo(struct NetDeviceInfoResult *netDeviceInfoResult)
451 {
452 HalMutexLock();
453 int32_t ret = GetNetDevInfoInner(netDeviceInfoResult);
454 HalMutexUnlock();
455 return ret;
456 }
457
WifiGetPowerMode(const char * ifName,uint8_t * mode)458 static int32_t WifiGetPowerMode(const char *ifName, uint8_t *mode)
459 {
460 HalMutexLock();
461 int32_t ret = GetPowerModeInner(ifName, mode);
462 HalMutexUnlock();
463 return ret;
464 }
465
WifiSetPowerMode(const char * ifName,uint8_t mode)466 static int32_t WifiSetPowerMode(const char *ifName, uint8_t mode)
467 {
468 HalMutexLock();
469 int32_t ret = SetPowerModeInner(ifName, mode);
470 HalMutexUnlock();
471 return ret;
472 }
473
WifiStartChannelMeas(const char * ifName,const struct MeasParam * measParam)474 static int32_t WifiStartChannelMeas(const char *ifName, const struct MeasParam *measParam)
475 {
476 HalMutexLock();
477 int32_t ret = StartChannelMeasInner(ifName, measParam);
478 HalMutexUnlock();
479 return ret;
480 }
481
WifiGetChannelMeasResult(const char * ifName,struct MeasResult * measResult)482 static int32_t WifiGetChannelMeasResult(const char *ifName, struct MeasResult *measResult)
483 {
484 HalMutexLock();
485 int32_t ret = GetChannelMeasResultInner(ifName, measResult);
486 HalMutexUnlock();
487 return ret;
488 }
489
WifiSetProjectionScreenParam(const char * ifName,const ProjectionScreenParam * param)490 static int32_t WifiSetProjectionScreenParam(const char *ifName, const ProjectionScreenParam *param)
491 {
492 HalMutexLock();
493 int32_t ret = SetProjectionScreenParamInner(ifName, param);
494 HalMutexUnlock();
495 return ret;
496 }
497
WifiSendCmdIoctl(const char * ifName,int32_t cmdId,const int8_t * paramBuf,uint32_t paramBufLen)498 static int32_t WifiSendCmdIoctl(const char *ifName, int32_t cmdId, const int8_t *paramBuf, uint32_t paramBufLen)
499 {
500 HalMutexLock();
501 int32_t ret = SendCmdIoctlInner(ifName, cmdId, paramBuf, paramBufLen);
502 HalMutexUnlock();
503 return ret;
504 }
505
WifiGetStationInfo(const char * ifName,StationInfo * info,const uint8_t * mac,uint32_t macLen)506 static int32_t WifiGetStationInfo(const char *ifName, StationInfo *info, const uint8_t *mac, uint32_t macLen)
507 {
508 HalMutexLock();
509 int32_t ret = GetStationInfoInner(ifName, info, mac, macLen);
510 HalMutexUnlock();
511 return ret;
512 }
513
WifiConstruct(struct IWiFi ** wifiInstance)514 int32_t WifiConstruct(struct IWiFi **wifiInstance)
515 {
516 static bool isInited = false;
517 static struct IWiFi singleWifiInstance;
518
519 if (!isInited) {
520 if (HalMutexInit() != HDF_SUCCESS) {
521 HDF_LOGE("%s: HalMutexInit failed, line: %d", __FUNCTION__, __LINE__);
522 return HDF_FAILURE;
523 }
524
525 singleWifiInstance.start = Start;
526 singleWifiInstance.stop = Stop;
527 singleWifiInstance.getSupportFeature = GetSupportFeature;
528 singleWifiInstance.getSupportCombo = GetSupportCombo;
529 singleWifiInstance.createFeature = CreateFeature;
530 singleWifiInstance.getFeatureByIfName = GetFeatureByIfName;
531 singleWifiInstance.destroyFeature = DestroyFeature;
532 singleWifiInstance.registerEventCallback = HalRegisterEventCallback;
533 singleWifiInstance.unregisterEventCallback = HalUnregisterEventCallback;
534 singleWifiInstance.resetDriver = ResetDriver;
535 singleWifiInstance.getNetDevInfo = GetNetDevInfo;
536 singleWifiInstance.getPowerMode = WifiGetPowerMode;
537 singleWifiInstance.setPowerMode = WifiSetPowerMode;
538 singleWifiInstance.startChannelMeas = WifiStartChannelMeas;
539 singleWifiInstance.getChannelMeasResult = WifiGetChannelMeasResult;
540 singleWifiInstance.setProjectionScreenParam = WifiSetProjectionScreenParam;
541 singleWifiInstance.sendCmdIoctl = WifiSendCmdIoctl;
542 singleWifiInstance.registerHid2dCallback = HalRegisterHid2dCallback;
543 singleWifiInstance.unregisterHid2dCallback = HalUnregisterHid2dCallback;
544 singleWifiInstance.getStationInfo = WifiGetStationInfo;
545 InitIWiFiList();
546 isInited = true;
547 }
548 (*wifiInstance) = &singleWifiInstance;
549 return HDF_SUCCESS;
550 }
551
WifiDestruct(struct IWiFi ** wifiInstance)552 int32_t WifiDestruct(struct IWiFi **wifiInstance)
553 {
554 if (wifiInstance == NULL) {
555 HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
556 return HDF_ERR_INVALID_PARAM;
557 }
558 *wifiInstance = NULL;
559 if (HalMutexDestroy() != HDF_SUCCESS) {
560 HDF_LOGE("%s: HalMutexDestroy failed, line: %d", __FUNCTION__, __LINE__);
561 return HDF_FAILURE;
562 }
563 return HDF_SUCCESS;
564 }
565
566 #ifdef __cplusplus
567 #if __cplusplus
568 }
569 #endif
570 #endif
571