• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_sta_feature.h"
17 #include "hdf_base.h"
18 #include "hdf_log.h"
19 #include "securec.h"
20 #include "wifi_hal_cmd.h"
21 #include "wifi_hal_util.h"
22 
23 #ifdef __cplusplus
24 #if __cplusplus
25 extern "C" {
26 #endif
27 #endif
28 
SetScanningMacAddressInner(const struct IWiFiSta * staFeature,unsigned char * scanMac,uint8_t len)29 static int32_t SetScanningMacAddressInner(const struct IWiFiSta *staFeature, unsigned char *scanMac, uint8_t len)
30 {
31     if (staFeature == NULL || scanMac == NULL || len != WIFI_MAC_ADDR_LENGTH) {
32         HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
33         return HDF_ERR_INVALID_PARAM;
34     }
35     return HalCmdSetScanningMacAddress(staFeature->baseFeature.ifName, scanMac, len);
36 }
37 
SetScanningMacAddress(const struct IWiFiSta * staFeature,unsigned char * scanMac,uint8_t len)38 static int32_t SetScanningMacAddress(const struct IWiFiSta *staFeature, unsigned char *scanMac, uint8_t len)
39 {
40     HalMutexLock();
41     int32_t ret = SetScanningMacAddressInner(staFeature, scanMac, len);
42     HalMutexUnlock();
43     return ret;
44 }
45 
StartScanInner(const char * ifName,WifiScan * scan)46 static int32_t StartScanInner(const char *ifName, WifiScan *scan)
47 {
48     if (ifName == NULL || scan == NULL) {
49         HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
50         return HDF_ERR_INVALID_PARAM;
51     }
52     return HalCmdStartScanInner(ifName, scan);
53 }
54 
StartScan(const char * ifName,WifiScan * scan)55 static int32_t StartScan(const char *ifName, WifiScan *scan)
56 {
57     HalMutexLock();
58     int32_t ret = StartScanInner(ifName, scan);
59     HalMutexUnlock();
60     return ret;
61 }
62 
InitStaFeature(struct IWiFiSta ** fe)63 int32_t InitStaFeature(struct IWiFiSta **fe)
64 {
65     if (fe == NULL || *fe == NULL) {
66         HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
67         return HDF_ERR_INVALID_PARAM;
68     }
69     if (InitBaseFeature((struct IWiFiBaseFeature **)fe) != HDF_SUCCESS) {
70         HDF_LOGE("%s: init base feature, line: %d", __FUNCTION__, __LINE__);
71         return HDF_FAILURE;
72     }
73     (*fe)->setScanningMacAddress = SetScanningMacAddress;
74     (*fe)->startScan = StartScan;
75     return HDF_SUCCESS;
76 }
77 
78 #ifdef __cplusplus
79 #if __cplusplus
80 }
81 #endif
82 #endif