1 /*
2  * Copyright (c) 2020-2022 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 /**
10  * @addtogroup WLAN
11  * @{
12  *
13  * @brief Provides cross-OS migration, component adaptation, and modular assembly and compilation.
14  *
15  * Based on the unified APIs provided by the WLAN module, developers of the Hardware Driver Interface
16  * (HDI) are capable of creating, disabling, scanning for, and connecting to WLAN hotspots, managing WLAN chips,
17  * network devices, and power, and applying for, releasing, and moving network data buffers.
18  *
19  * @since 1.0
20  * @version 1.0
21  */
22 
23 /**
24  * @file wifi_mac80211_ops.h
25  *
26  * @brief Declares Media Access Control (MAC) APIs and functions related to control flows.
27  *
28  * This file declares APIs for scanning, connection, disconnection, and mode conversion, as well as data
29  * structures of the parameters of these APIs.
30  *
31  * @since 1.0
32  * @version 1.0
33  */
34 
35 #ifndef WIFI_MAC80211_OPS_H
36 #define WIFI_MAC80211_OPS_H
37 
38 #include "hdf_wifi_cmd.h"
39 #include "net_device.h"
40 
41 /**
42  * @brief Indicates the length of the MAC address of the device.
43  *
44  * The value is <b>6</b>.
45  *
46  * @since 1.0
47  * @version 1.0
48  */
49 #define IEEE80211_MAC_ADDR_LEN 6
50 /**
51  * @brief Indicates the maximum length of the SSID of the device.
52  *
53  * The value is <b>32</b>.
54  *
55  * @since 1.0
56  * @version 1.0
57  */
58 #define IEEE80211_MAX_SSID_LEN 32
59 /**
60  * @brief Indicates the length of a reserved field for the WLAN connection parameters.
61  *
62  * The value is <b>3</b>.
63  *
64  * @since 1.0
65  * @version 1.0
66  */
67 #define WIFI_CONNECT_PARM_RESV_SIZE 3
68 /**
69  * @brief Indicates that the frequency is not specified.
70  *
71  * The value is <b>0</b>.
72  *
73  * @since 1.0
74  * @version 1.0
75  */
76 #define WLAN_FREQ_NOT_SPECFIED 0
77 /**
78  * @brief Indicates the maximum length of the hotspot SSID array.
79  *
80  * The value is <b>32</b>.
81  *
82  * @since 1.0
83  * @version 1.0
84  */
85 #define OAL_IEEE80211_MAX_SSID_LEN 32
86 /**
87  * @brief Indicates the maximum number of channels to scan for.
88  *
89  * The value is <b>14</b>.
90  *
91  * @since 1.0
92  * @version 1.0
93  */
94 #define MAX_SCAN_CHANNELS 14
95 /**
96  * @brief Indicates a reserved field for a scan request.
97  *
98  * The value is <b>2</b>.
99  *
100  * @since 1.0
101  * @version 1.0
102  */
103 #define SCAN_REQUEST_RESV_SIZE 2
104 /**
105  * @brief Indicates the maximum number of frequency filters.
106  *
107  * The value is <b>200</b>.
108  *
109  * @since 1.0
110  * @version 1.0
111  */
112 #define MAX_FREQ_FTILTER_COUNT 200
113 /**
114  * @brief Indicates the maximum number of cipher suites.
115  *
116  * The value is <b>5</b>.
117  *
118  * @since 1.0
119  * @version 1.0
120  */
121 #define NL80211_MAX_NR_CIPHER_SUITES 5
122 /**
123  * @brief Indicates the maximum number of AKM suites.
124  *
125  * The value is <b>2</b>.
126  *
127  * @since 1.0
128  * @version 1.0
129  */
130 #define NL80211_MAX_NR_AKM_SUITES 2
131 
132 /**
133  * @brief Enumerates frequency bands.
134  *
135  * @since 1.0
136  * @version 1.0
137  */
138 enum Ieee80211Band {
139     IEEE80211_BAND_2GHZ = 0, /**< 2.4 GHz */
140     IEEE80211_BAND_5GHZ,     /**< 5 GHz */
141     IEEE80211_NUM_BANDS      /**< Number of frequency bands */
142 };
143 
144 /**
145  * @brief Enumerates channel widths.
146  *
147  * @since 1.0
148  * @version 1.0
149  */
150 enum Ieee80211ChannelWidth {
151     WLAN_CHANNEL_WIDTH_10 = BIT(0),  /**< 10 MHz */
152     WLAN_CHANNEL_WIDTH_20 = BIT(1),  /**< 20 MHz */
153     WLAN_CHANNEL_WIDTH_40P = BIT(2), /**< 40 MHz (two 20 MHz channels, with the primary channel
154                                       * having a higher frequency
155                                       */
156     WLAN_CHANNEL_WIDTH_40M = BIT(3), /**< 40 MHz (two 20 MHz channels, with the primary channel
157                                       * having a lower frequency
158                                       */
159     WLAN_CHANNEL_WIDTH_80 = BIT(4),  /**< 80 MHz */
160     WLAN_CHANNEL_WIDTH_160 = BIT(5), /**< 160 MHz */
161 };
162 
163 /**
164  * @brief Enumerates WLAN modes.
165  *
166  * @since 1.0
167  * @version 1.0
168  */
169 enum WlanWorkMode {
170     WLAN_WORKMODE_STA = 2, /**< STA mode */
171     WLAN_WORKMODE_AP = 3,  /**< AP mode */
172     WLAN_WORKMODE_AP_VLAN,
173     WLAN_WORKMODE_WDS,
174     WLAN_WORKMODE_MONITOR,
175     WLAN_WORKMODE_MESH_POINT,
176     WLAN_WORKMODE_P2P_CLIENT,
177     WLAN_WORKMODE_P2P_GO,
178     WLAN_WORKMODE_P2P_DEVICE,
179 };
180 
181 /**
182  * @brief Describes a key.
183  *
184  * @since 1.0
185  * @version 1.0
186  */
187 struct KeyParams {
188     uint8_t *key;    /**< Key content */
189     uint8_t *seq;    /**< Content of a Temporal Key Integrity Protocol (TKIP) or Counter Mode Cipher Block Chaining
190                       * Message Authentication Code Protocol (CCMP) key
191                       */
192     int32_t keyLen;  /**< Key length */
193     int32_t seqLen;  /**< Length of a TKIP or CCMP key */
194     uint32_t cipher; /**< Cipher suite */
195 };
196 
197 #define UINT32_BIT(BIT) (((uint32_t)1) << (BIT))
198 
199 #define WLAN_CHANNEL_FLAG_DFS_UNKNOWN 0x00000000
200 #define WLAN_CHANNEL_FLAG_DFS_MASK    0x00000300
201 
202 /**
203  * @brief Enumerates WLAN channel capability flags.
204  *
205  * @since 1.0
206  * @version 1.0
207  */
208 enum WlanChannelCapabilityFlags {
209     WLAN_CHANNEL_FLAG_DISABLED = UINT32_BIT(0),  /**< Channel disabled */
210     WLAN_CHANNEL_FLAG_NO_IR = UINT32_BIT(1),     /**< Infrared light (IR) not supported */
211     WLAN_CHANNEL_FLAG_RADAR = UINT32_BIT(3),     /**< Radar supported */
212     WLAN_CHANNEL_FLAG_HT40PLUS = UINT32_BIT(4),  /**< A 40 MHz channel that consists of two 20 MHz channels,
213                                                   * with the primary channel having a higher frequency
214                                                   */
215     WLAN_CHANNEL_FLAG_HT40MINUS = UINT32_BIT(5), /**< A 40 MHz channel that consists of two 20 MHz channels,
216                                                   * with the primary channel having a lower frequency
217                                                   */
218     WLAN_CHANNEL_FLAG_HT40 = UINT32_BIT(6),      /**< 40 MHz channel */
219     WLAN_CHANNEL_FLAG_SURVEY_LIST_INITIALIZED = UINT32_BIT(7), /**< Survey list initialized */
220     WLAN_CHANNEL_FLAG_DFS_USABLE = UINT32_BIT(8),              /**< Dynamic frequency selection (DFS) supported */
221     WLAN_CHANNEL_FLAG_DFS_UNAVAILABLE = UINT32_BIT(9),         /**< DFS disabled */
222     WLAN_CHANNEL_FLAG_DFS_AVAILABLE = WLAN_CHANNEL_FLAG_DFS_USABLE | WLAN_CHANNEL_FLAG_DFS_UNAVAILABLE,
223     WLAN_CHANNEL_FLAG_VHT_10_70 =
224         UINT32_BIT(11), /**< A 80 MHz channel: Frequency
225                          * band = Channel's center frequency - 10 MHz to the channel's center frequency + 70 MHz
226                          */
227     WLAN_CHANNEL_FLAG_VHT_30_50 =
228         UINT32_BIT(12), /**< A 80 MHz channel: Frequency
229                          * band = Channel's center frequency - 30 MHz to the channel's center frequency + 50 MHz
230                          */
231     WLAN_CHANNEL_FLAG_VHT_50_30 =
232         UINT32_BIT(13), /**< A 80 MHz channel: Frequency
233                          * band = Channel's center frequency - 50 MHz to the channel's center frequency + 30 MHz
234                          */
235     WLAN_CHANNEL_FLAG_VHT_70_10 =
236         UINT32_BIT(14), /**< A 80 MHz channel: Frequency
237                          * band = Channel's center frequency - 70 MHz to the channel's center frequency + 10 MHz
238                          */
239     WLAN_CHANNEL_FLAG_INDOOR_ONLY = UINT32_BIT(16),   /**< Used only indoors */
240     WLAN_CHANNEL_FLAG_GO_CONCURRENT = UINT32_BIT(17), /**< Go Concurrent supported */
241     WLAN_CHANNEL_FLAG_VHT_10_150 = UINT32_BIT(20),    /**< A 160 MHz channel: Frequency band = Channel's center
242                                                        * frequency - 10 MHz to the channel's center frequency + 150 MHz
243                                                        */
244     WLAN_CHANNEL_FLAG_VHT_30_130 = UINT32_BIT(21),    /**< A 160 MHz channel: Frequency band = Channel's center
245                                                        * frequency - 30 MHz to the channel's center frequency + 130 MHz
246                                                        */
247     WLAN_CHANNEL_FLAG_VHT_50_110 = UINT32_BIT(22),    /**< A 160 MHz channel: Frequency band = Channel's center
248                                                        * frequency - 50 MHz to the channel's center frequency + 110 MHz
249                                                        */
250     WLAN_CHANNEL_FLAG_VHT_70_90 = UINT32_BIT(23),     /**< A 160 MHz channel: Frequency band = Channel's center
251                                                        frequency - 70 MHz to the channel's center frequency + 90 MHz
252                                                        */
253     WLAN_CHANNEL_FLAG_VHT_90_70 = UINT32_BIT(24),     /**< A 160 MHz channel: Frequency band = Channel's center
254                                                        * frequency - 90 MHz to the channel's center frequency + 70 MHz
255                                                        */
256     WLAN_CHANNEL_FLAG_VHT_110_50 = UINT32_BIT(25),    /**< A 160 MHz channel: Frequency band = Channel's center
257                                                        * frequency - 110 MHz to the channel's center frequency + 50 MHz
258                                                        */
259     WLAN_CHANNEL_FLAG_VHT_130_30 = UINT32_BIT(26),    /**< A 160 MHz channel: Frequency band = Channel's center
260                                                        * frequency - 130 MHz to the channel's center frequency + 30 MHz
261                                                        */
262     WLAN_CHANNEL_FLAG_VHT_150_10 = UINT32_BIT(27),    /**< A 160 MHz channel: Frequency band = Channel's center
263                                                        * frequency - 150 MHz to the channel's center frequency + 10 MHz
264                                                        */
265 };
266 
267 /**
268  * @brief Define wifi power mode.
269  *
270  * @since 1.0
271  * @version 1.0
272  */
273 #define WIFI_POWER_MODE_SLEEPING 0
274 #define WIFI_POWER_MODE_GENERAL 1
275 #define WIFI_POWER_MODE_THROUGH_WALL 2
276 #define WIFI_POWER_MODE_NUM 3
277 
278 /**
279  * @brief Describes a communication channel.
280  *
281  * @since 1.0
282  * @version 1.0
283  */
284 struct WlanChannel {
285     uint8_t channelId;   /**< Channel ID */
286     uint32_t centerFreq; /**< Center frequency */
287     uint32_t flags;      /**< Flags for the channel, as enumerated in <b>WlanChannelCapabilityFlags</b> */
288 };
289 
290 /**
291  * @brief Describes a band.
292  *
293  * @since 1.0
294  * @version 1.0
295  */
296 struct WlanBand {
297     uint16_t channelCount;          /**< Number of channels */
298     struct WlanChannel channels[0]; /**< WLAN channel structures */
299 };
300 
301 /**
302  * @brief Describes an SSID.
303  *
304  * @since 1.0
305  * @version 1.0
306  */
307 struct WlanSSID {
308     uint8_t ssid[IEEE80211_MAX_SSID_LEN]; /**< SSID array */
309     uint8_t ssidLen;                      /**< SSID length */
310 };
311 
312 /**
313  * @brief Describes scan request parameters.
314  *
315  * @since 1.0
316  * @version 1.0
317  */
318 struct WlanScanRequest {
319     uint8_t ssidCount;      /**< Number of SSIDs */
320     uint8_t freqsCount;     /**< Number of frequencies */
321     uint8_t *bssid;         /**< BSSID to scan for */
322     struct WlanSSID *ssids; /**< SSIDs to scan for */
323     uint32_t *freqs;        /**< An array of frequencies */
324     uint32_t extraIEsLen;   /**< Length of an extended information element (IE) */
325     uint8_t *extraIEs;      /**< Extended IEs */
326 };
327 
328 /**
329  * @brief Describes cryptography settings.
330  *
331  * @since 1.0
332  * @version 1.0
333  */
334 struct CryptoSettings {
335     uint32_t wpaVersions;                                   /**< WPA version */
336     uint32_t cipherGroup;                                   /**< Cipher group */
337     int32_t n_ciphersPairwise;                              /**< Number of unicast ciphers supported by the AP */
338     uint32_t ciphersPairwise[NL80211_MAX_NR_CIPHER_SUITES]; /**< Unicast cipher suites. The maximum number of
339                                                              * unicast cipher suites is specified by
340                                                              * {@link NL80211_MAX_NR_CIPHER_SUITES}.
341                                                              */
342     int32_t n_akmSuites;                           /**< Number of authentication and key management (AKM) suites */
343     uint32_t akmSuites[NL80211_MAX_NR_AKM_SUITES]; /**< AKM suites. The maximum number of AKM suites is specified
344                                                     * by {@link NL80211_MAX_NR_AKM_SUITES}.
345                                                     */
346     uint16_t controlPortEthertype;                 /**< Data can be transmitted over an unauthenticated port. */
347     int8_t controlPort;          /**< Whether the user space control port is authorized. The value <b>true</b>
348                                   * indicates that the user space control port is unauthorized.
349                                   */
350     int8_t controlPortNoEncrypt; /**< Whether to encrypt frames transmitted over the control port.
351                                   * The value <b>1</b> indicates that the frames are not encrypted.
352                                   */
353 };
354 
355 /**
356  * @brief Describes parameters for a connection request.
357  *
358  * @since 1.0
359  * @version 1.0
360  */
361 typedef struct WlanConnectParams {
362     uint32_t centerFreq;          /**< Connection channel. If this parameter is not specified, the connection channel
363                                    * is automatically obtained from the scan result.
364                                    */
365     uint8_t *bssid;               /**< AP BSSID. If this parameter is not specified, the AP BSSID is automatically
366                                    * obtained from the scan result.
367                                    */
368     uint8_t *ssid;                /**< SSID */
369     uint8_t *ie;                  /**< IE information required for the connection */
370     uint32_t ssidLen;             /**< SSID length */
371     uint32_t ieLen;               /**< IE length */
372     struct CryptoSettings crypto; /**< Cryptography information */
373     const uint8_t *key;           /**< Wired Equivalent Privacy (WEP) key used for Shared Key
374                                    * Authentication (SKA)
375                                    */
376     uint8_t authType;             /**< Authorization type */
377     uint8_t privacy;              /**< Whether to use a privacy-enabled AP */
378     uint8_t keyLen;               /**< Key length */
379     uint8_t keyIdx;               /**< Index of the WEP key used for SKA */
380     uint8_t mfp;                  /**< Whether to enable Management Frame Protection (MFP) */
381     uint8_t aucResv[WIFI_CONNECT_PARM_RESV_SIZE]; /**< Reserved field */
382 } WlanConnectParams;
383 
384 /**
385  * @brief Describes parameters for canceling a connection.
386  *
387  * @since 1.0
388  * @version 1.0
389  */
390 struct StationDelParameters {
391     const uint8_t *mac;  /**< MAC address of the station with which the connection is to be canceled */
392     uint8_t subtype;     /**< Cancellation type */
393     uint16_t reasonCode; /**< Reason code for the cancellation */
394 };
395 
396 /**
397  * @brief Describes MAC configuration parameters.
398  *
399  * @since 1.0
400  * @version 1.0
401  */
402 typedef struct MacConfigParam {
403     uint8_t mac[IEEE80211_MAC_ADDR_LEN]; /**< MAC address. For details about its length, see {@link
404                                           * IEEE80211_MAC_ADDR_LEN}.
405                                           */
406     uint8_t p2pMode;                     /**< Whether the peer-to-peer (P2P) mode is used. */
407     uint8_t resv;                        /**< Reserved field */
408 } Mac80211SetMacParam;
409 
410 /**
411  * @brief Describes disconnection parameters.
412  *
413  * @since 1.0
414  * @version 1.0
415  */
416 typedef struct {
417     uint8_t macAddr[IEEE80211_MAC_ADDR_LEN]; /**< Device MAC address */
418     uint16_t reasonCode;                     /**< Disconnection reason code */
419 } Mac80211DisconnectParam;
420 
421 /**
422  * @brief Describes the beacon configuration.
423  *
424  * @since 1.0
425  * @version 1.0
426  */
427 struct WlanBeaconConf {
428     uint32_t interval;    /**< Beacon interval */
429     uint32_t DTIMPeriod;  /**< Delivery Traffic Indication Message (DTIM) interval for sending beacons */
430     uint8_t *headIEs;     /**< One or more IEs before the TIM IE */
431     size_t headIEsLength; /**< Length of the IEs before the TIM IE */
432     uint8_t *tailIEs;     /**< One or more IEs after the TIM IE */
433     size_t tailIEsLength; /**< Length of the IEs after the TIM IE */
434     bool hiddenSSID;      /**< Whether to hide the SSID */
435 };
436 
437 /**
438  * @brief Describes the AP configuration.
439  *
440  * @since 1.0
441  * @version 1.0
442  */
443 struct WlanAPConf {
444     struct WlanSSID ssidConf; /**< SSID configuration */
445     uint16_t channel;         /**< Channel */
446     uint16_t centerFreq1;     /**< Center frequency 1 */
447     uint16_t centerFreq2;     /**< Center frequency 2 */
448     uint8_t band;             /**< Band, as enumerated in <b>Ieee80211Band</b> */
449     uint8_t width;            /**< Channel width, as enumerated in <b>Ieee80211ChannelWidth</b> */
450 };
451 
452 /**
453  * @brief Describes the hardware capability.
454  *
455  * @since 1.0
456  * @version 1.0
457  */
458 struct WlanHwCapability {
459     void (*Release)(struct WlanHwCapability *self); /**< Function for releasing the hardware capability */
460     struct WlanBand *bands[IEEE80211_NUM_BANDS];    /**< Frequency bands */
461     uint16_t htCapability;                          /**< High-throughput (HT) capability */
462     uint16_t supportedRateCount;                    /**< Number of supported rates */
463     uint16_t *supportedRates;                       /**< An array of supported rates in 100 kbit/s */
464 };
465 
466 /**
467  * @brief Describes the MAC-layer APIs for basic operations that need to be implemented by the driver.
468  *
469  * @since 1.0
470  * @version 1.0
471  */
472 struct HdfMac80211BaseOps {
473     /**
474      * @brief Sets the WLAN mode.
475      *
476      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
477      * @param mode Indicates the WLAN mode to set.
478      *
479      * @return Returns <b>0</b> if the WLAN mode is set; returns a non-zero value otherwise.
480      *
481      * @since 1.0
482      * @version 1.0
483      */
484     int32_t (*SetMode)(NetDevice *netDev, enum WlanWorkMode mode);
485 
486     /**
487      * @brief Adds a key with specified parameters.
488      *
489      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
490      * @param keyIndex Indicates the key index.
491      * @param pairwise Specifies whether the key is a key pair.
492      * @param macAddr Indicates the pointer to the MAC address.
493      * @param params Indicates the pointer to the key parameters.
494      *
495      * @return Returns <b>0</b> if the key is added; returns a non-zero value otherwise.
496      *
497      * @since 1.0
498      * @version 1.0
499      */
500     int32_t (*AddKey)(
501         struct NetDevice *netDev, uint8_t keyIndex, bool pairwise, const uint8_t *macAddr, struct KeyParams *params);
502 
503     /**
504      * @brief Deletes a key with a specified MAC address.
505      *
506      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
507      * @param keyIndex Indicates the key index.
508      * @param pairwise Specifies whether the key is a key pair.
509      * @param macAddr Indicates the pointer to the MAC address.
510      *
511      * @return Returns <b>0</b> if the key is deleted; returns a non-zero value otherwise.
512      *
513      * @since 1.0
514      * @version 1.0
515      */
516     int32_t (*DelKey)(struct NetDevice *netDev, uint8_t keyIndex, bool pairwise, const uint8_t *macAddr);
517 
518     /**
519      * @brief Sets the default key.
520      *
521      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
522      * @param keyIndex Indicates the key index.
523      * @param unicast Indicates the unicast.
524      * @param multicas Indicates the multicast.
525      *
526      * @return Returns <b>0</b> if the default key is set; returns a non-zero value otherwise.
527      *
528      * @since 1.0
529      * @version 1.0
530      */
531     int32_t (*SetDefaultKey)(struct NetDevice *netDev, uint8_t keyIndex, bool unicast, bool multicas);
532 
533     /**
534      * @brief Obtains the device MAC address.
535      *
536      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
537      * @param type Indicates the MAC address type of the device.
538      * @param mac Indicates the pointer to the MAC address.
539      * @param len Indicates the length of the MAC address.
540      *
541      * @return Returns <b>0</b> if the MAC address is obtained; returns a non-zero value otherwise.
542      *
543      * @since 1.0
544      * @version 1.0
545      */
546     int32_t (*GetDeviceMacAddr)(NetDevice *netDev, int32_t type, uint8_t *mac, uint8_t len);
547 
548     /**
549      * @brief Sets the MAC address.
550      *
551      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
552      * @param mac Indicates the pointer to the MAC address.
553      * @param len Indicates the length of the MAC address.
554      *
555      * @return Returns <b>0</b> if the MAC address is set; returns a non-zero value otherwise.
556      *
557      * @since 1.0
558      * @version 1.0
559      */
560     int32_t (*SetMacAddr)(NetDevice *netDev, uint8_t *mac, uint8_t len);
561 
562     /**
563      * @brief Sets the transmit power.
564      *
565      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
566      * @param power Indicates the transmit power to set.
567      *
568      * @return Returns <b>0</b> if the transmit power is set; returns a non-zero value otherwise.
569      *
570      * @since 1.0
571      * @version 1.0
572      */
573     int32_t (*SetTxPower)(NetDevice *netDev, int32_t power);
574 
575     /**
576      * @brief Obtains the frequencies supported by the 2.4 GHz or 5 GHz band.
577      *
578      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
579      * @param band Indicates the frequency band, either 2.4 GHz or 5 GHz.
580      * @param freqs Indicates the pointer to the supported frequencies.
581      * @param num Indicates the pointer to the number of supported frequencies.
582      *
583      * @return Returns <b>0</b> if the supported frequencies are obtained; returns a non-zero value otherwise.
584      *
585      * @since 1.0
586      * @version 1.0
587      */
588     int32_t (*GetValidFreqsWithBand)(NetDevice *netDev, int32_t band, int32_t *freqs, uint32_t *num);
589 
590     /**
591      * @brief Obtains the hardware capability supported by the device.
592      *
593      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
594      * @param capability Indicates the double pointer to the hardware capability.
595      *
596      * @return Returns <b>0</b> if the hardware capability is obtained; returns a non-zero value otherwise.
597      *
598      * @since 1.0
599      * @version 1.0
600      */
601     int32_t (*GetHwCapability)(NetDevice *netDev, struct WlanHwCapability **capability);
602 
603     int32_t (*SendAction)(struct NetDevice *netDev, WifiActionData *actionData);
604 
605     int32_t (*GetIftype)(struct NetDevice *netDev, uint8_t *iftype);
606 
607     /**
608      * @brief Obtains the power mode which is being used.
609      *
610      * @param ifName Indicates the pointer to the network interface name.
611      * @param mode Indicates the pointer to the power mode.
612      *
613      * @return Returns <b>0</b> if get infos successful; returns a negative value otherwise.
614      *
615      * @since 1.0
616      * @version 1.0
617      */
618     int32_t (*GetPowerMode)(struct NetDevice *netDev, uint8_t *mode);
619 
620     /**
621      * @brief Set the power mode.
622      *
623      * @param ifName Indicates the pointer to the network interface name.
624      * @param mode The value set to power mode.
625      *
626      * @return Returns <b>0</b> if get infos successful; returns a negative value otherwise.
627      *
628      * @since 1.0
629      * @version 1.0
630      */
631     int32_t (*SetPowerMode)(struct NetDevice *netDev, uint8_t mode);
632 
633     /**
634     * @brief Start channel measurement(asynchronous interface, need call getChannelMeasResult to
635      * get measurement results).
636      *
637      * @param ifName Indicates the pointer to the network interface name.
638      * @param measParam Parameters of the measurement channel.
639      *
640      * @return Returns <b>0</b> if get infos successful; returns a negative value otherwise.
641      *
642      * @since 3.2
643      * @version 1.0
644      */
645     int32_t (*StartChannelMeas)(struct NetDevice *netDev, const MeasParam *measParam);
646 
647     /**
648      * @brief Set projection screen parameters.
649      *
650      * @param ifName Indicates the pointer to the network interface name.
651      * @param cmd Command of projection screen configuration.
652      * @param data Parameters data send to dirver.
653      * @param bufLen Indicates the length of parameters data.
654      *
655      * @return Returns <b>0</b> if set projection screen parameters successful; returns a negative value otherwise.
656      *
657      * @since 3.2
658      * @version 1.0
659      */
660     int32_t (*SetProjectionScreenParam)(struct NetDevice *netDev, int32_t cmd, const int8_t *data, uint32_t dataLen);
661 
662     /**
663      * @brief Send ioctl command to driver.
664      *
665      * @param ifName Indicates the pointer to the network interface name.
666      * @param cmdId Indicates the command identity document.
667      * @param paramBuf Indicates the paramter send to driver.
668      * @param paramBufLen Indicates the length of parameter.
669      *
670      * @return Returns <b>0</b> if  Send ioctl command successful; returns a negative value otherwise.
671      *
672      * @since 3.2
673      * @version 1.0
674      */
675     int32_t (*SendCmdIoctl)(struct NetDevice *netDev, int32_t cmdId, const int8_t *paramBuf, uint32_t paramBufLen);
676 
677     /**
678      * @brief Get station information.
679      *
680      * @param ifName Indicates the pointer to the network interface name.
681      * @param info Indicates the Station information.
682      * @param mac Indicates the mac address of station.
683      * @param param Indicates the length of mac address.
684      *
685      * @return Returns <b>0</b> if get station information successful; returns a negative value otherwise.
686      *
687      * @since 3.2
688      * @version 1.0
689      */
690     int32_t (*GetStationInfo)(struct NetDevice *netDev, StationInfo *info, const uint8_t *mac, uint32_t macLen);
691 };
692 
693 /**
694  * @brief Describes the MAC-layer APIs for station operations that need to be implemented by the driver.
695  *
696  * @since 1.0
697  * @version 1.0
698  */
699 struct HdfMac80211STAOps {
700     /**
701      * @brief Starts a connection based on the specified parameters.
702      *
703      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
704      * @param param Indicates the pointer to the connection parameters.
705      *
706      * @return Returns <b>0</b> if the connection is started; returns a non-zero value otherwise.
707      *
708      * @since 1.0
709      * @version 1.0
710      */
711     int32_t (*Connect)(NetDevice *netDev, WlanConnectParams *param);
712 
713     /**
714      * @brief Cancels a connection.
715      *
716      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
717      * @param reasonCode Indicates the reason code for connection cancellation.
718      *
719      * @return Returns <b>0</b> if the connection is canceled; returns a non-zero value otherwise.
720      *
721      * @since 1.0
722      * @version 1.0
723      */
724     int32_t (*Disconnect)(NetDevice *netDev, uint16_t reasonCode);
725 
726     /**
727      * @brief Starts a scan based on the specified parameters.
728      *
729      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
730      * @param param Indicates the pointer to the scan parameters.
731      *
732      * @return Returns <b>0</b> if the scan is started; returns a non-zero value otherwise.
733      *
734      * @since 1.0
735      * @version 1.0
736      */
737     int32_t (*StartScan)(NetDevice *netDev, struct WlanScanRequest *param);
738 
739     /**
740      * @brief Stops a scan.
741      *
742      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
743      *
744      * @return Returns <b>0</b> if the scan is stopped; returns a non-zero value otherwise.
745      *
746      * @since 1.0
747      * @version 1.0
748      */
749     int32_t (*AbortScan)(NetDevice *netDev);
750 
751     /**
752      * @brief Sets scanning for a single MAC address.
753      *
754      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
755      * @param mac Indicates the pointer to the MAC address.
756      * @param len Indicates the length of the MAC address.
757      *
758      * @return Returns <b>0</b> if the setting is successful; returns a non-zero value otherwise.
759      *
760      * @since 1.0
761      * @version 1.0
762      */
763     int32_t (*SetScanningMacAddress)(NetDevice *netDev, unsigned char *mac, uint32_t len);
764 
765     /**
766      * @brief Start pno scan.
767      *
768      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
769      * @param pnoSettings Indicates the pno scan parameters.
770      *
771      * @return Returns <b>0</b> if Starting pno scan is successful; returns a non-zero value otherwise.
772      *
773      * @since 4.0
774      * @version 1.1
775      */
776     int32_t (*StartPnoScan)(NetDevice *netDev, const WifiPnoSettings *pnoSettings);
777 
778     /**
779      * @brief Stop pno scan.
780      *
781      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
782      *
783      * @return Returns <b>0</b> if Stopping pno scan is successful; returns a non-zero value otherwise.
784      *
785      * @since 4.0
786      * @version 1.0
787      */
788     int32_t (*StopPnoScan)(NetDevice *netDev);
789 
790     /**
791      * @brief Get signal information.
792      *
793      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
794      * @param signalInfo Indicates the obtained signal information.
795      *
796      * @return Returns <b>0</b> if getting signal information is successful; returns a non-zero value otherwise.
797      *
798      * @since 4.0
799      * @version 1.1
800      */
801     int32_t (*GetSignalPollInfo)(NetDevice *netDev, struct SignalResult *signalInfo);
802 };
803 
804 /**
805  * @brief Describes the MAC-layer APIs for AP operations that need to be implemented by the driver.
806  *
807  * @since 1.0
808  */
809 struct HdfMac80211APOps {
810     /**
811      * @brief Sets an AP.
812      *
813      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
814      * @param apConf Indicates the pointer to the AP configuration.
815      *
816      * @return Returns <b>0</b> if the AP is set; returns a non-zero value otherwise.
817      *
818      * @since 1.0
819      * @version 1.0
820      */
821     int32_t (*ConfigAp)(NetDevice *netDev, struct WlanAPConf *apConf);
822 
823     /**
824      * @brief Starts an AP.
825      *
826      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
827      *
828      * @return Returns <b>0</b> if the AP is started; returns a non-zero value otherwise.
829      *
830      * @since 1.0
831      * @version 1.0
832      */
833     int32_t (*StartAp)(NetDevice *netDev);
834 
835     /**
836      * @brief Stops an AP.
837      *
838      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
839      *
840      * @return Returns <b>0</b> if the AP is stopped; returns a non-zero value otherwise.
841      *
842      * @since 1.0
843      * @version 1.0
844      */
845     int32_t (*StopAp)(NetDevice *netDev);
846 
847     /**
848      * @brief Sets a beacon.
849      *
850      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
851      * @param beaconConf Indicates the pointer to the beacon configuration.
852      *
853      * @return Returns <b>0</b> if the beacon is set; returns a non-zero value otherwise.
854      *
855      * @since 1.0
856      * @version 1.0
857      */
858     int32_t (*ConfigBeacon)(NetDevice *netDev, struct WlanBeaconConf *beaconConf);
859 
860     /**
861      * @brief Deletes a station with a specified MAC address.
862      *
863      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
864      * @param macAddr Indicates the pointer to the MAC address.
865      *
866      * @return Returns <b>0</b> if the station is deleted; returns a non-zero value otherwise.
867      *
868      * @since 1.0
869      * @version 1.0
870      */
871     int32_t (*DelStation)(NetDevice *netDev, const uint8_t *macAddr);
872 
873     /**
874      * @brief Sets the country/region code.
875      *
876      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
877      * @param code Indicates the pointer to the country/region code.
878      * @param len Indicates the length of the country/region code.
879      *
880      * @return Returns <b>0</b> if the country/region code is set; returns a non-zero value otherwise.
881      *
882      * @since 1.0
883      * @version 1.0
884      */
885     int32_t (*SetCountryCode)(NetDevice *netDev, const char *code, uint32_t len);
886 
887     /**
888      * @brief Obtains the number of associated stations.
889      *
890      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
891      * @param num Indicates the pointer to the number of associated stations.
892      *
893      * @return Returns <b>0</b> if the number of associated stations is obtained; returns a non-zero value otherwise.
894      *
895      * @since 1.0
896      * @version 1.0
897      */
898     int32_t (*GetAssociatedStasCount)(NetDevice *netDev, uint32_t *num);
899 
900     /**
901      * @brief Obtains information about the associated stations.
902      *
903      * @param netDev Indicates the pointer to the network device structure obtained during initialization.
904      * @param staInfo Indicates the pointer to the information about the associated stations.
905      * @param num Indicates the number of associated stations.
906      *
907      * @return Returns <b>0</b> if the information is obtained; returns a non-zero value otherwise.
908      *
909      * @since 1.0
910      * @version 1.0
911      */
912     int32_t (*GetAssociatedStasInfo)(NetDevice *netDev, WifiStaInfo *staInfo, uint32_t num);
913 };
914 
915 struct HdfMac80211P2POps {
916     int32_t (*RemainOnChannel)(NetDevice *netDev, WifiOnChannel *onChannel);
917 
918     int32_t (*CancelRemainOnChannel)(NetDevice *netDev);
919 
920     int32_t (*ProbeReqReport)(NetDevice *netDev, int32_t report);
921 
922     int32_t (*AddIf)(NetDevice *netDev, WifiIfAdd *ifAdd);
923 
924     int32_t (*RemoveIf)(NetDevice *netDev, WifiIfRemove *ifRemove);
925 
926     int32_t (*SetApWpsP2pIe)(NetDevice *netDev, WifiAppIe *appIe);
927 
928     int32_t (*GetDriverFlag)(struct NetDevice *netDev, WifiGetDrvFlags **params);
929 };
930 
931 #endif // WIFI_MAC80211_OPS_H
932 /** @} */
933