Merge branch 'bugfix/wifi_backport_v5.2' into 'release/v5.2'

fix(esp_wifi): backport some wifi fixes to v5.2

See merge request espressif/esp-idf!27185
This commit is contained in:
Jiang Jiang Jian
2023-11-17 04:43:10 +08:00
47 changed files with 368 additions and 314 deletions

View File

@ -35,7 +35,7 @@
#include "soc/rtc.h" #include "soc/rtc.h"
#include "soc/soc_memory_layout.h" #include "soc/soc_memory_layout.h"
#include "soc/dport_reg.h" #include "soc/dport_reg.h"
#include "esp_coexist_internal.h" #include "private/esp_coexist_internal.h"
#include "esp_timer.h" #include "esp_timer.h"
#if !CONFIG_FREERTOS_UNICORE #if !CONFIG_FREERTOS_UNICORE
#include "esp_ipc.h" #include "esp_ipc.h"

View File

@ -24,7 +24,7 @@
#endif #endif
#if CONFIG_SW_COEXIST_ENABLE #if CONFIG_SW_COEXIST_ENABLE
#include "esp_coexist_internal.h" #include "private/esp_coexist_internal.h"
#endif #endif
#include "nimble/nimble_npl_os.h" #include "nimble/nimble_npl_os.h"

View File

@ -34,7 +34,7 @@
#include "soc/rtc.h" #include "soc/rtc.h"
#include "soc/rtc_cntl_reg.h" #include "soc/rtc_cntl_reg.h"
#include "soc/soc_memory_layout.h" #include "soc/soc_memory_layout.h"
#include "esp_coexist_internal.h" #include "private/esp_coexist_internal.h"
#include "esp_timer.h" #include "esp_timer.h"
#include "esp_sleep.h" #include "esp_sleep.h"
#include "esp_rom_sys.h" #include "esp_rom_sys.h"

View File

@ -24,7 +24,7 @@
#endif // ESP_PLATFORM #endif // ESP_PLATFORM
#if CONFIG_SW_COEXIST_ENABLE #if CONFIG_SW_COEXIST_ENABLE
#include "esp_coexist_internal.h" #include "private/esp_coexist_internal.h"
#endif // CONFIG_SW_COEXIST_ENABLE #endif // CONFIG_SW_COEXIST_ENABLE
#include "nimble/nimble_npl_os.h" #include "nimble/nimble_npl_os.h"

View File

@ -24,7 +24,7 @@
#endif // ESP_PLATFORM #endif // ESP_PLATFORM
#if CONFIG_SW_COEXIST_ENABLE #if CONFIG_SW_COEXIST_ENABLE
#include "esp_coexist_internal.h" #include "private/esp_coexist_internal.h"
#endif // CONFIG_SW_COEXIST_ENABLE #endif // CONFIG_SW_COEXIST_ENABLE
#include "nimble/nimble_npl_os.h" #include "nimble/nimble_npl_os.h"

View File

@ -18,7 +18,7 @@
#include "freertos/portmacro.h" #include "freertos/portmacro.h"
#include "esp_heap_caps.h" #include "esp_heap_caps.h"
#include "esp_timer.h" #include "esp_timer.h"
#include "esp_coexist_adapter.h" #include "private/esp_coexist_adapter.h"
#include "esp32/rom/ets_sys.h" #include "esp32/rom/ets_sys.h"
#define TAG "esp_coex_adapter" #define TAG "esp_coex_adapter"

View File

@ -20,7 +20,7 @@
#include "esp_timer.h" #include "esp_timer.h"
#include "soc/rtc.h" #include "soc/rtc.h"
#include "esp_private/esp_clk.h" #include "esp_private/esp_clk.h"
#include "esp_coexist_adapter.h" #include "private/esp_coexist_adapter.h"
#include "esp32c2/rom/ets_sys.h" #include "esp32c2/rom/ets_sys.h"
#define TAG "esp_coex_adapter" #define TAG "esp_coex_adapter"

View File

@ -20,7 +20,7 @@
#include "esp_timer.h" #include "esp_timer.h"
#include "soc/rtc.h" #include "soc/rtc.h"
#include "esp_private/esp_clk.h" #include "esp_private/esp_clk.h"
#include "esp_coexist_adapter.h" #include "private/esp_coexist_adapter.h"
#include "esp32c3/rom/ets_sys.h" #include "esp32c3/rom/ets_sys.h"
#include "soc/system_reg.h" #include "soc/system_reg.h"

View File

@ -20,7 +20,7 @@
#include "esp_timer.h" #include "esp_timer.h"
#include "soc/rtc.h" #include "soc/rtc.h"
#include "esp_private/esp_clk.h" #include "esp_private/esp_clk.h"
#include "esp_coexist_adapter.h" #include "private/esp_coexist_adapter.h"
#include "esp32c6/rom/ets_sys.h" #include "esp32c6/rom/ets_sys.h"
#define TAG "esp_coex_adapter" #define TAG "esp_coex_adapter"

View File

@ -20,7 +20,7 @@
#include "esp_timer.h" #include "esp_timer.h"
#include "soc/rtc.h" #include "soc/rtc.h"
#include "esp_private/esp_clk.h" #include "esp_private/esp_clk.h"
#include "esp_coexist_adapter.h" #include "private/esp_coexist_adapter.h"
#include "esp32c6/rom/ets_sys.h" #include "esp32c6/rom/ets_sys.h"
#define TAG "esp_coex_adapter" #define TAG "esp_coex_adapter"

View File

@ -20,7 +20,7 @@
#include "esp_timer.h" #include "esp_timer.h"
#include "soc/rtc.h" #include "soc/rtc.h"
#include "esp_private/esp_clk.h" #include "esp_private/esp_clk.h"
#include "esp_coexist_adapter.h" #include "private/esp_coexist_adapter.h"
#include "esp32s2/rom/ets_sys.h" #include "esp32s2/rom/ets_sys.h"
#define TAG "esp_coex_adapter" #define TAG "esp_coex_adapter"

View File

@ -20,7 +20,7 @@
#include "esp_timer.h" #include "esp_timer.h"
#include "soc/rtc.h" #include "soc/rtc.h"
#include "esp_private/esp_clk.h" #include "esp_private/esp_clk.h"
#include "esp_coexist_adapter.h" #include "private/esp_coexist_adapter.h"
#include "esp32s3/rom/ets_sys.h" #include "esp32s3/rom/ets_sys.h"
#include "soc/system_reg.h" #include "soc/system_reg.h"

View File

@ -9,7 +9,7 @@
#include <stdbool.h> #include <stdbool.h>
#include "esp_coexist.h" #include "esp_coexist.h"
#include "esp_coexist_adapter.h" #include "private/esp_coexist_adapter.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -165,7 +165,6 @@ int coex_register_bt_cb(coex_func_cb_t callback);
* @brief To acquire the spin-lock used in resetting Bluetooth baseband. * @brief To acquire the spin-lock used in resetting Bluetooth baseband.
* This function is only used to workaround ESP32 hardware issue. * This function is only used to workaround ESP32 hardware issue.
* *
* @param callback: callback function registered to coexistence module
* @return : value of the spinlock to be restored * @return : value of the spinlock to be restored
*/ */
uint32_t coex_bb_reset_lock(void); uint32_t coex_bb_reset_lock(void);
@ -260,7 +259,7 @@ void * coex_schm_curr_phase_get(void);
/** /**
* @brief Set current coexistence scheme phase index. * @brief Set current coexistence scheme phase index.
* *
* @param interval : Coexistence scheme phase index * @param idx : Coexistence scheme phase index
* @return : 0 - success, other - failed * @return : 0 - success, other - failed
*/ */
int coex_schm_curr_phase_idx_set(int idx); int coex_schm_curr_phase_idx_set(int idx);

View File

@ -5,7 +5,7 @@
*/ */
#include "esp_coexist.h" #include "esp_coexist.h"
#include "esp_coexist_internal.h" #include "private/esp_coexist_internal.h"
#if CONFIG_EXTERNAL_COEX_ENABLE #if CONFIG_EXTERNAL_COEX_ENABLE
#include "esp_log.h" #include "esp_log.h"

View File

@ -58,7 +58,7 @@ function check_md5()
} }
echo "Checking libraries for target ${IDF_TARGET}..." echo "Checking libraries for target ${IDF_TARGET}..."
check_md5 ${IDF_PATH}/components/esp_coex/include/esp_coexist_adapter.h g_coex_adapter_funcs_md5 check_md5 ${IDF_PATH}/components/esp_coex/include/private/esp_coexist_adapter.h g_coex_adapter_funcs_md5
case $IDF_TARGET in case $IDF_TARGET in
esp32c6|esp32h2) esp32c6|esp32h2)

View File

@ -37,7 +37,7 @@
/***********************************************/ /***********************************************/
// Headers for other components init functions // Headers for other components init functions
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
#include "esp_coexist_internal.h" #include "private/esp_coexist_internal.h"
#endif #endif
#if __has_include("esp_app_desc.h") #if __has_include("esp_app_desc.h")

View File

@ -39,11 +39,11 @@
#include "nvs.h" #include "nvs.h"
#include "os.h" #include "os.h"
#include "esp_smartconfig.h" #include "esp_smartconfig.h"
#include "esp_coexist_internal.h" #include "private/esp_coexist_internal.h"
#include "dport_access.h" #include "dport_access.h"
#include "esp_rom_sys.h" #include "esp_rom_sys.h"
#include "esp32/rom/ets_sys.h" #include "esp32/rom/ets_sys.h"
#include "esp_modem_wrapper.h" #include "private/esp_modem_wrapper.h"
#define TAG "esp_adapter" #define TAG "esp_adapter"

View File

@ -40,9 +40,9 @@
#include "nvs.h" #include "nvs.h"
#include "os.h" #include "os.h"
#include "esp_smartconfig.h" #include "esp_smartconfig.h"
#include "esp_coexist_internal.h" #include "private/esp_coexist_internal.h"
#include "esp32c2/rom/ets_sys.h" #include "esp32c2/rom/ets_sys.h"
#include "esp_modem_wrapper.h" #include "private/esp_modem_wrapper.h"
#define TAG "esp_adapter" #define TAG "esp_adapter"

View File

@ -41,9 +41,9 @@
#include "nvs.h" #include "nvs.h"
#include "os.h" #include "os.h"
#include "esp_smartconfig.h" #include "esp_smartconfig.h"
#include "esp_coexist_internal.h" #include "private/esp_coexist_internal.h"
#include "esp32c3/rom/ets_sys.h" #include "esp32c3/rom/ets_sys.h"
#include "esp_modem_wrapper.h" #include "private/esp_modem_wrapper.h"
#define TAG "esp_adapter" #define TAG "esp_adapter"

View File

@ -40,9 +40,9 @@
#include "nvs.h" #include "nvs.h"
#include "os.h" #include "os.h"
#include "esp_smartconfig.h" #include "esp_smartconfig.h"
#include "esp_coexist_internal.h" #include "private/esp_coexist_internal.h"
#include "esp32c6/rom/ets_sys.h" #include "esp32c6/rom/ets_sys.h"
#include "esp_modem_wrapper.h" #include "private/esp_modem_wrapper.h"
#include "esp_private/esp_modem_clock.h" #include "esp_private/esp_modem_clock.h"
#if SOC_PM_MODEM_RETENTION_BY_REGDMA #if SOC_PM_MODEM_RETENTION_BY_REGDMA

