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 #ifndef OHOS_WIFI_HAL_STA_INTERFACE_H
17 #define OHOS_WIFI_HAL_STA_INTERFACE_H
18 
19 #include <stdlib.h>
20 #include <string.h>
21 #include <unistd.h>
22 #include <dirent.h>
23 #include <stdio.h>
24 #include <stdbool.h>
25 #include <sys/types.h>
26 #include "wifi_hal_define.h"
27 #include "wifi_hal_struct.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 /**
34  * @Description Start WiFi.
35  *
36  * @return WifiErrorNo
37  */
38 WifiErrorNo Start(void);
39 
40 /**
41  * @Description Stop WiFi.
42  *
43  * @return WifiErrorNo
44  */
45 WifiErrorNo Stop(void);
46 
47 /**
48  * @Description Stop Wifi, No reference counting check.
49  *
50  * @return WifiErrorNo
51  */
52 WifiErrorNo ForceStop(void);
53 
54 /**
55  * @Description Start wpa_supplicant.
56  *
57  * @return WifiErrorNo
58  */
59 WifiErrorNo StartSupplicant(void);
60 
61 /**
62  * @Description Stop wpa_supplicant.
63  *
64  * @return WifiErrorNo
65  */
66 WifiErrorNo StopSupplicant(void);
67 
68 /**
69  * @Description Connect wpa_supplicant.
70  *
71  * @return WifiErrorNo
72  */
73 WifiErrorNo ConnectSupplicant(void);
74 
75 /**
76  * @Description Disconnect wpa_supplicant.
77  *
78  * @return WifiErrorNo
79  */
80 WifiErrorNo DisconnectSupplicant(void);
81 
82 /**
83  * @Description Send a request to wpa_supplicant.
84  *
85  * @param buf - Request information array.
86  * @param bufSize - Request message size.
87  * @return WifiErrorNo
88  */
89 WifiErrorNo RequestToSupplicant(const unsigned char *buf, int32_t bufSize);
90 
91 /**
92  * @Description Start Scanning.
93  *
94  * @param settings - Scanning parameters.
95  * @return WifiErrorNo
96  */
97 WifiErrorNo StartScan(const ScanSettings *settings);
98 
99 /**
100  * @Description Obtain the scanning result.
101  *
102  * @param results - Scan result array.
103  * @param size - Size of the scan result array and returns the actual size of the
104  *               scan result array.
105  * @return WifiErrorNo
106  */
107 WifiErrorNo GetScanInfos(ScanInfo *results, int *size);
108 
109 /**
110  * @Description Start PNO scanning.
111  *
112  * @param settings - PNO scanning parameters.
113  * @return WifiErrorNo
114  */
115 WifiErrorNo StartPnoScan(const PnoScanSettings *settings);
116 
117 /**
118  * @Description Stop PNO scanning.
119  *
120  * @return WifiErrorNo
121  */
122 WifiErrorNo StopPnoScan(void);
123 
124 /**
125  * @Description Wi-Fi connect.
126  *
127  * @param networkId - Network ID.
128  * @return WifiErrorNo
129  */
130 WifiErrorNo Connect(int networkId);
131 
132 /**
133  * @Description Wi-Fi reconnect.
134  *
135  * @return WifiErrorNo
136  */
137 WifiErrorNo Reconnect(void);
138 
139 /**
140  * @Description Wi-Fi reassociation.
141  *
142  * @return WifiErrorNo
143  */
144 WifiErrorNo Reassociate(void);
145 
146 /**
147  * @Description Disconnecting a Wi-Fi Connection.
148  *
149  * @return WifiErrorNo
150  */
151 WifiErrorNo Disconnect(void);
152 
153 /**
154  * @Description Turn on/off power save mode for the interface.
155  *
156  * @param enable
157  * @return WifiErrorNo
158  */
159 WifiErrorNo SetPowerSave(int enable);
160 
161 /**
162  * @Description Obtaining the STA Support Capability.
163  *
164  * @param capabilities - STA capability.
165  * @return WifiErrorNo
166  */
167 WifiErrorNo GetStaCapabilities(int32_t *capabilities);
168 
169 /**
170  * @Description Obtaining the MAC Address of a STA.
171  *
172  * @param mac - Mac Message.
173  * @param lenMac - Size of the array input when the MAC address is requested and get
174  *                 mac message array size.
175  * @return WifiErrorNo
176  */
177 WifiErrorNo GetDeviceMacAddress(unsigned char *mac, int *lenMac);
178 
179 /**
180  * @Description Obtains the frequencies supported by a specified frequency band.
181  *
182  * @param band - Frequency band.
183  * @param frequencies - Frequency array information.
184  * @param size - Request FrequencyArray Size and get the size of the frequency array.
185  * @return WifiErrorNo
186  */
187 WifiErrorNo GetFrequencies(int32_t band, int *frequencies, int32_t *size);
188 
189 /**
190  * @Description Sets the MAC address of the Wi-Fi connection.
191  *
192  * @param mac - Mac Address.
193  * @param lenMac - Mac Address array size.
194  * @param portType - Port Type
195  * @return WifiErrorNo
196  */
197 WifiErrorNo WEAK_FUNC SetAssocMacAddr(const unsigned char *mac, int lenMac, const int portType);
198 
199 /**
200  * @Description Sets the MAC address for Wi-Fi scanning.
201  *
202  * @param mac - Mac Address.
203  * @param lenMac - Mac Address array size.
204  * @return WifiErrorNo
205  */
206 WifiErrorNo SetScanningMacAddress(const unsigned char *mac, int lenMac);
207 
208 /**
209  * @Description Disconnect the BSSID of the last roaming subscriber.
210  *
211  * @param mac - Mac Address.
212  * @param lenMac - Mac Address array size.
213  * @return WifiErrorNo
214  */
215 WifiErrorNo DeauthLastRoamingBssid(const unsigned char *mac, int lenMac);
216 
217 /**
218  * @Description Get total supported feature.
219  *
220  * @param feature - Attributes.
221  * @return WifiErrorNo
222  */
223 WifiErrorNo GetSupportFeature(long *feature);
224 
225 /**
226  * @Description Send instructions to the Wi-Fi driver or chip.
227  *
228  * @param ifname
229  * @param cmdid - Command ID.
230  * @param buf
231  * @param bufSize
232  * @return WifiErrorNo
233  */
234 WifiErrorNo RunCmd(const char *ifname, int32_t cmdid, const unsigned char *buf, int32_t bufSize);
235 
236 /**
237  * @Description Set the Wi-Fi transmit power.
238  *
239  * @param power - Transmit power.
240  * @return WifiErrorNo
241  */
242 WifiErrorNo SetWifiTxPower(int32_t power);
243 
244 /**
245  * @Description - Deleting a Network.
246  *
247  * @param networkId - Network id.
248  * @return WifiErrorNo
249  */
250 WifiErrorNo RemoveNetwork(int networkId);
251 
252 /**
253  * @Description Send Add_network to the WPA and return the network ID.
254  *
255  * @param networkId - Network id.
256  * @return WifiErrorNo
257  */
258 WifiErrorNo AddNetwork(int *networkId);
259 
260 /**
261  * @Description Enable a network.
262  *
263  * @param networkId - Network id.
264  * @return WifiErrorNo
265  */
266 WifiErrorNo EnableNetwork(int networkId);
267 
268 /**
269  * @Description Disable a network.
270  *
271  * @param networkId - Network id.
272  * @return WifiErrorNo
273  */
274 WifiErrorNo DisableNetwork(int networkId);
275 
276 /**
277  * @Description Setting the network.
278  *
279  * @param networkId - Network ID.
280  * @param confs - Network configuration array to be set.
281  * @param size - Size of the network configuration array to be set.
282  * @return WifiErrorNo
283  */
284 WifiErrorNo SetNetwork(int networkId, const SetNetworkConfig *confs, int size);
285 
286 /**
287  * @Description Save the network.
288  *
289  * @return WifiErrorNo
290  */
291 WifiErrorNo SaveNetworkConfig(void);
292 
293 /**
294  * @Description Enabling WPS in PBC Mode.
295  *
296  * @param param
297  * @return WifiErrorNo
298  */
299 WifiErrorNo StartWpsPbcMode(const WifiWpsParam *param);
300 
301 /**
302  * @Description Enable PIN mode WPS.
303  *
304  * @param param
305  * @param pinCode
306  * @return WifiErrorNo
307  */
308 WifiErrorNo StartWpsPinMode(const WifiWpsParam *param, int *pinCode);
309 
310 /**
311  * @Description Stop wps.
312  *
313  * @return WifiErrorNo
314  */
315 WifiErrorNo StopWps(void);
316 
317 /**
318  * @Description Obtains the roaming support capability.
319  *
320  * @param capability - Obtains the roaming support capability.
321  * @return WifiErrorNo
322  */
323 WifiErrorNo GetRoamingCapabilities(WifiRoamCapability *capability);
324 
325 /**
326  * @Description Setting Roaming Configurations.
327  *
328  * @param blocklist - Ssid list.
329  * @param blocksize - Block size.
330  * @param trustlist - Ssid list.
331  * @param trustsize - trust size.
332  * @return WifiErrorNo
333  */
334 WifiErrorNo SetRoamConfig(char **blocklist, int blocksize, char **trustlist, int trustsize);
335 
336 /**
337  * @Description Set country code.
338  *
339  * @param countryCode - Country code.
340  * @return WifiErrorNo
341  */
342 WifiErrorNo WpaSetCountryCode(const char *countryCode);
343 
344 /**
345  * @Description Get country code.
346  *
347  * @param countryCode - Country code.
348  * @param codeSize - Size of the memory applied for by the address specified by countryCode.
349  * @return WifiErrorNo
350  */
351 WifiErrorNo WpaGetCountryCode(char *countryCode, int codeSize);
352 
353 /**
354  * @Description WpaGetNetWork Info.
355  *
356  * @param conf
357  * @return WifiErrorNo
358  */
359 WifiErrorNo WpaGetNetWork(GetNetworkConfig *conf);
360 
361 /**
362  * @Description Wpa_s disable/enable(0/1) automatic reconnection.
363  *
364  * @param enable
365  * @return WifiErrorNo
366  */
367 WifiErrorNo WpaAutoConnect(int enable);
368 
369 /**
370  * @Description Clearing the wpa Blocklist.
371  *
372  * @return WifiErrorNo
373  */
374 WifiErrorNo WpaBlocklistClear(void);
375 
376 /**
377  * @Description Obtaining the Network List.
378  *
379  * @param WifiNetworkInfo - Array pointer of the network info structure type.
380  * @param size - Number of infos that can be stored in the memory to which
381  *               the network info pointer points.
382  * @return WifiErrorNo
383  */
384 WifiErrorNo GetNetworkList(WifiNetworkInfo *infos, int *size);
385 
386 /**
387  * @Description Get current connect signal info, rssi, linkspeed, noise ...
388  *
389  * @param endBssid - peer end bssid, i.e. linked ap's bssid
390  * @param info - signal info
391  * @return WifiErrorNo
392  */
393 WifiErrorNo GetConnectSignalInfo(const char *endBssid, WpaSignalInfo *info);
394 
395 /**
396  * @Description Send suspend mode to wpa
397  *
398  * @param mode - true for suspend mode, false for resume mode.
399  * @return WifiErrorNo
400  */
401 WifiErrorNo SetSuspendMode(bool mode);
402 
403 /**
404  * @Description Send power mode to wpa
405  *
406  * @param mode - true for power mode, false for resume mode.
407  * @return WifiErrorNo
408  */
409 WifiErrorNo SetPowerMode(bool mode);
410 #ifdef __cplusplus
411 }
412 #endif
413 #endif
414