• 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_ap_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 
GetAssociatedStasInner(const struct IWiFiAp * apFeature,struct StaInfo * staInfo,uint32_t size,uint32_t * num)29 static int32_t GetAssociatedStasInner(const struct IWiFiAp *apFeature,
30     struct StaInfo *staInfo, uint32_t size, uint32_t *num)
31 {
32     if (apFeature == NULL || staInfo == NULL || size == 0 || num == NULL) {
33         HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
34         return HDF_ERR_INVALID_PARAM;
35     }
36     return HalCmdGetAssociatedStas(apFeature->baseFeature.ifName, staInfo, size, num);
37 }
38 
SetCountryCodeInner(const struct IWiFiAp * apFeature,const char * code,uint32_t len)39 static int32_t SetCountryCodeInner(const struct IWiFiAp *apFeature, const char *code, uint32_t len)
40 {
41     if (apFeature == NULL || code == NULL || len != strlen(code)) {
42         HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
43         return HDF_ERR_INVALID_PARAM;
44     }
45     return HalCmdSetCountryCode(apFeature->baseFeature.ifName, code, len);
46 }
47 
HalGetAssociatedStas(const struct IWiFiAp * apFeature,struct StaInfo * staInfo,uint32_t count,uint32_t * num)48 static int32_t HalGetAssociatedStas(const struct IWiFiAp *apFeature,
49     struct StaInfo *staInfo, uint32_t count, uint32_t *num)
50 {
51     HalMutexLock();
52     int32_t ret = GetAssociatedStasInner(apFeature, staInfo, count, num);
53     HalMutexUnlock();
54     return ret;
55 }
56 
HalSetCountryCode(const struct IWiFiAp * apFeature,const char * code,uint32_t len)57 static int32_t HalSetCountryCode(const struct IWiFiAp *apFeature, const char *code, uint32_t len)
58 {
59     HalMutexLock();
60     int32_t ret = SetCountryCodeInner(apFeature, code, len);
61     HalMutexUnlock();
62     return ret;
63 }
64 
InitApFeature(struct IWiFiAp ** fe)65 int32_t InitApFeature(struct IWiFiAp **fe)
66 {
67     if (fe == NULL || *fe == NULL) {
68         HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__);
69         return HDF_ERR_INVALID_PARAM;
70     }
71     if (InitBaseFeature((struct IWiFiBaseFeature **)fe) != HDF_SUCCESS) {
72         HDF_LOGE("%s: init base feature, line: %d", __FUNCTION__, __LINE__);
73         return HDF_FAILURE;
74     }
75     (*fe)->getAssociatedStas = HalGetAssociatedStas;
76     (*fe)->setCountryCode = HalSetCountryCode;
77     return HDF_SUCCESS;
78 }
79 
80 #ifdef __cplusplus
81 #if __cplusplus
82 }
83 #endif
84 #endif