View File

@ -41,10 +41,10 @@
#include "nvs.h" #include "nvs.h"
#include "os.h" #include "os.h"
#include "esp_smartconfig.h" #include "esp_smartconfig.h"
#include "esp_coexist_internal.h" #include "private/esp_coexist_internal.h"
#include "esp_rom_sys.h" #include "esp_rom_sys.h"
#include "esp32s2/rom/ets_sys.h" #include "esp32s2/rom/ets_sys.h"
#include "esp_modem_wrapper.h" #include "private/esp_modem_wrapper.h"
#define TAG "esp_adapter" #define TAG "esp_adapter"

View File

@ -42,10 +42,10 @@
#include "nvs.h" #include "nvs.h"
#include "os.h" #include "os.h"
#include "esp_smartconfig.h" #include "esp_smartconfig.h"
#include "esp_coexist_internal.h" #include "private/esp_coexist_internal.h"
#include "esp_rom_sys.h" #include "esp_rom_sys.h"
#include "esp32s3/rom/ets_sys.h" #include "esp32s3/rom/ets_sys.h"
#include "esp_modem_wrapper.h" #include "private/esp_modem_wrapper.h"
#define TAG "esp_adapter" #define TAG "esp_adapter"

View File

@ -136,10 +136,13 @@ extern "C" {
/** /**
* @brief Flag of mesh networking IE * @brief Flag of mesh networking IE
*/ */
#define MESH_ASSOC_FLAG_VOTE_IN_PROGRESS (0x02) /**< vote in progress */ #define MESH_ASSOC_FLAG_MAP_ASSOC (0x01) /**< Mesh AP doesn't detect children leave yet */
#define MESH_ASSOC_FLAG_VOTE_IN_PROGRESS (0x02) /**< station in vote, set when root vote start, clear when connect to router or when root switch*/
#define MESH_ASSOC_FLAG_STA_VOTED (0x04) /**< station vote done, set when connect to router */
#define MESH_ASSOC_FLAG_NETWORK_FREE (0x08) /**< no root in current network */ #define MESH_ASSOC_FLAG_NETWORK_FREE (0x08) /**< no root in current network */
#define MESH_ASSOC_FLAG_ROOTS_FOUND (0x20) /**< root conflict is found */ #define MESH_ASSOC_FLAG_STA_VOTE_EXPIRE (0x10) /**< the voted address is expired, means the voted device lose the chance to be root */
#define MESH_ASSOC_FLAG_ROOT_FIXED (0x40) /**< fixed root */ #define MESH_ASSOC_FLAG_ROOTS_FOUND (0x20) /**< roots conflict is found, means that thre are at least two roots in the mesh network */
#define MESH_ASSOC_FLAG_ROOT_FIXED (0x40) /**< the root is fixed in the mesh network */
/** /**
@ -1291,7 +1294,7 @@ int esp_mesh_get_capacity_num(void);
/** /**
* @brief Set mesh IE crypto functions * @brief Set mesh IE crypto functions
* *
* @attention This API can be called at any time after mesh is initialized. * @attention This API can be called at any time after mesh is configured.
* *
* @param[in] crypto_funcs crypto functions for mesh IE * @param[in] crypto_funcs crypto functions for mesh IE
* - If crypto_funcs is set to NULL, mesh IE is no longer encrypted. * - If crypto_funcs is set to NULL, mesh IE is no longer encrypted.
@ -1303,7 +1306,7 @@ esp_err_t esp_mesh_set_ie_crypto_funcs(const mesh_crypto_funcs_t *crypto_funcs);
/** /**
* @brief Set mesh IE crypto key * @brief Set mesh IE crypto key
* *
* @attention This API can be called at any time after mesh is initialized. * @attention This API can be called at any time after mesh is configured.
* *
* @param[in] key ASCII crypto key * @param[in] key ASCII crypto key
* @param[in] len length in bytes, range:8~64 * @param[in] len length in bytes, range:8~64

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -25,6 +25,9 @@ extern "C" {
/******************************************************* /*******************************************************
* Structures * Structures
*******************************************************/ *******************************************************/
/**
* @brief Mesh attempts
*/
typedef struct { typedef struct {
int scan; /**< minimum scan times before being a root, default:10 */ int scan; /**< minimum scan times before being a root, default:10 */
int vote; /**< max vote times in self-healing, default:1000 */ int vote; /**< max vote times in self-healing, default:1000 */
@ -33,20 +36,28 @@ typedef struct {
int monitor_ie; /**< acceptable times of parent networking IE change before update its own networking IE. default:3 */ int monitor_ie; /**< acceptable times of parent networking IE change before update its own networking IE. default:3 */
} mesh_attempts_t; } mesh_attempts_t;
/**
* @brief Mesh switch parent
*/
typedef struct { typedef struct {
int duration_ms; /* parent weak RSSI monitor duration, if the RSSI continues to be weak during this duration_ms, int duration_ms; /**< parent weak RSSI monitor duration, if the RSSI continues to be weak during this duration_ms,
device will search for a new parent. */ device will search for a new parent. */
int cnx_rssi; /* RSSI threshold for keeping a good connection with parent. int cnx_rssi; /**< RSSI threshold for keeping a good connection with parent.
If set a value greater than -120 dBm, a timer will be armed to monitor parent RSSI at a period time of duration_ms. */ If set a value greater than -120 dBm, a timer will be armed to monitor parent RSSI at a period time of duration_ms. */
int select_rssi; /* RSSI threshold for parent selection. It should be a value greater than switch_rssi. */ int select_rssi; /**< RSSI threshold for parent selection. It should be a value greater than switch_rssi. */
int switch_rssi; /* Disassociate with current parent and switch to a new parent when the RSSI is greater than this set threshold. */ int switch_rssi; /**< Disassociate with current parent and switch to a new parent when the RSSI is greater than this set threshold. */
int backoff_rssi; /* RSSI threshold for connecting to the root */ int backoff_rssi; /**< RSSI threshold for connecting to the root */
} mesh_switch_parent_t; } mesh_switch_parent_t;
/**
* @brief Mesh RSSI threshold
*/
typedef struct { typedef struct {
int high; int high; /**< high RSSI threshold, used to determine whether the new parent and the current parent are in the same RSSI range */
int medium; int medium; /**< medium RSSI threshold, used to determine whether the new parent and the current parent are in the same RSSI range */
int low; int low; /**< low RSSI threshold. If the parent's RSSI is lower than low for a period time of duration_ms,
then the mesh node will post MESH_WEAK_RSSI event.
Also used to determine whether the new parent and the current parent are in the same RSSI range */
} mesh_rssi_threshold_t; } mesh_rssi_threshold_t;
/** /**
@ -54,65 +65,71 @@ typedef struct {
*/ */
typedef struct { typedef struct {
/**< mesh networking IE head */ /**< mesh networking IE head */
uint8_t eid; /**< element ID */ uint8_t eid; /**< element ID, vendor specific, 221 */
uint8_t len; /**< element length */ uint8_t len; /**< element length, the length after this member */
uint8_t oui[3]; /**< organization identifier */ uint8_t oui[3]; /**< organization identifier, 0x18fe34 */
/**< mesh networking IE content */ uint8_t type; /**< ESP defined IE type, include Assoc IE, SSID IE, Ext Assoc IE, Roots IE, etc. */
uint8_t type; /** ESP defined IE type */
uint8_t encrypted : 1; /**< whether mesh networking IE is encrypted */ uint8_t encrypted : 1; /**< whether mesh networking IE is encrypted */
uint8_t version : 7; /**< mesh networking IE version */ uint8_t version : 7; /**< mesh networking IE version, equal to 2 if mesh PS is enabled, equal to 1 otherwise */
/**< content */ /**< content */
uint8_t mesh_type; /**< mesh device type */ uint8_t mesh_type; /**< mesh device type, include idle, root, node, etc, refer to mesh_type_t */
uint8_t mesh_id[6]; /**< mesh ID */ uint8_t mesh_id[6]; /**< mesh ID, only the same mesh id can form a unified mesh network */
uint8_t layer_cap; /**< max layer */ uint8_t layer_cap; /**< layer_cap = max_layer - layer, indicates the number of remaining available layers of the mesh network */
uint8_t layer; /**< current layer */ uint8_t layer; /**< the current layer of this node */
uint8_t assoc_cap; /**< max connections of mesh AP */ uint8_t assoc_cap; /**< the maximum connections of this mesh AP */
uint8_t assoc; /**< current connections */ uint8_t assoc; /**< current connections of this mesh AP */
uint8_t leaf_cap; /**< leaf capacity */ uint8_t leaf_cap; /**< the maximum number of leaves in the mesh network */
uint8_t leaf_assoc; /**< the number of current connected leaf */ uint8_t leaf_assoc; /**< the number of current connected leaves */
uint16_t root_cap; /**< root capacity */ uint16_t root_cap; /**< the capacity of the root, equal to the total child numbers plus 1, root node updates root_cap and self_cap */
uint16_t self_cap; /**< self capacity */ uint16_t self_cap; /**< the capacity of myself, total child numbers plus 1, all nodes update this member */
uint16_t layer2_cap; /**< layer2 capacity */ uint16_t layer2_cap; /**< the capacity of layer2 node, total child numbers plus 1, layer2 node updates layer2_cap and self_cap, root sets this to 0 */
uint16_t scan_ap_num; /**< the number of scanning APs */ uint16_t scan_ap_num; /**< the number of mesh APs around */
int8_t rssi; /**< RSSI of the parent */ int8_t rssi; /**< RSSI of the connected parent, default value is -120, root node will not update this */
int8_t router_rssi; /**< RSSI of the router */ int8_t router_rssi; /**< RSSI of the router, default value is -120 */
uint8_t flag; /**< flag of networking */ uint8_t flag; /**< flag of networking, indicates the status of the network, refer to MESH_ASSOC_FLAG_XXX */
uint8_t rc_addr[6]; /**< root address */ /**< vote related */
int8_t rc_rssi; /**< root RSSI */ uint8_t rc_addr[6]; /**< the address of the root candidate, i.e. the voted addesss before connection, root node will update this with self address */
uint8_t vote_addr[6]; /**< voter address */ int8_t rc_rssi; /**< the router RSSI of the root candidate */
int8_t vote_rssi; /**< vote RSSI of the router */ uint8_t vote_addr[6]; /**< the voted address after connection */
uint8_t vote_ttl; /**< vote ttl */ int8_t vote_rssi; /**< the router RSSI of the voted address */
uint16_t votes; /**< votes */ uint8_t vote_ttl; /**< vote ttl, indicate the voting is from myself or from other nodes */
uint16_t my_votes; /**< my votes */ uint16_t votes; /**< the number of all voting nodes */
uint8_t reason; /**< reason */ uint16_t my_votes; /**< the number of nodes that voted for me */
uint8_t child[6]; /**< child address */ uint8_t reason; /**< the reason why the voting happens, root initiated or child initiated, refer to mesh_vote_reason_t */
uint8_t toDS; /**< toDS state */ uint8_t child[6]; /**< child address, not used currently */
uint8_t toDS; /**< state represents whether the root is able to access external IP network */
} __attribute__((packed)) mesh_assoc_t; } __attribute__((packed)) mesh_assoc_t;
/**
* @brief Mesh chain layer
*/
typedef struct { typedef struct {
uint16_t layer_cap; uint16_t layer_cap; /**< max layer of the network */
uint16_t layer; uint16_t layer; /**< current layer of this node */
} mesh_chain_layer_t; } mesh_chain_layer_t;
/**
* @brief Mesh chain assoc
*/
typedef struct { typedef struct {
mesh_assoc_t tree; mesh_assoc_t tree; /**< tree top, mesh_assoc IE */
mesh_chain_layer_t chain; mesh_chain_layer_t chain; /**< chain top, mesh_assoc IE */
} __attribute__((packed)) mesh_chain_assoc_t; } __attribute__((packed)) mesh_chain_assoc_t;
/* mesh max connections */ /* mesh max connections */
#define MESH_MAX_CONNECTIONS (10) #define MESH_MAX_CONNECTIONS (10)
/** /**
* @brief Mesh PS duties * @brief Mesh power save duties
*/ */
typedef struct { typedef struct {
uint8_t device; uint8_t device; /**< device power save duty*/
uint8_t parent; uint8_t parent; /**< parent power save duty*/
struct { struct {
bool used; bool used; /**< whether the child is joined */
uint8_t duty; uint8_t duty; /**< power save duty of the child */
uint8_t mac[6]; uint8_t mac[6]; /**< mac address of the child */
} child[MESH_MAX_CONNECTIONS]; } child[MESH_MAX_CONNECTIONS]; /**< child */
} esp_mesh_ps_duties_t; } esp_mesh_ps_duties_t;
/******************************************************* /*******************************************************
@ -121,7 +138,7 @@ typedef struct {
/** /**
* @brief Set mesh softAP beacon interval * @brief Set mesh softAP beacon interval
* *
* @param[in] interval beacon interval (msecs) (100 msecs ~ 60000 msecs) * @param[in] interval_ms beacon interval (msecs) (100 msecs ~ 60000 msecs)
* *
* @return * @return
* - ESP_OK * - ESP_OK
@ -133,7 +150,7 @@ esp_err_t esp_mesh_set_beacon_interval(int interval_ms);
/** /**
* @brief Get mesh softAP beacon interval * @brief Get mesh softAP beacon interval
* *
* @param[out] interval beacon interval (msecs) * @param[out] interval_ms beacon interval (msecs)
* *
* @return * @return
* - ESP_OK * - ESP_OK
@ -185,7 +202,7 @@ esp_err_t esp_mesh_set_switch_parent_paras(mesh_switch_parent_t *paras);
esp_err_t esp_mesh_get_switch_parent_paras(mesh_switch_parent_t *paras); esp_err_t esp_mesh_get_switch_parent_paras(mesh_switch_parent_t *paras);
/** /**
* @brief Set RSSI threshold * @brief Set RSSI threshold of current parent
* - The default high RSSI threshold value is -78 dBm. * - The default high RSSI threshold value is -78 dBm.
* - The default medium RSSI threshold value is -82 dBm. * - The default medium RSSI threshold value is -82 dBm.
* - The default low RSSI threshold value is -85 dBm. * - The default low RSSI threshold value is -85 dBm.
@ -199,7 +216,7 @@ esp_err_t esp_mesh_get_switch_parent_paras(mesh_switch_parent_t *paras);
esp_err_t esp_mesh_set_rssi_threshold(const mesh_rssi_threshold_t *threshold); esp_err_t esp_mesh_set_rssi_threshold(const mesh_rssi_threshold_t *threshold);
/** /**
* @brief Get RSSI threshold * @brief Get RSSI threshold of current parent
* *
* @param[out] threshold RSSI threshold * @param[out] threshold RSSI threshold
* *
@ -242,7 +259,7 @@ esp_err_t esp_mesh_print_rxQ_waiting(void);
/** /**
* @brief Set passive scan time * @brief Set passive scan time
* *
* @param[in] interval_ms passive scan time (msecs) * @param[in] time_ms passive scan time (msecs)
* *
* @return * @return
* - ESP_OK * - ESP_OK
@ -283,7 +300,9 @@ esp_err_t esp_mesh_set_announce_interval(int short_ms, int long_ms);
esp_err_t esp_mesh_get_announce_interval(int *short_ms, int *long_ms); esp_err_t esp_mesh_get_announce_interval(int *short_ms, int *long_ms);
/** /**
* @brief Get the running duties of device, parent and children * @brief Get the running duties of device, parent and children
*
* @param[out] ps_duties ps duties
* *
* @return * @return
* - ESP_OK * - ESP_OK

View File

@ -8,6 +8,10 @@
#define ESP_WIFI_OS_ADAPTER_H_ #define ESP_WIFI_OS_ADAPTER_H_
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "sdkconfig.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -29,7 +29,7 @@ typedef struct {
* @warning This API works only for the default Wi-Fi AP interface, i.e. esp-netif with key="WIFI_AP_DEF" * @warning This API works only for the default Wi-Fi AP interface, i.e. esp-netif with key="WIFI_AP_DEF"
* *
* @param[in] wifi_sta_list Wi-Fi station info list, returned from esp_wifi_ap_get_sta_list() * @param[in] wifi_sta_list Wi-Fi station info list, returned from esp_wifi_ap_get_sta_list()
* @param[out] netif_sta_list IP layer station info list, corresponding to MAC addresses provided in wifi_sta_list * @param[out] wifi_sta_ip_mac_list IP layer station info list, corresponding to MAC addresses provided in wifi_sta_list
* *
* @return * @return
* - ESP_OK * - ESP_OK
@ -38,10 +38,6 @@ typedef struct {
*/ */
esp_err_t esp_wifi_ap_get_sta_list_with_ip(const wifi_sta_list_t *wifi_sta_list, wifi_sta_mac_ip_list_t *wifi_sta_ip_mac_list); esp_err_t esp_wifi_ap_get_sta_list_with_ip(const wifi_sta_list_t *wifi_sta_list, wifi_sta_mac_ip_list_t *wifi_sta_ip_mac_list);
/**
* @}
*/
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -14,6 +14,9 @@
During normal operation, you don't need to use any of these types or functions in this header. During normal operation, you don't need to use any of these types or functions in this header.
See esp_wifi.h & esp_wifi_types.h instead. See esp_wifi.h & esp_wifi_types.h instead.
*/ */
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -55,7 +58,7 @@ typedef struct crypto_hash esp_crypto_hash_t;
typedef struct crypto_cipher esp_crypto_cipher_t; typedef struct crypto_cipher esp_crypto_cipher_t;
/** /**
* @brief The AES callback function when do WPS connect. * @brief The AES 128 encrypt callback function used by esp_wifi.
* *
* @param key Encryption key. * @param key Encryption key.
* @param iv Encryption IV for CBC mode (16 bytes). * @param iv Encryption IV for CBC mode (16 bytes).
@ -65,7 +68,7 @@ typedef struct crypto_cipher esp_crypto_cipher_t;
typedef int (*esp_aes_128_encrypt_t)(const unsigned char *key, const unsigned char *iv, unsigned char *data, int data_len); typedef int (*esp_aes_128_encrypt_t)(const unsigned char *key, const unsigned char *iv, unsigned char *data, int data_len);
/** /**
* @brief The AES callback function when do WPS connect. * @brief The AES 128 decrypt callback function used by esp_wifi.
* *
* @param key Decryption key. * @param key Decryption key.
* @param iv Decryption IV for CBC mode (16 bytes). * @param iv Decryption IV for CBC mode (16 bytes).
@ -76,7 +79,7 @@ typedef int (*esp_aes_128_encrypt_t)(const unsigned char *key, const unsigned ch
typedef int (*esp_aes_128_decrypt_t)(const unsigned char *key, const unsigned char *iv, unsigned char *data, int data_len); typedef int (*esp_aes_128_decrypt_t)(const unsigned char *key, const unsigned char *iv, unsigned char *data, int data_len);
/** /**
* @brief The AES callback function when do STA connect. * @brief The AES wrap callback function used by esp_wifi.
* *
* @param kek 16-octet Key encryption key (KEK). * @param kek 16-octet Key encryption key (KEK).
* @param n Length of the plaintext key in 64-bit units; * @param n Length of the plaintext key in 64-bit units;
@ -87,7 +90,7 @@ typedef int (*esp_aes_128_decrypt_t)(const unsigned char *key, const unsigned ch
typedef int (*esp_aes_wrap_t)(const unsigned char *kek, int n, const unsigned char *plain, unsigned char *cipher); typedef int (*esp_aes_wrap_t)(const unsigned char *kek, int n, const unsigned char *plain, unsigned char *cipher);
/** /**
* @brief The AES callback function when do STA connect. * @brief The AES unwrap callback function used by esp_wifi.
* *
* @param kek 16-octet Key decryption key (KEK). * @param kek 16-octet Key decryption key (KEK).
* @param n Length of the plaintext key in 64-bit units; * @param n Length of the plaintext key in 64-bit units;
@ -98,7 +101,7 @@ typedef int (*esp_aes_wrap_t)(const unsigned char *kek, int n, const unsigned ch
typedef int (*esp_aes_unwrap_t)(const unsigned char *kek, int n, const unsigned char *cipher, unsigned char *plain); typedef int (*esp_aes_unwrap_t)(const unsigned char *kek, int n, const unsigned char *cipher, unsigned char *plain);
/** /**
* @brief The SHA256 callback function when do WPS connect. * @brief The SHA256 callback function used by esp_wifi.
* *
* @param key Key for HMAC operations. * @param key Key for HMAC operations.
* @param key_len Length of the key in bytes. * @param key_len Length of the key in bytes.
@ -112,7 +115,7 @@ typedef int (*esp_hmac_sha256_vector_t)(const unsigned char *key, int key_len, i
const unsigned char *addr[], const int *len, unsigned char *mac); const unsigned char *addr[], const int *len, unsigned char *mac);
/** /**
* @brief The AES callback function when do STA connect. * @brief The SHA256 PRF callback function used by esp_wifi.
* *
* @param key Key for PRF. * @param key Key for PRF.
* @param key_len Length of the key in bytes. * @param key_len Length of the key in bytes.
@ -127,69 +130,69 @@ typedef int (*esp_sha256_prf_t)(const unsigned char *key, int key_len, const cha
const unsigned char *data, int data_len, unsigned char *buf, int buf_len); const unsigned char *data, int data_len, unsigned char *buf, int buf_len);
/** /**
* @brief HMAC-MD5 over data buffer (RFC 2104)' * @brief HMAC-MD5 callback function over data buffer (RFC 2104)'
* *
* @key: Key for HMAC operations * @param key Key for HMAC operations
* @key_len: Length of the key in bytes * @param key_len Length of the key in bytes
* @data: Pointers to the data area * @param dataPointers to the data area
* @data_len: Length of the data area * @param data_len Length of the data area
* @mac: Buffer for the hash (16 bytes) * @param mac Buffer for the hash (16 bytes)
* Returns: 0 on success, -1 on failure * Returns: 0 on success, -1 on failure
*/ */
typedef int (*esp_hmac_md5_t)(const unsigned char *key, unsigned int key_len, const unsigned char *data, typedef int (*esp_hmac_md5_t)(const unsigned char *key, unsigned int key_len, const unsigned char *data,
unsigned int data_len, unsigned char *mac); unsigned int data_len, unsigned char *mac);
/** /**
* @brief HMAC-MD5 over data vector (RFC 2104) * @brief HMAC-MD5 callback function over data vector (RFC 2104)
* *
* @key: Key for HMAC operations * @param key Key for HMAC operations
* @key_len: Length of the key in bytes * @param key_len Length of the key in bytes
* @num_elem: Number of elements in the data vector * @param num_elem Number of elements in the data vector
* @addr: Pointers to the data areas * @param addr Pointers to the data areas
* @len: Lengths of the data blocks * @param len Lengths of the data blocks
* @mac: Buffer for the hash (16 bytes) * @param mac Buffer for the hash (16 bytes)
* Returns: 0 on success, -1 on failure * Returns: 0 on success, -1 on failure
*/ */
typedef int (*esp_hmac_md5_vector_t)(const unsigned char *key, unsigned int key_len, unsigned int num_elem, typedef int (*esp_hmac_md5_vector_t)(const unsigned char *key, unsigned int key_len, unsigned int num_elem,
const unsigned char *addr[], const unsigned int *len, unsigned char *mac); const unsigned char *addr[], const unsigned int *len, unsigned char *mac);
/** /**
* @brief HMAC-SHA1 over data buffer (RFC 2104) * @brief HMAC-SHA1 callback function over data buffer (RFC 2104)
* *
* @key: Key for HMAC operations * @param key Key for HMAC operations
* @key_len: Length of the key in bytes * @param key_len Length of the key in bytes
* @data: Pointers to the data area * @param data Pointers to the data area
* @data_len: Length of the data area * @param data_len Length of the data area
* @mac: Buffer for the hash (20 bytes) * @param mac Buffer for the hash (20 bytes)
* Returns: 0 on success, -1 of failure * Returns: 0 on success, -1 of failure
*/ */
typedef int (*esp_hmac_sha1_t)(const unsigned char *key, unsigned int key_len, const unsigned char *data, typedef int (*esp_hmac_sha1_t)(const unsigned char *key, unsigned int key_len, const unsigned char *data,
unsigned int data_len, unsigned char *mac); unsigned int data_len, unsigned char *mac);
/** /**
* @brief HMAC-SHA1 over data vector (RFC 2104) * @brief HMAC-SHA1 callback function over data vector (RFC 2104)
* *
* @key: Key for HMAC operations * @param key Key for HMAC operations
* @key_len: Length of the key in bytes * @param key_len Length of the key in bytes
* @num_elem: Number of elements in the data vector * @param num_elem Number of elements in the data vector
* @addr: Pointers to the data areas * @param addr Pointers to the data areas
* @len: Lengths of the data blocks * @param len Lengths of the data blocks
* @mac: Buffer for the hash (20 bytes) * @param mac Buffer for the hash (20 bytes)
* Returns: 0 on success, -1 on failure * Returns: 0 on success, -1 on failure
*/ */
typedef int (*esp_hmac_sha1_vector_t)(const unsigned char *key, unsigned int key_len, unsigned int num_elem, typedef int (*esp_hmac_sha1_vector_t)(const unsigned char *key, unsigned int key_len, unsigned int num_elem,
const unsigned char *addr[], const unsigned int *len, unsigned char *mac); const unsigned char *addr[], const unsigned int *len, unsigned char *mac);
/** /**
* @brief SHA1-based Pseudo-Random Function (PRF) (IEEE 802.11i, 8.5.1.1) * @brief SHA1-based Pseudo-Random Function (PRF) (IEEE 802.11i, 8.5.1.1) callback function
* *
* @key: Key for PRF * @param key Key for PRF
* @key_len: Length of the key in bytes * @param key_len Length of the key in bytes
* @label: A unique label for each purpose of the PRF * @param label A unique label for each purpose of the PRF
* @data: Extra data to bind into the key * @param data Extra data to bind into the key
* @data_len: Length of the data * @param data_len Length of the data
* @buf: Buffer for the generated pseudo-random key * @param buf Buffer for the generated pseudo-random key
* @buf_len: Number of bytes of key to generate * @param buf_len Number of bytes of key to generate
* Returns: 0 on success, -1 of failure * Returns: 0 on success, -1 of failure
* *
* This function is used to derive new, cryptographically separate keys from a * This function is used to derive new, cryptographically separate keys from a
@ -199,26 +202,26 @@ typedef int (*esp_sha1_prf_t)(const unsigned char *key, unsigned int key_len, co
const unsigned char *data, unsigned int data_len, unsigned char *buf, unsigned int buf_len); const unsigned char *data, unsigned int data_len, unsigned char *buf, unsigned int buf_len);
/** /**
* @brief SHA-1 hash for data vector * @brief SHA-1 hash callback function for data vector
* *
* @num_elem: Number of elements in the data vector * @param num_elem Number of elements in the data vector
* @addr: Pointers to the data areas * @param addr Pointers to the data areas
* @len: Lengths of the data blocks * @param len Lengths of the data blocks
* @mac: Buffer for the hash * @param mac Buffer for the hash
* Returns: 0 on success, -1 on failure * Returns: 0 on success, -1 on failure
*/ */
typedef int (*esp_sha1_vector_t)(unsigned int num_elem, const unsigned char *addr[], const unsigned int *len, typedef int (*esp_sha1_vector_t)(unsigned int num_elem, const unsigned char *addr[], const unsigned int *len,
unsigned char *mac); unsigned char *mac);
/** /**
* @brief SHA1-based key derivation function (PBKDF2) for IEEE 802.11i * @brief SHA1-based key derivation function (PBKDF2) callback function for IEEE 802.11i
* *
* @passphrase: ASCII passphrase * @param passphrase ASCII passphrase
* @ssid: SSID * @param ssid SSID
* @ssid_len: SSID length in bytes * @param ssid_len SSID length in bytes
* @iterations: Number of iterations to run * @param iterations Number of iterations to run
* @buf: Buffer for the generated key * @param buf Buffer for the generated key
* @buflen: Length of the buffer in bytes * @param buflen Length of the buffer in bytes
* Returns: 0 on success, -1 of failure * Returns: 0 on success, -1 of failure
* *
* This function is used to derive PSK for WPA-PSK. For this protocol, * This function is used to derive PSK for WPA-PSK. For this protocol,
@ -229,13 +232,13 @@ typedef int (*esp_pbkdf2_sha1_t)(const char *passphrase, const char *ssid, unsig
int iterations, unsigned char *buf, unsigned int buflen); int iterations, unsigned char *buf, unsigned int buflen);
/** /**
* @brief XOR RC4 stream to given data with skip-stream-start * @brief XOR RC4 stream callback function to given data with skip-stream-start
* *
* @key: RC4 key * @param key RC4 key
* @keylen: RC4 key length * @param keylen RC4 key length
* @skip: number of bytes to skip from the beginning of the RC4 stream * @param skip number of bytes to skip from the beginning of the RC4 stream
* @data: data to be XOR'ed with RC4 stream * @param data data to be XOR'ed with RC4 stream
* @data_len: buf length * @param data_len buf length
* Returns: 0 on success, -1 on failure * Returns: 0 on success, -1 on failure
* *
* Generate RC4 pseudo random stream for the given key, skip beginning of the * Generate RC4 pseudo random stream for the given key, skip beginning of the
@ -246,89 +249,89 @@ typedef int (*esp_rc4_skip_t)(const unsigned char *key, unsigned int keylen, uns
unsigned char *data, unsigned int data_len); unsigned char *data, unsigned int data_len);
/** /**
* @brief MD5 hash for data vector * @brief MD5 hash callback function for data vector
* *
* @num_elem: Number of elements in the data vector * @param num_elem Number of elements in the data vector
* @addr: Pointers to the data areas * @param addr Pointers to the data areas
* @len: Lengths of the data blocks * @param len Lengths of the data blocks
* @mac: Buffer for the hash * @param mac Buffer for the hash
* Returns: 0 on success, -1 on failure * Returns: 0 on success, -1 on failure
*/ */
typedef int (*esp_md5_vector_t)(unsigned int num_elem, const unsigned char *addr[], const unsigned int *len, typedef int (*esp_md5_vector_t)(unsigned int num_elem, const unsigned char *addr[], const unsigned int *len,
unsigned char *mac); unsigned char *mac);
/** /**
* @brief Encrypt one AES block * @brief Encrypt one AES block callback function
* *
* @ctx: Context pointer from aes_encrypt_init() * @param ctx Context pointer from aes_encrypt_init()
* @plain: Plaintext data to be encrypted (16 bytes) * @param plain Plaintext data to be encrypted (16 bytes)
* @crypt: Buffer for the encrypted data (16 bytes) * @param crypt Buffer for the encrypted data (16 bytes)
*/ */
typedef void (*esp_aes_encrypt_t)(void *ctx, const unsigned char *plain, unsigned char *crypt); typedef void (*esp_aes_encrypt_t)(void *ctx, const unsigned char *plain, unsigned char *crypt);
/** /**
* @brief Initialize AES for encryption * @brief Initialize AES callback function for encryption
* *
* @key: Encryption key * @param key Encryption key
* @len: Key length in bytes (usually 16, i.e., 128 bits) * @param len Key length in bytes (usually 16, i.e., 128 bits)
* Returns: Pointer to context data or %NULL on failure * Returns: Pointer to context data or %NULL on failure
*/ */
typedef void * (*esp_aes_encrypt_init_t)(const unsigned char *key, unsigned int len); typedef void * (*esp_aes_encrypt_init_t)(const unsigned char *key, unsigned int len);
/** /**
* @brief Deinitialize AES encryption * @brief Deinitialize AES encryption callback function
* *
* @ctx: Context pointer from aes_encrypt_init() * @param ctx Context pointer from aes_encrypt_init()
*/ */
typedef void (*esp_aes_encrypt_deinit_t)(void *ctx); typedef void (*esp_aes_encrypt_deinit_t)(void *ctx);
/** /**
* @brief Decrypt one AES block * @brief Decrypt one AES block callback function
* *
* @ctx: Context pointer from aes_encrypt_init() * @param ctx Context pointer from aes_encrypt_init()
* @crypt: Encrypted data (16 bytes) * @param crypt Encrypted data (16 bytes)
* @plain: Buffer for the decrypted data (16 bytes) * @param plain Buffer for the decrypted data (16 bytes)
*/ */
typedef void (*esp_aes_decrypt_t)(void *ctx, const unsigned char *crypt, unsigned char *plain); typedef void (*esp_aes_decrypt_t)(void *ctx, const unsigned char *crypt, unsigned char *plain);
/** /**
* @brief Initialize AES for decryption * @brief Initialize AES callback function for decryption
* *
* @key: Decryption key * @param key Decryption key
* @len: Key length in bytes (usually 16, i.e., 128 bits) * @param len Key length in bytes (usually 16, i.e., 128 bits)
* Returns: Pointer to context data or %NULL on failure * Returns: Pointer to context data or %NULL on failure
*/ */
typedef void * (*esp_aes_decrypt_init_t)(const unsigned char *key, unsigned int len); typedef void * (*esp_aes_decrypt_init_t)(const unsigned char *key, unsigned int len);
/** /**
* @brief Deinitialize AES decryption * @brief Deinitialize AES decryption callback function
* *
* @ctx: Context pointer from aes_encrypt_init() * @param ctx Context pointer from aes_encrypt_init()
*/ */
typedef void (*esp_aes_decrypt_deinit_t)(void *ctx); typedef void (*esp_aes_decrypt_deinit_t)(void *ctx);
/** /**
* @brief One-Key CBC MAC (OMAC1) hash with AES-128 for MIC computation * @brief One-Key CBC MAC (OMAC1) hash with AES-128 callback function for MIC computation
* *
* @key: 128-bit key for the hash operation * @param key 128-bit key for the hash operation
* @data: Data buffer for which a MIC is computed * @param data Data buffer for which a MIC is computed
* @data_len: Length of data buffer in bytes * @param data_len Length of data buffer in bytes
* @mic: Buffer for MIC (128 bits, i.e., 16 bytes) * @param mic Buffer for MIC (128 bits, i.e., 16 bytes)
* Returns: 0 on success, -1 on failure * Returns: 0 on success, -1 on failure
*/ */
typedef int (*esp_omac1_aes_128_t)(const uint8_t *key, const uint8_t *data, size_t data_len, typedef int (*esp_omac1_aes_128_t)(const uint8_t *key, const uint8_t *data, size_t data_len,
uint8_t *mic); uint8_t *mic);
/** /**
* @brief Decrypt data using CCMP (Counter Mode CBC-MAC Protocol OR * @brief Decrypt data callback function using CCMP (Counter Mode CBC-MAC Protocol OR
* Counter Mode Cipher Block Chaining Message Authentication * Counter Mode Cipher Block Chaining Message Authentication
* Code Protocol) which is used in IEEE 802.11i RSN standard. * Code Protocol) which is used in IEEE 802.11i RSN standard.
* @tk: 128-bit Temporal Key for obtained during 4-way handshake * @param tk 128-bit Temporal Key for obtained during 4-way handshake
* @hdr: Pointer to IEEE802.11 frame headeri needed for AAD * @param hdr Pointer to IEEE802.11 frame headeri needed for AAD
* @data: Pointer to encrypted data buffer * @param data Pointer to encrypted data buffer
* @data_len: Encrypted data length in bytes * @param data_len Encrypted data length in bytes
* @decrypted_len: Length of decrypted data * @param decrypted_len Length of decrypted data
* @espnow_pkt: Indicates if it's an ESPNOW packet * @param espnow_pkt Indicates if it's an ESPNOW packet
* Returns: Pointer to decrypted data on success, NULL on failure * Returns: Pointer to decrypted data on success, NULL on failure
*/ */
typedef uint8_t * (*esp_ccmp_decrypt_t)(const uint8_t *tk, const uint8_t *ieee80211_hdr, typedef uint8_t * (*esp_ccmp_decrypt_t)(const uint8_t *tk, const uint8_t *ieee80211_hdr,
@ -336,90 +339,90 @@ typedef uint8_t * (*esp_ccmp_decrypt_t)(const uint8_t *tk, const uint8_t *ieee80
size_t *decrypted_len, bool espnow_pkt); size_t *decrypted_len, bool espnow_pkt);
/** /**
* @brief Encrypt data using CCMP (Counter Mode CBC-MAC Protocol OR * @brief Encrypt data callback function using CCMP (Counter Mode CBC-MAC Protocol OR
* Counter Mode Cipher Block Chaining Message Authentication * Counter Mode Cipher Block Chaining Message Authentication
* Code Protocol) which is used in IEEE 802.11i RSN standard. * Code Protocol) which is used in IEEE 802.11i RSN standard.
* @tk: 128-bit Temporal Key for obtained during 4-way handshake * @param tk 128-bit Temporal Key for obtained during 4-way handshake
* @frame: Pointer to IEEE802.11 frame including header * @param frame Pointer to IEEE802.11 frame including header
* @len: Length of the frame including header * @param len Length of the frame including header
* @hdrlen: Length of the header * @param hdrlen Length of the header
* @pn: Packet Number counter * @param pn Packet Number counter
* @keyid: Key ID to be mentioned in CCMP Vector * @param keyid Key ID to be mentioned in CCMP Vector
* @encrypted_len: Length of the encrypted frame including header * @param encrypted_len Length of the encrypted frame including header
*/ */
typedef uint8_t * (*esp_ccmp_encrypt_t)(const uint8_t *tk, uint8_t *frame, size_t len, size_t hdrlen, typedef uint8_t * (*esp_ccmp_encrypt_t)(const uint8_t *tk, uint8_t *frame, size_t len, size_t hdrlen,
uint8_t *pn, int keyid, size_t *encrypted_len); uint8_t *pn, int keyid, size_t *encrypted_len);
/** /**
* @brief One-Key GMAC hash with AES for MIC computation * @brief One-Key GMAC hash callback function with AES for MIC computation
* *
* @key: key for the hash operation * @param key key for the hash operation
* @keylen: key length * @param keylen key length
* @iv: initialization vector * @param iv initialization vector
* @iv_len: initialization vector length * @param iv_len initialization vector length
* @aad: aad * @param aad aad
* @aad_len: aad length * @param aad_len aad length
* @mic: Buffer for MIC (128 bits, i.e., 16 bytes) * @param mic Buffer for MIC (128 bits, i.e., 16 bytes)
* Returns: 0 on success, -1 on failure * Returns: 0 on success, -1 on failure
*/ */
typedef int (*esp_aes_gmac_t)(const uint8_t *key, size_t keylen, const uint8_t *iv, size_t iv_len, typedef int (*esp_aes_gmac_t)(const uint8_t *key, size_t keylen, const uint8_t *iv, size_t iv_len,
const uint8_t *aad, size_t aad_len, uint8_t *mic); const uint8_t *aad, size_t aad_len, uint8_t *mic);
/** /**
* @brief SHA256 hash for data vector * @brief SHA256 hash callback function for data vector
* @num_elem: Number of elements in the data vector * @param num_elem Number of elements in the data vector
* @addr: Pointers to the data areas * @param addr Pointers to the data areas
* @len: Lengths of the data blocks * @param len Lengths of the data blocks
* @mac: Buffer for the hash * @param mac Buffer for the hash
* Returns: 0 on success, -1 on failure * Returns: 0 on success, -1 on failure
*/ */
typedef int (*esp_sha256_vector_t)(size_t num_elem, const uint8_t *addr[], const size_t *len, uint8_t *buf); typedef int (*esp_sha256_vector_t)(size_t num_elem, const uint8_t *addr[], const size_t *len, uint8_t *buf);
/** /**
* @brief CRC32 value in little endian. * @brief CRC32 value callback function in little endian.
* *
* @param crc: Initial CRC value (result of last calculation or 0 for the first time) * @param crc Initial CRC value (result of last calculation or 0 for the first time)
* @param buf: Data buffer that used to calculate the CRC value * @param buf Data buffer that used to calculate the CRC value
* @param len: Length of the data buffer * @param len Length of the data buffer
* @return CRC32 value * @return CRC32 value
*/ */
typedef uint32_t (*esp_crc32_le_t)(uint32_t crc, uint8_t const *buf, uint32_t len); typedef uint32_t (*esp_crc32_le_t)(uint32_t crc, uint8_t const *buf, uint32_t len);
/** /**
* @brief The crypto callback function structure used when do station security connect. * @brief The crypto callback function structure used by esp_wifi.
* The structure can be set as software crypto or the crypto optimized by device's * The structure can be set as software crypto or the crypto optimized by device's
* hardware. * hardware.
*/ */
typedef struct { typedef struct {
uint32_t size; uint32_t size; /**< The crypto callback function structure size */
uint32_t version; uint32_t version; /**< The crypto callback function structure version */
esp_aes_wrap_t aes_wrap; /**< station connect function used when send EAPOL frame */ esp_aes_wrap_t aes_wrap; /**< The AES wrap callback function used by esp_wifi */
esp_aes_unwrap_t aes_unwrap; /**< station connect function used when decrypt key data */ esp_aes_unwrap_t aes_unwrap; /**< The AES unwrap callback function used by esp_wifi */
esp_hmac_sha256_vector_t hmac_sha256_vector; /**< station connect function used when check MIC */ esp_hmac_sha256_vector_t hmac_sha256_vector; /**< The SHA256 callback function used by esp_wifi */
esp_sha256_prf_t sha256_prf; /**< station connect function used when check MIC */ esp_sha256_prf_t sha256_prf; /**< The SHA256 PRF callback function used by esp_wifi */
esp_hmac_md5_t hmac_md5; esp_hmac_md5_t hmac_md5; /**< HMAC-MD5 callback function over data buffer (RFC 2104) */
esp_hmac_md5_vector_t hamc_md5_vector; esp_hmac_md5_vector_t hamc_md5_vector; /**< HMAC-MD5 callback function over data vector (RFC 2104) */
esp_hmac_sha1_t hmac_sha1; esp_hmac_sha1_t hmac_sha1; /**< HMAC-SHA1 callback function over data buffer (RFC 2104) */
esp_hmac_sha1_vector_t hmac_sha1_vector; esp_hmac_sha1_vector_t hmac_sha1_vector; /**< HMAC-SHA1 callback function over data vector (RFC 2104) */
esp_sha1_prf_t sha1_prf; esp_sha1_prf_t sha1_prf; /**< SHA1-based Pseudo-Random Function (PRF) (IEEE 802.11i, 8.5.1.1) callback function */
esp_sha1_vector_t sha1_vector; esp_sha1_vector_t sha1_vector; /**< SHA-1 hash callback function for data vector */
esp_pbkdf2_sha1_t pbkdf2_sha1; esp_pbkdf2_sha1_t pbkdf2_sha1; /**< SHA1-based key derivation function (PBKDF2) callback function for IEEE 802.11i */
esp_rc4_skip_t rc4_skip; esp_rc4_skip_t rc4_skip; /**< XOR RC4 stream callback function to given data with skip-stream-start */
esp_md5_vector_t md5_vector; esp_md5_vector_t md5_vector; /**< MD5 hash callback function for data vector */
esp_aes_encrypt_t aes_encrypt; esp_aes_encrypt_t aes_encrypt; /**< Encrypt one AES block callback function */
esp_aes_encrypt_init_t aes_encrypt_init; esp_aes_encrypt_init_t aes_encrypt_init; /**< Initialize AES callback function for encryption */
esp_aes_encrypt_deinit_t aes_encrypt_deinit; esp_aes_encrypt_deinit_t aes_encrypt_deinit; /**< Deinitialize AES encryption callback function */
esp_aes_decrypt_t aes_decrypt; esp_aes_decrypt_t aes_decrypt; /**< Decrypt one AES block callback function */
esp_aes_decrypt_init_t aes_decrypt_init; esp_aes_decrypt_init_t aes_decrypt_init; /**< Initialize AES callback function for decryption */
esp_aes_decrypt_deinit_t aes_decrypt_deinit; esp_aes_decrypt_deinit_t aes_decrypt_deinit; /**< Deinitialize AES decryption callback function */
esp_aes_128_encrypt_t aes_128_encrypt; esp_aes_128_encrypt_t aes_128_encrypt; /**< The AES 128 encrypt callback function used by esp_wifi */
esp_aes_128_decrypt_t aes_128_decrypt; esp_aes_128_decrypt_t aes_128_decrypt; /**< The AES 128 decrypt callback function used by esp_wifi */
esp_omac1_aes_128_t omac1_aes_128; esp_omac1_aes_128_t omac1_aes_128; /**< One-Key CBC MAC (OMAC1) hash with AES-128 callback function for MIC computation */
esp_ccmp_decrypt_t ccmp_decrypt; esp_ccmp_decrypt_t ccmp_decrypt; /**< Decrypt data callback function using CCMP */
esp_ccmp_encrypt_t ccmp_encrypt; esp_ccmp_encrypt_t ccmp_encrypt; /**< Encrypt data callback function using CCMP */
esp_aes_gmac_t aes_gmac; esp_aes_gmac_t aes_gmac; /**< One-Key GMAC hash callback function with AES for MIC computation */
esp_sha256_vector_t sha256_vector; esp_sha256_vector_t sha256_vector; /**< SHA256 hash callback function for data vector */
esp_crc32_le_t crc32; esp_crc32_le_t crc32; /**< CRC32 value callback function in little endian */
}wpa_crypto_funcs_t; }wpa_crypto_funcs_t;
/** /**
@ -428,8 +431,8 @@ typedef struct {
* hardware. * hardware.
*/ */
typedef struct{ typedef struct{
esp_aes_128_encrypt_t aes_128_encrypt; /**< function used in mesh vendor IE encryption */ esp_aes_128_encrypt_t aes_128_encrypt; /**< Callback function used in mesh vendor IE encryption */
esp_aes_128_decrypt_t aes_128_decrypt; /**< function used in mesh vendor IE decryption */ esp_aes_128_decrypt_t aes_128_decrypt; /**< Callback function used in mesh vendor IE decryption */
} mesh_crypto_funcs_t; } mesh_crypto_funcs_t;
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -8,6 +8,7 @@
#define _ESP_WIFI_DEFAULT_H #define _ESP_WIFI_DEFAULT_H
#include "esp_netif.h" #include "esp_netif.h"
#include "esp_wifi_types.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -25,7 +25,7 @@ extern "C" {
* @attention Support at most 8 TWT agreements, otherwise ESP_ERR_WIFI_TWT_FULL will be returned. * @attention Support at most 8 TWT agreements, otherwise ESP_ERR_WIFI_TWT_FULL will be returned.
* Support sleep time up to (1 << 35) us. * Support sleep time up to (1 << 35) us.
* *
* @param[in/out] setup_config pointer to itwt setup config structure. * @param[in,out] setup_config pointer to itwt setup config structure.
* *
* @return * @return
* - ESP_OK: succeed * - ESP_OK: succeed

View File

@ -1,11 +1,17 @@
/* /*
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#pragma once #pragma once
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#include "esp_wifi_types.h"
#include "esp_netif_types.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -133,6 +133,9 @@ typedef enum {
WIFI_REASON_ROAMING = 207, WIFI_REASON_ROAMING = 207,
WIFI_REASON_ASSOC_COMEBACK_TIME_TOO_LONG = 208, WIFI_REASON_ASSOC_COMEBACK_TIME_TOO_LONG = 208,
WIFI_REASON_SA_QUERY_TIMEOUT = 209, WIFI_REASON_SA_QUERY_TIMEOUT = 209,
WIFI_REASON_NO_AP_FOUND_W_COMPATIBLE_SECURITY = 210,
WIFI_REASON_NO_AP_FOUND_IN_AUTHMODE_THRESHOLD = 211,
WIFI_REASON_NO_AP_FOUND_IN_RSSI_THRESHOLD = 212,
} wifi_err_reason_t; } wifi_err_reason_t;
typedef enum { typedef enum {
@ -450,24 +453,26 @@ typedef struct {
signed rssi:8; /**< Received Signal Strength Indicator(RSSI) of packet. unit: dBm */ signed rssi:8; /**< Received Signal Strength Indicator(RSSI) of packet. unit: dBm */
unsigned rate:5; /**< PHY rate encoding of the packet. Only valid for non HT(11bg) packet */ unsigned rate:5; /**< PHY rate encoding of the packet. Only valid for non HT(11bg) packet */
unsigned :1; /**< reserved */ unsigned :1; /**< reserved */
unsigned sig_mode:2; /**< 0: non HT(11bg) packet; 1: HT(11n) packet; 3: VHT(11ac) packet */ unsigned sig_mode:2; /**< Protocol of the reveived packet, 0: non HT(11bg) packet; 1: HT(11n) packet; 3: VHT(11ac) packet */
unsigned :16; /**< reserved */ unsigned :16; /**< reserved */
unsigned mcs:7; /**< Modulation Coding Scheme. If is HT(11n) packet, shows the modulation, range from 0 to 76(MSC0 ~ MCS76) */ unsigned mcs:7; /**< Modulation Coding Scheme. If is HT(11n) packet, shows the modulation, range from 0 to 76(MSC0 ~ MCS76) */
unsigned cwb:1; /**< Channel Bandwidth of the packet. 0: 20MHz; 1: 40MHz */ unsigned cwb:1; /**< Channel Bandwidth of the packet. 0: 20MHz; 1: 40MHz */
unsigned :16; /**< reserved */ unsigned :16; /**< reserved */
unsigned smoothing:1; /**< reserved */ unsigned smoothing:1; /**< Set to 1 indicates that channel estimate smoothing is recommended.
unsigned not_sounding:1; /**< reserved */ Set to 0 indicates that only per-carrierindependent (unsmoothed) channel estimate is recommended. */
unsigned not_sounding:1; /**< Set to 0 indicates that PPDU is a sounding PPDU. Set to 1indicates that the PPDU is not a sounding PPDU.
sounding PPDU is used for channel estimation by the request receiver */
unsigned :1; /**< reserved */ unsigned :1; /**< reserved */
unsigned aggregation:1; /**< Aggregation. 0: MPDU packet; 1: AMPDU packet */ unsigned aggregation:1; /**< Aggregation. 0: MPDU packet; 1: AMPDU packet */
unsigned stbc:2; /**< Space Time Block Code(STBC). 0: non STBC packet; 1: STBC packet */ unsigned stbc:2; /**< Space Time Block Code(STBC). 0: non STBC packet; 1: STBC packet */
unsigned fec_coding:1; /**< Flag is set for 11n packets which are LDPC */ unsigned fec_coding:1; /**< Forward Error Correction(FEC). Flag is set for 11n packets which are LDPC */
unsigned sgi:1; /**< Short Guide Interval(SGI). 0: Long GI; 1: Short GI */ unsigned sgi:1; /**< Short Guide Interval(SGI). 0: Long GI; 1: Short GI */
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32
signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/ signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 #elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2
unsigned :8; /**< reserved */ unsigned :8; /**< reserved */
#endif #endif
unsigned ampdu_cnt:8; /**< ampdu cnt */ unsigned ampdu_cnt:8; /**< the number of subframes aggregated in AMPDU */
unsigned channel:4; /**< primary channel on which this packet is received */ unsigned channel:4; /**< primary channel on which this packet is received */
unsigned secondary_channel:4; /**< secondary channel on which this packet is received. 0: none; 1: above; 2: below */ unsigned secondary_channel:4; /**< secondary channel on which this packet is received. 0: none; 1: above; 2: below */
unsigned :8; /**< reserved */ unsigned :8; /**< reserved */
@ -572,9 +577,12 @@ typedef struct {
wifi_pkt_rx_ctrl_t rx_ctrl;/**< received packet radio metadata header of the CSI data */ wifi_pkt_rx_ctrl_t rx_ctrl;/**< received packet radio metadata header of the CSI data */
uint8_t mac[6]; /**< source MAC address of the CSI data */ uint8_t mac[6]; /**< source MAC address of the CSI data */
uint8_t dmac[6]; /**< destination MAC address of the CSI data */ uint8_t dmac[6]; /**< destination MAC address of the CSI data */
bool first_word_invalid; /**< first four bytes of the CSI data is invalid or not */ bool first_word_invalid; /**< first four bytes of the CSI data is invalid or not, true indicates the first four bytes is invalid due to hardware limition */
int8_t *buf; /**< buffer of CSI data */ int8_t *buf; /**< valid buffer of CSI data */
uint16_t len; /**< length of CSI data */ uint16_t len; /**< valid length of CSI data */
uint8_t *hdr; /**< header of the wifi packet */
uint8_t *payload; /**< payload of the wifi packet */
uint16_t payload_len; /**< payload len of the wifi packet */
} wifi_csi_info_t; } wifi_csi_info_t;
/** /**

View File

@ -1,20 +1,16 @@
// Copyright 2010-2017 Espressif Systems (Shanghai) PTE LTD /*
// * SPDX-FileCopyrightText: 2010-2023 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// You may obtain a copy of the License at */
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SMARTCONFIG_ACK_H #ifndef SMARTCONFIG_ACK_H
#define SMARTCONFIG_ACK_H #define SMARTCONFIG_ACK_H
#include "esp_smartconfig.h"
#include "esp_err.h"
#include <stdint.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -16,7 +16,7 @@
#include "esp_private/esp_clk.h" #include "esp_private/esp_clk.h"
#include "esp_wpa.h" #include "esp_wpa.h"
#include "esp_netif.h" #include "esp_netif.h"
#include "esp_coexist_internal.h" #include "private/esp_coexist_internal.h"
#include "esp_phy_init.h" #include "esp_phy_init.h"
#include "esp_private/phy.h" #include "esp_private/phy.h"
#ifdef CONFIG_ESP_WIFI_NAN_ENABLE #ifdef CONFIG_ESP_WIFI_NAN_ENABLE

View File

@ -217,10 +217,10 @@ int wpa_auth_for_each_sta(struct wpa_authenticator *wpa_auth,
} }
static void wpa_sta_disconnect(struct wpa_authenticator *wpa_auth, static void wpa_sta_disconnect(struct wpa_authenticator *wpa_auth,
const u8 *addr) const u8 *addr, u16 reason)
{ {
wpa_printf(MSG_DEBUG, "wpa_sta_disconnect STA " MACSTR, MAC2STR(addr)); wpa_printf(MSG_DEBUG, "wpa_sta_disconnect STA " MACSTR, MAC2STR(addr));
esp_wifi_ap_deauth_internal((uint8_t*)addr, WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT); esp_wifi_ap_deauth_internal((uint8_t*)addr, reason);
return; return;
} }
@ -797,7 +797,8 @@ continue_processing:
"collect more entropy for random number " "collect more entropy for random number "
"generation"); "generation");
random_mark_pool_ready(); random_mark_pool_ready();
wpa_sta_disconnect(wpa_auth, sm->addr); wpa_sta_disconnect(wpa_auth, sm->addr,
WLAN_REASON_PREV_AUTH_NOT_VALID);
return; return;
} }
if (wpa_parse_kde_ies((u8 *) (key + 1), key_data_length, if (wpa_parse_kde_ies((u8 *) (key + 1), key_data_length,
@ -824,12 +825,14 @@ continue_processing:
wpa_hexdump(MSG_DEBUG, "WPA IE in msg 2/4", wpa_hexdump(MSG_DEBUG, "WPA IE in msg 2/4",
eapol_key_ie, eapol_key_ie_len); eapol_key_ie, eapol_key_ie_len);
/* MLME-DEAUTHENTICATE.request */ /* MLME-DEAUTHENTICATE.request */
wpa_sta_disconnect(wpa_auth, sm->addr); wpa_sta_disconnect(wpa_auth, sm->addr,
WLAN_REASON_PREV_AUTH_NOT_VALID);
return; return;
} }
#ifdef CONFIG_IEEE80211R_AP #ifdef CONFIG_IEEE80211R_AP
if (ft && ft_check_msg_2_of_4(wpa_auth, sm, &kde) < 0) { if (ft && ft_check_msg_2_of_4(wpa_auth, sm, &kde) < 0) {
wpa_sta_disconnect(wpa_auth, sm->addr); wpa_sta_disconnect(wpa_auth, sm->addr,
WLAN_REASON_PREV_AUTH_NOT_VALID);
return; return;
} }
#endif /* CONFIG_IEEE80211R_AP */ #endif /* CONFIG_IEEE80211R_AP */
@ -863,6 +866,8 @@ continue_processing:
if (sm->PTK_valid && !sm->update_snonce) { if (sm->PTK_valid && !sm->update_snonce) {
if (wpa_verify_key_mic(sm->wpa_key_mgmt, &sm->PTK, data, if (wpa_verify_key_mic(sm->wpa_key_mgmt, &sm->PTK, data,
data_len)) { data_len)) {
wpa_printf(MSG_INFO,
"received EAPOL-Key with invalid MIC");
return; return;
} }
sm->MICVerified = TRUE; sm->MICVerified = TRUE;
@ -876,6 +881,8 @@ continue_processing:
memcpy(sm->req_replay_counter, key->replay_counter, memcpy(sm->req_replay_counter, key->replay_counter,
WPA_REPLAY_COUNTER_LEN); WPA_REPLAY_COUNTER_LEN);
} else { } else {
wpa_printf(MSG_INFO,
"received EAPOL-Key request with invalid MIC");
return; return;
} }
@ -1359,9 +1366,14 @@ SM_STATE(WPA_PTK, INITIALIZE)
SM_STATE(WPA_PTK, DISCONNECT) SM_STATE(WPA_PTK, DISCONNECT)
{ {
u16 reason = sm->disconnect_reason;
SM_ENTRY_MA(WPA_PTK, DISCONNECT, wpa_ptk); SM_ENTRY_MA(WPA_PTK, DISCONNECT, wpa_ptk);
sm->Disconnect = FALSE; sm->Disconnect = FALSE;
wpa_sta_disconnect(sm->wpa_auth, sm->addr); sm->disconnect_reason = 0;
if (!reason)
reason = WLAN_REASON_PREV_AUTH_NOT_VALID;
wpa_sta_disconnect(sm->wpa_auth, sm->addr, reason);
} }
@ -1431,7 +1443,7 @@ SM_STATE(WPA_PTK, AUTHENTICATION2)
if (os_get_random(sm->ANonce, WPA_NONCE_LEN)) { if (os_get_random(sm->ANonce, WPA_NONCE_LEN)) {
wpa_printf( MSG_ERROR, "WPA: Failed to get random data for " wpa_printf( MSG_ERROR, "WPA: Failed to get random data for "
"ANonce."); "ANonce.");
wpa_sta_disconnect(sm->wpa_auth, sm->addr); sm->Disconnect = true;
return; return;
} }
wpa_hexdump(MSG_DEBUG, "WPA: Assign ANonce", sm->ANonce, wpa_hexdump(MSG_DEBUG, "WPA: Assign ANonce", sm->ANonce,
@ -1645,11 +1657,8 @@ SM_STATE(WPA_PTK, PTKCALCNEGOTIATING)
if (wpa_verify_key_mic(sm->wpa_key_mgmt, &PTK, if (wpa_verify_key_mic(sm->wpa_key_mgmt, &PTK,
sm->last_rx_eapol_key, sm->last_rx_eapol_key,
sm->last_rx_eapol_key_len) == 0) { sm->last_rx_eapol_key_len) == 0) {
wpa_printf( MSG_DEBUG, "mic verify ok, pmk=%p", pmk);
ok = 1; ok = 1;
break; break;
} else {
wpa_printf( MSG_DEBUG, "mic verify fail, pmk=%p", pmk);
} }
if (!wpa_key_mgmt_wpa_psk(sm->wpa_key_mgmt) || if (!wpa_key_mgmt_wpa_psk(sm->wpa_key_mgmt) ||
@ -1660,6 +1669,7 @@ SM_STATE(WPA_PTK, PTKCALCNEGOTIATING)
} }
if (!ok) { if (!ok) {
wpa_printf(MSG_INFO, "invalid MIC in msg 2/4 of 4-Way Handshake");
return; return;
} }
@ -1705,7 +1715,8 @@ SM_STATE(WPA_PTK, PTKCALCNEGOTIATING)
sm->rsnxe, sm->rsnxe_len); sm->rsnxe, sm->rsnxe_len);
wpa_hexdump(MSG_DEBUG, "RSNXE in EAPOL-Key msg 2/4", wpa_hexdump(MSG_DEBUG, "RSNXE in EAPOL-Key msg 2/4",
kde.rsnxe, kde.rsnxe_len); kde.rsnxe, kde.rsnxe_len);
wpa_sta_disconnect(sm->wpa_auth, sm->addr); wpa_sta_disconnect(sm->wpa_auth, sm->addr,
WLAN_REASON_PREV_AUTH_NOT_VALID);
return; return;
} }
@ -1950,7 +1961,8 @@ SM_STATE(WPA_PTK, PTKINITDONE)
int klen = wpa_cipher_key_len(sm->pairwise); int klen = wpa_cipher_key_len(sm->pairwise);
if (wpa_auth_set_key(sm->wpa_auth, 0, alg, sm->addr, 0, if (wpa_auth_set_key(sm->wpa_auth, 0, alg, sm->addr, 0,
sm->PTK.tk, klen)) { sm->PTK.tk, klen)) {
wpa_sta_disconnect(sm->wpa_auth, sm->addr); wpa_sta_disconnect(sm->wpa_auth, sm->addr,
WLAN_REASON_PREV_AUTH_NOT_VALID);
return; return;
} }
/* FIX: MLME-SetProtection.Request(TA, Tx_Rx) */ /* FIX: MLME-SetProtection.Request(TA, Tx_Rx) */
@ -2062,6 +2074,8 @@ SM_STEP(WPA_PTK)
SM_ENTER(WPA_PTK, PTKCALCNEGOTIATING); SM_ENTER(WPA_PTK, PTKCALCNEGOTIATING);
else if (sm->TimeoutCtr > else if (sm->TimeoutCtr >
(int) dot11RSNAConfigPairwiseUpdateCount) { (int) dot11RSNAConfigPairwiseUpdateCount) {
sm->disconnect_reason =
WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT;
SM_ENTER(WPA_PTK, DISCONNECT); SM_ENTER(WPA_PTK, DISCONNECT);
} else if (sm->TimeoutEvt) } else if (sm->TimeoutEvt)
SM_ENTER(WPA_PTK, PTKSTART); SM_ENTER(WPA_PTK, PTKSTART);
@ -2086,6 +2100,8 @@ SM_STEP(WPA_PTK)
SM_ENTER(WPA_PTK, PTKINITDONE); SM_ENTER(WPA_PTK, PTKINITDONE);
else if (sm->TimeoutCtr > else if (sm->TimeoutCtr >
(int) dot11RSNAConfigPairwiseUpdateCount) { (int) dot11RSNAConfigPairwiseUpdateCount) {
sm->disconnect_reason =
WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT;
SM_ENTER(WPA_PTK, DISCONNECT); SM_ENTER(WPA_PTK, DISCONNECT);
} else if (sm->TimeoutEvt) } else if (sm->TimeoutEvt)
SM_ENTER(WPA_PTK, PTKINITNEGOTIATING); SM_ENTER(WPA_PTK, PTKINITNEGOTIATING);
@ -2191,6 +2207,7 @@ SM_STATE(WPA_PTK_GROUP, KEYERROR)
sm->group->GKeyDoneStations--; sm->group->GKeyDoneStations--;
sm->GUpdateStationKeys = FALSE; sm->GUpdateStationKeys = FALSE;
sm->Disconnect = TRUE; sm->Disconnect = TRUE;
sm->disconnect_reason = WLAN_REASON_GROUP_KEY_UPDATE_TIMEOUT;
} }

