forked from espressif/esp-idf
wpa_supplicant: Move ETS/ESP timers to eloop
This commit is contained in:
@@ -836,7 +836,7 @@ int esp_supplicant_post_evt(uint32_t evt_id, uint32_t data)
|
||||
os_free(evt);
|
||||
return -1;
|
||||
}
|
||||
if (os_queue_send(s_supplicant_evt_queue, &evt, 10 / portTICK_PERIOD_MS ) != TRUE) {
|
||||
if (os_queue_send(s_supplicant_evt_queue, &evt, os_task_ms_to_tick(10)) != TRUE) {
|
||||
SUPPLICANT_API_UNLOCK();
|
||||
os_free(evt);
|
||||
return -1;
|
||||
|
@@ -4,10 +4,13 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "utils/includes.h"
|
||||
#include "utils/common.h"
|
||||
#include "common/defs.h"
|
||||
|
||||
#include "esp_dpp_i.h"
|
||||
#include "esp_dpp.h"
|
||||
#include "esp_wpa.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "common/ieee802_11_defs.h"
|
||||
@@ -50,7 +53,7 @@ static int esp_dpp_post_evt(uint32_t evt_id, uint32_t data)
|
||||
ret = ESP_ERR_DPP_FAILURE;
|
||||
goto end;
|
||||
}
|
||||
if (os_queue_send(s_dpp_evt_queue, &evt, 10 / portTICK_PERIOD_MS ) != TRUE) {
|
||||
if (os_queue_send(s_dpp_evt_queue, &evt, os_task_ms_to_tick(10)) != TRUE) {
|
||||
DPP_API_UNLOCK();
|
||||
ret = ESP_ERR_DPP_FAILURE;
|
||||
goto end;
|
||||
|
@@ -276,7 +276,7 @@ int wpa2_post(uint32_t sig, uint32_t par)
|
||||
DATA_MUTEX_GIVE();
|
||||
evt->sig = sig;
|
||||
evt->par = par;
|
||||
if (os_queue_send(s_wpa2_queue, &evt, 10 / portTICK_PERIOD_MS ) != TRUE) {
|
||||
if (os_queue_send(s_wpa2_queue, &evt, os_task_ms_to_tick(10)) != TRUE) {
|
||||
wpa_printf(MSG_ERROR, "WPA2: Q S E");
|
||||
return ESP_FAIL;
|
||||
} else {
|
||||
|
@@ -7,6 +7,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "utils/includes.h"
|
||||
#include "common.h"
|
||||
#include "eloop.h"
|
||||
#include "rsn_supp/wpa.h"
|
||||
#include "utils/common.h"
|
||||
#include "common/eapol_common.h"
|
||||
@@ -53,7 +55,7 @@ static uint8_t s_wps_sig_cnt[SIG_WPS_NUM] = {0};
|
||||
#endif
|
||||
|
||||
void wifi_wps_scan_done(void *arg, STATUS status);
|
||||
void wifi_wps_scan(void);
|
||||
void wifi_wps_scan(void *data, void *user_ctx);
|
||||
int wifi_station_wps_start(void);
|
||||
int wps_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len);
|
||||
void wifi_wps_start_internal(void);
|
||||
@@ -66,6 +68,11 @@ void wifi_wps_scan_internal(void);
|
||||
void wifi_station_wps_eapol_start_handle_internal(void);
|
||||
void wps_add_discard_ap(u8 *bssid);
|
||||
|
||||
void wifi_station_wps_msg_timeout(void *data, void *user_ctx);
|
||||
void wifi_station_wps_eapol_start_handle(void *data, void *user_ctx);
|
||||
void wifi_station_wps_success(void *data, void *user_ctx);
|
||||
void wifi_station_wps_timeout(void *data, void *user_ctx);
|
||||
|
||||
struct wps_sm *gWpsSm = NULL;
|
||||
static wps_factory_information_t *s_factory_info = NULL;
|
||||
|
||||
@@ -228,7 +235,7 @@ int wps_post(uint32_t sig, uint32_t par)
|
||||
evt->par = par;
|
||||
DATA_MUTEX_GIVE();
|
||||
|
||||
if (os_queue_send(s_wps_queue, &evt, 10 / portTICK_PERIOD_MS) != TRUE) {
|
||||
if (os_queue_send(s_wps_queue, &evt, os_task_ms_to_tick(10)) != TRUE) {
|
||||
wpa_printf(MSG_ERROR, "WPS: Q S E");
|
||||
DATA_MUTEX_TAKE();
|
||||
s_wps_sig_cnt[sig]--;
|
||||
@@ -586,7 +593,7 @@ int wps_process_wps_mX_req(u8 *ubuf, int len, enum wps_process_res *res)
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
ets_timer_disarm(&sm->wps_msg_timeout_timer);
|
||||
eloop_cancel_timeout(wifi_station_wps_msg_timeout, NULL, NULL);
|
||||
|
||||
if (res) {
|
||||
*res = wps_enrollee_process_msg(sm->wps, expd->opcode, wps_buf);
|
||||
@@ -675,7 +682,7 @@ int wps_tx_start(void)
|
||||
wps_sm_ether_send(sm, ETH_P_EAPOL, buf, len);
|
||||
wps_sm_free_eapol(buf);
|
||||
|
||||
ets_timer_arm(&sm->wps_eapol_start_timer, 3000, 0);
|
||||
eloop_register_timeout(3, 0, wifi_station_wps_eapol_start_handle, NULL, NULL);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -693,8 +700,8 @@ int wps_start_pending(void)
|
||||
static void wps_stop_connection_timers(struct wps_sm *sm)
|
||||
{
|
||||
esp_wifi_disarm_sta_connection_timer_internal();
|
||||
ets_timer_disarm(&sm->wps_msg_timeout_timer);
|
||||
ets_timer_disarm(&sm->wps_success_cb_timer);
|
||||
eloop_cancel_timeout(wifi_station_wps_msg_timeout, NULL, NULL);
|
||||
eloop_cancel_timeout(wifi_station_wps_success, NULL, NULL);
|
||||
}
|
||||
|
||||
static int wps_sm_init(struct wps_sm *sm)
|
||||
@@ -765,8 +772,8 @@ int wps_finish(void)
|
||||
|
||||
os_free(config);
|
||||
}
|
||||
ets_timer_disarm(&sm->wps_success_cb_timer);
|
||||
ets_timer_arm(&sm->wps_success_cb_timer, 1000, 0);
|
||||
eloop_cancel_timeout(wifi_station_wps_success, NULL, NULL);
|
||||
eloop_register_timeout(1, 0, wifi_station_wps_success, NULL, NULL);
|
||||
|
||||
ret = 0;
|
||||
} else {
|
||||
@@ -820,14 +827,14 @@ int wps_start_msg_timer(void)
|
||||
if (sm->wps->state == WPS_FINISHED) {
|
||||
msg_timeout = 100;
|
||||
wpa_printf(MSG_DEBUG, "start msg timer WPS_FINISHED %d ms", msg_timeout);
|
||||
ets_timer_disarm(&sm->wps_msg_timeout_timer);
|
||||
ets_timer_arm(&sm->wps_msg_timeout_timer, msg_timeout, 0);
|
||||
eloop_cancel_timeout(wifi_station_wps_msg_timeout, NULL, NULL);
|
||||
eloop_register_timeout(0, msg_timeout*1000, wifi_station_wps_msg_timeout, NULL, NULL);
|
||||
ret = 0;
|
||||
} else if (sm->wps->state == RECV_M2) {
|
||||
msg_timeout = 5000;
|
||||
msg_timeout = 5;
|
||||
wpa_printf(MSG_DEBUG, "start msg timer RECV_M2 %d ms", msg_timeout);
|
||||
ets_timer_disarm(&sm->wps_msg_timeout_timer);
|
||||
ets_timer_arm(&sm->wps_msg_timeout_timer, msg_timeout, 0);
|
||||
eloop_cancel_timeout(wifi_station_wps_msg_timeout, NULL, NULL);
|
||||
eloop_register_timeout(msg_timeout, 0, wifi_station_wps_msg_timeout, NULL, NULL);
|
||||
ret = 0;
|
||||
}
|
||||
return ret;
|
||||
@@ -980,10 +987,10 @@ int wps_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len)
|
||||
case EAP_TYPE_IDENTITY:
|
||||
wpa_printf(MSG_DEBUG, "=========identity===========");
|
||||
sm->current_identifier = ehdr->identifier;
|
||||
ets_timer_disarm(&sm->wps_eapol_start_timer);
|
||||
eloop_cancel_timeout(wifi_station_wps_eapol_start_handle, NULL, NULL);
|
||||
wpa_printf(MSG_DEBUG, "WPS: Build EAP Identity.");
|
||||
ret = wps_send_eap_identity_rsp(ehdr->identifier);
|
||||
ets_timer_arm(&sm->wps_eapol_start_timer, 3000, 0);
|
||||
eloop_register_timeout(3, 0, wifi_station_wps_eapol_start_handle, NULL, NULL);
|
||||
break;
|
||||
case EAP_TYPE_EXPANDED:
|
||||
wpa_printf(MSG_DEBUG, "=========expanded plen[%d], %d===========", plen, sizeof(*ehdr));
|
||||
@@ -1019,13 +1026,13 @@ int wps_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len)
|
||||
}
|
||||
out:
|
||||
if (ret != 0 && sm->ignore_sel_reg) {
|
||||
wifi_wps_scan();
|
||||
wifi_wps_scan(NULL, NULL);
|
||||
} else if ((ret != 0 || res == WPS_FAILURE)) {
|
||||
wifi_event_sta_wps_fail_reason_t reason_code = WPS_FAIL_REASON_NORMAL;
|
||||
wpa_printf(MSG_DEBUG, "wpa rx eapol internal: fail ret=%d", ret);
|
||||
wps_set_status(WPS_STATUS_DISABLE);
|
||||
esp_wifi_disarm_sta_connection_timer_internal();
|
||||
ets_timer_disarm(&sm->wps_timeout_timer);
|
||||
eloop_cancel_timeout(wifi_station_wps_timeout, NULL, NULL);
|
||||
|
||||
esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_FAILED, &reason_code, sizeof(reason_code), OS_BLOCK);
|
||||
|
||||
@@ -1213,7 +1220,7 @@ wifi_station_wps_timeout_internal(void)
|
||||
esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_TIMEOUT, 0, 0, OS_BLOCK);
|
||||
}
|
||||
|
||||
void wifi_station_wps_timeout(void)
|
||||
void wifi_station_wps_timeout(void *data, void *user_ctx)
|
||||
{
|
||||
#ifdef USE_WPS_TASK
|
||||
wps_post(SIG_WPS_TIMER_TIMEOUT, 0);
|
||||
@@ -1248,11 +1255,11 @@ wifi_station_wps_msg_timeout_internal(void)
|
||||
os_bzero(sm->ssid_len, sizeof(sm->ssid_len));
|
||||
os_bzero(sm->bssid, ETH_ALEN);
|
||||
sm->discover_ssid_cnt = 0;
|
||||
wifi_wps_scan();
|
||||
wifi_wps_scan(NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_station_wps_msg_timeout(void)
|
||||
void wifi_station_wps_msg_timeout(void *data, void *user_ctx)
|
||||
{
|
||||
#ifdef USE_WPS_TASK
|
||||
wps_post(SIG_WPS_TIMER_MSG_TIMEOUT, 0);
|
||||
@@ -1286,7 +1293,7 @@ void wifi_station_wps_success_internal(void)
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_station_wps_success(void)
|
||||
void wifi_station_wps_success(void *data, void *user_ctx)
|
||||
{
|
||||
#ifdef USE_WPS_TASK
|
||||
wps_post(SIG_WPS_TIMER_SUCCESS_CB, 0);
|
||||
@@ -1302,7 +1309,7 @@ void wifi_station_wps_eapol_start_handle_internal(void)
|
||||
wps_tx_start();
|
||||
}
|
||||
|
||||
void wifi_station_wps_eapol_start_handle(void)
|
||||
void wifi_station_wps_eapol_start_handle(void *data, void *user_ctx)
|
||||
{
|
||||
#ifdef USE_WPS_TASK
|
||||
wps_post(SIG_WPS_TIMER_EAPOL_START, 0);
|
||||
@@ -1418,16 +1425,11 @@ wifi_station_wps_init(void)
|
||||
wps_build_ic_appie_wps_ar();
|
||||
}
|
||||
|
||||
ets_timer_disarm(&sm->wps_timeout_timer);
|
||||
ets_timer_setfn(&sm->wps_timeout_timer, (ETSTimerFunc *)wifi_station_wps_timeout, NULL);
|
||||
ets_timer_disarm(&sm->wps_msg_timeout_timer);
|
||||
ets_timer_setfn(&sm->wps_msg_timeout_timer, (ETSTimerFunc *)wifi_station_wps_msg_timeout, NULL);
|
||||
ets_timer_disarm(&sm->wps_success_cb_timer);
|
||||
ets_timer_setfn(&sm->wps_success_cb_timer, (ETSTimerFunc *)wifi_station_wps_success, NULL);
|
||||
ets_timer_disarm(&sm->wps_scan_timer);
|
||||
ets_timer_setfn(&sm->wps_scan_timer, (ETSTimerFunc *)wifi_wps_scan, NULL);
|
||||
ets_timer_disarm(&sm->wps_eapol_start_timer);
|
||||
ets_timer_setfn(&sm->wps_eapol_start_timer, (ETSTimerFunc *)wifi_station_wps_eapol_start_handle, NULL);
|
||||
eloop_cancel_timeout(wifi_station_wps_timeout, NULL, NULL);
|
||||
eloop_cancel_timeout(wifi_station_wps_msg_timeout, NULL, NULL);
|
||||
eloop_cancel_timeout(wifi_station_wps_success, NULL, NULL);
|
||||
eloop_cancel_timeout(wifi_wps_scan, NULL, NULL);
|
||||
eloop_cancel_timeout(wifi_station_wps_eapol_start_handle, NULL, NULL);
|
||||
|
||||
wps_cb = os_malloc(sizeof(struct wps_funcs));
|
||||
if (wps_cb == NULL) {
|
||||
@@ -1472,16 +1474,11 @@ int wps_delete_timer(void)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
ets_timer_disarm(&sm->wps_success_cb_timer);
|
||||
ets_timer_disarm(&sm->wps_timeout_timer);
|
||||
ets_timer_disarm(&sm->wps_msg_timeout_timer);
|
||||
ets_timer_disarm(&sm->wps_scan_timer);
|
||||
ets_timer_disarm(&sm->wps_eapol_start_timer);
|
||||
ets_timer_done(&sm->wps_success_cb_timer);
|
||||
ets_timer_done(&sm->wps_timeout_timer);
|
||||
ets_timer_done(&sm->wps_msg_timeout_timer);
|
||||
ets_timer_done(&sm->wps_scan_timer);
|
||||
ets_timer_done(&sm->wps_eapol_start_timer);
|
||||
eloop_cancel_timeout(wifi_station_wps_success, NULL, NULL);
|
||||
eloop_cancel_timeout(wifi_station_wps_timeout, NULL, NULL);
|
||||
eloop_cancel_timeout(wifi_station_wps_msg_timeout, NULL, NULL);
|
||||
eloop_cancel_timeout(wifi_wps_scan, NULL, NULL);
|
||||
eloop_cancel_timeout(wifi_station_wps_eapol_start_handle, NULL, NULL);
|
||||
esp_wifi_disarm_sta_connection_timer_internal();
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -1564,14 +1561,15 @@ wifi_wps_scan_done(void *arg, STATUS status)
|
||||
|
||||
wpa_printf(MSG_DEBUG, "WPS: neg start");
|
||||
esp_wifi_connect();
|
||||
ets_timer_disarm(&sm->wps_msg_timeout_timer);
|
||||
ets_timer_arm(&sm->wps_msg_timeout_timer, 2000, 0);
|
||||
eloop_cancel_timeout(wifi_station_wps_msg_timeout, NULL, NULL);
|
||||
eloop_register_timeout(2, 0, wifi_station_wps_msg_timeout, NULL, NULL);
|
||||
} else if (wps_get_status() == WPS_STATUS_SCANNING) {
|
||||
if (wps_get_type() == WPS_TYPE_PIN && sm->scan_cnt > WPS_IGNORE_SEL_REG_MAX_CNT) {
|
||||
wpa_printf(MSG_INFO, "WPS: ignore selected registrar after %d scans", sm->scan_cnt);
|
||||
sm->ignore_sel_reg = true;
|
||||
}
|
||||
ets_timer_arm(&sm->wps_scan_timer, 100, 0);
|
||||
eloop_cancel_timeout(wifi_wps_scan, NULL, NULL);
|
||||
eloop_register_timeout(0, 100*1000, wifi_wps_scan, NULL, NULL);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@@ -1590,7 +1588,7 @@ wifi_wps_scan_internal(void)
|
||||
esp_wifi_promiscuous_scan_start(NULL, wifi_wps_scan_done);
|
||||
}
|
||||
|
||||
void wifi_wps_scan(void)
|
||||
void wifi_wps_scan(void *data, void *user_ctx)
|
||||
{
|
||||
#ifdef USE_WPS_TASK
|
||||
wps_post(SIG_WPS_TIMER_SCAN, 0);
|
||||
@@ -1614,7 +1612,7 @@ int wifi_station_wps_start(void)
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
ets_timer_arm(&sm->wps_timeout_timer, 120000, 0); /* 120s total */
|
||||
eloop_register_timeout(120, 0, wifi_station_wps_timeout, NULL, NULL);
|
||||
|
||||
switch (wps_get_status()) {
|
||||
case WPS_STATUS_DISABLE: {
|
||||
@@ -1627,13 +1625,13 @@ int wifi_station_wps_start(void)
|
||||
sm->wps->wps->rf_band_cb = wps_rf_band_cb;
|
||||
wpabuf_clear_free(sm->wps->dh_privkey);
|
||||
sm->wps->dh_privkey = NULL;
|
||||
wifi_wps_scan();
|
||||
wifi_wps_scan(NULL, NULL);
|
||||
break;
|
||||
}
|
||||
case WPS_STATUS_SCANNING:
|
||||
sm->scan_cnt = 0;
|
||||
ets_timer_disarm(&sm->wps_timeout_timer);
|
||||
ets_timer_arm(&sm->wps_timeout_timer, 120000, 0); /* 120s total */
|
||||
eloop_cancel_timeout(wifi_station_wps_timeout, NULL, NULL);
|
||||
eloop_register_timeout(120, 0, wifi_station_wps_timeout, NULL, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@@ -61,11 +61,6 @@ struct wps_sm {
|
||||
u8 ap_cred_cnt;
|
||||
struct wps_device_data *dev;
|
||||
u8 uuid[16];
|
||||
ETSTimer wps_timeout_timer;
|
||||
ETSTimer wps_msg_timeout_timer;
|
||||
ETSTimer wps_scan_timer;
|
||||
ETSTimer wps_success_cb_timer;
|
||||
ETSTimer wps_eapol_start_timer;
|
||||
u8 current_identifier;
|
||||
bool is_wps_scan;
|
||||
u8 channel;
|
||||
@@ -123,3 +118,4 @@ static inline int wps_set_status(uint32_t status)
|
||||
return esp_wifi_set_wps_status_internal(status);
|
||||
}
|
||||
int wps_init_cfg_pin(struct wps_config *cfg);
|
||||
void wifi_station_wps_eapol_start_handle(void *data, void *user_ctx);
|
||||
|
@@ -16,7 +16,6 @@
|
||||
#include "common.h"
|
||||
#include "list.h"
|
||||
#include "eloop.h"
|
||||
#include "esp_wifi.h"
|
||||
|
||||
struct eloop_timeout {
|
||||
struct dl_list list;
|
||||
@@ -43,8 +42,8 @@ int eloop_init(void)
|
||||
{
|
||||
os_memset(&eloop, 0, sizeof(eloop));
|
||||
dl_list_init(&eloop.timeout);
|
||||
ets_timer_disarm(&eloop.eloop_timer);
|
||||
ets_timer_setfn(&eloop.eloop_timer, (ETSTimerFunc *)eloop_run, NULL);
|
||||
os_timer_disarm(&eloop.eloop_timer);
|
||||
os_timer_setfn(&eloop.eloop_timer, (ETSTimerFunc *)eloop_run, NULL);
|
||||
|
||||
eloop_data_lock = os_recursive_mutex_create();
|
||||
|
||||
@@ -100,8 +99,8 @@ int eloop_register_timeout(unsigned int secs, unsigned int usecs,
|
||||
ELOOP_UNLOCK();
|
||||
|
||||
run:
|
||||
ets_timer_disarm(&eloop.eloop_timer);
|
||||
ets_timer_arm(&eloop.eloop_timer, 0, 0);
|
||||
os_timer_disarm(&eloop.eloop_timer);
|
||||
os_timer_arm(&eloop.eloop_timer, 0, 0);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -271,8 +270,8 @@ void eloop_run(void)
|
||||
uint32_t ms;
|
||||
os_reltime_sub(&timeout->time, &now, &tv);
|
||||
ms = tv.sec * 1000 + tv.usec / 1000;
|
||||
ets_timer_disarm(&eloop.eloop_timer);
|
||||
ets_timer_arm(&eloop.eloop_timer, ms, 0);
|
||||
os_timer_disarm(&eloop.eloop_timer);
|
||||
os_timer_arm(&eloop.eloop_timer, ms, 0);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@@ -324,6 +323,6 @@ void eloop_destroy(void)
|
||||
os_semphr_delete(eloop_data_lock);
|
||||
eloop_data_lock = NULL;
|
||||
}
|
||||
ets_timer_disarm(&eloop.eloop_timer);
|
||||
os_timer_disarm(&eloop.eloop_timer);
|
||||
os_memset(&eloop, 0, sizeof(eloop));
|
||||
}
|
||||
|
@@ -55,6 +55,7 @@ static const u32 dot11RSNAConfigPairwiseUpdateCount = 4;
|
||||
#define WPA_SM_MAX_INDEX 16
|
||||
static void *s_sm_table[WPA_SM_MAX_INDEX];
|
||||
static u32 s_sm_valid_bitmap = 0;
|
||||
void resend_eapol_handle(void *data, void *user_ctx);
|
||||
|
||||
static struct wpa_state_machine * wpa_auth_get_sm(u32 index)
|
||||
{
|
||||
@@ -449,8 +450,7 @@ void wpa_auth_sta_deinit(struct wpa_state_machine *sm)
|
||||
if (sm == NULL)
|
||||
return;
|
||||
|
||||
ets_timer_disarm(&sm->resend_eapol);
|
||||
ets_timer_done(&sm->resend_eapol);
|
||||
eloop_cancel_timeout(resend_eapol_handle, (void*)(sm->index), NULL);
|
||||
|
||||
if (sm->in_step_loop) {
|
||||
/* Must not free state machine while wpa_sm_step() is running.
|
||||
@@ -806,8 +806,6 @@ continue_processing:
|
||||
}
|
||||
sm->MICVerified = TRUE;
|
||||
eloop_cancel_timeout(wpa_send_eapol_timeout, wpa_auth, sm);
|
||||
ets_timer_disarm(&sm->resend_eapol);
|
||||
ets_timer_done(&sm->resend_eapol);
|
||||
sm->pending_1_of_4_timeout = 0;
|
||||
}
|
||||
|
||||
@@ -1098,12 +1096,12 @@ int hostap_eapol_resend_process(void *timeout_ctx)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void resend_eapol_handle(void *timeout_ctx)
|
||||
void resend_eapol_handle(void *data, void *user_ctx)
|
||||
{
|
||||
wifi_ipc_config_t cfg;
|
||||
|
||||
cfg.fn = hostap_eapol_resend_process;
|
||||
cfg.arg = timeout_ctx;
|
||||
cfg.arg = data;
|
||||
cfg.arg_size = 0;
|
||||
esp_wifi_ipc_internal(&cfg, false);
|
||||
}
|
||||
@@ -1126,9 +1124,9 @@ static void wpa_send_eapol(struct wpa_authenticator *wpa_auth,
|
||||
ctr = pairwise ? sm->TimeoutCtr : sm->GTimeoutCtr;
|
||||
if (pairwise && ctr == 1 && !(key_info & WPA_KEY_INFO_MIC))
|
||||
sm->pending_1_of_4_timeout = 1;
|
||||
ets_timer_disarm(&sm->resend_eapol);
|
||||
ets_timer_setfn(&sm->resend_eapol, (ETSTimerFunc *)resend_eapol_handle, (void*)(sm->index));
|
||||
ets_timer_arm(&sm->resend_eapol, 1000, 0);
|
||||
|
||||
eloop_cancel_timeout(resend_eapol_handle, (void*)(sm->index), NULL);
|
||||
eloop_register_timeout(1, 0, resend_eapol_handle, (void*)(sm->index), NULL);
|
||||
}
|
||||
|
||||
static int wpa_verify_key_mic(int akmp, struct wpa_ptk *PTK, u8 *data,
|
||||
|
@@ -130,7 +130,6 @@ struct wpa_state_machine {
|
||||
|
||||
int pending_1_of_4_timeout;
|
||||
u32 index;
|
||||
ETSTimer resend_eapol;
|
||||
struct rsn_sppamsdu_sup spp_sup;
|
||||
};
|
||||
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include "utils/includes.h"
|
||||
|
||||
#include "utils/common.h"
|
||||
#include "utils/eloop.h"
|
||||
#include "common/ieee802_11_defs.h"
|
||||
#include "rsn_supp/wpa.h"
|
||||
#include "wpa_supplicant_i.h"
|
||||
@@ -21,7 +22,6 @@
|
||||
#include "ieee802_11_common.h"
|
||||
|
||||
#ifdef ESP_SUPPLICANT
|
||||
#include "esp_timer.h"
|
||||
#include "esp_mbo.h"
|
||||
|
||||
extern struct wpa_supplicant g_wpa_supp;
|
||||
@@ -522,18 +522,16 @@ wpa_bss_tmp_disallowed * wpas_get_disallowed_bss(struct wpa_supplicant *wpa_s,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void wpa_bss_tmp_disallow_timeout(void *timeout_ctx)
|
||||
static void wpa_bss_tmp_disallow_timeout(void *timeout_ctx, void *user_ctx)
|
||||
{
|
||||
struct wpa_supplicant *wpa_s = &g_wpa_supp;
|
||||
struct wpa_bss_tmp_disallowed *tmp, *bss = timeout_ctx;
|
||||
struct wpa_bss_tmp_disallowed *tmp, *bss = user_ctx;
|
||||
|
||||
/* Make sure the bss is not already freed */
|
||||
dl_list_for_each(tmp, &wpa_s->bss_tmp_disallowed,
|
||||
struct wpa_bss_tmp_disallowed, list) {
|
||||
if (bss == tmp) {
|
||||
dl_list_del(&tmp->list);
|
||||
esp_timer_stop(bss->blacklist_timer);
|
||||
esp_timer_delete(bss->blacklist_timer);
|
||||
os_free(tmp);
|
||||
break;
|
||||
}
|
||||
@@ -547,7 +545,7 @@ void wpa_bss_tmp_disallow(struct wpa_supplicant *wpa_s, const u8 *bssid,
|
||||
|
||||
bss = wpas_get_disallowed_bss(wpa_s, bssid);
|
||||
if (bss) {
|
||||
esp_timer_stop(bss->blacklist_timer);
|
||||
eloop_cancel_timeout(wpa_bss_tmp_disallow_timeout, wpa_s, bss);
|
||||
goto finish;
|
||||
}
|
||||
|
||||
@@ -558,22 +556,12 @@ void wpa_bss_tmp_disallow(struct wpa_supplicant *wpa_s, const u8 *bssid,
|
||||
return;
|
||||
}
|
||||
|
||||
esp_timer_create_args_t blacklist_timer_create = {
|
||||
.callback = &wpa_bss_tmp_disallow_timeout,
|
||||
.arg = bss,
|
||||
.dispatch_method = ESP_TIMER_TASK,
|
||||
.name = "blacklist_timeout_timer"
|
||||
};
|
||||
if (esp_timer_create(&blacklist_timer_create, &(bss->blacklist_timer)) != ESP_OK) {
|
||||
os_free(bss);
|
||||
return;
|
||||
}
|
||||
|
||||
os_memcpy(bss->bssid, bssid, ETH_ALEN);
|
||||
dl_list_add(&wpa_s->bss_tmp_disallowed, &bss->list);
|
||||
|
||||
finish:
|
||||
esp_timer_start_once(bss->blacklist_timer, (sec + 1) * 1e6);
|
||||
eloop_register_timeout(sec, 0, wpa_bss_tmp_disallow_timeout,
|
||||
wpa_s, bss);
|
||||
}
|
||||
|
||||
int wpa_is_bss_tmp_disallowed(struct wpa_supplicant *wpa_s,
|
||||
|
@@ -12,7 +12,6 @@
|
||||
|
||||
#include "drivers/driver.h"
|
||||
#include "common/ieee802_11_defs.h"
|
||||
#include "esp_timer.h"
|
||||
/*
|
||||
* struct rrm_data - Data used for managing RRM features
|
||||
*/
|
||||
@@ -47,8 +46,6 @@ struct wpa_bss_tmp_disallowed {
|
||||
u8 bssid[ETH_ALEN];
|
||||
#ifndef ESP_SUPPLICANT
|
||||
int rssi_threshold;
|
||||
#else
|
||||
esp_timer_handle_t blacklist_timer;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@@ -6,14 +6,14 @@
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#include "utils/includes.h"
|
||||
|
||||
#include "includes.h"
|
||||
#include "common.h"
|
||||
#include "eloop.h"
|
||||
#include "rsn_supp/wpa.h"
|
||||
#include "rsn_supp/wpa_i.h"
|
||||
#include "common/eapol_common.h"
|
||||
#include "common/ieee802_11_defs.h"
|
||||
#include "pmksa_cache.h"
|
||||
#include "esp_timer.h"
|
||||
|
||||
#ifdef IEEE8021X_EAPOL
|
||||
|
||||
@@ -25,7 +25,6 @@ struct rsn_pmksa_cache {
|
||||
struct rsn_pmksa_cache_entry *pmksa; /* PMKSA cache */
|
||||
int pmksa_count; /* number of entries in PMKSA cache */
|
||||
struct wpa_sm *sm; /* TODO: get rid of this reference(?) */
|
||||
esp_timer_handle_t cache_timeout_timer;
|
||||
|
||||
void (*free_cb)(struct rsn_pmksa_cache_entry *entry, void *ctx,
|
||||
enum pmksa_free_reason reason);
|
||||
@@ -52,12 +51,13 @@ static void pmksa_cache_free_entry(struct rsn_pmksa_cache *pmksa,
|
||||
}
|
||||
|
||||
|
||||
static void pmksa_cache_expire(void *eloop_ctx)
|
||||
static void pmksa_cache_expire(void *eloop_ctx, void *user_data)
|
||||
{
|
||||
struct rsn_pmksa_cache *pmksa = eloop_ctx;
|
||||
int64_t now_sec = esp_timer_get_time() / 1e6;
|
||||
struct os_reltime now;
|
||||
|
||||
while (pmksa->pmksa && pmksa->pmksa->expiration <= now_sec) {
|
||||
os_get_reltime(&now);
|
||||
while (pmksa->pmksa && pmksa->pmksa->expiration <= now.sec) {
|
||||
struct rsn_pmksa_cache_entry *entry = pmksa->pmksa;
|
||||
pmksa->pmksa = entry->next;
|
||||
wpa_printf(MSG_DEBUG, "RSN: expired PMKSA cache entry for "
|
||||
@@ -71,16 +71,18 @@ static void pmksa_cache_expire(void *eloop_ctx)
|
||||
static void pmksa_cache_set_expiration(struct rsn_pmksa_cache *pmksa)
|
||||
{
|
||||
int sec;
|
||||
int64_t now_sec = esp_timer_get_time() / 1e6;
|
||||
struct os_reltime now;
|
||||
|
||||
esp_timer_stop(pmksa->cache_timeout_timer);
|
||||
eloop_cancel_timeout(pmksa_cache_expire, pmksa, NULL);
|
||||
if (pmksa->pmksa == NULL)
|
||||
return;
|
||||
sec = pmksa->pmksa->expiration - now_sec;
|
||||
|
||||
os_get_reltime(&now);
|
||||
sec = pmksa->pmksa->expiration - now.sec;
|
||||
if (sec < 0)
|
||||
sec = 0;
|
||||
|
||||
esp_timer_start_once(pmksa->cache_timeout_timer, (sec + 1) * 1e6);
|
||||
eloop_register_timeout(sec + 1, 0, pmksa_cache_expire, pmksa, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,7 +109,7 @@ pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len,
|
||||
const u8 *aa, const u8 *spa, void *network_ctx, int akmp)
|
||||
{
|
||||
struct rsn_pmksa_cache_entry *entry, *pos, *prev;
|
||||
int64_t now_sec = esp_timer_get_time() / 1e6;
|
||||
struct os_reltime now;
|
||||
|
||||
if (pmk_len > PMK_LEN_MAX)
|
||||
return NULL;
|
||||
@@ -129,8 +131,9 @@ pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len,
|
||||
else
|
||||
rsn_pmkid(pmk, pmk_len, aa, spa, entry->pmkid,
|
||||
wpa_key_mgmt_sha256(akmp));
|
||||
entry->expiration = now_sec + dot11RSNAConfigPMKLifetime;
|
||||
entry->reauth_time = now_sec + dot11RSNAConfigPMKLifetime *
|
||||
os_get_reltime(&now);
|
||||
entry->expiration = now.sec + dot11RSNAConfigPMKLifetime;
|
||||
entry->reauth_time = now.sec + dot11RSNAConfigPMKLifetime *
|
||||
dot11RSNAConfigPMKReauthThreshold / 100;
|
||||
entry->akmp = akmp;
|
||||
os_memcpy(entry->aa, aa, ETH_ALEN);
|
||||
@@ -286,8 +289,7 @@ void pmksa_cache_deinit(struct rsn_pmksa_cache *pmksa)
|
||||
os_free(prev);
|
||||
}
|
||||
pmksa_cache_set_expiration(pmksa);
|
||||
esp_timer_stop(pmksa->cache_timeout_timer);
|
||||
esp_timer_delete(pmksa->cache_timeout_timer);
|
||||
eloop_cancel_timeout(pmksa_cache_expire, pmksa, NULL);
|
||||
os_free(pmksa);
|
||||
}
|
||||
|
||||
@@ -459,7 +461,7 @@ int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len)
|
||||
int i, ret;
|
||||
char *pos = buf;
|
||||
struct rsn_pmksa_cache_entry *entry;
|
||||
int64_t now_sec = esp_timer_get_time() / 1e6;
|
||||
struct os_reltime now;
|
||||
ret = os_snprintf(pos, buf + len - pos,
|
||||
"Index / AA / PMKID / expiration (in seconds) / "
|
||||
"opportunistic\n");
|
||||
@@ -468,6 +470,7 @@ int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len)
|
||||
pos += ret;
|
||||
i = 0;
|
||||
entry = pmksa->pmksa;
|
||||
os_get_reltime(&now);
|
||||
while (entry) {
|
||||
i++;
|
||||
ret = os_snprintf(pos, buf + len - pos, "%d " MACSTR " ",
|
||||
@@ -478,7 +481,7 @@ int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len)
|
||||
pos += wpa_snprintf_hex(pos, buf + len - pos, entry->pmkid,
|
||||
PMKID_LEN);
|
||||
ret = os_snprintf(pos, buf + len - pos, " %d %d\n",
|
||||
(int) (entry->expiration - now_sec),
|
||||
(int) (entry->expiration - now.sec),
|
||||
entry->opportunistic);
|
||||
if (os_snprintf_error(buf + len - pos, ret))
|
||||
return pos - buf;
|
||||
@@ -510,17 +513,6 @@ pmksa_cache_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry,
|
||||
pmksa->sm = sm;
|
||||
pmksa->pmksa_count = 0;
|
||||
pmksa->pmksa = NULL;
|
||||
|
||||
esp_timer_create_args_t pmksa_cache_timeout_timer_create = {
|
||||
.callback = &pmksa_cache_expire,
|
||||
.arg = pmksa,
|
||||
.dispatch_method = ESP_TIMER_TASK,
|
||||
.name = "pmksa_timeout_timer"
|
||||
};
|
||||
if (esp_timer_create(&pmksa_cache_timeout_timer_create, &(pmksa->cache_timeout_timer)) != ESP_OK) {
|
||||
os_free(pmksa);
|
||||
pmksa = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return pmksa;
|
||||
|
@@ -63,6 +63,7 @@ void wpa_set_passphrase(char * passphrase, u8 *ssid, size_t ssid_len);
|
||||
|
||||
void wpa_sm_set_pmk_from_pmksa(struct wpa_sm *sm);
|
||||
static bool wpa_supplicant_gtk_in_use(struct wpa_sm *sm, struct wpa_gtk_data *gd);
|
||||
void wpa_supplicant_stop_countermeasures(void *data, void *user_ctx);
|
||||
static inline enum wpa_states wpa_sm_get_state(struct wpa_sm *sm)
|
||||
{
|
||||
return sm->wpa_state;;
|
||||
@@ -2098,9 +2099,9 @@ out:
|
||||
*/
|
||||
void wpa_sm_set_state(enum wpa_states state)
|
||||
{
|
||||
struct wpa_sm *sm = &gWpaSm;
|
||||
struct wpa_sm *sm = &gWpaSm;
|
||||
if(WPA_MIC_FAILURE==WPA_SM_STATE(sm))
|
||||
ets_timer_disarm(&(sm->cm_timer));
|
||||
eloop_cancel_timeout(wpa_supplicant_stop_countermeasures, NULL, NULL);
|
||||
sm->wpa_state= state;
|
||||
}
|
||||
|
||||
@@ -2446,26 +2447,25 @@ void wpa_supplicant_clr_countermeasures(u16 *pisunicast)
|
||||
{
|
||||
struct wpa_sm *sm = &gWpaSm;
|
||||
sm->mic_errors_seen = 0;
|
||||
ets_timer_done(&(sm->cm_timer));
|
||||
wpa_printf(MSG_DEBUG, "WPA: TKIP countermeasures clean\n");
|
||||
}
|
||||
|
||||
/*recovery from countermeasures state, countermeasures state is period that stop connection with ap
|
||||
also used in wpa_init after connecting with ap
|
||||
*/
|
||||
void wpa_supplicant_stop_countermeasures(u16 *pisunicast)
|
||||
void wpa_supplicant_stop_countermeasures(void *data, void *user_ctx)
|
||||
{
|
||||
struct wpa_sm *sm = &gWpaSm;
|
||||
struct wpa_sm *sm = &gWpaSm;
|
||||
|
||||
ets_timer_done(&(sm->cm_timer));
|
||||
if (sm->countermeasures) {
|
||||
sm->countermeasures = 0;
|
||||
wpa_supplicant_clr_countermeasures(NULL);
|
||||
wpa_supplicant_clr_countermeasures(NULL);
|
||||
eloop_cancel_timeout(wpa_supplicant_stop_countermeasures, NULL, NULL);
|
||||
|
||||
wpa_printf(MSG_DEBUG, "WPA: TKIP countermeasures stopped\n");
|
||||
/*renew scan preocess, this isn't done now*/
|
||||
/*renew scan preocess, this isn't done now*/
|
||||
}
|
||||
wpa_sm_set_state(WPA_DISCONNECTED);
|
||||
wpa_sm_set_state(WPA_DISCONNECTED);
|
||||
}
|
||||
|
||||
int wpa_michael_mic_failure(u16 isunicast)
|
||||
@@ -2494,10 +2494,8 @@ int wpa_michael_mic_failure(u16 isunicast)
|
||||
/*deauthenticate AP*/
|
||||
|
||||
/*stop monitor next mic_failure timer,disconnect for 60sec, then stop contermeasures*/
|
||||
ets_timer_disarm(&(sm->cm_timer));
|
||||
ets_timer_done(&(sm->cm_timer));
|
||||
ets_timer_setfn(&(sm->cm_timer), (ETSTimerFunc *)wpa_supplicant_stop_countermeasures, NULL);
|
||||
ets_timer_arm(&(sm->cm_timer), 60*1000, false);
|
||||
eloop_cancel_timeout(wpa_supplicant_stop_countermeasures, NULL, NULL);
|
||||
eloop_register_timeout(60, 0, wpa_supplicant_stop_countermeasures, NULL, NULL);
|
||||
|
||||
/* TODO: mark the AP rejected for 60 second. STA is
|
||||
* allowed to associate with another AP.. */
|
||||
@@ -2506,10 +2504,8 @@ int wpa_michael_mic_failure(u16 isunicast)
|
||||
wpa_sm_set_state(WPA_MIC_FAILURE);
|
||||
wpa_sm_key_request(sm, 1, isunicast);
|
||||
/*start 60sec counter to monitor whether next mic_failure occur in this period, or clear mic_errors_seen*/
|
||||
ets_timer_disarm(&(sm->cm_timer));
|
||||
ets_timer_done(&(sm->cm_timer));
|
||||
ets_timer_setfn(&(sm->cm_timer), (ETSTimerFunc *)wpa_supplicant_clr_countermeasures, NULL);
|
||||
ets_timer_arm(&(sm->cm_timer), 60*1000, false);
|
||||
eloop_cancel_timeout(wpa_supplicant_stop_countermeasures, NULL, NULL);
|
||||
eloop_register_timeout(60, 0, wpa_supplicant_stop_countermeasures, NULL, NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@@ -50,7 +50,6 @@ struct wpa_sm {
|
||||
int rsn_enabled; /* Whether RSN is enabled in configuration */
|
||||
|
||||
int countermeasures; /*TKIP countermeasures state flag, 1:in countermeasures state*/
|
||||
ETSTimer cm_timer;
|
||||
|
||||
u8 *assoc_wpa_ie; /* Own WPA/RSN IE from (Re)AssocReq */
|
||||
size_t assoc_wpa_ie_len;
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include "includes.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "eloop.h"
|
||||
#include "crypto/crypto.h"
|
||||
#include "crypto/sha256.h"
|
||||
#include "crypto/random.h"
|
||||
@@ -1364,12 +1365,11 @@ extern struct wps_sm *gWpsSm;
|
||||
static enum wps_process_res wps_process_wsc_start(struct wps_data *wps,
|
||||
const struct wpabuf *msg)
|
||||
{
|
||||
struct wps_sm *sm = gWpsSm;
|
||||
enum wps_process_res ret = WPS_CONTINUE;
|
||||
|
||||
wpa_printf(MSG_DEBUG, "WPS: Received WSC_START");
|
||||
ets_timer_disarm(&sm->wps_eapol_start_timer);
|
||||
wps->state = SEND_M1;
|
||||
eloop_cancel_timeout(wifi_station_wps_eapol_start_handle, NULL, NULL);
|
||||
wps->state = SEND_M1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@@ -44,12 +44,17 @@ void callback(void *a, void *b)
|
||||
|
||||
}
|
||||
|
||||
extern const wifi_osi_funcs_t *wifi_funcs;
|
||||
/* Check if eloop runs its timers correctly & in correct order */
|
||||
TEST_CASE("Test eloop timers run", "[eloop]")
|
||||
{
|
||||
int execution_order[6] = {1, 5, 3, 0, 2, 4};
|
||||
int index[6] = {0,1,2,3,4,5};
|
||||
|
||||
wifi_funcs = WIFI_OSI_FUNCS_INITIALIZER();
|
||||
if (!wifi_funcs) {
|
||||
TEST_ASSERT(1);
|
||||
}
|
||||
eloop_init();
|
||||
os_get_reltime(&ts);
|
||||
for (int i = 0; i < 6; i++) {
|
||||
@@ -59,7 +64,7 @@ TEST_CASE("Test eloop timers run", "[eloop]")
|
||||
|
||||
/* wait for all timers to run */
|
||||
os_sleep(20, 0);
|
||||
|
||||
t = 0;
|
||||
/* check the execution order, this will also check whether they were fired at correct time */
|
||||
TEST_ASSERT(memcmp(execution_order, executed_order, 6*sizeof(int)) == 0);
|
||||
eloop_destroy();
|
||||
|
Reference in New Issue
Block a user