mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-12-15 01:48:20 +08:00
feat(wpa_supplicant): sync include and port files with idf@664bf793
This commit is contained in:
@@ -44,7 +44,9 @@ extern "C" {
|
||||
/* Crypto callback functions */
|
||||
const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs;
|
||||
/* Mesh crypto callback functions */
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S2)
|
||||
const mesh_crypto_funcs_t g_wifi_default_mesh_crypto_funcs;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Supplicant initialization
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Hardware crypto support Copyright 2017 Espressif Systems (Shanghai) PTE LTD
|
||||
// Hardware crypto support Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -12,11 +12,12 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef ESP_WPA2_H
|
||||
#define ESP_WPA2_H
|
||||
#ifndef _ESP_WPA2_H
|
||||
#define _ESP_WPA2_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_wifi_crypto_types.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_wifi_crypto_types.h"
|
||||
#include "esp_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -78,10 +79,10 @@ typedef struct {
|
||||
.wps_type = type, \
|
||||
.crypto_funcs = &g_wifi_default_wps_crypto_funcs, \
|
||||
.factory_info = { \
|
||||
.manufacturer = "ESPRESSIF", \
|
||||
.model_number = "ESP8266", \
|
||||
.model_name = "ESPRESSIF IOT", \
|
||||
.device_name = "ESP STATION", \
|
||||
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(manufacturer, "ESPRESSIF") \
|
||||
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(model_number, "ESP8266") \
|
||||
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(model_name, "ESPRESSIF IOT") \
|
||||
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(device_name, "ESP STATION") \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ void wpa_debug_close_file(void);
|
||||
*/
|
||||
void wpa_debug_print_timestamp(void);
|
||||
|
||||
#ifdef DEBUG_PRINT
|
||||
/**
|
||||
* wpa_printf - conditional printf
|
||||
* @level: priority level (MSG_*) of the message
|
||||
@@ -58,8 +59,17 @@ void wpa_debug_print_timestamp(void);
|
||||
*
|
||||
* Note: New line '\n' is added to the end of the text when printing to stdout.
|
||||
*/
|
||||
//#define DEBUG_PRINT
|
||||
//#define MSG_PRINT
|
||||
#define wpa_printf(level,fmt, args...) ESP_LOG_LEVEL_LOCAL(level, TAG, fmt, ##args)
|
||||
|
||||
void wpa_dump_mem(char* desc, uint8_t *addr, uint16_t len);
|
||||
static inline void wpa_hexdump_ascii(int level, const char *title, const u8 *buf, size_t len)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static inline void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf, size_t len)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* wpa_hexdump - conditional hex dump
|
||||
@@ -72,19 +82,6 @@ void wpa_debug_print_timestamp(void);
|
||||
* output may be directed to stdout, stderr, and/or syslog based on
|
||||
* configuration. The contents of buf is printed out has hex dump.
|
||||
*/
|
||||
#ifdef DEBUG_PRINT
|
||||
#define wpa_printf(level,fmt, args...) ESP_LOG_LEVEL_LOCAL(level, TAG, fmt, ##args)
|
||||
|
||||
static inline void wpa_hexdump_ascii(int level, const char *title, const u8 *buf, size_t len)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static inline void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf, size_t len)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len);
|
||||
|
||||
static inline void wpa_hexdump_buf(int level, const char *title,
|
||||
@@ -148,13 +145,14 @@ void wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
|
||||
void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf,
|
||||
size_t len);
|
||||
#else
|
||||
#define wpa_printf(level,fmt, args...)
|
||||
#define wpa_hexdump(...)
|
||||
#define wpa_hexdump_buf(...)
|
||||
#define wpa_hexdump_key(...)
|
||||
#define wpa_hexdump_buf_key(...)
|
||||
#define wpa_hexdump_ascii(...)
|
||||
#define wpa_hexdump_ascii_key(...)
|
||||
#define wpa_printf(level,fmt, args...) do {} while(0)
|
||||
#define wpa_hexdump(...) do {} while(0)
|
||||
#define wpa_dump_mem(...) do {} while(0)
|
||||
#define wpa_hexdump_buf(...) do {} while(0)
|
||||
#define wpa_hexdump_key(...) do {} while(0)
|
||||
#define wpa_hexdump_buf_key(...) do {} while(0)
|
||||
#define wpa_hexdump_ascii(...) do {} while(0)
|
||||
#define wpa_hexdump_ascii_key(...) do {} while(0)
|
||||
#endif
|
||||
|
||||
#define wpa_auth_logger
|
||||
|
||||
@@ -38,7 +38,7 @@ void wpabuf_free(struct wpabuf *buf);
|
||||
void * wpabuf_put(struct wpabuf *buf, size_t len);
|
||||
struct wpabuf * wpabuf_concat(struct wpabuf *a, struct wpabuf *b);
|
||||
struct wpabuf * wpabuf_zeropad(struct wpabuf *buf, size_t len);
|
||||
void wpabuf_printf(struct wpabuf *buf, char *fmt, ...) PRINTF_FORMAT(2, 3);
|
||||
void wpabuf_printf(struct wpabuf *buf, const char *fmt, ...) PRINTF_FORMAT(2, 3);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
#ifndef BYTESWAP_H
|
||||
#define BYTESWAP_H
|
||||
|
||||
#include <machine/endian.h>
|
||||
|
||||
/* Swap bytes in 16 bit value. */
|
||||
#ifndef __bswap_16
|
||||
#ifdef __GNUC__
|
||||
# define __bswap_16(x) \
|
||||
(__extension__ \
|
||||
@@ -18,8 +21,10 @@ __bswap_16 (unsigned short int __bsx)
|
||||
return ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8));
|
||||
}
|
||||
#endif
|
||||
#endif // __bswap_16
|
||||
|
||||
/* Swap bytes in 32 bit value. */
|
||||
#ifndef __bswap_32
|
||||
#ifdef __GNUC__
|
||||
# define __bswap_32(x) \
|
||||
(__extension__ \
|
||||
@@ -34,7 +39,9 @@ __bswap_32 (unsigned int __bsx)
|
||||
(((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24));
|
||||
}
|
||||
#endif
|
||||
#endif // __bswap_32
|
||||
|
||||
#ifndef __bswap_64
|
||||
#if defined __GNUC__ && __GNUC__ >= 2
|
||||
/* Swap bytes in 64 bit value. */
|
||||
# define __bswap_constant_64(x) \
|
||||
@@ -61,5 +68,6 @@ __bswap_32 (unsigned int __bsx)
|
||||
} \
|
||||
__r.__ll; }))
|
||||
#endif
|
||||
#endif // __bswap_64
|
||||
|
||||
#endif /* BYTESWAP_H */
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#ifndef _ENDIAN_H_
|
||||
#define _ENDIAN_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include "byteswap.h"
|
||||
|
||||
#ifndef BIG_ENDIAN
|
||||
@@ -81,9 +83,7 @@ typedef __uint64_t uint64_t;
|
||||
* Host to big endian, host to little endian, big endian to host, and little
|
||||
* endian to host byte order functions as detailed in byteorder(9).
|
||||
*/
|
||||
#if 1 //BYTE_ORDER == _LITTLE_ENDIAN
|
||||
#define __bswap16 __bswap_16
|
||||
#define __bswap32 __bswap_32
|
||||
#if BYTE_ORDER == _LITTLE_ENDIAN
|
||||
#define htobe16(x) bswap16((x))
|
||||
#define htobe32(x) bswap32((x))
|
||||
#define htobe64(x) bswap64((x))
|
||||
|
||||
@@ -19,12 +19,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "esp_err.h"
|
||||
#include "rom/ets_sys.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
// #include "esp32/rom/ets_sys.h"
|
||||
#include "esp_libc.h"
|
||||
|
||||
typedef long os_time_t;
|
||||
typedef time_t os_time_t;
|
||||
|
||||
/**
|
||||
* os_sleep - Sleep (sec, usec)
|
||||
@@ -35,7 +33,16 @@ void os_sleep(os_time_t sec, os_time_t usec);
|
||||
|
||||
struct os_time {
|
||||
os_time_t sec;
|
||||
os_time_t usec;
|
||||
suseconds_t usec;
|
||||
};
|
||||
|
||||
struct os_tm {
|
||||
int sec; /* 0..59 or 60 for leap seconds */
|
||||
int min; /* 0..59 */
|
||||
int hour; /* 0..23 */
|
||||
int day; /* 1..31 */
|
||||
int month; /* 1..12 */
|
||||
int year; /* Four digit year */
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -79,6 +86,7 @@ int os_get_time(struct os_time *t);
|
||||
int os_mktime(int year, int month, int day, int hour, int min, int sec,
|
||||
os_time_t *t);
|
||||
|
||||
int os_gmtime(os_time_t t, struct os_tm *tm);
|
||||
|
||||
/**
|
||||
* os_daemonize - Run in the background (detach from the controlling terminal)
|
||||
@@ -192,6 +200,19 @@ char * os_readfile(const char *name, size_t *len);
|
||||
* these functions need to be implemented in os_*.c file for the target system.
|
||||
*/
|
||||
|
||||
#ifndef os_malloc
|
||||
#define os_malloc(s) malloc((s))
|
||||
#endif
|
||||
#ifndef os_realloc
|
||||
#define os_realloc(p, s) realloc((p), (s))
|
||||
#endif
|
||||
#ifndef os_zalloc
|
||||
#define os_zalloc(s) calloc(1, (s))
|
||||
#endif
|
||||
#ifndef os_free
|
||||
#define os_free(p) free((p))
|
||||
#endif
|
||||
|
||||
#ifndef os_bzero
|
||||
#define os_bzero(s, n) bzero(s, n)
|
||||
#endif
|
||||
@@ -222,6 +243,7 @@ char * ets_strdup(const char *s);
|
||||
#define os_memcmp_const(s1, s2, n) memcmp((s1), (s2), (n))
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef os_strlen
|
||||
#define os_strlen(s) strlen(s)
|
||||
#endif
|
||||
@@ -252,12 +274,14 @@ char * ets_strdup(const char *s);
|
||||
#define os_strncpy(d, s, n) strncpy((d), (s), (n))
|
||||
#endif
|
||||
#ifndef os_strrchr
|
||||
//hard cold
|
||||
#define os_strrchr(s, c) NULL
|
||||
#define os_strrchr(s, c) strrchr((s), (c))
|
||||
#endif
|
||||
#ifndef os_strstr
|
||||
#define os_strstr(h, n) strstr((h), (n))
|
||||
#endif
|
||||
#ifndef os_strlcpy
|
||||
#define os_strlcpy(d, s, n) strlcpy((d), (s), (n))
|
||||
#endif
|
||||
|
||||
#ifndef os_snprintf
|
||||
#ifdef _MSC_VER
|
||||
@@ -271,60 +295,4 @@ static inline int os_snprintf_error(size_t size, int res)
|
||||
{
|
||||
return res < 0 || (unsigned int) res >= size;
|
||||
}
|
||||
|
||||
/**
|
||||
* os_strlcpy - Copy a string with size bound and NUL-termination
|
||||
* @dest: Destination
|
||||
* @src: Source
|
||||
* @siz: Size of the target buffer
|
||||
* Returns: Total length of the target string (length of src) (not including
|
||||
* NUL-termination)
|
||||
*
|
||||
* This function matches in behavior with the strlcpy(3) function in OpenBSD.
|
||||
*/
|
||||
size_t os_strlcpy(char *dest, const char *src, size_t siz);
|
||||
|
||||
void *_xmalloc(size_t n);
|
||||
void _xfree(void *ptr);
|
||||
void *_xrealloc(void *ptr, size_t n);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP8266
|
||||
/**
|
||||
* @brief save IRQ state and disable IRQ
|
||||
*
|
||||
* @return saved IRQ state
|
||||
*/
|
||||
static inline uint32_t arch_local_irq_save(void)
|
||||
{
|
||||
uint32_t tmp;
|
||||
|
||||
__asm__ __volatile__ ("rsil %0, 3" : "=a" (tmp) :: "memory");
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief restore IRQ state
|
||||
*
|
||||
* @param tmp saved IRQ state
|
||||
*/
|
||||
static inline void arch_local_irq_restore(uint32_t tmp)
|
||||
{
|
||||
__asm__ __volatile__ ("wsr %0, ps" :: "a" (tmp) : "memory");
|
||||
}
|
||||
|
||||
#define local_irq_declare(_t) uint32_t (_t)
|
||||
#define local_irq_save(_t) (_t) = arch_local_irq_save()
|
||||
#define local_irq_restore(_t) arch_local_irq_restore(_t)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* OS_H */
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
|
||||
#if CONFIG_WPA_MBEDTLS_CRYPTO
|
||||
#define USE_MBEDTLS_CRYPTO 1
|
||||
#else
|
||||
#define CONFIG_TLS_INTERNAL_CLIENT
|
||||
#define CONFIG_TLSV12
|
||||
#endif
|
||||
|
||||
#if CONFIG_WPA_DEBUG_PRINT
|
||||
#define DEBUG_PRINT
|
||||
#endif
|
||||
|
||||
#if CONFIG_WPA_TLS_V12
|
||||
#define CONFIG_TLSV12
|
||||
#endif
|
||||
|
||||
#endif /* _SUPPLICANT_OPT_H */
|
||||
|
||||
@@ -21,55 +21,31 @@
|
||||
* this file to work correctly. Note that these implementations are only
|
||||
* examples and are not optimized for speed.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
#include "os.h"
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include "esp_system.h"
|
||||
#include "utils/common.h"
|
||||
|
||||
void *_xmalloc(size_t n)
|
||||
int os_get_time(struct os_time *t)
|
||||
{
|
||||
void *return_addr = (void *)__builtin_return_address(0);
|
||||
|
||||
return _heap_caps_malloc(n, MALLOC_CAP_8BIT, return_addr, 0);
|
||||
struct timeval tv;
|
||||
int ret = gettimeofday(&tv, NULL);
|
||||
t->sec = (os_time_t) tv.tv_sec;
|
||||
t->usec = tv.tv_usec;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void _xfree(void *ptr)
|
||||
unsigned long os_random(void)
|
||||
{
|
||||
void *return_addr = (void *)__builtin_return_address(0);
|
||||
|
||||
_heap_caps_free(ptr, return_addr, 0);
|
||||
return esp_random();
|
||||
}
|
||||
|
||||
void *_xrealloc(void *ptr, size_t n)
|
||||
int os_get_random(unsigned char *buf, size_t len)
|
||||
{
|
||||
void *return_addr = (void *)__builtin_return_address(0);
|
||||
|
||||
return _heap_caps_realloc(ptr, n, MALLOC_CAP_8BIT, return_addr, 0);
|
||||
}
|
||||
|
||||
int os_get_time(struct os_time* t)
|
||||
{
|
||||
int res = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
uint32_t esp_random(void);
|
||||
|
||||
int ICACHE_FLASH_ATTR os_get_random(unsigned char* buf, size_t len)
|
||||
{
|
||||
int i, j;
|
||||
unsigned long tmp;
|
||||
|
||||
for (i = 0; i < ((len + 3) & ~3) / 4; i++) {
|
||||
tmp = esp_random();
|
||||
|
||||
for (j = 0; j < 4; j++) {
|
||||
if ((i * 4 + j) < len) {
|
||||
buf[i * 4 + j] = (uint8_t)(tmp >> (j * 8));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
esp_fill_random(buf, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user