View File

@ -47,6 +47,7 @@ struct wpa_state_machine {
Boolean AuthenticationRequest; Boolean AuthenticationRequest;
Boolean ReAuthenticationRequest; Boolean ReAuthenticationRequest;
Boolean Disconnect; Boolean Disconnect;
u16 disconnect_reason; /* specific reason code to use with Disconnect */
int TimeoutCtr; int TimeoutCtr;
int GTimeoutCtr; int GTimeoutCtr;
Boolean TimeoutEvt; Boolean TimeoutEvt;

View File

@ -2740,14 +2740,16 @@ int wpa_sm_set_ap_rsnxe(const u8 *ie, size_t len)
sm->ap_rsnxe_len = len; sm->ap_rsnxe_len = len;
} }
sm->sae_pwe = esp_wifi_get_config_sae_pwe_h2e_internal(WIFI_IF_STA); if (sm->ap_rsnxe != NULL) {
sm->sae_pwe = esp_wifi_get_config_sae_pwe_h2e_internal(WIFI_IF_STA);
#ifdef CONFIG_SAE_PK #ifdef CONFIG_SAE_PK
const u8 *pw = (const u8 *)esp_wifi_sta_get_prof_password_internal(); const u8 *pw = (const u8 *)esp_wifi_sta_get_prof_password_internal();
if (esp_wifi_sta_get_config_sae_pk_internal() != WPA3_SAE_PK_MODE_DISABLED && if (esp_wifi_sta_get_config_sae_pk_internal() != WPA3_SAE_PK_MODE_DISABLED &&
sae_pk_valid_password((const char*)pw)) { sae_pk_valid_password((const char*)pw)) {
sm->sae_pk = true; sm->sae_pk = true;
} }
#endif /* CONFIG_SAE_PK */ #endif /* CONFIG_SAE_PK */
}
return 0; return 0;
} }

