• 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_2/iwlan_callback.h"
21 #include "v1_2/iwlan_interface.h"
22 #include "wlan_common_cmd.h"
23 #include "wlan_extend_cmd.h"
24 #include "wlan_impl.h"
25 #include "v1_2/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     service->interface.GetApBandwidth = WlanInterfaceGetApBandwidth;
74     service->interface.ResetToFactoryMacAddress = WlanInterfaceResetToFactoryMacAddress;
75     service->interface.SendActionFrame = WlanInterfaceSendActionFrame;
76     service->interface.RegisterActionFrameReceiver = WlanInterfaceRegisterActionFrameReceiver;
77     return &service->interface;
78 }
79 
WlanInterfaceServiceInit(void)80 int32_t WlanInterfaceServiceInit(void)
81 {
82     int32_t ret;
83     ret = WlanInterfaceWifiConstruct();
84     if (ret != HDF_SUCCESS) {
85         HDF_LOGE("%{public}s construct wifi interface failed! error code: %{public}d", __func__, ret);
86         return ret;
87     }
88     ret = WlanExtendInterfaceWifiConstruct();
89     if (ret != HDF_SUCCESS) {
90         HDF_LOGE("%{public}s construct wifi extend interface failed! error code: %{public}d", __func__, ret);
91         return ret;
92     }
93     return ret;
94 }
95 
WlanInterfaceImplRelease(struct IWlanInterface * instance)96 void WlanInterfaceImplRelease(struct IWlanInterface *instance)
97 {
98     if (instance == NULL) {
99         return;
100     }
101     OsalMemFree(instance);
102     if (WlanInterfaceWifiDestruct() != HDF_SUCCESS) {
103         HDF_LOGE("%{public}s destruct WiFi failed!", __func__);
104     }
105     if (WlanExtendInterfaceWifiDestruct() != HDF_SUCCESS) {
106         HDF_LOGE("%{public}s wifi extend interface destruct failed!", __func__);
107     }
108 }
109