Merge branch 'bugfix/esp_supplicant_format' into 'master'

fix(wifi): update coding format of WiFi files

See merge request espressif/esp-idf!28079
pull/13517/merge
Jiang Jiang Jian 2024-04-16 15:23:21 +08:00
commit 8f4f21580a
60 zmienionych plików z 3805 dodań i 3861 usunięć

Wyświetl plik

@ -1,4 +1,4 @@
[codespell]
skip = build,*.yuv,components/fatfs/src/*,alice.txt,*.rgb
skip = build,*.yuv,components/fatfs/src/*,alice.txt,*.rgb,components/wpa_supplicant/*,components/esp_wifi/*
ignore-words-list = ser,dout,rsource,fram,inout,shs,ans,aci,unstall,unstalling,hart
write-changes = true

Wyświetl plik

@ -71,10 +71,10 @@ static void IRAM_ATTR s_esp_dport_access_stall_other_cpu_end(void)
If CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
If failed, try to allocate it in internal memory then.
*/
IRAM_ATTR void *wifi_malloc( size_t size )
IRAM_ATTR void *wifi_malloc(size_t size)
{
#if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
#else
return malloc(size);
#endif
@ -84,10 +84,10 @@ IRAM_ATTR void *wifi_malloc( size_t size )
If CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
If failed, try to allocate it in internal memory then.
*/
IRAM_ATTR void *wifi_realloc( void *ptr, size_t size )
IRAM_ATTR void *wifi_realloc(void *ptr, size_t size)
{
#if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
return heap_caps_realloc_prefer(ptr, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
return heap_caps_realloc_prefer(ptr, size, 2, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
#else
return realloc(ptr, size);
#endif
@ -97,10 +97,10 @@ IRAM_ATTR void *wifi_realloc( void *ptr, size_t size )
If CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
If failed, try to allocate it in internal memory then.
*/
IRAM_ATTR void *wifi_calloc( size_t n, size_t size )
IRAM_ATTR void *wifi_calloc(size_t n, size_t size)
{
#if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
return heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
return heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
#else
return calloc(n, size);
#endif
@ -112,11 +112,11 @@ static void * IRAM_ATTR wifi_zalloc_wrapper(size_t size)
return ptr;
}
wifi_static_queue_t* wifi_create_queue( int queue_len, int item_size)
wifi_static_queue_t* wifi_create_queue(int queue_len, int item_size)
{
wifi_static_queue_t *queue = NULL;
queue = (wifi_static_queue_t*)heap_caps_malloc(sizeof(wifi_static_queue_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
queue = (wifi_static_queue_t*)heap_caps_malloc(sizeof(wifi_static_queue_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
if (!queue) {
return NULL;
}
@ -124,12 +124,12 @@ wifi_static_queue_t* wifi_create_queue( int queue_len, int item_size)
#if CONFIG_SPIRAM_USE_MALLOC
/* Wi-Fi still use internal RAM */
queue->storage = heap_caps_calloc(1, sizeof(StaticQueue_t) + (queue_len*item_size), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
queue->storage = heap_caps_calloc(1, sizeof(StaticQueue_t) + (queue_len * item_size), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
if (!queue->storage) {
goto _error;
}
queue->handle = xQueueCreateStatic( queue_len, item_size, ((uint8_t*)(queue->storage)) + sizeof(StaticQueue_t), (StaticQueue_t*)(queue->storage));
queue->handle = xQueueCreateStatic(queue_len, item_size, ((uint8_t*)(queue->storage)) + sizeof(StaticQueue_t), (StaticQueue_t*)(queue->storage));
if (!queue->handle) {
goto _error;
@ -148,7 +148,7 @@ _error:
return NULL;
#else
queue->handle = xQueueCreate( queue_len, item_size);
queue->handle = xQueueCreate(queue_len, item_size);
return queue;
#endif
}
@ -405,17 +405,17 @@ static int get_time_wrapper(void *t)
static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size)
{
return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
}
static void * IRAM_ATTR calloc_internal_wrapper(size_t n, size_t size)
{
return heap_caps_calloc(n, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
return heap_caps_calloc(n, size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
}
static void * IRAM_ATTR zalloc_internal_wrapper(size_t size)
{
void *ptr = heap_caps_calloc(1, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
void *ptr = heap_caps_calloc(1, size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
return ptr;
}
@ -629,8 +629,8 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
._queue_msg_waiting = (uint32_t(*)(void *))uxQueueMessagesWaiting,
._event_group_create = (void *(*)(void))xEventGroupCreate,
._event_group_delete = (void(*)(void *))vEventGroupDelete,
._event_group_set_bits = (uint32_t(*)(void *,uint32_t))xEventGroupSetBits,
._event_group_clear_bits = (uint32_t(*)(void *,uint32_t))xEventGroupClearBits,
._event_group_set_bits = (uint32_t(*)(void *, uint32_t))xEventGroupSetBits,
._event_group_clear_bits = (uint32_t(*)(void *, uint32_t))xEventGroupClearBits,
._event_group_wait_bits = event_group_wait_bits_wrapper,
._task_create_pinned_to_core = task_create_pinned_to_core_wrapper,
._task_create = task_create_wrapper,

Wyświetl plik

@ -56,17 +56,17 @@ extern void wifi_apb80m_request(void);
extern void wifi_apb80m_release(void);
#endif
IRAM_ATTR void *wifi_malloc( size_t size )
IRAM_ATTR void *wifi_malloc(size_t size)
{
return malloc(size);
}
IRAM_ATTR void *wifi_realloc( void *ptr, size_t size )
IRAM_ATTR void *wifi_realloc(void *ptr, size_t size)
{
return realloc(ptr, size);
}
IRAM_ATTR void *wifi_calloc( size_t n, size_t size )
IRAM_ATTR void *wifi_calloc(size_t n, size_t size)
{
return calloc(n, size);
}
@ -77,16 +77,16 @@ static void * IRAM_ATTR wifi_zalloc_wrapper(size_t size)
return ptr;
}
wifi_static_queue_t* wifi_create_queue( int queue_len, int item_size)
wifi_static_queue_t* wifi_create_queue(int queue_len, int item_size)
{
wifi_static_queue_t *queue = NULL;
queue = (wifi_static_queue_t*)heap_caps_malloc(sizeof(wifi_static_queue_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
queue = (wifi_static_queue_t*)heap_caps_malloc(sizeof(wifi_static_queue_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
if (!queue) {
return NULL;
}
queue->handle = xQueueCreate( queue_len, item_size);
queue->handle = xQueueCreate(queue_len, item_size);
return queue;
}
@ -317,31 +317,31 @@ static int get_time_wrapper(void *t)
static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size)
{
return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
}
static void * IRAM_ATTR calloc_internal_wrapper(size_t n, size_t size)
{
return heap_caps_calloc(n, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
return heap_caps_calloc(n, size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
}
static void * IRAM_ATTR zalloc_internal_wrapper(size_t size)
{
void *ptr = heap_caps_calloc(1, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
void *ptr = heap_caps_calloc(1, size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
return ptr;
}
static esp_err_t nvs_open_wrapper(const char* name, unsigned int open_mode, nvs_handle_t *out_handle)
{
return nvs_open(name,(nvs_open_mode_t)open_mode, out_handle);
return nvs_open(name, (nvs_open_mode_t)open_mode, out_handle);
}
static void esp_log_writev_wrapper(unsigned int level, const char *tag, const char *format, va_list args)
{
return esp_log_writev((esp_log_level_t)level,tag,format,args);
return esp_log_writev((esp_log_level_t)level, tag, format, args);
}
static void esp_log_write_wrapper(unsigned int level,const char *tag,const char *format, ...)
static void esp_log_write_wrapper(unsigned int level, const char *tag, const char *format, ...)
{
va_list list;
va_start(list, format);
@ -568,8 +568,8 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
._queue_msg_waiting = (uint32_t(*)(void *))uxQueueMessagesWaiting,
._event_group_create = (void *(*)(void))xEventGroupCreate,
._event_group_delete = (void(*)(void *))vEventGroupDelete,
._event_group_set_bits = (uint32_t(*)(void *,uint32_t))xEventGroupSetBits,
._event_group_clear_bits = (uint32_t(*)(void *,uint32_t))xEventGroupClearBits,
._event_group_set_bits = (uint32_t(*)(void *, uint32_t))xEventGroupSetBits,
._event_group_clear_bits = (uint32_t(*)(void *, uint32_t))xEventGroupClearBits,
._event_group_wait_bits = event_group_wait_bits_wrapper,
._task_create_pinned_to_core = task_create_pinned_to_core_wrapper,
._task_create = task_create_wrapper,

Wyświetl plik

@ -59,17 +59,17 @@ extern void wifi_apb80m_request(void);
extern void wifi_apb80m_release(void);
#endif
IRAM_ATTR void *wifi_malloc( size_t size )
IRAM_ATTR void *wifi_malloc(size_t size)
{
return malloc(size);
}
IRAM_ATTR void *wifi_realloc( void *ptr, size_t size )
IRAM_ATTR void *wifi_realloc(void *ptr, size_t size)
{
return realloc(ptr, size);
}
IRAM_ATTR void *wifi_calloc( size_t n, size_t size )
IRAM_ATTR void *wifi_calloc(size_t n, size_t size)
{
return calloc(n, size);
}
@ -80,16 +80,16 @@ static void * IRAM_ATTR wifi_zalloc_wrapper(size_t size)
return ptr;
}
wifi_static_queue_t* wifi_create_queue( int queue_len, int item_size)
wifi_static_queue_t* wifi_create_queue(int queue_len, int item_size)
{
wifi_static_queue_t *queue = NULL;
queue = (wifi_static_queue_t*)heap_caps_malloc(sizeof(wifi_static_queue_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
queue = (wifi_static_queue_t*)heap_caps_malloc(sizeof(wifi_static_queue_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
if (!queue) {
return NULL;
}
queue->handle = xQueueCreate( queue_len, item_size);
queue->handle = xQueueCreate(queue_len, item_size);
return queue;
}
@ -334,31 +334,31 @@ static int get_time_wrapper(void *t)
static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size)
{
return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
}
static void * IRAM_ATTR calloc_internal_wrapper(size_t n, size_t size)
{
return heap_caps_calloc(n, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
return heap_caps_calloc(n, size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
}
static void * IRAM_ATTR zalloc_internal_wrapper(size_t size)
{
void *ptr = heap_caps_calloc(1, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
void *ptr = heap_caps_calloc(1, size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
return ptr;
}
static esp_err_t nvs_open_wrapper(const char* name, unsigned int open_mode, nvs_handle_t *out_handle)
{
return nvs_open(name,(nvs_open_mode_t)open_mode, out_handle);
return nvs_open(name, (nvs_open_mode_t)open_mode, out_handle);
}
static void esp_log_writev_wrapper(unsigned int level, const char *tag, const char *format, va_list args)
{
return esp_log_writev((esp_log_level_t)level,tag,format,args);
return esp_log_writev((esp_log_level_t)level, tag, format, args);
}
static void esp_log_write_wrapper(unsigned int level,const char *tag,const char *format, ...)
static void esp_log_write_wrapper(unsigned int level, const char *tag, const char *format, ...)
{
va_list list;
va_start(list, format);
@ -585,8 +585,8 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
._queue_msg_waiting = (uint32_t(*)(void *))uxQueueMessagesWaiting,
._event_group_create = (void *(*)(void))xEventGroupCreate,
._event_group_delete = (void(*)(void *))vEventGroupDelete,
._event_group_set_bits = (uint32_t(*)(void *,uint32_t))xEventGroupSetBits,
._event_group_clear_bits = (uint32_t(*)(void *,uint32_t))xEventGroupClearBits,
._event_group_set_bits = (uint32_t(*)(void *, uint32_t))xEventGroupSetBits,
._event_group_clear_bits = (uint32_t(*)(void *, uint32_t))xEventGroupClearBits,
._event_group_wait_bits = event_group_wait_bits_wrapper,
._task_create_pinned_to_core = task_create_pinned_to_core_wrapper,
._task_create = task_create_wrapper,

Wyświetl plik

@ -62,17 +62,17 @@ extern void wifi_apb80m_request(void);
extern void wifi_apb80m_release(void);
#endif
IRAM_ATTR void *wifi_malloc( size_t size )
IRAM_ATTR void *wifi_malloc(size_t size)
{
return malloc(size);
}
IRAM_ATTR void *wifi_realloc( void *ptr, size_t size )
IRAM_ATTR void *wifi_realloc(void *ptr, size_t size)
{
return realloc(ptr, size);
}
IRAM_ATTR void *wifi_calloc( size_t n, size_t size )
IRAM_ATTR void *wifi_calloc(size_t n, size_t size)
{
return calloc(n, size);
}
@ -83,7 +83,7 @@ static void *IRAM_ATTR wifi_zalloc_wrapper(size_t size)
return ptr;
}
wifi_static_queue_t *wifi_create_queue( int queue_len, int item_size)
wifi_static_queue_t *wifi_create_queue(int queue_len, int item_size)
{
wifi_static_queue_t *queue = NULL;
@ -92,7 +92,7 @@ wifi_static_queue_t *wifi_create_queue( int queue_len, int item_size)
return NULL;
}
queue->handle = xQueueCreate( queue_len, item_size);
queue->handle = xQueueCreate(queue_len, item_size);
return queue;
}

Wyświetl plik

@ -53,10 +53,10 @@ extern void wifi_apb80m_request(void);
extern void wifi_apb80m_release(void);
#endif
IRAM_ATTR void *wifi_malloc( size_t size )
IRAM_ATTR void *wifi_malloc(size_t size)
{
#if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
#else
return malloc(size);
#endif
@ -66,10 +66,10 @@ IRAM_ATTR void *wifi_malloc( size_t size )
If CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
If failed, try to allocate it in internal memory then.
*/
IRAM_ATTR void *wifi_realloc( void *ptr, size_t size )
IRAM_ATTR void *wifi_realloc(void *ptr, size_t size)
{
#if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
return heap_caps_realloc_prefer(ptr, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
return heap_caps_realloc_prefer(ptr, size, 2, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
#else
return realloc(ptr, size);
#endif
@ -79,10 +79,10 @@ IRAM_ATTR void *wifi_realloc( void *ptr, size_t size )
If CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
If failed, try to allocate it in internal memory then.
*/
IRAM_ATTR void *wifi_calloc( size_t n, size_t size )
IRAM_ATTR void *wifi_calloc(size_t n, size_t size)
{
#if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
return heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
return heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
#else
return calloc(n, size);
#endif
@ -94,7 +94,7 @@ static void *IRAM_ATTR wifi_zalloc_wrapper(size_t size)
return ptr;
}
wifi_static_queue_t *wifi_create_queue( int queue_len, int item_size)
wifi_static_queue_t *wifi_create_queue(int queue_len, int item_size)
{
wifi_static_queue_t *queue = NULL;
@ -105,12 +105,12 @@ wifi_static_queue_t *wifi_create_queue( int queue_len, int item_size)
#if CONFIG_SPIRAM_USE_MALLOC
queue->storage = heap_caps_calloc(1, sizeof(StaticQueue_t) + (queue_len*item_size), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
queue->storage = heap_caps_calloc(1, sizeof(StaticQueue_t) + (queue_len * item_size), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
if (!queue->storage) {
goto _error;
}
queue->handle = xQueueCreateStatic( queue_len, item_size, ((uint8_t*)(queue->storage)) + sizeof(StaticQueue_t), (StaticQueue_t*)(queue->storage));
queue->handle = xQueueCreateStatic(queue_len, item_size, ((uint8_t*)(queue->storage)) + sizeof(StaticQueue_t), (StaticQueue_t*)(queue->storage));
if (!queue->handle) {
goto _error;
@ -129,7 +129,7 @@ _error:
return NULL;
#else
queue->handle = xQueueCreate( queue_len, item_size);
queue->handle = xQueueCreate(queue_len, item_size);
return queue;
#endif
}
@ -550,10 +550,10 @@ bool IRAM_ATTR esp_coex_common_env_is_chip_wrapper(void)
void * esp_coex_common_spin_lock_create_wrapper(void)
{
portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED;
void *mux = heap_caps_malloc(sizeof(portMUX_TYPE), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
void *mux = heap_caps_malloc(sizeof(portMUX_TYPE), MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL);
if (mux) {
memcpy(mux,&tmp,sizeof(portMUX_TYPE));
memcpy(mux, &tmp, sizeof(portMUX_TYPE));
return mux;
}
return NULL;
@ -630,7 +630,7 @@ void IRAM_ATTR esp_coex_common_timer_arm_us_wrapper(void *ptimer, uint32_t us, b
void * IRAM_ATTR esp_coex_common_malloc_internal_wrapper(size_t size)
{
return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
return heap_caps_malloc(size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
}
wifi_osi_funcs_t g_wifi_osi_funcs = {

Wyświetl plik

@ -62,10 +62,10 @@ extern void wifi_apb80m_release(void);
If CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
If failed, try to allocate it in internal memory then.
*/
IRAM_ATTR void *wifi_malloc( size_t size )
IRAM_ATTR void *wifi_malloc(size_t size)
{
#if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
#else
return malloc(size);
#endif
@ -75,10 +75,10 @@ IRAM_ATTR void *wifi_malloc( size_t size )
If CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
If failed, try to allocate it in internal memory then.
*/
IRAM_ATTR void *wifi_realloc( void *ptr, size_t size )
IRAM_ATTR void *wifi_realloc(void *ptr, size_t size)
{
#if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
return heap_caps_realloc_prefer(ptr, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
return heap_caps_realloc_prefer(ptr, size, 2, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
#else
return realloc(ptr, size);
#endif
@ -88,10 +88,10 @@ IRAM_ATTR void *wifi_realloc( void *ptr, size_t size )
If CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
If failed, try to allocate it in internal memory then.
*/
IRAM_ATTR void *wifi_calloc( size_t n, size_t size )
IRAM_ATTR void *wifi_calloc(size_t n, size_t size)
{
#if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
return heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
return heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
#else
return calloc(n, size);
#endif
@ -103,11 +103,11 @@ static void * IRAM_ATTR wifi_zalloc_wrapper(size_t size)
return ptr;
}
wifi_static_queue_t* wifi_create_queue( int queue_len, int item_size)
wifi_static_queue_t* wifi_create_queue(int queue_len, int item_size)
{
wifi_static_queue_t *queue = NULL;
queue = (wifi_static_queue_t*)heap_caps_malloc(sizeof(wifi_static_queue_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
queue = (wifi_static_queue_t*)heap_caps_malloc(sizeof(wifi_static_queue_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
if (!queue) {
return NULL;
}
@ -115,12 +115,12 @@ wifi_static_queue_t* wifi_create_queue( int queue_len, int item_size)
#if CONFIG_SPIRAM_USE_MALLOC
/* Wi-Fi still use internal RAM */
queue->storage = heap_caps_calloc(1, sizeof(StaticQueue_t) + (queue_len*item_size), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
queue->storage = heap_caps_calloc(1, sizeof(StaticQueue_t) + (queue_len * item_size), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
if (!queue->storage) {
goto _error;
}
queue->handle = xQueueCreateStatic( queue_len, item_size, ((uint8_t*)(queue->storage)) + sizeof(StaticQueue_t), (StaticQueue_t*)(queue->storage));
queue->handle = xQueueCreateStatic(queue_len, item_size, ((uint8_t*)(queue->storage)) + sizeof(StaticQueue_t), (StaticQueue_t*)(queue->storage));
if (!queue->handle) {
goto _error;
@ -139,7 +139,7 @@ _error:
return NULL;
#else
queue->handle = xQueueCreate( queue_len, item_size);
queue->handle = xQueueCreate(queue_len, item_size);
return queue;
#endif
}
@ -396,17 +396,17 @@ static int get_time_wrapper(void *t)
static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size)
{
return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
}
static void * IRAM_ATTR calloc_internal_wrapper(size_t n, size_t size)
{
return heap_caps_calloc(n, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
return heap_caps_calloc(n, size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
}
static void * IRAM_ATTR zalloc_internal_wrapper(size_t size)
{
void *ptr = heap_caps_calloc(1, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
void *ptr = heap_caps_calloc(1, size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
return ptr;
}
@ -622,8 +622,8 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
._queue_msg_waiting = (uint32_t(*)(void *))uxQueueMessagesWaiting,
._event_group_create = (void *(*)(void))xEventGroupCreate,
._event_group_delete = (void(*)(void *))vEventGroupDelete,
._event_group_set_bits = (uint32_t(*)(void *,uint32_t))xEventGroupSetBits,
._event_group_clear_bits = (uint32_t(*)(void *,uint32_t))xEventGroupClearBits,
._event_group_set_bits = (uint32_t(*)(void *, uint32_t))xEventGroupSetBits,
._event_group_clear_bits = (uint32_t(*)(void *, uint32_t))xEventGroupClearBits,
._event_group_wait_bits = event_group_wait_bits_wrapper,
._task_create_pinned_to_core = task_create_pinned_to_core_wrapper,
._task_create = task_create_wrapper,

Wyświetl plik

@ -65,10 +65,10 @@ extern void wifi_apb80m_release(void);
If CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
If failed, try to allocate it in internal memory then.
*/
IRAM_ATTR void *wifi_malloc( size_t size )
IRAM_ATTR void *wifi_malloc(size_t size)
{
#if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
#else
return malloc(size);
#endif
@ -78,10 +78,10 @@ IRAM_ATTR void *wifi_malloc( size_t size )
If CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
If failed, try to allocate it in internal memory then.
*/
IRAM_ATTR void *wifi_realloc( void *ptr, size_t size )
IRAM_ATTR void *wifi_realloc(void *ptr, size_t size)
{
#if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
return heap_caps_realloc_prefer(ptr, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
return heap_caps_realloc_prefer(ptr, size, 2, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
#else
return realloc(ptr, size);
#endif
@ -91,10 +91,10 @@ IRAM_ATTR void *wifi_realloc( void *ptr, size_t size )
If CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
If failed, try to allocate it in internal memory then.
*/
IRAM_ATTR void *wifi_calloc( size_t n, size_t size )
IRAM_ATTR void *wifi_calloc(size_t n, size_t size)
{
#if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
return heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
return heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
#else
return calloc(n, size);
#endif
@ -106,11 +106,11 @@ static void * IRAM_ATTR wifi_zalloc_wrapper(size_t size)
return ptr;
}
wifi_static_queue_t* wifi_create_queue( int queue_len, int item_size)
wifi_static_queue_t* wifi_create_queue(int queue_len, int item_size)
{
wifi_static_queue_t *queue = NULL;
queue = (wifi_static_queue_t*)heap_caps_malloc(sizeof(wifi_static_queue_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
queue = (wifi_static_queue_t*)heap_caps_malloc(sizeof(wifi_static_queue_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
if (!queue) {
return NULL;
}
@ -118,12 +118,12 @@ wifi_static_queue_t* wifi_create_queue( int queue_len, int item_size)
#if CONFIG_SPIRAM_USE_MALLOC
/* Wi-Fi still use internal RAM */
queue->storage = heap_caps_calloc(1, sizeof(StaticQueue_t) + (queue_len*item_size), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
queue->storage = heap_caps_calloc(1, sizeof(StaticQueue_t) + (queue_len * item_size), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
if (!queue->storage) {
goto _error;
}
queue->handle = xQueueCreateStatic( queue_len, item_size, ((uint8_t*)(queue->storage)) + sizeof(StaticQueue_t), (StaticQueue_t*)(queue->storage));
queue->handle = xQueueCreateStatic(queue_len, item_size, ((uint8_t*)(queue->storage)) + sizeof(StaticQueue_t), (StaticQueue_t*)(queue->storage));
if (!queue->handle) {
goto _error;
@ -142,7 +142,7 @@ _error:
return NULL;
#else
queue->handle = xQueueCreate( queue_len, item_size);
queue->handle = xQueueCreate(queue_len, item_size);
return queue;
#endif
}
@ -413,17 +413,17 @@ static int get_time_wrapper(void *t)
static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size)
{
return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
}
static void * IRAM_ATTR calloc_internal_wrapper(size_t n, size_t size)
{
return heap_caps_calloc(n, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
return heap_caps_calloc(n, size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
}
static void * IRAM_ATTR zalloc_internal_wrapper(size_t size)
{
void *ptr = heap_caps_calloc(1, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
void *ptr = heap_caps_calloc(1, size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
return ptr;
}
@ -595,7 +595,6 @@ static void IRAM_ATTR esp_empty_wrapper(void)
}
static void esp_phy_enable_wrapper(void)
{
esp_phy_enable(PHY_MODEM_WIFI);
@ -642,8 +641,8 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
._queue_msg_waiting = (uint32_t(*)(void *))uxQueueMessagesWaiting,
._event_group_create = (void *(*)(void))xEventGroupCreate,
._event_group_delete = (void(*)(void *))vEventGroupDelete,
._event_group_set_bits = (uint32_t(*)(void *,uint32_t))xEventGroupSetBits,
._event_group_clear_bits = (uint32_t(*)(void *,uint32_t))xEventGroupClearBits,
._event_group_set_bits = (uint32_t(*)(void *, uint32_t))xEventGroupSetBits,
._event_group_clear_bits = (uint32_t(*)(void *, uint32_t))xEventGroupClearBits,
._event_group_wait_bits = event_group_wait_bits_wrapper,
._task_create_pinned_to_core = task_create_pinned_to_core_wrapper,
._task_create = task_create_wrapper,

Wyświetl plik

@ -144,7 +144,6 @@ extern "C" {
#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 */
/**
* @brief Mesh PS (Power Save) duty cycle type
*/

Wyświetl plik

@ -268,7 +268,7 @@ esp_err_t esp_now_mod_peer(const esp_now_peer_info_t *peer);
* - others: failed
*/
esp_err_t esp_wifi_config_espnow_rate(wifi_interface_t ifx, wifi_phy_rate_t rate)
__attribute__((deprecated("This API can be only used when rate is non-HE rate, \
__attribute__((deprecated("This API can be only used when rate is non-HE rate, \
please use esp_now_set_peer_rate_config if you want full support of the rate.")));
/**

Wyświetl plik

@ -121,33 +121,33 @@ typedef struct {
} __attribute__((packed)) esp_wifi_vht_siga1_t;
typedef struct {
uint32_t ru_allocation :8;
uint32_t crc :4;
uint32_t tail :6; //18 bits
uint32_t ru_allocation : 8;
uint32_t crc : 4;
uint32_t tail : 6; //18 bits
} esp_wifi_mu_sigb_common_t;
typedef struct {
uint32_t ru_allocation :16;
uint32_t center_26tone_ru :1;
uint32_t crc :4;
uint32_t tail :6; //not included into the sigb_common_info (21bits)
uint32_t ru_allocation : 16;
uint32_t center_26tone_ru : 1;
uint32_t crc : 4;
uint32_t tail : 6; //not included into the sigb_common_info (21bits)
} esp_wifi_mu_sigb_common_80mhz_ppdu_t;
typedef struct {
uint32_t sta_id :11;
uint32_t nsts :3;
uint32_t beamformed :1;
uint32_t he_mcs :4;
uint32_t dcm :1;
uint32_t coding :1;
uint32_t sta_id : 11;
uint32_t nsts : 3;
uint32_t beamformed : 1;
uint32_t he_mcs : 4;
uint32_t dcm : 1;
uint32_t coding : 1;
} esp_wifi_mu_sigb_user_non_mimo_t;
typedef struct {
uint32_t sta_id :11;
uint32_t spatial_config :4;
uint32_t he_mcs :4;
uint32_t rsvd :1;
uint32_t coding :1;
uint32_t sta_id : 11;
uint32_t spatial_config : 4;
uint32_t he_mcs : 4;
uint32_t rsvd : 1;
uint32_t coding : 1;
} esp_wifi_mu_sigb_user_mimo_t;
#define ESP_TEST_RX_MU_USER_NUM (9)

Wyświetl plik

@ -15,7 +15,6 @@
*
*/
#ifndef __ESP_WIFI_INTERNAL_H__
#define __ESP_WIFI_INTERNAL_H__
@ -46,7 +45,7 @@ typedef struct {
*/
typedef enum {
WIFI_LOG_NONE = 0,
WIFI_LOG_ERROR , /*enabled by default*/
WIFI_LOG_ERROR, /*enabled by default*/
WIFI_LOG_WARNING, /*enabled by default*/
WIFI_LOG_INFO, /*enabled by default*/
WIFI_LOG_DEBUG, /*can be set in menuconfig*/
@ -74,7 +73,6 @@ typedef enum {
#define WIFI_LOG_SUBMODULE_CONN (1<<2) /*logs related to connecting*/
#define WIFI_LOG_SUBMODULE_SCAN (1<<3) /*logs related to scanning*/
/**
* @brief Initialize Wi-Fi Driver
* Alloc resource for WiFi driver, such as WiFi control structure, RX/TX buffer,
@ -215,7 +213,6 @@ esp_err_t esp_wifi_internal_wapi_deinit(void);
*/
esp_err_t esp_wifi_internal_reg_netstack_buf_cb(wifi_netstack_buf_ref_cb_t ref, wifi_netstack_buf_free_cb_t free);
/**
* @brief The WiFi RX callback function
*
@ -370,7 +367,7 @@ esp_err_t esp_wifi_internal_esp_wifi_he_md5_check(const char *md5);
*
* @return A pointer to the memory allocated on success, NULL on failure
*/
void *wifi_malloc( size_t size );
void *wifi_malloc(size_t size);
/**
* @brief Reallocate a chunk of memory for WiFi driver
@ -382,7 +379,7 @@ void *wifi_malloc( size_t size );
*
* @return A pointer to the memory allocated on success, NULL on failure
*/
void *wifi_realloc( void *ptr, size_t size );
void *wifi_realloc(void *ptr, size_t size);
/**
* @brief Callocate memory for WiFi driver
@ -394,7 +391,7 @@ void *wifi_realloc( void *ptr, size_t size );
*
* @return A pointer to the memory allocated on success, NULL on failure
*/
void *wifi_calloc( size_t n, size_t size );
void *wifi_calloc(size_t n, size_t size);
/**
* @brief Update WiFi MAC time
@ -403,7 +400,7 @@ void *wifi_calloc( size_t n, size_t size );
*
* @return Always returns ESP_OK
*/
typedef esp_err_t (* wifi_mac_time_update_cb_t)( uint32_t time_delta );
typedef esp_err_t (* wifi_mac_time_update_cb_t)(uint32_t time_delta);
/**
* @brief Update WiFi MAC time
@ -412,7 +409,7 @@ typedef esp_err_t (* wifi_mac_time_update_cb_t)( uint32_t time_delta );
*
* @return Always returns ESP_OK
*/
esp_err_t esp_wifi_internal_update_mac_time( uint32_t time_delta );
esp_err_t esp_wifi_internal_update_mac_time(uint32_t time_delta);
/**
* @brief Set current WiFi log level
@ -539,7 +536,6 @@ void esp_wifi_power_domain_on(void);
*/
void esp_wifi_power_domain_off(void);
#if (CONFIG_FREERTOS_USE_TICKLESS_IDLE && SOC_PM_MODEM_RETENTION_BY_REGDMA)
/**
* @brief Get wifi mac sleep retention hardware context configuration and size

Wyświetl plik

@ -4,7 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/* Notes about WiFi Programming
*
* WiFi programming model can be depicted as following picture:
@ -561,7 +560,6 @@ esp_err_t esp_wifi_scan_get_ap_record(wifi_ap_record_t *ap_record);
*/
esp_err_t esp_wifi_clear_ap_list(void);
/**
* @brief Get information of AP to which the device is associated with
*
@ -749,7 +747,6 @@ esp_err_t esp_wifi_set_country(const wifi_country_t *country);
*/
esp_err_t esp_wifi_get_country(wifi_country_t *country);
/**
* @brief Set MAC address of WiFi station, soft-AP or NAN interface.
*
@ -983,7 +980,7 @@ esp_err_t esp_wifi_set_storage(wifi_storage_t storage);
* @param vnd_ie Pointer to the vendor specific element data received.
* @param rssi Received signal strength indication.
*/
typedef void (*esp_vendor_ie_cb_t) (void *ctx, wifi_vendor_ie_type_t type, const uint8_t sa[6], const vendor_ie_data_t *vnd_ie, int rssi);
typedef void (*esp_vendor_ie_cb_t)(void *ctx, wifi_vendor_ie_type_t type, const uint8_t sa[6], const vendor_ie_data_t *vnd_ie, int rssi);
/**
* @brief Set 802.11 Vendor-Specific Information Element
@ -1115,7 +1112,6 @@ esp_err_t esp_wifi_80211_tx(wifi_interface_t ifx, const void *buffer, int len, b
*/
typedef void (* wifi_csi_cb_t)(void *ctx, wifi_csi_info_t *data);
/**
* @brief Register the RX callback function of CSI data.
*
@ -1194,7 +1190,6 @@ esp_err_t esp_wifi_set_ant_gpio(const wifi_ant_gpio_config_t *config) __attribut
*/
esp_err_t esp_wifi_get_ant_gpio(wifi_ant_gpio_config_t *config) __attribute__((deprecated("Please use esp_phy_get_ant_gpio instead")));
/**
* @brief Set antenna configuration
*

Wyświetl plik

@ -13,7 +13,6 @@
extern "C" {
#endif
#ifndef ESP_WIFI_MAX_CONN_NUM
// Number of maximum wifi connection may be undefined if we have no native wifi support on this target
// and at the same time there's no native interface injected by the wifi_remote component.

Wyświetl plik

@ -1,10 +1,9 @@
/*
* SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __ESP_WIFI_CRYPTO_TYPES_H__
#define __ESP_WIFI_CRYPTO_TYPES_H__
@ -33,7 +32,7 @@ typedef enum {
ESP_CRYPTO_HASH_ALG_MD5, ESP_CRYPTO_HASH_ALG_SHA1,
ESP_CRYPTO_HASH_ALG_HMAC_MD5, ESP_CRYPTO_HASH_ALG_HMAC_SHA1,
ESP_CRYPTO_HASH_ALG_SHA256, ESP_CRYPTO_HASH_ALG_HMAC_SHA256
}esp_crypto_hash_alg_t;
} esp_crypto_hash_alg_t;
/*
* Enumeration for block cipher operations.
@ -112,7 +111,7 @@ typedef int (*esp_aes_unwrap_t)(const unsigned char *kek, int n, const unsigned
*
*/
typedef int (*esp_hmac_sha256_vector_t)(const unsigned char *key, int key_len, int num_elem,
const unsigned char *addr[], const int *len, unsigned char *mac);
const unsigned char *addr[], const int *len, unsigned char *mac);
/**
* @brief The SHA256 PRF callback function used by esp_wifi.
@ -127,7 +126,7 @@ typedef int (*esp_hmac_sha256_vector_t)(const unsigned char *key, int key_len, i
*
*/
typedef int (*esp_sha256_prf_t)(const unsigned char *key, int key_len, const char *label,
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 callback function over data buffer (RFC 2104)'
@ -154,7 +153,7 @@ typedef int (*esp_hmac_md5_t)(const unsigned char *key, unsigned int key_len, co
* 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,
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 callback function over data buffer (RFC 2104)
@ -167,7 +166,7 @@ typedef int (*esp_hmac_md5_vector_t)(const unsigned char *key, unsigned int key_
* 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,
unsigned int data_len, unsigned char *mac);
unsigned int data_len, unsigned char *mac);
/**
* @brief HMAC-SHA1 callback function over data vector (RFC 2104)
@ -181,7 +180,7 @@ typedef int (*esp_hmac_sha1_t)(const unsigned char *key, unsigned int key_len, c
* 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,
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) callback function
@ -211,7 +210,7 @@ typedef int (*esp_sha1_prf_t)(const unsigned char *key, unsigned int key_len, co
* 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,
unsigned char *mac);
unsigned char *mac);
/**
* @brief SHA1-based key derivation function (PBKDF2) callback function for IEEE 802.11i
@ -229,7 +228,7 @@ typedef int (*esp_sha1_vector_t)(unsigned int num_elem, const unsigned char *add
* IEEE Std 802.11-2004, Clause H.4. The main construction is from PKCS#5 v2.0.
*/
typedef int (*esp_pbkdf2_sha1_t)(const char *passphrase, const char *ssid, unsigned int ssid_len,
int iterations, unsigned char *buf, unsigned int buflen);
int iterations, unsigned char *buf, unsigned int buflen);
/**
* @brief XOR RC4 stream callback function to given data with skip-stream-start
@ -258,7 +257,7 @@ typedef int (*esp_rc4_skip_t)(const unsigned char *key, unsigned int keylen, uns
* 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,
unsigned char *mac);
unsigned char *mac);
/**
* @brief Encrypt one AES block callback function
@ -423,14 +422,14 @@ typedef struct wpa_crypto_funcs_t {
esp_aes_gmac_t aes_gmac; /**< One-Key GMAC hash callback function with AES for MIC computation */
esp_sha256_vector_t sha256_vector; /**< SHA256 hash callback function for data vector */
esp_crc32_le_t crc32; /**< CRC32 value callback function in little endian */
}wpa_crypto_funcs_t;
} wpa_crypto_funcs_t;
/**
* @brief The crypto callback function structure used in mesh vendor IE encryption. The
* structure can be set as software crypto or the crypto optimized by device's
* hardware.
*/
typedef struct{
typedef struct {
esp_aes_128_encrypt_t aes_128_encrypt; /**< Callback function used in mesh vendor IE encryption */
esp_aes_128_decrypt_t aes_128_decrypt; /**< Callback function used in mesh vendor IE decryption */
} mesh_crypto_funcs_t;

Wyświetl plik

@ -15,7 +15,6 @@
extern "C" {
#endif
/**
* @brief Set up an individual TWT agreement (NegotiationType=0) or change TWT parameters of the existing TWT agreement
* - TWT Wake Interval = TWT Wake Interval Mantissa * (2 ^ TWT Wake Interval Exponent), unit: us

Wyświetl plik

@ -114,17 +114,16 @@ typedef enum {
/**
* @brief TWT setup config
*/
typedef struct
{
typedef struct {
wifi_twt_setup_cmds_t setup_cmd; /**< Indicates the type of TWT command */
uint16_t trigger :1; /**< 1: a trigger-enabled TWT, 0: a non-trigger-enabled TWT */
uint16_t flow_type :1; /**< 0: an announced TWT, 1: an unannounced TWT */
uint16_t flow_id :3; /**< When set up an individual TWT agreement, the flow id will be assigned by AP after a successful agreement setup.
uint16_t trigger : 1; /**< 1: a trigger-enabled TWT, 0: a non-trigger-enabled TWT */
uint16_t flow_type : 1; /**< 0: an announced TWT, 1: an unannounced TWT */
uint16_t flow_id : 3; /**< When set up an individual TWT agreement, the flow id will be assigned by AP after a successful agreement setup.
flow_id could be specified to a value in the range of [0, 7], but it might be changed by AP in the response.
When change TWT parameters of the existing TWT agreement, flow_id should be an existing one. The value range is [0, 7]. */
uint16_t wake_invl_expn :5; /**< TWT Wake Interval Exponent. The value range is [0, 31]. */
uint16_t wake_duration_unit :1; /**< TWT Wake duration unit, 0: 256us 1: TU (TU = 1024us)*/
uint16_t reserved :5; /**< bit: 11.15 reserved */
uint16_t wake_invl_expn : 5; /**< TWT Wake Interval Exponent. The value range is [0, 31]. */
uint16_t wake_duration_unit : 1; /**< TWT Wake duration unit, 0: 256us 1: TU (TU = 1024us)*/
uint16_t reserved : 5; /**< bit: 11.15 reserved */
uint8_t min_wake_dura; /**< Nominal Minimum Wake Duration, indicates the minimum amount of time, in unit of 256 us, that the TWT requesting STA expects that it needs to be awake. The value range is [1, 255]. */
uint16_t wake_invl_mant; /**< TWT Wake Interval Mantissa. The value range is [1, 65535]. */
uint16_t twt_id; /**< TWT connection id, the value range is [0, 32767]. */
@ -161,38 +160,38 @@ typedef enum {
*/
#if CONFIG_IDF_TARGET_ESP32C5
typedef struct {
signed rssi:8; /**< the RSSI of the reception frame */
unsigned rate:5; /**< if cur_bb_format is RX_BB_FORMAT_11B, it's the transmission rate. otherwise it's Rate field of L-SIG */
signed rssi: 8; /**< the RSSI of the reception frame */
unsigned rate: 5; /**< if cur_bb_format is RX_BB_FORMAT_11B, it's the transmission rate. otherwise it's Rate field of L-SIG */
unsigned : 1; /**< reserved */
unsigned : 2; /**< reserved */
unsigned : 12; /**< reserved */
unsigned rxmatch0:1; /**< indicate whether the reception frame is from interface 0 */
unsigned rxmatch1:1; /**< indicate whether the reception frame is from interface 1 */
unsigned rxmatch2:1; /**< indicate whether the reception frame is from interface 2 */
unsigned rxmatch3:1; /**< indicate whether the reception frame is from interface 3 */
unsigned rxmatch0: 1; /**< indicate whether the reception frame is from interface 0 */
unsigned rxmatch1: 1; /**< indicate whether the reception frame is from interface 1 */
unsigned rxmatch2: 1; /**< indicate whether the reception frame is from interface 2 */
unsigned rxmatch3: 1; /**< indicate whether the reception frame is from interface 3 */
uint32_t he_siga1; /**< HE-SIGA1 or HT-SIG or VHT-SIG */
unsigned rxend_state:8; /**< reception state, 0: successful, others: failure */
unsigned rxend_state: 8; /**< reception state, 0: successful, others: failure */
uint16_t he_siga2; /**< HE-SIGA2 */
unsigned : 7; /**< reserved */
unsigned is_group:1; /**< indicate whether the reception is a group addressed frame */
unsigned timestamp:32; /**< timestamp. The local time when this packet is received. It is precise only if modem sleep or light sleep is not enabled. unit: microsecond */
unsigned is_group: 1; /**< indicate whether the reception is a group addressed frame */
unsigned timestamp: 32; /**< timestamp. The local time when this packet is received. It is precise only if modem sleep or light sleep is not enabled. unit: microsecond */
unsigned : 15; /**< reserved */
unsigned : 15; /**< reserved */
unsigned : 2; /**< reserved */
unsigned noise_floor:8; /**< the noise floor of the reception frame */
unsigned noise_floor: 8; /**< the noise floor of the reception frame */
signed : 8; /**< reserved */
signed : 8; /**< reserved */
unsigned : 8; /**< reserved */
unsigned : 8; /**< reserved */
unsigned : 8; /**< reserved */
unsigned : 2; /**< reserved */
unsigned sigb_len:10; /**< the sigb length */
unsigned sigb_len: 10; /**< the sigb length */
unsigned : 1; /**< reserved */
unsigned : 1; /**< reserved */
unsigned : 1; /**< reserved */
unsigned : 1; /**< reserved */
unsigned channel:4; /**< the primary channel */
unsigned second:4; /**< the second channel if in HT40 */
unsigned channel: 4; /**< the primary channel */
unsigned second: 4; /**< the second channel if in HT40 */
unsigned : 12; /**< reserved */
unsigned : 4; /**< reserved */
unsigned : 1; /**< reserved */
@ -204,9 +203,9 @@ typedef struct {
unsigned : 1; /**< reserved */
unsigned : 12; /**< reserved */
unsigned : 12; /**< reserved */
unsigned cur_bb_format:4; /**< the format of the reception frame */
unsigned rx_channel_estimate_len:10; /**< the length of the channel information */
unsigned rx_channel_estimate_info_vld:1; /**< indicate the channel information is valid */
unsigned cur_bb_format: 4; /**< the format of the reception frame */
unsigned rx_channel_estimate_len: 10; /**< the length of the channel information */
unsigned rx_channel_estimate_info_vld: 1; /**< indicate the channel information is valid */
unsigned : 5; /**< reserved */
unsigned : 21; /**< reserved */
unsigned : 10; /**< reserved */
@ -221,11 +220,11 @@ typedef struct {
unsigned : 1; /**< reserved */
unsigned : 8; /**< reserved */
unsigned : 16; /**< reserved */
unsigned sig_len:14; /**< the length of the reception MPDU */
unsigned sig_len: 14; /**< the length of the reception MPDU */
unsigned : 2; /**< reserved */
unsigned dump_len:14; /**< the length of the reception MPDU excluding the FCS */
unsigned dump_len: 14; /**< the length of the reception MPDU excluding the FCS */
unsigned : 2; /**< reserved */
unsigned rx_state:8; /**< reception state, 0: successful, others: failure */
unsigned rx_state: 8; /**< reception state, 0: successful, others: failure */
unsigned : 8; /**< reserved */
unsigned : 16; /**< reserved */
} __attribute__((packed)) esp_wifi_rxctrl_t;

Wyświetl plik

@ -4,7 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __ESP_WIFI_TYPES_H__
#define __ESP_WIFI_TYPES_H__
@ -209,9 +208,9 @@ typedef enum {
/** @brief Description of a WiFi AP HE Info */
typedef struct {
uint8_t bss_color:6; /**< an unsigned integer whose value is the BSS Color of the BSS corresponding to the AP */
uint8_t partial_bss_color:1; /**< indicate if an AID assignment rule based on the BSS color */
uint8_t bss_color_disabled:1; /**< indicate if the use of BSS color is disabled */
uint8_t bss_color: 6; /**< an unsigned integer whose value is the BSS Color of the BSS corresponding to the AP */
uint8_t partial_bss_color: 1; /**< indicate if an AID assignment rule based on the BSS color */
uint8_t bss_color_disabled: 1; /**< indicate if the use of BSS color is disabled */
uint8_t bssid_index; /**< in M-BSSID set, identifies the nontransmitted BSSID */
} wifi_he_ap_info_t;
@ -226,17 +225,17 @@ typedef struct {
wifi_cipher_type_t pairwise_cipher; /**< pairwise cipher of AP */
wifi_cipher_type_t group_cipher; /**< group cipher of AP */
wifi_ant_t ant; /**< antenna used to receive beacon from AP */
uint32_t phy_11b:1; /**< bit: 0 flag to identify if 11b mode is enabled or not */
uint32_t phy_11g:1; /**< bit: 1 flag to identify if 11g mode is enabled or not */
uint32_t phy_11n:1; /**< bit: 2 flag to identify if 11n mode is enabled or not */
uint32_t phy_lr:1; /**< bit: 3 flag to identify if low rate is enabled or not */
uint32_t phy_11a:1; /**< bit: 4 flag to identify if 11ax mode is enabled or not */
uint32_t phy_11ac:1; /**< bit: 5 flag to identify if 11ax mode is enabled or not */
uint32_t phy_11ax:1; /**< bit: 6 flag to identify if 11ax mode is enabled or not */
uint32_t wps:1; /**< bit: 7 flag to identify if WPS is supported or not */
uint32_t ftm_responder:1; /**< bit: 8 flag to identify if FTM is supported in responder mode */
uint32_t ftm_initiator:1; /**< bit: 9 flag to identify if FTM is supported in initiator mode */
uint32_t reserved:22; /**< bit: 10..31 reserved */
uint32_t phy_11b: 1; /**< bit: 0 flag to identify if 11b mode is enabled or not */
uint32_t phy_11g: 1; /**< bit: 1 flag to identify if 11g mode is enabled or not */
uint32_t phy_11n: 1; /**< bit: 2 flag to identify if 11n mode is enabled or not */
uint32_t phy_lr: 1; /**< bit: 3 flag to identify if low rate is enabled or not */
uint32_t phy_11a: 1; /**< bit: 4 flag to identify if 11ax mode is enabled or not */
uint32_t phy_11ac: 1; /**< bit: 5 flag to identify if 11ax mode is enabled or not */
uint32_t phy_11ax: 1; /**< bit: 6 flag to identify if 11ax mode is enabled or not */
uint32_t wps: 1; /**< bit: 7 flag to identify if WPS is supported or not */
uint32_t ftm_responder: 1; /**< bit: 8 flag to identify if FTM is supported in responder mode */
uint32_t ftm_initiator: 1; /**< bit: 9 flag to identify if FTM is supported in initiator mode */
uint32_t reserved: 22; /**< bit: 10..31 reserved */
wifi_country_t country; /**< country information of AP */
wifi_he_ap_info_t he_ap; /**< HE AP info */
uint8_t bandwidth; /**< For either 20 MHz or 40 MHz operation, the Channel Width field is set to 0.
@ -252,19 +251,19 @@ typedef struct {
typedef enum {
WIFI_FAST_SCAN = 0, /**< Do fast scan, scan will end after find SSID match AP */
WIFI_ALL_CHANNEL_SCAN, /**< All channel scan, scan will end after scan all the channel */
}wifi_scan_method_t;
} wifi_scan_method_t;
typedef enum {
WIFI_CONNECT_AP_BY_SIGNAL = 0, /**< Sort match AP in scan list by RSSI */
WIFI_CONNECT_AP_BY_SECURITY, /**< Sort match AP in scan list by security mode */
}wifi_sort_method_t;
} wifi_sort_method_t;
/** @brief Structure describing parameters for a WiFi fast scan */
typedef struct {
int8_t rssi; /**< The minimum rssi to accept in the fast scan mode */
wifi_auth_mode_t authmode; /**< The weakest authmode to accept in the fast scan mode
Note: In case this value is not set and password is set as per WPA2 standards(password len >= 8), it will be defaulted to WPA2 and device won't connect to deprecated WEP/WPA networks. Please set authmode threshold as WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK to connect to WEP/WPA networks */
}wifi_scan_threshold_t;
} wifi_scan_threshold_t;
typedef enum {
WIFI_PS_NONE, /**< No power save */
@ -340,26 +339,26 @@ typedef struct {
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. Note that when btm is enabled, the application itself should not set specific bssid (i.e using bssid_set and bssid in this config)or channel to connect to. This defeats the purpose of a BTM supported network, and hence if btm is supported and a specific bssid or channel is set in this config, it will be cleared from the config at the first disconnection or connection so that the device can roam to other BSS. It is recommended not to set BSSID when BTM is enabled. */
uint32_t mbo_enabled:1; /**< Whether MBO is enabled for the connection. Note that when mbo is enabled, the application itself should not set specific bssid (i.e using bssid_set and bssid in this config)or channel to connect to. This defeats the purpose of a MBO supported network, and hence if btm is supported and a specific bssid or channel is set in this config, it will be cleared from the config at the first disconnection or connection so that the device can roam to other BSS. It is recommended not to set BSSID when MBO is enabled. Enabling mbo here, automatically enables btm and rm above.*/
uint32_t ft_enabled:1; /**< Whether FT is enabled for the connection */
uint32_t owe_enabled:1; /**< Whether OWE is enabled for the connection */
uint32_t transition_disable:1; /**< Whether to enable transition disable feature */
uint32_t reserved:26; /**< Reserved for future feature set */
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. Note that when btm is enabled, the application itself should not set specific bssid (i.e using bssid_set and bssid in this config)or channel to connect to. This defeats the purpose of a BTM supported network, and hence if btm is supported and a specific bssid or channel is set in this config, it will be cleared from the config at the first disconnection or connection so that the device can roam to other BSS. It is recommended not to set BSSID when BTM is enabled. */
uint32_t mbo_enabled: 1; /**< Whether MBO is enabled for the connection. Note that when mbo is enabled, the application itself should not set specific bssid (i.e using bssid_set and bssid in this config)or channel to connect to. This defeats the purpose of a MBO supported network, and hence if btm is supported and a specific bssid or channel is set in this config, it will be cleared from the config at the first disconnection or connection so that the device can roam to other BSS. It is recommended not to set BSSID when MBO is enabled. Enabling mbo here, automatically enables btm and rm above.*/
uint32_t ft_enabled: 1; /**< Whether FT is enabled for the connection */
uint32_t owe_enabled: 1; /**< Whether OWE is enabled for the connection */
uint32_t transition_disable: 1; /**< Whether to enable transition disable feature */
uint32_t reserved: 26; /**< Reserved for future feature set */
wifi_sae_pwe_method_t sae_pwe_h2e; /**< Configuration for SAE PWE derivation method */
wifi_sae_pk_mode_t sae_pk_mode; /**< Configuration for SAE-PK (Public Key) Authentication 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 in case best AP doesn't behave properly. */
uint32_t he_dcm_set:1; /**< Whether DCM max.constellation for transmission and reception is set. */
uint32_t he_dcm_max_constellation_tx:2; /**< Indicate the max.constellation for DCM in TB PPDU the STA supported. 0: not supported. 1: BPSK, 2: QPSK, 3: 16-QAM. The default value is 3. */
uint32_t he_dcm_max_constellation_rx:2; /**< Indicate the max.constellation for DCM in both Data field and HE-SIG-B field the STA supported. 0: not supported. 1: BPSK, 2: QPSK, 3: 16-QAM. The default value is 3. */
uint32_t he_mcs9_enabled:1; /**< Whether to support HE-MCS 0 to 9. The default value is 0. */
uint32_t he_su_beamformee_disabled:1; /**< Whether to disable support for operation as an SU beamformee. */
uint32_t he_trig_su_bmforming_feedback_disabled:1; /**< Whether to disable support the transmission of SU feedback in an HE TB sounding sequence. */
uint32_t he_trig_mu_bmforming_partial_feedback_disabled:1; /**< Whether to disable support the transmission of partial-bandwidth MU feedback in an HE TB sounding sequence. */
uint32_t he_trig_cqi_feedback_disabled:1; /**< Whether to disable support the transmission of CQI feedback in an HE TB sounding sequence. */
uint32_t he_reserved:22; /**< Reserved for future feature set */
uint32_t he_dcm_set: 1; /**< Whether DCM max.constellation for transmission and reception is set. */
uint32_t he_dcm_max_constellation_tx: 2; /**< Indicate the max.constellation for DCM in TB PPDU the STA supported. 0: not supported. 1: BPSK, 2: QPSK, 3: 16-QAM. The default value is 3. */
uint32_t he_dcm_max_constellation_rx: 2; /**< Indicate the max.constellation for DCM in both Data field and HE-SIG-B field the STA supported. 0: not supported. 1: BPSK, 2: QPSK, 3: 16-QAM. The default value is 3. */
uint32_t he_mcs9_enabled: 1; /**< Whether to support HE-MCS 0 to 9. The default value is 0. */
uint32_t he_su_beamformee_disabled: 1; /**< Whether to disable support for operation as an SU beamformee. */
uint32_t he_trig_su_bmforming_feedback_disabled: 1; /**< Whether to disable support the transmission of SU feedback in an HE TB sounding sequence. */
uint32_t he_trig_mu_bmforming_partial_feedback_disabled: 1; /**< Whether to disable support the transmission of partial-bandwidth MU feedback in an HE TB sounding sequence. */
uint32_t he_trig_cqi_feedback_disabled: 1; /**< Whether to disable support the transmission of CQI feedback in an HE TB sounding sequence. */
uint32_t he_reserved: 22; /**< Reserved for future feature set */
uint8_t sae_h2e_identifier[SAE_H2E_IDENTIFIER_LEN];/**< Password identifier for H2E. this needs to be null terminated string */
} wifi_sta_config_t;
@ -390,15 +389,15 @@ typedef union {
typedef struct {
uint8_t mac[6]; /**< mac address */
int8_t rssi; /**< current average rssi of sta connected */
uint32_t phy_11b:1; /**< bit: 0 flag to identify if 11b mode is enabled or not */
uint32_t phy_11g:1; /**< bit: 1 flag to identify if 11g mode is enabled or not */
uint32_t phy_11n:1; /**< bit: 2 flag to identify if 11n mode is enabled or not */
uint32_t phy_lr:1; /**< bit: 3 flag to identify if low rate is enabled or not */
uint32_t phy_11a:1; /**< bit: 4 flag to identify if 11ax mode is enabled or not */
uint32_t phy_11ac:1; /**< bit: 5 flag to identify if 11ax mode is enabled or not */
uint32_t phy_11ax:1; /**< bit: 6 flag to identify if 11ax mode is enabled or not */
uint32_t is_mesh_child:1;/**< bit: 7 flag to identify mesh child */
uint32_t reserved:24; /**< bit: 8..31 reserved */
uint32_t phy_11b: 1; /**< bit: 0 flag to identify if 11b mode is enabled or not */
uint32_t phy_11g: 1; /**< bit: 1 flag to identify if 11g mode is enabled or not */
uint32_t phy_11n: 1; /**< bit: 2 flag to identify if 11n mode is enabled or not */
uint32_t phy_lr: 1; /**< bit: 3 flag to identify if low rate is enabled or not */
uint32_t phy_11a: 1; /**< bit: 4 flag to identify if 11ax mode is enabled or not */
uint32_t phy_11ac: 1; /**< bit: 5 flag to identify if 11ax mode is enabled or not */
uint32_t phy_11ax: 1; /**< bit: 6 flag to identify if 11ax mode is enabled or not */
uint32_t is_mesh_child: 1; /**< bit: 7 flag to identify mesh child */
uint32_t reserved: 24; /**< bit: 8..31 reserved */
} wifi_sta_info_t;
typedef enum {
@ -434,8 +433,7 @@ typedef enum {
/**
* @brief Operation Phymode
*/
typedef enum
{
typedef enum {
WIFI_PHY_MODE_LR, /**< PHY mode for Low Rate */
WIFI_PHY_MODE_11B, /**< PHY mode for 11b */
WIFI_PHY_MODE_11G, /**< PHY mode for 11g */
@ -472,7 +470,6 @@ typedef enum {
WIFI_PKT_MISC, /**< Other type, such as MIMO etc. 'buf' argument is wifi_promiscuous_pkt_t but the payload is zero length. */
} wifi_promiscuous_pkt_type_t;
#define WIFI_PROMIS_FILTER_MASK_ALL (0xFFFFFFFF) /**< filter all packets */
#define WIFI_PROMIS_FILTER_MASK_MGMT (1) /**< filter the packets with type of WIFI_PKT_MGMT */
#define WIFI_PROMIS_FILTER_MASK_CTRL (1<<1) /**< filter the packets with type of WIFI_PKT_CTRL */
@ -616,9 +613,9 @@ typedef struct {
wifi_nan_service_type_t type; /**< Service type */
char matching_filter[ESP_WIFI_MAX_FILTER_LEN]; /**< Comma separated filters for filtering services */
char svc_info[ESP_WIFI_MAX_SVC_INFO_LEN]; /**< Service info shared in Publish frame */
uint8_t single_replied_event:1; /**< Give single Replied event or every time */
uint8_t datapath_reqd:1; /**< NAN Datapath required for the service */
uint8_t reserved:6; /**< Reserved */
uint8_t single_replied_event: 1; /**< Give single Replied event or every time */
uint8_t datapath_reqd: 1; /**< NAN Datapath required for the service */
uint8_t reserved: 6; /**< Reserved */
} wifi_nan_publish_cfg_t;
/**
@ -630,8 +627,8 @@ typedef struct {
wifi_nan_service_type_t type; /**< Service type */
char matching_filter[ESP_WIFI_MAX_FILTER_LEN]; /**< Comma separated filters for filtering services */
char svc_info[ESP_WIFI_MAX_SVC_INFO_LEN]; /**< Service info shared in Subscribe frame */
uint8_t single_match_event:1; /**< Give single Match event or every time */
uint8_t reserved:7; /**< Reserved */
uint8_t single_match_event: 1; /**< Give single Match event or every time */
uint8_t reserved: 7; /**< Reserved */
} wifi_nan_subscribe_cfg_t;
/**

Wyświetl plik

@ -35,54 +35,54 @@ typedef esp_wifi_rxctrl_t wifi_pkt_rx_ctrl_t;
#else
/** @brief Received packet radio metadata header, this is the common header at the beginning of all promiscuous mode RX callback buffers */
typedef struct {
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 :1; /**< reserved */
unsigned sig_mode:2; /**< Protocol of the received packet, 0: non HT(11bg) packet; 1: HT(11n) packet; 3: VHT(11ac) packet */
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 cwb:1; /**< Channel Bandwidth of the packet. 0: 20MHz; 1: 40MHz */
unsigned :16; /**< reserved */
unsigned smoothing:1; /**< Set to 1 indicates that channel estimate smoothing is recommended.
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 : 1; /**< reserved */
unsigned sig_mode: 2; /**< Protocol of the received packet, 0: non HT(11bg) packet; 1: HT(11n) packet; 3: VHT(11ac) packet */
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 cwb: 1; /**< Channel Bandwidth of the packet. 0: 20MHz; 1: 40MHz */
unsigned : 16; /**< reserved */
unsigned smoothing: 1; /**< Set to 1 indicates that channel estimate smoothing is recommended.
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.
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 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 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 : 1; /**< reserved */
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 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 */
#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
unsigned :8; /**< reserved */
unsigned : 8; /**< reserved */
#endif
unsigned ampdu_cnt:8; /**< the number of subframes aggregated in AMPDU */
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 :8; /**< reserved */
unsigned timestamp:32; /**< timestamp. The local time when this packet is received. It is precise only if modem sleep or light sleep is not enabled. unit: microsecond */
unsigned :32; /**< reserved */
unsigned ampdu_cnt: 8; /**< the number of subframes aggregated in AMPDU */
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 : 8; /**< reserved */
unsigned timestamp: 32; /**< timestamp. The local time when this packet is received. It is precise only if modem sleep or light sleep is not enabled. unit: microsecond */
unsigned : 32; /**< reserved */
#if CONFIG_IDF_TARGET_ESP32S2
unsigned :32; /**< reserved */
unsigned : 32; /**< reserved */
#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2
signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/
unsigned :24; /**< reserved */
unsigned :32; /**< reserved */
signed noise_floor: 8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/
unsigned : 24; /**< reserved */
unsigned : 32; /**< reserved */
#endif
unsigned :31; /**< reserved */
unsigned ant:1; /**< antenna number from which this packet is received. 0: WiFi antenna 0; 1: WiFi antenna 1 */
unsigned : 31; /**< reserved */
unsigned ant: 1; /**< antenna number from which this packet is received. 0: WiFi antenna 0; 1: WiFi antenna 1 */
#if CONFIG_IDF_TARGET_ESP32S2
signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/
unsigned :24; /**< reserved */
signed noise_floor: 8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/
unsigned : 24; /**< reserved */
#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2
unsigned :32; /**< reserved */
unsigned :32; /**< reserved */
unsigned :32; /**< reserved */
unsigned : 32; /**< reserved */
unsigned : 32; /**< reserved */
unsigned : 32; /**< reserved */
#endif
unsigned sig_len:12; /**< length of packet including Frame Check Sequence(FCS) */
unsigned :12; /**< reserved */
unsigned rx_state:8; /**< state of the packet. 0: no error; others: error numbers which are not public */
unsigned sig_len: 12; /**< length of packet including Frame Check Sequence(FCS) */
unsigned : 12; /**< reserved */
unsigned rx_state: 8; /**< state of the packet. 0: no error; others: error numbers which are not public */
} wifi_pkt_rx_ctrl_t;
#endif
@ -105,7 +105,6 @@ typedef struct {
} wifi_csi_config_t;
#endif // !CONFIG_SOC_WIFI_HE_SUPPORT
/** @brief Payload passed to 'buf' parameter of promiscuous mode RX callback.
*/
typedef struct {

@ -1 +1 @@
Subproject commit 49c8e2d99d2dfc26e49b320327fb6df06dfc9722
Subproject commit 852cfcfa667356b2ae99052d6fbe5fdb587956eb

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2010-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -86,7 +86,7 @@ static void sc_ack_send_task(void *pvParameters)
remote_port = SC_ACK_TOUCH_SERVER_PORT;
} else if (ack->type == SC_TYPE_ESPTOUCH_V2) {
uint8_t port_bit = ack->ctx.token;
if(port_bit > 3) {
if (port_bit > 3) {
port_bit = 0;
}
remote_port = SC_ACK_TOUCH_V2_SERVER_PORT(port_bit);
@ -194,8 +194,7 @@ static void sc_ack_send_task(void *pvParameters)
goto _end;
}
}
}
else {
} else {
vTaskDelay((TickType_t)(100 / portTICK_PERIOD_MS));
}
}

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -278,13 +278,13 @@ esp_err_t esp_wifi_set_default_wifi_nan_handlers(void)
esp_err_t esp_wifi_clear_default_wifi_driver_and_handlers(void *esp_netif)
{
int i;
for (i = 0; i< MAX_WIFI_IFS; ++i) {
for (i = 0; i < MAX_WIFI_IFS; ++i) {
// clear internal static pointers to netifs
if (s_wifi_netifs[i] == esp_netif) {
s_wifi_netifs[i] = NULL;
}
}
for (i = 0; i< MAX_WIFI_IFS; ++i) {
for (i = 0; i < MAX_WIFI_IFS; ++i) {
// check if all netifs are cleared to delete default handlers
if (s_wifi_netifs[i] != NULL) {
break;
@ -298,7 +298,6 @@ esp_err_t esp_wifi_clear_default_wifi_driver_and_handlers(void *esp_netif)
return disconnect_and_destroy(esp_netif);
}
//
// Object manipulation
//
@ -329,12 +328,12 @@ static inline esp_err_t esp_netif_attach_wifi(esp_netif_t *esp_netif, wifi_inter
{
if (esp_netif == NULL || (wifi_if != WIFI_IF_STA
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
&& wifi_if != WIFI_IF_AP
&& wifi_if != WIFI_IF_AP
#endif
#ifdef CONFIG_ESP_WIFI_NAN_ENABLE
&& wifi_if != WIFI_IF_NAN
&& wifi_if != WIFI_IF_NAN
#endif
)) {
)) {
return ESP_ERR_INVALID_ARG;
}
s_wifi_netifs[wifi_if] = esp_netif;
@ -360,7 +359,6 @@ esp_err_t esp_netif_attach_wifi_nan(esp_netif_t *esp_netif)
}
#endif
//
// Default WiFi creation from user code
//
@ -459,8 +457,8 @@ esp_err_t esp_netif_create_default_wifi_mesh_netifs(esp_netif_t **p_netif_sta, e
memcpy(&netif_cfg, ESP_NETIF_BASE_DEFAULT_WIFI_AP, sizeof(netif_cfg));
netif_cfg.flags &= ~ESP_NETIF_DHCP_SERVER;
esp_netif_config_t cfg_ap = {
.base = &netif_cfg,
.stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP,
.base = &netif_cfg,
.stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP,
};
esp_netif_t *netif_ap = esp_netif_new(&cfg_ap);
assert(netif_ap);
@ -474,8 +472,8 @@ esp_err_t esp_netif_create_default_wifi_mesh_netifs(esp_netif_t **p_netif_sta, e
memcpy(&netif_cfg, ESP_NETIF_BASE_DEFAULT_WIFI_STA, sizeof(netif_cfg));
netif_cfg.flags &= ~ESP_NETIF_DHCP_CLIENT;
esp_netif_config_t cfg_sta = {
.base = &netif_cfg,
.stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_STA,
.base = &netif_cfg,
.stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_STA,
};
esp_netif_t *netif_sta = esp_netif_new(&cfg_sta);
assert(netif_sta);

Wyświetl plik

@ -162,7 +162,7 @@ static esp_err_t wifi_deinit_internal(void)
}
if (esp_wifi_internal_reg_rxcb(WIFI_IF_STA, NULL) != ESP_OK ||
esp_wifi_internal_reg_rxcb(WIFI_IF_AP, NULL) != ESP_OK) {
esp_wifi_internal_reg_rxcb(WIFI_IF_AP, NULL) != ESP_OK) {
ESP_LOGW(TAG, "Failed to unregister Rx callbacks");
}
@ -349,7 +349,7 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config)
#if CONFIG_MAC_BB_PD
if (esp_register_mac_bb_pd_callback(pm_mac_sleep) != ESP_OK
|| esp_register_mac_bb_pu_callback(pm_mac_wakeup) != ESP_OK) {
|| esp_register_mac_bb_pu_callback(pm_mac_wakeup) != ESP_OK) {
esp_unregister_mac_bb_pd_callback(pm_mac_sleep);
esp_unregister_mac_bb_pu_callback(pm_mac_wakeup);
@ -418,7 +418,7 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config)
#ifdef CONFIG_PM_ENABLE
if (s_wifi_modem_sleep_lock == NULL) {
result = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "wifi",
&s_wifi_modem_sleep_lock);
&s_wifi_modem_sleep_lock);
if (result != ESP_OK) {
ESP_LOGE(TAG, "Failed to create pm lock (0x%x)", result);
goto _deinit;

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -81,10 +81,10 @@ static esp_err_t wifi_driver_start(esp_netif_t * esp_netif, void * args)
wifi_netif_driver_t driver = args;
driver->base.netif = esp_netif;
esp_netif_driver_ifconfig_t driver_ifconfig = {
.handle = driver,
.transmit = wifi_transmit,
.transmit_wrap= wifi_transmit_wrap,
.driver_free_rx_buffer = wifi_free
.handle = driver,
.transmit = wifi_transmit,
.transmit_wrap = wifi_transmit_wrap,
.driver_free_rx_buffer = wifi_free
};
return esp_netif_set_driver_config(esp_netif, &driver_ifconfig);
@ -94,7 +94,7 @@ void esp_wifi_destroy_if_driver(wifi_netif_driver_t h)
{
if (h) {
esp_wifi_internal_reg_rxcb(h->wifi_if, NULL); // ignore the potential error
// as the wifi might have been already uninitialized
// as the wifi might have been already uninitialized
s_wifi_netifs[h->wifi_if] = NULL;
}
free(h);
@ -140,8 +140,7 @@ esp_err_t esp_wifi_register_if_rxcb(wifi_netif_driver_t ifx, esp_netif_receive_t
wifi_rxcb_t rxcb = NULL;
esp_err_t ret;
switch (wifi_interface)
{
switch (wifi_interface) {
case WIFI_IF_STA:
rxcb = wifi_sta_receive;

Wyświetl plik

@ -43,7 +43,6 @@ void tearDown(void)
check_leak(before_free_32bit, after_free_32bit, "32BIT");
}
void app_main(void)
{
ESP_ERROR_CHECK(nvs_flash_init());

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*
@ -24,7 +24,6 @@
#include "freertos/task.h"
#include "freertos/event_groups.h"
#ifndef TEST_SUFFIX_STR
#define TEST_SUFFIX_STR "_0000"
#endif
@ -34,7 +33,6 @@
#define TEST_DEFAULT_CHANNEL (6)
#define CONNECT_TIMEOUT_MS (8000)
#define GOT_IP_EVENT (1)
#define WIFI_DISCONNECT_EVENT (1<<1)
#define WIFI_STA_CONNECTED (1<<2)
@ -42,7 +40,6 @@
#define EVENT_HANDLER_FLAG_DO_NOT_AUTO_RECONNECT 0x00000001
static const char* TAG = "test_wifi";
static uint32_t wifi_event_handler_flag;
static esp_netif_t* s_ap_netif = NULL;
@ -51,60 +48,59 @@ static esp_netif_t* s_sta_netif = NULL;
static EventGroupHandle_t wifi_events;
static void wifi_event_handler(void* arg, esp_event_base_t event_base,
int32_t event_id, void* event_data)
int32_t event_id, void* event_data)
{
ESP_LOGI(TAG, "wifi event handler: %"PRIi32, event_id);
switch(event_id) {
case WIFI_EVENT_STA_START:
ESP_LOGI(TAG, "WIFI_EVENT_STA_START");
break;
case WIFI_EVENT_AP_STACONNECTED:
ESP_LOGI(TAG, "WIFI_EVENT_AP_STACONNECTED");
if (wifi_events) {
xEventGroupSetBits(wifi_events, WIFI_AP_STA_CONNECTED);
}
break;
case WIFI_EVENT_STA_CONNECTED:
ESP_LOGI(TAG, "WIFI_EVENT_STA_CONNECTED");
if (wifi_events) {
xEventGroupSetBits(wifi_events, WIFI_STA_CONNECTED);
}
break;
case WIFI_EVENT_STA_DISCONNECTED:
ESP_LOGI(TAG, "WIFI_EVENT_STA_DISCONNECTED");
wifi_event_sta_disconnected_t *event = (wifi_event_sta_disconnected_t *)event_data;
ESP_LOGI(TAG, "disconnect reason: %u", event->reason);
if (! (EVENT_HANDLER_FLAG_DO_NOT_AUTO_RECONNECT & wifi_event_handler_flag) ) {
TEST_ESP_OK(esp_wifi_connect());
}
if (wifi_events) {
xEventGroupSetBits(wifi_events, WIFI_DISCONNECT_EVENT);
}
break;
default:
break;
switch (event_id) {
case WIFI_EVENT_STA_START:
ESP_LOGI(TAG, "WIFI_EVENT_STA_START");
break;
case WIFI_EVENT_AP_STACONNECTED:
ESP_LOGI(TAG, "WIFI_EVENT_AP_STACONNECTED");
if (wifi_events) {
xEventGroupSetBits(wifi_events, WIFI_AP_STA_CONNECTED);
}
break;
case WIFI_EVENT_STA_CONNECTED:
ESP_LOGI(TAG, "WIFI_EVENT_STA_CONNECTED");
if (wifi_events) {
xEventGroupSetBits(wifi_events, WIFI_STA_CONNECTED);
}
break;
case WIFI_EVENT_STA_DISCONNECTED:
ESP_LOGI(TAG, "WIFI_EVENT_STA_DISCONNECTED");
wifi_event_sta_disconnected_t *event = (wifi_event_sta_disconnected_t *)event_data;
ESP_LOGI(TAG, "disconnect reason: %u", event->reason);
if (!(EVENT_HANDLER_FLAG_DO_NOT_AUTO_RECONNECT & wifi_event_handler_flag)) {
TEST_ESP_OK(esp_wifi_connect());
}
if (wifi_events) {
xEventGroupSetBits(wifi_events, WIFI_DISCONNECT_EVENT);
}
break;
default:
break;
}
return;
}
static void ip_event_handler(void* arg, esp_event_base_t event_base,
int32_t event_id, void* event_data)
int32_t event_id, void* event_data)
{
ip_event_got_ip_t *event;
ESP_LOGI(TAG, "ip event handler");
switch(event_id) {
case IP_EVENT_STA_GOT_IP:
event = (ip_event_got_ip_t*)event_data;
ESP_LOGI(TAG, "IP_EVENT_STA_GOT_IP");
ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
if (wifi_events) {
xEventGroupSetBits(wifi_events, GOT_IP_EVENT);
}
break;
default:
break;
switch (event_id) {
case IP_EVENT_STA_GOT_IP:
event = (ip_event_got_ip_t*)event_data;
ESP_LOGI(TAG, "IP_EVENT_STA_GOT_IP");
ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
if (wifi_events) {
xEventGroupSetBits(wifi_events, GOT_IP_EVENT);
}
break;
default:
break;
}
return;
}
@ -131,18 +127,17 @@ static esp_err_t event_deinit(void)
#define EMPH_STR(s) "****** "s" ******"
static void start_wifi_as_softap(void)
{
wifi_config_t w_config = {
.ap.ssid = TEST_DEFAULT_SSID,
.ap.password = TEST_DEFAULT_PWD,
.ap.ssid_len = strlen(TEST_DEFAULT_SSID),
.ap.channel = TEST_DEFAULT_CHANNEL,
.ap.authmode = WIFI_AUTH_WPA2_PSK,
.ap.ssid_hidden = false,
.ap.max_connection = 4,
.ap.beacon_interval = 100,
.ap.channel = TEST_DEFAULT_CHANNEL,
.ap.authmode = WIFI_AUTH_WPA2_PSK,
.ap.ssid_hidden = false,
.ap.max_connection = 4,
.ap.beacon_interval = 100,
};
event_init();
@ -181,7 +176,7 @@ static void stop_wifi(void)
vEventGroupDelete(wifi_events);
wifi_events = NULL;
}
vTaskDelay(500/portTICK_PERIOD_MS);
vTaskDelay(500 / portTICK_PERIOD_MS);
}
static void receive_ds2ds_packet(void)
@ -189,7 +184,7 @@ static void receive_ds2ds_packet(void)
start_wifi_as_softap();
// wait for sender to send packets
vTaskDelay(1000/portTICK_PERIOD_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
stop_wifi();
}
@ -210,7 +205,7 @@ static void send_ds2ds_packet(void)
esp_wifi_80211_tx(WIFI_IF_AP, ds2ds_pdu, sizeof(ds2ds_pdu), true);
vTaskDelay(50 / portTICK_PERIOD_MS);
}
vTaskDelay(500/portTICK_PERIOD_MS);
vTaskDelay(500 / portTICK_PERIOD_MS);
stop_wifi();
}
@ -228,7 +223,7 @@ static void wifi_connect(void)
TEST_ESP_OK(esp_wifi_set_config(WIFI_IF_STA, &w_config));
TEST_ESP_OK(esp_wifi_connect());
ESP_LOGI(TAG, "start esp_wifi_connect: %s", TEST_DEFAULT_SSID);
bits = xEventGroupWaitBits(wifi_events, GOT_IP_EVENT, 1, 0, CONNECT_TIMEOUT_MS/portTICK_PERIOD_MS);
bits = xEventGroupWaitBits(wifi_events, GOT_IP_EVENT, 1, 0, CONNECT_TIMEOUT_MS / portTICK_PERIOD_MS);
TEST_ASSERT(bits & GOT_IP_EVENT);
}
@ -238,7 +233,7 @@ static void test_wifi_connection_sta(void)
start_wifi_as_sta();
// make sure softap has started
vTaskDelay(1000/portTICK_PERIOD_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
wifi_connect();
// do not auto reconnect after connected
@ -258,7 +253,7 @@ static void test_wifi_connection_softap(void)
start_wifi_as_softap();
// wait station connected
bits = xEventGroupWaitBits(wifi_events, WIFI_AP_STA_CONNECTED, 1, 0, CONNECT_TIMEOUT_MS/portTICK_PERIOD_MS);
bits = xEventGroupWaitBits(wifi_events, WIFI_AP_STA_CONNECTED, 1, 0, CONNECT_TIMEOUT_MS / portTICK_PERIOD_MS);
TEST_ASSERT(bits & WIFI_AP_STA_CONNECTED);
// wait 70s (longer than station side)
@ -275,7 +270,7 @@ static void esp_wifi_connect_first_time(void)
{
start_wifi_as_sta();
// make sure softap has started
vTaskDelay(1000/portTICK_PERIOD_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
wifi_config_t w_config;
memset(&w_config, 0, sizeof(w_config));
@ -296,7 +291,7 @@ static void test_wifi_connect_at_scan_phase(void)
esp_wifi_connect_first_time();
// connect when first connect in scan
vTaskDelay(300/portTICK_PERIOD_MS);
vTaskDelay(300 / portTICK_PERIOD_MS);
ESP_LOGI(TAG, "connect when first connect in scan");
TEST_ESP_ERR(ESP_ERR_WIFI_CONN, esp_wifi_connect());
wifi_event_handler_flag |= EVENT_HANDLER_FLAG_DO_NOT_AUTO_RECONNECT;
@ -310,7 +305,7 @@ static void test_wifi_connect_before_connected_phase(void)
esp_wifi_connect_first_time();
// connect before connected
vTaskDelay(730/portTICK_PERIOD_MS);
vTaskDelay(730 / portTICK_PERIOD_MS);
ESP_LOGI(TAG, "connect when first connect after scan before connected");
TEST_ESP_ERR(ESP_ERR_WIFI_CONN, esp_wifi_connect());
wifi_event_handler_flag |= EVENT_HANDLER_FLAG_DO_NOT_AUTO_RECONNECT;
@ -328,7 +323,7 @@ static void test_wifi_connect_after_connected_phase(void)
xEventGroupClearBits(wifi_events, WIFI_STA_CONNECTED | WIFI_DISCONNECT_EVENT);
ESP_LOGI(TAG, "connect after connected");
TEST_ESP_OK(esp_wifi_connect());
bits = xEventGroupWaitBits(wifi_events, WIFI_STA_CONNECTED | WIFI_DISCONNECT_EVENT, pdTRUE, pdFALSE, CONNECT_TIMEOUT_MS/portTICK_PERIOD_MS);
bits = xEventGroupWaitBits(wifi_events, WIFI_STA_CONNECTED | WIFI_DISCONNECT_EVENT, pdTRUE, pdFALSE, CONNECT_TIMEOUT_MS / portTICK_PERIOD_MS);
// shouldn't reconnect
TEST_ASSERT((bits & WIFI_AP_STA_CONNECTED) == 0);
// shouldn't disconnect
@ -344,7 +339,7 @@ static void set_wifi_softap(void)
start_wifi_as_softap();
// wait for sta connect
vTaskDelay(20000/portTICK_PERIOD_MS);
vTaskDelay(20000 / portTICK_PERIOD_MS);
stop_wifi();
}

Wyświetl plik

@ -38,7 +38,6 @@ void tearDown(void)
check_leak(before_free_32bit, after_free_32bit, "32BIT");
}
void app_main(void)
{
ESP_ERROR_CHECK(nvs_flash_init());

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -20,8 +20,8 @@ TEST_CASE("wifi set country code", "[wifi_init]")
TEST_ESP_OK(esp_wifi_init(&cfg));
wifi_country_t country;
wifi_country_t country_01 = {.cc="01", .schan=1, .nchan=11, .policy=WIFI_COUNTRY_POLICY_MANUAL};
wifi_country_t country_CN = {.cc="CN", .schan=1, .nchan=13, .policy=WIFI_COUNTRY_POLICY_MANUAL};
wifi_country_t country_01 = {.cc = "01", .schan = 1, .nchan = 11, .policy = WIFI_COUNTRY_POLICY_MANUAL};
wifi_country_t country_CN = {.cc = "CN", .schan = 1, .nchan = 13, .policy = WIFI_COUNTRY_POLICY_MANUAL};
ESP_LOGI(TAG, EMPH_STR("esp_wifi_get_country (default)"));
TEST_ESP_OK(esp_wifi_get_country(&country));
@ -34,7 +34,6 @@ TEST_CASE("wifi set country code", "[wifi_init]")
TEST_ESP_OK(esp_wifi_get_country(&country));
TEST_ASSERT(country.cc[0] == country_CN.cc[0] && country.cc[1] == country_CN.cc[1]);
ESP_LOGI(TAG, EMPH_STR("esp_wifi_deinit"));
TEST_ESP_OK(esp_wifi_deinit());
@ -55,7 +54,6 @@ TEST_CASE("wifi set country code", "[wifi_init]")
TEST_ESP_OK(esp_wifi_get_country_code(&country_code_string[0]));
TEST_ASSERT(country_code_string[0] == country_code_string_CN[0] && country_code_string[1] == country_code_string_CN[1]);
ESP_LOGI(TAG, EMPH_STR("esp_wifi_deinit"));
TEST_ESP_OK(esp_wifi_deinit());

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -15,24 +15,23 @@
#define EMPH_STR(s) "****** "s" ******"
static const char* TAG = "test_wifi_init";
static void wifi_event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data)
{
printf("wifi event handle called.\n");
switch(event_id) {
case WIFI_EVENT_AP_START:
ESP_LOGI(TAG, "WIFI_EVENT_AP_START");
break;
case WIFI_EVENT_STA_START:
ESP_LOGI(TAG, "WIFI_EVENT_STA_START");
break;
case WIFI_EVENT_STA_DISCONNECTED:
ESP_LOGI(TAG, "WIFI_EVENT_STA_DISCONNECTED");
break;
default:
break;
switch (event_id) {
case WIFI_EVENT_AP_START:
ESP_LOGI(TAG, "WIFI_EVENT_AP_START");
break;
case WIFI_EVENT_STA_START:
ESP_LOGI(TAG, "WIFI_EVENT_STA_START");
break;
case WIFI_EVENT_STA_DISCONNECTED:
ESP_LOGI(TAG, "WIFI_EVENT_STA_DISCONNECTED");
break;
default:
break;
}
return;
}
@ -46,7 +45,7 @@ static esp_err_t event_init(void)
static esp_err_t event_deinit(void)
{
ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT,ESP_EVENT_ANY_ID,&wifi_event_handler));
ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler));
ESP_ERROR_CHECK(esp_event_loop_delete_default());
return ESP_OK;
}
@ -75,9 +74,9 @@ TEST_CASE("wifi driver can start on APP CPU", "[wifi_init]")
TEST_ASSERT_NOT_NULL(sema);
printf("Creating tasks\n");
#ifndef CONFIG_FREERTOS_UNICORE
xTaskCreatePinnedToCore(wifi_driver_can_start_on_APP_CPU_task, "wifi_driver_can_start_on_APP_CPU_task", 2048*2, &sema, 3, &th, 1);
xTaskCreatePinnedToCore(wifi_driver_can_start_on_APP_CPU_task, "wifi_driver_can_start_on_APP_CPU_task", 2048 * 2, &sema, 3, &th, 1);
#else
xTaskCreate(wifi_driver_can_start_on_APP_CPU_task, "wifi_driver_can_start_on_APP_CPU_task", 2048*2, &sema, 3, &th);
xTaskCreate(wifi_driver_can_start_on_APP_CPU_task, "wifi_driver_can_start_on_APP_CPU_task", 2048 * 2, &sema, 3, &th);
#endif
TEST_ASSERT_NOT_NULL(th);
xSemaphoreTake(sema, portMAX_DELAY);

Wyświetl plik

@ -83,8 +83,9 @@ static nan_ctx_t s_nan_ctx;
void esp_wifi_nan_get_ipv6_linklocal_from_mac(ip6_addr_t *ip6, uint8_t *mac_addr)
{
if (ip6 == NULL || mac_addr == NULL)
if (ip6 == NULL || mac_addr == NULL) {
return;
}
/* Link-local prefix. */
ip6->addr[0] = htonl(0xfe800000ul);
ip6->addr[1] = 0;

Wyświetl plik

@ -42,7 +42,6 @@ typedef struct {
bool fast_pac_format_binary; /**< Set to true for binary format PAC, false for ASCII format PAC */
} esp_eap_fast_config;
/**
* @brief Enable EAP authentication(WiFi Enterprise) for the station mode.
*
@ -61,7 +60,6 @@ typedef struct {
*/
esp_err_t esp_wifi_sta_enterprise_enable(void);
/**
* @brief Disable EAP authentication(WiFi Enterprise) for the station mode.
*

Wyświetl plik

@ -40,7 +40,7 @@ typedef void (*neighbor_rep_request_cb)(void *ctx, const uint8_t *report, size_t
__attribute__((deprecated("Use 'esp_rrm_send_neighbor_report_request' instead")))
int esp_rrm_send_neighbor_rep_request(neighbor_rep_request_cb cb,
void *cb_ctx);
void *cb_ctx);
/**
* @brief Send Radio measurement neighbor report request to connected AP
* @return

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -16,16 +16,16 @@ extern "C" {
* enum btm_query_reason: Reason code for sending btm query
*/
enum btm_query_reason {
REASON_UNSPECIFIED = 0,
REASON_FRAME_LOSS = 1,
REASON_DELAY = 2,
REASON_BANDWIDTH = 3,
REASON_LOAD_BALANCE = 4,
REASON_RSSI = 5,
REASON_RETRANSMISSIONS = 6,
REASON_INTERFERENCE = 7,
REASON_GRAY_ZONE = 8,
REASON_PREMIUM_AP = 9,
REASON_UNSPECIFIED = 0,
REASON_FRAME_LOSS = 1,
REASON_DELAY = 2,
REASON_BANDWIDTH = 3,
REASON_LOAD_BALANCE = 4,
REASON_RSSI = 5,
REASON_RETRANSMISSIONS = 6,
REASON_INTERFERENCE = 7,
REASON_GRAY_ZONE = 8,
REASON_PREMIUM_AP = 9,
};
/**
@ -41,8 +41,8 @@ enum btm_query_reason {
* - -2: station not connected to AP
*/
int esp_wnm_send_bss_transition_mgmt_query(enum btm_query_reason query_reason,
const char *btm_candidates,
int cand_list);
const char *btm_candidates,
int cand_list);
/**
* @brief Check bss trasition capability of connected AP

Wyświetl plik

@ -201,8 +201,8 @@ void esp_wifi_sta_wpa2_ent_clear_ca_cert(void);
*/
__attribute__((deprecated("Use 'esp_eap_client_set_certificate_and_key' instead")))
esp_err_t esp_wifi_sta_wpa2_ent_set_cert_key(const unsigned char *client_cert, int client_cert_len,
const unsigned char *private_key, int private_key_len,
const unsigned char *private_key_passwd, int private_key_passwd_len);
const unsigned char *private_key, int private_key_len,
const unsigned char *private_key_passwd, int private_key_passwd_len);
/**
* @brief Clear client certificate and key.

Wyświetl plik

@ -181,7 +181,6 @@ esp_err_t esp_wifi_ap_wps_disable(void);
*/
esp_err_t esp_wifi_ap_wps_start(const unsigned char *pin);
/**
* @}
*/

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -33,7 +33,6 @@ struct crypto_bignum *crypto_bignum_init(void)
return (struct crypto_bignum *)bn;
}
struct crypto_bignum *crypto_bignum_init_set(const u8 *buf, size_t len)
{
int ret = 0;
@ -50,7 +49,6 @@ cleanup:
return NULL;
}
struct crypto_bignum * crypto_bignum_init_uint(unsigned int val)
{
@ -65,14 +63,12 @@ struct crypto_bignum * crypto_bignum_init_uint(unsigned int val)
return (struct crypto_bignum *)bn;
}
void crypto_bignum_deinit(struct crypto_bignum *n, int clear)
{
mbedtls_mpi_free((mbedtls_mpi *)n);
os_free((mbedtls_mpi *)n);
}
int crypto_bignum_to_bin(const struct crypto_bignum *a,
u8 *buf, size_t buflen, size_t padlen)
{
@ -102,7 +98,6 @@ cleanup:
return ret;
}
int crypto_bignum_add(const struct crypto_bignum *a,
const struct crypto_bignum *b,
struct crypto_bignum *c)
@ -111,7 +106,6 @@ int crypto_bignum_add(const struct crypto_bignum *a,
-1 : 0;
}
int crypto_bignum_mod(const struct crypto_bignum *a,
const struct crypto_bignum *b,
struct crypto_bignum *c)
@ -119,7 +113,6 @@ int crypto_bignum_mod(const struct crypto_bignum *a,
return mbedtls_mpi_mod_mpi((mbedtls_mpi *) c, (const mbedtls_mpi *) a, (const mbedtls_mpi *) b) ? -1 : 0;
}
int crypto_bignum_exptmod(const struct crypto_bignum *a,
const struct crypto_bignum *b,
const struct crypto_bignum *c,
@ -129,7 +122,6 @@ int crypto_bignum_exptmod(const struct crypto_bignum *a,
}
int crypto_bignum_inverse(const struct crypto_bignum *a,
const struct crypto_bignum *b,
struct crypto_bignum *c)
@ -138,7 +130,6 @@ int crypto_bignum_inverse(const struct crypto_bignum *a,
(const mbedtls_mpi *) b) ? -1 : 0;
}
int crypto_bignum_sub(const struct crypto_bignum *a,
const struct crypto_bignum *b,
struct crypto_bignum *c)
@ -147,7 +138,6 @@ int crypto_bignum_sub(const struct crypto_bignum *a,
-1 : 0;
}
int crypto_bignum_div(const struct crypto_bignum *a,
const struct crypto_bignum *b,
struct crypto_bignum *c)
@ -156,14 +146,13 @@ int crypto_bignum_div(const struct crypto_bignum *a,
-1 : 0;
}
int crypto_bignum_mulmod(const struct crypto_bignum *a,
const struct crypto_bignum *b,
const struct crypto_bignum *c,
struct crypto_bignum *d)
{
return mbedtls_mpi_mul_mpi((mbedtls_mpi *)d, (const mbedtls_mpi *)a, (const mbedtls_mpi *)b) ||
mbedtls_mpi_mod_mpi((mbedtls_mpi *)d, (mbedtls_mpi *)d, (const mbedtls_mpi *)c) ? -1 : 0;
mbedtls_mpi_mod_mpi((mbedtls_mpi *)d, (mbedtls_mpi *)d, (const mbedtls_mpi *)c) ? -1 : 0;
}
int crypto_bignum_sqrmod(const struct crypto_bignum *a,
@ -176,19 +165,18 @@ int crypto_bignum_sqrmod(const struct crypto_bignum *a,
return -1;
}
res = mbedtls_mpi_copy((mbedtls_mpi *) tmp,(const mbedtls_mpi *) a);
res = crypto_bignum_mulmod(a,tmp,b,c);
res = mbedtls_mpi_copy((mbedtls_mpi *) tmp, (const mbedtls_mpi *) a);
res = crypto_bignum_mulmod(a, tmp, b, c);
crypto_bignum_deinit(tmp, 0);
return res ? -1 : 0;
}
int crypto_bignum_rshift(const struct crypto_bignum *a, int n,
struct crypto_bignum *r)
{
int res;
res = mbedtls_mpi_copy((mbedtls_mpi *) r,(const mbedtls_mpi *) a);
res = mbedtls_mpi_copy((mbedtls_mpi *) r, (const mbedtls_mpi *) a);
if (res) {
return -1;
}
@ -198,26 +186,22 @@ int crypto_bignum_rshift(const struct crypto_bignum *a, int n,
}
int crypto_bignum_cmp(const struct crypto_bignum *a,
const struct crypto_bignum *b)
{
return mbedtls_mpi_cmp_mpi((const mbedtls_mpi *) a, (const mbedtls_mpi *) b);
}
int crypto_bignum_bits(const struct crypto_bignum *a)
{
return mbedtls_mpi_bitlen((const mbedtls_mpi *) a);
}
int crypto_bignum_is_zero(const struct crypto_bignum *a)
{
return (mbedtls_mpi_cmp_int((const mbedtls_mpi *) a, 0) == 0);
}
int crypto_bignum_is_one(const struct crypto_bignum *a)
{
return (mbedtls_mpi_cmp_int((const mbedtls_mpi *) a, 1) == 0);
@ -231,7 +215,7 @@ int crypto_bignum_is_odd(const struct crypto_bignum *a)
int crypto_bignum_rand(struct crypto_bignum *r, const struct crypto_bignum *m)
{
return ((mbedtls_mpi_random((mbedtls_mpi *) r, 0, (const mbedtls_mpi *) m,
crypto_rng_wrapper, NULL) != 0) ? -1 : 0);
crypto_rng_wrapper, NULL) != 0) ? -1 : 0);
}
int crypto_bignum_legendre(const struct crypto_bignum *a,
@ -251,11 +235,11 @@ int crypto_bignum_legendre(const struct crypto_bignum *a,
if (mbedtls_mpi_cmp_int(&tmp, 1) == 0) {
res = 1;
} else if (mbedtls_mpi_cmp_int(&tmp, 0) == 0
/* The below check is workaround for the case where HW
* does not behave properly for X ^ A mod M when X is
* power of M. Instead of returning value 0, value M is
* returned.*/
|| mbedtls_mpi_cmp_mpi(&tmp, (const mbedtls_mpi *)p) == 0) {
/* The below check is workaround for the case where HW
* does not behave properly for X ^ A mod M when X is
* power of M. Instead of returning value 0, value M is
* returned.*/
|| mbedtls_mpi_cmp_mpi(&tmp, (const mbedtls_mpi *)p) == 0) {
res = 0;
} else {
res = -1;
@ -268,7 +252,7 @@ cleanup:
}
int crypto_bignum_to_string(const struct crypto_bignum *a,
u8 *buf, size_t buflen, size_t padlen)
u8 *buf, size_t buflen, size_t padlen)
{
int num_bytes, offset;
size_t outlen;
@ -287,24 +271,26 @@ int crypto_bignum_to_string(const struct crypto_bignum *a,
os_memset(buf, 0, offset);
mbedtls_mpi_write_string((mbedtls_mpi *) a, 16, (char *)(buf + offset),
mbedtls_mpi_size((mbedtls_mpi *)a), &outlen);
mbedtls_mpi_size((mbedtls_mpi *)a), &outlen);
return outlen;
}
int crypto_bignum_addmod(const struct crypto_bignum *a,
const struct crypto_bignum *b,
const struct crypto_bignum *c,
struct crypto_bignum *d)
const struct crypto_bignum *b,
const struct crypto_bignum *c,
struct crypto_bignum *d)
{
struct crypto_bignum *tmp = crypto_bignum_init();
int ret = -1;
if (mbedtls_mpi_add_mpi((mbedtls_mpi *) tmp, (const mbedtls_mpi *) a, (const mbedtls_mpi *) b) < 0)
if (mbedtls_mpi_add_mpi((mbedtls_mpi *) tmp, (const mbedtls_mpi *) a, (const mbedtls_mpi *) b) < 0) {
goto fail;
}
if (mbedtls_mpi_mod_mpi( (mbedtls_mpi *) d, (const mbedtls_mpi *) tmp, (const mbedtls_mpi *) c) < 0)
if (mbedtls_mpi_mod_mpi((mbedtls_mpi *) d, (const mbedtls_mpi *) tmp, (const mbedtls_mpi *) c) < 0) {
goto fail;
}
ret = 0;
fail:

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -29,10 +29,10 @@ struct crypto_private_key;
#ifdef DEBUG_PRINT
static void crypto_dump_verify_info(u32 flags)
{
char dump_buffer[1024];
char dump_buffer[1024];
mbedtls_x509_crt_verify_info(dump_buffer, 1024, " ! ", flags );
wpa_printf(MSG_ERROR, "%s", dump_buffer);
mbedtls_x509_crt_verify_info(dump_buffer, 1024, " ! ", flags);
wpa_printf(MSG_ERROR, "%s", dump_buffer);
}
#else
static void crypto_dump_verify_info(u32 flags) { }
@ -40,365 +40,377 @@ static void crypto_dump_verify_info(u32 flags) { }
static int crypto_rng_wrapper(void *ctx, unsigned char *buf, size_t len)
{
return os_get_random(buf, len);
return os_get_random(buf, len);
}
int crypto_verify_cert(const u8 *cert_start, int certlen, const u8 *ca_cert_start, int ca_certlen)
{
int ret;
u32 flags = 0;
int ret;
u32 flags = 0;
mbedtls_x509_crt *cert = os_zalloc(sizeof(mbedtls_x509_crt));
mbedtls_x509_crt *ca_cert = os_zalloc(sizeof(mbedtls_x509_crt));
mbedtls_x509_crt *cert = os_zalloc(sizeof(mbedtls_x509_crt));
mbedtls_x509_crt *ca_cert = os_zalloc(sizeof(mbedtls_x509_crt));
if (!cert || !ca_cert) {
if (cert)
os_free(cert);
if (ca_cert)
os_free(ca_cert);
wpa_printf(MSG_ERROR, "%s: memory allocation failed", __func__);
return -1;
}
mbedtls_x509_crt_init(cert);
mbedtls_x509_crt_init(ca_cert);
ret = mbedtls_x509_crt_parse(cert, cert_start, certlen);
if (ret < 0) {
wpa_printf(MSG_ERROR, "peer cert parsing failed");
goto cleanup;
}
ret = mbedtls_x509_crt_parse(ca_cert, ca_cert_start, ca_certlen);
if (ret < 0) {
wpa_printf(MSG_ERROR, "CA cert parsing failed");
goto cleanup;
}
if (!cert || !ca_cert) {
if (cert) {
os_free(cert);
}
if (ca_cert) {
os_free(ca_cert);
}
wpa_printf(MSG_ERROR, "%s: memory allocation failed", __func__);
return -1;
}
mbedtls_x509_crt_init(cert);
mbedtls_x509_crt_init(ca_cert);
ret = mbedtls_x509_crt_parse(cert, cert_start, certlen);
if (ret < 0) {
wpa_printf(MSG_ERROR, "peer cert parsing failed");
goto cleanup;
}
ret = mbedtls_x509_crt_parse(ca_cert, ca_cert_start, ca_certlen);
if (ret < 0) {
wpa_printf(MSG_ERROR, "CA cert parsing failed");
goto cleanup;
}
ret = mbedtls_x509_crt_verify(cert, ca_cert, NULL, NULL, &flags, NULL, NULL );
ret = mbedtls_x509_crt_verify(cert, ca_cert, NULL, NULL, &flags, NULL, NULL);
/* Certification is failed, try to get some more info */
if (ret != 0)
crypto_dump_verify_info(flags);
/* Certification is failed, try to get some more info */
if (ret != 0) {
crypto_dump_verify_info(flags);
}
cleanup:
mbedtls_x509_crt_free(cert);
mbedtls_x509_crt_free(ca_cert);
mbedtls_x509_crt_free(cert);
mbedtls_x509_crt_free(ca_cert);
os_free(cert);
os_free(ca_cert);
os_free(cert);
os_free(ca_cert);
return ret;
return ret;
}
struct crypto_public_key * crypto_public_key_import(const u8 *key, size_t len)
{
int ret;
mbedtls_pk_context *pkey = os_zalloc(sizeof(*pkey));
int ret;
mbedtls_pk_context *pkey = os_zalloc(sizeof(*pkey));
if (!pkey)
return NULL;
if (!pkey) {
return NULL;
}
mbedtls_pk_init(pkey);
ret = mbedtls_pk_parse_public_key(pkey, key, len);
mbedtls_pk_init(pkey);
ret = mbedtls_pk_parse_public_key(pkey, key, len);
if (ret < 0) {
wpa_printf(MSG_ERROR, "failed to parse public key");
os_free(pkey);
return NULL;
}
if (ret < 0) {
wpa_printf(MSG_ERROR, "failed to parse public key");
os_free(pkey);
return NULL;
}
return (struct crypto_public_key *)pkey;
return (struct crypto_public_key *)pkey;
}
struct crypto_private_key * crypto_private_key_import(const u8 *key,
size_t len,
const char *passwd)
size_t len,
const char *passwd)
{
int ret;
mbedtls_pk_context *pkey = os_zalloc(sizeof(mbedtls_pk_context));
if (!pkey)
return NULL;
int ret;
mbedtls_pk_context *pkey = os_zalloc(sizeof(mbedtls_pk_context));
if (!pkey) {
return NULL;
}
mbedtls_pk_init(pkey);
mbedtls_pk_init(pkey);
ret = mbedtls_pk_parse_key(pkey, key, len, (const unsigned char *)passwd,
passwd ? os_strlen(passwd) : 0, crypto_rng_wrapper, NULL);
ret = mbedtls_pk_parse_key(pkey, key, len, (const unsigned char *)passwd,
passwd ? os_strlen(passwd) : 0, crypto_rng_wrapper, NULL);
if (ret < 0) {
wpa_printf(MSG_ERROR, "failed to parse private key");
os_free(pkey);
pkey = NULL;
}
if (ret < 0) {
wpa_printf(MSG_ERROR, "failed to parse private key");
os_free(pkey);
pkey = NULL;
}
return (struct crypto_private_key *)pkey;
return (struct crypto_private_key *)pkey;
}
struct crypto_public_key *crypto_public_key_from_cert(const u8 *buf,
size_t len)
size_t len)
{
int ret;
mbedtls_x509_crt *cert;
mbedtls_pk_context *kctx = os_zalloc(sizeof(*kctx));
int ret;
mbedtls_x509_crt *cert;
mbedtls_pk_context *kctx = os_zalloc(sizeof(*kctx));
if (!kctx) {
wpa_printf(MSG_ERROR, "failed to allocate memory");
return NULL;
}
if (!kctx) {
wpa_printf(MSG_ERROR, "failed to allocate memory");
return NULL;
}
cert = os_zalloc(sizeof(mbedtls_x509_crt));
if (!cert) {
wpa_printf(MSG_ERROR, "failed to allocate memory");
goto fail;
}
mbedtls_x509_crt_init(cert);
cert = os_zalloc(sizeof(mbedtls_x509_crt));
if (!cert) {
wpa_printf(MSG_ERROR, "failed to allocate memory");
goto fail;
}
mbedtls_x509_crt_init(cert);
ret = mbedtls_x509_crt_parse(cert, buf, len);
if (ret < 0) {
wpa_printf(MSG_ERROR, "cert parsing failed");
goto fail;
}
ret = mbedtls_x509_crt_parse(cert, buf, len);
if (ret < 0) {
wpa_printf(MSG_ERROR, "cert parsing failed");
goto fail;
}
mbedtls_pk_init(kctx);
mbedtls_pk_init(kctx);
if(mbedtls_pk_setup(kctx, mbedtls_pk_info_from_type(mbedtls_pk_get_type(&cert->pk))) != 0) {
wpa_printf(MSG_ERROR, "key setup failed");
goto fail;
}
ret = mbedtls_rsa_copy(mbedtls_pk_rsa(*kctx), mbedtls_pk_rsa(cert->pk));
if (mbedtls_pk_setup(kctx, mbedtls_pk_info_from_type(mbedtls_pk_get_type(&cert->pk))) != 0) {
wpa_printf(MSG_ERROR, "key setup failed");
goto fail;
}
ret = mbedtls_rsa_copy(mbedtls_pk_rsa(*kctx), mbedtls_pk_rsa(cert->pk));
if (ret < 0) {
wpa_printf(MSG_ERROR, "key copy failed");
goto fail;
}
if (ret < 0) {
wpa_printf(MSG_ERROR, "key copy failed");
goto fail;
}
cleanup:
mbedtls_x509_crt_free(cert);
os_free(cert);
return (struct crypto_public_key *)kctx;
mbedtls_x509_crt_free(cert);
os_free(cert);
return (struct crypto_public_key *)kctx;
fail:
os_free(kctx);
kctx = NULL;
goto cleanup;
os_free(kctx);
kctx = NULL;
goto cleanup;
}
int crypto_public_key_encrypt_pkcs1_v15(struct crypto_public_key *key,
const u8 *in, size_t inlen,
u8 *out, size_t *outlen)
const u8 *in, size_t inlen,
u8 *out, size_t *outlen)
{
int ret;
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
const char *pers = "rsa_encrypt";
mbedtls_entropy_context *entropy = os_zalloc(sizeof(*entropy));
mbedtls_ctr_drbg_context *ctr_drbg = os_zalloc(sizeof(*ctr_drbg));
int ret;
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
const char *pers = "rsa_encrypt";
mbedtls_entropy_context *entropy = os_zalloc(sizeof(*entropy));
mbedtls_ctr_drbg_context *ctr_drbg = os_zalloc(sizeof(*ctr_drbg));
if (!pkey || !entropy || !ctr_drbg) {
if (entropy)
os_free(entropy);
if (ctr_drbg)
os_free(ctr_drbg);
wpa_printf(MSG_ERROR, "failed to allocate memory");
return -1;
}
if (!pkey || !entropy || !ctr_drbg) {
if (entropy) {
os_free(entropy);
}
if (ctr_drbg) {
os_free(ctr_drbg);
}
wpa_printf(MSG_ERROR, "failed to allocate memory");
return -1;
}
mbedtls_entropy_init( entropy );
mbedtls_ctr_drbg_init( ctr_drbg );
mbedtls_entropy_init(entropy);
mbedtls_ctr_drbg_init(ctr_drbg);
ret = mbedtls_ctr_drbg_seed( ctr_drbg, mbedtls_entropy_func,
entropy, (const unsigned char *) pers,
strlen( pers ) );
if( ret != 0 ) {
wpa_printf(MSG_ERROR, " failed ! mbedtls_ctr_drbg_seed returned %d",
ret );
goto cleanup;
}
ret = mbedtls_ctr_drbg_seed(ctr_drbg, mbedtls_entropy_func,
entropy, (const unsigned char *) pers,
strlen(pers));
if (ret != 0) {
wpa_printf(MSG_ERROR, " failed ! mbedtls_ctr_drbg_seed returned %d",
ret);
goto cleanup;
}
ret = mbedtls_rsa_pkcs1_encrypt(mbedtls_pk_rsa(*pkey), mbedtls_ctr_drbg_random,
ctr_drbg, inlen, in, out);
ret = mbedtls_rsa_pkcs1_encrypt(mbedtls_pk_rsa(*pkey), mbedtls_ctr_drbg_random,
ctr_drbg, inlen, in, out);
if(ret != 0) {
wpa_printf(MSG_ERROR, " failed ! mbedtls_rsa_pkcs1_encrypt returned -0x%04x", -ret);
goto cleanup;
}
*outlen = mbedtls_rsa_get_len(mbedtls_pk_rsa(*pkey));
if (ret != 0) {
wpa_printf(MSG_ERROR, " failed ! mbedtls_rsa_pkcs1_encrypt returned -0x%04x", -ret);
goto cleanup;
}
*outlen = mbedtls_rsa_get_len(mbedtls_pk_rsa(*pkey));
cleanup:
mbedtls_ctr_drbg_free( ctr_drbg );
mbedtls_entropy_free( entropy );
os_free(entropy);
os_free(ctr_drbg);
mbedtls_ctr_drbg_free(ctr_drbg);
mbedtls_entropy_free(entropy);
os_free(entropy);
os_free(ctr_drbg);
return ret;
return ret;
}
int crypto_private_key_decrypt_pkcs1_v15(struct crypto_private_key *key,
const u8 *in, size_t inlen,
u8 *out, size_t *outlen)
const u8 *in, size_t inlen,
u8 *out, size_t *outlen)
{
int ret;
size_t i;
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
const char *pers = "rsa_decrypt";
mbedtls_entropy_context *entropy = os_malloc(sizeof(*entropy));
mbedtls_ctr_drbg_context *ctr_drbg = os_malloc(sizeof(*ctr_drbg));
int ret;
size_t i;
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
const char *pers = "rsa_decrypt";
mbedtls_entropy_context *entropy = os_malloc(sizeof(*entropy));
mbedtls_ctr_drbg_context *ctr_drbg = os_malloc(sizeof(*ctr_drbg));
if (!pkey || !entropy || !ctr_drbg) {
if (entropy)
os_free(entropy);
if (ctr_drbg)
os_free(ctr_drbg);
return -1;
}
mbedtls_ctr_drbg_init( ctr_drbg );
mbedtls_entropy_init( entropy );
ret = mbedtls_ctr_drbg_seed(ctr_drbg, mbedtls_entropy_func,
entropy, (const unsigned char *) pers,
strlen(pers));
if (!pkey || !entropy || !ctr_drbg) {
if (entropy) {
os_free(entropy);
}
if (ctr_drbg) {
os_free(ctr_drbg);
}
return -1;
}
mbedtls_ctr_drbg_init(ctr_drbg);
mbedtls_entropy_init(entropy);
ret = mbedtls_ctr_drbg_seed(ctr_drbg, mbedtls_entropy_func,
entropy, (const unsigned char *) pers,
strlen(pers));
if (ret < 0)
goto cleanup;
if (ret < 0) {
goto cleanup;
}
i = mbedtls_rsa_get_len(mbedtls_pk_rsa(*pkey));
ret = mbedtls_rsa_rsaes_pkcs1_v15_decrypt(mbedtls_pk_rsa(*pkey), mbedtls_ctr_drbg_random,
ctr_drbg, &i, in, out, *outlen);
i = mbedtls_rsa_get_len(mbedtls_pk_rsa(*pkey));
ret = mbedtls_rsa_rsaes_pkcs1_v15_decrypt(mbedtls_pk_rsa(*pkey), mbedtls_ctr_drbg_random,
ctr_drbg, &i, in, out, *outlen);
*outlen = i;
*outlen = i;
cleanup:
mbedtls_ctr_drbg_free( ctr_drbg );
mbedtls_entropy_free( entropy );
os_free(entropy);
os_free(ctr_drbg);
mbedtls_ctr_drbg_free(ctr_drbg);
mbedtls_entropy_free(entropy);
os_free(entropy);
os_free(ctr_drbg);
return ret;
return ret;
}
int crypto_private_key_sign_pkcs1(struct crypto_private_key *key,
const u8 *in, size_t inlen,
u8 *out, size_t *outlen)
const u8 *in, size_t inlen,
u8 *out, size_t *outlen)
{
int ret;
const char *pers = "rsa_encrypt";
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
mbedtls_entropy_context *entropy = os_malloc(sizeof(*entropy));
mbedtls_ctr_drbg_context *ctr_drbg = os_malloc(sizeof(*ctr_drbg));
int ret;
const char *pers = "rsa_encrypt";
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
mbedtls_entropy_context *entropy = os_malloc(sizeof(*entropy));
mbedtls_ctr_drbg_context *ctr_drbg = os_malloc(sizeof(*ctr_drbg));
if (!pkey || !entropy || !ctr_drbg) {
if (entropy)
os_free(entropy);
if (ctr_drbg)
os_free(ctr_drbg);
return -1;
}
mbedtls_ctr_drbg_init( ctr_drbg );
mbedtls_entropy_init( entropy );
ret = mbedtls_ctr_drbg_seed(ctr_drbg, mbedtls_entropy_func,
entropy, (const unsigned char *) pers,
strlen(pers));
if (!pkey || !entropy || !ctr_drbg) {
if (entropy) {
os_free(entropy);
}
if (ctr_drbg) {
os_free(ctr_drbg);
}
return -1;
}
mbedtls_ctr_drbg_init(ctr_drbg);
mbedtls_entropy_init(entropy);
ret = mbedtls_ctr_drbg_seed(ctr_drbg, mbedtls_entropy_func,
entropy, (const unsigned char *) pers,
strlen(pers));
if((ret = mbedtls_rsa_pkcs1_sign(mbedtls_pk_rsa(*pkey), mbedtls_ctr_drbg_random, ctr_drbg,
(mbedtls_pk_rsa(*pkey))->MBEDTLS_PRIVATE(hash_id),
inlen, in, out)) != 0 ) {
wpa_printf(MSG_ERROR, " failed ! mbedtls_rsa_pkcs1_sign returned %d", ret );
goto cleanup;
}
*outlen = mbedtls_rsa_get_len(mbedtls_pk_rsa(*pkey));
if ((ret = mbedtls_rsa_pkcs1_sign(mbedtls_pk_rsa(*pkey), mbedtls_ctr_drbg_random, ctr_drbg,
(mbedtls_pk_rsa(*pkey))->MBEDTLS_PRIVATE(hash_id),
inlen, in, out)) != 0) {
wpa_printf(MSG_ERROR, " failed ! mbedtls_rsa_pkcs1_sign returned %d", ret);
goto cleanup;
}
*outlen = mbedtls_rsa_get_len(mbedtls_pk_rsa(*pkey));
cleanup:
mbedtls_ctr_drbg_free( ctr_drbg );
mbedtls_entropy_free( entropy );
os_free(entropy);
os_free(ctr_drbg);
return ret;
mbedtls_ctr_drbg_free(ctr_drbg);
mbedtls_entropy_free(entropy);
os_free(entropy);
os_free(ctr_drbg);
return ret;
}
void crypto_public_key_free(struct crypto_public_key *key)
{
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
if (!pkey)
return;
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
if (!pkey) {
return;
}
mbedtls_pk_free(pkey);
os_free(pkey);
mbedtls_pk_free(pkey);
os_free(pkey);
}
void crypto_private_key_free(struct crypto_private_key *key)
{
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
if (!pkey)
return;
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
if (!pkey) {
return;
}
mbedtls_pk_free(pkey);
os_free(pkey);
mbedtls_pk_free(pkey);
os_free(pkey);
}
int crypto_public_key_decrypt_pkcs1(struct crypto_public_key *key,
const u8 *crypt, size_t crypt_len,
u8 *plain, size_t *plain_len)
const u8 *crypt, size_t crypt_len,
u8 *plain, size_t *plain_len)
{
size_t len;
u8 *pos;
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
len = mbedtls_pk_rsa(*pkey)->MBEDTLS_PRIVATE(len);
if (len != crypt_len) {
return -1;
}
size_t len;
u8 *pos;
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
len = mbedtls_pk_rsa(*pkey)->MBEDTLS_PRIVATE(len);
if (len != crypt_len) {
return -1;
}
if (mbedtls_rsa_public(mbedtls_pk_rsa(*pkey), crypt, plain) < 0)
return -1;
if (mbedtls_rsa_public(mbedtls_pk_rsa(*pkey), crypt, plain) < 0) {
return -1;
}
/*
* PKCS #1 v1.5, 8.1:
*
* EB = 00 || BT || PS || 00 || D
* BT = 00 or 01
* PS = k-3-||D|| times (00 if BT=00) or (FF if BT=01)
* k = length of modulus in octets
*
* Based on 10.1.3, "The block type shall be 01" for a signature.
*/
/*
* PKCS #1 v1.5, 8.1:
*
* EB = 00 || BT || PS || 00 || D
* BT = 00 or 01
* PS = k-3-||D|| times (00 if BT=00) or (FF if BT=01)
* k = length of modulus in octets
*
* Based on 10.1.3, "The block type shall be 01" for a signature.
*/
if (len < 3 + 8 + 16 /* min hash len */ ||
plain[0] != 0x00 || plain[1] != 0x01) {
wpa_printf(MSG_INFO, "LibTomCrypt: Invalid signature EB "
"structure");
wpa_hexdump_key(MSG_DEBUG, "Signature EB", plain, len);
return -1;
}
if (len < 3 + 8 + 16 /* min hash len */ ||
plain[0] != 0x00 || plain[1] != 0x01) {
wpa_printf(MSG_INFO, "LibTomCrypt: Invalid signature EB "
"structure");
wpa_hexdump_key(MSG_DEBUG, "Signature EB", plain, len);
return -1;
}
pos = plain + 3;
/* BT = 01 */
if (plain[2] != 0xff) {
wpa_printf(MSG_INFO, "LibTomCrypt: Invalid signature "
"PS (BT=01)");
wpa_hexdump_key(MSG_DEBUG, "Signature EB", plain, len);
return -1;
}
while (pos < plain + len && *pos == 0xff)
pos++;
pos = plain + 3;
/* BT = 01 */
if (plain[2] != 0xff) {
wpa_printf(MSG_INFO, "LibTomCrypt: Invalid signature "
"PS (BT=01)");
wpa_hexdump_key(MSG_DEBUG, "Signature EB", plain, len);
return -1;
}
while (pos < plain + len && *pos == 0xff) {
pos++;
}
if (pos - plain - 2 < 8) {
/* PKCS #1 v1.5, 8.1: At least eight octets long PS */
wpa_printf(MSG_INFO, "LibTomCrypt: Too short signature "
"padding");
wpa_hexdump_key(MSG_DEBUG, "Signature EB", plain, len);
return -1;
}
if (pos - plain - 2 < 8) {
/* PKCS #1 v1.5, 8.1: At least eight octets long PS */
wpa_printf(MSG_INFO, "LibTomCrypt: Too short signature "
"padding");
wpa_hexdump_key(MSG_DEBUG, "Signature EB", plain, len);
return -1;
}
if (pos + 16 /* min hash len */ >= plain + len || *pos != 0x00) {
wpa_printf(MSG_INFO, "LibTomCrypt: Invalid signature EB "
"structure (2)");
wpa_hexdump_key(MSG_DEBUG, "Signature EB", plain, len);
return -1;
}
pos++;
len -= pos - plain;
if (pos + 16 /* min hash len */ >= plain + len || *pos != 0x00) {
wpa_printf(MSG_INFO, "LibTomCrypt: Invalid signature EB "
"structure (2)");
wpa_hexdump_key(MSG_DEBUG, "Signature EB", plain, len);
return -1;
}
pos++;
len -= pos - plain;
/* Strip PKCS #1 header */
os_memmove(plain, pos, len);
*plain_len = len;
/* Strip PKCS #1 header */
os_memmove(plain, pos, len);
*plain_len = len;
return 0;
return 0;
}
#endif

Wyświetl plik

@ -44,12 +44,12 @@
static inline void write32_be(uint32_t n, uint8_t out[4])
{
#if defined(__GNUC__) && __GNUC__ >= 4 && __BYTE_ORDER == __LITTLE_ENDIAN
*(uint32_t *)(out) = __builtin_bswap32(n);
*(uint32_t *)(out) = __builtin_bswap32(n);
#else
out[0] = (n >> 24) & 0xff;
out[1] = (n >> 16) & 0xff;
out[2] = (n >> 8) & 0xff;
out[3] = n & 0xff;
out[0] = (n >> 24) & 0xff;
out[1] = (n >> 16) & 0xff;
out[2] = (n >> 8) & 0xff;
out[3] = n & 0xff;
#endif
}
@ -59,10 +59,10 @@ static inline void write32_be(uint32_t n, uint8_t out[4])
* Message length is expressed in 32 bits (so suitable for sha1, sha256, sha512). */
static inline void md_pad(uint8_t *block, size_t blocksz, size_t used, size_t msg)
{
memset(block + used, 0, blocksz - used - 4);
block[used] = 0x80;
block += blocksz - 4;
write32_be((uint32_t) (msg * 8), block);
memset(block + used, 0, blocksz - used - 4);
block[used] = 0x80;
block += blocksz - 4;
write32_be((uint32_t)(msg * 8), block);
}
/* Internal function/type names for hash-specific things. */
@ -237,76 +237,76 @@ static inline void sha1_extract(mbedtls_sha1_context *restrict ctx, uint8_t *res
{
#if defined(MBEDTLS_SHA1_ALT)
#if CONFIG_IDF_TARGET_ESP32
/* ESP32 stores internal SHA state in BE format similar to software */
write32_be(ctx->state[0], out);
write32_be(ctx->state[1], out + 4);
write32_be(ctx->state[2], out + 8);
write32_be(ctx->state[3], out + 12);
write32_be(ctx->state[4], out + 16);
/* ESP32 stores internal SHA state in BE format similar to software */
write32_be(ctx->state[0], out);
write32_be(ctx->state[1], out + 4);
write32_be(ctx->state[2], out + 8);
write32_be(ctx->state[3], out + 12);
write32_be(ctx->state[4], out + 16);
#else
*(uint32_t *)(out) = ctx->state[0];
*(uint32_t *)(out + 4) = ctx->state[1];
*(uint32_t *)(out + 8) = ctx->state[2];
*(uint32_t *)(out + 12) = ctx->state[3];
*(uint32_t *)(out + 16) = ctx->state[4];
*(uint32_t *)(out) = ctx->state[0];
*(uint32_t *)(out + 4) = ctx->state[1];
*(uint32_t *)(out + 8) = ctx->state[2];
*(uint32_t *)(out + 12) = ctx->state[3];
*(uint32_t *)(out + 16) = ctx->state[4];
#endif
#else
write32_be(ctx->MBEDTLS_PRIVATE(state)[0], out);
write32_be(ctx->MBEDTLS_PRIVATE(state)[1], out + 4);
write32_be(ctx->MBEDTLS_PRIVATE(state)[2], out + 8);
write32_be(ctx->MBEDTLS_PRIVATE(state)[3], out + 12);
write32_be(ctx->MBEDTLS_PRIVATE(state)[4], out + 16);
write32_be(ctx->MBEDTLS_PRIVATE(state)[0], out);
write32_be(ctx->MBEDTLS_PRIVATE(state)[1], out + 4);
write32_be(ctx->MBEDTLS_PRIVATE(state)[2], out + 8);
write32_be(ctx->MBEDTLS_PRIVATE(state)[3], out + 12);
write32_be(ctx->MBEDTLS_PRIVATE(state)[4], out + 16);
#endif
}
static inline void sha1_cpy(mbedtls_sha1_context *restrict out, const mbedtls_sha1_context *restrict in)
{
#if defined(MBEDTLS_SHA1_ALT)
out->state[0] = in->state[0];
out->state[1] = in->state[1];
out->state[2] = in->state[2];
out->state[3] = in->state[3];
out->state[4] = in->state[4];
out->state[0] = in->state[0];
out->state[1] = in->state[1];
out->state[2] = in->state[2];
out->state[3] = in->state[3];
out->state[4] = in->state[4];
#else
out->MBEDTLS_PRIVATE(state)[0] = in->MBEDTLS_PRIVATE(state)[0];
out->MBEDTLS_PRIVATE(state)[1] = in->MBEDTLS_PRIVATE(state)[1];
out->MBEDTLS_PRIVATE(state)[2] = in->MBEDTLS_PRIVATE(state)[2];
out->MBEDTLS_PRIVATE(state)[3] = in->MBEDTLS_PRIVATE(state)[3];
out->MBEDTLS_PRIVATE(state)[4] = in->MBEDTLS_PRIVATE(state)[4];
out->MBEDTLS_PRIVATE(state)[0] = in->MBEDTLS_PRIVATE(state)[0];
out->MBEDTLS_PRIVATE(state)[1] = in->MBEDTLS_PRIVATE(state)[1];
out->MBEDTLS_PRIVATE(state)[2] = in->MBEDTLS_PRIVATE(state)[2];
out->MBEDTLS_PRIVATE(state)[3] = in->MBEDTLS_PRIVATE(state)[3];
out->MBEDTLS_PRIVATE(state)[4] = in->MBEDTLS_PRIVATE(state)[4];
#endif
}
static inline void sha1_xor(mbedtls_sha1_context *restrict out, const mbedtls_sha1_context *restrict in)
{
#if defined(MBEDTLS_SHA1_ALT)
out->state[0] ^= in->state[0];
out->state[1] ^= in->state[1];
out->state[2] ^= in->state[2];
out->state[3] ^= in->state[3];
out->state[4] ^= in->state[4];
out->state[0] ^= in->state[0];
out->state[1] ^= in->state[1];
out->state[2] ^= in->state[2];
out->state[3] ^= in->state[3];
out->state[4] ^= in->state[4];
#else
out->MBEDTLS_PRIVATE(state)[0] ^= in->MBEDTLS_PRIVATE(state)[0];
out->MBEDTLS_PRIVATE(state)[1] ^= in->MBEDTLS_PRIVATE(state)[1];
out->MBEDTLS_PRIVATE(state)[2] ^= in->MBEDTLS_PRIVATE(state)[2];
out->MBEDTLS_PRIVATE(state)[3] ^= in->MBEDTLS_PRIVATE(state)[3];
out->MBEDTLS_PRIVATE(state)[4] ^= in->MBEDTLS_PRIVATE(state)[4];
out->MBEDTLS_PRIVATE(state)[0] ^= in->MBEDTLS_PRIVATE(state)[0];
out->MBEDTLS_PRIVATE(state)[1] ^= in->MBEDTLS_PRIVATE(state)[1];
out->MBEDTLS_PRIVATE(state)[2] ^= in->MBEDTLS_PRIVATE(state)[2];
out->MBEDTLS_PRIVATE(state)[3] ^= in->MBEDTLS_PRIVATE(state)[3];
out->MBEDTLS_PRIVATE(state)[4] ^= in->MBEDTLS_PRIVATE(state)[4];
#endif
}
static int mbedtls_sha1_init_start(mbedtls_sha1_context *ctx)
{
mbedtls_sha1_init(ctx);
mbedtls_sha1_starts(ctx);
mbedtls_sha1_init(ctx);
mbedtls_sha1_starts(ctx);
#if defined(CONFIG_IDF_TARGET_ESP32) && defined(MBEDTLS_SHA1_ALT)
/* Use software mode for esp32 since hardware can't give output more than 20 */
esp_mbedtls_set_sha1_mode(ctx, ESP_MBEDTLS_SHA1_SOFTWARE);
/* Use software mode for esp32 since hardware can't give output more than 20 */
esp_mbedtls_set_sha1_mode(ctx, ESP_MBEDTLS_SHA1_SOFTWARE);
#endif
return 0;
return 0;
}
#ifndef MBEDTLS_SHA1_ALT
static int sha1_finish(mbedtls_sha1_context *ctx,
unsigned char output[20])
unsigned char output[20])
{
int ret = -1;
uint32_t used;
@ -384,5 +384,5 @@ void fastpbkdf2_hmac_sha1(const uint8_t *pw, size_t npw,
uint32_t iterations,
uint8_t *out, size_t nout)
{
PBKDF2(sha1)(pw, npw, salt, nsalt, iterations, out, nout);
PBKDF2(sha1)(pw, npw, salt, nsalt, iterations, out, nout);
}

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -14,11 +14,11 @@ extern struct wpa_supplicant g_wpa_supp;
#ifdef CONFIG_IEEE80211KV
struct ieee_mgmt_frame {
u8 sender[ETH_ALEN];
u8 channel;
int8_t rssi;
size_t len;
u8 payload[0];
u8 sender[ETH_ALEN];
u8 channel;
int8_t rssi;
size_t len;
u8 payload[0];
};
int esp_supplicant_post_evt(uint32_t evt_id, uint32_t data);
@ -29,10 +29,10 @@ typedef struct {
} supplicant_event_t;
enum SIG_SUPPLICANT {
SIG_SUPPLICANT_RX_ACTION,
SIG_SUPPLICANT_SCAN_DONE,
SIG_SUPPLICANT_DEL_TASK,
SIG_SUPPLICANT_MAX,
SIG_SUPPLICANT_RX_ACTION,
SIG_SUPPLICANT_SCAN_DONE,
SIG_SUPPLICANT_DEL_TASK,
SIG_SUPPLICANT_MAX,
};
void esp_get_tx_power(uint8_t *tx_power);

Wyświetl plik

@ -64,14 +64,14 @@ esp_err_t esp_dpp_post_evt(uint32_t evt_id, uint32_t data)
if (evt_id != SIG_DPP_DEL_TASK) {
DPP_API_UNLOCK();
}
wpa_printf(MSG_DEBUG,"DPP: Sent event %d to DPP task", evt_id);
wpa_printf(MSG_DEBUG, "DPP: Sent event %d to DPP task", evt_id);
return ret;
end:
if (evt) {
os_free(evt);
}
wpa_printf(MSG_ERROR,"DPP: Failed to send event %d to DPP task", evt_id);
wpa_printf(MSG_ERROR, "DPP: Failed to send event %d to DPP task", evt_id);
return ret;
}
@ -79,15 +79,15 @@ static uint8_t esp_dpp_deinit_auth(void)
{
esp_err_t ret = esp_dpp_post_evt(SIG_DPP_DEINIT_AUTH, 0);
if (ESP_OK != ret) {
wpa_printf(MSG_ERROR, "Failed to post DPP auth deinit to DPP Task(status=%d)", ret);
return ret;
}
return ESP_OK;
wpa_printf(MSG_ERROR, "Failed to post DPP auth deinit to DPP Task(status=%d)", ret);
return ret;
}
return ESP_OK;
}
static void esp_dpp_call_cb(esp_supp_dpp_event_t evt, void *data)
{
if ( evt == ESP_SUPP_DPP_FAIL && s_dpp_ctx.dpp_auth) {
if (evt == ESP_SUPP_DPP_FAIL && s_dpp_ctx.dpp_auth) {
esp_dpp_deinit_auth();
}
s_dpp_ctx.dpp_event_cb(evt, data);
@ -95,16 +95,17 @@ static void esp_dpp_call_cb(esp_supp_dpp_event_t evt, void *data)
static void esp_dpp_auth_conf_wait_timeout(void *eloop_ctx, void *timeout_ctx)
{
if (!s_dpp_ctx.dpp_auth || !s_dpp_ctx.dpp_auth->waiting_auth_conf)
if (!s_dpp_ctx.dpp_auth || !s_dpp_ctx.dpp_auth->waiting_auth_conf) {
return;
}
wpa_printf(MSG_DEBUG,
"DPP: Terminate authentication exchange due to Auth Confirm timeout");
"DPP: Terminate authentication exchange due to Auth Confirm timeout");
esp_dpp_call_cb(ESP_SUPP_DPP_FAIL, (void *)ESP_ERR_DPP_AUTH_TIMEOUT);
}
esp_err_t esp_dpp_send_action_frame(uint8_t *dest_mac, const uint8_t *buf, uint32_t len,
uint8_t channel, uint32_t wait_time_ms)
uint8_t channel, uint32_t wait_time_ms)
{
wifi_action_tx_req_t *req = os_zalloc(sizeof(*req) + len);;
if (!req) {
@ -179,10 +180,10 @@ static void esp_dpp_rx_auth_req(struct action_rx_param *rx_param, uint8_t *dpp_d
os_memcpy(s_dpp_ctx.dpp_auth->peer_mac_addr, rx_param->sa, ETH_ALEN);
esp_dpp_send_action_frame(rx_param->sa, wpabuf_head(s_dpp_ctx.dpp_auth->resp_msg),
wpabuf_len(s_dpp_ctx.dpp_auth->resp_msg),
rx_param->channel, OFFCHAN_TX_WAIT_TIME);
eloop_cancel_timeout(esp_dpp_auth_conf_wait_timeout, NULL,NULL);
eloop_register_timeout(ESP_DPP_AUTH_TIMEOUT_SECS, 0, esp_dpp_auth_conf_wait_timeout,NULL, NULL);
wpabuf_len(s_dpp_ctx.dpp_auth->resp_msg),
rx_param->channel, OFFCHAN_TX_WAIT_TIME);
eloop_cancel_timeout(esp_dpp_auth_conf_wait_timeout, NULL, NULL);
eloop_register_timeout(ESP_DPP_AUTH_TIMEOUT_SECS, 0, esp_dpp_auth_conf_wait_timeout, NULL, NULL);
return;
fail:
@ -206,7 +207,7 @@ static void gas_query_req_tx(struct dpp_authentication *auth)
MAC2STR(auth->peer_mac_addr), auth->curr_chan);
esp_dpp_send_action_frame(auth->peer_mac_addr, wpabuf_head(buf), wpabuf_len(buf),
auth->curr_chan, OFFCHAN_TX_WAIT_TIME);
auth->curr_chan, OFFCHAN_TX_WAIT_TIME);
}
static int esp_dpp_handle_config_obj(struct dpp_authentication *auth,
@ -355,16 +356,17 @@ static esp_err_t esp_dpp_rx_peer_disc_resp(struct action_rx_param *rx_param)
}
res = dpp_peer_intro(&intro, auth->conf_obj[i].connector,
wpabuf_head(auth->net_access_key),
wpabuf_len(auth->net_access_key),
wpabuf_head(auth->conf_obj[i].c_sign_key),
wpabuf_len(auth->conf_obj[i].c_sign_key),
connector, connector_len, &expiry);
wpabuf_head(auth->net_access_key),
wpabuf_len(auth->net_access_key),
wpabuf_head(auth->conf_obj[i].c_sign_key),
wpabuf_len(auth->conf_obj[i].c_sign_key),
connector, connector_len, &expiry);
if (res == DPP_STATUS_OK) {
entry = os_zalloc(sizeof(*entry));
if (!entry)
entry = os_zalloc(sizeof(*entry));
if (!entry) {
goto fail;
}
os_memcpy(entry->aa, rx_param->sa, ETH_ALEN);
os_memcpy(entry->pmkid, intro.pmkid, PMKID_LEN);
os_memcpy(entry->pmk, intro.pmk, intro.pmk_len);
@ -385,8 +387,8 @@ static esp_err_t esp_dpp_rx_peer_disc_resp(struct action_rx_param *rx_param)
pmksa_cache_add_entry(sm->pmksa, entry);
wpa_printf(MSG_INFO, "peer=" MACSTR " status=%u", MAC2STR(rx_param->sa), status[0]);
break;
}
break;
}
}
if (res != DPP_STATUS_OK) {
@ -395,13 +397,13 @@ static esp_err_t esp_dpp_rx_peer_disc_resp(struct action_rx_param *rx_param)
}
wpa_printf(MSG_DEBUG,
"DPP: Try connection after successful network introduction");
"DPP: Try connection after successful network introduction");
dpp_connect(rx_param->sa, true);
return ESP_OK;
fail:
os_memset(&intro, 0, sizeof(intro));
if (entry != NULL) {
os_free(entry);
os_free(entry);
}
return ESP_FAIL;
}
@ -469,8 +471,9 @@ static esp_err_t esp_dpp_rx_action(struct action_rx_param *rx_param)
int ret = ESP_OK;
if (!rx_param)
if (!rx_param) {
return ESP_ERR_INVALID_ARG;
}
if (rx_param->action_frm->category == WLAN_ACTION_PUBLIC) {
struct ieee80211_public_action *public_action =
@ -511,7 +514,7 @@ static esp_err_t esp_dpp_rx_action(struct action_rx_param *rx_param)
return ret;
}
static void esp_dpp_task(void *pvParameters )
static void esp_dpp_task(void *pvParameters)
{
dpp_event_t *evt;
bool task_del = false;
@ -572,7 +575,7 @@ static void esp_dpp_task(void *pvParameters )
}
channel = p->chan_list[counter++ % p->num_chan];
ret = esp_wifi_remain_on_channel(WIFI_IF_STA, WIFI_ROC_REQ, channel,
BOOTSTRAP_ROC_WAIT_TIME, s_action_rx_cb);
BOOTSTRAP_ROC_WAIT_TIME, s_action_rx_cb);
if (ret != ESP_OK) {
wpa_printf(MSG_ERROR, "Failed ROC. error : 0x%x", ret);
break;
@ -773,10 +776,10 @@ esp_supp_dpp_bootstrap_gen(const char *chan_list, enum dpp_bootstrap_type type,
}
os_snprintf(command, 1200, "type=qrcode mac=" MACSTR "%s%s%s%s%s",
MAC2STR(params->mac), uri_chan_list,
key ? "key=" : "", key ? key : "",
params->info_len ? " info=" : "",
params->info_len ? params->info : "");
MAC2STR(params->mac), uri_chan_list,
key ? "key=" : "", key ? key : "",
params->info_len ? " info=" : "",
params->info_len ? params->info : "");
ret = esp_dpp_post_evt(SIG_DPP_BOOTSTRAP_GEN, (u32)command);
if (ret != ESP_OK) {
@ -910,17 +913,17 @@ esp_err_t esp_dpp_start_net_intro_protocol(uint8_t *bssid)
struct dpp_authentication *auth = s_dpp_ctx.dpp_auth;
struct wpabuf *buf;
for (int i = 0; i < auth->num_conf_obj; i++) {
os_memcpy(auth->peer_mac_addr, bssid, ETH_ALEN);
buf = dpp_build_peer_disc_req(auth, &auth->conf_obj[i]);
os_memcpy(auth->peer_mac_addr, bssid, ETH_ALEN);
buf = dpp_build_peer_disc_req(auth, &auth->conf_obj[i]);
if (buf) {
if (buf) {
if (esp_dpp_send_action_frame(bssid, wpabuf_head(buf), wpabuf_len(buf), auth->curr_chan, OFFCHAN_TX_WAIT_TIME) != ESP_OK) {
wpabuf_free(buf);
return ESP_FAIL;
}
} else {
return ESP_ERR_NO_MEM;
}
}
} else {
return ESP_ERR_NO_MEM;
}
}
return ESP_OK;
}
@ -929,9 +932,9 @@ esp_err_t esp_supp_dpp_deinit(void)
{
esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_ACTION_TX_STATUS,
&offchan_event_handler);
&offchan_event_handler);
esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_ROC_DONE,
&offchan_event_handler);
&offchan_event_handler);
if (s_dpp_ctx.dpp_global) {
if (esp_dpp_post_evt(SIG_DPP_DEL_TASK, 0)) {
wpa_printf(MSG_ERROR, "DPP Deinit Failed");

Wyświetl plik

@ -165,7 +165,7 @@ static void wpa2_rxq_init(void)
static void wpa2_rxq_enqueue(struct wpa2_rx_param *param)
{
DATA_MUTEX_TAKE();
STAILQ_INSERT_TAIL(&s_wpa2_rxq,param, bqentry);
STAILQ_INSERT_TAIL(&s_wpa2_rxq, param, bqentry);
DATA_MUTEX_GIVE();
}
@ -175,7 +175,7 @@ static struct wpa2_rx_param * wpa2_rxq_dequeue(void)
DATA_MUTEX_TAKE();
if ((param = STAILQ_FIRST(&s_wpa2_rxq)) != NULL) {
STAILQ_REMOVE_HEAD(&s_wpa2_rxq, bqentry);
STAILQ_NEXT(param,bqentry) = NULL;
STAILQ_NEXT(param, bqentry) = NULL;
}
DATA_MUTEX_GIVE();
return param;
@ -187,14 +187,14 @@ static void wpa2_rxq_deinit(void)
DATA_MUTEX_TAKE();
while ((param = STAILQ_FIRST(&s_wpa2_rxq)) != NULL) {
STAILQ_REMOVE_HEAD(&s_wpa2_rxq, bqentry);
STAILQ_NEXT(param,bqentry) = NULL;
STAILQ_NEXT(param, bqentry) = NULL;
os_free(param->buf);
os_free(param);
}
DATA_MUTEX_GIVE();
}
void wpa2_task(void *pvParameters )
void wpa2_task(void *pvParameters)
{
ETSEvent *e;
struct eap_sm *sm = gEapSm;
@ -205,10 +205,10 @@ void wpa2_task(void *pvParameters )
}
for (;;) {
if ( TRUE == os_queue_recv(s_wpa2_queue, &e, OS_BLOCK) ) {
if (TRUE == os_queue_recv(s_wpa2_queue, &e, OS_BLOCK)) {
if (e->sig < SIG_WPA2_MAX) {
DATA_MUTEX_TAKE();
if(sm->wpa2_sig_cnt[e->sig]) {
if (sm->wpa2_sig_cnt[e->sig]) {
sm->wpa2_sig_cnt[e->sig]--;
} else {
wpa_printf(MSG_ERROR, "wpa2_task: invalid sig cnt, sig=%" PRId32 " cnt=%d", e->sig, sm->wpa2_sig_cnt[e->sig]);
@ -225,7 +225,7 @@ void wpa2_task(void *pvParameters )
case SIG_WPA2_RX: {
struct wpa2_rx_param *param = NULL;
while ((param = wpa2_rxq_dequeue()) != NULL){
while ((param = wpa2_rxq_dequeue()) != NULL) {
eap_sm_rx_eapol_internal(param->sa, param->buf, param->len, param->bssid);
os_free(param->buf);
os_free(param);
@ -320,8 +320,8 @@ int eap_sm_send_eapol(struct eap_sm *sm, struct wpabuf *resp)
}
outbuf = wpa_alloc_eapol(sm, IEEE802_1X_TYPE_EAP_PACKET,
wpabuf_head_u8(resp), wpabuf_len(resp),
&outlen, NULL);
wpabuf_head_u8(resp), wpabuf_len(resp),
&outlen, NULL);
if (!outbuf) {
return ESP_ERR_NO_MEM;
}
@ -357,7 +357,7 @@ int eap_sm_process_request(struct eap_sm *sm, struct wpabuf *reqData)
}
if (ehdr->identifier == sm->current_identifier &&
sm->lastRespData != NULL) {
sm->lastRespData != NULL) {
/*Retransmit*/
resp = sm->lastRespData;
goto send_resp;
@ -398,7 +398,7 @@ int eap_sm_process_request(struct eap_sm *sm, struct wpabuf *reqData)
if (!eap_sm_allowMethod(sm, reqVendor, reqVendorMethod)) {
wpa_printf(MSG_DEBUG, "EAP: vendor %" PRIu32 " method %" PRIu32 " not allowed",
reqVendor, reqVendorMethod);
reqVendor, reqVendorMethod);
wpa_msg(sm->msg_ctx, MSG_INFO, WPA_EVENT_EAP_PROPOSED_METHOD
"vendor=%" PRIu32 " method=%" PRIu32 " -> NAK",
reqVendor, reqVendorMethod);
@ -502,20 +502,20 @@ static int wpa2_ent_rx_eapol(u8 *src_addr, u8 *buf, u32 len, uint8_t *bssid)
hdr = (struct ieee802_1x_hdr *) buf;
switch (hdr->type) {
case IEEE802_1X_TYPE_EAPOL_START:
case IEEE802_1X_TYPE_EAP_PACKET:
case IEEE802_1X_TYPE_EAPOL_LOGOFF:
ret = eap_sm_rx_eapol(src_addr, buf, len, bssid);
break;
case IEEE802_1X_TYPE_EAPOL_KEY:
ret = wpa_sm_rx_eapol(src_addr, buf, len);
break;
default:
wpa_printf(MSG_ERROR, "Unknown EAPOL packet type - %d", hdr->type);
break;
case IEEE802_1X_TYPE_EAPOL_START:
case IEEE802_1X_TYPE_EAP_PACKET:
case IEEE802_1X_TYPE_EAPOL_LOGOFF:
ret = eap_sm_rx_eapol(src_addr, buf, len, bssid);
break;
case IEEE802_1X_TYPE_EAPOL_KEY:
ret = wpa_sm_rx_eapol(src_addr, buf, len);
break;
default:
wpa_printf(MSG_ERROR, "Unknown EAPOL packet type - %d", hdr->type);
break;
}
return ret;
return ret;
}
static int eap_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len, uint8_t *bssid)
@ -543,7 +543,7 @@ static int eap_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len, uint8_t *bss
tmp = buf;
hdr = (struct ieee802_1x_hdr *) tmp;
ehdr = (struct eap_hdr *) (hdr + 1);
ehdr = (struct eap_hdr *)(hdr + 1);
plen = be_to_host16(hdr->length);
data_len = plen + sizeof(*hdr);
@ -578,9 +578,9 @@ static int eap_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len, uint8_t *bss
case EAP_CODE_REQUEST:
/* Handle EAP-reauthentication case */
if (sm->finish_state == WPA2_ENT_EAP_STATE_SUCCESS) {
wpa_printf(MSG_INFO, "EAP Re-authentication in progress");
wpa2_set_eap_state(WPA2_ENT_EAP_STATE_IN_PROGRESS);
}
wpa_printf(MSG_INFO, "EAP Re-authentication in progress");
wpa2_set_eap_state(WPA2_ENT_EAP_STATE_IN_PROGRESS);
}
req = wpabuf_alloc_copy((u8 *)ehdr, len - sizeof(*hdr));
ret = eap_sm_process_request(sm, req);
@ -596,7 +596,7 @@ static int eap_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len, uint8_t *bss
wpa_printf(MSG_INFO, ">>>>>EAP FINISH");
ret = WPA2_ENT_EAP_STATE_SUCCESS;
wpa2_set_eap_state(WPA2_ENT_EAP_STATE_SUCCESS);
eap_deinit_prev_method(sm, "EAP Success");
eap_deinit_prev_method(sm, "EAP Success");
} else {
wpa_printf(MSG_INFO, ">>>>>EAP FAILED, receive EAP_SUCCESS but pmk is empty, potential attack!");
ret = WPA2_ENT_EAP_STATE_FAIL;
@ -638,7 +638,7 @@ static int wpa2_start_eapol_internal(void)
if (wpa_sta_cur_pmksa_matches_akm()) {
wpa_printf(MSG_DEBUG,
"RSN: PMKSA caching - do not send EAPOL-Start");
"RSN: PMKSA caching - do not send EAPOL-Start");
return ESP_FAIL;
}
@ -902,8 +902,8 @@ esp_err_t esp_wifi_sta_enterprise_disable(void)
}
esp_err_t esp_eap_client_set_certificate_and_key(const unsigned char *client_cert, int client_cert_len,
const unsigned char *private_key, int private_key_len,
const unsigned char *private_key_passwd, int private_key_passwd_len)
const unsigned char *private_key, int private_key_len,
const unsigned char *private_key_passwd, int private_key_passwd_len)
{
if (client_cert && client_cert_len > 0) {
g_wpa_client_cert = client_cert;
@ -1098,24 +1098,24 @@ esp_err_t esp_eap_client_get_disable_time_check(bool *disable)
esp_err_t esp_eap_client_set_ttls_phase2_method(esp_eap_ttls_phase2_types type)
{
switch (type) {
case ESP_EAP_TTLS_PHASE2_EAP:
g_wpa_ttls_phase2_type = "auth=EAP";
break;
case ESP_EAP_TTLS_PHASE2_MSCHAPV2:
g_wpa_ttls_phase2_type = "auth=MSCHAPV2";
break;
case ESP_EAP_TTLS_PHASE2_MSCHAP:
g_wpa_ttls_phase2_type = "auth=MSCHAP";
break;
case ESP_EAP_TTLS_PHASE2_PAP:
g_wpa_ttls_phase2_type = "auth=PAP";
break;
case ESP_EAP_TTLS_PHASE2_CHAP:
g_wpa_ttls_phase2_type = "auth=CHAP";
break;
default:
g_wpa_ttls_phase2_type = "auth=MSCHAPV2";
break;
case ESP_EAP_TTLS_PHASE2_EAP:
g_wpa_ttls_phase2_type = "auth=EAP";
break;
case ESP_EAP_TTLS_PHASE2_MSCHAPV2:
g_wpa_ttls_phase2_type = "auth=MSCHAPV2";
break;
case ESP_EAP_TTLS_PHASE2_MSCHAP:
g_wpa_ttls_phase2_type = "auth=MSCHAP";
break;
case ESP_EAP_TTLS_PHASE2_PAP:
g_wpa_ttls_phase2_type = "auth=PAP";
break;
case ESP_EAP_TTLS_PHASE2_CHAP:
g_wpa_ttls_phase2_type = "auth=CHAP";
break;
default:
g_wpa_ttls_phase2_type = "auth=MSCHAPV2";
break;
}
return ESP_OK;
}
@ -1164,8 +1164,8 @@ esp_err_t esp_eap_client_set_fast_params(esp_eap_fast_config config)
}
if (config.fast_max_pac_list_len && config.fast_max_pac_list_len < 100) {
os_snprintf((char *) &config_for_supplicant + strlen(config_for_supplicant),
PHASE1_PARAM_STRING_LEN - strlen(config_for_supplicant),
"fast_max_pac_list_len=%d ", config.fast_max_pac_list_len);
PHASE1_PARAM_STRING_LEN - strlen(config_for_supplicant),
"fast_max_pac_list_len=%d ", config.fast_max_pac_list_len);
} else if (config.fast_max_pac_list_len >= 100) {
return ESP_ERR_INVALID_ARG;
}

Wyświetl plik

@ -82,8 +82,7 @@ void *hostap_init(void)
pairwise_cipher = esp_wifi_ap_get_prof_pairwise_cipher_internal();
#ifdef CONFIG_IEEE80211W
if((auth_conf->wpa & WPA_PROTO_RSN) == WPA_PROTO_RSN)
{
if ((auth_conf->wpa & WPA_PROTO_RSN) == WPA_PROTO_RSN) {
esp_wifi_get_pmf_config_internal(&pmf_cfg, WIFI_IF_AP);
if (pmf_cfg.required) {
pairwise_cipher = WIFI_CIPHER_TYPE_CCMP;
@ -147,7 +146,7 @@ void *hostap_init(void)
#ifdef CONFIG_SAE
if (authmode == WIFI_AUTH_WPA3_PSK ||
authmode == WIFI_AUTH_WPA2_WPA3_PSK) {
authmode == WIFI_AUTH_WPA2_WPA3_PSK) {
if (wpa3_hostap_auth_init(hapd) != 0) {
goto fail;
}
@ -191,7 +190,7 @@ void hostapd_cleanup(struct hostapd_data *hapd)
if (hapd == NULL) {
return;
}
if(hapd->wpa_auth) {
if (hapd->wpa_auth) {
wpa_deinit(hapd->wpa_auth);
hapd->wpa_auth = NULL;
}
@ -209,7 +208,7 @@ void hostapd_cleanup(struct hostapd_data *hapd)
if (dl_list_empty(&hapd->sae_commit_queue)) {
dl_list_for_each_safe(q, tmp, &hapd->sae_commit_queue,
struct hostapd_sae_commit_queue, list) {
struct hostapd_sae_commit_queue, list) {
dl_list_del(&q->list);
os_free(q);
}
@ -217,8 +216,8 @@ void hostapd_cleanup(struct hostapd_data *hapd)
#endif /* CONFIG_SAE */
#ifdef CONFIG_WPS_REGISTRAR
if (esp_wifi_get_wps_type_internal () != WPS_TYPE_DISABLE ||
esp_wifi_get_wps_status_internal() != WPS_STATUS_DISABLE) {
if (esp_wifi_get_wps_type_internal() != WPS_TYPE_DISABLE ||
esp_wifi_get_wps_status_internal() != WPS_STATUS_DISABLE) {
esp_wifi_ap_wps_disable();
}
#endif /* CONFIG_WPS_REGISTRAR */
@ -227,7 +226,6 @@ void hostapd_cleanup(struct hostapd_data *hapd)
}
bool hostap_deinit(void *data)
{
struct hostapd_data *hapd = (struct hostapd_data *)data;
@ -242,7 +240,7 @@ bool hostap_deinit(void *data)
wpa3_hostap_auth_deinit();
/* Wait till lock is released by wpa3 task */
if (g_wpa3_hostap_auth_api_lock &&
WPA3_HOSTAP_AUTH_API_LOCK() == pdTRUE) {
WPA3_HOSTAP_AUTH_API_LOCK() == pdTRUE) {
WPA3_HOSTAP_AUTH_API_UNLOCK();
}
#endif /* CONFIG_SAE */
@ -263,8 +261,8 @@ int esp_wifi_build_rsnxe(struct hostapd_data *hapd, u8 *eid, size_t len)
}
if (wpa_key_mgmt_sae(hapd->wpa_auth->conf.wpa_key_mgmt) &&
(hapd->conf->sae_pwe == SAE_PWE_HASH_TO_ELEMENT
|| hapd->conf->sae_pwe == SAE_PWE_BOTH)) {
(hapd->conf->sae_pwe == SAE_PWE_HASH_TO_ELEMENT
|| hapd->conf->sae_pwe == SAE_PWE_BOTH)) {
capab |= BIT(WLAN_RSNX_CAPAB_SAE_H2E);
}
@ -282,7 +280,7 @@ int esp_wifi_build_rsnxe(struct hostapd_data *hapd, u8 *eid, size_t len)
}
u16 esp_send_assoc_resp(struct hostapd_data *hapd, const u8 *addr,
u16 status_code, bool omit_rsnxe, int subtype)
u16 status_code, bool omit_rsnxe, int subtype)
{
#define ASSOC_RESP_LENGTH 20
u8 buf[ASSOC_RESP_LENGTH];

Wyświetl plik

@ -16,11 +16,11 @@ extern "C" {
void *hostap_init(void);
bool hostap_deinit(void *data);
u16 esp_send_assoc_resp(struct hostapd_data *data, const u8 *addr,
u16 status_code, bool omit_rsnxe, int subtype);
u16 status_code, bool omit_rsnxe, int subtype);
int esp_send_sae_auth_reply(struct hostapd_data *hapd,
const u8 *dst, const u8 *bssid,
u16 auth_alg, u16 auth_transaction, u16 resp,
const u8 *ies, size_t ies_len);
const u8 *dst, const u8 *bssid,
u16 auth_alg, u16 auth_transaction, u16 resp,
const u8 *ies, size_t ies_len);
#endif
#ifdef __cplusplus

Wyświetl plik

@ -186,7 +186,6 @@ static int wifi_ap_wps_enable_internal(const esp_wps_config_t *config)
return ESP_FAIL;
}
if (wps_set_type(config->wps_type) != ESP_OK) {
goto _err;
}
@ -247,7 +246,6 @@ static int wifi_ap_wps_disable_internal(void)
goto _err;
}
s_wps_enabled = false;
return ESP_OK;
@ -275,7 +273,6 @@ static int wifi_ap_wps_start_internal(const unsigned char *pin)
return ESP_ERR_WIFI_MODE;
}
if (!s_wps_enabled) {
wpa_printf(MSG_ERROR, "wps start: wps not enabled");
API_MUTEX_GIVE();
@ -286,13 +283,13 @@ static int wifi_ap_wps_start_internal(const unsigned char *pin)
(wps_get_status() != WPS_STATUS_DISABLE &&
wps_get_status() != WPS_STATUS_SCANNING)) {
wpa_printf(MSG_ERROR, "wps start: wps_get_type=%d wps_get_status=%d",
wps_get_type(), wps_get_status());
wps_get_type(), wps_get_status());
return ESP_ERR_WIFI_WPS_TYPE;
}
if (esp_wifi_get_user_init_flag_internal() == 0) {
wpa_printf(MSG_ERROR, "wps start: esp_wifi_get_user_init_flag_internal=%d",
esp_wifi_get_user_init_flag_internal());
esp_wifi_get_user_init_flag_internal());
return ESP_ERR_WIFI_STATE;
}
@ -332,7 +329,7 @@ static void wps_reg_eloop_handler(void *eloop_ctx, void *user_ctx)
enum wps_reg_sig_type *sig = (enum wps_reg_sig_type *) eloop_ctx;
wps_ioctl_param_t *param = (wps_ioctl_param_t *) user_ctx;
switch(*sig) {
switch (*sig) {
case SIG_WPS_REG_ENABLE:
esp_wps_config_t *config = (esp_wps_config_t *)param->arg;
ret = wifi_ap_wps_enable_internal(config);

Wyświetl plik

@ -27,148 +27,149 @@ extern struct wpa_supplicant g_wpa_supp;
static void scan_done_event_handler(void *arg, ETS_STATUS status)
{
struct wpa_supplicant *wpa_s = &g_wpa_supp;
struct wpa_supplicant *wpa_s = &g_wpa_supp;
/* update last scan time */
wpa_s->scan_start_tsf = esp_wifi_get_tsf_time(WIFI_IF_STA);
if (wpa_s->scanning) {
wpa_s->type &= ~(1 << WLAN_FC_STYPE_BEACON) & ~(1 << WLAN_FC_STYPE_PROBE_RESP);
esp_wifi_register_mgmt_frame_internal(wpa_s->type, wpa_s->subtype);
}
/* update last scan time */
wpa_s->scan_start_tsf = esp_wifi_get_tsf_time(WIFI_IF_STA);
if (wpa_s->scanning) {
wpa_s->type &= ~(1 << WLAN_FC_STYPE_BEACON) & ~(1 << WLAN_FC_STYPE_PROBE_RESP);
esp_wifi_register_mgmt_frame_internal(wpa_s->type, wpa_s->subtype);
}
#ifdef CONFIG_SUPPLICANT_TASK
if (esp_supplicant_post_evt(SIG_SUPPLICANT_SCAN_DONE, 0) != 0) {
wpa_printf(MSG_ERROR, "Posting of scan done failed!");
}
if (esp_supplicant_post_evt(SIG_SUPPLICANT_SCAN_DONE, 0) != 0) {
wpa_printf(MSG_ERROR, "Posting of scan done failed!");
}
#else
esp_supplicant_handle_scan_done_evt();
esp_supplicant_handle_scan_done_evt();
#endif /*CONFIG_SUPPLICANT_TASK*/
}
#if defined(CONFIG_IEEE80211KV)
static void handle_wnm_scan_done(struct wpa_supplicant *wpa_s)
{
struct wpa_bss *bss = wpa_bss_get_next_bss(wpa_s, wpa_s->current_bss);
struct wpa_bss *bss = wpa_bss_get_next_bss(wpa_s, wpa_s->current_bss);
if (wpa_s->wnm_neighbor_report_elements) {
wnm_scan_process(wpa_s, 1);
} else if (wpa_s->wnm_dissoc_timer) {
if (wpa_s->num_bss == 1) {
wpa_printf(MSG_INFO, "not able to find another candidate, do nothing");
return;
}
/* this is a already matched bss */
if (bss) {
wnm_bss_tm_connect(wpa_s, bss, NULL, 1);
}
}
if (wpa_s->wnm_neighbor_report_elements) {
wnm_scan_process(wpa_s, 1);
} else if (wpa_s->wnm_dissoc_timer) {
if (wpa_s->num_bss == 1) {
wpa_printf(MSG_INFO, "not able to find another candidate, do nothing");
return;
}
/* this is a already matched bss */
if (bss) {
wnm_bss_tm_connect(wpa_s, bss, NULL, 1);
}
}
}
#endif
static void scan_done_cleanup(struct wpa_supplicant *wpa_s)
{
wpa_s->scanning = 0;
wpa_s->scan_reason = 0;
/* clean scan list from net80211 */
esp_wifi_clear_ap_list();
wpa_s->scanning = 0;
wpa_s->scan_reason = 0;
/* clean scan list from net80211 */
esp_wifi_clear_ap_list();
}
void esp_supplicant_handle_scan_done_evt(void)
{
struct wpa_supplicant *wpa_s = &g_wpa_supp;
struct wpa_supplicant *wpa_s = &g_wpa_supp;
wpa_printf(MSG_INFO, "scan done received");
wpa_printf(MSG_INFO, "scan done received");
#if defined(CONFIG_IEEE80211KV)
/* Check which module started this, call the respective function */
if (wpa_s->scan_reason == REASON_RRM_BEACON_REPORT) {
wpas_beacon_rep_scan_process(wpa_s, wpa_s->scan_start_tsf);
} else if (wpa_s->scan_reason == REASON_WNM_BSS_TRANS_REQ) {
handle_wnm_scan_done(wpa_s);
}
/* Check which module started this, call the respective function */
if (wpa_s->scan_reason == REASON_RRM_BEACON_REPORT) {
wpas_beacon_rep_scan_process(wpa_s, wpa_s->scan_start_tsf);
} else if (wpa_s->scan_reason == REASON_WNM_BSS_TRANS_REQ) {
handle_wnm_scan_done(wpa_s);
}
#endif
if (wpa_s->scanning) {
scan_done_cleanup(wpa_s);
}
wpa_bss_update_end(wpa_s);
if (wpa_s->scanning) {
scan_done_cleanup(wpa_s);
}
wpa_bss_update_end(wpa_s);
#ifndef SCAN_CACHE_SUPPORTED
wpa_bss_flush(wpa_s);
wpa_bss_flush(wpa_s);
#endif
}
void esp_scan_init(struct wpa_supplicant *wpa_s)
{
wpa_s->scanning = 0;
wpa_bss_init(wpa_s);
wpa_s->last_scan_res = NULL;
wpa_s->last_scan_res_used = 0;
wpa_s->scanning = 0;
wpa_bss_init(wpa_s);
wpa_s->last_scan_res = NULL;
wpa_s->last_scan_res_used = 0;
}
void esp_scan_deinit(struct wpa_supplicant *wpa_s)
{
wpa_bss_deinit(wpa_s);
os_free(wpa_s->last_scan_res);
wpa_s->last_scan_res = NULL;
wpa_s->last_scan_res_used = 0;
wpa_bss_deinit(wpa_s);
os_free(wpa_s->last_scan_res);
wpa_s->last_scan_res = NULL;
wpa_s->last_scan_res_used = 0;
}
int esp_handle_beacon_probe(u8 type, u8 *frame, size_t len, u8 *sender,
int8_t rssi, u8 channel, u64 current_tsf)
int8_t rssi, u8 channel, u64 current_tsf)
{
struct wpa_supplicant *wpa_s = &g_wpa_supp;
struct os_reltime now;
struct wpa_scan_res *res;
u8 *ptr;
struct wpa_supplicant *wpa_s = &g_wpa_supp;
struct os_reltime now;
struct wpa_scan_res *res;
u8 *ptr;
if (len < 12) {
wpa_printf(MSG_ERROR, "beacon/probe is having short len=%d", len);
return -1;
}
if (len < 12) {
wpa_printf(MSG_ERROR, "beacon/probe is having short len=%d", len);
return -1;
}
res = os_zalloc(sizeof(struct wpa_scan_res) + len - 12);
if (!res) {
wpa_printf(MSG_ERROR, "failed to allocate memory");
return -1;
}
res = os_zalloc(sizeof(struct wpa_scan_res) + len - 12);
if (!res) {
wpa_printf(MSG_ERROR, "failed to allocate memory");
return -1;
}
ptr = (u8 *)res;
os_get_time(&now);
os_memcpy(res->bssid, sender, ETH_ALEN);
res->tsf = WPA_GET_LE64(frame);
frame += 8;
len -= 8;
ptr = (u8 *)res;
os_get_time(&now);
os_memcpy(res->bssid, sender, ETH_ALEN);
res->tsf = WPA_GET_LE64(frame);
frame += 8;
len -= 8;
if ((wpa_s->scan_start_tsf == 0) &&
wpa_s->current_bss &&
(os_memcmp(wpa_s->current_bss, sender, ETH_ALEN) == 0)) {
wpa_s->scan_start_tsf = res->tsf;
os_memcpy(wpa_s->tsf_bssid, sender, ETH_ALEN);
}
res->beacon_int = WPA_GET_LE16(frame);
if ((wpa_s->scan_start_tsf == 0) &&
wpa_s->current_bss &&
(os_memcmp(wpa_s->current_bss, sender, ETH_ALEN) == 0)) {
wpa_s->scan_start_tsf = res->tsf;
os_memcpy(wpa_s->tsf_bssid, sender, ETH_ALEN);
}
res->beacon_int = WPA_GET_LE16(frame);
frame += 2;
len -= 2;
res->caps = WPA_GET_LE16(frame);
frame += 2;
len -= 2;
frame += 2;
len -= 2;
res->caps = WPA_GET_LE16(frame);
frame += 2;
len -= 2;
res->chan = channel;
res->noise = 0;
res->level = rssi;
os_memcpy(res->tsf_bssid, wpa_s->tsf_bssid, ETH_ALEN);
res->parent_tsf = current_tsf - wpa_s->scan_start_tsf;
res->ie_len = len;
res->chan = channel;
res->noise = 0;
res->level = rssi;
os_memcpy(res->tsf_bssid, wpa_s->tsf_bssid, ETH_ALEN);
res->parent_tsf = current_tsf - wpa_s->scan_start_tsf;
res->ie_len = len;
ptr += sizeof(struct wpa_scan_res);
ptr += sizeof(struct wpa_scan_res);
/* update rest of the frame */
os_memcpy(ptr, frame, len);
wpa_bss_update_scan_res(wpa_s, res, &now);
os_get_reltime(&wpa_s->last_scan);
os_free(res);
/* update rest of the frame */
os_memcpy(ptr, frame, len);
wpa_bss_update_scan_res(wpa_s, res, &now);
os_get_reltime(&wpa_s->last_scan);
os_free(res);
return 0;
return 0;
}
#ifdef CONFIG_WNM
void get_scan_channel_bitmap(struct wpa_supplicant *wpa_s, wifi_scan_config_t *params) {
void get_scan_channel_bitmap(struct wpa_supplicant *wpa_s, wifi_scan_config_t *params)
{
if (!wpa_s->wnm_num_neighbor_report) {
wpa_printf(MSG_DEBUG, "No Neighbor Report to gather scan channel list");
return;
@ -183,96 +184,98 @@ void get_scan_channel_bitmap(struct wpa_supplicant *wpa_s, wifi_scan_config_t *p
}
#endif /*CONFIG_WNM*/
static int issue_scan(struct wpa_supplicant *wpa_s,
struct wpa_driver_scan_params *scan_params)
struct wpa_driver_scan_params *scan_params)
{
wifi_scan_config_t *params = NULL;
int ret = 0;
u64 scan_start_tsf = esp_wifi_get_tsf_time(WIFI_IF_STA);
wifi_scan_config_t *params = NULL;
int ret = 0;
u64 scan_start_tsf = esp_wifi_get_tsf_time(WIFI_IF_STA);
/* TODO: Directly try to connect if scan results are recent */
if ((scan_start_tsf - wpa_s->scan_start_tsf) > 100000) {
wpa_printf(MSG_DEBUG, "flushing old scan cache %llu",
(scan_start_tsf - wpa_s->scan_start_tsf));
wpa_bss_flush(wpa_s);
}
/* TODO: Directly try to connect if scan results are recent */
if ((scan_start_tsf - wpa_s->scan_start_tsf) > 100000) {
wpa_printf(MSG_DEBUG, "flushing old scan cache %llu",
(scan_start_tsf - wpa_s->scan_start_tsf));
wpa_bss_flush(wpa_s);
}
esp_wifi_get_macaddr_internal(WIFI_IF_STA, wpa_s->tsf_bssid);
esp_wifi_get_macaddr_internal(WIFI_IF_STA, wpa_s->tsf_bssid);
if (scan_params) {
params = os_zalloc(sizeof(wifi_scan_config_t));
if (!params) {
wpa_printf(MSG_ERROR, "failed to allocate memory");
return -1;
}
if (scan_params->num_ssids) {
params->ssid = os_zalloc(scan_params->ssids[0].ssid_len + 1);
if (!params->ssid) {
wpa_printf(MSG_ERROR, "failed to allocate memory");
ret = -1;
goto cleanup;
}
os_memcpy(params->ssid, scan_params->ssids[0].ssid, scan_params->ssids[0].ssid_len);
} else
if (scan_params) {
params = os_zalloc(sizeof(wifi_scan_config_t));
if (!params) {
wpa_printf(MSG_ERROR, "failed to allocate memory");
return -1;
}
if (scan_params->num_ssids) {
params->ssid = os_zalloc(scan_params->ssids[0].ssid_len + 1);
if (!params->ssid) {
wpa_printf(MSG_ERROR, "failed to allocate memory");
ret = -1;
goto cleanup;
}
os_memcpy(params->ssid, scan_params->ssids[0].ssid, scan_params->ssids[0].ssid_len);
} else
if (scan_params->mode == BEACON_REPORT_MODE_PASSIVE) {
params->scan_type = WIFI_SCAN_TYPE_PASSIVE;
} else {
params->scan_type = WIFI_SCAN_TYPE_ACTIVE;
}
if (scan_params->mode == BEACON_REPORT_MODE_PASSIVE) {
params->scan_type = WIFI_SCAN_TYPE_PASSIVE;
} else {
params->scan_type = WIFI_SCAN_TYPE_ACTIVE;
}
if (scan_params->bssid) {
params->bssid = os_zalloc(ETH_ALEN);
if (!params->bssid) {
wpa_printf(MSG_ERROR, "failed to allocate memory");
ret = -1;
goto cleanup;
}
os_memcpy(params->bssid, scan_params->bssid, ETH_ALEN);
}
if (scan_params->channel) {
params->channel = scan_params->channel;
}
if (scan_params->bssid) {
params->bssid = os_zalloc(ETH_ALEN);
if (!params->bssid) {
wpa_printf(MSG_ERROR, "failed to allocate memory");
ret = -1;
goto cleanup;
}
os_memcpy(params->bssid, scan_params->bssid, ETH_ALEN);
}
if (scan_params->channel) {
params->channel = scan_params->channel;
}
#ifdef CONFIG_WNM
else {
get_scan_channel_bitmap(wpa_s, params);
}
else {
get_scan_channel_bitmap(wpa_s, params);
}
#endif /*CONFIG_WNM*/
if (scan_params->duration) {
params->scan_time.passive = scan_params->duration;
params->scan_time.active.min = scan_params->duration;
params->scan_time.active.max = scan_params->duration;
} else {
params->scan_time.active.min = SUPPLICANT_SCAN_ACTIVE_SCAN_MIN_DURATION;
params->scan_time.active.max = SUPPLICANT_SCAN_ACTIVE_SCAN_MAX_DURATION;
}
}
if (scan_params->duration) {
params->scan_time.passive = scan_params->duration;
params->scan_time.active.min = scan_params->duration;
params->scan_time.active.max = scan_params->duration;
} else {
params->scan_time.active.min = SUPPLICANT_SCAN_ACTIVE_SCAN_MIN_DURATION;
params->scan_time.active.max = SUPPLICANT_SCAN_ACTIVE_SCAN_MAX_DURATION;
}
}
wpa_s->scan_start_tsf = scan_start_tsf;
/* Register frames to come to supplicant when we park on channel */
wpa_s->type |= (1 << WLAN_FC_STYPE_BEACON) | (1 << WLAN_FC_STYPE_PROBE_RESP);
esp_wifi_register_mgmt_frame_internal(wpa_s->type, wpa_s->subtype);
wpa_s->scan_start_tsf = scan_start_tsf;
/* Register frames to come to supplicant when we park on channel */
wpa_s->type |= (1 << WLAN_FC_STYPE_BEACON) | (1 << WLAN_FC_STYPE_PROBE_RESP);
esp_wifi_register_mgmt_frame_internal(wpa_s->type, wpa_s->subtype);
typedef void (* scan_done_cb_t)(void *arg, ETS_STATUS status);
extern int esp_wifi_promiscuous_scan_start(wifi_scan_config_t *config, scan_done_cb_t cb);
/* issue scan */
if (esp_wifi_promiscuous_scan_start(params, scan_done_event_handler) < 0) {
ret = -1;
goto cleanup;
}
wpa_s->scanning = 1;
wpa_bss_update_start(wpa_s);
wpa_printf(MSG_INFO, "scan issued at time=%llu", wpa_s->scan_start_tsf);
typedef void (* scan_done_cb_t)(void *arg, ETS_STATUS status);
extern int esp_wifi_promiscuous_scan_start(wifi_scan_config_t *config, scan_done_cb_t cb);
/* issue scan */
if (esp_wifi_promiscuous_scan_start(params, scan_done_event_handler) < 0) {
ret = -1;
goto cleanup;
}
wpa_s->scanning = 1;
wpa_bss_update_start(wpa_s);
wpa_printf(MSG_INFO, "scan issued at time=%llu", wpa_s->scan_start_tsf);
cleanup:
if (params) {
if (params->ssid)
if (params->ssid) {
os_free(params->ssid);
if (params->bssid)
}
if (params->bssid) {
os_free(params->bssid);
}
os_free(params);
}
return ret;
return ret;
}
/**
@ -282,20 +285,22 @@ cleanup:
* Returns: 0 on success, -1 on failure
*/
int wpa_supplicant_trigger_scan(struct wpa_supplicant *wpa_s,
struct wpa_driver_scan_params *params)
struct wpa_driver_scan_params *params)
{
return issue_scan(wpa_s, params);
return issue_scan(wpa_s, params);
}
void wpa_scan_results_free(struct wpa_scan_results *res)
{
size_t i;
size_t i;
if (res == NULL)
return;
if (res == NULL) {
return;
}
for (i = 0; i < res->num; i++)
os_free(res->res[i]);
os_free(res->res);
os_free(res);
for (i = 0; i < res->num; i++) {
os_free(res->res[i]);
}
os_free(res->res);
os_free(res);
}

Wyświetl plik

@ -13,7 +13,7 @@
void esp_scan_init(struct wpa_supplicant *wpa_s);
void esp_scan_deinit(struct wpa_supplicant *wpa_s);
int esp_handle_beacon_probe(u8 type, u8 *frame, size_t len, u8 *sender,
int8_t rssi, u8 channel, u64 current_tsf);
int8_t rssi, u8 channel, u64 current_tsf);
void esp_supplicant_handle_scan_done_evt(void);
#endif

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -19,7 +19,7 @@
#define WPA2_TASK_STACK_SIZE (6144 + TASK_STACK_SIZE_ADD)
#define WPS_TASK_STACK_SIZE (12288 + TASK_STACK_SIZE_ADD)
enum wpa_alg{
enum wpa_alg {
WIFI_WPA_ALG_NONE = 0,
WIFI_WPA_ALG_WEP40 = 1,
WIFI_WPA_ALG_TKIP = 2,
@ -64,9 +64,9 @@ enum {
WPA2_AUTH_PSK = 0x05,
WPA_AUTH_CCKM = 0x06,
WPA2_AUTH_CCKM = 0x07,
WPA2_AUTH_PSK_SHA256= 0x08,
WPA2_AUTH_PSK_SHA256 = 0x08,
WPA3_AUTH_PSK = 0x09,
WPA2_AUTH_ENT_SHA256= 0x0a,
WPA2_AUTH_ENT_SHA256 = 0x0a,
WAPI_AUTH_PSK = 0x0b,
WAPI_AUTH_CERT = 0x0c,
WPA2_AUTH_ENT_SHA384_SUITE_B = 0x0d,
@ -146,18 +146,18 @@ struct wpa_funcs {
};
struct wpa2_funcs {
int (*wpa2_sm_rx_eapol)(u8 *src_addr, u8 *buf, u32 len, u8 *bssid);
int (*wpa2_start)(void);
u8 (*wpa2_get_state)(void);
int (*wpa2_init)(void);
int (*wpa2_sm_rx_eapol)(u8 *src_addr, u8 *buf, u32 len, u8 *bssid);
int (*wpa2_start)(void);
u8(*wpa2_get_state)(void);
int (*wpa2_init)(void);
void (*wpa2_deinit)(void);
};
struct wps_funcs {
bool (*wps_parse_scan_result)(struct wps_scan_ie *scan);
int (*wifi_station_wps_start)(void);
int (*wps_sm_rx_eapol)(u8 *src_addr, u8 *buf, u32 len);
int (*wps_start_pending)(void);
int (*wifi_station_wps_start)(void);
int (*wps_sm_rx_eapol)(u8 *src_addr, u8 *buf, u32 len);
int (*wps_start_pending)(void);
};
typedef esp_err_t (*wifi_wpa2_fn_t)(void *);

Wyświetl plik

@ -71,7 +71,7 @@ esp_err_t esp_wifi_sta_wpa2_ent_set_cert_key(const unsigned char *client_cert, i
const unsigned char *private_key_passwd, int private_key_passwd_len)
{
return esp_eap_client_set_certificate_and_key(client_cert, client_cert_len,
private_key, private_key_len, private_key_passwd, private_key_passwd_len);
private_key, private_key_len, private_key_passwd, private_key_passwd_len);
}
void esp_wifi_sta_wpa2_ent_clear_cert_key(void)

Wyświetl plik

@ -17,7 +17,6 @@
#include "esp_hostap.h"
#include <inttypes.h>
static struct sae_pt *g_sae_pt;
static struct sae_data g_sae_data;
static struct wpabuf *g_sae_token = NULL;
@ -34,7 +33,7 @@ static esp_err_t wpa3_build_sae_commit(u8 *bssid, size_t *sae_msg_len)
const u8 *pw = (const u8 *)esp_wifi_sta_get_prof_password_internal();
struct wifi_ssid *ssid = esp_wifi_sta_get_prof_ssid_internal();
uint8_t sae_pwe = esp_wifi_get_config_sae_pwe_h2e_internal(WIFI_IF_STA);
char sae_pwd_id[SAE_H2E_IDENTIFIER_LEN+1] = {0};
char sae_pwd_id[SAE_H2E_IDENTIFIER_LEN + 1] = {0};
bool valid_pwd_id = false;
const u8 *rsnxe;
u8 rsnxe_capa = 0;
@ -43,39 +42,39 @@ static esp_err_t wpa3_build_sae_commit(u8 *bssid, size_t *sae_msg_len)
use_pt = 1;
}
rsnxe = esp_wifi_sta_get_rsnxe(bssid);
if (rsnxe && rsnxe[1] >= 1) {
rsnxe_capa = rsnxe[2];
}
rsnxe = esp_wifi_sta_get_rsnxe(bssid);
if (rsnxe && rsnxe[1] >= 1) {
rsnxe_capa = rsnxe[2];
}
#ifdef CONFIG_SAE_PK
bool use_pk = false;
uint8_t sae_pk_mode = esp_wifi_sta_get_config_sae_pk_internal();
if ((rsnxe_capa & BIT(WLAN_RSNX_CAPAB_SAE_PK)) &&
sae_pk_mode != WPA3_SAE_PK_MODE_DISABLED &&
((pw && sae_pk_valid_password((const char*)pw)))) {
sae_pk_mode != WPA3_SAE_PK_MODE_DISABLED &&
((pw && sae_pk_valid_password((const char *)pw)))) {
use_pt = 1;
use_pk = true;
}
if (sae_pk_mode == WPA3_SAE_PK_MODE_ONLY && !use_pk) {
wpa_printf(MSG_DEBUG,
"SAE: Cannot use PK with the selected AP");
"SAE: Cannot use PK with the selected AP");
return ESP_FAIL;
}
#endif /* CONFIG_SAE_PK */
if (use_pt || sae_pwe == SAE_PWE_HASH_TO_ELEMENT ||
sae_pwe == SAE_PWE_BOTH) {
sae_pwe == SAE_PWE_BOTH) {
use_pt = !!(rsnxe_capa & BIT(WLAN_RSNX_CAPAB_SAE_H2E));
if ((sae_pwe == SAE_PWE_HASH_TO_ELEMENT ||
wpa_key_mgmt_sae_ext_key(gWpaSm.key_mgmt)
wpa_key_mgmt_sae_ext_key(gWpaSm.key_mgmt)
#ifdef CONFIG_SAE_PK
|| (use_pk && sae_pk_mode == WPA3_SAE_PK_MODE_ONLY)
|| (use_pk && sae_pk_mode == WPA3_SAE_PK_MODE_ONLY)
#endif /* CONFIG_SAE_PK */
) && !use_pt) {
wpa_printf(MSG_DEBUG,
"SAE: Cannot use H2E with the selected AP");
"SAE: Cannot use H2E with the selected AP");
return ESP_FAIL;
}
}
@ -123,14 +122,14 @@ static esp_err_t wpa3_build_sae_commit(u8 *bssid, size_t *sae_msg_len)
if (use_pt &&
sae_prepare_commit_pt(&g_sae_data, g_sae_pt,
own_addr, bssid, NULL, NULL) < 0) {
own_addr, bssid, NULL, NULL) < 0) {
wpa_printf(MSG_ERROR, "wpa3: failed to prepare SAE commit!");
return ESP_FAIL;
}
if (!use_pt &&
sae_prepare_commit(own_addr, bssid, pw,
strlen((const char *)pw),
&g_sae_data) < 0) {
strlen((const char *)pw),
&g_sae_data) < 0) {
wpa_printf(MSG_ERROR, "wpa3: failed to prepare SAE commit!");
return ESP_FAIL;
}
@ -138,9 +137,9 @@ static esp_err_t wpa3_build_sae_commit(u8 *bssid, size_t *sae_msg_len)
#ifdef CONFIG_SAE_PK
if (g_sae_data.tmp && use_pt && use_pk) {
g_sae_data.pk = 1;
os_memcpy(g_sae_data.tmp->own_addr,own_addr, ETH_ALEN );
os_memcpy(g_sae_data.tmp->own_addr, own_addr, ETH_ALEN);
os_memcpy(g_sae_data.tmp->peer_addr, bssid, ETH_ALEN);
sae_pk_set_password(&g_sae_data,(const char*) pw);
sae_pk_set_password(&g_sae_data, (const char*) pw);
}
#endif
@ -170,8 +169,9 @@ reuse_data:
static esp_err_t wpa3_build_sae_confirm(void)
{
if (g_sae_data.state != SAE_COMMITTED)
if (g_sae_data.state != SAE_COMMITTED) {
return ESP_FAIL;
}
if (g_sae_confirm) {
wpabuf_free(g_sae_confirm);
@ -218,25 +218,27 @@ static u8 *wpa3_build_sae_msg(u8 *bssid, u32 sae_msg_type, size_t *sae_msg_len)
u8 *buf = NULL;
switch (sae_msg_type) {
case SAE_MSG_COMMIT:
/* Do not go for SAE when WPS is ongoing */
if (esp_wifi_get_wps_status_internal() != WPS_STATUS_DISABLE) {
*sae_msg_len = 0;
return NULL;
}
if (ESP_OK != wpa3_build_sae_commit(bssid, sae_msg_len))
return NULL;
*sae_msg_len = wpabuf_len(g_sae_commit);
buf = wpabuf_mhead_u8(g_sae_commit);
break;
case SAE_MSG_CONFIRM:
if (ESP_OK != wpa3_build_sae_confirm())
return NULL;
*sae_msg_len = wpabuf_len(g_sae_confirm);
buf = wpabuf_mhead_u8(g_sae_confirm);
break;
default:
break;
case SAE_MSG_COMMIT:
/* Do not go for SAE when WPS is ongoing */
if (esp_wifi_get_wps_status_internal() != WPS_STATUS_DISABLE) {
*sae_msg_len = 0;
return NULL;
}
if (ESP_OK != wpa3_build_sae_commit(bssid, sae_msg_len)) {
return NULL;
}
*sae_msg_len = wpabuf_len(g_sae_commit);
buf = wpabuf_mhead_u8(g_sae_commit);
break;
case SAE_MSG_CONFIRM:
if (ESP_OK != wpa3_build_sae_confirm()) {
return NULL;
}
*sae_msg_len = wpabuf_len(g_sae_confirm);
buf = wpabuf_mhead_u8(g_sae_confirm);
break;
default:
break;
}
return buf;
@ -252,13 +254,14 @@ static int wpa3_parse_sae_commit(u8 *buf, u32 len, u16 status)
}
if (status == WLAN_STATUS_ANTI_CLOGGING_TOKEN_REQ) {
if (g_sae_token)
if (g_sae_token) {
wpabuf_free(g_sae_token);
}
if (g_sae_data.h2e) {
if ((buf[2] != WLAN_EID_EXTENSION) ||
(buf[3] == 0) ||
(buf[3] > len - 4) ||
(buf[4] != WLAN_EID_EXT_ANTI_CLOGGING_TOKEN)) {
(buf[3] == 0) ||
(buf[3] > len - 4) ||
(buf[4] != WLAN_EID_EXT_ANTI_CLOGGING_TOKEN)) {
wpa_printf(MSG_ERROR, "Invalid SAE anti-clogging token container header");
return ESP_FAIL;
}
@ -312,17 +315,17 @@ static int wpa3_parse_sae_msg(u8 *buf, size_t len, u32 sae_msg_type, u16 status)
int ret = ESP_OK;
switch (sae_msg_type) {
case SAE_MSG_COMMIT:
ret = wpa3_parse_sae_commit(buf, len, status);
break;
case SAE_MSG_CONFIRM:
ret = wpa3_parse_sae_confirm(buf, len);
esp_wpa3_free_sae_data();
break;
default:
wpa_printf(MSG_ERROR, "wpa3: Invalid SAE msg type(%" PRId32 ")!", sae_msg_type);
ret = ESP_FAIL;
break;
case SAE_MSG_COMMIT:
ret = wpa3_parse_sae_commit(buf, len, status);
break;
case SAE_MSG_CONFIRM:
ret = wpa3_parse_sae_confirm(buf, len);
esp_wpa3_free_sae_data();
break;
default:
wpa_printf(MSG_ERROR, "wpa3: Invalid SAE msg type(%" PRId32 ")!", sae_msg_type);
ret = ESP_FAIL;
break;
}
return ret;
@ -433,7 +436,7 @@ static void wpa3_process_rx_commit(wpa3_hostap_auth_event_t *evt)
os_semphr_give(sta->lock);
uint16_t aid = 0;
if (ret != WLAN_STATUS_SUCCESS &&
ret != WLAN_STATUS_ANTI_CLOGGING_TOKEN_REQ) {
ret != WLAN_STATUS_ANTI_CLOGGING_TOKEN_REQ) {
esp_wifi_ap_get_sta_aid(frm->bssid, &aid);
if (aid == 0) {
esp_wifi_ap_deauth_internal(frm->bssid, ret);
@ -516,7 +519,7 @@ static void esp_wpa3_hostap_task(void *pvParameters)
}
}
uint32_t items_in_queue = os_queue_msg_waiting(g_wpa3_hostap_evt_queue);
while(items_in_queue--) {
while (items_in_queue--) {
/* Free events posted to queue */
os_queue_recv(g_wpa3_hostap_evt_queue, &evt, portMAX_DELAY);
if (evt->id == SIG_WPA3_RX_CONFIRM) {
@ -556,9 +559,9 @@ int wpa3_hostap_auth_init(void *data)
}
if (os_task_create(esp_wpa3_hostap_task, "esp_wpa3_hostap_task",
WPA3_HOSTAP_HANDLE_AUTH_TASK_STACK_SIZE, NULL,
WPA3_HOSTAP_HANDLE_AUTH_TASK_PRIORITY,
&g_wpa3_hostap_task_hdl) != pdPASS) {
WPA3_HOSTAP_HANDLE_AUTH_TASK_STACK_SIZE, NULL,
WPA3_HOSTAP_HANDLE_AUTH_TASK_PRIORITY,
&g_wpa3_hostap_task_hdl) != pdPASS) {
wpa_printf(MSG_ERROR, "wpa3_hostap_auth_init: failed to create task");
os_queue_delete(g_wpa3_hostap_evt_queue);
return ESP_FAIL;

Wyświetl plik

@ -62,7 +62,7 @@ bool wpa3_hostap_auth_deinit(void);
static inline void esp_wifi_register_wpa3_ap_cb(struct wpa_funcs *wpa_cb)
{
wpa_cb->wpa3_hostap_handle_auth = NULL;
wpa_cb->wpa3_hostap_handle_auth = NULL;
}
#endif /* CONFIG_SAE */

Wyświetl plik

@ -114,7 +114,7 @@ int wpa_config_bss(uint8_t *bssid)
esp_wifi_get_macaddr_internal(0, mac);
ret = wpa_set_bss((char *)mac, (char *)bssid, esp_wifi_sta_get_pairwise_cipher_internal(), esp_wifi_sta_get_group_cipher_internal(),
(char *)esp_wifi_sta_get_prof_password_internal(), ssid->ssid, ssid->len);
(char *)esp_wifi_sta_get_prof_password_internal(), ssid->ssid, ssid->len);
return ret;
}
@ -136,7 +136,7 @@ bool wpa_attach(void)
{
bool ret = true;
ret = wpa_sm_init();
if(ret) {
if (ret) {
ret = (esp_wifi_register_eapol_txdonecb_internal(eapol_txcb) == ESP_OK);
}
esp_set_scan_ie();
@ -167,8 +167,8 @@ bool wpa_ap_rx_eapol(void *hapd_data, void *sm_data, u8 *data, size_t data_len)
int wps_type = esp_wifi_get_wps_type_internal();
if ((wps_type == WPS_TYPE_PBC) ||
(wps_type == WPS_TYPE_PIN)) {
ieee802_1x_receive(hapd, sta->addr, data, data_len);
(wps_type == WPS_TYPE_PIN)) {
ieee802_1x_receive(hapd, sta->addr, data, data_len);
return true;
}
#endif
@ -285,24 +285,24 @@ static void wpa_sta_connected_cb(uint8_t *bssid)
static void wpa_sta_disconnected_cb(uint8_t reason_code)
{
switch (reason_code) {
case WIFI_REASON_AUTH_EXPIRE:
case WIFI_REASON_NOT_AUTHED:
case WIFI_REASON_NOT_ASSOCED:
case WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT:
case WIFI_REASON_INVALID_PMKID:
case WIFI_REASON_AUTH_FAIL:
case WIFI_REASON_ASSOC_FAIL:
case WIFI_REASON_CONNECTION_FAIL:
case WIFI_REASON_HANDSHAKE_TIMEOUT:
esp_wpa3_free_sae_data();
case WIFI_REASON_AUTH_EXPIRE:
case WIFI_REASON_NOT_AUTHED:
case WIFI_REASON_NOT_ASSOCED:
case WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT:
case WIFI_REASON_INVALID_PMKID:
case WIFI_REASON_AUTH_FAIL:
case WIFI_REASON_ASSOC_FAIL:
case WIFI_REASON_CONNECTION_FAIL:
case WIFI_REASON_HANDSHAKE_TIMEOUT:
esp_wpa3_free_sae_data();
wpa_sta_clear_curr_pmksa();
wpa_sm_notify_disassoc(&gWpaSm);
break;
default:
if (g_wpa_pmk_caching_disabled) {
wpa_sta_clear_curr_pmksa();
wpa_sm_notify_disassoc(&gWpaSm);
break;
default:
if (g_wpa_pmk_caching_disabled) {
wpa_sta_clear_curr_pmksa();
}
break;
}
break;
}
#ifdef CONFIG_OWE_STA
owe_deinit();
@ -346,7 +346,7 @@ static int check_n_add_wps_sta(struct hostapd_data *hapd, struct sta_info *sta_i
}
#endif
static bool hostap_sta_join(void **sta, u8 *bssid, u8 *wpa_ie, u8 wpa_ie_len,u8 *rsnxe, u8 rsnxe_len, bool *pmf_enable, int subtype)
static bool hostap_sta_join(void **sta, u8 *bssid, u8 *wpa_ie, u8 wpa_ie_len, u8 *rsnxe, u8 rsnxe_len, bool *pmf_enable, int subtype)
{
struct sta_info *sta_info = NULL;
struct hostapd_data *hapd = hostapd_get_hapd_data();
@ -370,7 +370,7 @@ static bool hostap_sta_join(void **sta, u8 *bssid, u8 *wpa_ie, u8 wpa_ie_len,u8
ap_free_sta(hapd, old_sta);
}
#ifdef CONFIG_SAE
else if (old_sta && old_sta->lock) {
else if (old_sta && old_sta->lock) {
sta_info = old_sta;
goto process_old_sta;
}
@ -379,7 +379,7 @@ static bool hostap_sta_join(void **sta, u8 *bssid, u8 *wpa_ie, u8 wpa_ie_len,u8
sta_info = ap_get_sta(hapd, bssid);
if (!sta_info) {
sta_info = ap_sta_add(hapd,bssid);
sta_info = ap_sta_add(hapd, bssid);
if (!sta_info) {
wpa_printf(MSG_ERROR, "failed to add station " MACSTR, MAC2STR(bssid));
goto fail;
@ -397,7 +397,6 @@ static bool hostap_sta_join(void **sta, u8 *bssid, u8 *wpa_ie, u8 wpa_ie_len,u8
process_old_sta:
#endif /* CONFIG_SAE */
#ifdef CONFIG_WPS_REGISTRAR
if (check_n_add_wps_sta(hapd, sta_info, wpa_ie, wpa_ie_len, pmf_enable, subtype) == 0) {
if (sta_info->eapol_sm) {

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -72,13 +72,13 @@ int wpa_ether_send(void *ctx, const u8 *dest, u16 proto,
}
int hostapd_send_eapol(const u8 *source, const u8 *sta_addr,
const u8 *data, size_t data_len)
const u8 *data, size_t data_len)
{
void *buffer = os_malloc(data_len + sizeof(struct l2_ethhdr));
struct l2_ethhdr *eth = buffer;
if (!buffer){
wpa_printf( MSG_DEBUG, "send_eapol, buffer=%p", buffer);
if (!buffer) {
wpa_printf(MSG_DEBUG, "send_eapol, buffer=%p", buffer);
return -1;
}
@ -102,26 +102,26 @@ void wpa_supplicant_transition_disable(struct wpa_sm *sm, u8 bitmap)
{
wpa_printf(MSG_DEBUG, "TRANSITION_DISABLE %02x", bitmap);
if ((bitmap & TRANSITION_DISABLE_WPA3_PERSONAL) &&
wpa_key_mgmt_sae(sm->key_mgmt)) {
if ((bitmap & TRANSITION_DISABLE_WPA3_PERSONAL) &&
wpa_key_mgmt_sae(sm->key_mgmt)) {
disable_wpa_wpa2();
}
if ((bitmap & TRANSITION_DISABLE_SAE_PK) &&
wpa_key_mgmt_sae(sm->key_mgmt)) {
wpa_key_mgmt_sae(sm->key_mgmt)) {
wpa_printf(MSG_INFO,
"SAE-PK: SAE authentication without PK disabled based on AP notification");
"SAE-PK: SAE authentication without PK disabled based on AP notification");
disable_wpa_wpa2();
esp_wifi_enable_sae_pk_only_mode_internal();
}
if ((bitmap & TRANSITION_DISABLE_WPA3_ENTERPRISE) &&
wpa_key_mgmt_wpa_ieee8021x(sm->key_mgmt)) {
wpa_key_mgmt_wpa_ieee8021x(sm->key_mgmt)) {
disable_wpa_wpa2();
}
if ((bitmap & TRANSITION_DISABLE_ENHANCED_OPEN) &&
wpa_key_mgmt_owe(sm->key_mgmt)) {
wpa_key_mgmt_owe(sm->key_mgmt)) {
esp_wifi_sta_disable_owe_trans_internal();
}
}

Wyświetl plik

@ -34,5 +34,5 @@ int wpa_ether_send(void *ctx, const u8 *dest, u16 proto,
void wpa_supplicant_transition_disable(struct wpa_sm *sm, u8 bitmap);
int hostapd_send_eapol(const u8 *source, const u8 *sta_addr,
const u8 *data, size_t data_len);
const u8 *data, size_t data_len);
#endif /* WPAS_GLUE_H */

Wyświetl plik

@ -43,7 +43,7 @@ struct wps_rx_param {
int len;
STAILQ_ENTRY(wps_rx_param) bqentry;
};
static STAILQ_HEAD(,wps_rx_param) s_wps_rxq;
static STAILQ_HEAD(, wps_rx_param) s_wps_rxq;
static void *s_wps_task_hdl = NULL;
static void *s_wps_queue = NULL;
@ -85,7 +85,7 @@ static void wps_rxq_init(void)
static void wps_rxq_enqueue(struct wps_rx_param *param)
{
DATA_MUTEX_TAKE();
STAILQ_INSERT_TAIL(&s_wps_rxq,param, bqentry);
STAILQ_INSERT_TAIL(&s_wps_rxq, param, bqentry);
DATA_MUTEX_GIVE();
}
@ -95,7 +95,7 @@ static struct wps_rx_param * wps_rxq_dequeue(void)
DATA_MUTEX_TAKE();
if ((param = STAILQ_FIRST(&s_wps_rxq)) != NULL) {
STAILQ_REMOVE_HEAD(&s_wps_rxq, bqentry);
STAILQ_NEXT(param,bqentry) = NULL;
STAILQ_NEXT(param, bqentry) = NULL;
}
DATA_MUTEX_GIVE();
return param;
@ -107,7 +107,7 @@ static void wps_rxq_deinit(void)
DATA_MUTEX_TAKE();
while ((param = STAILQ_FIRST(&s_wps_rxq)) != NULL) {
STAILQ_REMOVE_HEAD(&s_wps_rxq, bqentry);
STAILQ_NEXT(param,bqentry) = NULL;
STAILQ_NEXT(param, bqentry) = NULL;
os_free(param->buf);
os_free(param);
}
@ -115,7 +115,7 @@ static void wps_rxq_deinit(void)
}
#ifdef USE_WPS_TASK
void wps_task(void *pvParameters )
void wps_task(void *pvParameters)
{
ETSEvent *e;
wps_ioctl_param_t *param;
@ -125,9 +125,9 @@ void wps_task(void *pvParameters )
wpa_printf(MSG_DEBUG, "wps_Task enter");
for (;;) {
if ( TRUE == os_queue_recv(s_wps_queue, &e, OS_BLOCK) ) {
if (TRUE == os_queue_recv(s_wps_queue, &e, OS_BLOCK)) {
if ( (e->sig >= SIG_WPS_ENABLE) && (e->sig < SIG_WPS_NUM) ) {
if ((e->sig >= SIG_WPS_ENABLE) && (e->sig < SIG_WPS_NUM)) {
DATA_MUTEX_TAKE();
if (s_wps_sig_cnt[e->sig]) {
s_wps_sig_cnt[e->sig]--;
@ -276,7 +276,6 @@ static inline int wps_sm_ether_send(struct wps_sm *sm, u16 proto,
return wpa_ether_send(sm, bssid, proto, data, data_len);
}
u8 *wps_sm_alloc_eapol(struct wps_sm *sm, u8 type,
const void *data, u16 data_len,
size_t *msg_len, void **data_pos)
@ -284,7 +283,6 @@ u8 *wps_sm_alloc_eapol(struct wps_sm *sm, u8 type,
return wpa_alloc_eapol(sm, type, data, data_len, msg_len, data_pos);
}
void wps_sm_free_eapol(u8 *buffer)
{
return wpa_free_eapol(buffer);
@ -374,7 +372,7 @@ wps_parse_scan_result(struct wps_scan_ie *scan)
esp_wifi_get_mode(&op_mode);
if ((op_mode != WIFI_MODE_STA)
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
&& (op_mode != WIFI_MODE_APSTA)
&& (op_mode != WIFI_MODE_APSTA)
#endif
) {
return false;
@ -396,7 +394,7 @@ wps_parse_scan_result(struct wps_scan_ie *scan)
int count;
if ((wps_get_type() == WPS_TYPE_PBC && wps_is_selected_pbc_registrar(buf)) ||
(wps_get_type() == WPS_TYPE_PIN && wps_is_addr_authorized(buf, sm->ownaddr, 1))) {
(wps_get_type() == WPS_TYPE_PIN && wps_is_addr_authorized(buf, sm->ownaddr, 1))) {
/* Found one AP with selected registrar true */
sm->ignore_sel_reg = false;
sm->discard_ap_cnt = 0;
@ -417,7 +415,7 @@ wps_parse_scan_result(struct wps_scan_ie *scan)
wpabuf_free(buf);
if (scan->ssid[1] > SSID_MAX_LEN) {
return false;
}
}
esp_wifi_enable_sta_privacy_internal();
os_memset(sm->ssid[0], 0, SSID_MAX_LEN);
os_memcpy(sm->ssid[0], (char *)&scan->ssid[2], (int)scan->ssid[1]);
@ -463,7 +461,6 @@ int wps_send_eap_identity_rsp(u8 id)
goto _err;
}
wpabuf_put_data(eap_buf, sm->identity, sm->identity_len);
buf = wps_sm_alloc_eapol(sm, IEEE802_1X_TYPE_EAP_PACKET, wpabuf_head_u8(eap_buf), wpabuf_len(eap_buf), (size_t *)&len, NULL);
@ -590,14 +587,14 @@ int wps_process_wps_mX_req(u8 *ubuf, int len, enum wps_process_res *res)
if (sm->state == WAIT_START) {
if (expd->opcode != WSC_Start) {
wpa_printf(MSG_DEBUG, "EAP-WSC: Unexpected Op-Code %d "
"in WAIT_START state", expd->opcode);
"in WAIT_START state", expd->opcode);
return ESP_FAIL;
}
wpa_printf(MSG_DEBUG, "EAP-WSC: Received start");
sm->state = WPA_MESG;
} else if (expd->opcode == WSC_Start){
} else if (expd->opcode == WSC_Start) {
wpa_printf(MSG_DEBUG, "EAP-WSC: Unexpected Op-Code %d",
expd->opcode);
expd->opcode);
return ESP_FAIL;
}
@ -617,7 +614,7 @@ int wps_process_wps_mX_req(u8 *ubuf, int len, enum wps_process_res *res)
if (tlen > 50000) {
wpa_printf(MSG_ERROR, "EAP-WSC: Invalid Message Length");
return ESP_FAIL;
}
}
wpa_printf(MSG_DEBUG, "rx frag msg id:%d, flag:%d, frag_len: %d, tot_len: %d, be_tot_len:%d", sm->current_identifier, flag, frag_len, tlen, be_tot_len);
if (ESP_OK != wps_enrollee_process_msg_frag(&wps_buf, tlen, tbuf, frag_len, flag)) {
if (wps_buf) {
@ -710,8 +707,6 @@ _err:
return ret;
}
int wps_tx_start(void)
{
struct wps_sm *sm = gWpsSm;
@ -825,7 +820,7 @@ int wps_finish(void)
os_free(config);
}
eloop_cancel_timeout(wifi_station_wps_success, NULL, NULL);
eloop_register_timeout(1, 0, wifi_station_wps_success, NULL, NULL);
eloop_register_timeout(1, 0, wifi_station_wps_success, NULL, NULL);
ret = 0;
} else {
@ -1021,7 +1016,7 @@ int wps_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len)
wpa_printf(MSG_DEBUG, "error: receive eapol response frame!");
ret = 0;
break;
case EAP_CODE_REQUEST: {
case EAP_CODE_REQUEST:
eap_type = ((u8 *)ehdr)[sizeof(*ehdr)];
switch (eap_type) {
case EAP_TYPE_IDENTITY:
@ -1058,7 +1053,6 @@ int wps_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len)
break;
}
break;
}
default:
break;
}
@ -1658,7 +1652,7 @@ int wifi_station_wps_start(void)
eloop_register_timeout(120, 0, wifi_station_wps_timeout, NULL, NULL);
switch (wps_get_status()) {
case WPS_STATUS_DISABLE: {
case WPS_STATUS_DISABLE:
sm->is_wps_scan = true;
wps_build_public_key(sm->wps, NULL);
@ -1672,7 +1666,6 @@ int wifi_station_wps_start(void)
sm->wps->dh_privkey = NULL;
wifi_wps_scan(NULL, NULL);
break;
}
case WPS_STATUS_SCANNING:
sm->scan_cnt = 0;
eloop_cancel_timeout(wifi_station_wps_timeout, NULL, NULL);

Wyświetl plik

@ -41,20 +41,20 @@ typedef struct {
} wps_ioctl_param_t;
#ifdef ESP_SUPPLICANT
enum wps_sm_state{
WAIT_START,
WPA_MESG,
WPA_FAIL
enum wps_sm_state {
WAIT_START,
WPA_MESG,
WPA_FAIL
};
#endif /* ESP_SUPPLICANT */
#define WPS_IGNORE_SEL_REG_MAX_CNT 4
#define WPS_IGNORE_SEL_REG_MAX_CNT 4
#define WPS_MAX_DIS_AP_NUM 10
#define WPS_MAX_DIS_AP_NUM 10
/* Bssid of the discard AP which is discarded for not select reg or other reason */
struct discard_ap_list_t{
u8 bssid[6];
struct discard_ap_list_t {
u8 bssid[6];
};
#ifndef MAX_PASSPHRASE_LEN

Wyświetl plik

@ -65,7 +65,6 @@ components_not_formatted_temporary:
- "/components/esp_phy/"
- "/components/esp_pm/"
- "/components/esp_rom/"
- "/components/esp_wifi/"
- "/components/esp-tls/"
- "/components/esptool_py/"
- "/components/fatfs/"
@ -95,7 +94,6 @@ components_not_formatted_temporary:
- "/components/vfs/"
- "/components/wear_levelling/"
- "/components/wifi_provisioning/"
- "/components/wpa_supplicant/"
- "/components/xtensa/"
- "/examples/bluetooth/"
- "/examples/build_system/"
@ -133,6 +131,8 @@ components_not_formatted_permanent:
- "/components/xtensa/include/xtensa/"
# FAT FS (upstream source code)
- "/components/fatfs/src/"
# wpa_supplicant upstream code
- "/components/wpa_supplicant/src/"
# Nginx HTTP parser (upstream source code)
- "/components/http_parser/"
# Argtable (upstream source code)