View File

@ -27,6 +27,7 @@ INPUT = \
$(PROJECT_PATH)/components/bootloader_support/include/bootloader_random.h \ $(PROJECT_PATH)/components/bootloader_support/include/bootloader_random.h \
$(PROJECT_PATH)/components/bootloader_support/include/esp_app_format.h \ $(PROJECT_PATH)/components/bootloader_support/include/esp_app_format.h \
$(PROJECT_PATH)/components/bootloader_support/include/esp_flash_encrypt.h \ $(PROJECT_PATH)/components/bootloader_support/include/esp_flash_encrypt.h \
$(PROJECT_PATH)/components/esp_coex/include/esp_coexist.h \
$(PROJECT_PATH)/components/bt/common/api/include/api/esp_blufi_api.h \ $(PROJECT_PATH)/components/bt/common/api/include/api/esp_blufi_api.h \
$(PROJECT_PATH)/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_common_api.h \ $(PROJECT_PATH)/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_common_api.h \
$(PROJECT_PATH)/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_local_data_operation_api.h \ $(PROJECT_PATH)/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_local_data_operation_api.h \
@ -196,10 +197,14 @@ INPUT = \
$(PROJECT_PATH)/components/esp_system/include/esp_task_wdt.h \ $(PROJECT_PATH)/components/esp_system/include/esp_task_wdt.h \
$(PROJECT_PATH)/components/esp_system/include/esp_task.h \ $(PROJECT_PATH)/components/esp_system/include/esp_task.h \
$(PROJECT_PATH)/components/esp_timer/include/esp_timer.h \ $(PROJECT_PATH)/components/esp_timer/include/esp_timer.h \
$(PROJECT_PATH)/components/esp_wifi/include/esp_mesh_internal.h \
$(PROJECT_PATH)/components/esp_wifi/include/esp_mesh.h \ $(PROJECT_PATH)/components/esp_wifi/include/esp_mesh.h \
$(PROJECT_PATH)/components/esp_wifi/include/esp_now.h \ $(PROJECT_PATH)/components/esp_wifi/include/esp_now.h \
$(PROJECT_PATH)/components/esp_wifi/include/esp_smartconfig.h \ $(PROJECT_PATH)/components/esp_wifi/include/esp_smartconfig.h \
$(PROJECT_PATH)/components/esp_wifi/include/esp_wifi_ap_get_sta_list.h \
$(PROJECT_PATH)/components/esp_wifi/include/esp_wifi_crypto_types.h \
$(PROJECT_PATH)/components/esp_wifi/include/esp_wifi_default.h \ $(PROJECT_PATH)/components/esp_wifi/include/esp_wifi_default.h \
$(PROJECT_PATH)/components/esp_wifi/include/esp_wifi_netif.h \
$(PROJECT_PATH)/components/esp_wifi/include/esp_wifi_types.h \ $(PROJECT_PATH)/components/esp_wifi/include/esp_wifi_types.h \
$(PROJECT_PATH)/components/esp_wifi/include/esp_wifi.h \ $(PROJECT_PATH)/components/esp_wifi/include/esp_wifi.h \
$(PROJECT_PATH)/components/wpa_supplicant/esp_supplicant/include/esp_mbo.h \ $(PROJECT_PATH)/components/wpa_supplicant/esp_supplicant/include/esp_mbo.h \

