1 /*
2  * Copyright (C) 2021-2022 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 #ifndef OHOS_WIFI_HAL_AP_INTERFACE_H
17 #define OHOS_WIFI_HAL_AP_INTERFACE_H
18 
19 #include "wifi_hal_define.h"
20 #include "wifi_hal_struct.h"
21 
22 #include <stdlib.h>
23 #include <string.h>
24 #include <unistd.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 /**
31  * @Description Start Ap.
32  *
33  * @param id - ap id
34  * @return WifiErrorNo
35  */
36 WifiErrorNo StartSoftAp(int id, char *ifaceName);
37 
38 /**
39  * @Description Start Hostapd.
40  *
41  * @param id - ap id
42  * @return WifiErrorNo
43  */
44 WifiErrorNo StartHostapd(void);
45 
46 /**
47  * @Description Init hostapd hal module.
48  *
49  * @param id - ap id
50  * @return WifiErrorNo
51  */
52 WifiErrorNo StartHostapdHal(int id);
53 
54 /**
55  * @Description Stop Ap.
56  *
57  * @return WifiErrorNo
58  */
59 WifiErrorNo StopSoftAp(int id);
60 
61 /**
62  * @Description Stop hostapd.
63  *
64  * @return WifiErrorNo
65  */
66 WifiErrorNo StopHostapd(void);
67 
68 /**
69  * @Description Release hostapd hal.
70  *
71  * @param id - ap id
72  * @return WifiErrorNo
73  */
74 WifiErrorNo StopHostapdHal(int id);
75 
76 /**
77  * @Description Obtains information about all connected STAs.
78  *
79  * @param infos - Connected STA information array.
80  * @param size - Obtains the size of all sta information arrays and Size of the
81  *               obtained sta information array.
82  * @param id - ap id
83  * @return WifiErrorNo
84  */
85 WifiErrorNo GetStaInfos(char *infos, int32_t *size, int id);
86 
87 /**
88  * @Description Setting the AP Country Code.
89  *
90  * @param code - Country code.
91  * @param id - ap id
92  * @return WifiErrorNo
93  */
94 WifiErrorNo SetCountryCode(const char *code, int id);
95 
96 /**
97  * @Description Setting the startup configuration items of the hostapd.
98  *
99  * @param config - Hostapd startup configuration.
100  * @param id - ap id
101  * @return WifiErrorNo
102  */
103 WifiErrorNo SetHostapdConfig(HostapdConfig *config, int id);
104 
105 /**
106  * @Description To set the blocklist filtering in AP mode to prohibit
107  *              the MAC address connection.
108  *
109  * @param mac - Blocklisted MAC address.
110  * @param lenMac - Blocklist MAC address length.
111  * @param id - ap id
112  * @return WifiErrorNo
113  */
114 WifiErrorNo SetMacFilter(const unsigned char *mac, int lenMac, int id);
115 
116 /**
117  * @Description To set blocklist filtering in AP mode and delete a specified MAC
118  *              address from the blocklist.
119  *
120  * @param mac - Blocklisted MAC address.
121  * @param lenMac - Blocklist MAC address length.
122  * @param id - ap id
123  * @return WifiErrorNo
124  */
125 WifiErrorNo DelMacFilter(const unsigned char *mac, int lenMac, int id);
126 
127 /**
128  * @Description Disconnect the STA with a specified MAC address.
129  *
130  * @param mac - Blocklisted MAC address.
131  * @param lenMac - Blocklist MAC address length.
132  * @param id - ap id
133  * @return WifiErrorNo
134  */
135 WifiErrorNo DisassociateSta(const unsigned char *mac, int lenMac, int id);
136 
137 /**
138  * @Description Obtains the hotspot frequency supported by a specified
139  *              frequency band.
140  *
141  * @param band - Specified frequency band.
142  * @param frequencies - Frequency array.
143  * @param size - Frequency array memory size and Returns the size of the frequency array.
144  * @param id - ap id
145  * @return WifiErrorNo
146  */
147 WifiErrorNo WEAK_FUNC GetValidFrequenciesForBand(int32_t band, int *frequencies, int32_t *size, int id);
148 
149 /**
150  * @Description Set the power mode.
151  *
152  * @param mode - power mode.
153  * @param id - ap id
154  * @return WifiErrorNo
155  */
156 WifiErrorNo WEAK_FUNC WifiSetPowerModel(const int mode, int id);
157 
158 /**
159  * @Description Get the power mode.
160  *
161  * @param mode - power mode.
162  * @param id - ap id
163  * @return WifiErrorNo
164  */
165 WifiErrorNo WEAK_FUNC WifiGetPowerModel(int* mode, int id);
166 
167 void InitCfg(char *ifaceName);
168 #ifdef __cplusplus
169 }
170 #endif
171 #endif