• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 #include <securec.h>
16 #include <hdf_base.h>
17 #include <hdf_log.h>
18 #include <osal_time.h>
19 #include <osal_mem.h>
20 #include "v1_1/iwlan_callback.h"
21 #include "v1_1/iwlan_interface.h"
22 #include "wlan_common_cmd.h"
23 #include "wlan_extend_cmd.h"
24 #include "wlan_impl.h"
25 #include "v1_1/iwlan_interface.h"
26 
27 struct WlanInterfaceService {
28     struct IWlanInterface interface;
29 };
30 
WlanInterfaceImplGetInstance(void)31 struct IWlanInterface *WlanInterfaceImplGetInstance(void)
32 {
33     struct WlanInterfaceService *service = (struct WlanInterfaceService *)OsalMemCalloc(
34         sizeof(struct WlanInterfaceService));
35     if (service == NULL) {
36         HDF_LOGE("%{public}s: malloc WlanInterfaceService obj failed!", __func__);
37         return NULL;
38     }
39 
40     service->interface.Start = WlanInterfaceStart;
41     service->interface.Stop = WlanInterfaceStop;
42     service->interface.CreateFeature = WlanInterfaceCreateFeature;
43     service->interface.DestroyFeature = WlanInterfaceDestroyFeature;
44     service->interface.GetAssociatedStas = WlanInterfaceGetAssociatedStas;
45     service->interface.GetChipId = WlanInterfaceGetChipId;
46     service->interface.GetDeviceMacAddress = WlanInterfaceGetDeviceMacAddress;
47     service->interface.GetFeatureByIfName = WlanInterfaceGetFeatureByIfName;
48     service->interface.GetFeatureType = WlanInterfaceGetFeatureType;
49     service->interface.GetFreqsWithBand = WlanInterfaceGetFreqsWithBand;
50     service->interface.GetIfNamesByChipId = WlanInterfaceGetIfNamesByChipId;
51     service->interface.GetNetworkIfaceName = WlanInterfaceGetNetworkIfaceName;
52     service->interface.GetSupportCombo = WlanInterfaceGetSupportCombo;
53     service->interface.GetSupportFeature = WlanInterfaceGetSupportFeature;
54     service->interface.RegisterEventCallback = WlanInterfaceRegisterEventCallback;
55     service->interface.UnregisterEventCallback = WlanInterfaceUnregisterEventCallback;
56     service->interface.ResetDriver = WlanInterfaceResetDriver;
57     service->interface.SetCountryCode = WlanInterfaceSetCountryCode;
58     service->interface.SetMacAddress = WlanInterfaceSetMacAddress;
59     service->interface.SetScanningMacAddress = WlanInterfaceSetScanningMacAddress;
60     service->interface.SetTxPower = WlanInterfaceSetTxPower;
61     service->interface.GetNetDevInfo = WlanInterfaceGetNetDevInfo;
62     service->interface.StartScan = WlanInterfaceStartScan;
63     service->interface.GetPowerMode = WlanInterfaceGetPowerMode;
64     service->interface.SetPowerMode = WlanInterfaceSetPowerMode;
65     service->interface.StartChannelMeas = WlanInterfaceStartChannelMeas;
66     service->interface.GetChannelMeasResult = WlanInterfaceGetChannelMeasResult;
67     service->interface.SetProjectionScreenParam = WlanInterfaceSetProjectionScreenParam;
68     service->interface.WifiSendCmdIoctl = WlanInterfaceWifiSendCmdIoctl;
69     service->interface.GetStaInfo = WlanInterfaceGetStaInfo;
70     service->interface.StartPnoScan = WlanInterfaceStartPnoScan;
71     service->interface.StopPnoScan = WlanInterfaceStopPnoScan;
72     service->interface.GetSignalPollInfo = WlanInterfaceGetSignalPollInfo;
73     return &service->interface;
74 }
75 
WlanInterfaceServiceInit(void)76 int32_t WlanInterfaceServiceInit(void)
77 {
78     int32_t ret;
79     ret = WlanInterfaceWifiConstruct();
80     if (ret != HDF_SUCCESS) {
81         HDF_LOGE("%{public}s construct wifi interface failed! error code: %{public}d", __func__, ret);
82         return ret;
83     }
84     ret = WlanExtendInterfaceWifiConstruct();
85     if (ret != HDF_SUCCESS) {
86         HDF_LOGE("%{public}s construct wifi extend interface failed! error code: %{public}d", __func__, ret);
87         return ret;
88     }
89     return ret;
90 }
91 
WlanInterfaceImplRelease(struct IWlanInterface * instance)92 void WlanInterfaceImplRelease(struct IWlanInterface *instance)
93 {
94     if (instance == NULL) {
95         return;
96     }
97     OsalMemFree(instance);
98     if (WlanInterfaceWifiDestruct() != HDF_SUCCESS) {
99         HDF_LOGE("%{public}s destruct WiFi failed!", __func__);
100     }
101     if (WlanExtendInterfaceWifiDestruct() != HDF_SUCCESS) {
102         HDF_LOGE("%{public}s wifi extend interface destruct failed!", __func__);
103     }
104 }
105