View File

@ -11,3 +11,5 @@ INPUT += \
$(PROJECT_PATH)/components/esp_phy/include/esp_phy_init.h \ $(PROJECT_PATH)/components/esp_phy/include/esp_phy_init.h \
$(PROJECT_PATH)/components/esp_phy/include/esp_phy_cert_test.h \ $(PROJECT_PATH)/components/esp_phy/include/esp_phy_cert_test.h \
$(PROJECT_PATH)/components/ulp/ulp_common/include/ulp_common.h \ $(PROJECT_PATH)/components/ulp/ulp_common/include/ulp_common.h \
$(PROJECT_PATH)/components/esp_wifi/include/esp_wifi_he_types.h \
$(PROJECT_PATH)/components/esp_wifi/include/esp_wifi_he.h \

View File

@ -2,3 +2,4 @@ INPUT += \
$(PROJECT_PATH)/components/bt/include/esp32h2/include/esp_bt.h \ $(PROJECT_PATH)/components/bt/include/esp32h2/include/esp_bt.h \
$(PROJECT_PATH)/components/esp_phy/include/esp_phy_init.h \ $(PROJECT_PATH)/components/esp_phy/include/esp_phy_init.h \
$(PROJECT_PATH)/components/esp_phy/include/esp_phy_cert_test.h \ $(PROJECT_PATH)/components/esp_phy/include/esp_phy_cert_test.h \
$(PROJECT_PATH)/components/esp_coex/include/esp_coex_i154.h \

