Skip to content

Commit

Permalink
Merge branch 'docs/update_wifi_and_wpa_supplicant_documentation_v4.4'…
Browse files Browse the repository at this point in the history
… into 'release/v4.4'

docs(wifi): Update wifi and wifi security documentation and bugfixes

See merge request espressif/esp-idf!25831
  • Loading branch information
jack0c committed Oct 18, 2023
2 parents 006f076 + a319ccb commit 6087eb2
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 102 deletions.
2 changes: 1 addition & 1 deletion components/esp_wifi/Kconfig
Expand Up @@ -244,7 +244,7 @@ menu "Wi-Fi"
config ESP32_WIFI_ENABLE_WPA3_SAE
bool "Enable WPA3-Personal"
default y
depends on WPA_MBEDTLS_CRYPTO
select WPA_MBEDTLS_CRYPTO
help
Select this option to allow the device to establish a WPA3-Personal connection with eligible AP's.
PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be
Expand Down
6 changes: 3 additions & 3 deletions components/esp_wifi/include/esp_mesh.h
Expand Up @@ -1414,7 +1414,7 @@ esp_err_t esp_mesh_set_parent(const wifi_config_t *parent, const mesh_addr_t *pa
* @return
* - ESP_OK
* - ESP_ERR_WIFI_NOT_INIT
* - ESP_ERR_WIFI_ARG
* - ESP_ERR_INVALID_ARG
* - ESP_ERR_WIFI_FAIL
*/
esp_err_t esp_mesh_scan_get_ap_ie_len(int *len);
Expand All @@ -1431,7 +1431,7 @@ esp_err_t esp_mesh_scan_get_ap_ie_len(int *len);
* @return
* - ESP_OK
* - ESP_ERR_WIFI_NOT_INIT
* - ESP_ERR_WIFI_ARG
* - ESP_ERR_INVALID_ARG
* - ESP_ERR_WIFI_FAIL
*/
esp_err_t esp_mesh_scan_get_ap_record(wifi_ap_record_t *ap_record, void *buffer);
Expand Down Expand Up @@ -1520,7 +1520,7 @@ esp_err_t esp_mesh_switch_channel(const uint8_t *new_bssid, int csa_newchan, int
* @return
* - ESP_OK
* - ESP_ERR_WIFI_NOT_INIT
* - ESP_ERR_WIFI_ARG
* - ESP_ERR_INVALID_ARG
*/
esp_err_t esp_mesh_get_router_bssid(uint8_t *router_bssid);

Expand Down
2 changes: 1 addition & 1 deletion components/esp_wifi/include/esp_mesh_internal.h
Expand Up @@ -126,7 +126,7 @@ typedef struct {
* @return
* - ESP_OK
* - ESP_FAIL
* - ESP_ERR_WIFI_ARG
* - ESP_ERR_INVALID_ARG
*/
esp_err_t esp_mesh_set_beacon_interval(int interval_ms);

Expand Down
8 changes: 4 additions & 4 deletions components/esp_wifi/include/esp_private/wifi.h
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -132,7 +132,7 @@ void esp_wifi_internal_free_rx_buffer(void* buffer);
* @return
* - ESP_OK : Successfully transmit the buffer to wifi driver
* - ESP_ERR_NO_MEM: out of memory
* - ESP_ERR_WIFI_ARG: invalid argument
* - ESP_ERR_INVALID_ARG: invalid argument
* - ESP_ERR_WIFI_IF : WiFi interface is invalid
* - ESP_ERR_WIFI_CONN : WiFi interface is not created, e.g. send the data to STA while WiFi mode is AP mode
* - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started
Expand Down Expand Up @@ -171,7 +171,7 @@ typedef void (*wifi_netstack_buf_free_cb_t)(void *netstack_buf);
* @return
* - ESP_OK : Successfully transmit the buffer to wifi driver
* - ESP_ERR_NO_MEM: out of memory
* - ESP_ERR_WIFI_ARG: invalid argument
* - ESP_ERR_INVALID_ARG: invalid argument
* - ESP_ERR_WIFI_IF : WiFi interface is invalid
* - ESP_ERR_WIFI_CONN : WiFi interface is not created, e.g. send the data to STA while WiFi mode is AP mode
* - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started
Expand Down Expand Up @@ -417,7 +417,7 @@ esp_err_t esp_wifi_internal_set_log_level(wifi_log_level_t level);
* @return
* - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_ARG: invalid argument
* - ESP_ERR_INVALID_ARG: invalid argument
*/
esp_err_t esp_wifi_internal_set_log_mod(wifi_log_module_t module, uint32_t submodule, bool enable);

Expand Down
42 changes: 22 additions & 20 deletions components/esp_wifi/include/esp_wifi.h
Expand Up @@ -344,9 +344,9 @@ esp_err_t esp_wifi_restore(void);
* @attention 3. The scanning triggered by esp_wifi_scan_start() will not be effective until connection between ESP32 and the AP is established.
* If ESP32 is scanning and connecting at the same time, ESP32 will abort scanning and return a warning message and error
* number ESP_ERR_WIFI_STATE.
* If you want to do reconnection after ESP32 received disconnect event, remember to add the maximum retry time, otherwise the called
* scan will not work. This is especially true when the AP doesn't exist, and you still try reconnection after ESP32 received disconnect
* event with the reason code WIFI_REASON_NO_AP_FOUND.
* @attention 4. This API attempts to connect to an Access Point (AP) only once. To enable reconnection in case of a connection failure, please use
* the 'failure_retry_cnt' feature in the 'wifi_sta_config_t'. Users are suggested to implement reconnection logic in their application
* for scenarios where the specified AP does not exist, or reconnection is desired after the device has received a disconnect event.
*
* @return
* - ESP_OK: succeed
Expand Down Expand Up @@ -401,7 +401,10 @@ esp_err_t esp_wifi_deauth_sta(uint16_t aid);
* @attention The values of maximum active scan time and passive scan time per channel are limited to 1500 milliseconds.
* Values above 1500ms may cause station to disconnect from AP and are not recommended.
*
* @param config configuration of scanning
* @param config configuration settings for scanning, if set to NULL default settings will be used
* of which default values are show_hidden:false, scan_type:active, scan_time.active.min:0,
* scan_time.active.max:120 miliseconds, scan_time.passive:360 miliseconds
*
* @param block if block is true, this API will block the caller until the scan is done, otherwise
* it will return immediately
*
Expand Down Expand Up @@ -785,7 +788,7 @@ esp_err_t esp_wifi_set_promiscuous_ctrl_filter(const wifi_promiscuous_filter_t *
* @return
* - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_ARG: invalid argument
* - ESP_ERR_INVALID_ARG: invalid argument
*/
esp_err_t esp_wifi_get_promiscuous_ctrl_filter(wifi_promiscuous_filter_t *filter);

Expand Down Expand Up @@ -932,7 +935,7 @@ esp_err_t esp_wifi_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx);
* - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
* - ESP_ERR_WIFI_ARG: invalid argument, e.g. parameter is out of range
* - ESP_ERR_INVALID_ARG: invalid argument, e.g. parameter is out of range
*/
esp_err_t esp_wifi_set_max_tx_power(int8_t power);

Expand All @@ -945,7 +948,7 @@ esp_err_t esp_wifi_set_max_tx_power(int8_t power);
* - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
* - ESP_ERR_WIFI_ARG: invalid argument
* - ESP_ERR_INVALID_ARG: invalid argument
*/
esp_err_t esp_wifi_get_max_tx_power(int8_t *power);

Expand Down Expand Up @@ -974,7 +977,7 @@ esp_err_t esp_wifi_set_event_mask(uint32_t mask);
* @return
* - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_ARG: invalid argument
* - ESP_ERR_INVALID_ARG: invalid argument
*/
esp_err_t esp_wifi_get_event_mask(uint32_t *mask);

Expand All @@ -994,7 +997,7 @@ esp_err_t esp_wifi_get_event_mask(uint32_t *mask);
* the system sequence number.
* Generally, if esp_wifi_80211_tx is called before the Wi-Fi connection has been set up, both
* en_sys_seq==true and en_sys_seq==false are fine. However, if the API is called after the Wi-Fi
* connection has been set up, en_sys_seq must be true, otherwise ESP_ERR_WIFI_ARG is returned.
* connection has been set up, en_sys_seq must be true, otherwise ESP_ERR_INVALID_ARG is returned.
*
* @return
* - ESP_OK: success
Expand Down Expand Up @@ -1066,7 +1069,7 @@ esp_err_t esp_wifi_set_csi(bool en);
* @return
* - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_ARG: Invalid argument, e.g. parameter is NULL, invalid GPIO number etc
* - ESP_ERR_INVALID_ARG: Invalid argument, e.g. parameter is NULL, invalid GPIO number etc
*/
esp_err_t esp_wifi_set_ant_gpio(const wifi_ant_gpio_config_t *config);

Expand All @@ -1078,7 +1081,7 @@ esp_err_t esp_wifi_set_ant_gpio(const wifi_ant_gpio_config_t *config);
* @return
* - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_ARG: invalid argument, e.g. parameter is NULL
* - ESP_ERR_INVALID_ARG: invalid argument, e.g. parameter is NULL
*/
esp_err_t esp_wifi_get_ant_gpio(wifi_ant_gpio_config_t *config);

Expand All @@ -1091,7 +1094,7 @@ esp_err_t esp_wifi_get_ant_gpio(wifi_ant_gpio_config_t *config);
* @return
* - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_ARG: Invalid argument, e.g. parameter is NULL, invalid antenna mode or invalid GPIO number
* - ESP_ERR_INVALID_ARG: Invalid argument, e.g. parameter is NULL, invalid antenna mode or invalid GPIO number
*/
esp_err_t esp_wifi_set_ant(const wifi_ant_config_t *config);

Expand All @@ -1103,7 +1106,7 @@ esp_err_t esp_wifi_set_ant(const wifi_ant_config_t *config);
* @return
* - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_ARG: invalid argument, e.g. parameter is NULL
* - ESP_ERR_INVALID_ARG: invalid argument, e.g. parameter is NULL
*/
esp_err_t esp_wifi_get_ant(wifi_ant_config_t *config);

Expand Down Expand Up @@ -1136,7 +1139,7 @@ int64_t esp_wifi_get_tsf_time(wifi_interface_t interface);
* - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
* - ESP_ERR_WIFI_ARG: invalid argument, For Station, if sec is less than 3. For SoftAP, if sec is less than 10.
* - ESP_ERR_INVALID_ARG: invalid argument, For Station, if sec is less than 3. For SoftAP, if sec is less than 10.
*/
esp_err_t esp_wifi_set_inactive_time(wifi_interface_t ifx, uint16_t sec);

Expand All @@ -1150,7 +1153,7 @@ esp_err_t esp_wifi_set_inactive_time(wifi_interface_t ifx, uint16_t sec);
* - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
* - ESP_ERR_WIFI_ARG: invalid argument
* - ESP_ERR_INVALID_ARG: invalid argument
*/
esp_err_t esp_wifi_get_inactive_time(wifi_interface_t ifx, uint16_t *sec);

Expand All @@ -1166,16 +1169,17 @@ esp_err_t esp_wifi_get_inactive_time(wifi_interface_t ifx, uint16_t *sec);
esp_err_t esp_wifi_statis_dump(uint32_t modules);

/**
* @brief Set RSSI threshold below which APP will get an event
* @brief Set RSSI threshold, if average rssi gets lower than threshold, WiFi task will post event WIFI_EVENT_STA_BSS_RSSI_LOW.
*
* @attention This API needs to be called every time after WIFI_EVENT_STA_BSS_RSSI_LOW event is received.
* @attention If the user wants to receive another WIFI_EVENT_STA_BSS_RSSI_LOW event after receiving one, this API needs to be
* called again with an updated/same RSSI threshold.
*
* @param rssi threshold value in dbm between -100 to 0
*
* @return
* - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_ARG: invalid argument
* - ESP_ERR_INVALID_ARG: invalid argument
*/
esp_err_t esp_wifi_set_rssi_threshold(int32_t rssi);

Expand Down Expand Up @@ -1337,8 +1341,6 @@ esp_err_t esp_wifi_sta_get_aid(uint16_t *aid);
*
* @param[out] phymode store the negotiated phymode.
*
* @attention Operation phy mode, BIT[5]: indicate whether LR enabled, BIT[0-4]: wifi_phy_mode_t
*
* @return
* - ESP_OK: succeed
*/
Expand Down
37 changes: 19 additions & 18 deletions components/esp_wifi/include/esp_wifi_types.h
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -267,23 +267,24 @@ typedef struct {

/** @brief STA configuration settings for the ESP32 */
typedef struct {
uint8_t ssid[32]; /**< SSID of target AP. */
uint8_t password[64]; /**< Password of target AP. */
wifi_scan_method_t scan_method; /**< do all channel scan or fast scan */
bool bssid_set; /**< whether set MAC address of target AP or not. Generally, station_config.bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP.*/
uint8_t bssid[6]; /**< MAC address of target AP*/
uint8_t channel; /**< channel of target AP. Set to 1~13 to scan starting from the specified channel before connecting to AP. If the channel of AP is unknown, set it to 0.*/
uint16_t listen_interval; /**< Listen interval for ESP32 station to receive beacon when WIFI_PS_MAX_MODEM is set. Units: AP beacon intervals. Defaults to 3 if set to 0. */
wifi_sort_method_t sort_method; /**< sort the connect AP in the list by rssi or security mode */
wifi_scan_threshold_t threshold; /**< When sort_method is set, only APs which have an auth mode that is more secure than the selected auth mode and a signal stronger than the minimum RSSI will be used. */
wifi_pmf_config_t pmf_cfg; /**< Configuration for Protected Management Frame. Will be advertized in RSN Capabilities in RSN IE. */
uint32_t rm_enabled:1; /**< Whether Radio Measurements are enabled for the connection */
uint32_t btm_enabled:1; /**< Whether BSS Transition Management is enabled for the connection */
uint32_t mbo_enabled:1; /**< Whether MBO is enabled for the connection */
uint32_t transition_disable:1; /**< Whether to enable transition disable feature */
uint32_t reserved:28; /**< Reserved for future feature set */
wifi_sae_pwe_method_t sae_pwe_h2e; /**< Whether SAE hash to element is enabled */
uint8_t failure_retry_cnt; /**< Number of connection retries station will do before moving to next AP. scan_method should be set as WIFI_ALL_CHANNEL_SCAN to use this config. Note: Enabling this may cause connection time to increase incase best AP doesn't behave properly. */
uint8_t ssid[32]; /**< SSID of target AP. */
uint8_t password[64]; /**< Password of target AP. */
wifi_scan_method_t scan_method; /**< do all channel scan or fast scan */
bool bssid_set; /**< whether set MAC address of target AP or not. Generally, station_config.bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP.*/
uint8_t bssid[6]; /**< MAC address of target AP*/
uint8_t channel; /**< channel of target AP. Set to 1~13 to scan starting from the specified channel before connecting to AP. If the channel of AP is unknown, set it to 0.*/
uint16_t listen_interval; /**< Listen interval for ESP32 station to receive beacon when WIFI_PS_MAX_MODEM is set. Units: AP beacon intervals. Defaults to 3 if set to 0. */
wifi_sort_method_t sort_method; /**< sort the connect AP in the list by rssi or security mode */
wifi_scan_threshold_t threshold; /**< When scan_threshold is set, only APs which have an auth mode that is more secure than the selected auth mode and a signal stronger than the minimum RSSI will be used. */
wifi_pmf_config_t pmf_cfg; /**< Configuration for Protected Management Frame. Will be advertised in RSN Capabilities in RSN IE. */
uint32_t rm_enabled:1; /**< Whether Radio Measurements are enabled for the connection */
uint32_t btm_enabled:1; /**< Whether BSS Transition Management is enabled for the connection */
uint32_t mbo_enabled:1; /**< Whether MBO is enabled for the connection */
uint32_t transition_disable:1; /**< Whether to enable transition disable feature */
uint32_t reserved:28; /**< Reserved for future feature set */
wifi_sae_pwe_method_t sae_pwe_h2e; /**< Configuration for SAE PWE derivation method */
uint8_t failure_retry_cnt; /**< Number of connection retries station will do before moving to next AP. scan_method should be set as WIFI_ALL_CHANNEL_SCAN to use this config.
Note: Enabling this may cause connection time to increase incase best AP doesn't behave properly. */
} wifi_sta_config_t;

/** @brief Configuration data for ESP32 AP or STA.
Expand Down
1 change: 1 addition & 0 deletions components/wpa_supplicant/Kconfig
Expand Up @@ -8,6 +8,7 @@ menu "Supplicant"
select MBEDTLS_ECDH_C
select MBEDTLS_ECDSA_C
select MBEDTLS_TLS_ENABLED
select MBEDTLS_ECP_DP_SECP256R1_ENABLED
help
Select this option to use MbedTLS crypto APIs which utilize hardware acceleration.

Expand Down
8 changes: 4 additions & 4 deletions components/wpa_supplicant/esp_supplicant/include/esp_wpa2.h
Expand Up @@ -32,8 +32,8 @@ extern "C" {
/**
* @brief Enable wpa2 enterprise authentication.
*
* @attention 1. wpa2 enterprise authentication can only be used when ESP32 station is enabled.
* @attention 2. wpa2 enterprise authentication can only support TLS, PEAP-MSCHAPv2 and TTLS-MSCHAPv2 method.
* @attention 1. wpa2 enterprise authentication can only be used when station mode is enabled.
* @attention 2. wpa2 enterprise authentication supports EAP-FAST, TLS, PEAP, TTLS(EAP, MSCHAPv2, MSCHAP, PAP, CHAP) methods.
*
* @return
* - ESP_OK: succeed.
Expand All @@ -44,8 +44,8 @@ esp_err_t esp_wifi_sta_wpa2_ent_enable(void);
/**
* @brief Disable wpa2 enterprise authentication.
*
* @attention 1. wpa2 enterprise authentication can only be used when ESP32 station is enabled.
* @attention 2. wpa2 enterprise authentication can only support TLS, PEAP-MSCHAPv2 and TTLS-MSCHAPv2 method.
* @attention 1. wpa2 enterprise authentication can only be used when station mode is enabled.
* @attention 2. wpa2 enterprise authentication supports EAP-FAST, TLS, PEAP, TTLS(EAP, MSCHAPv2, MSCHAP, PAP, CHAP) methods.
*
* @return
* - ESP_OK: succeed.
Expand Down
1 change: 0 additions & 1 deletion components/wpa_supplicant/src/common/sae.c
Expand Up @@ -77,7 +77,6 @@ int sae_set_group(struct sae_data *sae, int group)
/* Unsupported group */
wpa_printf(MSG_DEBUG,
"SAE: Group %d not supported by the crypto library", group);
os_free(tmp);
return ESP_FAIL;
}

Expand Down

0 comments on commit 6087eb2

Please sign in to comment.