1 /*
2  * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #ifndef ESP_WPA3_H
7 #define ESP_WPA3_H
8 
9 #include "esp_wifi_driver.h"
10 
11 #ifdef CONFIG_WPA3_SAE
12 
13 void esp_wifi_register_wpa3_cb(struct wpa_funcs *wpa_cb);
14 void esp_wpa3_free_sae_data(void);
15 
16 #else /* CONFIG_WPA3_SAE */
17 
esp_wifi_register_wpa3_cb(struct wpa_funcs * wpa_cb)18 static inline void esp_wifi_register_wpa3_cb(struct wpa_funcs *wpa_cb)
19 {
20     wpa_cb->wpa3_build_sae_msg = NULL;
21     wpa_cb->wpa3_parse_sae_msg = NULL;
22 }
23 
esp_wpa3_free_sae_data(void)24 static inline void esp_wpa3_free_sae_data(void)
25 {
26 }
27 
28 #endif /* CONFIG_WPA3_SAE */
29 
30 #ifdef CONFIG_SAE
31 enum SIG_WPA3_TASK {
32     SIG_WPA3_RX_COMMIT,
33     SIG_WPA3_RX_CONFIRM,
34     SIG_TASK_DEL,
35     SIG_TASK_MAX
36 };
37 
38 typedef struct {
39     uint32_t id;
40     uint32_t data;
41 } wpa3_hostap_auth_event_t;
42 
43 struct sae_hostap_confirm_data {
44     size_t len;
45     u8 bssid[ETH_ALEN];
46     u32 auth_transaction;
47     u16 status;
48     u8 msg[];
49 };
50 
51 #define WPA3_HOSTAP_HANDLE_AUTH_TASK_STACK_SIZE  (6144)
52 #define WPA3_HOSTAP_HANDLE_AUTH_TASK_PRIORITY    (19)
53 #define WPA3_HOSTAP_AUTH_API_LOCK() os_semphr_take(g_wpa3_hostap_auth_api_lock, OS_BLOCK)
54 #define WPA3_HOSTAP_AUTH_API_UNLOCK() os_semphr_give(g_wpa3_hostap_auth_api_lock)
55 
56 int wpa3_hostap_post_evt(uint32_t evt_id, uint32_t data);
57 void esp_wifi_register_wpa3_ap_cb(struct wpa_funcs *wpa_cb);
58 int wpa3_hostap_auth_init(void *data);
59 bool wpa3_hostap_auth_deinit(void);
60 int esp_send_sae_auth_reply(struct hostapd_data *hapd,
61                const u8 *dst, const u8 *bssid,
62                u16 auth_alg, u16 auth_transaction, u16 resp,
63                const u8 *ies, size_t ies_len);
64 
65 #else /* CONFIG_SAE */
66 
esp_wifi_register_wpa3_ap_cb(struct wpa_funcs * wpa_cb)67 static inline void esp_wifi_register_wpa3_ap_cb(struct wpa_funcs *wpa_cb)
68 {
69 	wpa_cb->wpa3_hostap_handle_auth = NULL;
70 }
71 
72 #endif /* CONFIG_SAE */
73 #endif /* ESP_WPA3_H */
74