View File

@ -85,8 +85,6 @@ Espressif SoCs mask ROM hardware includes binaries compiled from portions of the
* miniz_, by Rich Geldreich - placed into the public domain. * miniz_, by Rich Geldreich - placed into the public domain.
* `wpa_supplicant`_ Copyright (c) 2003-2022 Jouni Malinen <j@w1.fi> and contributors and licensed under the BSD license.
* TJpgDec_ Copyright (C) 2011, ChaN, all right reserved. See below for license. * TJpgDec_ Copyright (C) 2011, ChaN, all right reserved. See below for license.
* Parts of Zephyr RTOS USB stack: * Parts of Zephyr RTOS USB stack:

View File

@ -301,17 +301,8 @@ void app_main(void)
/* mesh initialization */ /* mesh initialization */
ESP_ERROR_CHECK(esp_mesh_init()); ESP_ERROR_CHECK(esp_mesh_init());
ESP_ERROR_CHECK(esp_event_handler_register(MESH_EVENT, ESP_EVENT_ANY_ID, &mesh_event_handler, NULL)); ESP_ERROR_CHECK(esp_event_handler_register(MESH_EVENT, ESP_EVENT_ANY_ID, &mesh_event_handler, NULL));
/* mesh enable IE crypto */ /* mesh config */
mesh_cfg_t cfg = MESH_INIT_CONFIG_DEFAULT(); mesh_cfg_t cfg = MESH_INIT_CONFIG_DEFAULT();
#if CONFIG_MESH_IE_CRYPTO_FUNCS
/* modify IE crypto key */
ESP_ERROR_CHECK(esp_mesh_set_ie_crypto_funcs(&g_wifi_default_mesh_crypto_funcs));
ESP_ERROR_CHECK(esp_mesh_set_ie_crypto_key(CONFIG_MESH_IE_CRYPTO_KEY, strlen(CONFIG_MESH_IE_CRYPTO_KEY)));
#else
/* disable IE crypto */
ESP_LOGI(MESH_TAG, "<Config>disable IE crypto");
ESP_ERROR_CHECK(esp_mesh_set_ie_crypto_funcs(NULL));
#endif
/* mesh ID */ /* mesh ID */
memcpy((uint8_t *) &cfg.mesh_id, MESH_ID, 6); memcpy((uint8_t *) &cfg.mesh_id, MESH_ID, 6);
/* router */ /* router */
@ -327,6 +318,16 @@ void app_main(void)
memcpy((uint8_t *) &cfg.mesh_ap.password, CONFIG_MESH_AP_PASSWD, memcpy((uint8_t *) &cfg.mesh_ap.password, CONFIG_MESH_AP_PASSWD,
strlen(CONFIG_MESH_AP_PASSWD)); strlen(CONFIG_MESH_AP_PASSWD));
ESP_ERROR_CHECK(esp_mesh_set_config(&cfg)); ESP_ERROR_CHECK(esp_mesh_set_config(&cfg));
/* mesh enable IE crypto */
#if CONFIG_MESH_IE_CRYPTO_FUNCS
/* modify IE crypto key */
ESP_ERROR_CHECK(esp_mesh_set_ie_crypto_funcs(&g_wifi_default_mesh_crypto_funcs));
ESP_ERROR_CHECK(esp_mesh_set_ie_crypto_key(CONFIG_MESH_IE_CRYPTO_KEY, strlen(CONFIG_MESH_IE_CRYPTO_KEY)));
#else
/* disable IE crypto */
ESP_LOGI(MESH_TAG, "<Config>disable IE crypto");
ESP_ERROR_CHECK(esp_mesh_set_ie_crypto_funcs(NULL));
#endif
/* mesh start */ /* mesh start */
ESP_ERROR_CHECK(esp_mesh_start()); ESP_ERROR_CHECK(esp_mesh_start());
ESP_LOGI(MESH_TAG, "mesh starts successfully, heap:%" PRId32, esp_get_free_heap_size()); ESP_LOGI(MESH_TAG, "mesh starts successfully, heap:%" PRId32, esp_get_free_heap_size());

