mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-04 05:04:33 +02:00
fix(esp_wifi): Address review comments
This commit is contained in:
@@ -37,7 +37,8 @@ typedef enum {
|
|||||||
ESP_EAP_TYPE_TLS = (1 << 0), /*!< EAP-TLS method */
|
ESP_EAP_TYPE_TLS = (1 << 0), /*!< EAP-TLS method */
|
||||||
ESP_EAP_TYPE_TTLS = (1 << 1), /*!< EAP-TTLS method */
|
ESP_EAP_TYPE_TTLS = (1 << 1), /*!< EAP-TTLS method */
|
||||||
ESP_EAP_TYPE_PEAP = (1 << 2), /*!< EAP-PEAP method */
|
ESP_EAP_TYPE_PEAP = (1 << 2), /*!< EAP-PEAP method */
|
||||||
ESP_EAP_TYPE_FAST = (1 << 3) /*!< EAP-FAST method */
|
ESP_EAP_TYPE_FAST = (1 << 3), /*!< EAP-FAST method */
|
||||||
|
ESP_EAP_TYPE_ALL = (ESP_EAP_TYPE_TLS | ESP_EAP_TYPE_TTLS | ESP_EAP_TYPE_PEAP | ESP_EAP_TYPE_FAST), /*!< All supported EAP methods */
|
||||||
} esp_eap_method_t;
|
} esp_eap_method_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -361,8 +362,7 @@ esp_err_t esp_eap_client_set_domain_name(const char *domain_name);
|
|||||||
* - ESP_ERR_INVALID_ARG if none of the methods are valid
|
* - ESP_ERR_INVALID_ARG if none of the methods are valid
|
||||||
*
|
*
|
||||||
* @note
|
* @note
|
||||||
* If this API is not called or `EAP_TYPE_NONE` is passed, EAP methods will be dynamically
|
* If this API is not called, all supported EAP methods will be considered.
|
||||||
* selected at runtime based on configuration from other `esp_eap_client_*` APIs.
|
|
||||||
* If one or more methods are set using this API, only the specified methods will be considered.
|
* If one or more methods are set using this API, only the specified methods will be considered.
|
||||||
*/
|
*/
|
||||||
esp_err_t esp_eap_client_set_eap_methods(esp_eap_method_t methods);
|
esp_err_t esp_eap_client_set_eap_methods(esp_eap_method_t methods);
|
||||||
|
@@ -820,8 +820,6 @@ static esp_err_t esp_client_enable_fn(void *arg)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
g_wpa_config_changed = true;
|
g_wpa_config_changed = true;
|
||||||
/* Enable opportunistic key caching support */
|
|
||||||
esp_wifi_set_okc_support(true);
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -858,9 +856,11 @@ esp_err_t esp_wifi_sta_enterprise_enable(void)
|
|||||||
|
|
||||||
static void eap_globals_reset(void)
|
static void eap_globals_reset(void)
|
||||||
{
|
{
|
||||||
|
os_free(g_wpa_anonymous_identity);
|
||||||
g_wpa_anonymous_identity = NULL;
|
g_wpa_anonymous_identity = NULL;
|
||||||
g_wpa_anonymous_identity_len = 0;
|
g_wpa_anonymous_identity_len = 0;
|
||||||
|
|
||||||
|
os_free(g_wpa_username);
|
||||||
g_wpa_username = NULL;
|
g_wpa_username = NULL;
|
||||||
g_wpa_username_len = 0;
|
g_wpa_username_len = 0;
|
||||||
|
|
||||||
@@ -876,15 +876,19 @@ static void eap_globals_reset(void)
|
|||||||
g_wpa_ca_cert = NULL;
|
g_wpa_ca_cert = NULL;
|
||||||
g_wpa_ca_cert_len = 0;
|
g_wpa_ca_cert_len = 0;
|
||||||
|
|
||||||
|
os_free(g_wpa_password);
|
||||||
g_wpa_password = NULL;
|
g_wpa_password = NULL;
|
||||||
g_wpa_password_len = 0;
|
g_wpa_password_len = 0;
|
||||||
|
|
||||||
|
os_free(g_wpa_new_password);
|
||||||
g_wpa_new_password = NULL;
|
g_wpa_new_password = NULL;
|
||||||
g_wpa_new_password_len = 0;
|
g_wpa_new_password_len = 0;
|
||||||
|
|
||||||
g_wpa_ttls_phase2_type = NULL;
|
g_wpa_ttls_phase2_type = NULL;
|
||||||
|
os_free(g_wpa_phase1_options);
|
||||||
g_wpa_phase1_options = NULL;
|
g_wpa_phase1_options = NULL;
|
||||||
|
|
||||||
|
os_free(g_wpa_pac_file);
|
||||||
g_wpa_pac_file = NULL;
|
g_wpa_pac_file = NULL;
|
||||||
g_wpa_pac_file_len = 0;
|
g_wpa_pac_file_len = 0;
|
||||||
|
|
||||||
@@ -896,9 +900,10 @@ static void eap_globals_reset(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_TLS_INTERNAL_CLIENT
|
#ifndef CONFIG_TLS_INTERNAL_CLIENT
|
||||||
|
os_free(g_wpa_domain_match);
|
||||||
g_wpa_domain_match = NULL;
|
g_wpa_domain_match = NULL;
|
||||||
#endif
|
#endif
|
||||||
g_eap_method_mask = 0;
|
g_eap_method_mask = ESP_EAP_TYPE_ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static esp_err_t eap_client_disable_fn(void *param)
|
static esp_err_t eap_client_disable_fn(void *param)
|
||||||
@@ -1313,9 +1318,8 @@ esp_err_t esp_eap_client_set_domain_name(const char *domain_name)
|
|||||||
|
|
||||||
esp_err_t esp_eap_client_set_eap_methods(esp_eap_method_t methods)
|
esp_err_t esp_eap_client_set_eap_methods(esp_eap_method_t methods)
|
||||||
{
|
{
|
||||||
const esp_eap_method_t supported_methods = EAP_TYPE_TLS | EAP_TYPE_TTLS | EAP_TYPE_PEAP | EAP_TYPE_FAST;
|
|
||||||
|
|
||||||
if ((methods & ~supported_methods) != 0) {
|
if ((methods & ~ESP_EAP_TYPE_ALL) != 0) {
|
||||||
return ESP_ERR_INVALID_ARG;
|
return ESP_ERR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -71,7 +71,7 @@ int (*esp_crt_bundle_attach_fn)(void *conf);
|
|||||||
#ifndef CONFIG_TLS_INTERNAL_CLIENT
|
#ifndef CONFIG_TLS_INTERNAL_CLIENT
|
||||||
char *g_wpa_domain_match;
|
char *g_wpa_domain_match;
|
||||||
#endif
|
#endif
|
||||||
uint32_t g_eap_method_mask;
|
uint32_t g_eap_method_mask = ESP_EAP_TYPE_ALL;
|
||||||
|
|
||||||
void eap_peer_config_deinit(struct eap_sm *sm);
|
void eap_peer_config_deinit(struct eap_sm *sm);
|
||||||
void eap_peer_blob_deinit(struct eap_sm *sm);
|
void eap_peer_blob_deinit(struct eap_sm *sm);
|
||||||
@@ -625,19 +625,19 @@ int eap_peer_config_init(
|
|||||||
|
|
||||||
if (g_wpa_username) {
|
if (g_wpa_username) {
|
||||||
//set EAP-PEAP
|
//set EAP-PEAP
|
||||||
if ((g_eap_method_mask == 0) || (g_eap_method_mask & ESP_EAP_TYPE_PEAP)) {
|
if (g_eap_method_mask & ESP_EAP_TYPE_PEAP) {
|
||||||
config_methods[allowed_method_count].vendor = EAP_VENDOR_IETF;
|
config_methods[allowed_method_count].vendor = EAP_VENDOR_IETF;
|
||||||
config_methods[allowed_method_count++].method = EAP_TYPE_PEAP;
|
config_methods[allowed_method_count++].method = EAP_TYPE_PEAP;
|
||||||
}
|
}
|
||||||
//set EAP-TTLS
|
//set EAP-TTLS
|
||||||
if ((g_eap_method_mask == 0) || (g_eap_method_mask & ESP_EAP_TYPE_TTLS)) {
|
if (g_eap_method_mask & ESP_EAP_TYPE_TTLS) {
|
||||||
config_methods[allowed_method_count].vendor = EAP_VENDOR_IETF;
|
config_methods[allowed_method_count].vendor = EAP_VENDOR_IETF;
|
||||||
config_methods[allowed_method_count++].method = EAP_TYPE_TTLS;
|
config_methods[allowed_method_count++].method = EAP_TYPE_TTLS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (g_wpa_private_key) {
|
if (g_wpa_private_key) {
|
||||||
//set EAP-TLS
|
//set EAP-TLS
|
||||||
if ((g_eap_method_mask == 0) || (g_eap_method_mask & ESP_EAP_TYPE_TLS)) {
|
if (g_eap_method_mask & ESP_EAP_TYPE_TLS) {
|
||||||
config_methods[allowed_method_count].vendor = EAP_VENDOR_IETF;
|
config_methods[allowed_method_count].vendor = EAP_VENDOR_IETF;
|
||||||
config_methods[allowed_method_count++].method = EAP_TYPE_TLS;
|
config_methods[allowed_method_count++].method = EAP_TYPE_TLS;
|
||||||
}
|
}
|
||||||
@@ -645,7 +645,7 @@ int eap_peer_config_init(
|
|||||||
#ifdef EAP_FAST
|
#ifdef EAP_FAST
|
||||||
if (g_wpa_pac_file) {
|
if (g_wpa_pac_file) {
|
||||||
//set EAP-FAST
|
//set EAP-FAST
|
||||||
if ((g_eap_method_mask == 0) || (g_eap_method_mask & ESP_EAP_TYPE_FAST)) {
|
if (g_eap_method_mask & ESP_EAP_TYPE_FAST) {
|
||||||
config_methods[allowed_method_count].vendor = EAP_VENDOR_IETF;
|
config_methods[allowed_method_count].vendor = EAP_VENDOR_IETF;
|
||||||
config_methods[allowed_method_count++].method = EAP_TYPE_FAST;
|
config_methods[allowed_method_count++].method = EAP_TYPE_FAST;
|
||||||
}
|
}
|
||||||
|
@@ -96,7 +96,7 @@ static void event_handler(void* arg, esp_event_base_t event_base,
|
|||||||
|
|
||||||
static void initialise_wifi(void)
|
static void initialise_wifi(void)
|
||||||
{
|
{
|
||||||
esp_eap_method_t eap_methods = ESP_EAP_TYPE_NONE;
|
esp_eap_method_t eap_methods = ESP_EAP_TYPE_ALL;
|
||||||
#ifdef SERVER_CERT_VALIDATION_ENABLED
|
#ifdef SERVER_CERT_VALIDATION_ENABLED
|
||||||
unsigned int ca_pem_bytes = ca_pem_end - ca_pem_start;
|
unsigned int ca_pem_bytes = ca_pem_end - ca_pem_start;
|
||||||
#endif /* SERVER_CERT_VALIDATION_ENABLED */
|
#endif /* SERVER_CERT_VALIDATION_ENABLED */
|
||||||
|
Reference in New Issue
Block a user