View File

@ -39,7 +39,7 @@
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "driver/usb_serial_jtag.h" #include "driver/usb_serial_jtag.h"
#include "esp_coexist_internal.h" #include "esp_coexist.h"
#include "esp_log.h" #include "esp_log.h"
#include "esp_netif.h" #include "esp_netif.h"
#include "esp_spiffs.h" #include "esp_spiffs.h"
@ -173,8 +173,7 @@ void app_main(void)
ESP_ERROR_CHECK(example_connect()); ESP_ERROR_CHECK(example_connect());
#if CONFIG_ESP_COEX_SW_COEXIST_ENABLE #if CONFIG_ESP_COEX_SW_COEXIST_ENABLE
ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_MIN_MODEM)); ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_MIN_MODEM));
coex_enable(); esp_coex_wifi_i154_enable();
coex_schm_status_bit_set(1, 1);
#else #else
ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE)); ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE));
#endif #endif

View File

@ -502,7 +502,6 @@ components/esp_system/test_eh_frame_parser/linker.ld
components/esp_system/ubsan.c components/esp_system/ubsan.c
components/esp_wifi/include/esp_private/esp_wifi_types_private.h components/esp_wifi/include/esp_private/esp_wifi_types_private.h
components/esp_wifi/include/esp_private/wifi_types.h components/esp_wifi/include/esp_private/wifi_types.h
components/esp_wifi/include/smartconfig_ack.h
components/esp_wifi/src/mesh_event.c components/esp_wifi/src/mesh_event.c
components/fatfs/diskio/diskio.c components/fatfs/diskio/diskio.c
components/fatfs/diskio/diskio_impl.h components/fatfs/diskio/diskio_impl.h

View File

@ -88,8 +88,7 @@ components/esp_hw_support/include/esp_private/esp_memprot_internal.h
### Here are the files that use CONFIG_XXX values but don't include sdkconfig.h ### Here are the files that use CONFIG_XXX values but don't include sdkconfig.h
# #
components/esp_wifi/include/esp_private/wifi_os_adapter.h components/esp_coex/include/private/esp_coexist_adapter.h
components/esp_coex/include/esp_coexist_adapter.h
components/esp_coex/include/esp_coex_i154.h components/esp_coex/include/esp_coex_i154.h
### To be fixed: headers that rely on implicit inclusion ### To be fixed: headers that rely on implicit inclusion
# #
@ -110,10 +109,6 @@ components/esp_rom/include/esp32s2/rom/secure_boot.h
components/esp_rom/include/esp32s2/rom/opi_flash.h components/esp_rom/include/esp32s2/rom/opi_flash.h
components/esp_rom/include/esp32s2/rom/efuse.h components/esp_rom/include/esp32s2/rom/efuse.h
components/esp_ringbuf/include/freertos/ringbuf.h components/esp_ringbuf/include/freertos/ringbuf.h
components/esp_wifi/include/esp_wifi_crypto_types.h
components/esp_wifi/include/esp_wifi_netif.h
components/esp_wifi/include/smartconfig_ack.h
components/esp_wifi/include/esp_wifi_default.h
components/esp_netif/include/esp_netif_defaults.h components/esp_netif/include/esp_netif_defaults.h
components/esp_netif/include/esp_netif_net_stack.h components/esp_netif/include/esp_netif_net_stack.h
components/esp_netif/include/esp_netif_ppp.h components/esp_netif/include/esp_netif_ppp.h
@ -121,7 +116,6 @@ components/protocomm/include/transports/protocomm_httpd.h
components/fatfs/src/diskio.h components/fatfs/src/diskio.h
components/fatfs/diskio/diskio_sdmmc.h components/fatfs/diskio/diskio_sdmmc.h
components/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h components/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h
components/wifi_provisioning/include/wifi_provisioning/scheme_softap.h
components/usb/include/esp_private/usb_phy.h components/usb/include/esp_private/usb_phy.h
components/usb/include/usb/usb_types_stack.h components/usb/include/usb/usb_types_stack.h