Update tools to latest IDF
This commit is contained in:
parent
f0b7959425
commit
7e0811ec56
@ -290,7 +290,6 @@ void initWiFi()
|
||||
{
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
nvs_flash_init();
|
||||
system_init();
|
||||
tcpip_adapter_init();
|
||||
esp_event_loop_init(WiFiGenericClass::_eventCallback, NULL);
|
||||
esp_wifi_init(&cfg);
|
||||
|
@ -29,6 +29,7 @@ extern "C" {
|
||||
|
||||
#include "esp32-hal-i2c.h"
|
||||
#include "Wire.h"
|
||||
#include "Arduino.h"
|
||||
|
||||
TwoWire::TwoWire(uint8_t bus_num)
|
||||
:num(bus_num & 1)
|
||||
|
@ -13,7 +13,7 @@ compiler.warning_flags.all=-Wall -Wextra
|
||||
|
||||
compiler.path={runtime.tools.xtensa-esp32-elf-gcc.path}/bin/
|
||||
compiler.sdk.path={runtime.platform.path}/tools/sdk
|
||||
compiler.cpreprocessor.flags=-DESP_PLATFORM -DMBEDTLS_CONFIG_FILE='"mbedtls/esp_config.h"' -DHAVE_CONFIG_H "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/bt" "-I{compiler.sdk.path}/include/driver" "-I{compiler.sdk.path}/include/esp32" "-I{compiler.sdk.path}/include/freertos" "-I{compiler.sdk.path}/include/log" "-I{compiler.sdk.path}/include/vfs" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/nvs_flash" "-I{compiler.sdk.path}/include/spi_flash" "-I{compiler.sdk.path}/include/tcpip_adapter" "-I{compiler.sdk.path}/include/expat" "-I{compiler.sdk.path}/include/json" "-I{compiler.sdk.path}/include/mbedtls" "-I{compiler.sdk.path}/include/nghttp" "-I{compiler.sdk.path}/include/lwip"
|
||||
compiler.cpreprocessor.flags=-DESP_PLATFORM -DMBEDTLS_CONFIG_FILE='"mbedtls/esp_config.h"' -DHAVE_CONFIG_H "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/bt" "-I{compiler.sdk.path}/include/driver" "-I{compiler.sdk.path}/include/esp32" "-I{compiler.sdk.path}/include/freertos" "-I{compiler.sdk.path}/include/log" "-I{compiler.sdk.path}/include/vfs" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/nvs_flash" "-I{compiler.sdk.path}/include/spi_flash" "-I{compiler.sdk.path}/include/tcpip_adapter" "-I{compiler.sdk.path}/include/xtensa-debug-module" "-I{compiler.sdk.path}/include/wpa_supplicant" "-I{compiler.sdk.path}/include/expat" "-I{compiler.sdk.path}/include/json" "-I{compiler.sdk.path}/include/mbedtls" "-I{compiler.sdk.path}/include/nghttp" "-I{compiler.sdk.path}/include/lwip"
|
||||
|
||||
compiler.c.cmd=xtensa-esp32-elf-gcc
|
||||
compiler.c.flags=-c {compiler.warning_flags} -Os -g3 -Wpointer-arith -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -ffunction-sections -fdata-sections -mlongcalls -nostdlib -MMD -std=gnu99 -fstrict-volatile-bitfields
|
||||
@ -26,7 +26,7 @@ compiler.S.flags=-c -g3 -x assembler-with-cpp -MMD -mlongcalls
|
||||
|
||||
compiler.c.elf.cmd=xtensa-esp32-elf-gcc
|
||||
compiler.c.elf.flags="-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" -nostdlib -T esp32_out.ld -T esp32.common.ld -T esp32.rom.ld -T esp32.peripherals.ld -u call_user_start_cpu0 -Wl,--gc-sections -Wl,-static -Wl,--undefined=uxTopUsedPriority
|
||||
compiler.c.elf.libs=-lgcc -lc -lm -lhal -lcore -lnet80211 -lphy -lrtc -lpp -lwpa -lsmartconfig -lbtdm_app -lbt -ldriver -lesp32 -lcrypto -lexpat -lfreertos -ljson -llog -llwip -lmbedtls -lnghttp -lnvs_flash -lspi_flash -ltcpip_adapter -lnewlib -lvfs
|
||||
compiler.c.elf.libs=-lbt -lbtdm_app -lc -lcoexist -lcore -ldriver -lesp32 -lexpat -lfreertos -lg -lhal -ljson -llog -llwip -lm -lmbedtls -lnet80211 -lnewlib -lnghttp -lnvs_flash -lopenssl -lphy -lpp -lrtc -lsmartconfig -lspi_flash -ltcpip_adapter -lvfs -lwpa -lwpa_supplicant -lxtensa-debug-module
|
||||
|
||||
compiler.as.cmd=xtensa-esp32-elf-as
|
||||
|
||||
|
Binary file not shown.
@ -28,37 +28,36 @@ extern "C" {
|
||||
*
|
||||
* This function should be called only once, before any other BT functions are called.
|
||||
*/
|
||||
void bt_controller_init();
|
||||
void bt_controller_init(void);
|
||||
|
||||
/** @brief: vhci_host_callback
|
||||
/** @brief vhci_host_callback
|
||||
* used for vhci call host function to notify what host need to do
|
||||
*
|
||||
* notify_host_send_available: notify host can send packet to controller
|
||||
* notify_host_recv: notify host that controller has packet send to host
|
||||
*/
|
||||
typedef struct vhci_host_callback {
|
||||
|
||||
void (*notify_host_send_available)(void);
|
||||
int (*notify_host_recv)(uint8_t *data, uint16_t len);
|
||||
} vhci_host_callback_t;
|
||||
|
||||
/** @brief: API_vhci_host_check_send_available
|
||||
/** @brief API_vhci_host_check_send_available
|
||||
* used for check actively if the host can send packet to controller or not.
|
||||
* return true for ready to send, false means cannot send packet
|
||||
* @return true for ready to send, false means cannot send packet
|
||||
*/
|
||||
bool API_vhci_host_check_send_available(void);
|
||||
|
||||
/** @brief: API_vhci_host_send_packet
|
||||
/** @brief API_vhci_host_send_packet
|
||||
* host send packet to controller
|
||||
* param data is the packet point, the param len is the packet length
|
||||
* return void
|
||||
* @param data the packet point
|
||||
*,@param len the packet length
|
||||
*/
|
||||
void API_vhci_host_send_packet(uint8_t *data, uint16_t len);
|
||||
|
||||
/** @brief: API_vhci_host_register_callback
|
||||
/** @brief API_vhci_host_register_callback
|
||||
* register the vhci referece callback, the call back
|
||||
* struct defined by vhci_host_callback structure.
|
||||
* param is the vhci_host_callback type variable
|
||||
* @param callback vhci_host_callback type variable
|
||||
*/
|
||||
void API_vhci_host_register_callback(const vhci_host_callback_t *callback);
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define CONFIG_ULP_COPROC_RESERVE_MEM 0
|
||||
#define CONFIG_ESPTOOLPY_BAUD 921600
|
||||
#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-"
|
||||
#define CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC 1
|
||||
#define CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX 0
|
||||
#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384
|
||||
#define CONFIG_ESP32_ENABLE_STACK_WIFI 1
|
||||
@ -28,8 +29,10 @@
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHMODE_DIO 1
|
||||
#define CONFIG_PYTHON "python"
|
||||
#define CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 1
|
||||
#define CONFIG_ESPTOOLPY_COMPRESSED 1
|
||||
#define CONFIG_PARTITION_TABLE_FILENAME "partitions_singleapp.csv"
|
||||
#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1
|
||||
#define CONFIG_PARTITION_TABLE_SINGLE_APP 1
|
||||
#define CONFIG_WIFI_ENABLED 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ_80M 1
|
||||
@ -43,6 +46,7 @@
|
||||
#define CONFIG_LWIP_SO_REUSE 1
|
||||
#define CONFIG_FREERTOS_CORETIMER_0 1
|
||||
#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv"
|
||||
#define CONFIG_FREERTOS_ISR_STACKSIZE 1536
|
||||
#define CONFIG_OPTIMIZATION_LEVEL_DEBUG 1
|
||||
#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32
|
||||
#define CONFIG_ESPTOOLPY_BAUD_921600B 1
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "soc/gpio_struct.h"
|
||||
#include "soc/rtc_io_reg.h"
|
||||
#include "soc/io_mux_reg.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "rom/gpio.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
@ -27,43 +28,43 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define GPIO_SEL_0 (BIT(0)) /* Pin 0 selected */
|
||||
#define GPIO_SEL_1 (BIT(1)) /* Pin 1 selected */
|
||||
#define GPIO_SEL_2 (BIT(2)) /* Pin 2 selected */
|
||||
#define GPIO_SEL_3 (BIT(3)) /* Pin 3 selected */
|
||||
#define GPIO_SEL_4 (BIT(4)) /* Pin 4 selected */
|
||||
#define GPIO_SEL_5 (BIT(5)) /* Pin 5 selected */
|
||||
#define GPIO_SEL_6 (BIT(6)) /* Pin 6 selected */
|
||||
#define GPIO_SEL_7 (BIT(7)) /* Pin 7 selected */
|
||||
#define GPIO_SEL_8 (BIT(8)) /* Pin 8 selected */
|
||||
#define GPIO_SEL_9 (BIT(9)) /* Pin 9 selected */
|
||||
#define GPIO_SEL_10 (BIT(10)) /* Pin 10 selected */
|
||||
#define GPIO_SEL_11 (BIT(11)) /* Pin 11 selected */
|
||||
#define GPIO_SEL_12 (BIT(12)) /* Pin 12 selected */
|
||||
#define GPIO_SEL_13 (BIT(13)) /* Pin 13 selected */
|
||||
#define GPIO_SEL_14 (BIT(14)) /* Pin 14 selected */
|
||||
#define GPIO_SEL_15 (BIT(15)) /* Pin 15 selected */
|
||||
#define GPIO_SEL_16 (BIT(16)) /* Pin 16 selected */
|
||||
#define GPIO_SEL_17 (BIT(17)) /* Pin 17 selected */
|
||||
#define GPIO_SEL_18 (BIT(18)) /* Pin 18 selected */
|
||||
#define GPIO_SEL_19 (BIT(19)) /* Pin 19 selected */
|
||||
#define GPIO_SEL_0 (BIT(0)) /*!< Pin 0 selected */
|
||||
#define GPIO_SEL_1 (BIT(1)) /*!< Pin 1 selected */
|
||||
#define GPIO_SEL_2 (BIT(2)) /*!< Pin 2 selected */
|
||||
#define GPIO_SEL_3 (BIT(3)) /*!< Pin 3 selected */
|
||||
#define GPIO_SEL_4 (BIT(4)) /*!< Pin 4 selected */
|
||||
#define GPIO_SEL_5 (BIT(5)) /*!< Pin 5 selected */
|
||||
#define GPIO_SEL_6 (BIT(6)) /*!< Pin 6 selected */
|
||||
#define GPIO_SEL_7 (BIT(7)) /*!< Pin 7 selected */
|
||||
#define GPIO_SEL_8 (BIT(8)) /*!< Pin 8 selected */
|
||||
#define GPIO_SEL_9 (BIT(9)) /*!< Pin 9 selected */
|
||||
#define GPIO_SEL_10 (BIT(10)) /*!< Pin 10 selected */
|
||||
#define GPIO_SEL_11 (BIT(11)) /*!< Pin 11 selected */
|
||||
#define GPIO_SEL_12 (BIT(12)) /*!< Pin 12 selected */
|
||||
#define GPIO_SEL_13 (BIT(13)) /*!< Pin 13 selected */
|
||||
#define GPIO_SEL_14 (BIT(14)) /*!< Pin 14 selected */
|
||||
#define GPIO_SEL_15 (BIT(15)) /*!< Pin 15 selected */
|
||||
#define GPIO_SEL_16 (BIT(16)) /*!< Pin 16 selected */
|
||||
#define GPIO_SEL_17 (BIT(17)) /*!< Pin 17 selected */
|
||||
#define GPIO_SEL_18 (BIT(18)) /*!< Pin 18 selected */
|
||||
#define GPIO_SEL_19 (BIT(19)) /*!< Pin 19 selected */
|
||||
|
||||
#define GPIO_SEL_21 (BIT(21)) /* Pin 21 selected */
|
||||
#define GPIO_SEL_22 (BIT(22)) /* Pin 22 selected */
|
||||
#define GPIO_SEL_23 (BIT(23)) /* Pin 23 selected */
|
||||
#define GPIO_SEL_21 (BIT(21)) /*!< Pin 21 selected */
|
||||
#define GPIO_SEL_22 (BIT(22)) /*!< Pin 22 selected */
|
||||
#define GPIO_SEL_23 (BIT(23)) /*!< Pin 23 selected */
|
||||
|
||||
#define GPIO_SEL_25 (BIT(25)) /* Pin 25 selected */
|
||||
#define GPIO_SEL_26 (BIT(26)) /* Pin 26 selected */
|
||||
#define GPIO_SEL_27 (BIT(27)) /* Pin 27 selected */
|
||||
#define GPIO_SEL_25 (BIT(25)) /*!< Pin 25 selected */
|
||||
#define GPIO_SEL_26 (BIT(26)) /*!< Pin 26 selected */
|
||||
#define GPIO_SEL_27 (BIT(27)) /*!< Pin 27 selected */
|
||||
|
||||
#define GPIO_SEL_32 ((uint64_t)(((uint64_t)1)<<32)) /* Pin 32 selected */
|
||||
#define GPIO_SEL_33 ((uint64_t)(((uint64_t)1)<<33)) /* Pin 33 selected */
|
||||
#define GPIO_SEL_34 ((uint64_t)(((uint64_t)1)<<34)) /* Pin 34 selected */
|
||||
#define GPIO_SEL_35 ((uint64_t)(((uint64_t)1)<<35)) /* Pin 35 selected */
|
||||
#define GPIO_SEL_36 ((uint64_t)(((uint64_t)1)<<36)) /* Pin 36 selected */
|
||||
#define GPIO_SEL_37 ((uint64_t)(((uint64_t)1)<<37)) /* Pin 37 selected */
|
||||
#define GPIO_SEL_38 ((uint64_t)(((uint64_t)1)<<38)) /* Pin 38 selected */
|
||||
#define GPIO_SEL_39 ((uint64_t)(((uint64_t)1)<<39)) /* Pin 39 selected */
|
||||
#define GPIO_SEL_32 ((uint64_t)(((uint64_t)1)<<32)) /*!< Pin 32 selected */
|
||||
#define GPIO_SEL_33 ((uint64_t)(((uint64_t)1)<<33)) /*!< Pin 33 selected */
|
||||
#define GPIO_SEL_34 ((uint64_t)(((uint64_t)1)<<34)) /*!< Pin 34 selected */
|
||||
#define GPIO_SEL_35 ((uint64_t)(((uint64_t)1)<<35)) /*!< Pin 35 selected */
|
||||
#define GPIO_SEL_36 ((uint64_t)(((uint64_t)1)<<36)) /*!< Pin 36 selected */
|
||||
#define GPIO_SEL_37 ((uint64_t)(((uint64_t)1)<<37)) /*!< Pin 37 selected */
|
||||
#define GPIO_SEL_38 ((uint64_t)(((uint64_t)1)<<38)) /*!< Pin 38 selected */
|
||||
#define GPIO_SEL_39 ((uint64_t)(((uint64_t)1)<<39)) /*!< Pin 39 selected */
|
||||
|
||||
#define GPIO_PIN_REG_0 PERIPHS_IO_MUX_GPIO0_U
|
||||
#define GPIO_PIN_REG_1 PERIPHS_IO_MUX_U0TXD_U
|
||||
@ -117,222 +118,193 @@ extern const uint32_t GPIO_PIN_MUX_REG[GPIO_PIN_COUNT];
|
||||
#define GPIO_IS_VALID_OUTPUT_GPIO(gpio_num) ((GPIO_IS_VALID_GPIO(gpio_num)) && (gpio_num < 34)) //to decide whether it can be a valid GPIO number of output mode
|
||||
|
||||
typedef enum {
|
||||
GPIO_NUM_0 = 0,
|
||||
GPIO_NUM_1 = 1,
|
||||
GPIO_NUM_2 = 2,
|
||||
GPIO_NUM_3 = 3,
|
||||
GPIO_NUM_4 = 4,
|
||||
GPIO_NUM_5 = 5,
|
||||
GPIO_NUM_6 = 6,
|
||||
GPIO_NUM_7 = 7,
|
||||
GPIO_NUM_8 = 8,
|
||||
GPIO_NUM_9 = 9,
|
||||
GPIO_NUM_10 = 10,
|
||||
GPIO_NUM_11 = 11,
|
||||
GPIO_NUM_12 = 12,
|
||||
GPIO_NUM_13 = 13,
|
||||
GPIO_NUM_14 = 14,
|
||||
GPIO_NUM_15 = 15,
|
||||
GPIO_NUM_16 = 16,
|
||||
GPIO_NUM_17 = 17,
|
||||
GPIO_NUM_18 = 18,
|
||||
GPIO_NUM_19 = 19,
|
||||
GPIO_NUM_0 = 0, /*!< GPIO0, input and output */
|
||||
GPIO_NUM_1 = 1, /*!< GPIO1, input and output */
|
||||
GPIO_NUM_2 = 2, /*!< GPIO2, input and output */
|
||||
GPIO_NUM_3 = 3, /*!< GPIO3, input and output */
|
||||
GPIO_NUM_4 = 4, /*!< GPIO4, input and output */
|
||||
GPIO_NUM_5 = 5, /*!< GPIO5, input and output */
|
||||
GPIO_NUM_6 = 6, /*!< GPIO6, input and output */
|
||||
GPIO_NUM_7 = 7, /*!< GPIO7, input and output */
|
||||
GPIO_NUM_8 = 8, /*!< GPIO8, input and output */
|
||||
GPIO_NUM_9 = 9, /*!< GPIO9, input and output */
|
||||
GPIO_NUM_10 = 10, /*!< GPIO10, input and output */
|
||||
GPIO_NUM_11 = 11, /*!< GPIO11, input and output */
|
||||
GPIO_NUM_12 = 12, /*!< GPIO12, input and output */
|
||||
GPIO_NUM_13 = 13, /*!< GPIO13, input and output */
|
||||
GPIO_NUM_14 = 14, /*!< GPIO14, input and output */
|
||||
GPIO_NUM_15 = 15, /*!< GPIO15, input and output */
|
||||
GPIO_NUM_16 = 16, /*!< GPIO16, input and output */
|
||||
GPIO_NUM_17 = 17, /*!< GPIO17, input and output */
|
||||
GPIO_NUM_18 = 18, /*!< GPIO18, input and output */
|
||||
GPIO_NUM_19 = 19, /*!< GPIO19, input and output */
|
||||
|
||||
GPIO_NUM_21 = 21,
|
||||
GPIO_NUM_22 = 22,
|
||||
GPIO_NUM_23 = 23,
|
||||
GPIO_NUM_21 = 21, /*!< GPIO21, input and output */
|
||||
GPIO_NUM_22 = 22, /*!< GPIO22, input and output */
|
||||
GPIO_NUM_23 = 23, /*!< GPIO23, input and output */
|
||||
|
||||
GPIO_NUM_25 = 25,
|
||||
GPIO_NUM_26 = 26,
|
||||
GPIO_NUM_27 = 27,
|
||||
GPIO_NUM_25 = 25, /*!< GPIO25, input and output */
|
||||
GPIO_NUM_26 = 26, /*!< GPIO26, input and output */
|
||||
GPIO_NUM_27 = 27, /*!< GPIO27, input and output */
|
||||
|
||||
GPIO_NUM_32 = 32,
|
||||
GPIO_NUM_33 = 33,
|
||||
GPIO_NUM_34 = 34, /*input mode only */
|
||||
GPIO_NUM_35 = 35, /*input mode only */
|
||||
GPIO_NUM_36 = 36, /*input mode only */
|
||||
GPIO_NUM_37 = 37, /*input mode only */
|
||||
GPIO_NUM_38 = 38, /*input mode only */
|
||||
GPIO_NUM_39 = 39, /*input mode only */
|
||||
GPIO_NUM_32 = 32, /*!< GPIO32, input and output */
|
||||
GPIO_NUM_33 = 33, /*!< GPIO32, input and output */
|
||||
GPIO_NUM_34 = 34, /*!< GPIO34, input mode only */
|
||||
GPIO_NUM_35 = 35, /*!< GPIO35, input mode only */
|
||||
GPIO_NUM_36 = 36, /*!< GPIO36, input mode only */
|
||||
GPIO_NUM_37 = 37, /*!< GPIO37, input mode only */
|
||||
GPIO_NUM_38 = 38, /*!< GPIO38, input mode only */
|
||||
GPIO_NUM_39 = 39, /*!< GPIO39, input mode only */
|
||||
} gpio_num_t;
|
||||
|
||||
typedef enum {
|
||||
GPIO_INTR_DISABLE = 0, /* disable GPIO interrupt */
|
||||
GPIO_INTR_POSEDGE = 1, /* GPIO interrupt type : rising edge */
|
||||
GPIO_INTR_NEGEDGE = 2, /* GPIO interrupt type : falling edge */
|
||||
GPIO_INTR_ANYEDGE = 3, /* GPIO interrupt type : both rising and falling edge */
|
||||
GPIO_INTR_LOW_LEVEL = 4, /* GPIO interrupt type : input low level trigger */
|
||||
GPIO_INTR_HIGH_LEVEL = 5, /* GPIO interrupt type : input high level trigger */
|
||||
GPIO_INTR_DISABLE = 0, /*!< Disable GPIO interrupt */
|
||||
GPIO_INTR_POSEDGE = 1, /*!< GPIO interrupt type : rising edge */
|
||||
GPIO_INTR_NEGEDGE = 2, /*!< GPIO interrupt type : falling edge */
|
||||
GPIO_INTR_ANYEDGE = 3, /*!< GPIO interrupt type : both rising and falling edge */
|
||||
GPIO_INTR_LOW_LEVEL = 4, /*!< GPIO interrupt type : input low level trigger */
|
||||
GPIO_INTR_HIGH_LEVEL = 5, /*!< GPIO interrupt type : input high level trigger */
|
||||
GPIO_INTR_MAX,
|
||||
} gpio_int_type_t;
|
||||
|
||||
typedef enum {
|
||||
GPIO_MODE_INPUT = GPIO_MODE_DEF_INPUT, /* GPIO mode : input only */
|
||||
GPIO_MODE_OUTPUT = GPIO_MODE_DEF_OUTPUT, /* GPIO mode : output only mode */
|
||||
GPIO_MODE_OUTPUT_OD = ((GPIO_MODE_DEF_OUTPUT)|(GPIO_MODE_DEF_OD)), /* GPIO mode : output only with open-drain mode */
|
||||
GPIO_MODE_INPUT_OUTPUT_OD = ((GPIO_MODE_DEF_INPUT)|(GPIO_MODE_DEF_OUTPUT)|(GPIO_MODE_DEF_OD)), /* GPIO mode : output and input with open-drain mode*/
|
||||
GPIO_MODE_INPUT_OUTPUT = ((GPIO_MODE_DEF_INPUT)|(GPIO_MODE_DEF_OUTPUT)), /* GPIO mode : output and input mode */
|
||||
GPIO_MODE_INPUT = GPIO_MODE_DEF_INPUT, /*!< GPIO mode : input only */
|
||||
GPIO_MODE_OUTPUT = GPIO_MODE_DEF_OUTPUT, /*!< GPIO mode : output only mode */
|
||||
GPIO_MODE_OUTPUT_OD = ((GPIO_MODE_DEF_OUTPUT)|(GPIO_MODE_DEF_OD)), /*!< GPIO mode : output only with open-drain mode */
|
||||
GPIO_MODE_INPUT_OUTPUT_OD = ((GPIO_MODE_DEF_INPUT)|(GPIO_MODE_DEF_OUTPUT)|(GPIO_MODE_DEF_OD)), /*!< GPIO mode : output and input with open-drain mode*/
|
||||
GPIO_MODE_INPUT_OUTPUT = ((GPIO_MODE_DEF_INPUT)|(GPIO_MODE_DEF_OUTPUT)), /*!< GPIO mode : output and input mode */
|
||||
} gpio_mode_t;
|
||||
|
||||
typedef enum {
|
||||
GPIO_PULLUP_DISABLE = 0x0, /* disable GPIO pull-up resistor */
|
||||
GPIO_PULLUP_ENABLE = 0x1, /* enable GPIO pull-up resistor */
|
||||
GPIO_PULLUP_DISABLE = 0x0, /*!< Disable GPIO pull-up resistor */
|
||||
GPIO_PULLUP_ENABLE = 0x1, /*!< Enable GPIO pull-up resistor */
|
||||
} gpio_pullup_t;
|
||||
|
||||
typedef enum {
|
||||
GPIO_PULLDOWN_DISABLE = 0x0, /* disable GPIO pull-down resistor */
|
||||
GPIO_PULLDOWN_ENABLE = 0x1, /* enable GPIO pull-down resistor */
|
||||
GPIO_PULLDOWN_DISABLE = 0x0, /*!< Disable GPIO pull-down resistor */
|
||||
GPIO_PULLDOWN_ENABLE = 0x1, /*!< Enable GPIO pull-down resistor */
|
||||
} gpio_pulldown_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t pin_bit_mask; /* GPIO pin: set with bit mask, each bit maps to a GPIO */
|
||||
gpio_mode_t mode; /* GPIO mode: set input/output mode */
|
||||
gpio_pullup_t pull_up_en; /* GPIO pull-up */
|
||||
gpio_pulldown_t pull_down_en; /* GPIO pull-down */
|
||||
gpio_int_type_t intr_type; /* GPIO interrupt type */
|
||||
uint64_t pin_bit_mask; /*!< GPIO pin: set with bit mask, each bit maps to a GPIO */
|
||||
gpio_mode_t mode; /*!< GPIO mode: set input/output mode */
|
||||
gpio_pullup_t pull_up_en; /*!< GPIO pull-up */
|
||||
gpio_pulldown_t pull_down_en; /*!< GPIO pull-down */
|
||||
gpio_int_type_t intr_type; /*!< GPIO interrupt type */
|
||||
} gpio_config_t;
|
||||
|
||||
typedef enum {
|
||||
GPIO_LOW_LEVEL = 0,
|
||||
GPIO_HIGH_LEVEL = 1,
|
||||
GPIO_LEVEL_ERR,
|
||||
} gpio_level_t;
|
||||
|
||||
typedef enum {
|
||||
GPIO_PULLUP_ONLY, /* Pad pull up */
|
||||
GPIO_PULLDOWN_ONLY, /* Pad pull down */
|
||||
GPIO_PULLUP_PULLDOWN, /* Pad pull up + pull down*/
|
||||
GPIO_FLOATING, /* Pad floating */
|
||||
GPIO_PULLUP_ONLY, /*!< Pad pull up */
|
||||
GPIO_PULLDOWN_ONLY, /*!< Pad pull down */
|
||||
GPIO_PULLUP_PULLDOWN, /*!< Pad pull up + pull down*/
|
||||
GPIO_FLOATING, /*!< Pad floating */
|
||||
} gpio_pull_mode_t;
|
||||
|
||||
typedef void (*gpio_event_callback)(gpio_num_t gpio_intr_num);
|
||||
|
||||
/** \defgroup Driver_APIs Driver APIs
|
||||
* @brief Driver APIs
|
||||
*/
|
||||
|
||||
/** @addtogroup Driver_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** \defgroup GPIO_Driver_APIs GPIO Driver APIs
|
||||
* @brief GPIO APIs
|
||||
*/
|
||||
|
||||
/** @addtogroup GPIO_Driver_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief GPIO common configuration
|
||||
* @brief GPIO common configuration
|
||||
*
|
||||
* Use this Function ,Configure GPIO's Mode,pull-up,PullDown,IntrType
|
||||
* Configure GPIO's Mode,pull-up,PullDown,IntrType
|
||||
*
|
||||
* @parameter[in] pGPIOConfig
|
||||
* pGPIOConfig.pin_bit_mask : Configure GPIO pins bits,set this parameter with bit mask.
|
||||
* If you want to configure GPIO34 and GPIO16, pin_bit_mask=GPIO_Pin_16|GPIO_Pin_34;
|
||||
* pGPIOConfig.mode : Configure GPIO mode,such as output ,input...
|
||||
* pGPIOConfig.pull_up_en : Enable or Disable pull-up
|
||||
* pGPIOConfig.pull_down_en : Enable or Disable pull-down
|
||||
* pGPIOConfig.intr_type : Configure GPIO interrupt trigger type
|
||||
* @return ESP_OK: success ;
|
||||
* ESP_ERR_INVALID_ARG: parameter error
|
||||
* ESP_FAIL : GPIO error
|
||||
* @param pGPIOConfig Pointer to GPIO configure struct
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*
|
||||
*/
|
||||
esp_err_t gpio_config(gpio_config_t *pGPIOConfig);
|
||||
|
||||
|
||||
/**
|
||||
* @brief GPIO set interrupt trigger type
|
||||
* @brief GPIO set interrupt trigger type
|
||||
*
|
||||
* @parameter[in] gpio_num : GPIO number.
|
||||
* If you want to set output level of GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
* @parameter[in] intr_type: interrupt type, select from gpio_int_type_t
|
||||
* @param gpio_num GPIO number. If you want to set output level of GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
* @param intr_type Interrupt type, select from gpio_int_type_t
|
||||
*
|
||||
* @return ESP_OK : success
|
||||
* ESP_ERR_INVALID_ARG: parameter error
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*
|
||||
*/
|
||||
esp_err_t gpio_set_intr_type(gpio_num_t gpio_num, gpio_int_type_t intr_type);
|
||||
|
||||
/**
|
||||
* @brief enable GPIO module interrupt signal
|
||||
* @brief Enable GPIO module interrupt signal
|
||||
*
|
||||
* @parameter[in] gpio_num : GPIO number.
|
||||
* If you want to set output level of GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
* @param gpio_num GPIO number. If you want to set output level of GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
*
|
||||
* @return ESP_OK : success
|
||||
* ESP_ERR_INVALID_ARG: parameter error
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*
|
||||
*/
|
||||
esp_err_t gpio_intr_enable(gpio_num_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief disable GPIO module interrupt signal
|
||||
* @brief Disable GPIO module interrupt signal
|
||||
*
|
||||
* @parameter[in] gpio_num : GPIO number.
|
||||
* If you want to set output level of GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
* @param gpio_num GPIO number. If you want to set output level of GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
*
|
||||
* @return ESP_OK : success
|
||||
* ESP_ERR_INVALID_ARG: parameter error
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*
|
||||
*/
|
||||
esp_err_t gpio_intr_disable(gpio_num_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief GPIO set output level
|
||||
* @brief GPIO set output level
|
||||
*
|
||||
* @parameter[in] gpio_num : GPIO number.
|
||||
* If you want to set output level of GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
* @parameter[in] level : Output level. 0: low ; 1: high
|
||||
* @param gpio_num GPIO number. If you want to set output level of GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
* @param level Output level. 0: low ; 1: high
|
||||
*
|
||||
* @return ESP_OK : success
|
||||
* ESP_FAIL : GPIO error
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - GPIO_IS_VALID_GPIO GPIO number error
|
||||
*
|
||||
*/
|
||||
esp_err_t gpio_set_level(gpio_num_t gpio_num, uint32_t level);
|
||||
|
||||
/**
|
||||
* @brief GPIO get input level
|
||||
* @brief GPIO get input level
|
||||
*
|
||||
* @parameter[in] gpio_num : GPIO number.
|
||||
* If you want to get level of pin GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
* @param gpio_num GPIO number. If you want to get level of pin GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
*
|
||||
* @return 0 : the GPIO input level is 0
|
||||
* 1 : the GPIO input level is 1
|
||||
* @return
|
||||
* - 0 the GPIO input level is 0
|
||||
* - 1 the GPIO input level is 1
|
||||
*
|
||||
*/
|
||||
int gpio_get_level(gpio_num_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief GPIO set direction
|
||||
* @brief GPIO set direction
|
||||
*
|
||||
* Configure GPIO direction,such as output_only,input_only,output_and_input
|
||||
*
|
||||
* @parameter[in] gpio_num : Configure GPIO pins number,it should be GPIO number.
|
||||
* If you want to set direction of GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
* @parameter[in] mode : Configure GPIO direction,such as output_only,input_only,...
|
||||
* @param gpio_num Configure GPIO pins number, it should be GPIO number. If you want to set direction of GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
* @param mode GPIO direction
|
||||
*
|
||||
* @return ESP_OK : success
|
||||
* ESP_ERR_INVALID_ARG : fail
|
||||
* ESP_FAIL : GPIO error
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG GPIO error
|
||||
*
|
||||
*/
|
||||
esp_err_t gpio_set_direction(gpio_num_t gpio_num, gpio_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief GPIO set pull
|
||||
* @brief GPIO set pull
|
||||
*
|
||||
* User this Function,configure GPIO pull mode,such as pull-up,pull-down
|
||||
*
|
||||
* @parameter[in] gpio_num : Configure GPIO pins number,it should be GPIO number.
|
||||
* If you want to set pull up or down mode for GPIO16,gpio_num should be GPIO_NUM_16 (16);
|
||||
* @parameter[in] pull : Configure GPIO pull up/down mode,such as pullup_only,pulldown_only,pullup_and_pulldown,...
|
||||
* @param gpio_num GPIO number. If you want to set pull up or down mode for GPIO16,gpio_num should be GPIO_NUM_16 (16);
|
||||
* @param pull GPIO pull up/down mode.
|
||||
*
|
||||
* @return ESP_OK : success
|
||||
* ESP_ERR_INVALID_ARG : fail
|
||||
* ESP_FAIL : GPIO error
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG : Parameter error
|
||||
*
|
||||
*/
|
||||
esp_err_t gpio_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull);
|
||||
@ -340,121 +312,140 @@ esp_err_t gpio_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull);
|
||||
/**
|
||||
* @brief enable GPIO wake-up function.
|
||||
*
|
||||
* @param gpio_num_t gpio_num : GPIO number.
|
||||
* @param gpio_num GPIO number.
|
||||
*
|
||||
* @param gpio_int_type_t intr_type : only GPIO_INTR_LOLEVEL\GPIO_INTR_HILEVEL can be used
|
||||
* @param intr_type GPIO wake-up type. Only GPIO_INTR_LOW_LEVEL\GPIO_INTR_HIGH_LEVEL can be used.
|
||||
*
|
||||
* @return ESP_OK: success
|
||||
* ESP_ERR_INVALID_ARG: parameter error
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t gpio_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t intr_type);
|
||||
|
||||
/**
|
||||
* @brief disable GPIO wake-up function.
|
||||
* @brief Disable GPIO wake-up function.
|
||||
*
|
||||
* @param gpio_num_t gpio_num: GPIO number
|
||||
* @param gpio_num GPIO number
|
||||
*
|
||||
* @return ESP_OK: success
|
||||
* ESP_ERR_INVALID_ARG: parameter error
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t gpio_wakeup_disable(gpio_num_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief register GPIO interrupt handler, the handler is an ISR.
|
||||
* The handler will be attached to the same CPU core that this function is running on.
|
||||
* @note
|
||||
* Users should know that which CPU is running and then pick a INUM that is not used by system.
|
||||
* We can find the information of INUM and interrupt level in soc.h.
|
||||
* TODO: to move INUM options to menu_config
|
||||
* @parameter uint32_t gpio_intr_num : GPIO interrupt number,check the info in soc.h, and please see the core-isa.h for more details
|
||||
* @parameter void (* fn)(void* ) : interrupt handler function.
|
||||
* Note that the handler function MUST be defined with attribution of "IRAM_ATTR".
|
||||
* @parameter void * arg : parameter for handler function
|
||||
*
|
||||
* @return ESP_OK : success ;
|
||||
* ESP_FAIL: gpio error
|
||||
* @param gpio_intr_num GPIO interrupt number,check the info in soc.h, and please see the core-isa.h for more details
|
||||
* @param fn Interrupt handler function.
|
||||
*
|
||||
* @note
|
||||
* Note that the handler function MUST be defined with attribution of "IRAM_ATTR".
|
||||
*
|
||||
* @param arg Parameter for handler function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success ;
|
||||
* - ESP_ERR_INVALID_ARG GPIO error
|
||||
*/
|
||||
esp_err_t gpio_isr_register(uint32_t gpio_intr_num, void (*fn)(void*), void * arg);
|
||||
|
||||
/**
|
||||
* *************** ATTENTION ********************/
|
||||
/**
|
||||
*
|
||||
* Each GPIO has its own separate configuration register, so we do not use
|
||||
* a lock to serialize access to them. This works under the assumption that
|
||||
* no situation will occur where two tasks try to configure the same GPIO
|
||||
* pin simultaneously. It is up to the application developer to guarantee this.
|
||||
*@attention
|
||||
* Each GPIO has its own separate configuration register, so we do not use
|
||||
* a lock to serialize access to them. This works under the assumption that
|
||||
* no situation will occur where two tasks try to configure the same GPIO
|
||||
* pin simultaneously. It is up to the application developer to guarantee this.
|
||||
*/
|
||||
|
||||
|
||||
/*----------EXAMPLE TO CONIFGURE GPIO AS OUTPUT ------------ */
|
||||
/* gpio_config_t io_conf;
|
||||
/**
|
||||
*----------EXAMPLE TO CONIFGURE GPIO AS OUTPUT ------------ *
|
||||
* @code{c}
|
||||
* gpio_config_t io_conf;
|
||||
* io_conf.intr_type = GPIO_INTR_DISABLE; //disable interrupt
|
||||
* io_conf.mode = GPIO_MODE_OUTPUT; //set as output mode
|
||||
* io_conf.pin_bit_mask = GPIO_SEL_18 | GPIO_SEL_19; //bit mask of the pins that you want to set,e.g.GPIO18/19
|
||||
* io_conf.pull_down_en = 0; //disable pull-down mode
|
||||
* io_conf.pull_up_en = 0; //disable pull-up mode
|
||||
* gpio_config(&io_conf); //configure GPIO with the given settings
|
||||
* @endcode
|
||||
**/
|
||||
/*----------EXAMPLE TO CONIFGURE GPIO AS OUTPUT ------------ */
|
||||
/* io_conf.intr_type = GPIO_INTR_POSEDGE; //set posedge interrupt
|
||||
|
||||
/**
|
||||
*----------EXAMPLE TO CONIFGURE GPIO AS OUTPUT ------------ *
|
||||
* @code{c}
|
||||
* io_conf.intr_type = GPIO_INTR_POSEDGE; //set posedge interrupt
|
||||
* io_conf.mode = GPIO_MODE_INPUT; //set as input
|
||||
* io_conf.pin_bit_mask = GPIO_SEL_4 | GPIO_SEL_5; //bit mask of the pins that you want to set, e.g.,GPIO4/5
|
||||
* io_conf.pull_down_en = 0; //disable pull-down mode
|
||||
* io_conf.pull_up_en = 1; //enable pull-up mode
|
||||
* gpio_config(&io_conf); //configure GPIO with the given settings
|
||||
*----------EXAMPLE TO SET ISR HANDLER ----------------------*/
|
||||
/* gpio_isr_register(18,gpio_intr_test,NULL); //hook the isr handler for GPIO interrupt
|
||||
* //the first parameter is INUM, you can pick one form interrupt level 1/2 which is not used by the system.
|
||||
* //NOTE1:user should arrange the INUMs that used, better not to use a same INUM for different interrupt.
|
||||
* //NOTE2:do not pick the INUM that already occupied by the system.
|
||||
* //NOTE3:refer to soc.h to check which INUMs that can be used.
|
||||
*-------------EXAMPLE OF HANDLER FUNCTION-------------------*/
|
||||
/*#include "esp_attr.h"
|
||||
* @endcode
|
||||
*/
|
||||
/**
|
||||
*----------EXAMPLE TO SET ISR HANDLER ----------------------
|
||||
* @code{c}
|
||||
* //the first parameter is INUM, you can pick one form interrupt level 1/2 which is not used by the system.
|
||||
* gpio_isr_register(18,gpio_intr_test,NULL); //hook the isr handler for GPIO interrupt
|
||||
* @endcode
|
||||
* @note
|
||||
* 1. user should arrange the INUMs that used, better not to use a same INUM for different interrupt.
|
||||
* 2. do not pick the INUM that already occupied by the system.
|
||||
* 3. refer to soc.h to check which INUMs that can be used.
|
||||
*/
|
||||
/**
|
||||
*-------------EXAMPLE OF HANDLER FUNCTION-------------------*
|
||||
* @code{c}
|
||||
* #include "esp_attr.h"
|
||||
* void IRAM_ATTR gpio_intr_test(void* arg)
|
||||
*{
|
||||
* //GPIO intr process
|
||||
* ets_printf("in gpio_intr\n");
|
||||
* uint32_t gpio_num = 0;
|
||||
* uint32_t gpio_intr_status = READ_PERI_REG(GPIO_STATUS_REG); //read status to get interrupt status for GPIO0-31
|
||||
* uint32_t gpio_intr_status_h = READ_PERI_REG(GPIO_STATUS1_REG);//read status1 to get interrupt status for GPIO32-39
|
||||
* SET_PERI_REG_MASK(GPIO_STATUS_W1TC_REG, gpio_intr_status); //Clear intr for gpio0-gpio31
|
||||
* SET_PERI_REG_MASK(GPIO_STATUS1_W1TC_REG, gpio_intr_status_h); //Clear intr for gpio32-39
|
||||
* do {
|
||||
* if(gpio_num < 32) {
|
||||
* if(gpio_intr_status & BIT(gpio_num)) { //gpio0-gpio31
|
||||
* ets_printf("Intr GPIO%d ,val: %d\n",gpio_num,gpio_get_level(gpio_num));
|
||||
* //This is an isr handler, you should post an event to process it in RTOS queue.
|
||||
* }
|
||||
* } else {
|
||||
* if(gpio_intr_status_h & BIT(gpio_num - 32)) {
|
||||
* ets_printf("Intr GPIO%d, val : %d\n",gpio_num,gpio_get_level(gpio_num));
|
||||
* //This is an isr handler, you should post an event to process it in RTOS queue.
|
||||
* }
|
||||
* }
|
||||
* } while(++gpio_num < GPIO_PIN_COUNT);
|
||||
*}
|
||||
*----EXAMPLE OF I2C CONFIG AND PICK SIGNAL FOR IO MATRIX---*/
|
||||
/* gpio_config_t io_conf;
|
||||
* io_conf.intr_type = GPIO_INTR_DISABLE; //disable interrupt
|
||||
* io_conf.mode = GPIO_MODE_INPUT_OUTPUT_OD; //set as output mode
|
||||
* io_conf.pin_bit_mask = GPIO_SEL_21 | GPIO_SEL_22; //bit mask of the pins that you want to set,e.g.GPIO21/22
|
||||
* io_conf.pull_down_en = 0; //disable pull-down mode
|
||||
* io_conf.pull_up_en = 1; //enable pull-up mode
|
||||
* gpio_config(&io_conf); //configure GPIO with the given settings
|
||||
* gpio_matrix_out(21, EXT_I2C_SCL_O_IDX, 0, 0); //set output signal for io_matrix
|
||||
* gpio_matrix_out(22, EXT_I2C_SDA_O_IDX, 0, 0); //set output signal for io_matrix
|
||||
* gpio_matrix_in( 22, EXT_I2C_SDA_I_IDX, 0); //set input signal for io_matrix
|
||||
* {
|
||||
* //GPIO intr process
|
||||
* ets_printf("in gpio_intr\n");
|
||||
* uint32_t gpio_num = 0;
|
||||
* uint32_t gpio_intr_status = READ_PERI_REG(GPIO_STATUS_REG); //read status to get interrupt status for GPIO0-31
|
||||
* uint32_t gpio_intr_status_h = READ_PERI_REG(GPIO_STATUS1_REG);//read status1 to get interrupt status for GPIO32-39
|
||||
* SET_PERI_REG_MASK(GPIO_STATUS_W1TC_REG, gpio_intr_status); //Clear intr for gpio0-gpio31
|
||||
* SET_PERI_REG_MASK(GPIO_STATUS1_W1TC_REG, gpio_intr_status_h); //Clear intr for gpio32-39
|
||||
* do {
|
||||
* if(gpio_num < 32) {
|
||||
* if(gpio_intr_status & BIT(gpio_num)) { //gpio0-gpio31
|
||||
* ets_printf("Intr GPIO%d ,val: %d\n",gpio_num,gpio_get_level(gpio_num));
|
||||
* //This is an isr handler, you should post an event to process it in RTOS queue.
|
||||
* }
|
||||
* } else {
|
||||
* if(gpio_intr_status_h & BIT(gpio_num - 32)) {
|
||||
* ets_printf("Intr GPIO%d, val : %d\n",gpio_num,gpio_get_level(gpio_num));
|
||||
* //This is an isr handler, you should post an event to process it in RTOS queue.
|
||||
* }
|
||||
* }
|
||||
* } while(++gpio_num < GPIO_PIN_COUNT);
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
|
||||
/**
|
||||
*----EXAMPLE OF I2C CONFIG AND PICK SIGNAL FOR IO MATRIX---*
|
||||
* @code{c}
|
||||
* gpio_config_t io_conf;
|
||||
* io_conf.intr_type = GPIO_INTR_DISABLE; //disable interrupt
|
||||
* io_conf.mode = GPIO_MODE_INPUT_OUTPUT_OD; //set as output mode
|
||||
* io_conf.pin_bit_mask = GPIO_SEL_21 | GPIO_SEL_22; //bit mask of the pins that you want to set,e.g.GPIO21/22
|
||||
* io_conf.pull_down_en = 0; //disable pull-down mode
|
||||
* io_conf.pull_up_en = 1; //enable pull-up mode
|
||||
* gpio_config(&io_conf); //configure GPIO with the given settings
|
||||
* gpio_matrix_out(21, EXT_I2C_SCL_O_IDX, 0, 0); //set output signal for io_matrix
|
||||
* gpio_matrix_out(22, EXT_I2C_SDA_O_IDX, 0, 0); //set output signal for io_matrix
|
||||
* gpio_matrix_in( 22, EXT_I2C_SDA_I_IDX, 0); //set input signal for io_matrix
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -30,68 +30,68 @@ extern "C" {
|
||||
#define LEDC_REF_CLK_HZ (1*1000000)
|
||||
|
||||
typedef enum {
|
||||
LEDC_HIGH_SPEED_MODE = 0, /*LEDC high speed speed_mode */
|
||||
LEDC_HIGH_SPEED_MODE = 0, /*!< LEDC high speed speed_mode */
|
||||
//in this version, we only support high speed speed_mode. We will access low speed speed_mode later
|
||||
//LEDC_LOW_SPEED_MODE, /*LEDC low speed speed_mode */
|
||||
LEDC_SPEED_MODE_MAX,
|
||||
//LEDC_LOW_SPEED_MODE, /*!< LEDC low speed speed_mode */
|
||||
LEDC_SPEED_MODE_MAX, /*!< LEDC speed limit */
|
||||
} ledc_mode_t;
|
||||
|
||||
typedef enum {
|
||||
LEDC_INTR_DISABLE = 0, /*Disable LEDC interrupt */
|
||||
LEDC_INTR_FADE_END, /*Enable LEDC interrupt */
|
||||
LEDC_INTR_DISABLE = 0, /*!< Disable LEDC interrupt */
|
||||
LEDC_INTR_FADE_END, /*!< Enable LEDC interrupt */
|
||||
} ledc_intr_type_t;
|
||||
|
||||
typedef enum {
|
||||
LEDC_DUTY_DIR_DECREASE = 0, /*LEDC duty decrease direction */
|
||||
LEDC_DUTY_DIR_INCREASE = 1, /*LEDC duty increase direction */
|
||||
LEDC_DUTY_DIR_DECREASE = 0, /*!< LEDC duty decrease direction */
|
||||
LEDC_DUTY_DIR_INCREASE = 1, /*!< LEDC duty increase direction */
|
||||
} ledc_duty_direction_t;
|
||||
|
||||
typedef enum {
|
||||
LEDC_REF_TICK = 0, /*LEDC timer clock divided from reference tick(1Mhz) */
|
||||
LEDC_APB_CLK, /*LEDC timer clock divided from APB clock(80Mhz)*/
|
||||
LEDC_REF_TICK = 0, /*!< LEDC timer clock divided from reference tick(1Mhz) */
|
||||
LEDC_APB_CLK, /*!< LEDC timer clock divided from APB clock(80Mhz)*/
|
||||
} ledc_clk_src_t;
|
||||
|
||||
typedef enum {
|
||||
LEDC_TIMER_0 = 0, /*LEDC source timer TIMER0 */
|
||||
LEDC_TIMER_1, /*LEDC source timer TIMER1 */
|
||||
LEDC_TIMER_2, /*LEDC source timer TIMER2 */
|
||||
LEDC_TIMER_3, /*LEDC source timer TIMER3 */
|
||||
LEDC_TIMER_0 = 0, /*!< LEDC source timer TIMER0 */
|
||||
LEDC_TIMER_1, /*!< LEDC source timer TIMER1 */
|
||||
LEDC_TIMER_2, /*!< LEDC source timer TIMER2 */
|
||||
LEDC_TIMER_3, /*!< LEDC source timer TIMER3 */
|
||||
} ledc_timer_t;
|
||||
|
||||
typedef enum {
|
||||
LEDC_CHANNEL_0 = 0, /*LEDC channel 0 */
|
||||
LEDC_CHANNEL_1, /*LEDC channel 1 */
|
||||
LEDC_CHANNEL_2, /*LEDC channel 2 */
|
||||
LEDC_CHANNEL_3, /*LEDC channel 3 */
|
||||
LEDC_CHANNEL_4, /*LEDC channel 4 */
|
||||
LEDC_CHANNEL_5, /*LEDC channel 5 */
|
||||
LEDC_CHANNEL_6, /*LEDC channel 6 */
|
||||
LEDC_CHANNEL_7, /*LEDC channel 7 */
|
||||
LEDC_CHANNEL_0 = 0, /*!< LEDC channel 0 */
|
||||
LEDC_CHANNEL_1, /*!< LEDC channel 1 */
|
||||
LEDC_CHANNEL_2, /*!< LEDC channel 2 */
|
||||
LEDC_CHANNEL_3, /*!< LEDC channel 3 */
|
||||
LEDC_CHANNEL_4, /*!< LEDC channel 4 */
|
||||
LEDC_CHANNEL_5, /*!< LEDC channel 5 */
|
||||
LEDC_CHANNEL_6, /*!< LEDC channel 6 */
|
||||
LEDC_CHANNEL_7, /*!< LEDC channel 7 */
|
||||
} ledc_channel_t;
|
||||
|
||||
typedef enum {
|
||||
LEDC_TIMER_10_BIT = 10, /*LEDC PWM depth 10Bit */
|
||||
LEDC_TIMER_11_BIT = 11, /*LEDC PWM depth 11Bit */
|
||||
LEDC_TIMER_12_BIT = 12, /*LEDC PWM depth 12Bit */
|
||||
LEDC_TIMER_13_BIT = 13, /*LEDC PWM depth 13Bit */
|
||||
LEDC_TIMER_14_BIT = 14, /*LEDC PWM depth 14Bit */
|
||||
LEDC_TIMER_15_BIT = 15, /*LEDC PWM depth 15Bit */
|
||||
LEDC_TIMER_10_BIT = 10, /*!< LEDC PWM depth 10Bit */
|
||||
LEDC_TIMER_11_BIT = 11, /*!< LEDC PWM depth 11Bit */
|
||||
LEDC_TIMER_12_BIT = 12, /*!< LEDC PWM depth 12Bit */
|
||||
LEDC_TIMER_13_BIT = 13, /*!< LEDC PWM depth 13Bit */
|
||||
LEDC_TIMER_14_BIT = 14, /*!< LEDC PWM depth 14Bit */
|
||||
LEDC_TIMER_15_BIT = 15, /*!< LEDC PWM depth 15Bit */
|
||||
} ledc_timer_bit_t;
|
||||
|
||||
typedef struct {
|
||||
int gpio_num; /*the LEDC output gpio_num, if you want to use gpio16, gpio_num = 16*/
|
||||
ledc_mode_t speed_mode; /*LEDC speed speed_mode, high-speed mode or low-speed mode*/
|
||||
ledc_channel_t channel; /*LEDC channel(0 - 7)*/
|
||||
ledc_intr_type_t intr_type; /*configure interrupt, Fade interrupt enable or Fade interrupt disable*/
|
||||
ledc_timer_t timer_sel; /*Select the timer source of channel (0 - 3)*/
|
||||
uint32_t duty; /*LEDC channel duty, the duty range is [0, (2**bit_num) - 1], */
|
||||
int gpio_num; /*!< the LEDC output gpio_num, if you want to use gpio16, gpio_num = 16*/
|
||||
ledc_mode_t speed_mode; /*!< LEDC speed speed_mode, high-speed mode or low-speed mode*/
|
||||
ledc_channel_t channel; /*!< LEDC channel(0 - 7)*/
|
||||
ledc_intr_type_t intr_type; /*!< configure interrupt, Fade interrupt enable or Fade interrupt disable*/
|
||||
ledc_timer_t timer_sel; /*!< Select the timer source of channel (0 - 3)*/
|
||||
uint32_t duty; /*!< LEDC channel duty, the duty range is [0, (2**bit_num) - 1], */
|
||||
} ledc_channel_config_t;
|
||||
|
||||
typedef struct {
|
||||
ledc_mode_t speed_mode; /*LEDC speed speed_mode, high-speed mode or low-speed mode*/
|
||||
ledc_timer_bit_t bit_num; /*LEDC channel duty depth*/
|
||||
ledc_timer_t timer_num; /*The timer source of channel (0 - 3)*/
|
||||
uint32_t freq_hz; /*LEDC timer frequency(Hz)*/
|
||||
ledc_mode_t speed_mode; /*!< LEDC speed speed_mode, high-speed mode or low-speed mode*/
|
||||
ledc_timer_bit_t bit_num; /*!< LEDC channel duty depth*/
|
||||
ledc_timer_t timer_num; /*!< The timer source of channel (0 - 3)*/
|
||||
uint32_t freq_hz; /*!< LEDC timer frequency(Hz)*/
|
||||
} ledc_timer_config_t;
|
||||
|
||||
|
||||
@ -100,15 +100,10 @@ typedef struct {
|
||||
*
|
||||
* User this Function, configure LEDC channel with the given channel/output gpio_num/interrupt/source timer/frequency(Hz)/LEDC depth
|
||||
*
|
||||
* @param[in] ledc_channel_config_t
|
||||
* ledc_channel_config_t.speed_mode : LEDC speed speed_mode
|
||||
* ledc_channel_config_t.gpio_num : LEDC output gpio_num, if you want to use gpio16, ledc_channel_config_t.gpio_num = 16
|
||||
* ledc_channel_config_t.channel : LEDC channel(0 - 7)
|
||||
* ledc_channel_config_t.intr_type : configure interrupt, Fade interrupt enable or Fade interrupt disable
|
||||
* ledc_channel_config_t.timer_sel : Select the timer source of channel (0 - 3), high speed channel must bind with high speed timer.
|
||||
* ledc_channel_config_t.duty : LEDC channel duty, the duty range is [0, (2**timer_bit_num) - 1],
|
||||
* @return ESP_OK: success
|
||||
* ESP_ERR_INVALID_ARG: parameter error
|
||||
* @param ledc_conf Pointer of LEDC channel configure struct
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*
|
||||
*/
|
||||
esp_err_t ledc_channel_config(ledc_channel_config_t* ledc_conf);
|
||||
@ -118,14 +113,13 @@ esp_err_t ledc_channel_config(ledc_channel_config_t* ledc_conf);
|
||||
*
|
||||
* User this Function, configure LEDC timer with the given source timer/frequency(Hz)/bit_num
|
||||
*
|
||||
* @param[in] ledc_timer_config_t
|
||||
* ledc_timer_config_t.speed_mode : LEDC speed speed_mode
|
||||
* ledc_timer_config_t.timer_num : Select the timer source of channel (0 - 3)
|
||||
* ledc_timer_config_t.freq_hz : LEDC channel frequency(Hz),
|
||||
* ledc_timer_config_t.bit_num : LEDC channel duty depth
|
||||
* @return ESP_OK: success
|
||||
* ESP_ERR_INVALID_ARG: parameter error
|
||||
* ESP_FAIL: Can not find a proper pre-divider number base on the given frequency and the current bit_num.
|
||||
* @param timer_conf Pointer of LEDC timer configure struct
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Can not find a proper pre-divider number base on the given frequency and the current bit_num.
|
||||
*
|
||||
*/
|
||||
esp_err_t ledc_timer_config(ledc_timer_config_t* timer_conf);
|
||||
@ -136,12 +130,13 @@ esp_err_t ledc_timer_config(ledc_timer_config_t* timer_conf);
|
||||
* Call this function to activate the LEDC updated parameters.
|
||||
* After ledc_set_duty, ledc_set_fade, we need to call this function to update the settings.
|
||||
*
|
||||
* @param[in] speed_mode : select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
*
|
||||
* @param[in] channel : LEDC channel(0-7), select from ledc_channel_t
|
||||
* @param channel LEDC channel(0-7), select from ledc_channel_t
|
||||
*
|
||||
* @return ESP_OK: success
|
||||
* ESP_ERR_INVALID_ARG: parameter error
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*
|
||||
*/
|
||||
esp_err_t ledc_update_duty(ledc_mode_t speed_mode, ledc_channel_t channel);
|
||||
@ -151,12 +146,13 @@ esp_err_t ledc_update_duty(ledc_mode_t speed_mode, ledc_channel_t channel);
|
||||
*
|
||||
* Disable LEDC output, and set idle level
|
||||
*
|
||||
* @param[in] speed_mode : select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
*
|
||||
* @param[in] channel : LEDC channel(0-7), select from ledc_channel_t
|
||||
* @param channel LEDC channel(0-7), select from ledc_channel_t
|
||||
*
|
||||
* @return ESP_OK: success
|
||||
* ESP_ERR_INVALID_ARG: parameter error
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t ledc_stop(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t idle_level);
|
||||
|
||||
@ -165,27 +161,29 @@ esp_err_t ledc_stop(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t idl
|
||||
*
|
||||
* Set LEDC frequency(Hz)
|
||||
*
|
||||
* @param[in] speed_mode : select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
*
|
||||
* @param[in] timer_num : LEDC timer index(0-3), select from ledc_timer_t
|
||||
* @param timer_num LEDC timer index(0-3), select from ledc_timer_t
|
||||
*
|
||||
* @param[in] freq_hz : set the LEDC frequency
|
||||
* @param freq_hz Set the LEDC frequency
|
||||
*
|
||||
* @return ESP_OK: success
|
||||
* ESP_ERR_INVALID_ARG: parameter error
|
||||
* ESP_FAIL: Can not find a proper pre-divider number base on the given frequency and the current bit_num.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Can not find a proper pre-divider number base on the given frequency and the current bit_num.
|
||||
*/
|
||||
esp_err_t ledc_set_freq(ledc_mode_t speed_mode, ledc_timer_t timer_num, uint32_t freq_hz);
|
||||
|
||||
/**
|
||||
* @brief LEDC get channel frequency(Hz)
|
||||
*
|
||||
* @param[in] speed_mode : select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
*
|
||||
* @param[in] timer_num : LEDC timer index(0-3), select from ledc_timer_t
|
||||
* @param timer_num LEDC timer index(0-3), select from ledc_timer_t
|
||||
*
|
||||
* @return 0 : error
|
||||
* others : current LEDC frequency
|
||||
* @return
|
||||
* - 0 error
|
||||
* - Others Current LEDC frequency
|
||||
*
|
||||
*/
|
||||
uint32_t ledc_get_freq(ledc_mode_t speed_mode, ledc_timer_t timer_num);
|
||||
@ -195,27 +193,29 @@ uint32_t ledc_get_freq(ledc_mode_t speed_mode, ledc_timer_t timer_num);
|
||||
*
|
||||
* Set LEDC duty, After the function calls the ledc_update_duty function, the function can take effect.
|
||||
*
|
||||
* @param[in] speed_mode : select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
*
|
||||
* @param[in] channel : LEDC channel(0-7), select from ledc_channel_t
|
||||
* @param channel LEDC channel(0-7), select from ledc_channel_t
|
||||
*
|
||||
* @param[in] duty : set the LEDC duty, the duty range is [0, (2**bit_num) - 1]
|
||||
* @param duty Set the LEDC duty, the duty range is [0, (2**bit_num) - 1]
|
||||
*
|
||||
* @return ESP_OK: success
|
||||
* ESP_ERR_INVALID_ARG: parameter error
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t ledc_set_duty(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t duty);
|
||||
|
||||
/**
|
||||
* @brief LEDC get duty
|
||||
*
|
||||
* @param[in] speed_mode : select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
*
|
||||
* @param[in] channel : LEDC channel(0-7), select from ledc_channel_t
|
||||
* @param channel LEDC channel(0-7), select from ledc_channel_t
|
||||
*
|
||||
*
|
||||
* @return -1: parameter error
|
||||
* other value: current LEDC duty
|
||||
* @return
|
||||
* - (-1) parameter error
|
||||
* - Others Current LEDC duty
|
||||
*
|
||||
*/
|
||||
int ledc_get_duty(ledc_mode_t speed_mode, ledc_channel_t channel);
|
||||
@ -225,22 +225,23 @@ int ledc_get_duty(ledc_mode_t speed_mode, ledc_channel_t channel);
|
||||
*
|
||||
* Set LEDC gradient, After the function calls the ledc_update_duty function, the function can take effect.
|
||||
*
|
||||
* @param[in] speed_mode : select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
*
|
||||
* @param[in] channel : LEDC channel(0-7), select from ledc_channel_t
|
||||
* @param channel LEDC channel(0-7), select from ledc_channel_t
|
||||
*
|
||||
* @param[in] duty : set the start of the gradient duty, the duty range is [0, (2**bit_num) - 1]
|
||||
* @param duty Set the start of the gradient duty, the duty range is [0, (2**bit_num) - 1]
|
||||
*
|
||||
* @param[in] gradule_direction : set the direction of the gradient
|
||||
* @param gradule_direction Set the direction of the gradient
|
||||
*
|
||||
* @param[in] step_num : set the number of the gradient
|
||||
* @param step_num Set the number of the gradient
|
||||
*
|
||||
* @param[in] duty_cyle_num : set how many LEDC tick each time the gradient lasts
|
||||
* @param duty_cyle_num Set how many LEDC tick each time the gradient lasts
|
||||
*
|
||||
* @param[in] duty_scale : set gradient change amplitude
|
||||
* @param duty_scale Set gradient change amplitude
|
||||
*
|
||||
* @return ESP_OK : success
|
||||
* ESP_ERR_INVALID_ARG : parameter error
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t ledc_set_fade(ledc_mode_t speed_mode, uint32_t channel, uint32_t duty, ledc_duty_direction_t gradule_direction,
|
||||
uint32_t step_num, uint32_t duty_cyle_num, uint32_t duty_scale);
|
||||
@ -248,34 +249,37 @@ esp_err_t ledc_set_fade(ledc_mode_t speed_mode, uint32_t channel, uint32_t duty,
|
||||
/**
|
||||
* @brief register LEDC interrupt handler, the handler is an ISR.
|
||||
* The handler will be attached to the same CPU core that this function is running on.
|
||||
* Users should know that which CPU is running and then pick a INUM that is not used by system.
|
||||
* We can find the information of INUM and interrupt level in soc.h.
|
||||
* TODO: to move INUM options to menu_config
|
||||
* @param[in] uint32_t ledc_intr_num : LEDC interrupt number, check the info in soc.h, and please see the core-isa.h for more details
|
||||
* @param[in] void (* fn)(void* ) : interrupt handler function.
|
||||
* Note that the handler function MUST be defined with attribution of "IRAM_ATTR".
|
||||
* @param[in] void * arg : parameter for handler function
|
||||
* @note
|
||||
* Users should know that which CPU is running and then pick a INUM that is not used by system.
|
||||
* We can find the information of INUM and interrupt level in soc.h.
|
||||
* @param ledc_intr_num LEDC interrupt number, check the info in soc.h, and please see the core-isa.h for more details
|
||||
* @param fn Interrupt handler function.
|
||||
* @note
|
||||
* Note that the handler function MUST be defined with attribution of "IRAM_ATTR".
|
||||
* @param arg Parameter for handler function
|
||||
*
|
||||
* @return ESP_OK : success ;
|
||||
* ESP_ERR_INVALID_ARG : function ptr error.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Function pointer error.
|
||||
*/
|
||||
esp_err_t ledc_isr_register(uint32_t ledc_intr_num, void (*fn)(void*), void * arg);
|
||||
|
||||
/**
|
||||
* @brief configure LEDC settings
|
||||
*
|
||||
* @param[in] speed_mode : select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
*
|
||||
* @param[in] timer_sel : timer index(0-3), there are 4 timers in LEDC module
|
||||
* @param timer_sel Timer index(0-3), there are 4 timers in LEDC module
|
||||
*
|
||||
* @param[in] div_num : timer clock divide number, the timer clock is divided from the selected clock source
|
||||
* @param div_num Timer clock divide number, the timer clock is divided from the selected clock source
|
||||
*
|
||||
* @param[in] bit_num : the count number of one period, counter range is 0 ~ ((2 ** bit_num) - 1)
|
||||
* @param bit_num The count number of one period, counter range is 0 ~ ((2 ** bit_num) - 1)
|
||||
*
|
||||
* @param[in] clk_src : select LEDC source clock.
|
||||
* @param clk_src Select LEDC source clock.
|
||||
*
|
||||
* @return -1: parameter error
|
||||
* other value: current LEDC duty
|
||||
* @return
|
||||
* - (-1) Parameter error
|
||||
* - Other Current LEDC duty
|
||||
*
|
||||
*/
|
||||
esp_err_t ledc_timer_set(ledc_mode_t speed_mode, ledc_timer_t timer_sel, uint32_t div_num, uint32_t bit_num, ledc_clk_src_t clk_src);
|
||||
@ -283,13 +287,14 @@ esp_err_t ledc_timer_set(ledc_mode_t speed_mode, ledc_timer_t timer_sel, uint32_
|
||||
/**
|
||||
* @brief reset LEDC timer
|
||||
*
|
||||
* @param[in] speed_mode : select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
*
|
||||
* @param[in] timer_sel : LEDC timer index(0-3), select from ledc_timer_t
|
||||
* @param timer_sel LEDC timer index(0-3), select from ledc_timer_t
|
||||
*
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG: parameter error
|
||||
* ESP_OK: success
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_OK Success
|
||||
*
|
||||
*/
|
||||
esp_err_t ledc_timer_rst(ledc_mode_t speed_mode, uint32_t timer_sel);
|
||||
@ -297,13 +302,14 @@ esp_err_t ledc_timer_rst(ledc_mode_t speed_mode, uint32_t timer_sel);
|
||||
/**
|
||||
* @brief pause LEDC timer counter
|
||||
*
|
||||
* @param[in] speed_mode : select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
*
|
||||
* @param[in] timer_sel : LEDC timer index(0-3), select from ledc_timer_t
|
||||
* @param timer_sel LEDC timer index(0-3), select from ledc_timer_t
|
||||
*
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG: parameter error
|
||||
* ESP_OK: success
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_OK Success
|
||||
*
|
||||
*/
|
||||
esp_err_t ledc_timer_pause(ledc_mode_t speed_mode, uint32_t timer_sel);
|
||||
@ -311,13 +317,14 @@ esp_err_t ledc_timer_pause(ledc_mode_t speed_mode, uint32_t timer_sel);
|
||||
/**
|
||||
* @brief pause LEDC timer resume
|
||||
*
|
||||
* @param[in] speed_mode : select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
*
|
||||
* @param[in] timer_sel : LEDC timer index(0-3), select from ledc_timer_t
|
||||
* @param timer_sel LEDC timer index(0-3), select from ledc_timer_t
|
||||
*
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG: parameter error
|
||||
* ESP_OK: success
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_OK Success
|
||||
*
|
||||
*/
|
||||
esp_err_t ledc_timer_resume(ledc_mode_t speed_mode, uint32_t timer_sel);
|
||||
@ -325,15 +332,16 @@ esp_err_t ledc_timer_resume(ledc_mode_t speed_mode, uint32_t timer_sel);
|
||||
/**
|
||||
* @brief bind LEDC channel with the selected timer
|
||||
*
|
||||
* @param[in] speed_mode : select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode, now we only support high-speed mode. We will access low-speed mode in next version
|
||||
*
|
||||
* @param[in] channel : LEDC channel index(0-7), select from ledc_channel_t
|
||||
* @param channel LEDC channel index(0-7), select from ledc_channel_t
|
||||
*
|
||||
* @param[in] timer_idx : LEDC timer index(0-3), select from ledc_timer_t
|
||||
* @param timer_idx LEDC timer index(0-3), select from ledc_timer_t
|
||||
*
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG: parameter error
|
||||
* ESP_OK: success
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_OK Success
|
||||
*
|
||||
*/
|
||||
esp_err_t ledc_bind_channel_timer(ledc_mode_t speed_mode, uint32_t channel, uint32_t timer_idx);
|
||||
@ -342,44 +350,56 @@ esp_err_t ledc_bind_channel_timer(ledc_mode_t speed_mode, uint32_t channel, uint
|
||||
*
|
||||
*
|
||||
* ----------------EXAMPLE OF LEDC SETTING ---------------------
|
||||
* //1. enable LEDC
|
||||
* periph_module_enable(PERIPH_LEDC_MODULE); //enable LEDC module, or you can not set any register of it.
|
||||
* @code{c}
|
||||
* //1. enable LEDC
|
||||
* //enable LEDC module, or you can not set any register of it.
|
||||
* periph_module_enable(PERIPH_LEDC_MODULE);
|
||||
* @endcode
|
||||
*
|
||||
* //2. set LEDC timer
|
||||
* ledc_timer_config_t timer_conf = {
|
||||
* .bit_num = LEDC_TIMER_12_BIT, //set timer counter bit number
|
||||
* .freq_hz = 1000, //set frequency of pwm, here, 1000Hz
|
||||
* .speed_mode = LEDC_HIGH_SPEED_MODE //timer mode,
|
||||
* .timer_num = LEDC_TIMER_0, //timer number
|
||||
* };
|
||||
* ledc_timer_config(&timer_conf); //setup timer.
|
||||
* @code{c}
|
||||
* //2. set LEDC timer
|
||||
* ledc_timer_config_t timer_conf = {
|
||||
* .bit_num = LEDC_TIMER_12_BIT, //set timer counter bit number
|
||||
* .freq_hz = 1000, //set frequency of pwm, here, 1000Hz
|
||||
* .speed_mode = LEDC_HIGH_SPEED_MODE, //timer mode,
|
||||
* .timer_num = LEDC_TIMER_0, //timer number
|
||||
* };
|
||||
* ledc_timer_config(&timer_conf); //setup timer.
|
||||
* @endcode
|
||||
*
|
||||
* //3. set LEDC channel
|
||||
* ledc_channel_config_t ledc_conf = {
|
||||
* .channel = LEDC_CHANNEL_0; //set LEDC channel 0
|
||||
* .duty = 1000; //set the duty for initialization.(duty range is 0 ~ ((2**bit_num)-1)
|
||||
* .gpio_num = 16; //GPIO number
|
||||
* .intr_type = LEDC_INTR_FADE_END; //GPIO INTR TYPE, as an example, we enable fade_end interrupt here.
|
||||
* .speed_mode = LEDC_HIGH_SPEED_MODE; //set LEDC mode, from ledc_mode_t
|
||||
* .timer_sel = LEDC_TIMER_0; //set LEDC timer source, if different channel use one timer, the frequency and bit_num of these channels should be the same
|
||||
* }
|
||||
* ledc_channel_config(&ledc_conf); //setup the configuration
|
||||
* @code{c}
|
||||
* //3. set LEDC channel
|
||||
* ledc_channel_config_t ledc_conf = {
|
||||
* .channel = LEDC_CHANNEL_0; //set LEDC channel 0
|
||||
* .duty = 1000; //set the duty for initialization.(duty range is 0 ~ ((2**bit_num)-1)
|
||||
* .gpio_num = 16; //GPIO number
|
||||
* .intr_type = LEDC_INTR_FADE_END; //GPIO INTR TYPE, as an example, we enable fade_end interrupt here.
|
||||
* .speed_mode = LEDC_HIGH_SPEED_MODE; //set LEDC mode, from ledc_mode_t
|
||||
* .timer_sel = LEDC_TIMER_0; //set LEDC timer source, if different channel use one timer, the frequency and bit_num of these channels should be the same
|
||||
* }
|
||||
* ledc_channel_config(&ledc_conf); //setup the configuration
|
||||
*
|
||||
* ----------------EXAMPLE OF SETTING DUTY --- -----------------
|
||||
* uint32_t ledc_channel = LEDC_CHANNEL_0; //LEDC channel(0-73)
|
||||
* uint32_t duty = 2000; //duty range is 0 ~ ((2**bit_num)-1)
|
||||
* LEDC_set_duty(LEDC_HIGH_SPEED_MODE, ledc_channel, duty); //set speed mode, channel, and duty.
|
||||
* ledc_update_duty(LEDC_HIGH_SPEED_MODE, ledc_channel); //after set duty, we need to call ledc_update_duty to update the settings.
|
||||
*
|
||||
* @code{c}
|
||||
* uint32_t ledc_channel = LEDC_CHANNEL_0; //LEDC channel(0-73)
|
||||
* uint32_t duty = 2000; //duty range is 0 ~ ((2**bit_num)-1)
|
||||
* LEDC_set_duty(LEDC_HIGH_SPEED_MODE, ledc_channel, duty); //set speed mode, channel, and duty.
|
||||
* ledc_update_duty(LEDC_HIGH_SPEED_MODE, ledc_channel); //after set duty, we need to call ledc_update_duty to update the settings.
|
||||
* @endcode
|
||||
*
|
||||
* ----------------EXAMPLE OF LEDC INTERRUPT ------------------
|
||||
* //we have fade_end interrupt and counter overflow interrupt. we just give an example of fade_end interrupt here.
|
||||
* ledc_isr_register(18, ledc_isr_handler, NULL); //hook the isr handler for LEDC interrupt
|
||||
* //the first parameter is INUM, you can pick one form interrupt level 1/2 which is not used by the system.
|
||||
* //NOTE1:user should arrange the INUMs that used, better not to use a same INUM for different interrupt source.
|
||||
* //NOTE2:do not pick the INUM that already occupied by the system.
|
||||
* //NOTE3:refer to soc.h to check which INUMs that can be used.
|
||||
* @code{c}
|
||||
* //we have fade_end interrupt and counter overflow interrupt. we just give an example of fade_end interrupt here.
|
||||
* ledc_isr_register(18, ledc_isr_handler, NULL); //hook the isr handler for LEDC interrupt
|
||||
* @endcode
|
||||
* @note
|
||||
* 1. the first parameter is INUM, you can pick one form interrupt level 1/2 which is not used by the system.
|
||||
* 2. user should arrange the INUMs that used, better not to use a same INUM for different interrupt source.
|
||||
* 3. do not pick the INUM that already occupied by the system.
|
||||
* 4. refer to soc.h to check which INUMs that can be used.
|
||||
*
|
||||
* ----------------EXAMPLE OF INTERRUPT HANDLER ---------------
|
||||
* @code{c}
|
||||
* #include "esp_attr.h"
|
||||
* void IRAM_ATTR ledc_isr_handler(void* arg) //we should add 'IRAM_ATTR' attribution when we declare the isr function
|
||||
* {
|
||||
@ -391,7 +411,7 @@ esp_err_t ledc_bind_channel_timer(ledc_mode_t speed_mode, uint32_t channel, uint
|
||||
*
|
||||
* LEDC.int_clr.val = intr_st; //clear LEDC interrupt status.
|
||||
* }
|
||||
*
|
||||
* @endcode
|
||||
*
|
||||
*--------------------------END OF EXAMPLE --------------------------
|
||||
*/
|
||||
|
763
tools/sdk/include/driver/driver/uart.h
Normal file
763
tools/sdk/include/driver/driver/uart.h
Normal file
@ -0,0 +1,763 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _DRIVER_UART_H_
|
||||
#define _DRIVER_UART_H_
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "soc/uart_reg.h"
|
||||
#include "soc/uart_struct.h"
|
||||
#include "esp_err.h"
|
||||
#include "driver/periph_ctrl.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/ringbuf.h"
|
||||
#include <esp_types.h>
|
||||
|
||||
#define UART_FIFO_LEN (128) /*< Length of the hardware FIFO buffers */
|
||||
#define UART_INTR_MASK 0x1ff
|
||||
#define UART_LINE_INV_MASK (0x3f << 19)
|
||||
#define UART_BITRATE_MAX 5000000
|
||||
#define UART_PIN_NO_CHANGE (-1)
|
||||
|
||||
#define UART_INVERSE_DISABLE (0x0) /*!< Disable UART signal inverse*/
|
||||
#define UART_INVERSE_RXD (UART_RXD_INV_M) /*!< UART RXD input inverse*/
|
||||
#define UART_INVERSE_CTS (UART_CTS_INV_M) /*!< UART CTS input inverse*/
|
||||
#define UART_INVERSE_TXD (UART_TXD_INV_M) /*!< UART TXD output inverse*/
|
||||
#define UART_INVERSE_RTS (UART_RTS_INV_M) /*!< UART RTS output inverse*/
|
||||
|
||||
typedef enum {
|
||||
UART_DATA_5_BITS = 0x0, /*!< word length: 5bits*/
|
||||
UART_DATA_6_BITS = 0x1, /*!< word length: 6bits*/
|
||||
UART_DATA_7_BITS = 0x2, /*!< word length: 7bits*/
|
||||
UART_DATA_8_BITS = 0x3, /*!< word length: 8bits*/
|
||||
UART_DATA_BITS_MAX = 0X4,
|
||||
} uart_word_length_t;
|
||||
|
||||
typedef enum {
|
||||
UART_STOP_BITS_1 = 0x1, /*!< stop bit: 1bit*/
|
||||
UART_STOP_BITS_1_5 = 0x2, /*!< stop bit: 1.5bits*/
|
||||
UART_STOP_BITS_2 = 0x3, /*!< stop bit: 2bits*/
|
||||
UART_STOP_BITS_MAX = 0x4,
|
||||
} uart_stop_bits_t;
|
||||
|
||||
typedef enum {
|
||||
UART_NUM_0 = 0x0, /*!< UART base address 0x3ff40000*/
|
||||
UART_NUM_1 = 0x1, /*!< UART base address 0x3ff50000*/
|
||||
UART_NUM_2 = 0x2, /*!< UART base address 0x3ff6E000*/
|
||||
UART_NUM_MAX,
|
||||
} uart_port_t;
|
||||
|
||||
typedef enum {
|
||||
UART_PARITY_DISABLE = 0x0, /*!< Disable UART parity*/
|
||||
UART_PARITY_EVEN = 0x10, /*!< Enable UART even parity*/
|
||||
UART_PARITY_ODD = 0x11 /*!< Enable UART odd parity*/
|
||||
} uart_parity_t;
|
||||
|
||||
typedef enum {
|
||||
UART_HW_FLOWCTRL_DISABLE = 0x0, /*!< disable hardware flow control*/
|
||||
UART_HW_FLOWCTRL_RTS = 0x1, /*!< enable RX hardware flow control (rts)*/
|
||||
UART_HW_FLOWCTRL_CTS = 0x2, /*!< enable TX hardware flow control (cts)*/
|
||||
UART_HW_FLOWCTRL_CTS_RTS = 0x3, /*!< enable hardware flow control*/
|
||||
UART_HW_FLOWCTRL_MAX = 0x4,
|
||||
} uart_hw_flowcontrol_t;
|
||||
|
||||
typedef struct {
|
||||
int baud_rate; /*!< UART baudrate*/
|
||||
uart_word_length_t data_bits; /*!< UART byte size*/
|
||||
uart_parity_t parity; /*!< UART parity mode*/
|
||||
uart_stop_bits_t stop_bits; /*!< UART stop bits*/
|
||||
uart_hw_flowcontrol_t flow_ctrl; /*!< UART HW flow control mode(cts/rts)*/
|
||||
uint8_t rx_flow_ctrl_thresh ; /*!< UART HW RTS threshold*/
|
||||
} uart_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t intr_enable_mask; /*!< UART interrupt enable mask, choose from UART_XXXX_INT_ENA_M under UART_INT_ENA_REG(i), connect with bit-or operator*/
|
||||
uint8_t rx_timeout_thresh; /*!< UART timeout interrupt threshold(unit: time of sending one byte)*/
|
||||
uint8_t txfifo_empty_intr_thresh; /*!< UART TX empty interrupt threshold.*/
|
||||
uint8_t rxfifo_full_thresh; /*!< UART RX full interrupt threshold.*/
|
||||
} uart_intr_config_t;
|
||||
|
||||
typedef enum {
|
||||
UART_DATA, /*!< UART data event*/
|
||||
UART_BREAK, /*!< UART break event*/
|
||||
UART_BUFFER_FULL, /*!< UART RX buffer full event*/
|
||||
UART_FIFO_OVF, /*!< UART FIFO overflow event*/
|
||||
UART_FRAME_ERR, /*!< UART RX frame error event*/
|
||||
UART_PARITY_ERR, /*!< UART RX parity event*/
|
||||
UART_DATA_BREAK, /*!< UART TX data and break event*/
|
||||
UART_EVENT_MAX, /*!< UART event max index*/
|
||||
} uart_event_type_t;
|
||||
|
||||
typedef struct {
|
||||
uart_event_type_t type; /*!< UART event type */
|
||||
size_t size; /*!< UART data size for UART_DATA event*/
|
||||
} uart_event_t;
|
||||
|
||||
/**
|
||||
* @brief Set UART data bits.
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param data_bit UART data bits
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_set_word_length(uart_port_t uart_num, uart_word_length_t data_bit);
|
||||
|
||||
/**
|
||||
* @brief Get UART data bits.
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success, result will be put in (*data_bit)
|
||||
*/
|
||||
esp_err_t uart_get_word_length(uart_port_t uart_num, uart_word_length_t* data_bit);
|
||||
|
||||
/**
|
||||
* @brief Set UART stop bits.
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param bit_num UART stop bits
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t uart_set_stop_bits(uart_port_t uart_no, uart_stop_bits_t bit_num);
|
||||
|
||||
/**
|
||||
* @brief Set UART stop bits.
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success, result will be put in (*stop_bit)
|
||||
*/
|
||||
esp_err_t uart_get_stop_bits(uart_port_t uart_num, uart_stop_bits_t* stop_bit);
|
||||
|
||||
/**
|
||||
* @brief Set UART parity.
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param parity_mode the enum of uart parity configuration
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t uart_set_parity(uart_port_t uart_no, uart_parity_t parity_mode);
|
||||
|
||||
/**
|
||||
* @brief Get UART parity mode.
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success, result will be put in (*parity_mode)
|
||||
*
|
||||
*/
|
||||
esp_err_t uart_get_parity(uart_port_t uart_num, uart_parity_t* parity_mode);
|
||||
|
||||
/**
|
||||
* @brief Set UART baud rate.
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param baud_rate UART baud-rate.
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t uart_set_baudrate(uart_port_t uart_no, uint32_t baud_rate);
|
||||
|
||||
/**
|
||||
* @brief Get UART bit-rate.
|
||||
*
|
||||
* @param uart_no: UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success, result will be put in (*baudrate)
|
||||
*
|
||||
*/
|
||||
esp_err_t uart_get_baudrate(uart_port_t uart_num, uint32_t* baudrate);
|
||||
|
||||
/**
|
||||
* @brief Set UART line inverse mode
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param inverse_mask Choose the wires that need to be inversed.
|
||||
*
|
||||
* (inverse_mask should be chosen from UART_INVERSE_RXD/UART_INVERSE_TXD/UART_INVERSE_RTS/UART_INVERSE_CTS, combine with OR-OPERATION)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_set_line_inverse(uart_port_t uart_no, uint32_t inverse_mask);
|
||||
|
||||
/**
|
||||
* @brief Set hardware flow control.
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param flow_ctrl Hardware flow control mode
|
||||
*
|
||||
* @param rx_thresh Threshold of Hardware RX flow control(0 ~ UART_FIFO_LEN)
|
||||
*
|
||||
* Only when UART_HW_FLOWCTRL_RTS is set , will the rx_thresh value be set.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_set_hw_flow_ctrl(uart_port_t uart_no, uart_hw_flowcontrol_t flow_ctrl, uint8_t rx_thresh);
|
||||
|
||||
/**
|
||||
* @brief Get hardware flow control mode
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success, result will be put in (*flow_ctrl)
|
||||
*/
|
||||
esp_err_t uart_get_hw_flow_ctrl(uart_port_t uart_num, uart_hw_flowcontrol_t* flow_ctrl);
|
||||
|
||||
/**
|
||||
* @brief Clear UART interrupt status
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param clr_mask Bit mask of the status that to be cleared.
|
||||
*
|
||||
* (enable_mask should be chosen from the fields of register UART_INT_CLR_REG)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_clear_intr_status(uart_port_t uart_num, uint32_t clr_mask);
|
||||
|
||||
/**
|
||||
* @brief Set UART interrupt enable
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param enable_mask Bit mask of the enable bits.
|
||||
*
|
||||
* (enable_mask should be chosen from the fields of register UART_INT_ENA_REG)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_enable_intr_mask(uart_port_t uart_num, uint32_t enable_mask);
|
||||
|
||||
/**
|
||||
* @brief Clear UART interrupt enable bits
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param disable_mask Bit mask of the disable bits.
|
||||
*
|
||||
* (disable_mask should be chosen from the fields of register UART_INT_ENA_REG)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_disable_intr_mask(uart_port_t uart_num, uint32_t disable_mask);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Enable UART RX interrupt(RX_FULL & RX_TIMEOUT INTERRUPT)
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_enable_rx_intr(uart_port_t uart_num);
|
||||
|
||||
/**
|
||||
* @brief Disable UART RX interrupt(RX_FULL & RX_TIMEOUT INTERRUPT)
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_disable_rx_intr(uart_port_t uart_num);
|
||||
|
||||
/**
|
||||
* @brief Disable UART TX interrupt(RX_FULL & RX_TIMEOUT INTERRUPT)
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_disable_tx_intr(uart_port_t uart_num);
|
||||
|
||||
/**
|
||||
* @brief Enable UART TX interrupt(RX_FULL & RX_TIMEOUT INTERRUPT)
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param enable 1: enable; 0: disable
|
||||
*
|
||||
* @param thresh Threshold of TX interrupt, 0 ~ UART_FIFO_LEN
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_enable_tx_intr(uart_port_t uart_num, int enable, int thresh);
|
||||
|
||||
/**
|
||||
* @brief register UART interrupt handler(ISR).
|
||||
* @note
|
||||
* UART ISR handler will be attached to the same CPU core that this function is running on.
|
||||
* Users should know that which CPU is running and then pick a INUM that is not used by system.
|
||||
* We can find the information of INUM and interrupt level in soc.h.
|
||||
*
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param uart_intr_num UART interrupt number,check the info in soc.h, and please refer to core-isa.h for more details
|
||||
*
|
||||
* @param fn Interrupt handler function.
|
||||
* @attention
|
||||
* The ISR handler function MUST be defined with attribution of "IRAM_ATTR" for now.
|
||||
* @param arg parameter for handler function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_isr_register(uart_port_t uart_num, uint8_t uart_intr_num, void (*fn)(void*), void * arg);
|
||||
|
||||
/**
|
||||
* @brief Set UART pin number
|
||||
*
|
||||
* @note
|
||||
* Internal signal can be output to multiple GPIO pads
|
||||
* Only one GPIO pad can connect with input signal
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param tx_io_num UART TX pin GPIO number, if set to UART_PIN_NO_CHANGE, use the current pin.
|
||||
*
|
||||
* @param rx_io_num UART RX pin GPIO number, if set to UART_PIN_NO_CHANGE, use the current pin.
|
||||
*
|
||||
* @param rts_io_num UART RTS pin GPIO number, if set to UART_PIN_NO_CHANGE, use the current pin.
|
||||
*
|
||||
* @param cts_io_num UART CTS pin GPIO number, if set to UART_PIN_NO_CHANGE, use the current pin.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_set_pin(uart_port_t uart_num, int tx_io_num, int rx_io_num, int rts_io_num, int cts_io_num);
|
||||
|
||||
/**
|
||||
* @brief UART set RTS level (before inverse)
|
||||
* UART rx hardware flow control should not be set.
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param level 1: RTS output low(active); 0: RTS output high(block)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_set_rts(uart_port_t uart_num, int level);
|
||||
|
||||
/**
|
||||
* @brief UART set DTR level (before inverse)
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param level 1: DTR output low; 0: DTR output high
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_set_dtr(uart_port_t uart_num, int level);
|
||||
|
||||
/**
|
||||
* @brief UART parameter configure
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param uart_config UART parameter settings
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_param_config(uart_port_t uart_num, const uart_config_t *uart_config);
|
||||
|
||||
/**
|
||||
* @brief UART interrupt configure
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param intr_conf UART interrupt settings
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_intr_config(uart_port_t uart_num, const uart_intr_config_t *intr_conf);
|
||||
|
||||
/**
|
||||
* @brief Install UART driver.
|
||||
*
|
||||
* UART ISR handler will be attached to the same CPU core that this function is running on.
|
||||
* Users should know that which CPU is running and then pick a INUM that is not used by system.
|
||||
* We can find the information of INUM and interrupt level in soc.h.
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param rx_buffer_size UART RX ring buffer size
|
||||
*
|
||||
* @param tx_buffer_size UART TX ring buffer size.
|
||||
*
|
||||
* If set to zero, driver will not use TX buffer, TX function will block task until all data have been sent out..
|
||||
*
|
||||
* @param queue_size UART event queue size/depth.
|
||||
*
|
||||
* @param uart_intr_num UART interrupt number,check the info in soc.h, and please refer to core-isa.h for more details
|
||||
*
|
||||
* @param uart_queue UART event queue handle, if set NULL, driver will not use an event queue.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_driver_install(uart_port_t uart_num, int rx_buffer_size, int tx_buffer_size, int queue_size, int uart_intr_num, void* uart_queue);
|
||||
|
||||
/**
|
||||
* @brief Uninstall UART driver.
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_driver_delete(uart_port_t uart_num);
|
||||
|
||||
/**
|
||||
* @brief Wait UART TX FIFO empty
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param ticks_to_wait Timeout, count in RTOS ticks
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_ERR_TIMEOUT Timeout
|
||||
*/
|
||||
esp_err_t uart_wait_tx_done(uart_port_t uart_num, TickType_t ticks_to_wait);
|
||||
|
||||
/**
|
||||
* @brief Send data to the UART port from a given buffer and length,
|
||||
* This function will not wait for the space in TX FIFO, just fill the TX FIFO and return when the FIFO is full.
|
||||
* @note
|
||||
* This function should only be used when UART TX buffer is not enabled.
|
||||
*
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param buffer data buffer address
|
||||
*
|
||||
* @param len data length to send
|
||||
*
|
||||
* @return
|
||||
* - (-1) Parameter error
|
||||
* - OTHERS(>=0) The number of data that pushed to the TX FIFO
|
||||
*/
|
||||
int uart_tx_chars(uart_port_t uart_no, const char* buffer, uint32_t len);
|
||||
|
||||
/**
|
||||
* @brief Send data to the UART port from a given buffer and length,
|
||||
*
|
||||
* If parameter tx_buffer_size is set to zero:
|
||||
* This function will not return until all the data have been sent out, or at least pushed into TX FIFO.
|
||||
*
|
||||
* Otherwise, if tx_buffer_size > 0, this function will return after copying all the data to tx ringbuffer,
|
||||
* then, UART ISR will move data from ring buffer to TX FIFO gradually.
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param src data buffer address
|
||||
*
|
||||
* @param size data length to send
|
||||
*
|
||||
* @return
|
||||
* - (-1) Parameter error
|
||||
* - OTHERS(>=0) The number of data that pushed to the TX FIFO
|
||||
*/
|
||||
int uart_write_bytes(uart_port_t uart_num, const char* src, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Send data to the UART port from a given buffer and length,
|
||||
*
|
||||
* If parameter tx_buffer_size is set to zero:
|
||||
* This function will not return until all the data and the break signal have been sent out.
|
||||
* After all data send out, send a break signal.
|
||||
*
|
||||
* Otherwise, if tx_buffer_size > 0, this function will return after copying all the data to tx ringbuffer,
|
||||
* then, UART ISR will move data from ring buffer to TX FIFO gradually.
|
||||
* After all data send out, send a break signal.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param src data buffer address
|
||||
*
|
||||
* @param size data length to send
|
||||
*
|
||||
* @param brk_len break signal length (unit: one bit's time@current_baudrate)
|
||||
*
|
||||
* @return
|
||||
* - (-1) Parameter error
|
||||
* - OTHERS(>=0) The number of data that pushed to the TX FIFO
|
||||
*/
|
||||
|
||||
int uart_write_bytes_with_break(uart_port_t uart_num, const char* src, size_t size, int brk_len);
|
||||
|
||||
/**
|
||||
* @brief UART read bytes from UART buffer
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @param buf pointer to the buffer.
|
||||
*
|
||||
* @param length data length
|
||||
*
|
||||
* @param ticks_to_wait sTimeout, count in RTOS ticks
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* - (-1) Error
|
||||
* - Others return a char data from uart fifo.
|
||||
*/
|
||||
int uart_read_bytes(uart_port_t uart_num, uint8_t* buf, uint32_t length, TickType_t ticks_to_wait);
|
||||
|
||||
/**
|
||||
* @brief UART ring buffer flush
|
||||
*
|
||||
* @param uart_no UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_flush(uart_port_t uart_num);
|
||||
|
||||
/***************************EXAMPLE**********************************
|
||||
*
|
||||
*
|
||||
* ----------------EXAMPLE OF UART SETTING ---------------------
|
||||
* @code{c}
|
||||
* //1. Setup UART
|
||||
* #include "freertos/queue.h"
|
||||
* #define UART_INTR_NUM 17 //choose one interrupt number from soc.h
|
||||
* //a. Set UART parameter
|
||||
* int uart_num = 0; //uart port number
|
||||
* uart_config_t uart_config = {
|
||||
* .baud_rate = UART_BITRATE_115200, //baudrate
|
||||
* .data_bits = UART_DATA_8_BITS, //data bit mode
|
||||
* .parity = UART_PARITY_DISABLE, //parity mode
|
||||
* .stop_bits = UART_STOP_BITS_1, //stop bit mode
|
||||
* .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, //hardware flow control(cts/rts)
|
||||
* .rx_flow_ctrl_thresh = 120, //flow control threshold
|
||||
* };
|
||||
* uart_param_config(uart_num, &uart_config);
|
||||
* //b1. Setup UART driver(with UART queue)
|
||||
* QueueHandle_t uart_queue;
|
||||
* //parameters here are just an example, tx buffer size is 2048
|
||||
* uart_driver_install(uart_num, 1024 * 2, 1024 * 2, 10, UART_INTR_NUM, &uart_queue);
|
||||
* //b2. Setup UART driver(without UART queue)
|
||||
* //parameters here are just an example, tx buffer size is 0
|
||||
* uart_driver_install(uart_num, 1024 * 2, 0, 10, UART_INTR_NUM, NULL);
|
||||
*@endcode
|
||||
*-----------------------------------------------------------------------------*
|
||||
* @code{c}
|
||||
* //2. Set UART pin
|
||||
* //set UART pin, not needed if use default pins.
|
||||
* uart_set_pin(uart_num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, 15, 13);
|
||||
* @endcode
|
||||
*-----------------------------------------------------------------------------*
|
||||
* @code{c}
|
||||
* //3. Read data from UART.
|
||||
* uint8_t data[128];
|
||||
* int length = 0;
|
||||
* length = uart_read_bytes(uart_num, data, sizeof(data), 100);
|
||||
* @endcode
|
||||
*-----------------------------------------------------------------------------*
|
||||
* @code{c}
|
||||
* //4. Write data to UART.
|
||||
* char* test_str = "This is a test string.\n"
|
||||
* uart_write_bytes(uart_num, (const char*)test_str, strlen(test_str));
|
||||
* @endcode
|
||||
*-----------------------------------------------------------------------------*
|
||||
* @code{c}
|
||||
* //5. Write data to UART, end with a break signal.
|
||||
* uart_write_bytes_with_break(0, "test break\n",strlen("test break\n"), 100);
|
||||
* @endcode
|
||||
*-----------------------------------------------------------------------------*
|
||||
* @code{c}
|
||||
* //6. an example of echo test with hardware flow control on UART1
|
||||
* void uart_loop_back_test()
|
||||
* {
|
||||
* int uart_num = 1;
|
||||
* uart_config_t uart_config = {
|
||||
* .baud_rate = 115200,
|
||||
* .data_bits = UART_DATA_8_BITS,
|
||||
* .parity = UART_PARITY_DISABLE,
|
||||
* .stop_bits = UART_STOP_BITS_1,
|
||||
* .flow_ctrl = UART_HW_FLOWCTRL_CTS_RTS,
|
||||
* .rx_flow_ctrl_thresh = 122,
|
||||
* };
|
||||
* //Configure UART1 parameters
|
||||
* uart_param_config(uart_num, &uart_config);
|
||||
* //Set UART1 pins(TX: IO16, RX: IO17, RTS: IO18, CTS: IO19)
|
||||
* uart_set_pin(uart_num, 16, 17, 18, 19);
|
||||
* //Install UART driver( We don't need an event queue here)
|
||||
* uart_driver_install(uart_num, 1024 * 2, 1024*4, 10, 17, NULL, RINGBUF_TYPE_BYTEBUF);
|
||||
* uint8_t data[1000];
|
||||
* while(1) {
|
||||
* //Read data from UART
|
||||
* int len = uart_read_bytes(uart_num, data, sizeof(data), 10);
|
||||
* //Write data back to UART
|
||||
* uart_write_bytes(uart_num, (const char*)data, len);
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
*-----------------------------------------------------------------------------*
|
||||
* @code{c}
|
||||
* //7. An example of using UART event queue on UART0.
|
||||
* #include "freertos/queue.h"
|
||||
* //A queue to handle UART event.
|
||||
* QueueHandle_t uart0_queue;
|
||||
* static const char *TAG = "uart_example";
|
||||
* void uart_task(void *pvParameters)
|
||||
* {
|
||||
* int uart_num = (int)pvParameters;
|
||||
* uart_event_t event;
|
||||
* uint8_t dtmp[1000];
|
||||
* for(;;) {
|
||||
* //Waiting for UART event.
|
||||
* if(xQueueReceive(uart0_queue, (void * )&event, (portTickType)portMAX_DELAY)) {
|
||||
* ESP_LOGI(TAG, "uart[%d] event:", uart_num);
|
||||
* switch(event.type) {
|
||||
* memset(dtmp, 0, sizeof(dtmp));
|
||||
* //Event of UART receving data
|
||||
* case UART_DATA:
|
||||
* ESP_LOGI(TAG,"data, len: %d", event.size);
|
||||
* int len = uart_read_bytes(uart_num, dtmp, event.size, 10);
|
||||
* ESP_LOGI(TAG, "uart read: %d", len);
|
||||
uart_write_bytes(uart_num, (const char*)dtmp, len);
|
||||
* break;
|
||||
* //Event of HW FIFO overflow detected
|
||||
* case UART_FIFO_OVF:
|
||||
* ESP_LOGI(TAG, "hw fifo overflow\n");
|
||||
* break;
|
||||
* //Event of UART ring buffer full
|
||||
* case UART_BUFFER_FULL:
|
||||
* ESP_LOGI(TAG, "ring buffer full\n");
|
||||
* break;
|
||||
* //Event of UART RX break detected
|
||||
* case UART_BREAK:
|
||||
* ESP_LOGI(TAG, "uart rx break\n");
|
||||
* break;
|
||||
* //Event of UART parity check error
|
||||
* case UART_PARITY_ERR:
|
||||
* ESP_LOGI(TAG, "uart parity error\n");
|
||||
* break;
|
||||
* //Event of UART frame error
|
||||
* case UART_FRAME_ERR:
|
||||
* ESP_LOGI(TAG, "uart frame error\n");
|
||||
* break;
|
||||
* //Others
|
||||
* default:
|
||||
* ESP_LOGI(TAG, "uart event type: %d\n", event.type);
|
||||
* break;
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* vTaskDelete(NULL);
|
||||
* }
|
||||
*
|
||||
* void uart_queue_test()
|
||||
* {
|
||||
* int uart_num = 0;
|
||||
* uart_config_t uart_config = {
|
||||
* .baud_rate = 115200,
|
||||
* .data_bits = UART_DATA_8_BITS,
|
||||
* .parity = UART_PARITY_DISABLE,
|
||||
* .stop_bits = UART_STOP_BITS_1,
|
||||
* .flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
|
||||
* .rx_flow_ctrl_thresh = 122,
|
||||
* };
|
||||
* //Set UART parameters
|
||||
* uart_param_config(uart_num, &uart_config);
|
||||
* //Set UART pins,(-1: default pin, no change.)
|
||||
* uart_set_pin(uart_num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, 15, 13);
|
||||
* //Set UART log level
|
||||
* esp_log_level_set(TAG, ESP_LOG_INFO);
|
||||
* //Install UART driver, and get the queue.
|
||||
* uart_driver_install(uart_num, 1024 * 2, 1024*4, 10, 17, &uart0_queue, RINGBUF_TYPE_BYTEBUF);
|
||||
* //Create a task to handler UART event from ISR
|
||||
* xTaskCreate(uart_task, "uTask", 2048*8, (void*)uart_num, 10, NULL);
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
***************************END OF EXAMPLE**********************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_DRIVER_UART_H_*/
|
@ -20,22 +20,21 @@
|
||||
//and all variables in shared RAM. These macros can be used to redirect
|
||||
//particular functions/variables to other memory regions.
|
||||
|
||||
// Forces code into IRAM instead of flash
|
||||
// Forces code into IRAM instead of flash.
|
||||
#define IRAM_ATTR __attribute__((section(".iram1")))
|
||||
|
||||
// Forces data into DRAM instead of flash
|
||||
#define DRAM_ATTR __attribute__((section(".dram1")))
|
||||
|
||||
// Forces code into RTC fast memory
|
||||
// Forces code into RTC fast memory. See "docs/deep-sleep-stub.rst"
|
||||
#define RTC_IRAM_ATTR __attribute__((section(".rtc.text")))
|
||||
|
||||
// Forces data into RTC slow memory
|
||||
// Forces data into RTC slow memory. See "docs/deep-sleep-stub.rst"
|
||||
// Any variable marked with this attribute will keep its value
|
||||
// during a deep sleep / wake cycle.
|
||||
#define RTC_DATA_ATTR __attribute__((section(".rtc.data")))
|
||||
|
||||
// Forces read-only data into RTC slow memory
|
||||
// Makes constant data available to RTC wake stubs (see esp_deepsleep.h)
|
||||
// Forces read-only data into RTC slow memory. See "docs/deep-sleep-stub.rst"
|
||||
#define RTC_RODATA_ATTR __attribute__((section(".rtc.rodata")))
|
||||
|
||||
#endif /* __ESP_ATTR_H__ */
|
||||
|
42
tools/sdk/include/esp32/esp_crosscore_int.h
Normal file
42
tools/sdk/include/esp32/esp_crosscore_int.h
Normal file
@ -0,0 +1,42 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef __ESP_CROSSCORE_INT_H
|
||||
#define __ESP_CROSSCORE_INT_H
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the crosscore interrupt system for this CPU.
|
||||
* This needs to be called once on every CPU that is used
|
||||
* by FreeRTOS.
|
||||
*
|
||||
* If multicore FreeRTOS support is enabled, this will be
|
||||
* called automatically by the startup code and should not
|
||||
* be called manually.
|
||||
*/
|
||||
void esp_crosscore_int_init();
|
||||
|
||||
|
||||
/**
|
||||
* Send an interrupt to a CPU indicating it should yield its
|
||||
* currently running task in favour of a higher-priority task
|
||||
* that presumably just woke up.
|
||||
*
|
||||
* This is used internally by FreeRTOS in multicore mode
|
||||
* and should not be called by the user.
|
||||
*
|
||||
* @param coreID Core that should do the yielding
|
||||
*/
|
||||
void esp_crosscore_int_send_yield(int coreId);
|
||||
|
||||
#endif
|
@ -54,37 +54,7 @@ void system_deep_sleep(uint64_t time_in_us);
|
||||
* to run code immediately when the chip wakes from
|
||||
* sleep.
|
||||
*
|
||||
* For example:
|
||||
* @code
|
||||
* void RTC_IRAM_ATTR esp_wake_deep_sleep(void) {
|
||||
* esp_default_wake_deep_sleep();
|
||||
* // Add additional functionality here
|
||||
* }
|
||||
*
|
||||
* (Implementing this function is not required for normal operation,
|
||||
* in the usual case your app will start normally when waking from
|
||||
* deep sleep.)
|
||||
*
|
||||
* esp_wake_deep_sleep() functionality is limited:
|
||||
*
|
||||
* - Runs immediately on wake, so most of the SoC is freshly reset -
|
||||
* flash is unmapped and hardware is otherwise uninitialised.
|
||||
*
|
||||
* - Can only call functions implemented in ROM, or marked RTC_IRAM_ATTR.
|
||||
*
|
||||
* - Static variables marked RTC_DATA_ATTR will have initial values on
|
||||
* cold boot, and maintain these values between sleep/wake cycles.
|
||||
*
|
||||
* - Read-only data should be marked RTC_RODATA_ATTR. Strings must be
|
||||
* declared as variables also using RTC_RODATA_ATTR, like this:
|
||||
* RTC_RODATA_ATTR const char message[] = "Hello from very early boot!\n";
|
||||
*
|
||||
* - Any other static memory will not be initialised (either to zero,
|
||||
* or to any predefined value).
|
||||
*
|
||||
*
|
||||
* - If you implement your own stub, the first call the stub makes
|
||||
should be to esp_default_wake_deep_sleep().
|
||||
* See docs/deep-sleep-stub.rst for details.
|
||||
*/
|
||||
void esp_wake_deep_sleep(void);
|
||||
|
||||
@ -115,9 +85,7 @@ esp_deep_sleep_wake_stub_fn_t esp_get_deep_sleep_wake_stub(void);
|
||||
|
||||
/* The default esp-idf-provided esp_wake_deep_sleep() stub.
|
||||
|
||||
If you replace esp_wake_deep_sleep() in your program, or use
|
||||
esp_set_deep_sleep_wake_stub(), then it is recommended you call
|
||||
esp_default_wake_deep_sleep() as the first function in your stub.
|
||||
See docs/deep-sleep-stub.rst for details.
|
||||
*/
|
||||
void esp_default_wake_deep_sleep(void);
|
||||
|
||||
|
@ -31,6 +31,13 @@ typedef int32_t esp_err_t;
|
||||
#define ESP_ERR_NO_MEM 0x101
|
||||
#define ESP_ERR_INVALID_ARG 0x102
|
||||
#define ESP_ERR_INVALID_STATE 0x103
|
||||
#define ESP_ERR_INVALID_SIZE 0x104
|
||||
#define ESP_ERR_NOT_FOUND 0x105
|
||||
#define ESP_ERR_NOT_SUPPORTED 0x106
|
||||
#define ESP_ERR_TIMEOUT 0x107
|
||||
|
||||
|
||||
#define ESP_ERR_WIFI_BASE 0x3000 /*!< Starting number of WiFi error codes */
|
||||
|
||||
/**
|
||||
* Macro which can be used to check the error code,
|
||||
|
106
tools/sdk/include/esp32/esp_flash_data_types.h
Normal file
106
tools/sdk/include/esp32/esp_flash_data_types.h
Normal file
@ -0,0 +1,106 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef __ESP_BIN_TYPES_H__
|
||||
#define __ESP_BIN_TYPES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define ESP_PARTITION_TABLE_ADDR 0x4000
|
||||
#define ESP_PARTITION_MAGIC 0x50AA
|
||||
|
||||
/* SPI flash mode, used in esp_image_header_t */
|
||||
typedef enum {
|
||||
ESP_IMAGE_SPI_MODE_QIO,
|
||||
ESP_IMAGE_SPI_MODE_QOUT,
|
||||
ESP_IMAGE_SPI_MODE_DIO,
|
||||
ESP_IMAGE_SPI_MODE_DOUT,
|
||||
ESP_IMAGE_SPI_MODE_FAST_READ,
|
||||
ESP_IMAGE_SPI_MODE_SLOW_READ
|
||||
} esp_image_spi_mode_t;
|
||||
|
||||
/* SPI flash clock frequency */
|
||||
enum {
|
||||
ESP_IMAGE_SPI_SPEED_40M,
|
||||
ESP_IMAGE_SPI_SPEED_26M,
|
||||
ESP_IMAGE_SPI_SPEED_20M,
|
||||
ESP_IMAGE_SPI_SPEED_80M = 0xF
|
||||
} esp_image_spi_freq_t;
|
||||
|
||||
/* Supported SPI flash sizes */
|
||||
typedef enum {
|
||||
ESP_IMAGE_FLASH_SIZE_1MB = 0,
|
||||
ESP_IMAGE_FLASH_SIZE_2MB,
|
||||
ESP_IMAGE_FLASH_SIZE_4MB,
|
||||
ESP_IMAGE_FLASH_SIZE_8MB,
|
||||
ESP_IMAGE_FLASH_SIZE_16MB,
|
||||
ESP_IMAGE_FLASH_SIZE_MAX
|
||||
} esp_image_flash_size_t;
|
||||
|
||||
/* Main header of binary image */
|
||||
typedef struct {
|
||||
uint8_t magic;
|
||||
uint8_t blocks;
|
||||
uint8_t spi_mode; /* flash read mode (esp_image_spi_mode_t as uint8_t) */
|
||||
uint8_t spi_speed: 4; /* flash frequency (esp_image_spi_freq_t as uint8_t) */
|
||||
uint8_t spi_size: 4; /* flash chip size (esp_image_flash_size_t as uint8_t) */
|
||||
uint32_t entry_addr;
|
||||
uint8_t encrypt_flag; /* encrypt flag */
|
||||
uint8_t secure_boot_flag; /* secure boot flag */
|
||||
uint8_t extra_header[14]; /* ESP32 additional header, unused by second bootloader */
|
||||
} esp_image_header_t;
|
||||
|
||||
/* Header of binary image segment */
|
||||
typedef struct {
|
||||
uint32_t load_addr;
|
||||
uint32_t data_len;
|
||||
} esp_image_section_header_t;
|
||||
|
||||
|
||||
/* OTA selection structure (two copies in the OTA data partition.)
|
||||
Size of 32 bytes is friendly to flash encryption */
|
||||
typedef struct {
|
||||
uint32_t ota_seq;
|
||||
uint8_t seq_label[24];
|
||||
uint32_t crc; /* CRC32 of ota_seq field only */
|
||||
} esp_ota_select_entry_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t offset;
|
||||
uint32_t size;
|
||||
} esp_partition_pos_t;
|
||||
|
||||
/* Structure which describes the layout of partition table entry.
|
||||
* See docs/partition_tables.rst for more information about individual fields.
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t magic;
|
||||
uint8_t type;
|
||||
uint8_t subtype;
|
||||
esp_partition_pos_t pos;
|
||||
uint8_t label[16];
|
||||
uint8_t reserved[4];
|
||||
} esp_partition_info_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //__ESP_BIN_TYPES_H__
|
@ -32,6 +32,13 @@ extern "C" {
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @attention application don't need to call this function anymore. It do nothing and will
|
||||
* be removed in future version.
|
||||
*/
|
||||
void system_init(void) __attribute__ ((deprecated));
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get information of the SDK version.
|
||||
*
|
||||
@ -169,8 +176,6 @@ bool system_rtc_mem_write(uint16_t dst, const void *src, uint16_t n);
|
||||
esp_err_t system_efuse_read_mac(uint8_t mac[6]);
|
||||
|
||||
|
||||
void system_init(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -70,6 +70,24 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_ERR_WIFI_OK ESP_OK /*!< No error */
|
||||
#define ESP_ERR_WIFI_FAIL ESP_FAIL /*!< General fail code */
|
||||
#define ESP_ERR_WIFI_NO_MEM ESP_ERR_NO_MEM /*!< Out of memory */
|
||||
#define ESP_ERR_WIFI_ARG ESP_ERR_INVALID_ARG /*!< Invalid argument */
|
||||
#define ESP_ERR_WIFI_NOT_SUPPORT ESP_ERR_NOT_SUPPORTED /*!< Indicates that API is not supported yet */
|
||||
|
||||
#define ESP_ERR_WIFI_NOT_INIT (ESP_ERR_WIFI_BASE + 1) /*!< WiFi driver is not installed by esp_wifi_init */
|
||||
#define ESP_ERR_WIFI_NOT_START (ESP_ERR_WIFI_BASE + 2) /*!< WiFi driver is not started by esp_wifi_start */
|
||||
#define ESP_ERR_WIFI_IF (ESP_ERR_WIFI_BASE + 3) /*!< WiFi interface error */
|
||||
#define ESP_ERR_WIFI_MODE (ESP_ERR_WIFI_BASE + 4) /*!< WiFi mode error */
|
||||
#define ESP_ERR_WIFI_STATE (ESP_ERR_WIFI_BASE + 5) /*!< WiFi internal state error */
|
||||
#define ESP_ERR_WIFI_CONN (ESP_ERR_WIFI_BASE + 6) /*!< WiFi internal control block of station or soft-AP error */
|
||||
#define ESP_ERR_WIFI_NVS (ESP_ERR_WIFI_BASE + 7) /*!< WiFi internal NVS module error */
|
||||
#define ESP_ERR_WIFI_MAC (ESP_ERR_WIFI_BASE + 8) /*!< MAC address is invalid */
|
||||
#define ESP_ERR_WIFI_SSID (ESP_ERR_WIFI_BASE + 9) /*!< SSID is invalid */
|
||||
#define ESP_ERR_WIFI_PASSWORD (ESP_ERR_WIFI_BASE + 10) /*!< Passord is invalid */
|
||||
#define ESP_ERR_WIFI_TIMEOUT (ESP_ERR_WIFI_BASE + 11) /*!< Timeout error */
|
||||
|
||||
typedef struct {
|
||||
system_event_handler_t event_handler; /**< WiFi event handler */
|
||||
} wifi_init_config_t;
|
||||
@ -92,8 +110,10 @@ typedef struct {
|
||||
*
|
||||
* @param wifi_init_config_t *config : provide WiFi init configuration
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NO_MEM : out of memory
|
||||
* - others : refer to error code esp_err.h
|
||||
*/
|
||||
esp_err_t esp_wifi_init(wifi_init_config_t *config);
|
||||
|
||||
@ -104,7 +124,6 @@ esp_err_t esp_wifi_init(wifi_init_config_t *config);
|
||||
* @attention 1. This API should be called if you want to remove WiFi driver from the system
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
*/
|
||||
esp_err_t esp_wifi_deinit(void);
|
||||
|
||||
@ -116,8 +135,11 @@ esp_err_t esp_wifi_deinit(void);
|
||||
*
|
||||
* @param wifi_mode_t mode : WiFi operating modes:
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
* - others : refer to error code in esp_err.h
|
||||
*/
|
||||
esp_err_t esp_wifi_set_mode(wifi_mode_t mode);
|
||||
|
||||
@ -126,8 +148,10 @@ esp_err_t esp_wifi_set_mode(wifi_mode_t mode);
|
||||
*
|
||||
* @param wifi_mode_t *mode : store current WiFi mode
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_get_mode(wifi_mode_t *mode);
|
||||
|
||||
@ -139,8 +163,13 @@ esp_err_t esp_wifi_get_mode(wifi_mode_t *mode);
|
||||
*
|
||||
* @param null
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
* - ESP_ERR_WIFI_NO_MEM : out of memory
|
||||
* - ESP_ERR_WIFI_CONN : WiFi internal error, station or soft-AP control block wrong
|
||||
* - ESP_ERR_WIFI_FAIL : other WiFi internal errors
|
||||
*/
|
||||
esp_err_t esp_wifi_start(void);
|
||||
|
||||
@ -152,8 +181,9 @@ esp_err_t esp_wifi_start(void);
|
||||
*
|
||||
* @param null
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
*/
|
||||
esp_err_t esp_wifi_stop(void);
|
||||
|
||||
@ -165,8 +195,12 @@ esp_err_t esp_wifi_stop(void);
|
||||
*
|
||||
* @param null
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_NOT_START : WiFi is not started by esp_wifi_start
|
||||
* - ESP_ERR_WIFI_CONN : WiFi internal error, station or soft-AP control block wrong
|
||||
* - ESP_ERR_WIFI_SSID : SSID of AP which station connects is invalid
|
||||
*/
|
||||
esp_err_t esp_wifi_connect(void);
|
||||
|
||||
@ -175,8 +209,11 @@ esp_err_t esp_wifi_connect(void);
|
||||
*
|
||||
* @param null
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_NOT_START : WiFi is not started by esp_wifi_start
|
||||
* - ESP_ERR_WIFI_FAIL : other WiFi internal errors
|
||||
*/
|
||||
esp_err_t esp_wifi_disconnect(void);
|
||||
|
||||
@ -185,8 +222,9 @@ esp_err_t esp_wifi_disconnect(void);
|
||||
*
|
||||
* @param null
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - others : fail
|
||||
*/
|
||||
esp_err_t esp_wifi_clear_fast_connect(void);
|
||||
|
||||
@ -195,8 +233,12 @@ esp_err_t esp_wifi_clear_fast_connect(void);
|
||||
*
|
||||
* @param uint16_t aid : when aid is 0, deauthenticate all stations, otherwise deauthenticate station whose associated id is aid
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_NOT_START : WiFi is not started by esp_wifi_start
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
* - ESP_ERR_WIFI_MODE : WiFi mode is wrong
|
||||
*/
|
||||
esp_err_t esp_wifi_deauth_sta(uint16_t aid);
|
||||
|
||||
@ -211,8 +253,12 @@ esp_err_t esp_wifi_deauth_sta(uint16_t aid);
|
||||
* @param bool block : if block is true, this API will block the caller until the scan is done, otherwise
|
||||
* it will return immediately
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_NOT_START : WiFi is not started by esp_wifi_start
|
||||
* - ESP_ERR_WIFI_TIMEOUT : blocking scan is timeout
|
||||
* - others : refer to error code in esp_err.h
|
||||
*/
|
||||
esp_err_t esp_wifi_scan_start(wifi_scan_config_t *conf, bool block);
|
||||
|
||||
@ -220,8 +266,10 @@ esp_err_t esp_wifi_scan_start(wifi_scan_config_t *conf, bool block);
|
||||
* @brief Stop the scan in process
|
||||
*
|
||||
* @param null
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_NOT_START : WiFi is not started by esp_wifi_start
|
||||
*/
|
||||
esp_err_t esp_wifi_scan_stop(void);
|
||||
|
||||
@ -232,8 +280,11 @@ esp_err_t esp_wifi_scan_stop(void);
|
||||
*
|
||||
* @attention This API can only be called when the scan is completed, otherwise it may get wrong value
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_NOT_START : WiFi is not started by esp_wifi_start
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_scan_get_ap_num(uint16_t *number);
|
||||
|
||||
@ -244,8 +295,12 @@ esp_err_t esp_wifi_scan_get_ap_num(uint16_t *number);
|
||||
the actual AP number this API returns
|
||||
* @param wifi_ap_record_t *ap_records: wifi_ap_record_t array to hold the found APs
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_NOT_START : WiFi is not started by esp_wifi_start
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
* - ESP_ERR_WIFI_NO_MEM : out of memory
|
||||
*/
|
||||
esp_err_t esp_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records);
|
||||
|
||||
@ -255,8 +310,9 @@ esp_err_t esp_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_re
|
||||
*
|
||||
* @param wifi_ap_record_t *ap_info: the wifi_ap_record_t to hold station assocated AP
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - others : fail
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info);
|
||||
|
||||
@ -265,8 +321,7 @@ esp_err_t esp_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info);
|
||||
*
|
||||
* @param wifi_ps_type_t type : power save type
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return ESP_ERR_WIFI_NOT_SUPPORT : not support yet
|
||||
*/
|
||||
esp_err_t esp_wifi_set_ps(wifi_ps_type_t type);
|
||||
|
||||
@ -275,8 +330,7 @@ esp_err_t esp_wifi_set_ps(wifi_ps_type_t type);
|
||||
*
|
||||
* @param wifi_ps_type_t *type : store current power save type
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return ESP_ERR_WIFI_NOT_SUPPORT : not support yet
|
||||
*/
|
||||
esp_err_t esp_wifi_get_ps(wifi_ps_type_t *type);
|
||||
|
||||
@ -289,8 +343,11 @@ esp_err_t esp_wifi_get_ps(wifi_ps_type_t *type);
|
||||
* @param wifi_interface_t ifx : interfaces
|
||||
* @param uint8_t protocol : WiFi protocol bitmap
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_IF : invalid interface
|
||||
* - others : refer to erro code in esp_err.h
|
||||
*/
|
||||
esp_err_t esp_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap);
|
||||
|
||||
@ -300,8 +357,12 @@ esp_err_t esp_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap);
|
||||
* @param wifi_interface_t ifx : interfaces
|
||||
* @param uint8_t protocol : store current WiFi protocol bitmap of interface ifx
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_IF : invalid interface
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
* - others : refer to error code in esp_err.h
|
||||
*/
|
||||
esp_err_t esp_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap);
|
||||
|
||||
@ -314,8 +375,12 @@ esp_err_t esp_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap);
|
||||
* @param wifi_interface_t ifx : interface to be configured
|
||||
* @param wifi_bandwidth_t bw : bandwidth
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_IF : invalid interface
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
* - others : refer to error code in esp_err.h
|
||||
*/
|
||||
esp_err_t esp_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw);
|
||||
|
||||
@ -327,8 +392,11 @@ esp_err_t esp_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw);
|
||||
* @param wifi_interface_t ifx : interface to be configured
|
||||
* @param wifi_bandwidth_t *bw : store bandwidth of interface ifx
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_IF : invalid interface
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw);
|
||||
|
||||
@ -340,8 +408,11 @@ esp_err_t esp_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw);
|
||||
* @param uint8_t primary : for HT20, primary is the channel number, for HT40, primary is the primary channel
|
||||
* @param wifi_second_chan_t second : for HT20, second is ignored, for HT40, second is the second channel
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_IF : invalid interface
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_set_channel(uint8_t primary, wifi_second_chan_t second);
|
||||
|
||||
@ -353,8 +424,10 @@ esp_err_t esp_wifi_set_channel(uint8_t primary, wifi_second_chan_t second);
|
||||
* @param uint8_t *primary : store current primary channel
|
||||
* @param wifi_second_chan_t *second : store current second channel
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second);
|
||||
|
||||
@ -364,8 +437,11 @@ esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second);
|
||||
*
|
||||
* @param wifi_country_t country : country type
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
* - others : refer to error code in esp_err.h
|
||||
*/
|
||||
esp_err_t esp_wifi_set_country(wifi_country_t country);
|
||||
|
||||
@ -374,8 +450,10 @@ esp_err_t esp_wifi_set_country(wifi_country_t country);
|
||||
*
|
||||
* @param wifi_country_t country : store current country
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_get_country(wifi_country_t *country);
|
||||
|
||||
@ -390,8 +468,14 @@ esp_err_t esp_wifi_get_country(wifi_country_t *country);
|
||||
* @param wifi_interface_t ifx : interface
|
||||
* @param uint8 mac[6]: the MAC address.
|
||||
*
|
||||
* @return true : succeed
|
||||
* @return false : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
* - ESP_ERR_WIFI_IF : invalid interface
|
||||
* - ESP_ERR_WIFI_MAC : invalid mac address
|
||||
* - ESP_ERR_WIFI_MODE : WiFi mode is wrong
|
||||
* - others : refer to error code in esp_err.h
|
||||
*/
|
||||
esp_err_t esp_wifi_set_mac(wifi_interface_t ifx, uint8_t mac[6]);
|
||||
|
||||
@ -400,8 +484,11 @@ esp_err_t esp_wifi_set_mac(wifi_interface_t ifx, uint8_t mac[6]);
|
||||
*
|
||||
* @param uint8_t mac[6] : store mac of this interface ifx
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
* - ESP_ERR_WIFI_IF : invalid interface
|
||||
*/
|
||||
esp_err_t esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]);
|
||||
|
||||
@ -413,8 +500,7 @@ esp_err_t esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]);
|
||||
* @param void *buf : the data received
|
||||
* @param uint16_t len : data length
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return none
|
||||
*/
|
||||
typedef void (* wifi_promiscuous_cb_t)(void *buf, uint16_t len);
|
||||
|
||||
@ -425,8 +511,9 @@ typedef void (* wifi_promiscuous_cb_t)(void *buf, uint16_t len);
|
||||
*
|
||||
* @param wifi_promiscuous_cb_t cb : callback
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
*/
|
||||
esp_err_t esp_wifi_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb);
|
||||
|
||||
@ -435,8 +522,9 @@ esp_err_t esp_wifi_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb);
|
||||
*
|
||||
* @param bool promiscuous : false - disable / true - enable
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
*/
|
||||
esp_err_t esp_wifi_set_promiscuous(bool en);
|
||||
|
||||
@ -445,8 +533,10 @@ esp_err_t esp_wifi_set_promiscuous(bool en);
|
||||
*
|
||||
* @param bool *enable : store the current status of promiscuous mode
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_get_promiscuous(bool *en);
|
||||
|
||||
@ -461,8 +551,15 @@ esp_err_t esp_wifi_get_promiscuous(bool *en);
|
||||
* @param wifi_interface_t ifx : interface
|
||||
* @param wifi_config_t *conf : station or soft-AP configuration
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
* - ESP_ERR_WIFI_IF : invalid interface
|
||||
* - ESP_ERR_WIFI_MODE : invalid mode
|
||||
* - ESP_ERR_WIFI_PASSWORD : invalid password
|
||||
* - ESP_ERR_WIFI_NVS : WiFi internal NVS error
|
||||
* - others : refer to the erro code in esp_err.h
|
||||
*/
|
||||
esp_err_t esp_wifi_set_config(wifi_interface_t ifx, wifi_config_t *conf);
|
||||
|
||||
@ -472,8 +569,11 @@ esp_err_t esp_wifi_set_config(wifi_interface_t ifx, wifi_config_t *conf);
|
||||
* @param wifi_interface_t ifx : interface
|
||||
* @param wifi_config_t *conf : station or soft-AP configuration
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
* - ESP_ERR_WIFI_IF : invalid interface
|
||||
*/
|
||||
esp_err_t esp_wifi_get_config(wifi_interface_t ifx, wifi_config_t *conf);
|
||||
|
||||
@ -484,8 +584,12 @@ esp_err_t esp_wifi_get_config(wifi_interface_t ifx, wifi_config_t *conf);
|
||||
*
|
||||
* @param wifi_sta_list_t *sta: station list
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
* - ESP_ERR_WIFI_MODE : WiFi mode is wrong
|
||||
* - ESP_ERR_WIFI_CONN : WiFi internal error, the station/soft-AP control block is invalid
|
||||
*/
|
||||
esp_err_t esp_wifi_ap_get_sta_list(wifi_sta_list_t *sta);
|
||||
|
||||
@ -497,42 +601,24 @@ esp_err_t esp_wifi_ap_get_sta_list(wifi_sta_list_t *sta);
|
||||
*
|
||||
* @param wifi_storage_t storage : storage type
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_set_storage(wifi_storage_t storage);
|
||||
|
||||
/**
|
||||
* @brief The WiFi RX callback function
|
||||
*
|
||||
* Each time the WiFi need to forward the packets to high layer, the callback function will be called
|
||||
*
|
||||
*/
|
||||
typedef esp_err_t (*wifi_rxcb_t)(void *buffer, uint16_t len, void *eb);
|
||||
|
||||
/**
|
||||
* @brief Set the WiFi RX callback
|
||||
*
|
||||
* @attention 1. Currently we support only one RX callback for each interface
|
||||
*
|
||||
* @param wifi_interface_t ifx : interface
|
||||
* @param wifi_rxcb_t fn : WiFi RX callback
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
*/
|
||||
esp_err_t esp_wifi_reg_rxcb(wifi_interface_t ifx, wifi_rxcb_t fn);
|
||||
|
||||
/**
|
||||
* @brief Set auto connect
|
||||
* The default value is true
|
||||
*
|
||||
* @attention 1.
|
||||
*
|
||||
* @param bool en : true - enable auto connect / false - disable auto connect
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_MODE : WiFi internal error, the station/soft-AP control block is invalid
|
||||
* - others : refer to error code in esp_err.h
|
||||
*/
|
||||
esp_err_t esp_wifi_set_auto_connect(bool en);
|
||||
|
||||
@ -541,8 +627,10 @@ esp_err_t esp_wifi_set_auto_connect(bool en);
|
||||
*
|
||||
* @param bool *en : store current auto connect configuration
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_get_auto_connect(bool *en);
|
||||
|
||||
@ -559,8 +647,11 @@ esp_err_t esp_wifi_get_auto_connect(bool *en);
|
||||
1 - WIFI_VND_IE_ID_1
|
||||
* @param uint8_t *vnd_ie : pointer to a vendor specific element
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
* - ESP_ERR_WIFI_ARG : invalid argument
|
||||
* - ESP_ERR_WIFI_NO_MEM : out of memory
|
||||
*/
|
||||
esp_err_t esp_wifi_set_vendor_ie(bool enable, wifi_vendor_ie_type_t type, wifi_vendor_ie_id_t idx, uint8_t *vnd_ie);
|
||||
|
||||
@ -584,8 +675,9 @@ typedef void (*esp_vendor_ie_cb_t) (void *ctx, wifi_vendor_ie_type_t type, const
|
||||
* @param esp_vendor_ie_cb_t cb : callback function
|
||||
* @param void *ctx : reserved
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
|
||||
*/
|
||||
esp_err_t esp_wifi_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx);
|
||||
|
||||
|
@ -62,16 +62,48 @@ void esp_wifi_internal_free_rx_buffer(void* buffer);
|
||||
/**
|
||||
* @brief transmit the buffer via wifi driver
|
||||
*
|
||||
* @attention1 TODO should modify the return type from bool to int
|
||||
*
|
||||
* @param wifi_interface_t wifi_if : wifi interface id
|
||||
* @param void *buffer : the buffer to be tansmit
|
||||
* @param u16_t len : the length of buffer
|
||||
*
|
||||
* @return True : success transmit the buffer to wifi driver
|
||||
* False : failed to transmit the buffer to wifi driver
|
||||
* @return
|
||||
* - ERR_OK : Successfully transmit the buffer to wifi driver
|
||||
* - ERR_MEM : Out of memory
|
||||
* - ERR_IF : WiFi driver error
|
||||
* - ERR_ARG : Invalid argument
|
||||
*/
|
||||
bool esp_wifi_internal_tx(wifi_interface_t wifi_if, void *buffer, u16_t len);
|
||||
int esp_wifi_internal_tx(wifi_interface_t wifi_if, void *buffer, u16_t len);
|
||||
|
||||
/**
|
||||
* @brief The WiFi RX callback function
|
||||
*
|
||||
* Each time the WiFi need to forward the packets to high layer, the callback function will be called
|
||||
*
|
||||
*/
|
||||
typedef esp_err_t (*wifi_rxcb_t)(void *buffer, uint16_t len, void *eb);
|
||||
|
||||
/**
|
||||
* @brief Set the WiFi RX callback
|
||||
*
|
||||
* @attention 1. Currently we support only one RX callback for each interface
|
||||
*
|
||||
* @param wifi_interface_t ifx : interface
|
||||
* @param wifi_rxcb_t fn : WiFi RX callback
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
*/
|
||||
esp_err_t esp_wifi_internal_reg_rxcb(wifi_interface_t ifx, wifi_rxcb_t fn);
|
||||
|
||||
/**
|
||||
* @brief Notify WIFI driver that the station got ip successfully
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return ESP_OK : succeed
|
||||
* @return others : fail
|
||||
*/
|
||||
esp_err_t esp_wifi_internal_set_sta_ip(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -154,10 +154,10 @@ typedef struct {
|
||||
uint8_t mac[6]; /**< mac address of sta that associated with ESP32 soft-AP */
|
||||
}wifi_sta_info_t;
|
||||
|
||||
#define ESP_WIFI_MAX_CONN_NUM (8+2) /**< max number of sta the eSP32 soft-AP can connect */
|
||||
#define ESP_WIFI_MAX_CONN_NUM (10) /**< max number of stations which can connect to ESP32 soft-AP */
|
||||
typedef struct {
|
||||
wifi_sta_info_t sta[ESP_WIFI_MAX_CONN_NUM]; /**< station list */
|
||||
uint8_t num; /**< number of station that associated with ESP32 soft-AP */
|
||||
int num; /**< number of station that associated with ESP32 soft-AP */
|
||||
}wifi_sta_list_t;
|
||||
|
||||
typedef enum {
|
||||
|
@ -3830,6 +3830,11 @@
|
||||
#define DPORT_DATE_S 0
|
||||
#define DPORT_DPORT_DATE_VERSION 0x1605190
|
||||
|
||||
/* Flash MMU table for PRO CPU */
|
||||
#define DPORT_PRO_FLASH_MMU_TABLE ((volatile uint32_t*) 0x3FF10000)
|
||||
|
||||
/* Flash MMU table for APP CPU */
|
||||
#define DPORT_APP_FLASH_MMU_TABLE ((volatile uint32_t*) 0x3FF12000)
|
||||
|
||||
|
||||
|
||||
|
49
tools/sdk/include/esp32/soc/frc_timer_reg.h
Normal file
49
tools/sdk/include/esp32/soc/frc_timer_reg.h
Normal file
@ -0,0 +1,49 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _SOC_FRC_TIMER_REG_H_
|
||||
#define _SOC_FRC_TIMER_REG_H_
|
||||
|
||||
#include "soc.h"
|
||||
|
||||
/**
|
||||
* These are the register definitions for "legacy" timers
|
||||
*/
|
||||
|
||||
#define REG_FRC_TIMER_BASE(i) (DR_REG_FRC_TIMER_BASE + i*0x20)
|
||||
|
||||
#define FRC_TIMER_LOAD_REG(i) (REG_FRC_TIMER_BASE(i) + 0x0) // timer load value (23 bit for i==0, 32 bit for i==1)
|
||||
#define FRC_TIMER_LOAD_VALUE(i) ((i == 0)?0x007FFFFF:0xffffffff)
|
||||
#define FRC_TIMER_LOAD_VALUE_S 0
|
||||
|
||||
#define FRC_TIMER_COUNT_REG(i) (REG_FRC_TIMER_BASE(i) + 0x4) // timer count value (23 bit for i==0, 32 bit for i==1)
|
||||
#define FRC_TIMER_COUNT ((i == 0)?0x007FFFFF:0xffffffff)
|
||||
#define FRC_TIMER_COUNT_S 0
|
||||
|
||||
#define FRC_TIMER_CTRL_REG(i) (REG_FRC_TIMER_BASE(i) + 0x8)
|
||||
#define FRC_TIMER_INT_ENABLE (BIT(8)) // enable interrupt
|
||||
#define FRC_TIMER_ENABLE (BIT(7)) // enable timer
|
||||
#define FRC_TIMER_AUTOLOAD (BIT(6)) // enable autoload
|
||||
#define FRC_TIMER_PRESCALER 0x00000007 // 0: divide by 1, 2: divide by 16, 4: divide by 256
|
||||
#define FRC_TIMER_PRESCALER_S 1
|
||||
#define FRC_TIMER_EDGE_INT (BIT(0)) // 0: level, 1: edge
|
||||
|
||||
#define FRC_TIMER_INT_REG(i) (REG_FRC_TIMER_BASE(i) + 0xC)
|
||||
#define FRC_TIMER_INT_CLR (BIT(0)) // clear interrupt
|
||||
|
||||
#define FRC_TIMER_ALARM_REG(i) (REG_FRC_TIMER_BASE(i) + 0x10) // timer alarm value; register only present for i == 1
|
||||
#define FRC_TIMER_ALARM 0xFFFFFFFF
|
||||
#define FRC_TIMER_ALARM_S 0
|
||||
|
||||
#endif //_SOC_FRC_TIMER_REG_H_
|
@ -231,11 +231,10 @@ typedef volatile struct {
|
||||
struct {
|
||||
union {
|
||||
struct {
|
||||
uint32_t level1: 1;
|
||||
uint32_t duration1: 15;
|
||||
uint32_t level0: 1;
|
||||
uint32_t duration0: 15;
|
||||
|
||||
uint32_t level0: 1;
|
||||
uint32_t duration1: 15;
|
||||
uint32_t level1: 1;
|
||||
};
|
||||
uint32_t val;
|
||||
} data[64];
|
||||
|
@ -239,6 +239,9 @@
|
||||
#define RTC_CNTL_TIME_VALID_V 0x1
|
||||
#define RTC_CNTL_TIME_VALID_S 30
|
||||
|
||||
/* frequency of RTC slow clock, Hz */
|
||||
#define RTC_CTNL_SLOWCLK_FREQ 150000
|
||||
|
||||
#define RTC_CNTL_TIME0_REG (DR_REG_RTCCNTL_BASE + 0x10)
|
||||
/* RTC_CNTL_TIME_LO : RO ;bitpos:[31:0] ;default: 32'h0 ; */
|
||||
/*description: RTC timer low 32 bits*/
|
||||
|
@ -148,6 +148,7 @@
|
||||
#define DR_REG_GPIO_SD_BASE 0x3ff44f00
|
||||
#define DR_REG_FE2_BASE 0x3ff45000
|
||||
#define DR_REG_FE_BASE 0x3ff46000
|
||||
#define DR_REG_FRC_TIMER_BASE 0x3ff47000
|
||||
#define DR_REG_RTCCNTL_BASE 0x3ff48000
|
||||
#define DR_REG_RTCIO_BASE 0x3ff48400
|
||||
#define DR_REG_SARADC_BASE 0x3ff48800
|
||||
@ -281,9 +282,9 @@
|
||||
* 19 2 extern level
|
||||
* 20 2 extern level
|
||||
* 21 2 extern level
|
||||
* 22 3 extern edge
|
||||
* 22 3 extern edge FRC1 timer
|
||||
* 23 3 extern level
|
||||
* 24 4 extern level
|
||||
* 24 4 extern level TG1_WDT
|
||||
* 25 4 extern level Reserved Reserved
|
||||
* 26 5 extern level Reserved Reserved
|
||||
* 27 3 extern level Reserved Reserved
|
||||
@ -301,8 +302,10 @@
|
||||
#define ETS_T0_WDT_INUM 3
|
||||
#define ETS_WBB_INUM 4
|
||||
#define ETS_TG0_T1_INUM 10 /**< use edge interrupt*/
|
||||
#define ETS_FRC1_INUM 22
|
||||
#define ETS_T1_WDT_INUM 24
|
||||
|
||||
//CPU0 Intrrupt number used in ROM, should be cancelled in SDK
|
||||
//CPU0 Interrupt number used in ROM, should be cancelled in SDK
|
||||
#define ETS_SLC_INUM 1
|
||||
#define ETS_UART0_INUM 5
|
||||
#define ETS_UART1_INUM 5
|
||||
|
@ -18,8 +18,10 @@
|
||||
#include "soc.h"
|
||||
|
||||
#define REG_UART_BASE( i ) (DR_REG_UART_BASE + (i) * 0x10000 + ( i > 1 ? 0xe000 : 0 ) )
|
||||
|
||||
#define REG_UART_AHB_BASE(i) (0x60000000 + (i) * 0x10000 + ( i > 1 ? 0xe000 : 0 ) )
|
||||
#define UART_FIFO_AHB_REG(i) (REG_UART_AHB_BASE(i) + 0x0)
|
||||
#define UART_FIFO_REG(i) (REG_UART_BASE(i) + 0x0)
|
||||
|
||||
/* UART_RXFIFO_RD_BYTE : RO ;bitpos:[7:0] ;default: 8'b0 ; */
|
||||
/*description: This register stores one byte data read by rx fifo.*/
|
||||
#define UART_RXFIFO_RD_BYTE 0x000000FF
|
||||
|
@ -180,7 +180,7 @@
|
||||
/* The Xtensa port uses a separate interrupt stack. Adjust the stack size */
|
||||
/* to suit the needs of your specific application. */
|
||||
#ifndef configISR_STACK_SIZE
|
||||
#define configISR_STACK_SIZE 1024//2048
|
||||
#define configISR_STACK_SIZE CONFIG_FREERTOS_ISR_STACKSIZE
|
||||
#endif
|
||||
|
||||
/* Minimal heap size to make sure examples can run on memory limited
|
||||
|
@ -179,6 +179,14 @@ BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION;
|
||||
*/
|
||||
void vPortEndScheduler( void ) PRIVILEGED_FUNCTION;
|
||||
|
||||
|
||||
/*
|
||||
* Send an interrupt to another core in order to make the task running
|
||||
* on it yield for a higher-priority task.
|
||||
*/
|
||||
|
||||
void vPortYieldOtherCore( BaseType_t coreid) PRIVILEGED_FUNCTION;
|
||||
|
||||
/*
|
||||
* The structures and methods of manipulating the MPU are contained within the
|
||||
* port layer.
|
||||
|
@ -18,22 +18,34 @@ to this bit of memory will block.
|
||||
|
||||
The requirement for items to be contiguous is slightly problematic when the only way to place
|
||||
the next item would involve a wraparound from the end to the beginning of the ringbuffer. This can
|
||||
be solved in two ways:
|
||||
- allow_split_items = pdTRUE: The insertion code will split the item in two items; one which fits
|
||||
be solved (or not) in a few ways:
|
||||
- type = RINGBUF_TYPE_ALLOWSPLIT: The insertion code will split the item in two items; one which fits
|
||||
in the space left at the end of the ringbuffer, one that contains the remaining data which is placed
|
||||
in the beginning. Two xRingbufferReceive calls will be needed to retrieve the data.
|
||||
- allow_split_items = pdFALSE: The insertion code will leave the room at the end of the ringbuffer
|
||||
- type = RINGBUF_TYPE_NOSPLIT: The insertion code will leave the room at the end of the ringbuffer
|
||||
unused and instead will put the entire item at the start of the ringbuffer, as soon as there is
|
||||
enough free space.
|
||||
- type = RINGBUF_TYPE_BYTEBUF: This is your conventional byte-based ringbuffer. It does have no
|
||||
overhead, but it has no item contiguousness either: a read will just give you the entire written
|
||||
buffer space, or the space up to the end of the buffer, and writes can be broken up in any way
|
||||
possible. Note that this type cannot do a 2nd read before returning the memory of the 1st.
|
||||
|
||||
The maximum size of an item will be affected by this decision. When split items are allowed, it's
|
||||
acceptable to push items of (buffer_size)-16 bytes into the buffer. When it's not allowed, the
|
||||
maximum size is (buffer_size/2)-8 bytes.
|
||||
maximum size is (buffer_size/2)-8 bytes. The bytebuf can fill the entire buffer with data, it has
|
||||
no overhead.
|
||||
*/
|
||||
|
||||
//An opaque handle for a ringbuff object.
|
||||
typedef void * RingbufHandle_t;
|
||||
|
||||
//The various types of buffer
|
||||
typedef enum {
|
||||
RINGBUF_TYPE_NOSPLIT = 0,
|
||||
RINGBUF_TYPE_ALLOWSPLIT,
|
||||
RINGBUF_TYPE_BYTEBUF
|
||||
} ringbuf_type_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Create a ring buffer
|
||||
@ -45,7 +57,7 @@ typedef void * RingbufHandle_t;
|
||||
*
|
||||
* @return A RingbufHandle_t handle to the created ringbuffer, or NULL in case of error.
|
||||
*/
|
||||
RingbufHandle_t xRingbufferCreate(size_t buf_length, BaseType_t allow_split_items);
|
||||
RingbufHandle_t xRingbufferCreate(size_t buf_length, ringbuf_type_t type);
|
||||
|
||||
|
||||
/**
|
||||
@ -120,6 +132,34 @@ void *xRingbufferReceive(RingbufHandle_t ringbuf, size_t *item_size, TickType_t
|
||||
void *xRingbufferReceiveFromISR(RingbufHandle_t ringbuf, size_t *item_size);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Retrieve bytes from a ByteBuf type of ring buffer, specifying the maximum amount of bytes
|
||||
* to return
|
||||
*
|
||||
* @param ringbuf - Ring buffer to retrieve the item from
|
||||
* @param item_size - Pointer to a variable to which the size of the retrieved item will be written.
|
||||
* @param xTicksToWait - Ticks to wait for items in the ringbuffer.
|
||||
*
|
||||
* @return Pointer to the retrieved item on success; *item_size filled with the length of the
|
||||
* item. NULL on timeout, *item_size is untouched in that case.
|
||||
*/
|
||||
void *xRingbufferReceiveUpTo(RingbufHandle_t ringbuf, size_t *item_size, TickType_t ticks_to_wait, size_t wanted_size);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Retrieve bytes from a ByteBuf type of ring buffer, specifying the maximum amount of bytes
|
||||
* to return. Call this from an ISR.
|
||||
*
|
||||
* @param ringbuf - Ring buffer to retrieve the item from
|
||||
* @param item_size - Pointer to a variable to which the size of the retrieved item will be written.
|
||||
*
|
||||
* @return Pointer to the retrieved item on success; *item_size filled with the length of the
|
||||
* item. NULL when the ringbuffer is empty, *item_size is untouched in that case.
|
||||
*/
|
||||
void *xRingbufferReceiveUpToFromISR(RingbufHandle_t ringbuf, size_t *item_size, size_t wanted_size);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Return a previously-retrieved item to the ringbuffer
|
||||
*
|
||||
|
@ -24,76 +24,16 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Logging library
|
||||
*
|
||||
* Log library has two ways of managing log verbosity: compile time, set via
|
||||
* menuconfig, and runtime, using esp_log_set_level function.
|
||||
*
|
||||
* At compile time, filtering is done using CONFIG_LOG_DEFAULT_LEVEL macro, set via
|
||||
* menuconfig. All logging statments for levels higher than CONFIG_LOG_DEFAULT_LEVEL
|
||||
* will be removed by the preprocessor.
|
||||
*
|
||||
* At run time, all logs below CONFIG_LOG_DEFAULT_LEVEL are enabled by default.
|
||||
* esp_log_set_level function may be used to set logging level per module.
|
||||
* Modules are identified by their tags, which are human-readable ASCII
|
||||
* zero-terminated strings.
|
||||
*
|
||||
* How to use this library:
|
||||
*
|
||||
* In each C file which uses logging functionality, define TAG variable like this:
|
||||
*
|
||||
* static const char* TAG = "MyModule";
|
||||
*
|
||||
* then use one of logging macros to produce output, e.g:
|
||||
*
|
||||
* ESP_LOGW(TAG, "Baud rate error %.1f%%. Requested: %d baud, actual: %d baud", error * 100, baud_req, baud_real);
|
||||
*
|
||||
* Several macros are available for different verbosity levels:
|
||||
*
|
||||
* ESP_LOGE — error
|
||||
* ESP_LOGW — warning
|
||||
* ESP_LOGI — info
|
||||
* ESP_LOGD - debug
|
||||
* ESP_LOGV - verbose
|
||||
*
|
||||
* Additionally there is an _EARLY_ variant for each of these macros (e.g. ESP_EARLY_LOGE).
|
||||
* These variants can run in startup code, before heap allocator and syscalls
|
||||
* have been initialized.
|
||||
* When compiling bootloader, normal ESP_LOGx macros fall back to the same implementation
|
||||
* as ESP_EARLY_LOGx macros. So the only place where ESP_EARLY_LOGx have to be used explicitly
|
||||
* is the early startup code, such as heap allocator initialization code.
|
||||
*
|
||||
* (Note that such distinction would not have been necessary if we would have an
|
||||
* ets_vprintf function in the ROM. Then it would be possible to switch implementation
|
||||
* from _EARLY version to normal version on the fly. Unfortunately, ets_vprintf in ROM
|
||||
* has been inlined by the compiler into ets_printf, so it is not accessible outside.)
|
||||
*
|
||||
* To override default verbosity level at file or component scope, define LOG_LOCAL_LEVEL macro.
|
||||
* At file scope, define it before including esp_log.h, e.g.:
|
||||
*
|
||||
* #define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
|
||||
* #include "esp_log.h"
|
||||
*
|
||||
* At component scope, define it in component makefile:
|
||||
*
|
||||
* CFLAGS += -D LOG_LOCAL_LEVEL=ESP_LOG_DEBUG
|
||||
*
|
||||
* To configure logging output per module at runtime, add calls to esp_log_set_level function:
|
||||
*
|
||||
* esp_log_set_level("*", ESP_LOG_ERROR); // set all components to ERROR level
|
||||
* esp_log_set_level("wifi", ESP_LOG_WARN); // enable WARN logs from WiFi stack
|
||||
* esp_log_set_level("dhcpc", ESP_LOG_INFO); // enable INFO logs from DHCP client
|
||||
* @brief Log level
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
typedef enum {
|
||||
ESP_LOG_NONE, // No log output
|
||||
ESP_LOG_ERROR, // Critical errors, software module can not recover on its own
|
||||
ESP_LOG_WARN, // Error conditions from which recovery measures have been taken
|
||||
ESP_LOG_INFO, // Information messages which describe normal flow of events
|
||||
ESP_LOG_DEBUG, // Extra information which is not necessary for normal use (values, pointers, sizes, etc).
|
||||
ESP_LOG_VERBOSE // Bigger chunks of debugging information, or frequent messages which can potentially flood the output.
|
||||
ESP_LOG_NONE, /*!< No log output */
|
||||
ESP_LOG_ERROR, /*!< Critical errors, software module can not recover on its own */
|
||||
ESP_LOG_WARN, /*!< Error conditions from which recovery measures have been taken */
|
||||
ESP_LOG_INFO, /*!< Information messages which describe normal flow of events */
|
||||
ESP_LOG_DEBUG, /*!< Extra information which is not necessary for normal use (values, pointers, sizes, etc). */
|
||||
ESP_LOG_VERBOSE /*!< Bigger chunks of debugging information, or frequent messages which can potentially flood the output. */
|
||||
} esp_log_level_t;
|
||||
|
||||
typedef int (*vprintf_like_t)(const char *, va_list);
|
||||
@ -120,17 +60,6 @@ void esp_log_level_set(const char* tag, esp_log_level_t level);
|
||||
*/
|
||||
void esp_log_set_vprintf(vprintf_like_t func);
|
||||
|
||||
/**
|
||||
* @brief Write message into the log
|
||||
*
|
||||
* This function is not intended to be used directly. Instead, use one of
|
||||
* ESP_LOGE, ESP_LOGW, ESP_LOGI, ESP_LOGD, ESP_LOGV macros.
|
||||
*
|
||||
* This function or these macros should not be used from an interrupt.
|
||||
*/
|
||||
void esp_log_write(esp_log_level_t level, const char* tag, const char* format, ...) __attribute__ ((format (printf, 3, 4)));
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function which returns timestamp to be used in log output
|
||||
*
|
||||
@ -143,7 +72,17 @@ void esp_log_write(esp_log_level_t level, const char* tag, const char* format, .
|
||||
*
|
||||
* @return timestamp, in milliseconds
|
||||
*/
|
||||
uint32_t esp_log_timestamp();
|
||||
uint32_t esp_log_timestamp(void);
|
||||
|
||||
/**
|
||||
* @brief Write message into the log
|
||||
*
|
||||
* This function is not intended to be used directly. Instead, use one of
|
||||
* ESP_LOGE, ESP_LOGW, ESP_LOGI, ESP_LOGD, ESP_LOGV macros.
|
||||
*
|
||||
* This function or these macros should not be used from an interrupt.
|
||||
*/
|
||||
void esp_log_write(esp_log_level_t level, const char* tag, const char* format, ...) __attribute__ ((format (printf, 3, 4)));
|
||||
|
||||
|
||||
#if CONFIG_LOG_COLORS
|
||||
|
@ -33,6 +33,9 @@
|
||||
#define __LWIPOPTS_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include "esp_task.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
@ -95,17 +98,37 @@ extern unsigned long os_random(void);
|
||||
---------- Internal Memory Pool Sizes ----------
|
||||
------------------------------------------------
|
||||
*/
|
||||
/**
|
||||
* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections.
|
||||
* (requires the LWIP_TCP option)
|
||||
*/
|
||||
#define MEMP_NUM_TCP_PCB 5
|
||||
|
||||
/**
|
||||
* MEMP_NUM_NETCONN: the number of struct netconns.
|
||||
* (only needed if you use the sequential API, like api_lib.c)
|
||||
*/
|
||||
#define MEMP_NUM_NETCONN 10
|
||||
#define MEMP_NUM_NETCONN CONFIG_LWIP_MAX_SOCKETS
|
||||
|
||||
/**
|
||||
* MEMP_NUM_RAW_PCB: Number of raw connection PCBs
|
||||
* (requires the LWIP_RAW option)
|
||||
*/
|
||||
#define MEMP_NUM_RAW_PCB 16
|
||||
|
||||
/**
|
||||
* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections.
|
||||
* (requires the LWIP_TCP option)
|
||||
*/
|
||||
#define MEMP_NUM_TCP_PCB 16
|
||||
|
||||
/**
|
||||
* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections.
|
||||
* (requires the LWIP_TCP option)
|
||||
*/
|
||||
#define MEMP_NUM_TCP_PCB_LISTEN 16
|
||||
|
||||
/**
|
||||
* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
||||
* per active UDP "connection".
|
||||
* (requires the LWIP_UDP option)
|
||||
*/
|
||||
#define MEMP_NUM_UDP_PCB 16
|
||||
|
||||
/*
|
||||
--------------------------------
|
||||
@ -220,26 +243,6 @@ extern unsigned long os_random(void);
|
||||
---------- TCP options ----------
|
||||
---------------------------------
|
||||
*/
|
||||
/**
|
||||
* TCP_WND: The size of a TCP window. This must be at least
|
||||
* (2 * TCP_MSS) for things to work well
|
||||
*/
|
||||
|
||||
#define ESP_PER_SOC_TCP_WND 1
|
||||
#if ESP_PER_SOC_TCP_WND
|
||||
#define TCP_WND_DEFAULT (4*TCP_MSS)
|
||||
#define TCP_SND_BUF_DEFAULT (2*TCP_MSS)
|
||||
|
||||
#define TCP_WND(pcb) (pcb->per_soc_tcp_wnd)
|
||||
#define TCP_SND_BUF(pcb) (pcb->per_soc_tcp_snd_buf)
|
||||
#else
|
||||
#ifdef PERF
|
||||
extern unsigned char misc_prof_get_tcpw(void);
|
||||
extern unsigned char misc_prof_get_tcp_snd_buf(void);
|
||||
#define TCP_WND(pcb) (misc_prof_get_tcpw()*TCP_MSS)
|
||||
#define TCP_SND_BUF(pcb) (misc_prof_get_tcp_snd_buf()*TCP_MSS)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
@ -523,10 +526,10 @@ extern unsigned char misc_prof_get_tcp_snd_buf(void);
|
||||
#define ESP_IP4_ATON 1
|
||||
#define ESP_LIGHT_SLEEP 1
|
||||
|
||||
|
||||
#if ESP_PER_SOC_TCP_WND
|
||||
#define TCP_WND_DEFAULT (4*TCP_MSS)
|
||||
#define TCP_SND_BUF_DEFAULT (2*TCP_MSS)
|
||||
|
||||
#if ESP_PER_SOC_TCP_WND
|
||||
#define TCP_WND(pcb) (pcb->per_soc_tcp_wnd)
|
||||
#define TCP_SND_BUF(pcb) (pcb->per_soc_tcp_snd_buf)
|
||||
#else
|
||||
@ -542,19 +545,32 @@ extern unsigned char misc_prof_get_tcp_snd_buf(void);
|
||||
* DHCP_DEBUG: Enable debugging in dhcp.c.
|
||||
*/
|
||||
#define DHCP_DEBUG LWIP_DBG_OFF
|
||||
#define LWIP_DEBUG 0
|
||||
#define LWIP_DEBUG LWIP_DBG_OFF
|
||||
#define TCP_DEBUG LWIP_DBG_OFF
|
||||
#define ESP_THREAD_SAFE_DEBUG LWIP_DBG_OFF
|
||||
#define ESP_THREAD_SAFE_DEBUG LWIP_DBG_OFF
|
||||
|
||||
#define CHECKSUM_CHECK_UDP 0
|
||||
#define CHECKSUM_CHECK_IP 0
|
||||
|
||||
#define HEAP_HIGHWAT 20*1024
|
||||
|
||||
#define LWIP_NETCONN_FULLDUPLEX 1
|
||||
#define LWIP_NETCONN_SEM_PER_THREAD 1
|
||||
|
||||
#define LWIP_DHCP_MAX_NTP_SERVERS CONFIG_LWIP_DHCP_MAX_NTP_SERVERS
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
|
||||
#define SNTP_SET_SYSTEM_TIME_US(sec, us) \
|
||||
do { \
|
||||
struct timeval tv = { .tv_sec = sec, .tv_usec = us }; \
|
||||
settimeofday(&tv, NULL); \
|
||||
} while (0);
|
||||
|
||||
#define SNTP_GET_SYSTEM_TIME(sec, us) \
|
||||
do { \
|
||||
struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; \
|
||||
gettimeofday(&tv, NULL); \
|
||||
(sec) = tv.tv_sec; \
|
||||
(us) = tv.tv_usec; \
|
||||
} while (0);
|
||||
|
||||
#define SOC_SEND_LOG //printf
|
||||
|
||||
|
@ -33,6 +33,9 @@
|
||||
#define __LWIPOPTS_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include "esp_task.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
@ -95,17 +98,37 @@ extern unsigned long os_random(void);
|
||||
---------- Internal Memory Pool Sizes ----------
|
||||
------------------------------------------------
|
||||
*/
|
||||
/**
|
||||
* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections.
|
||||
* (requires the LWIP_TCP option)
|
||||
*/
|
||||
#define MEMP_NUM_TCP_PCB 5
|
||||
|
||||
/**
|
||||
* MEMP_NUM_NETCONN: the number of struct netconns.
|
||||
* (only needed if you use the sequential API, like api_lib.c)
|
||||
*/
|
||||
#define MEMP_NUM_NETCONN 10
|
||||
#define MEMP_NUM_NETCONN CONFIG_LWIP_MAX_SOCKETS
|
||||
|
||||
/**
|
||||
* MEMP_NUM_RAW_PCB: Number of raw connection PCBs
|
||||
* (requires the LWIP_RAW option)
|
||||
*/
|
||||
#define MEMP_NUM_RAW_PCB 16
|
||||
|
||||
/**
|
||||
* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections.
|
||||
* (requires the LWIP_TCP option)
|
||||
*/
|
||||
#define MEMP_NUM_TCP_PCB 16
|
||||
|
||||
/**
|
||||
* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections.
|
||||
* (requires the LWIP_TCP option)
|
||||
*/
|
||||
#define MEMP_NUM_TCP_PCB_LISTEN 16
|
||||
|
||||
/**
|
||||
* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
||||
* per active UDP "connection".
|
||||
* (requires the LWIP_UDP option)
|
||||
*/
|
||||
#define MEMP_NUM_UDP_PCB 16
|
||||
|
||||
/*
|
||||
--------------------------------
|
||||
@ -220,26 +243,6 @@ extern unsigned long os_random(void);
|
||||
---------- TCP options ----------
|
||||
---------------------------------
|
||||
*/
|
||||
/**
|
||||
* TCP_WND: The size of a TCP window. This must be at least
|
||||
* (2 * TCP_MSS) for things to work well
|
||||
*/
|
||||
|
||||
#define ESP_PER_SOC_TCP_WND 1
|
||||
#if ESP_PER_SOC_TCP_WND
|
||||
#define TCP_WND_DEFAULT (4*TCP_MSS)
|
||||
#define TCP_SND_BUF_DEFAULT (2*TCP_MSS)
|
||||
|
||||
#define TCP_WND(pcb) (pcb->per_soc_tcp_wnd)
|
||||
#define TCP_SND_BUF(pcb) (pcb->per_soc_tcp_snd_buf)
|
||||
#else
|
||||
#ifdef PERF
|
||||
extern unsigned char misc_prof_get_tcpw(void);
|
||||
extern unsigned char misc_prof_get_tcp_snd_buf(void);
|
||||
#define TCP_WND(pcb) (misc_prof_get_tcpw()*TCP_MSS)
|
||||
#define TCP_SND_BUF(pcb) (misc_prof_get_tcp_snd_buf()*TCP_MSS)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
@ -523,10 +526,10 @@ extern unsigned char misc_prof_get_tcp_snd_buf(void);
|
||||
#define ESP_IP4_ATON 1
|
||||
#define ESP_LIGHT_SLEEP 1
|
||||
|
||||
|
||||
#if ESP_PER_SOC_TCP_WND
|
||||
#define TCP_WND_DEFAULT (4*TCP_MSS)
|
||||
#define TCP_SND_BUF_DEFAULT (2*TCP_MSS)
|
||||
|
||||
#if ESP_PER_SOC_TCP_WND
|
||||
#define TCP_WND(pcb) (pcb->per_soc_tcp_wnd)
|
||||
#define TCP_SND_BUF(pcb) (pcb->per_soc_tcp_snd_buf)
|
||||
#else
|
||||
@ -542,19 +545,32 @@ extern unsigned char misc_prof_get_tcp_snd_buf(void);
|
||||
* DHCP_DEBUG: Enable debugging in dhcp.c.
|
||||
*/
|
||||
#define DHCP_DEBUG LWIP_DBG_OFF
|
||||
#define LWIP_DEBUG 0
|
||||
#define LWIP_DEBUG LWIP_DBG_OFF
|
||||
#define TCP_DEBUG LWIP_DBG_OFF
|
||||
#define ESP_THREAD_SAFE_DEBUG LWIP_DBG_OFF
|
||||
#define ESP_THREAD_SAFE_DEBUG LWIP_DBG_OFF
|
||||
|
||||
#define CHECKSUM_CHECK_UDP 0
|
||||
#define CHECKSUM_CHECK_IP 0
|
||||
|
||||
#define HEAP_HIGHWAT 20*1024
|
||||
|
||||
#define LWIP_NETCONN_FULLDUPLEX 1
|
||||
#define LWIP_NETCONN_SEM_PER_THREAD 1
|
||||
|
||||
#define LWIP_DHCP_MAX_NTP_SERVERS CONFIG_LWIP_DHCP_MAX_NTP_SERVERS
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
|
||||
#define SNTP_SET_SYSTEM_TIME_US(sec, us) \
|
||||
do { \
|
||||
struct timeval tv = { .tv_sec = sec, .tv_usec = us }; \
|
||||
settimeofday(&tv, NULL); \
|
||||
} while (0);
|
||||
|
||||
#define SNTP_GET_SYSTEM_TIME(sec, us) \
|
||||
do { \
|
||||
struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; \
|
||||
gettimeofday(&tv, NULL); \
|
||||
(sec) = tv.tv_sec; \
|
||||
(us) = tv.tv_usec; \
|
||||
} while (0);
|
||||
|
||||
#define SOC_SEND_LOG //printf
|
||||
|
||||
|
@ -28,23 +28,27 @@ extern "C" {
|
||||
*/
|
||||
typedef uint32_t nvs_handle;
|
||||
|
||||
#define ESP_ERR_NVS_BASE 0x1100
|
||||
#define ESP_ERR_NVS_NOT_INITIALIZED (ESP_ERR_NVS_BASE + 0x01)
|
||||
#define ESP_ERR_NVS_NOT_FOUND (ESP_ERR_NVS_BASE + 0x02)
|
||||
#define ESP_ERR_NVS_TYPE_MISMATCH (ESP_ERR_NVS_BASE + 0x03)
|
||||
#define ESP_ERR_NVS_READ_ONLY (ESP_ERR_NVS_BASE + 0x04)
|
||||
#define ESP_ERR_NVS_NOT_ENOUGH_SPACE (ESP_ERR_NVS_BASE + 0x05)
|
||||
#define ESP_ERR_NVS_INVALID_NAME (ESP_ERR_NVS_BASE + 0x06)
|
||||
#define ESP_ERR_NVS_INVALID_HANDLE (ESP_ERR_NVS_BASE + 0x07)
|
||||
#define ESP_ERR_NVS_REMOVE_FAILED (ESP_ERR_NVS_BASE + 0x08)
|
||||
#define ESP_ERR_NVS_KEY_TOO_LONG (ESP_ERR_NVS_BASE + 0x09)
|
||||
#define ESP_ERR_NVS_PAGE_FULL (ESP_ERR_NVS_BASE + 0x0a)
|
||||
#define ESP_ERR_NVS_INVALID_STATE (ESP_ERR_NVS_BASE + 0x0b)
|
||||
#define ESP_ERR_NVS_INVALID_LENGTH (ESP_ERR_NVS_BASE + 0x0c)
|
||||
#define ESP_ERR_NVS_BASE 0x1100 /*!< Starting number of error codes */
|
||||
#define ESP_ERR_NVS_NOT_INITIALIZED (ESP_ERR_NVS_BASE + 0x01) /*!< The storage driver is not initialized */
|
||||
#define ESP_ERR_NVS_NOT_FOUND (ESP_ERR_NVS_BASE + 0x02) /*!< Id namespace doesn’t exist yet and mode is NVS_READONLY */
|
||||
#define ESP_ERR_NVS_TYPE_MISMATCH (ESP_ERR_NVS_BASE + 0x03) /*!< TBA */
|
||||
#define ESP_ERR_NVS_READ_ONLY (ESP_ERR_NVS_BASE + 0x04) /*!< Storage handle was opened as read only */
|
||||
#define ESP_ERR_NVS_NOT_ENOUGH_SPACE (ESP_ERR_NVS_BASE + 0x05) /*!< There is not enough space in the underlying storage to save the value */
|
||||
#define ESP_ERR_NVS_INVALID_NAME (ESP_ERR_NVS_BASE + 0x06) /*!< Namespace name doesn’t satisfy constraints */
|
||||
#define ESP_ERR_NVS_INVALID_HANDLE (ESP_ERR_NVS_BASE + 0x07) /*!< Handle has been closed or is NULL */
|
||||
#define ESP_ERR_NVS_REMOVE_FAILED (ESP_ERR_NVS_BASE + 0x08) /*!< The value wasn’t updated because flash write operation has failed. The value was written however, and update will be finished after re-initialization of nvs, provided that flash operation doesn’t fail again. */
|
||||
#define ESP_ERR_NVS_KEY_TOO_LONG (ESP_ERR_NVS_BASE + 0x09) /*!< TBA */
|
||||
#define ESP_ERR_NVS_PAGE_FULL (ESP_ERR_NVS_BASE + 0x0a) /*!< TBA */
|
||||
#define ESP_ERR_NVS_INVALID_STATE (ESP_ERR_NVS_BASE + 0x0b) /*!< TBA */
|
||||
#define ESP_ERR_NVS_INVALID_LENGTH (ESP_ERR_NVS_BASE + 0x0c) /*!< TBA */
|
||||
|
||||
/**
|
||||
* @brief Mode of opening the non-volatile storage
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
NVS_READONLY,
|
||||
NVS_READWRITE
|
||||
NVS_READONLY, /*!< Read only */
|
||||
NVS_READWRITE /*!< Read and write */
|
||||
} nvs_open_mode;
|
||||
|
||||
/**
|
||||
@ -58,12 +62,13 @@ typedef enum {
|
||||
* underlying implementation, but is guaranteed to be
|
||||
* at least 16 characters. Shouldn't be empty.
|
||||
* @param[in] open_mode NVS_READWRITE or NVS_READONLY. If NVS_READONLY, will
|
||||
* open a handle for reading only. All write requests will
|
||||
* be rejected for this handle.
|
||||
* open a handle for reading only. All write requests will
|
||||
* be rejected for this handle.
|
||||
* @param[out] out_handle If successful (return code is zero), handle will be
|
||||
* returned in this argument.
|
||||
*
|
||||
* @return - ESP_OK if storage handle was opened successfully
|
||||
* @return
|
||||
* - ESP_OK if storage handle was opened successfully
|
||||
* - ESP_ERR_NVS_NOT_INITIALIZED if the storage driver is not initialized
|
||||
* - ESP_ERR_NVS_NOT_FOUND id namespace doesn't exist yet and
|
||||
* mode is NVS_READONLY
|
||||
@ -86,7 +91,8 @@ esp_err_t nvs_open(const char* name, nvs_open_mode open_mode, nvs_handle *out_ha
|
||||
* @param[in] value The value to set.
|
||||
* @param[in] length For nvs_set_blob: length of binary value to set, in bytes.
|
||||
*
|
||||
* @return - ESP_OK if value was set successfully
|
||||
* @return
|
||||
* - ESP_OK if value was set successfully
|
||||
* - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL
|
||||
* - ESP_ERR_NVS_READ_ONLY if storage handle was opened as read only
|
||||
* - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints
|
||||
@ -129,24 +135,26 @@ esp_err_t nvs_set_blob(nvs_handle handle, const char* key, const void* value, si
|
||||
* It is suggested that nvs_get/set_str is used for zero-terminated C strings, and
|
||||
* nvs_get/set_blob used for arbitrary data structures.
|
||||
*
|
||||
* Example of using nvs_get_i32:
|
||||
* \code{c}
|
||||
* // Example of using nvs_get_i32:
|
||||
* int32_t max_buffer_size = 4096; // default value
|
||||
* esp_err_t err = nvs_get_i32(my_handle, "max_buffer_size", &max_buffer_size);
|
||||
* assert(err == ESP_OK || err == ESP_ERR_NVS_NOT_FOUND);
|
||||
* // if ESP_ERR_NVS_NOT_FOUND was returned, max_buffer_size will still
|
||||
* // have its default value.
|
||||
*
|
||||
* Example (without error checking) of using nvs_get_str to get a string into dynamic array:
|
||||
* // Example (without error checking) of using nvs_get_str to get a string into dynamic array:
|
||||
* size_t required_size;
|
||||
* nvs_get_str(my_handle, "server_name", NULL, &required_size);
|
||||
* char* server_name = malloc(required_size);
|
||||
* nvs_get_str(my_handle, "server_name", server_name, &required_size);
|
||||
*
|
||||
* Example (without error checking) of using nvs_get_blob to get a binary data
|
||||
* // Example (without error checking) of using nvs_get_blob to get a binary data
|
||||
* into a static array:
|
||||
* uint8_t mac_addr[6];
|
||||
* size_t size = sizeof(mac_addr);
|
||||
* nvs_get_blob(my_handle, "dst_mac_addr", mac_addr, &size);
|
||||
* \endcode
|
||||
*
|
||||
* @param[in] handle Handle obtained from nvs_open function.
|
||||
* @param[in] key Key name. Maximal length is determined by the underlying
|
||||
@ -162,7 +170,8 @@ esp_err_t nvs_set_blob(nvs_handle handle, const char* key, const void* value, si
|
||||
* zero, will be set to the actual length of the value
|
||||
* written. For nvs_get_str this includes zero terminator.
|
||||
*
|
||||
* @return - ESP_OK if the value was retrieved successfully
|
||||
* @return
|
||||
* - ESP_OK if the value was retrieved successfully
|
||||
* - ESP_ERR_NVS_NOT_FOUND if the requested key doesn't exist
|
||||
* - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL
|
||||
* - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints
|
||||
@ -191,7 +200,8 @@ esp_err_t nvs_get_blob(nvs_handle handle, const char* key, void* out_value, size
|
||||
* implementation, but is guaranteed to be at least
|
||||
* 16 characters. Shouldn't be empty.
|
||||
*
|
||||
* @return - ESP_OK if erase operation was successful
|
||||
* @return
|
||||
* - ESP_OK if erase operation was successful
|
||||
* - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL
|
||||
* - ESP_ERR_NVS_READ_ONLY if handle was opened as read only
|
||||
* - ESP_ERR_NVS_NOT_FOUND if the requested key doesn't exist
|
||||
@ -207,7 +217,8 @@ esp_err_t nvs_erase_key(nvs_handle handle, const char* key);
|
||||
* @param[in] handle Storage handle obtained with nvs_open.
|
||||
* Handles that were opened read only cannot be used.
|
||||
*
|
||||
* @return - ESP_OK if erase operation was successful
|
||||
* @return
|
||||
* - ESP_OK if erase operation was successful
|
||||
* - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL
|
||||
* - ESP_ERR_NVS_READ_ONLY if handle was opened as read only
|
||||
* - other error codes from the underlying storage driver
|
||||
@ -224,7 +235,8 @@ esp_err_t nvs_erase_all(nvs_handle handle);
|
||||
* @param[in] handle Storage handle obtained with nvs_open.
|
||||
* Handles that were opened read only cannot be used.
|
||||
*
|
||||
* @return - ESP_OK if the changes have been written successfully
|
||||
* @return
|
||||
* - ESP_OK if the changes have been written successfully
|
||||
* - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL
|
||||
* - other error codes from the underlying storage driver
|
||||
*/
|
||||
@ -249,3 +261,4 @@ void nvs_close(nvs_handle handle);
|
||||
#endif
|
||||
|
||||
#endif //ESP_NVS_H
|
||||
|
||||
|
@ -22,6 +22,8 @@ extern "C" {
|
||||
|
||||
Temporarily, this region is hardcoded as a 12KB (0x3000 byte)
|
||||
region starting at 24KB (0x6000 byte) offset in flash.
|
||||
|
||||
@return ESP_OK if flash was successfully initialised.
|
||||
*/
|
||||
esp_err_t nvs_flash_init(void);
|
||||
|
||||
|
242
tools/sdk/include/spi_flash/esp_partition.h
Normal file
242
tools/sdk/include/spi_flash/esp_partition.h
Normal file
@ -0,0 +1,242 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_PARTITION_H__
|
||||
#define __ESP_PARTITION_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_spi_flash.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ESP_PARTITION_TYPE_APP = 0x00,
|
||||
ESP_PARTITION_TYPE_DATA = 0x01,
|
||||
ESP_PARTITION_TYPE_FILESYSTEM = 0x02,
|
||||
} esp_partition_type_t;
|
||||
|
||||
typedef enum {
|
||||
ESP_PARTITION_SUBTYPE_APP_FACTORY = 0x00,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_MIN = 0x10,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_0 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 0,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_1 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 1,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_2 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 2,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_3 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 3,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_4 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 4,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_5 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 5,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_6 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 6,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_7 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 7,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_8 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 8,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_9 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 9,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_10 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 10,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_11 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 11,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_12 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 12,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_13 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 13,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_14 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 14,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_15 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 15,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_MAX = 15,
|
||||
ESP_PARTITION_SUBTYPE_APP_TEST = 0x20,
|
||||
|
||||
ESP_PARTITION_SUBTYPE_DATA_OTA = 0x00,
|
||||
ESP_PARTITION_SUBTYPE_DATA_RF = 0x01,
|
||||
ESP_PARTITION_SUBTYPE_DATA_NVS = 0x02,
|
||||
|
||||
ESP_PARTITION_SUBTYPE_FILESYSTEM_ESPHTTPD = 0x00,
|
||||
ESP_PARTITION_SUBTYPE_FILESYSTEM_FAT = 0x01,
|
||||
ESP_PARTITION_SUBTYPE_FILESYSTEM_SPIFFS = 0x02,
|
||||
|
||||
ESP_PARTITION_SUBTYPE_ANY = 0xff,
|
||||
} esp_partition_subtype_t;
|
||||
|
||||
#define ESP_PARTITION_SUBTYPE_OTA(i) ((esp_partition_subtype_t)(ESP_PARTITION_SUBTYPE_APP_OTA_MIN + ((i) & 0xf)))
|
||||
|
||||
|
||||
typedef struct esp_partition_iterator_opaque_* esp_partition_iterator_t;
|
||||
|
||||
typedef struct {
|
||||
esp_partition_type_t type;
|
||||
esp_partition_subtype_t subtype;
|
||||
uint32_t address;
|
||||
uint32_t size;
|
||||
char label[17];
|
||||
bool encrypted;
|
||||
} esp_partition_t;
|
||||
|
||||
/**
|
||||
* @brief Find partition based on one or more parameters
|
||||
*
|
||||
* @param type Partition type, one of esp_partition_type_t values
|
||||
* @param subtype Partition subtype, one of esp_partition_subtype_t values.
|
||||
* To find all partitions of given type, use
|
||||
* ESP_PARTITION_SUBTYPE_ANY.
|
||||
* @param label (optional) Partition label. Set this value if looking
|
||||
* for partition with a specific name. Pass NULL otherwise.
|
||||
*
|
||||
* @return iterator which can be used to enumerate all the partitions found,
|
||||
* or NULL if no partitions were found.
|
||||
* Iterator obtained through this function has to be released
|
||||
* using esp_partition_iterator_release when not used any more.
|
||||
*/
|
||||
esp_partition_iterator_t esp_partition_find(esp_partition_type_t type, esp_partition_subtype_t subtype, const char* label);
|
||||
|
||||
/**
|
||||
* @brief Find first partition based on one or more parameters
|
||||
*
|
||||
* @param type Partition type, one of esp_partition_type_t values
|
||||
* @param subtype Partition subtype, one of esp_partition_subtype_t values.
|
||||
* To find all partitions of given type, use
|
||||
* ESP_PARTITION_SUBTYPE_ANY.
|
||||
* @param label (optional) Partition label. Set this value if looking
|
||||
* for partition with a specific name. Pass NULL otherwise.
|
||||
*
|
||||
* @return pointer to esp_partition_t structure, or NULL if no partition is found.
|
||||
* This pointer is valid for the lifetime of the application.
|
||||
*/
|
||||
const esp_partition_t* esp_partition_find_first(esp_partition_type_t type, esp_partition_subtype_t subtype, const char* label);
|
||||
|
||||
/**
|
||||
* @brief Get esp_partition_t structure for given partition
|
||||
*
|
||||
* @param iterator Iterator obtained using esp_partition_find. Must be non-NULL.
|
||||
*
|
||||
* @return pointer to esp_partition_t structure. This pointer is valid for the lifetime
|
||||
* of the application.
|
||||
*/
|
||||
const esp_partition_t* esp_partition_get(esp_partition_iterator_t iterator);
|
||||
|
||||
/**
|
||||
* @brief Move partition iterator to the next partition found
|
||||
*
|
||||
* Any copies of the iterator will be invalid after this call.
|
||||
*
|
||||
* @param iterator Iterator obtained using esp_partition_find. Must be non-NULL.
|
||||
*
|
||||
* @return NULL if no partition was found, valid esp_partition_iterator_t otherwise.
|
||||
*/
|
||||
esp_partition_iterator_t esp_partition_next(esp_partition_iterator_t iterator);
|
||||
|
||||
/**
|
||||
* @brief Release partition iterator
|
||||
*
|
||||
* @param iterator Iterator obtained using esp_partition_find. Must be non-NULL.
|
||||
*
|
||||
*/
|
||||
void esp_partition_iterator_release(esp_partition_iterator_t iterator);
|
||||
|
||||
/**
|
||||
* @brief Read data from the partition
|
||||
*
|
||||
* @param partition Pointer to partition structure obtained using
|
||||
* esp_partition_find_first or esp_partition_get.
|
||||
* Must be non-NULL.
|
||||
* @param dst Pointer to the buffer where data should be stored.
|
||||
* Pointer must be non-NULL and buffer must be at least 'size' bytes long.
|
||||
* @param src_offset Address of the data to be read, relative to the
|
||||
* beginning of the partition.
|
||||
* @param size Size of data to be read, in bytes.
|
||||
*
|
||||
* @return ESP_OK, if data was read successfully;
|
||||
* ESP_ERR_INVALID_ARG, if src_offset exceeds partition size;
|
||||
* ESP_ERR_INVALID_SIZE, if read would go out of bounds of the partition;
|
||||
* or one of error codes from lower-level flash driver.
|
||||
*/
|
||||
esp_err_t esp_partition_read(const esp_partition_t* partition,
|
||||
size_t src_offset, void* dst, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Write data to the partition
|
||||
*
|
||||
* Before writing data to flash, corresponding region of flash needs to be erased.
|
||||
* This can be done using esp_partition_erase_range function.
|
||||
*
|
||||
* @param partition Pointer to partition structure obtained using
|
||||
* esp_partition_find_first or esp_partition_get.
|
||||
* Must be non-NULL.
|
||||
* @param dst_offset Address where the data should be written, relative to the
|
||||
* beginning of the partition.
|
||||
* @param src Pointer to the source buffer. Pointer must be non-NULL and
|
||||
* buffer must be at least 'size' bytes long.
|
||||
* @param size Size of data to be written, in bytes.
|
||||
*
|
||||
* @note Prior to writing to flash memory, make sure it has been erased with
|
||||
* esp_partition_erase_range call.
|
||||
*
|
||||
* @return ESP_OK, if data was written successfully;
|
||||
* ESP_ERR_INVALID_ARG, if dst_offset exceeds partition size;
|
||||
* ESP_ERR_INVALID_SIZE, if write would go out of bounds of the partition;
|
||||
* or one of error codes from lower-level flash driver.
|
||||
*/
|
||||
esp_err_t esp_partition_write(const esp_partition_t* partition,
|
||||
size_t dst_offset, const void* src, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Erase part of the partition
|
||||
*
|
||||
* @param partition Pointer to partition structure obtained using
|
||||
* esp_partition_find_first or esp_partition_get.
|
||||
* Must be non-NULL.
|
||||
* @param start_addr Address where erase operation should start. Must be aligned
|
||||
* to 4 kilobytes.
|
||||
* @param size Size of the range which should be erased, in bytes.
|
||||
* Must be divisible by 4 kilobytes.
|
||||
*
|
||||
* @return ESP_OK, if the range was erased successfully;
|
||||
* ESP_ERR_INVALID_ARG, if iterator or dst are NULL;
|
||||
* ESP_ERR_INVALID_SIZE, if erase would go out of bounds of the partition;
|
||||
* or one of error codes from lower-level flash driver.
|
||||
*/
|
||||
esp_err_t esp_partition_erase_range(const esp_partition_t* partition,
|
||||
uint32_t start_addr, uint32_t size);
|
||||
|
||||
/**
|
||||
* @brief Configure MMU to map partition into data memory
|
||||
*
|
||||
* Unlike spi_flash_mmap function, which requires a 64kB aligned base address,
|
||||
* this function doesn't impose such a requirement.
|
||||
* If offset results in a flash address which is not aligned to 64kB boundary,
|
||||
* address will be rounded to the lower 64kB boundary, so that mapped region
|
||||
* includes requested range.
|
||||
* Pointer returned via out_ptr argument will be adjusted to point to the
|
||||
* requested offset (not necessarily to the beginning of mmap-ed region).
|
||||
*
|
||||
* To release mapped memory, pass handle returned via out_handle argument to
|
||||
* spi_flash_munmap function.
|
||||
*
|
||||
* @param partition Pointer to partition structure obtained using
|
||||
* esp_partition_find_first or esp_partition_get.
|
||||
* Must be non-NULL.
|
||||
* @param offset Offset from the beginning of partition where mapping should start.
|
||||
* @param size Size of the area to be mapped.
|
||||
* @param memory Memory space where the region should be mapped
|
||||
* @param out_ptr Output, pointer to the mapped memory region
|
||||
* @param out_handle Output, handle which should be used for spi_flash_munmap call
|
||||
*
|
||||
* @return ESP_OK, if successful
|
||||
*/
|
||||
esp_err_t esp_partition_mmap(const esp_partition_t* partition, uint32_t offset, uint32_t size,
|
||||
spi_flash_mmap_memory_t memory,
|
||||
const void** out_ptr, spi_flash_mmap_handle_t* out_handle);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __ESP_PARTITION_H__ */
|
@ -16,6 +16,7 @@
|
||||
#define ESP_SPI_FLASH_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "esp_err.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
@ -34,41 +35,126 @@ extern "C" {
|
||||
*
|
||||
* This function must be called exactly once, before any other
|
||||
* spi_flash_* functions are called.
|
||||
* Currently this function is called from startup code. There is
|
||||
* no need to call it from application code.
|
||||
*
|
||||
*/
|
||||
void spi_flash_init();
|
||||
|
||||
/**
|
||||
* @brief Get flash chip size, as set in binary image header
|
||||
*
|
||||
* @note This value does not necessarily match real flash size.
|
||||
*
|
||||
* @return size of flash chip, in bytes
|
||||
*/
|
||||
size_t spi_flash_get_chip_size();
|
||||
|
||||
/**
|
||||
* @brief Erase the Flash sector.
|
||||
*
|
||||
* @param uint16 sec : Sector number, the count starts at sector 0, 4KB per sector.
|
||||
* @param sector Sector number, the count starts at sector 0, 4KB per sector.
|
||||
*
|
||||
* @return esp_err_t
|
||||
*/
|
||||
esp_err_t spi_flash_erase_sector(uint16_t sec);
|
||||
esp_err_t spi_flash_erase_sector(size_t sector);
|
||||
|
||||
/**
|
||||
* @brief Erase a range of flash sectors
|
||||
*
|
||||
* @param uint32_t start_address : Address where erase operation has to start.
|
||||
* Must be 4kB-aligned
|
||||
* @param uint32_t size : Size of erased range, in bytes. Must be divisible by 4kB.
|
||||
*
|
||||
* @return esp_err_t
|
||||
*/
|
||||
esp_err_t spi_flash_erase_range(size_t start_addr, size_t size);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Write data to Flash.
|
||||
*
|
||||
* @param uint32 des_addr : destination address in Flash.
|
||||
* @param uint32 *src_addr : source address of the data.
|
||||
* @param uint32 size : length of data
|
||||
* @note Address in flash, dest, has to be 4-byte aligned.
|
||||
* This is a temporary limitation which will be removed.
|
||||
*
|
||||
* @param dest destination address in Flash
|
||||
* @param src pointer to the source buffer
|
||||
* @param size length of data, in bytes
|
||||
*
|
||||
* @return esp_err_t
|
||||
*/
|
||||
esp_err_t spi_flash_write(uint32_t des_addr, const uint32_t *src_addr, uint32_t size);
|
||||
esp_err_t spi_flash_write(size_t dest, const void *src, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Read data from Flash.
|
||||
*
|
||||
* @param uint32 src_addr : source address of the data in Flash.
|
||||
* @param uint32 *des_addr : destination address.
|
||||
* @param uint32 size : length of data
|
||||
* @note Both src and dest have to be 4-byte aligned.
|
||||
* This is a temporary limitation which will be removed.
|
||||
*
|
||||
* @param src source address of the data in Flash.
|
||||
* @param dest pointer to the destination buffer
|
||||
* @param size length of data
|
||||
*
|
||||
* @return esp_err_t
|
||||
*/
|
||||
esp_err_t spi_flash_read(uint32_t src_addr, uint32_t *des_addr, uint32_t size);
|
||||
esp_err_t spi_flash_read(size_t src, void *dest, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Enumeration which specifies memory space requested in an mmap call
|
||||
*/
|
||||
typedef enum {
|
||||
SPI_FLASH_MMAP_DATA, /**< map to data memory (Vaddr0), allows byte-aligned access, 4 MB total */
|
||||
SPI_FLASH_MMAP_INST, /**< map to instruction memory (Vaddr1-3), allows only 4-byte-aligned access, 11 MB total */
|
||||
} spi_flash_mmap_memory_t;
|
||||
|
||||
/**
|
||||
* @brief Opaque handle for memory region obtained from spi_flash_mmap.
|
||||
*/
|
||||
typedef uint32_t spi_flash_mmap_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Map region of flash memory into data or instruction address space
|
||||
*
|
||||
* This function allocates sufficient number of 64k MMU pages and configures
|
||||
* them to map request region of flash memory into data address space or into
|
||||
* instruction address space. It may reuse MMU pages which already provide
|
||||
* required mapping. As with any allocator, there is possibility of fragmentation
|
||||
* of address space if mmap/munmap are heavily used. To troubleshoot issues with
|
||||
* page allocation, use spi_flash_mmap_dump function.
|
||||
*
|
||||
* @param src_addr Physical address in flash where requested region starts.
|
||||
* This address *must* be aligned to 64kB boundary.
|
||||
* @param size Size of region which has to be mapped. This size will be rounded
|
||||
* up to a 64k boundary.
|
||||
* @param memory Memory space where the region should be mapped
|
||||
* @param out_ptr Output, pointer to the mapped memory region
|
||||
* @param out_handle Output, handle which should be used for spi_flash_munmap call
|
||||
*
|
||||
* @return ESP_OK on success, ESP_ERR_NO_MEM if pages can not be allocated
|
||||
*/
|
||||
esp_err_t spi_flash_mmap(uint32_t src_addr, size_t size, spi_flash_mmap_memory_t memory,
|
||||
const void** out_ptr, spi_flash_mmap_handle_t* out_handle);
|
||||
|
||||
/**
|
||||
* @brief Release region previously obtained using spi_flash_mmap
|
||||
*
|
||||
* @note Calling this function will not necessarily unmap memory region.
|
||||
* Region will only be unmapped when there are no other handles which
|
||||
* reference this region. In case of partially overlapping regions
|
||||
* it is possible that memory will be unmapped partially.
|
||||
*
|
||||
* @param handle Handle obtained from spi_flash_mmap
|
||||
*/
|
||||
void spi_flash_munmap(spi_flash_mmap_handle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Display information about mapped regions
|
||||
*
|
||||
* This function lists handles obtained using spi_flash_mmap, along with range
|
||||
* of pages allocated to each handle. It also lists all non-zero entries of
|
||||
* MMU table and corresponding reference counts.
|
||||
*/
|
||||
void spi_flash_mmap_dump();
|
||||
|
||||
#if CONFIG_SPI_FLASH_ENABLE_COUNTERS
|
||||
|
||||
@ -78,7 +164,7 @@ esp_err_t spi_flash_read(uint32_t src_addr, uint32_t *des_addr, uint32_t size);
|
||||
typedef struct {
|
||||
uint32_t count; // number of times operation was executed
|
||||
uint32_t time; // total time taken, in microseconds
|
||||
uint32_t bytes; // total number of bytes, for read and write operations
|
||||
uint32_t bytes; // total number of bytes
|
||||
} spi_flash_counter_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -73,8 +73,8 @@ typedef struct {
|
||||
}tcpip_adapter_sta_info_t;
|
||||
|
||||
typedef struct {
|
||||
tcpip_adapter_sta_info_t sta[ESP_WIFI_MAX_CONN_NUM+2];
|
||||
uint8_t num;
|
||||
tcpip_adapter_sta_info_t sta[ESP_WIFI_MAX_CONN_NUM];
|
||||
int num;
|
||||
}tcpip_adapter_sta_list_t;
|
||||
#endif
|
||||
|
||||
|
65
tools/sdk/include/wpa_supplicant/byteswap.h
Normal file
65
tools/sdk/include/wpa_supplicant/byteswap.h
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2010 Espressif System
|
||||
*/
|
||||
|
||||
#ifndef BYTESWAP_H
|
||||
#define BYTESWAP_H
|
||||
|
||||
/* Swap bytes in 16 bit value. */
|
||||
#ifdef __GNUC__
|
||||
# define __bswap_16(x) \
|
||||
(__extension__ \
|
||||
({ unsigned short int __bsx = (x); \
|
||||
((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8)); }))
|
||||
#else
|
||||
static INLINE unsigned short int
|
||||
__bswap_16 (unsigned short int __bsx)
|
||||
{
|
||||
return ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Swap bytes in 32 bit value. */
|
||||
#ifdef __GNUC__
|
||||
# define __bswap_32(x) \
|
||||
(__extension__ \
|
||||
({ unsigned int __bsx = (x); \
|
||||
((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) | \
|
||||
(((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24)); }))
|
||||
#else
|
||||
static INLINE unsigned int
|
||||
__bswap_32 (unsigned int __bsx)
|
||||
{
|
||||
return ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) |
|
||||
(((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined __GNUC__ && __GNUC__ >= 2
|
||||
/* Swap bytes in 64 bit value. */
|
||||
# define __bswap_constant_64(x) \
|
||||
((((x) & 0xff00000000000000ull) >> 56) \
|
||||
| (((x) & 0x00ff000000000000ull) >> 40) \
|
||||
| (((x) & 0x0000ff0000000000ull) >> 24) \
|
||||
| (((x) & 0x000000ff00000000ull) >> 8) \
|
||||
| (((x) & 0x00000000ff000000ull) << 8) \
|
||||
| (((x) & 0x0000000000ff0000ull) << 24) \
|
||||
| (((x) & 0x000000000000ff00ull) << 40) \
|
||||
| (((x) & 0x00000000000000ffull) << 56))
|
||||
|
||||
# define __bswap_64(x) \
|
||||
(__extension__ \
|
||||
({ union { __extension__ unsigned long long int __ll; \
|
||||
unsigned int __l[2]; } __w, __r; \
|
||||
if (__builtin_constant_p (x)) \
|
||||
__r.__ll = __bswap_constant_64 (x); \
|
||||
else \
|
||||
{ \
|
||||
__w.__ll = (x); \
|
||||
__r.__l[0] = __bswap_32 (__w.__l[1]); \
|
||||
__r.__l[1] = __bswap_32 (__w.__l[0]); \
|
||||
} \
|
||||
__r.__ll; }))
|
||||
#endif
|
||||
|
||||
#endif /* BYTESWAP_H */
|
27
tools/sdk/include/wpa_supplicant/crypto/aes.h
Normal file
27
tools/sdk/include/wpa_supplicant/crypto/aes.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* AES functions
|
||||
* Copyright (c) 2003-2006, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef AES_H
|
||||
#define AES_H
|
||||
|
||||
#define AES_BLOCK_SIZE 16
|
||||
|
||||
void * aes_encrypt_init(const u8 *key, size_t len);
|
||||
void aes_encrypt(void *ctx, const u8 *plain, u8 *crypt);
|
||||
void aes_encrypt_deinit(void *ctx);
|
||||
void * aes_decrypt_init(const u8 *key, size_t len);
|
||||
void aes_decrypt(void *ctx, const u8 *crypt, u8 *plain);
|
||||
void aes_decrypt_deinit(void *ctx);
|
||||
|
||||
#endif /* AES_H */
|
131
tools/sdk/include/wpa_supplicant/crypto/aes_i.h
Normal file
131
tools/sdk/include/wpa_supplicant/crypto/aes_i.h
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* AES (Rijndael) cipher
|
||||
* Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef AES_I_H
|
||||
#define AES_I_H
|
||||
|
||||
#include "aes.h"
|
||||
|
||||
/* #define FULL_UNROLL */
|
||||
#define AES_SMALL_TABLES
|
||||
|
||||
extern const u32 Te0[256];
|
||||
extern const u32 Te1[256];
|
||||
extern const u32 Te2[256];
|
||||
extern const u32 Te3[256];
|
||||
extern const u32 Te4[256];
|
||||
extern const u32 Td0[256];
|
||||
extern const u32 Td1[256];
|
||||
extern const u32 Td2[256];
|
||||
extern const u32 Td3[256];
|
||||
extern const u32 Td4[256];
|
||||
extern const u32 rcon[10];
|
||||
extern const u8 Td4s[256];
|
||||
extern const u8 rcons[10];
|
||||
|
||||
#ifndef AES_SMALL_TABLES
|
||||
|
||||
#define RCON(i) rcon[(i)]
|
||||
|
||||
#define TE0(i) Te0[((i) >> 24) & 0xff]
|
||||
#define TE1(i) Te1[((i) >> 16) & 0xff]
|
||||
#define TE2(i) Te2[((i) >> 8) & 0xff]
|
||||
#define TE3(i) Te3[(i) & 0xff]
|
||||
#define TE41(i) (Te4[((i) >> 24) & 0xff] & 0xff000000)
|
||||
#define TE42(i) (Te4[((i) >> 16) & 0xff] & 0x00ff0000)
|
||||
#define TE43(i) (Te4[((i) >> 8) & 0xff] & 0x0000ff00)
|
||||
#define TE44(i) (Te4[(i) & 0xff] & 0x000000ff)
|
||||
#define TE421(i) (Te4[((i) >> 16) & 0xff] & 0xff000000)
|
||||
#define TE432(i) (Te4[((i) >> 8) & 0xff] & 0x00ff0000)
|
||||
#define TE443(i) (Te4[(i) & 0xff] & 0x0000ff00)
|
||||
#define TE414(i) (Te4[((i) >> 24) & 0xff] & 0x000000ff)
|
||||
#define TE411(i) (Te4[((i) >> 24) & 0xff] & 0xff000000)
|
||||
#define TE422(i) (Te4[((i) >> 16) & 0xff] & 0x00ff0000)
|
||||
#define TE433(i) (Te4[((i) >> 8) & 0xff] & 0x0000ff00)
|
||||
#define TE444(i) (Te4[(i) & 0xff] & 0x000000ff)
|
||||
#define TE4(i) (Te4[(i)] & 0x000000ff)
|
||||
|
||||
#define TD0(i) Td0[((i) >> 24) & 0xff]
|
||||
#define TD1(i) Td1[((i) >> 16) & 0xff]
|
||||
#define TD2(i) Td2[((i) >> 8) & 0xff]
|
||||
#define TD3(i) Td3[(i) & 0xff]
|
||||
#define TD41(i) (Td4[((i) >> 24) & 0xff] & 0xff000000)
|
||||
#define TD42(i) (Td4[((i) >> 16) & 0xff] & 0x00ff0000)
|
||||
#define TD43(i) (Td4[((i) >> 8) & 0xff] & 0x0000ff00)
|
||||
#define TD44(i) (Td4[(i) & 0xff] & 0x000000ff)
|
||||
#define TD0_(i) Td0[(i) & 0xff]
|
||||
#define TD1_(i) Td1[(i) & 0xff]
|
||||
#define TD2_(i) Td2[(i) & 0xff]
|
||||
#define TD3_(i) Td3[(i) & 0xff]
|
||||
|
||||
#else /* AES_SMALL_TABLES */
|
||||
|
||||
#define RCON(i) (rcons[(i)] << 24)
|
||||
|
||||
static inline u32 rotr(u32 val, int bits)
|
||||
{
|
||||
return (val >> bits) | (val << (32 - bits));
|
||||
}
|
||||
|
||||
#define TE0(i) Te0[((i) >> 24) & 0xff]
|
||||
#define TE1(i) rotr(Te0[((i) >> 16) & 0xff], 8)
|
||||
#define TE2(i) rotr(Te0[((i) >> 8) & 0xff], 16)
|
||||
#define TE3(i) rotr(Te0[(i) & 0xff], 24)
|
||||
#define TE41(i) ((Te0[((i) >> 24) & 0xff] << 8) & 0xff000000)
|
||||
#define TE42(i) (Te0[((i) >> 16) & 0xff] & 0x00ff0000)
|
||||
#define TE43(i) (Te0[((i) >> 8) & 0xff] & 0x0000ff00)
|
||||
#define TE44(i) ((Te0[(i) & 0xff] >> 8) & 0x000000ff)
|
||||
#define TE421(i) ((Te0[((i) >> 16) & 0xff] << 8) & 0xff000000)
|
||||
#define TE432(i) (Te0[((i) >> 8) & 0xff] & 0x00ff0000)
|
||||
#define TE443(i) (Te0[(i) & 0xff] & 0x0000ff00)
|
||||
#define TE414(i) ((Te0[((i) >> 24) & 0xff] >> 8) & 0x000000ff)
|
||||
#define TE411(i) ((Te0[((i) >> 24) & 0xff] << 8) & 0xff000000)
|
||||
#define TE422(i) (Te0[((i) >> 16) & 0xff] & 0x00ff0000)
|
||||
#define TE433(i) (Te0[((i) >> 8) & 0xff] & 0x0000ff00)
|
||||
#define TE444(i) ((Te0[(i) & 0xff] >> 8) & 0x000000ff)
|
||||
#define TE4(i) ((Te0[(i)] >> 8) & 0x000000ff)
|
||||
|
||||
#define TD0(i) Td0[((i) >> 24) & 0xff]
|
||||
#define TD1(i) rotr(Td0[((i) >> 16) & 0xff], 8)
|
||||
#define TD2(i) rotr(Td0[((i) >> 8) & 0xff], 16)
|
||||
#define TD3(i) rotr(Td0[(i) & 0xff], 24)
|
||||
#define TD41(i) (Td4s[((i) >> 24) & 0xff] << 24)
|
||||
#define TD42(i) (Td4s[((i) >> 16) & 0xff] << 16)
|
||||
#define TD43(i) (Td4s[((i) >> 8) & 0xff] << 8)
|
||||
#define TD44(i) (Td4s[(i) & 0xff])
|
||||
#define TD0_(i) Td0[(i) & 0xff]
|
||||
#define TD1_(i) rotr(Td0[(i) & 0xff], 8)
|
||||
#define TD2_(i) rotr(Td0[(i) & 0xff], 16)
|
||||
#define TD3_(i) rotr(Td0[(i) & 0xff], 24)
|
||||
|
||||
#endif /* AES_SMALL_TABLES */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
|
||||
#define GETU32(p) SWAP(*((u32 *)(p)))
|
||||
#define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); }
|
||||
#else
|
||||
#define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ \
|
||||
((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
|
||||
#define PUTU32(ct, st) { \
|
||||
(ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); \
|
||||
(ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); }
|
||||
#endif
|
||||
|
||||
#define AES_PRIV_SIZE (4 * 4 * 15 + 4)
|
||||
#define AES_PRIV_NR_POS (4 * 15)
|
||||
|
||||
int rijndaelKeySetupEnc(u32 rk[], const u8 cipherKey[], int keyBits);
|
||||
|
||||
#endif /* AES_I_H */
|
48
tools/sdk/include/wpa_supplicant/crypto/aes_wrap.h
Normal file
48
tools/sdk/include/wpa_supplicant/crypto/aes_wrap.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* AES-based functions
|
||||
*
|
||||
* - AES Key Wrap Algorithm (128-bit KEK) (RFC3394)
|
||||
* - One-Key CBC MAC (OMAC1) hash with AES-128
|
||||
* - AES-128 CTR mode encryption
|
||||
* - AES-128 EAX mode encryption/decryption
|
||||
* - AES-128 CBC
|
||||
*
|
||||
* Copyright (c) 2003-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef AES_WRAP_H
|
||||
#define AES_WRAP_H
|
||||
|
||||
int __must_check aes_wrap(const u8 *kek, int n, const u8 *plain, u8 *cipher);
|
||||
int __must_check aes_unwrap(const u8 *kek, int n, const u8 *cipher, u8 *plain);
|
||||
int __must_check omac1_aes_128_vector(const u8 *key, size_t num_elem,
|
||||
const u8 *addr[], const size_t *len,
|
||||
u8 *mac);
|
||||
int __must_check omac1_aes_128(const u8 *key, const u8 *data, size_t data_len,
|
||||
u8 *mac);
|
||||
int __must_check aes_128_encrypt_block(const u8 *key, const u8 *in, u8 *out);
|
||||
int __must_check aes_128_ctr_encrypt(const u8 *key, const u8 *nonce,
|
||||
u8 *data, size_t data_len);
|
||||
int __must_check aes_128_eax_encrypt(const u8 *key,
|
||||
const u8 *nonce, size_t nonce_len,
|
||||
const u8 *hdr, size_t hdr_len,
|
||||
u8 *data, size_t data_len, u8 *tag);
|
||||
int __must_check aes_128_eax_decrypt(const u8 *key,
|
||||
const u8 *nonce, size_t nonce_len,
|
||||
const u8 *hdr, size_t hdr_len,
|
||||
u8 *data, size_t data_len, const u8 *tag);
|
||||
int __must_check aes_128_cbc_encrypt(const u8 *key, const u8 *iv, u8 *data,
|
||||
size_t data_len);
|
||||
int __must_check aes_128_cbc_decrypt(const u8 *key, const u8 *iv, u8 *data,
|
||||
size_t data_len);
|
||||
|
||||
#endif /* AES_WRAP_H */
|
23
tools/sdk/include/wpa_supplicant/crypto/base64.h
Normal file
23
tools/sdk/include/wpa_supplicant/crypto/base64.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Base64 encoding/decoding (RFC1341)
|
||||
* Copyright (c) 2005, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef BASE64_H
|
||||
#define BASE64_H
|
||||
|
||||
unsigned char * base64_encode(const unsigned char *src, size_t len,
|
||||
size_t *out_len);
|
||||
unsigned char * base64_decode(const unsigned char *src, size_t len,
|
||||
size_t *out_len);
|
||||
|
||||
#endif /* BASE64_H */
|
481
tools/sdk/include/wpa_supplicant/crypto/common.h
Normal file
481
tools/sdk/include/wpa_supplicant/crypto/common.h
Normal file
@ -0,0 +1,481 @@
|
||||
/*
|
||||
* wpa_supplicant/hostapd / common helper functions, etc.
|
||||
* Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#include "os.h"
|
||||
|
||||
#if defined(__XTENSA__)
|
||||
#include <machine/endian.h>
|
||||
#define __BYTE_ORDER BYTE_ORDER
|
||||
#define __LITTLE_ENDIAN LITTLE_ENDIAN
|
||||
#define __BIG_ENDIAN BIG_ENDIAN
|
||||
#endif /*__XTENSA__*/
|
||||
|
||||
#if defined(__linux__) || defined(__GLIBC__)
|
||||
#include <endian.h>
|
||||
#include <byteswap.h>
|
||||
#endif /* __linux__ */
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \
|
||||
defined(__OpenBSD__)
|
||||
#include <sys/types.h>
|
||||
#include <sys/endian.h>
|
||||
#define __BYTE_ORDER _BYTE_ORDER
|
||||
#define __LITTLE_ENDIAN _LITTLE_ENDIAN
|
||||
#define __BIG_ENDIAN _BIG_ENDIAN
|
||||
#ifdef __OpenBSD__
|
||||
#define bswap_16 swap16
|
||||
#define bswap_32 swap32
|
||||
#define bswap_64 swap64
|
||||
#else /* __OpenBSD__ */
|
||||
#define bswap_16 bswap16
|
||||
#define bswap_32 bswap32
|
||||
#define bswap_64 bswap64
|
||||
#endif /* __OpenBSD__ */
|
||||
#endif /* defined(__FreeBSD__) || defined(__NetBSD__) ||
|
||||
* defined(__DragonFly__) || defined(__OpenBSD__) */
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <sys/types.h>
|
||||
#include <machine/endian.h>
|
||||
#define __BYTE_ORDER _BYTE_ORDER
|
||||
#define __LITTLE_ENDIAN _LITTLE_ENDIAN
|
||||
#define __BIG_ENDIAN _BIG_ENDIAN
|
||||
static inline unsigned short bswap_16(unsigned short v)
|
||||
{
|
||||
return ((v & 0xff) << 8) | (v >> 8);
|
||||
}
|
||||
|
||||
static inline unsigned int bswap_32(unsigned int v)
|
||||
{
|
||||
return ((v & 0xff) << 24) | ((v & 0xff00) << 8) |
|
||||
((v & 0xff0000) >> 8) | (v >> 24);
|
||||
}
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
#ifdef CONFIG_TI_COMPILER
|
||||
#define __BIG_ENDIAN 4321
|
||||
#define __LITTLE_ENDIAN 1234
|
||||
#ifdef __big_endian__
|
||||
#define __BYTE_ORDER __BIG_ENDIAN
|
||||
#else
|
||||
#define __BYTE_ORDER __LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif /* CONFIG_TI_COMPILER */
|
||||
|
||||
#ifdef __SYMBIAN32__
|
||||
#define __BIG_ENDIAN 4321
|
||||
#define __LITTLE_ENDIAN 1234
|
||||
#define __BYTE_ORDER __LITTLE_ENDIAN
|
||||
#endif /* __SYMBIAN32__ */
|
||||
|
||||
#ifdef CONFIG_NATIVE_WINDOWS
|
||||
#include <winsock.h>
|
||||
|
||||
typedef int socklen_t;
|
||||
|
||||
#ifndef MSG_DONTWAIT
|
||||
#define MSG_DONTWAIT 0 /* not supported */
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_NATIVE_WINDOWS */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define inline __inline
|
||||
|
||||
#undef vsnprintf
|
||||
#define vsnprintf _vsnprintf
|
||||
#undef close
|
||||
#define close closesocket
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
|
||||
/* Define platform specific integer types */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
typedef UINT64 u64;
|
||||
typedef UINT32 u32;
|
||||
typedef UINT16 u16;
|
||||
typedef UINT8 u8;
|
||||
typedef INT64 s64;
|
||||
typedef INT32 s32;
|
||||
typedef INT16 s16;
|
||||
typedef INT8 s8;
|
||||
#define WPA_TYPES_DEFINED
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#ifdef __vxworks
|
||||
typedef unsigned long long u64;
|
||||
typedef UINT32 u32;
|
||||
typedef UINT16 u16;
|
||||
typedef UINT8 u8;
|
||||
typedef long long s64;
|
||||
typedef INT32 s32;
|
||||
typedef INT16 s16;
|
||||
typedef INT8 s8;
|
||||
#define WPA_TYPES_DEFINED
|
||||
#endif /* __vxworks */
|
||||
|
||||
#ifdef CONFIG_TI_COMPILER
|
||||
#ifdef _LLONG_AVAILABLE
|
||||
typedef unsigned long long u64;
|
||||
#else
|
||||
/*
|
||||
* TODO: 64-bit variable not available. Using long as a workaround to test the
|
||||
* build, but this will likely not work for all operations.
|
||||
*/
|
||||
typedef unsigned long u64;
|
||||
#endif
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned char u8;
|
||||
#define WPA_TYPES_DEFINED
|
||||
#endif /* CONFIG_TI_COMPILER */
|
||||
|
||||
#ifdef __SYMBIAN32__
|
||||
#define __REMOVE_PLATSEC_DIAGNOSTICS__
|
||||
#include <e32def.h>
|
||||
typedef TUint64 u64;
|
||||
typedef TUint32 u32;
|
||||
typedef TUint16 u16;
|
||||
typedef TUint8 u8;
|
||||
#define WPA_TYPES_DEFINED
|
||||
#endif /* __SYMBIAN32__ */
|
||||
|
||||
#ifndef WPA_TYPES_DEFINED
|
||||
#ifdef CONFIG_USE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
typedef uint64_t u64;
|
||||
typedef uint32_t u32;
|
||||
typedef uint16_t u16;
|
||||
typedef uint8_t u8;
|
||||
typedef int64_t s64;
|
||||
typedef int32_t s32;
|
||||
typedef int16_t s16;
|
||||
typedef int8_t s8;
|
||||
#define WPA_TYPES_DEFINED
|
||||
#endif /* !WPA_TYPES_DEFINED */
|
||||
|
||||
|
||||
/* Define platform specific byte swapping macros */
|
||||
|
||||
#if defined(__CYGWIN__) || defined(CONFIG_NATIVE_WINDOWS)
|
||||
|
||||
static inline unsigned short wpa_swap_16(unsigned short v)
|
||||
{
|
||||
return ((v & 0xff) << 8) | (v >> 8);
|
||||
}
|
||||
|
||||
static inline unsigned int wpa_swap_32(unsigned int v)
|
||||
{
|
||||
return ((v & 0xff) << 24) | ((v & 0xff00) << 8) |
|
||||
((v & 0xff0000) >> 8) | (v >> 24);
|
||||
}
|
||||
|
||||
#define le_to_host16(n) (n)
|
||||
#define host_to_le16(n) (n)
|
||||
#define be_to_host16(n) wpa_swap_16(n)
|
||||
#define host_to_be16(n) wpa_swap_16(n)
|
||||
#define le_to_host32(n) (n)
|
||||
#define be_to_host32(n) wpa_swap_32(n)
|
||||
#define host_to_be32(n) wpa_swap_32(n)
|
||||
|
||||
#define WPA_BYTE_SWAP_DEFINED
|
||||
|
||||
#endif /* __CYGWIN__ || CONFIG_NATIVE_WINDOWS */
|
||||
|
||||
|
||||
#ifndef WPA_BYTE_SWAP_DEFINED
|
||||
|
||||
#ifndef __BYTE_ORDER
|
||||
#ifndef __LITTLE_ENDIAN
|
||||
#ifndef __BIG_ENDIAN
|
||||
#define __LITTLE_ENDIAN 1234
|
||||
#define __BIG_ENDIAN 4321
|
||||
#if defined(sparc)
|
||||
#define __BYTE_ORDER __BIG_ENDIAN
|
||||
#endif
|
||||
#endif /* __BIG_ENDIAN */
|
||||
#endif /* __LITTLE_ENDIAN */
|
||||
#endif /* __BYTE_ORDER */
|
||||
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#define le_to_host16(n) ((__force u16) (le16) (n))
|
||||
#define host_to_le16(n) ((__force le16) (u16) (n))
|
||||
#define be_to_host16(n) bswap_16((__force u16) (be16) (n))
|
||||
#define host_to_be16(n) ((__force be16) bswap_16((n)))
|
||||
#define le_to_host32(n) ((__force u32) (le32) (n))
|
||||
#define host_to_le32(n) ((__force le32) (u32) (n))
|
||||
#define be_to_host32(n) bswap_32((__force u32) (be32) (n))
|
||||
#define host_to_be32(n) ((__force be32) bswap_32((n)))
|
||||
#define le_to_host64(n) ((__force u64) (le64) (n))
|
||||
#define host_to_le64(n) ((__force le64) (u64) (n))
|
||||
#define be_to_host64(n) bswap_64((__force u64) (be64) (n))
|
||||
#define host_to_be64(n) ((__force be64) bswap_64((n)))
|
||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
#define le_to_host16(n) bswap_16(n)
|
||||
#define host_to_le16(n) bswap_16(n)
|
||||
#define be_to_host16(n) (n)
|
||||
#define host_to_be16(n) (n)
|
||||
#define le_to_host32(n) bswap_32(n)
|
||||
#define be_to_host32(n) (n)
|
||||
#define host_to_be32(n) (n)
|
||||
#define le_to_host64(n) bswap_64(n)
|
||||
#define host_to_le64(n) bswap_64(n)
|
||||
#define be_to_host64(n) (n)
|
||||
#define host_to_be64(n) (n)
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
#define WORDS_BIGENDIAN
|
||||
#endif
|
||||
#else
|
||||
#error Could not determine CPU byte order
|
||||
#endif
|
||||
|
||||
#define WPA_BYTE_SWAP_DEFINED
|
||||
#endif /* !WPA_BYTE_SWAP_DEFINED */
|
||||
|
||||
|
||||
/* Macros for handling unaligned memory accesses */
|
||||
|
||||
#define WPA_GET_BE16(a) ((u16) (((a)[0] << 8) | (a)[1]))
|
||||
#define WPA_PUT_BE16(a, val) \
|
||||
do { \
|
||||
(a)[0] = ((u16) (val)) >> 8; \
|
||||
(a)[1] = ((u16) (val)) & 0xff; \
|
||||
} while (0)
|
||||
|
||||
#define WPA_GET_LE16(a) ((u16) (((a)[1] << 8) | (a)[0]))
|
||||
#define WPA_PUT_LE16(a, val) \
|
||||
do { \
|
||||
(a)[1] = ((u16) (val)) >> 8; \
|
||||
(a)[0] = ((u16) (val)) & 0xff; \
|
||||
} while (0)
|
||||
|
||||
#define WPA_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \
|
||||
((u32) (a)[2]))
|
||||
#define WPA_PUT_BE24(a, val) \
|
||||
do { \
|
||||
(a)[0] = (u8) ((((u32) (val)) >> 16) & 0xff); \
|
||||
(a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \
|
||||
(a)[2] = (u8) (((u32) (val)) & 0xff); \
|
||||
} while (0)
|
||||
|
||||
#define WPA_GET_BE32(a) ((((u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \
|
||||
(((u32) (a)[2]) << 8) | ((u32) (a)[3]))
|
||||
#define WPA_PUT_BE32(a, val) \
|
||||
do { \
|
||||
(a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \
|
||||
(a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \
|
||||
(a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \
|
||||
(a)[3] = (u8) (((u32) (val)) & 0xff); \
|
||||
} while (0)
|
||||
|
||||
#define WPA_GET_LE32(a) ((((u32) (a)[3]) << 24) | (((u32) (a)[2]) << 16) | \
|
||||
(((u32) (a)[1]) << 8) | ((u32) (a)[0]))
|
||||
#define WPA_PUT_LE32(a, val) \
|
||||
do { \
|
||||
(a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff); \
|
||||
(a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff); \
|
||||
(a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \
|
||||
(a)[0] = (u8) (((u32) (val)) & 0xff); \
|
||||
} while (0)
|
||||
|
||||
#define WPA_GET_BE64(a) ((((u64) (a)[0]) << 56) | (((u64) (a)[1]) << 48) | \
|
||||
(((u64) (a)[2]) << 40) | (((u64) (a)[3]) << 32) | \
|
||||
(((u64) (a)[4]) << 24) | (((u64) (a)[5]) << 16) | \
|
||||
(((u64) (a)[6]) << 8) | ((u64) (a)[7]))
|
||||
#define WPA_PUT_BE64(a, val) \
|
||||
do { \
|
||||
(a)[0] = (u8) (((u64) (val)) >> 56); \
|
||||
(a)[1] = (u8) (((u64) (val)) >> 48); \
|
||||
(a)[2] = (u8) (((u64) (val)) >> 40); \
|
||||
(a)[3] = (u8) (((u64) (val)) >> 32); \
|
||||
(a)[4] = (u8) (((u64) (val)) >> 24); \
|
||||
(a)[5] = (u8) (((u64) (val)) >> 16); \
|
||||
(a)[6] = (u8) (((u64) (val)) >> 8); \
|
||||
(a)[7] = (u8) (((u64) (val)) & 0xff); \
|
||||
} while (0)
|
||||
|
||||
#define WPA_GET_LE64(a) ((((u64) (a)[7]) << 56) | (((u64) (a)[6]) << 48) | \
|
||||
(((u64) (a)[5]) << 40) | (((u64) (a)[4]) << 32) | \
|
||||
(((u64) (a)[3]) << 24) | (((u64) (a)[2]) << 16) | \
|
||||
(((u64) (a)[1]) << 8) | ((u64) (a)[0]))
|
||||
|
||||
|
||||
#ifndef ETH_ALEN
|
||||
#define ETH_ALEN 6
|
||||
#endif
|
||||
#ifndef IFNAMSIZ
|
||||
#define IFNAMSIZ 16
|
||||
#endif
|
||||
#ifndef ETH_P_ALL
|
||||
#define ETH_P_ALL 0x0003
|
||||
#endif
|
||||
#ifndef ETH_P_PAE
|
||||
#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
|
||||
#endif /* ETH_P_PAE */
|
||||
#ifndef ETH_P_EAPOL
|
||||
#define ETH_P_EAPOL ETH_P_PAE
|
||||
#endif /* ETH_P_EAPOL */
|
||||
#ifndef ETH_P_RSN_PREAUTH
|
||||
#define ETH_P_RSN_PREAUTH 0x88c7
|
||||
#endif /* ETH_P_RSN_PREAUTH */
|
||||
#ifndef ETH_P_RRB
|
||||
#define ETH_P_RRB 0x890D
|
||||
#endif /* ETH_P_RRB */
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define PRINTF_FORMAT(a,b) __attribute__ ((format (printf, (a), (b))))
|
||||
#define STRUCT_PACKED __attribute__ ((packed))
|
||||
#else
|
||||
#define PRINTF_FORMAT(a,b)
|
||||
#define STRUCT_PACKED
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ANSI_C_EXTRA
|
||||
|
||||
#if !defined(_MSC_VER) || _MSC_VER < 1400
|
||||
/* snprintf - used in number of places; sprintf() is _not_ a good replacement
|
||||
* due to possible buffer overflow; see, e.g.,
|
||||
* http://www.ijs.si/software/snprintf/ for portable implementation of
|
||||
* snprintf. */
|
||||
int snprintf(char *str, size_t size, const char *format, ...);
|
||||
|
||||
/* vsnprintf - only used for wpa_msg() in wpa_supplicant.c */
|
||||
int vsnprintf(char *str, size_t size, const char *format, va_list ap);
|
||||
#endif /* !defined(_MSC_VER) || _MSC_VER < 1400 */
|
||||
|
||||
/* getopt - only used in main.c */
|
||||
int getopt(int argc, char *const argv[], const char *optstring);
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
#ifndef CONFIG_NO_SOCKLEN_T_TYPEDEF
|
||||
#ifndef __socklen_t_defined
|
||||
typedef int socklen_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* inline - define as __inline or just define it to be empty, if needed */
|
||||
#ifdef CONFIG_NO_INLINE
|
||||
#define inline
|
||||
#else
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
#ifndef __func__
|
||||
#define __func__ "__func__ not defined"
|
||||
#endif
|
||||
|
||||
#ifndef bswap_16
|
||||
#define bswap_16(a) ((((u16) (a) << 8) & 0xff00) | (((u16) (a) >> 8) & 0xff))
|
||||
#endif
|
||||
|
||||
#ifndef bswap_32
|
||||
#define bswap_32(a) ((((u32) (a) << 24) & 0xff000000) | \
|
||||
(((u32) (a) << 8) & 0xff0000) | \
|
||||
(((u32) (a) >> 8) & 0xff00) | \
|
||||
(((u32) (a) >> 24) & 0xff))
|
||||
#endif
|
||||
|
||||
#ifndef MSG_DONTWAIT
|
||||
#define MSG_DONTWAIT 0
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
void perror(const char *s);
|
||||
#endif /* _WIN32_WCE */
|
||||
|
||||
#endif /* CONFIG_ANSI_C_EXTRA */
|
||||
|
||||
#ifndef MAC2STR
|
||||
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
|
||||
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
#endif
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(x) (1 << (x))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Definitions for sparse validation
|
||||
* (http://kernel.org/pub/linux/kernel/people/josh/sparse/)
|
||||
*/
|
||||
#ifdef __CHECKER__
|
||||
#define __force __attribute__((force))
|
||||
#define __bitwise __attribute__((bitwise))
|
||||
#else
|
||||
#define __force
|
||||
#define __bitwise
|
||||
#endif
|
||||
|
||||
typedef u16 __bitwise be16;
|
||||
typedef u16 __bitwise le16;
|
||||
typedef u32 __bitwise be32;
|
||||
typedef u32 __bitwise le32;
|
||||
typedef u64 __bitwise be64;
|
||||
typedef u64 __bitwise le64;
|
||||
|
||||
#ifndef __must_check
|
||||
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
|
||||
#define __must_check __attribute__((__warn_unused_result__))
|
||||
#else
|
||||
#define __must_check
|
||||
#endif /* __GNUC__ */
|
||||
#endif /* __must_check */
|
||||
|
||||
int hwaddr_aton(const char *txt, u8 *addr);
|
||||
int hwaddr_aton2(const char *txt, u8 *addr);
|
||||
int hexstr2bin(const char *hex, u8 *buf, size_t len);
|
||||
void inc_byte_array(u8 *counter, size_t len);
|
||||
void wpa_get_ntp_timestamp(u8 *buf);
|
||||
int wpa_snprintf_hex(char *buf, size_t buf_size, const u8 *data, size_t len);
|
||||
int wpa_snprintf_hex_uppercase(char *buf, size_t buf_size, const u8 *data,
|
||||
size_t len);
|
||||
|
||||
#ifdef CONFIG_NATIVE_WINDOWS
|
||||
void wpa_unicode2ascii_inplace(TCHAR *str);
|
||||
TCHAR * wpa_strdup_tchar(const char *str);
|
||||
#else /* CONFIG_NATIVE_WINDOWS */
|
||||
#define wpa_unicode2ascii_inplace(s) do { } while (0)
|
||||
#define wpa_strdup_tchar(s) strdup((s))
|
||||
#endif /* CONFIG_NATIVE_WINDOWS */
|
||||
|
||||
const char * wpa_ssid_txt(const u8 *ssid, size_t ssid_len);
|
||||
|
||||
static inline int is_zero_ether_addr(const u8 *a)
|
||||
{
|
||||
return !(a[0] | a[1] | a[2] | a[3] | a[4] | a[5]);
|
||||
}
|
||||
|
||||
/*
|
||||
* gcc 4.4 ends up generating strict-aliasing warnings about some very common
|
||||
* networking socket uses that do not really result in a real problem and
|
||||
* cannot be easily avoided with union-based type-punning due to struct
|
||||
* definitions including another struct in system header files. To avoid having
|
||||
* to fully disable strict-aliasing warnings, provide a mechanism to hide the
|
||||
* typecast from aliasing for now. A cleaner solution will hopefully be found
|
||||
* in the future to handle these cases.
|
||||
*/
|
||||
void * __hide_aliasing_typecast(void *foo);
|
||||
#define aliasing_hide_typecast(a,t) (t *) __hide_aliasing_typecast((a))
|
||||
|
||||
#endif /* COMMON_H */
|
471
tools/sdk/include/wpa_supplicant/crypto/crypto.h
Normal file
471
tools/sdk/include/wpa_supplicant/crypto/crypto.h
Normal file
@ -0,0 +1,471 @@
|
||||
/*
|
||||
* WPA Supplicant / wrapper functions for crypto libraries
|
||||
* Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*
|
||||
* This file defines the cryptographic functions that need to be implemented
|
||||
* for wpa_supplicant and hostapd. When TLS is not used, internal
|
||||
* implementation of MD5, SHA1, and AES is used and no external libraries are
|
||||
* required. When TLS is enabled (e.g., by enabling EAP-TLS or EAP-PEAP), the
|
||||
* crypto library used by the TLS implementation is expected to be used for
|
||||
* non-TLS needs, too, in order to save space by not implementing these
|
||||
* functions twice.
|
||||
*
|
||||
* Wrapper code for using each crypto library is in its own file (crypto*.c)
|
||||
* and one of these files is build and linked in to provide the functions
|
||||
* defined here.
|
||||
*/
|
||||
|
||||
#ifndef CRYPTO_H
|
||||
#define CRYPTO_H
|
||||
|
||||
/**
|
||||
* md4_vector - MD4 hash for data vector
|
||||
* @num_elem: Number of elements in the data vector
|
||||
* @addr: Pointers to the data areas
|
||||
* @len: Lengths of the data blocks
|
||||
* @mac: Buffer for the hash
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int md4_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac);
|
||||
|
||||
/**
|
||||
* md5_vector - MD5 hash for data vector
|
||||
* @num_elem: Number of elements in the data vector
|
||||
* @addr: Pointers to the data areas
|
||||
* @len: Lengths of the data blocks
|
||||
* @mac: Buffer for the hash
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int md5_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac);
|
||||
|
||||
#ifdef CONFIG_FIPS
|
||||
/**
|
||||
* md5_vector_non_fips_allow - MD5 hash for data vector (non-FIPS use allowed)
|
||||
* @num_elem: Number of elements in the data vector
|
||||
* @addr: Pointers to the data areas
|
||||
* @len: Lengths of the data blocks
|
||||
* @mac: Buffer for the hash
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int md5_vector_non_fips_allow(size_t num_elem, const u8 *addr[],
|
||||
const size_t *len, u8 *mac);
|
||||
#else /* CONFIG_FIPS */
|
||||
#define md5_vector_non_fips_allow md5_vector
|
||||
#endif /* CONFIG_FIPS */
|
||||
|
||||
|
||||
/**
|
||||
* sha1_vector - SHA-1 hash for data vector
|
||||
* @num_elem: Number of elements in the data vector
|
||||
* @addr: Pointers to the data areas
|
||||
* @len: Lengths of the data blocks
|
||||
* @mac: Buffer for the hash
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int sha1_vector(size_t num_elem, const u8 *addr[], const size_t *len,
|
||||
u8 *mac);
|
||||
|
||||
/**
|
||||
* fips186_2-prf - NIST FIPS Publication 186-2 change notice 1 PRF
|
||||
* @seed: Seed/key for the PRF
|
||||
* @seed_len: Seed length in bytes
|
||||
* @x: Buffer for PRF output
|
||||
* @xlen: Output length in bytes
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function implements random number generation specified in NIST FIPS
|
||||
* Publication 186-2 for EAP-SIM. This PRF uses a function that is similar to
|
||||
* SHA-1, but has different message padding.
|
||||
*/
|
||||
int __must_check fips186_2_prf(const u8 *seed, size_t seed_len, u8 *x,
|
||||
size_t xlen);
|
||||
|
||||
/**
|
||||
* sha256_vector - SHA256 hash for data vector
|
||||
* @num_elem: Number of elements in the data vector
|
||||
* @addr: Pointers to the data areas
|
||||
* @len: Lengths of the data blocks
|
||||
* @mac: Buffer for the hash
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len,
|
||||
u8 *mac);
|
||||
|
||||
/**
|
||||
* des_encrypt - Encrypt one block with DES
|
||||
* @clear: 8 octets (in)
|
||||
* @key: 7 octets (in) (no parity bits included)
|
||||
* @cypher: 8 octets (out)
|
||||
*/
|
||||
void des_encrypt(const u8 *clear, const u8 *key, u8 *cypher);
|
||||
|
||||
/**
|
||||
* aes_encrypt_init - Initialize AES for encryption
|
||||
* @key: Encryption key
|
||||
* @len: Key length in bytes (usually 16, i.e., 128 bits)
|
||||
* Returns: Pointer to context data or %NULL on failure
|
||||
*/
|
||||
void * aes_encrypt_init(const u8 *key, size_t len);
|
||||
|
||||
/**
|
||||
* aes_encrypt - Encrypt one AES block
|
||||
* @ctx: Context pointer from aes_encrypt_init()
|
||||
* @plain: Plaintext data to be encrypted (16 bytes)
|
||||
* @crypt: Buffer for the encrypted data (16 bytes)
|
||||
*/
|
||||
void aes_encrypt(void *ctx, const u8 *plain, u8 *crypt);
|
||||
|
||||
/**
|
||||
* aes_encrypt_deinit - Deinitialize AES encryption
|
||||
* @ctx: Context pointer from aes_encrypt_init()
|
||||
*/
|
||||
void aes_encrypt_deinit(void *ctx);
|
||||
|
||||
/**
|
||||
* aes_decrypt_init - Initialize AES for decryption
|
||||
* @key: Decryption key
|
||||
* @len: Key length in bytes (usually 16, i.e., 128 bits)
|
||||
* Returns: Pointer to context data or %NULL on failure
|
||||
*/
|
||||
void * aes_decrypt_init(const u8 *key, size_t len);
|
||||
|
||||
/**
|
||||
* aes_decrypt - Decrypt one AES block
|
||||
* @ctx: Context pointer from aes_encrypt_init()
|
||||
* @crypt: Encrypted data (16 bytes)
|
||||
* @plain: Buffer for the decrypted data (16 bytes)
|
||||
*/
|
||||
void aes_decrypt(void *ctx, const u8 *crypt, u8 *plain);
|
||||
|
||||
/**
|
||||
* aes_decrypt_deinit - Deinitialize AES decryption
|
||||
* @ctx: Context pointer from aes_encrypt_init()
|
||||
*/
|
||||
void aes_decrypt_deinit(void *ctx);
|
||||
|
||||
|
||||
enum crypto_hash_alg {
|
||||
CRYPTO_HASH_ALG_MD5, CRYPTO_HASH_ALG_SHA1,
|
||||
CRYPTO_HASH_ALG_HMAC_MD5, CRYPTO_HASH_ALG_HMAC_SHA1,
|
||||
CRYPTO_HASH_ALG_SHA256, CRYPTO_HASH_ALG_HMAC_SHA256
|
||||
};
|
||||
|
||||
|
||||
struct crypto_hash;
|
||||
|
||||
/**
|
||||
* crypto_hash_init - Initialize hash/HMAC function
|
||||
* @alg: Hash algorithm
|
||||
* @key: Key for keyed hash (e.g., HMAC) or %NULL if not needed
|
||||
* @key_len: Length of the key in bytes
|
||||
* Returns: Pointer to hash context to use with other hash functions or %NULL
|
||||
* on failure
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
struct crypto_hash * crypto_hash_init(enum crypto_hash_alg alg, const u8 *key,
|
||||
size_t key_len);
|
||||
|
||||
/**
|
||||
* crypto_hash_update - Add data to hash calculation
|
||||
* @ctx: Context pointer from crypto_hash_init()
|
||||
* @data: Data buffer to add
|
||||
* @len: Length of the buffer
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
void crypto_hash_update(struct crypto_hash *ctx, const u8 *data, size_t len);
|
||||
|
||||
/**
|
||||
* crypto_hash_finish - Complete hash calculation
|
||||
* @ctx: Context pointer from crypto_hash_init()
|
||||
* @hash: Buffer for hash value or %NULL if caller is just freeing the hash
|
||||
* context
|
||||
* @len: Pointer to length of the buffer or %NULL if caller is just freeing the
|
||||
* hash context; on return, this is set to the actual length of the hash value
|
||||
* Returns: 0 on success, -1 if buffer is too small (len set to needed length),
|
||||
* or -2 on other failures (including failed crypto_hash_update() operations)
|
||||
*
|
||||
* This function calculates the hash value and frees the context buffer that
|
||||
* was used for hash calculation.
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
int crypto_hash_finish(struct crypto_hash *ctx, u8 *hash, size_t *len);
|
||||
|
||||
|
||||
enum crypto_cipher_alg {
|
||||
CRYPTO_CIPHER_NULL = 0, CRYPTO_CIPHER_ALG_AES, CRYPTO_CIPHER_ALG_3DES,
|
||||
CRYPTO_CIPHER_ALG_DES, CRYPTO_CIPHER_ALG_RC2, CRYPTO_CIPHER_ALG_RC4
|
||||
};
|
||||
|
||||
struct crypto_cipher;
|
||||
|
||||
/**
|
||||
* crypto_cipher_init - Initialize block/stream cipher function
|
||||
* @alg: Cipher algorithm
|
||||
* @iv: Initialization vector for block ciphers or %NULL for stream ciphers
|
||||
* @key: Cipher key
|
||||
* @key_len: Length of key in bytes
|
||||
* Returns: Pointer to cipher context to use with other cipher functions or
|
||||
* %NULL on failure
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
struct crypto_cipher * crypto_cipher_init(enum crypto_cipher_alg alg,
|
||||
const u8 *iv, const u8 *key,
|
||||
size_t key_len);
|
||||
|
||||
/**
|
||||
* crypto_cipher_encrypt - Cipher encrypt
|
||||
* @ctx: Context pointer from crypto_cipher_init()
|
||||
* @plain: Plaintext to cipher
|
||||
* @crypt: Resulting ciphertext
|
||||
* @len: Length of the plaintext
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
int __must_check crypto_cipher_encrypt(struct crypto_cipher *ctx,
|
||||
const u8 *plain, u8 *crypt, size_t len);
|
||||
|
||||
/**
|
||||
* crypto_cipher_decrypt - Cipher decrypt
|
||||
* @ctx: Context pointer from crypto_cipher_init()
|
||||
* @crypt: Ciphertext to decrypt
|
||||
* @plain: Resulting plaintext
|
||||
* @len: Length of the cipher text
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
int __must_check crypto_cipher_decrypt(struct crypto_cipher *ctx,
|
||||
const u8 *crypt, u8 *plain, size_t len);
|
||||
|
||||
/**
|
||||
* crypto_cipher_decrypt - Free cipher context
|
||||
* @ctx: Context pointer from crypto_cipher_init()
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
void crypto_cipher_deinit(struct crypto_cipher *ctx);
|
||||
|
||||
|
||||
struct crypto_public_key;
|
||||
struct crypto_private_key;
|
||||
|
||||
/**
|
||||
* crypto_public_key_import - Import an RSA public key
|
||||
* @key: Key buffer (DER encoded RSA public key)
|
||||
* @len: Key buffer length in bytes
|
||||
* Returns: Pointer to the public key or %NULL on failure
|
||||
*
|
||||
* This function can just return %NULL if the crypto library supports X.509
|
||||
* parsing. In that case, crypto_public_key_from_cert() is used to import the
|
||||
* public key from a certificate.
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
struct crypto_public_key * crypto_public_key_import(const u8 *key, size_t len);
|
||||
|
||||
/**
|
||||
* crypto_private_key_import - Import an RSA private key
|
||||
* @key: Key buffer (DER encoded RSA private key)
|
||||
* @len: Key buffer length in bytes
|
||||
* @passwd: Key encryption password or %NULL if key is not encrypted
|
||||
* Returns: Pointer to the private key or %NULL on failure
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
struct crypto_private_key * crypto_private_key_import(const u8 *key,
|
||||
size_t len,
|
||||
const char *passwd);
|
||||
|
||||
/**
|
||||
* crypto_public_key_from_cert - Import an RSA public key from a certificate
|
||||
* @buf: DER encoded X.509 certificate
|
||||
* @len: Certificate buffer length in bytes
|
||||
* Returns: Pointer to public key or %NULL on failure
|
||||
*
|
||||
* This function can just return %NULL if the crypto library does not support
|
||||
* X.509 parsing. In that case, internal code will be used to parse the
|
||||
* certificate and public key is imported using crypto_public_key_import().
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
struct crypto_public_key * crypto_public_key_from_cert(const u8 *buf,
|
||||
size_t len);
|
||||
|
||||
/**
|
||||
* crypto_public_key_encrypt_pkcs1_v15 - Public key encryption (PKCS #1 v1.5)
|
||||
* @key: Public key
|
||||
* @in: Plaintext buffer
|
||||
* @inlen: Length of plaintext buffer in bytes
|
||||
* @out: Output buffer for encrypted data
|
||||
* @outlen: Length of output buffer in bytes; set to used length on success
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
int __must_check crypto_public_key_encrypt_pkcs1_v15(
|
||||
struct crypto_public_key *key, const u8 *in, size_t inlen,
|
||||
u8 *out, size_t *outlen);
|
||||
|
||||
/**
|
||||
* crypto_private_key_decrypt_pkcs1_v15 - Private key decryption (PKCS #1 v1.5)
|
||||
* @key: Private key
|
||||
* @in: Encrypted buffer
|
||||
* @inlen: Length of encrypted buffer in bytes
|
||||
* @out: Output buffer for encrypted data
|
||||
* @outlen: Length of output buffer in bytes; set to used length on success
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
int __must_check crypto_private_key_decrypt_pkcs1_v15(
|
||||
struct crypto_private_key *key, const u8 *in, size_t inlen,
|
||||
u8 *out, size_t *outlen);
|
||||
|
||||
/**
|
||||
* crypto_private_key_sign_pkcs1 - Sign with private key (PKCS #1)
|
||||
* @key: Private key from crypto_private_key_import()
|
||||
* @in: Plaintext buffer
|
||||
* @inlen: Length of plaintext buffer in bytes
|
||||
* @out: Output buffer for encrypted (signed) data
|
||||
* @outlen: Length of output buffer in bytes; set to used length on success
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
int __must_check crypto_private_key_sign_pkcs1(struct crypto_private_key *key,
|
||||
const u8 *in, size_t inlen,
|
||||
u8 *out, size_t *outlen);
|
||||
|
||||
/**
|
||||
* crypto_public_key_free - Free public key
|
||||
* @key: Public key
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
void crypto_public_key_free(struct crypto_public_key *key);
|
||||
|
||||
/**
|
||||
* crypto_private_key_free - Free private key
|
||||
* @key: Private key from crypto_private_key_import()
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
void crypto_private_key_free(struct crypto_private_key *key);
|
||||
|
||||
/**
|
||||
* crypto_public_key_decrypt_pkcs1 - Decrypt PKCS #1 signature
|
||||
* @key: Public key
|
||||
* @crypt: Encrypted signature data (using the private key)
|
||||
* @crypt_len: Encrypted signature data length
|
||||
* @plain: Buffer for plaintext (at least crypt_len bytes)
|
||||
* @plain_len: Plaintext length (max buffer size on input, real len on output);
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int __must_check crypto_public_key_decrypt_pkcs1(
|
||||
struct crypto_public_key *key, const u8 *crypt, size_t crypt_len,
|
||||
u8 *plain, size_t *plain_len);
|
||||
|
||||
/**
|
||||
* crypto_global_init - Initialize crypto wrapper
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
int __must_check crypto_global_init(void);
|
||||
|
||||
/**
|
||||
* crypto_global_deinit - Deinitialize crypto wrapper
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
void crypto_global_deinit(void);
|
||||
|
||||
/**
|
||||
* crypto_mod_exp - Modular exponentiation of large integers
|
||||
* @base: Base integer (big endian byte array)
|
||||
* @base_len: Length of base integer in bytes
|
||||
* @power: Power integer (big endian byte array)
|
||||
* @power_len: Length of power integer in bytes
|
||||
* @modulus: Modulus integer (big endian byte array)
|
||||
* @modulus_len: Length of modulus integer in bytes
|
||||
* @result: Buffer for the result
|
||||
* @result_len: Result length (max buffer size on input, real len on output)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function calculates result = base ^ power mod modulus. modules_len is
|
||||
* used as the maximum size of modulus buffer. It is set to the used size on
|
||||
* success.
|
||||
*
|
||||
* This function is only used with internal TLSv1 implementation
|
||||
* (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
|
||||
* to implement this.
|
||||
*/
|
||||
int __must_check crypto_mod_exp(const u8 *base, size_t base_len,
|
||||
const u8 *power, size_t power_len,
|
||||
const u8 *modulus, size_t modulus_len,
|
||||
u8 *result, size_t *result_len);
|
||||
|
||||
/**
|
||||
* rc4_skip - XOR RC4 stream to given data with skip-stream-start
|
||||
* @key: RC4 key
|
||||
* @keylen: RC4 key length
|
||||
* @skip: number of bytes to skip from the beginning of the RC4 stream
|
||||
* @data: data to be XOR'ed with RC4 stream
|
||||
* @data_len: buf length
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* Generate RC4 pseudo random stream for the given key, skip beginning of the
|
||||
* stream, and XOR the end result with the data buffer to perform RC4
|
||||
* encryption/decryption.
|
||||
*/
|
||||
int rc4_skip(const u8 *key, size_t keylen, size_t skip,
|
||||
u8 *data, size_t data_len);
|
||||
|
||||
#endif /* CRYPTO_H */
|
23
tools/sdk/include/wpa_supplicant/crypto/dh_group5.h
Normal file
23
tools/sdk/include/wpa_supplicant/crypto/dh_group5.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Diffie-Hellman group 5 operations
|
||||
* Copyright (c) 2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef DH_GROUP5_H
|
||||
#define DH_GROUP5_H
|
||||
|
||||
void * dh5_init(struct wpabuf **priv, struct wpabuf **publ);
|
||||
struct wpabuf * dh5_derive_shared(void *ctx, const struct wpabuf *peer_public,
|
||||
const struct wpabuf *own_private);
|
||||
void dh5_free(void *ctx);
|
||||
|
||||
#endif /* DH_GROUP5_H */
|
32
tools/sdk/include/wpa_supplicant/crypto/dh_groups.h
Normal file
32
tools/sdk/include/wpa_supplicant/crypto/dh_groups.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Diffie-Hellman groups
|
||||
* Copyright (c) 2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef DH_GROUPS_H
|
||||
#define DH_GROUPS_H
|
||||
|
||||
struct dh_group {
|
||||
int id;
|
||||
const u8 *generator;
|
||||
size_t generator_len;
|
||||
const u8 *prime;
|
||||
size_t prime_len;
|
||||
};
|
||||
|
||||
const struct dh_group * dh_groups_get(int id);
|
||||
struct wpabuf * dh_init(const struct dh_group *dh, struct wpabuf **priv);
|
||||
struct wpabuf * dh_derive_shared(const struct wpabuf *peer_public,
|
||||
const struct wpabuf *own_private,
|
||||
const struct dh_group *dh);
|
||||
|
||||
#endif /* DH_GROUPS_H */
|
65
tools/sdk/include/wpa_supplicant/crypto/includes.h
Normal file
65
tools/sdk/include/wpa_supplicant/crypto/includes.h
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* wpa_supplicant/hostapd - Default include files
|
||||
* Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*
|
||||
* This header file is included into all C files so that commonly used header
|
||||
* files can be selected with OS specific ifdef blocks in one place instead of
|
||||
* having to have OS/C library specific selection in many files.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDES_H
|
||||
#define INCLUDES_H
|
||||
|
||||
/* Include possible build time configuration before including anything else */
|
||||
//#include "build_config.h" //don't need anymore
|
||||
#ifndef __ets__
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#ifndef _WIN32_WCE
|
||||
#ifndef CONFIG_TI_COMPILER
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#endif /* CONFIG_TI_COMPILER */
|
||||
#include <errno.h>
|
||||
#endif /* _WIN32_WCE */
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifndef CONFIG_TI_COMPILER
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
#endif /* _MSC_VER */
|
||||
#endif /* CONFIG_TI_COMPILER */
|
||||
|
||||
#ifndef CONFIG_NATIVE_WINDOWS
|
||||
#ifndef CONFIG_TI_COMPILER
|
||||
//#include <sys/socket.h>
|
||||
//#include <netinet/in.h>
|
||||
//#include <arpa/inet.h>
|
||||
#ifndef __vxworks
|
||||
#ifndef __SYMBIAN32__
|
||||
//#include <sys/uio.h>
|
||||
#endif /* __SYMBIAN32__ */
|
||||
#include <sys/time.h>
|
||||
#endif /* __vxworks */
|
||||
#endif /* CONFIG_TI_COMPILER */
|
||||
#endif /* CONFIG_NATIVE_WINDOWS */
|
||||
|
||||
#else
|
||||
|
||||
#include "rom/ets_sys.h"
|
||||
|
||||
#endif /* !__ets__ */
|
||||
|
||||
#endif /* INCLUDES_H */
|
35
tools/sdk/include/wpa_supplicant/crypto/md5.h
Normal file
35
tools/sdk/include/wpa_supplicant/crypto/md5.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* MD5 hash implementation and interface functions
|
||||
* Copyright (c) 2003-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef MD5_H
|
||||
#define MD5_H
|
||||
|
||||
#define MD5_MAC_LEN 16
|
||||
|
||||
int hmac_md5_vector(const u8 *key, size_t key_len, size_t num_elem,
|
||||
const u8 *addr[], const size_t *len, u8 *mac);
|
||||
int hmac_md5(const u8 *key, size_t key_len, const u8 *data, size_t data_len,
|
||||
u8 *mac);
|
||||
#ifdef CONFIG_FIPS
|
||||
int hmac_md5_vector_non_fips_allow(const u8 *key, size_t key_len,
|
||||
size_t num_elem, const u8 *addr[],
|
||||
const size_t *len, u8 *mac);
|
||||
int hmac_md5_non_fips_allow(const u8 *key, size_t key_len, const u8 *data,
|
||||
size_t data_len, u8 *mac);
|
||||
#else /* CONFIG_FIPS */
|
||||
#define hmac_md5_vector_non_fips_allow hmac_md5_vector
|
||||
#define hmac_md5_non_fips_allow hmac_md5
|
||||
#endif /* CONFIG_FIPS */
|
||||
|
||||
#endif /* MD5_H */
|
29
tools/sdk/include/wpa_supplicant/crypto/md5_i.h
Normal file
29
tools/sdk/include/wpa_supplicant/crypto/md5_i.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* MD5 internal definitions
|
||||
* Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef MD5_I_H
|
||||
#define MD5_I_H
|
||||
|
||||
struct MD5Context {
|
||||
u32 buf[4];
|
||||
u32 bits[2];
|
||||
u8 in[64];
|
||||
};
|
||||
|
||||
void MD5Init(struct MD5Context *context);
|
||||
void MD5Update(struct MD5Context *context, unsigned char const *buf,
|
||||
unsigned len);
|
||||
void MD5Final(unsigned char digest[16], struct MD5Context *context);
|
||||
|
||||
#endif /* MD5_I_H */
|
34
tools/sdk/include/wpa_supplicant/crypto/random.h
Normal file
34
tools/sdk/include/wpa_supplicant/crypto/random.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Random number generator
|
||||
* Copyright (c) 2010-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef RANDOM_H
|
||||
#define RANDOM_H
|
||||
|
||||
#define CONFIG_NO_RANDOM_POOL
|
||||
|
||||
#ifdef CONFIG_NO_RANDOM_POOL
|
||||
#define random_init(e) do { } while (0)
|
||||
#define random_deinit() do { } while (0)
|
||||
#define random_add_randomness(b, l) do { } while (0)
|
||||
#define random_get_bytes(b, l) os_get_random((b), (l))
|
||||
#define random_pool_ready() 1
|
||||
#define random_mark_pool_ready() do { } while (0)
|
||||
#else /* CONFIG_NO_RANDOM_POOL */
|
||||
void random_init(const char *entropy_file);
|
||||
void random_deinit(void);
|
||||
void random_add_randomness(const void *buf, size_t len);
|
||||
int random_get_bytes(void *buf, size_t len);
|
||||
#endif /* CONFIG_NO_RANDOM_POOL */
|
||||
|
||||
#endif /* RANDOM_H */
|
33
tools/sdk/include/wpa_supplicant/crypto/sha1.h
Normal file
33
tools/sdk/include/wpa_supplicant/crypto/sha1.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* SHA1 hash implementation and interface functions
|
||||
* Copyright (c) 2003-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef SHA1_H
|
||||
#define SHA1_H
|
||||
|
||||
#define SHA1_MAC_LEN 20
|
||||
|
||||
int hmac_sha1_vector(const u8 *key, size_t key_len, size_t num_elem,
|
||||
const u8 *addr[], const size_t *len, u8 *mac);
|
||||
int hmac_sha1(const u8 *key, size_t key_len, const u8 *data, size_t data_len,
|
||||
u8 *mac);
|
||||
int sha1_prf(const u8 *key, size_t key_len, const char *label,
|
||||
const u8 *data, size_t data_len, u8 *buf, size_t buf_len);
|
||||
int sha1_t_prf(const u8 *key, size_t key_len, const char *label,
|
||||
const u8 *seed, size_t seed_len, u8 *buf, size_t buf_len);
|
||||
//int __must_check tls_prf(const u8 *secret, size_t secret_len,
|
||||
// const char *label, const u8 *seed, size_t seed_len,
|
||||
// u8 *out, size_t outlen);
|
||||
int pbkdf2_sha1(const char *passphrase, const char *ssid, size_t ssid_len,
|
||||
int iterations, u8 *buf, size_t buflen);
|
||||
#endif /* SHA1_H */
|
29
tools/sdk/include/wpa_supplicant/crypto/sha1_i.h
Normal file
29
tools/sdk/include/wpa_supplicant/crypto/sha1_i.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* SHA1 internal definitions
|
||||
* Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef SHA1_I_H
|
||||
#define SHA1_I_H
|
||||
|
||||
struct SHA1Context {
|
||||
u32 state[5];
|
||||
u32 count[2];
|
||||
unsigned char buffer[64];
|
||||
};
|
||||
|
||||
void SHA1Init(struct SHA1Context *context);
|
||||
void SHA1Update(struct SHA1Context *context, const void *data, u32 len);
|
||||
void SHA1Final(unsigned char digest[20], struct SHA1Context *context);
|
||||
void SHA1Transform(u32 state[5], const unsigned char buffer[64]);
|
||||
|
||||
#endif /* SHA1_I_H */
|
27
tools/sdk/include/wpa_supplicant/crypto/sha256.h
Normal file
27
tools/sdk/include/wpa_supplicant/crypto/sha256.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* SHA256 hash implementation and interface functions
|
||||
* Copyright (c) 2003-2006, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef SHA256_H
|
||||
#define SHA256_H
|
||||
|
||||
#define SHA256_MAC_LEN 32
|
||||
|
||||
void hmac_sha256_vector(const u8 *key, size_t key_len, size_t num_elem,
|
||||
const u8 *addr[], const size_t *len, u8 *mac);
|
||||
void hmac_sha256(const u8 *key, size_t key_len, const u8 *data,
|
||||
size_t data_len, u8 *mac);
|
||||
void sha256_prf(const u8 *key, size_t key_len, const char *label,
|
||||
const u8 *data, size_t data_len, u8 *buf, size_t buf_len);
|
||||
|
||||
#endif /* SHA256_H */
|
229
tools/sdk/include/wpa_supplicant/endian.h
Normal file
229
tools/sdk/include/wpa_supplicant/endian.h
Normal file
@ -0,0 +1,229 @@
|
||||
/*-
|
||||
* Copyright (c) 2002 Thomas Moestl <tmm@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _ENDIAN_H_
|
||||
#define _ENDIAN_H_
|
||||
|
||||
#include "byteswap.h"
|
||||
|
||||
#ifndef BIG_ENDIAN
|
||||
#define BIG_ENDIAN 4321
|
||||
#endif
|
||||
#ifndef LITTLE_ENDIAN
|
||||
#define LITTLE_ENDIAN 1234
|
||||
#endif
|
||||
|
||||
#ifndef BYTE_ORDER
|
||||
#ifdef __IEEE_LITTLE_ENDIAN
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#else
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define _UINT8_T_DECLARED
|
||||
#ifndef _UINT8_T_DECLARED
|
||||
typedef __uint8_t uint8_t;
|
||||
#define _UINT8_T_DECLARED
|
||||
#endif
|
||||
|
||||
#define _UINT16_T_DECLARED
|
||||
#ifndef _UINT16_T_DECLARED
|
||||
typedef __uint16_t uint16_t;
|
||||
#define _UINT16_T_DECLARED
|
||||
#endif
|
||||
|
||||
#define _UINT32_T_DECLARED
|
||||
#ifndef _UINT32_T_DECLARED
|
||||
typedef __uint32_t uint32_t;
|
||||
#define _UINT32_T_DECLARED
|
||||
#endif
|
||||
|
||||
#define _UINT64_T_DECLARED
|
||||
#ifndef _UINT64_T_DECLARED
|
||||
typedef __uint64_t uint64_t;
|
||||
#define _UINT64_T_DECLARED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* General byte order swapping functions.
|
||||
*/
|
||||
#define bswap16(x) __bswap16(x)
|
||||
#define bswap32(x) __bswap32(x)
|
||||
#define bswap64(x) __bswap64(x)
|
||||
|
||||
/*
|
||||
* 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
|
||||
#define htobe16(x) bswap16((x))
|
||||
#define htobe32(x) bswap32((x))
|
||||
#define htobe64(x) bswap64((x))
|
||||
#define htole16(x) ((uint16_t)(x))
|
||||
#define htole32(x) ((uint32_t)(x))
|
||||
#define htole64(x) ((uint64_t)(x))
|
||||
|
||||
#define be16toh(x) bswap16((x))
|
||||
#define be32toh(x) bswap32((x))
|
||||
#define be64toh(x) bswap64((x))
|
||||
#define le16toh(x) ((uint16_t)(x))
|
||||
#define le32toh(x) ((uint32_t)(x))
|
||||
#define le64toh(x) ((uint64_t)(x))
|
||||
|
||||
#ifndef htons
|
||||
#define htons htobe16
|
||||
#endif //htons
|
||||
|
||||
#else /* _BYTE_ORDER != _LITTLE_ENDIAN */
|
||||
#define htobe16(x) ((uint16_t)(x))
|
||||
#define htobe32(x) ((uint32_t)(x))
|
||||
#define htobe64(x) ((uint64_t)(x))
|
||||
#define htole16(x) bswap16((x))
|
||||
#define htole32(x) bswap32((x))
|
||||
#define htole64(x) bswap64((x))
|
||||
|
||||
#define be16toh(x) ((uint16_t)(x))
|
||||
#define be32toh(x) ((uint32_t)(x))
|
||||
#define be64toh(x) ((uint64_t)(x))
|
||||
#define le16toh(x) bswap16((x))
|
||||
#define le32toh(x) bswap32((x))
|
||||
#define le64toh(x) bswap64((x))
|
||||
#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */
|
||||
|
||||
/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */
|
||||
|
||||
static INLINE uint16_t
|
||||
be16dec(const void *pp)
|
||||
{
|
||||
uint8_t const *p = (uint8_t const *)pp;
|
||||
|
||||
return ((p[0] << 8) | p[1]);
|
||||
}
|
||||
|
||||
static INLINE uint32_t
|
||||
be32dec(const void *pp)
|
||||
{
|
||||
uint8_t const *p = (uint8_t const *)pp;
|
||||
|
||||
return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
|
||||
}
|
||||
|
||||
static INLINE uint64_t
|
||||
be64dec(const void *pp)
|
||||
{
|
||||
uint8_t const *p = (uint8_t const *)pp;
|
||||
|
||||
return (((uint64_t)be32dec(p) << 32) | be32dec(p + 4));
|
||||
}
|
||||
|
||||
static INLINE uint16_t
|
||||
le16dec(const void *pp)
|
||||
{
|
||||
uint8_t const *p = (uint8_t const *)pp;
|
||||
|
||||
return ((p[1] << 8) | p[0]);
|
||||
}
|
||||
|
||||
static INLINE uint32_t
|
||||
le32dec(const void *pp)
|
||||
{
|
||||
uint8_t const *p = (uint8_t const *)pp;
|
||||
|
||||
return (((unsigned)p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
|
||||
}
|
||||
|
||||
static INLINE uint64_t
|
||||
le64dec(const void *pp)
|
||||
{
|
||||
uint8_t const *p = (uint8_t const *)pp;
|
||||
|
||||
return (((uint64_t)le32dec(p + 4) << 32) | le32dec(p));
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
be16enc(void *pp, uint16_t u)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)pp;
|
||||
|
||||
p[0] = (u >> 8) & 0xff;
|
||||
p[1] = u & 0xff;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
be32enc(void *pp, uint32_t u)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)pp;
|
||||
|
||||
p[0] = (u >> 24) & 0xff;
|
||||
p[1] = (u >> 16) & 0xff;
|
||||
p[2] = (u >> 8) & 0xff;
|
||||
p[3] = u & 0xff;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
be64enc(void *pp, uint64_t u)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)pp;
|
||||
|
||||
be32enc(p, (uint32_t)(u >> 32));
|
||||
be32enc(p + 4, (uint32_t)(u & 0xffffffffU));
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
le16enc(void *pp, uint16_t u)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)pp;
|
||||
|
||||
p[0] = u & 0xff;
|
||||
p[1] = (u >> 8) & 0xff;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
le32enc(void *pp, uint32_t u)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)pp;
|
||||
|
||||
p[0] = u & 0xff;
|
||||
p[1] = (u >> 8) & 0xff;
|
||||
p[2] = (u >> 16) & 0xff;
|
||||
p[3] = (u >> 24) & 0xff;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
le64enc(void *pp, uint64_t u)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)pp;
|
||||
|
||||
le32enc(p, (uint32_t)(u & 0xffffffffU));
|
||||
le32enc(p + 4, (uint32_t)(u >> 32));
|
||||
}
|
||||
|
||||
#endif /* _ENDIAN_H_ */
|
286
tools/sdk/include/wpa_supplicant/os.h
Normal file
286
tools/sdk/include/wpa_supplicant/os.h
Normal file
@ -0,0 +1,286 @@
|
||||
/*
|
||||
* OS specific functions
|
||||
* Copyright (c) 2005-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef OS_H
|
||||
#define OS_H
|
||||
#include "esp_types.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "rom/ets_sys.h"
|
||||
#include "lwip/mem.h"
|
||||
typedef long os_time_t;
|
||||
|
||||
/**
|
||||
* os_sleep - Sleep (sec, usec)
|
||||
* @sec: Number of seconds to sleep
|
||||
* @usec: Number of microseconds to sleep
|
||||
*/
|
||||
void os_sleep(os_time_t sec, os_time_t usec);
|
||||
|
||||
struct os_time {
|
||||
os_time_t sec;
|
||||
os_time_t usec;
|
||||
};
|
||||
|
||||
/**
|
||||
* os_get_time - Get current time (sec, usec)
|
||||
* @t: Pointer to buffer for the time
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int os_get_time(struct os_time *t);
|
||||
|
||||
|
||||
/* Helper macros for handling struct os_time */
|
||||
|
||||
#define os_time_before(a, b) \
|
||||
((a)->sec < (b)->sec || \
|
||||
((a)->sec == (b)->sec && (a)->usec < (b)->usec))
|
||||
|
||||
#define os_time_sub(a, b, res) do { \
|
||||
(res)->sec = (a)->sec - (b)->sec; \
|
||||
(res)->usec = (a)->usec - (b)->usec; \
|
||||
if ((res)->usec < 0) { \
|
||||
(res)->sec--; \
|
||||
(res)->usec += 1000000; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* os_mktime - Convert broken-down time into seconds since 1970-01-01
|
||||
* @year: Four digit year
|
||||
* @month: Month (1 .. 12)
|
||||
* @day: Day of month (1 .. 31)
|
||||
* @hour: Hour (0 .. 23)
|
||||
* @min: Minute (0 .. 59)
|
||||
* @sec: Second (0 .. 60)
|
||||
* @t: Buffer for returning calendar time representation (seconds since
|
||||
* 1970-01-01 00:00:00)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* Note: The result is in seconds from Epoch, i.e., in UTC, not in local time
|
||||
* which is used by POSIX mktime().
|
||||
*/
|
||||
int os_mktime(int year, int month, int day, int hour, int min, int sec,
|
||||
os_time_t *t);
|
||||
|
||||
|
||||
/**
|
||||
* os_daemonize - Run in the background (detach from the controlling terminal)
|
||||
* @pid_file: File name to write the process ID to or %NULL to skip this
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int os_daemonize(const char *pid_file);
|
||||
|
||||
/**
|
||||
* os_daemonize_terminate - Stop running in the background (remove pid file)
|
||||
* @pid_file: File name to write the process ID to or %NULL to skip this
|
||||
*/
|
||||
void os_daemonize_terminate(const char *pid_file);
|
||||
|
||||
/**
|
||||
* os_get_random - Get cryptographically strong pseudo random data
|
||||
* @buf: Buffer for pseudo random data
|
||||
* @len: Length of the buffer
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int os_get_random(unsigned char *buf, size_t len);
|
||||
|
||||
/**
|
||||
* os_random - Get pseudo random value (not necessarily very strong)
|
||||
* Returns: Pseudo random value
|
||||
*/
|
||||
unsigned long os_random(void);
|
||||
|
||||
/**
|
||||
* os_rel2abs_path - Get an absolute path for a file
|
||||
* @rel_path: Relative path to a file
|
||||
* Returns: Absolute path for the file or %NULL on failure
|
||||
*
|
||||
* This function tries to convert a relative path of a file to an absolute path
|
||||
* in order for the file to be found even if current working directory has
|
||||
* changed. The returned value is allocated and caller is responsible for
|
||||
* freeing it. It is acceptable to just return the same path in an allocated
|
||||
* buffer, e.g., return strdup(rel_path). This function is only used to find
|
||||
* configuration files when os_daemonize() may have changed the current working
|
||||
* directory and relative path would be pointing to a different location.
|
||||
*/
|
||||
char * os_rel2abs_path(const char *rel_path);
|
||||
|
||||
/**
|
||||
* os_program_init - Program initialization (called at start)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function is called when a programs starts. If there are any OS specific
|
||||
* processing that is needed, it can be placed here. It is also acceptable to
|
||||
* just return 0 if not special processing is needed.
|
||||
*/
|
||||
int os_program_init(void);
|
||||
|
||||
/**
|
||||
* os_program_deinit - Program deinitialization (called just before exit)
|
||||
*
|
||||
* This function is called just before a program exists. If there are any OS
|
||||
* specific processing, e.g., freeing resourced allocated in os_program_init(),
|
||||
* it should be done here. It is also acceptable for this function to do
|
||||
* nothing.
|
||||
*/
|
||||
void os_program_deinit(void);
|
||||
|
||||
/**
|
||||
* os_setenv - Set environment variable
|
||||
* @name: Name of the variable
|
||||
* @value: Value to set to the variable
|
||||
* @overwrite: Whether existing variable should be overwritten
|
||||
* Returns: 0 on success, -1 on error
|
||||
*
|
||||
* This function is only used for wpa_cli action scripts. OS wrapper does not
|
||||
* need to implement this if such functionality is not needed.
|
||||
*/
|
||||
int os_setenv(const char *name, const char *value, int overwrite);
|
||||
|
||||
/**
|
||||
* os_unsetenv - Delete environent variable
|
||||
* @name: Name of the variable
|
||||
* Returns: 0 on success, -1 on error
|
||||
*
|
||||
* This function is only used for wpa_cli action scripts. OS wrapper does not
|
||||
* need to implement this if such functionality is not needed.
|
||||
*/
|
||||
int os_unsetenv(const char *name);
|
||||
|
||||
/**
|
||||
* os_readfile - Read a file to an allocated memory buffer
|
||||
* @name: Name of the file to read
|
||||
* @len: For returning the length of the allocated buffer
|
||||
* Returns: Pointer to the allocated buffer or %NULL on failure
|
||||
*
|
||||
* This function allocates memory and reads the given file to this buffer. Both
|
||||
* binary and text files can be read with this function. The caller is
|
||||
* responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
char * os_readfile(const char *name, size_t *len);
|
||||
|
||||
/*
|
||||
* The following functions are wrapper for standard ANSI C or POSIX functions.
|
||||
* By default, they are just defined to use the standard function name and no
|
||||
* os_*.c implementation is needed for them. This avoids extra function calls
|
||||
* by allowing the C pre-processor take care of the function name mapping.
|
||||
*
|
||||
* If the target system uses a C library that does not provide these functions,
|
||||
* build_config.h can be used to define the wrappers to use a different
|
||||
* function name. This can be done on function-by-function basis since the
|
||||
* defines here are only used if build_config.h does not define the os_* name.
|
||||
* If needed, os_*.c file can be used to implement the functions that are not
|
||||
* included in the C library on the target system. Alternatively,
|
||||
* OS_NO_C_LIB_DEFINES can be defined to skip all defines here in which case
|
||||
* 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_strdup
|
||||
#ifdef _MSC_VER
|
||||
#define os_strdup(s) _strdup(s)
|
||||
#else
|
||||
#define os_strdup(s) strdup(s)
|
||||
#endif
|
||||
#endif
|
||||
char * ets_strdup(const char *s);
|
||||
|
||||
#ifndef os_memcpy
|
||||
#define os_memcpy(d, s, n) memcpy((d), (s), (n))
|
||||
#endif
|
||||
#ifndef os_memmove
|
||||
#define os_memmove(d, s, n) memmove((d), (s), (n))
|
||||
#endif
|
||||
#ifndef os_memset
|
||||
#define os_memset(s, c, n) memset(s, c, n)
|
||||
#endif
|
||||
#ifndef os_memcmp
|
||||
#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
|
||||
#endif
|
||||
|
||||
#ifndef os_strlen
|
||||
#define os_strlen(s) strlen(s)
|
||||
#endif
|
||||
#ifndef os_strcasecmp
|
||||
#ifdef _MSC_VER
|
||||
#define os_strcasecmp(s1, s2) _stricmp((s1), (s2))
|
||||
#else
|
||||
#define os_strcasecmp(s1, s2) strcasecmp((s1), (s2))
|
||||
#endif
|
||||
#endif
|
||||
#ifndef os_strncasecmp
|
||||
#ifdef _MSC_VER
|
||||
#define os_strncasecmp(s1, s2, n) _strnicmp((s1), (s2), (n))
|
||||
#else
|
||||
#define os_strncasecmp(s1, s2, n) strncasecmp((s1), (s2), (n))
|
||||
#endif
|
||||
#endif
|
||||
#ifndef os_strchr
|
||||
#define os_strchr(s, c) strchr((s), (c))
|
||||
#endif
|
||||
#ifndef os_strcmp
|
||||
#define os_strcmp(s1, s2) strcmp((s1), (s2))
|
||||
#endif
|
||||
#ifndef os_strncmp
|
||||
#define os_strncmp(s1, s2, n) strncmp((s1), (s2), (n))
|
||||
#endif
|
||||
#ifndef os_strncpy
|
||||
#define os_strncpy(d, s, n) strncpy((d), (s), (n))
|
||||
#endif
|
||||
#ifndef os_strrchr
|
||||
//hard cold
|
||||
#define os_strrchr(s, c) NULL
|
||||
#endif
|
||||
#ifndef os_strstr
|
||||
#define os_strstr(h, n) strstr((h), (n))
|
||||
#endif
|
||||
|
||||
#ifndef os_snprintf
|
||||
#ifdef _MSC_VER
|
||||
#define os_snprintf _snprintf
|
||||
#else
|
||||
#define os_snprintf vsnprintf
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
|
||||
|
||||
#endif /* OS_H */
|
544
tools/sdk/include/wpa_supplicant/wpa/ap_config.h
Normal file
544
tools/sdk/include/wpa_supplicant/wpa/ap_config.h
Normal file
@ -0,0 +1,544 @@
|
||||
/*
|
||||
* hostapd / Configuration definitions and helpers functions
|
||||
* Copyright (c) 2003-2012, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef HOSTAPD_CONFIG_H
|
||||
#define HOSTAPD_CONFIG_H
|
||||
|
||||
#include "wpa/defs.h"
|
||||
//#include "ip_addr.h"
|
||||
#include "wpa/wpa_common.h"
|
||||
//#include "common/ieee802_11_common.h"
|
||||
//#include "wps/wps.h"
|
||||
|
||||
#define MAX_STA_COUNT 4
|
||||
#define MAX_VLAN_ID 4094
|
||||
|
||||
typedef u8 macaddr[ETH_ALEN];
|
||||
|
||||
struct mac_acl_entry {
|
||||
macaddr addr;
|
||||
int vlan_id;
|
||||
};
|
||||
|
||||
struct hostapd_radius_servers;
|
||||
struct ft_remote_r0kh;
|
||||
struct ft_remote_r1kh;
|
||||
|
||||
#define HOSTAPD_MAX_SSID_LEN 32
|
||||
|
||||
#define NUM_WEP_KEYS 4
|
||||
struct hostapd_wep_keys {
|
||||
u8 idx;
|
||||
u8 *key[NUM_WEP_KEYS];
|
||||
size_t len[NUM_WEP_KEYS];
|
||||
int keys_set;
|
||||
size_t default_len; /* key length used for dynamic key generation */
|
||||
};
|
||||
|
||||
typedef enum hostap_security_policy {
|
||||
SECURITY_PLAINTEXT = 0,
|
||||
SECURITY_STATIC_WEP = 1,
|
||||
SECURITY_IEEE_802_1X = 2,
|
||||
SECURITY_WPA_PSK = 3,
|
||||
SECURITY_WPA = 4
|
||||
} secpolicy;
|
||||
|
||||
struct hostapd_ssid {
|
||||
u8 ssid[HOSTAPD_MAX_SSID_LEN];
|
||||
size_t ssid_len;
|
||||
unsigned int ssid_set:1;
|
||||
unsigned int utf8_ssid:1;
|
||||
|
||||
// char vlan[IFNAMSIZ + 1];
|
||||
// secpolicy security_policy;
|
||||
|
||||
struct hostapd_wpa_psk *wpa_psk;
|
||||
char *wpa_passphrase;
|
||||
// char *wpa_psk_file;
|
||||
|
||||
struct hostapd_wep_keys wep;
|
||||
|
||||
#if 0
|
||||
#define DYNAMIC_VLAN_DISABLED 0
|
||||
#define DYNAMIC_VLAN_OPTIONAL 1
|
||||
#define DYNAMIC_VLAN_REQUIRED 2
|
||||
int dynamic_vlan;
|
||||
#define DYNAMIC_VLAN_NAMING_WITHOUT_DEVICE 0
|
||||
#define DYNAMIC_VLAN_NAMING_WITH_DEVICE 1
|
||||
#define DYNAMIC_VLAN_NAMING_END 2
|
||||
int vlan_naming;
|
||||
#ifdef CONFIG_FULL_DYNAMIC_VLAN
|
||||
char *vlan_tagged_interface;
|
||||
#endif /* CONFIG_FULL_DYNAMIC_VLAN */
|
||||
struct hostapd_wep_keys **dyn_vlan_keys;
|
||||
size_t max_dyn_vlan_keys;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if 0
|
||||
#define VLAN_ID_WILDCARD -1
|
||||
|
||||
struct hostapd_vlan {
|
||||
struct hostapd_vlan *next;
|
||||
int vlan_id; /* VLAN ID or -1 (VLAN_ID_WILDCARD) for wildcard entry */
|
||||
char ifname[IFNAMSIZ + 1];
|
||||
int dynamic_vlan;
|
||||
#ifdef CONFIG_FULL_DYNAMIC_VLAN
|
||||
|
||||
#define DVLAN_CLEAN_BR 0x1
|
||||
#define DVLAN_CLEAN_VLAN 0x2
|
||||
#define DVLAN_CLEAN_VLAN_PORT 0x4
|
||||
#define DVLAN_CLEAN_WLAN_PORT 0x8
|
||||
int clean;
|
||||
#endif /* CONFIG_FULL_DYNAMIC_VLAN */
|
||||
};
|
||||
#endif
|
||||
|
||||
#define PMK_LEN 32
|
||||
struct hostapd_sta_wpa_psk_short {
|
||||
struct hostapd_sta_wpa_psk_short *next;
|
||||
u8 psk[PMK_LEN];
|
||||
};
|
||||
|
||||
struct hostapd_wpa_psk {
|
||||
struct hostapd_wpa_psk *next;
|
||||
int group;
|
||||
u8 psk[PMK_LEN];
|
||||
u8 addr[ETH_ALEN];
|
||||
};
|
||||
|
||||
#if 0
|
||||
struct hostapd_eap_user {
|
||||
struct hostapd_eap_user *next;
|
||||
u8 *identity;
|
||||
size_t identity_len;
|
||||
struct {
|
||||
int vendor;
|
||||
u32 method;
|
||||
} methods[EAP_MAX_METHODS];
|
||||
u8 *password;
|
||||
size_t password_len;
|
||||
int phase2;
|
||||
int force_version;
|
||||
unsigned int wildcard_prefix:1;
|
||||
unsigned int password_hash:1; /* whether password is hashed with
|
||||
* nt_password_hash() */
|
||||
int ttls_auth; /* EAP_TTLS_AUTH_* bitfield */
|
||||
};
|
||||
|
||||
struct hostapd_radius_attr {
|
||||
u8 type;
|
||||
struct wpabuf *val;
|
||||
struct hostapd_radius_attr *next;
|
||||
};
|
||||
|
||||
|
||||
#define NUM_TX_QUEUES 4
|
||||
|
||||
struct hostapd_tx_queue_params {
|
||||
int aifs;
|
||||
int cwmin;
|
||||
int cwmax;
|
||||
int burst; /* maximum burst time in 0.1 ms, i.e., 10 = 1 ms */
|
||||
};
|
||||
|
||||
|
||||
#define MAX_ROAMING_CONSORTIUM_LEN 15
|
||||
|
||||
struct hostapd_roaming_consortium {
|
||||
u8 len;
|
||||
u8 oi[MAX_ROAMING_CONSORTIUM_LEN];
|
||||
};
|
||||
|
||||
struct hostapd_lang_string {
|
||||
u8 lang[3];
|
||||
u8 name_len;
|
||||
u8 name[252];
|
||||
};
|
||||
|
||||
#define MAX_NAI_REALMS 10
|
||||
#define MAX_NAI_REALMLEN 255
|
||||
#define MAX_NAI_EAP_METHODS 5
|
||||
#define MAX_NAI_AUTH_TYPES 4
|
||||
struct hostapd_nai_realm_data {
|
||||
u8 encoding;
|
||||
char realm_buf[MAX_NAI_REALMLEN + 1];
|
||||
char *realm[MAX_NAI_REALMS];
|
||||
u8 eap_method_count;
|
||||
struct hostapd_nai_realm_eap {
|
||||
u8 eap_method;
|
||||
u8 num_auths;
|
||||
u8 auth_id[MAX_NAI_AUTH_TYPES];
|
||||
u8 auth_val[MAX_NAI_AUTH_TYPES];
|
||||
} eap_method[MAX_NAI_EAP_METHODS];
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* struct hostapd_bss_config - Per-BSS configuration
|
||||
*/
|
||||
struct hostapd_bss_config {
|
||||
// char iface[IFNAMSIZ + 1];
|
||||
// char bridge[IFNAMSIZ + 1];
|
||||
// char wds_bridge[IFNAMSIZ + 1];
|
||||
|
||||
// enum hostapd_logger_level logger_syslog_level, logger_stdout_level;
|
||||
|
||||
// unsigned int logger_syslog; /* module bitfield */
|
||||
// unsigned int logger_stdout; /* module bitfield */
|
||||
|
||||
// char *dump_log_name; /* file name for state dump (SIGUSR1) */
|
||||
|
||||
int max_num_sta; /* maximum number of STAs in station table */
|
||||
|
||||
int dtim_period;
|
||||
|
||||
int ieee802_1x; /* use IEEE 802.1X */
|
||||
int eapol_version;
|
||||
// int eap_server; /* Use internal EAP server instead of external
|
||||
// * RADIUS server */
|
||||
// struct hostapd_eap_user *eap_user;
|
||||
// char *eap_user_sqlite;
|
||||
// char *eap_sim_db;
|
||||
// struct hostapd_ip_addr own_ip_addr;
|
||||
// char *nas_identifier;
|
||||
// struct hostapd_radius_servers *radius;
|
||||
// int acct_interim_interval;
|
||||
// int radius_request_cui;
|
||||
// struct hostapd_radius_attr *radius_auth_req_attr;
|
||||
// struct hostapd_radius_attr *radius_acct_req_attr;
|
||||
// int radius_das_port;
|
||||
// unsigned int radius_das_time_window;
|
||||
// int radius_das_require_event_timestamp;
|
||||
// struct hostapd_ip_addr radius_das_client_addr;
|
||||
// u8 *radius_das_shared_secret;
|
||||
// size_t radius_das_shared_secret_len;
|
||||
|
||||
struct hostapd_ssid ssid;
|
||||
|
||||
// char *eap_req_id_text; /* optional displayable message sent with
|
||||
// * EAP Request-Identity */
|
||||
// size_t eap_req_id_text_len;
|
||||
// int eapol_key_index_workaround;
|
||||
|
||||
// size_t default_wep_key_len;
|
||||
// int individual_wep_key_len;
|
||||
int wep_rekeying_period;
|
||||
int broadcast_key_idx_min, broadcast_key_idx_max;
|
||||
// int eap_reauth_period;
|
||||
|
||||
// int ieee802_11f; /* use IEEE 802.11f (IAPP) */
|
||||
// char iapp_iface[IFNAMSIZ + 1]; /* interface used with IAPP broadcast
|
||||
// * frames */
|
||||
|
||||
enum {
|
||||
ACCEPT_UNLESS_DENIED = 0,
|
||||
DENY_UNLESS_ACCEPTED = 1,
|
||||
USE_EXTERNAL_RADIUS_AUTH = 2
|
||||
} macaddr_acl;
|
||||
// struct mac_acl_entry *accept_mac;
|
||||
// int num_accept_mac;
|
||||
// struct mac_acl_entry *deny_mac;
|
||||
// int num_deny_mac;
|
||||
// int wds_sta;
|
||||
// int isolate;
|
||||
|
||||
int auth_algs; /* bitfield of allowed IEEE 802.11 authentication
|
||||
* algorithms, WPA_AUTH_ALG_{OPEN,SHARED,LEAP} */
|
||||
|
||||
int wpa; /* bitfield of WPA_PROTO_WPA, WPA_PROTO_RSN */
|
||||
int wpa_key_mgmt;
|
||||
#ifdef CONFIG_IEEE80211W
|
||||
enum mfp_options ieee80211w;
|
||||
/* dot11AssociationSAQueryMaximumTimeout (in TUs) */
|
||||
unsigned int assoc_sa_query_max_timeout;
|
||||
/* dot11AssociationSAQueryRetryTimeout (in TUs) */
|
||||
int assoc_sa_query_retry_timeout;
|
||||
#endif /* CONFIG_IEEE80211W */
|
||||
enum {
|
||||
PSK_RADIUS_IGNORED = 0,
|
||||
PSK_RADIUS_ACCEPTED = 1,
|
||||
PSK_RADIUS_REQUIRED = 2
|
||||
} wpa_psk_radius;
|
||||
int wpa_pairwise;
|
||||
int wpa_group;
|
||||
int wpa_group_rekey;
|
||||
int wpa_strict_rekey;
|
||||
int wpa_gmk_rekey;
|
||||
int wpa_ptk_rekey;
|
||||
int rsn_pairwise;
|
||||
int rsn_preauth;
|
||||
char *rsn_preauth_interfaces;
|
||||
int peerkey;
|
||||
|
||||
#ifdef CONFIG_IEEE80211R
|
||||
/* IEEE 802.11r - Fast BSS Transition */
|
||||
u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
|
||||
u8 r1_key_holder[FT_R1KH_ID_LEN];
|
||||
u32 r0_key_lifetime;
|
||||
u32 reassociation_deadline;
|
||||
struct ft_remote_r0kh *r0kh_list;
|
||||
struct ft_remote_r1kh *r1kh_list;
|
||||
int pmk_r1_push;
|
||||
int ft_over_ds;
|
||||
#endif /* CONFIG_IEEE80211R */
|
||||
|
||||
// char *ctrl_interface; /* directory for UNIX domain sockets */
|
||||
#ifndef CONFIG_NATIVE_WINDOWS
|
||||
// gid_t ctrl_interface_gid;
|
||||
#endif /* CONFIG_NATIVE_WINDOWS */
|
||||
// int ctrl_interface_gid_set;
|
||||
|
||||
// char *ca_cert;
|
||||
// char *server_cert;
|
||||
// char *private_key;
|
||||
// char *private_key_passwd;
|
||||
// int check_crl;
|
||||
// char *dh_file;
|
||||
// u8 *pac_opaque_encr_key;
|
||||
// u8 *eap_fast_a_id;
|
||||
// size_t eap_fast_a_id_len;
|
||||
// char *eap_fast_a_id_info;
|
||||
// int eap_fast_prov;
|
||||
// int pac_key_lifetime;
|
||||
// int pac_key_refresh_time;
|
||||
// int eap_sim_aka_result_ind;
|
||||
// int tnc;
|
||||
// int fragment_size;
|
||||
// u16 pwd_group;
|
||||
|
||||
// char *radius_server_clients;
|
||||
// int radius_server_auth_port;
|
||||
// int radius_server_ipv6;
|
||||
|
||||
// char *test_socket; /* UNIX domain socket path for driver_test */
|
||||
|
||||
// int use_pae_group_addr; /* Whether to send EAPOL frames to PAE group
|
||||
// * address instead of individual address
|
||||
// * (for driver_wired.c).
|
||||
// */
|
||||
|
||||
int ap_max_inactivity;
|
||||
int ignore_broadcast_ssid;
|
||||
|
||||
int wmm_enabled;
|
||||
int wmm_uapsd;
|
||||
|
||||
// struct hostapd_vlan *vlan, *vlan_tail;
|
||||
|
||||
macaddr bssid;
|
||||
|
||||
/*
|
||||
* Maximum listen interval that STAs can use when associating with this
|
||||
* BSS. If a STA tries to use larger value, the association will be
|
||||
* denied with status code 51.
|
||||
*/
|
||||
u16 max_listen_interval;
|
||||
|
||||
// int disable_pmksa_caching;
|
||||
// int okc; /* Opportunistic Key Caching */
|
||||
|
||||
// int wps_state;
|
||||
#ifdef CONFIG_WPS
|
||||
int ap_setup_locked;
|
||||
u8 uuid[16];
|
||||
char *wps_pin_requests;
|
||||
char *device_name;
|
||||
char *manufacturer;
|
||||
char *model_name;
|
||||
char *model_number;
|
||||
char *serial_number;
|
||||
u8 device_type[WPS_DEV_TYPE_LEN];
|
||||
char *config_methods;
|
||||
u8 os_version[4];
|
||||
char *ap_pin;
|
||||
int skip_cred_build;
|
||||
u8 *extra_cred;
|
||||
size_t extra_cred_len;
|
||||
int wps_cred_processing;
|
||||
u8 *ap_settings;
|
||||
size_t ap_settings_len;
|
||||
char *upnp_iface;
|
||||
char *friendly_name;
|
||||
char *manufacturer_url;
|
||||
char *model_description;
|
||||
char *model_url;
|
||||
char *upc;
|
||||
struct wpabuf *wps_vendor_ext[MAX_WPS_VENDOR_EXTENSIONS];
|
||||
int wps_nfc_dev_pw_id;
|
||||
struct wpabuf *wps_nfc_dh_pubkey;
|
||||
struct wpabuf *wps_nfc_dh_privkey;
|
||||
struct wpabuf *wps_nfc_dev_pw;
|
||||
#endif /* CONFIG_WPS */
|
||||
// int pbc_in_m1;
|
||||
|
||||
#define P2P_ENABLED BIT(0)
|
||||
#define P2P_GROUP_OWNER BIT(1)
|
||||
#define P2P_GROUP_FORMATION BIT(2)
|
||||
#define P2P_MANAGE BIT(3)
|
||||
#define P2P_ALLOW_CROSS_CONNECTION BIT(4)
|
||||
// int p2p;
|
||||
|
||||
// int disassoc_low_ack;
|
||||
// int skip_inactivity_poll;
|
||||
|
||||
#define TDLS_PROHIBIT BIT(0)
|
||||
#define TDLS_PROHIBIT_CHAN_SWITCH BIT(1)
|
||||
// int tdls;
|
||||
// int disable_11n;
|
||||
// int disable_11ac;
|
||||
|
||||
/* IEEE 802.11v */
|
||||
// int time_advertisement;
|
||||
// char *time_zone;
|
||||
// int wnm_sleep_mode;
|
||||
// int bss_transition;
|
||||
|
||||
/* IEEE 802.11u - Interworking */
|
||||
// int interworking;
|
||||
// int access_network_type;
|
||||
// int internet;
|
||||
// int asra;
|
||||
// int esr;
|
||||
// int uesa;
|
||||
// int venue_info_set;
|
||||
// u8 venue_group;
|
||||
// u8 venue_type;
|
||||
// u8 hessid[ETH_ALEN];
|
||||
|
||||
/* IEEE 802.11u - Roaming Consortium list */
|
||||
// unsigned int roaming_consortium_count;
|
||||
// struct hostapd_roaming_consortium *roaming_consortium;
|
||||
|
||||
/* IEEE 802.11u - Venue Name duples */
|
||||
// unsigned int venue_name_count;
|
||||
// struct hostapd_lang_string *venue_name;
|
||||
|
||||
/* IEEE 802.11u - Network Authentication Type */
|
||||
// u8 *network_auth_type;
|
||||
// size_t network_auth_type_len;
|
||||
|
||||
/* IEEE 802.11u - IP Address Type Availability */
|
||||
// u8 ipaddr_type_availability;
|
||||
// u8 ipaddr_type_configured;
|
||||
|
||||
/* IEEE 802.11u - 3GPP Cellular Network */
|
||||
// u8 *anqp_3gpp_cell_net;
|
||||
// size_t anqp_3gpp_cell_net_len;
|
||||
|
||||
/* IEEE 802.11u - Domain Name */
|
||||
// u8 *domain_name;
|
||||
// size_t domain_name_len;
|
||||
|
||||
// unsigned int nai_realm_count;
|
||||
// struct hostapd_nai_realm_data *nai_realm_data;
|
||||
|
||||
// u16 gas_comeback_delay;
|
||||
// int gas_frag_limit;
|
||||
|
||||
#ifdef CONFIG_HS20
|
||||
int hs20;
|
||||
int disable_dgaf;
|
||||
unsigned int hs20_oper_friendly_name_count;
|
||||
struct hostapd_lang_string *hs20_oper_friendly_name;
|
||||
u8 *hs20_wan_metrics;
|
||||
u8 *hs20_connection_capability;
|
||||
size_t hs20_connection_capability_len;
|
||||
u8 *hs20_operating_class;
|
||||
u8 hs20_operating_class_len;
|
||||
#endif /* CONFIG_HS20 */
|
||||
|
||||
// u8 wps_rf_bands; /* RF bands for WPS (WPS_RF_*) */
|
||||
|
||||
#ifdef CONFIG_RADIUS_TEST
|
||||
char *dump_msk_file;
|
||||
#endif /* CONFIG_RADIUS_TEST */
|
||||
|
||||
// struct wpabuf *vendor_elements;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* struct hostapd_config - Per-radio interface configuration
|
||||
*/
|
||||
struct hostapd_config {
|
||||
struct hostapd_bss_config *bss, *last_bss;
|
||||
size_t num_bss;
|
||||
|
||||
u16 beacon_int;
|
||||
int rts_threshold;
|
||||
int fragm_threshold;
|
||||
u8 send_probe_response;
|
||||
u8 channel;
|
||||
enum hostapd_hw_mode hw_mode; /* HOSTAPD_MODE_IEEE80211A, .. */
|
||||
enum {
|
||||
LONG_PREAMBLE = 0,
|
||||
SHORT_PREAMBLE = 1
|
||||
} preamble;
|
||||
|
||||
int *supported_rates;
|
||||
int *basic_rates;
|
||||
|
||||
const struct wpa_driver_ops *driver;
|
||||
|
||||
int ap_table_max_size;
|
||||
int ap_table_expiration_time;
|
||||
|
||||
char country[3]; /* first two octets: country code as described in
|
||||
* ISO/IEC 3166-1. Third octet:
|
||||
* ' ' (ascii 32): all environments
|
||||
* 'O': Outdoor environemnt only
|
||||
* 'I': Indoor environment only
|
||||
*/
|
||||
|
||||
int ieee80211d;
|
||||
|
||||
// struct hostapd_tx_queue_params tx_queue[NUM_TX_QUEUES];
|
||||
|
||||
/*
|
||||
* WMM AC parameters, in same order as 802.1D, i.e.
|
||||
* 0 = BE (best effort)
|
||||
* 1 = BK (background)
|
||||
* 2 = VI (video)
|
||||
* 3 = VO (voice)
|
||||
*/
|
||||
// struct hostapd_wmm_ac_params wmm_ac_params[4];
|
||||
|
||||
int ht_op_mode_fixed;
|
||||
u16 ht_capab;
|
||||
int ieee80211n;
|
||||
int secondary_channel;
|
||||
int require_ht;
|
||||
u32 vht_capab;
|
||||
int ieee80211ac;
|
||||
int require_vht;
|
||||
u8 vht_oper_chwidth;
|
||||
u8 vht_oper_centr_freq_seg0_idx;
|
||||
u8 vht_oper_centr_freq_seg1_idx;
|
||||
};
|
||||
|
||||
|
||||
int hostapd_mac_comp(const void *a, const void *b);
|
||||
int hostapd_mac_comp_empty(const void *a);
|
||||
struct hostapd_config * hostapd_config_defaults(void);
|
||||
void hostapd_config_defaults_bss(struct hostapd_bss_config *bss);
|
||||
void hostapd_config_free(struct hostapd_config *conf);
|
||||
int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
|
||||
const u8 *addr, int *vlan_id);
|
||||
int hostapd_rate_found(int *list, int rate);
|
||||
int hostapd_wep_key_cmp(struct hostapd_wep_keys *a,
|
||||
struct hostapd_wep_keys *b);
|
||||
const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
|
||||
const u8 *addr, const u8 *prev_psk);
|
||||
int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf);
|
||||
//const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan,
|
||||
// int vlan_id);
|
||||
//struct hostapd_radius_attr *
|
||||
//hostapd_config_get_radius_attr(struct hostapd_radius_attr *attr, u8 type);
|
||||
|
||||
#endif /* HOSTAPD_CONFIG_H */
|
324
tools/sdk/include/wpa_supplicant/wpa/common.h
Normal file
324
tools/sdk/include/wpa_supplicant/wpa/common.h
Normal file
@ -0,0 +1,324 @@
|
||||
/*
|
||||
* wpa_supplicant/hostapd / common helper functions, etc.
|
||||
* Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#if defined(__ets__)
|
||||
#endif /* ets */
|
||||
#include "os.h"
|
||||
|
||||
#if defined(__XTENSA__)
|
||||
#include <machine/endian.h>
|
||||
#define __BYTE_ORDER BYTE_ORDER
|
||||
#define __LITTLE_ENDIAN LITTLE_ENDIAN
|
||||
#define __BIG_ENDIAN BIG_ENDIAN
|
||||
#endif /*__XTENSA__*/
|
||||
|
||||
#if defined(__linux__) || defined(__GLIBC__) || defined(__ets__)
|
||||
#include <endian.h>
|
||||
#include <byteswap.h>
|
||||
#endif /* __linux__ */
|
||||
|
||||
/* Define platform specific byte swapping macros */
|
||||
|
||||
#if defined(__CYGWIN__) || defined(CONFIG_NATIVE_WINDOWS)
|
||||
|
||||
static inline unsigned short wpa_swap_16(unsigned short v)
|
||||
{
|
||||
return ((v & 0xff) << 8) | (v >> 8);
|
||||
}
|
||||
|
||||
static inline unsigned int wpa_swap_32(unsigned int v)
|
||||
{
|
||||
return ((v & 0xff) << 24) | ((v & 0xff00) << 8) |
|
||||
((v & 0xff0000) >> 8) | (v >> 24);
|
||||
}
|
||||
|
||||
#define le_to_host16(n) (n)
|
||||
#define host_to_le16(n) (n)
|
||||
#define be_to_host16(n) wpa_swap_16(n)
|
||||
#define host_to_be16(n) wpa_swap_16(n)
|
||||
#define le_to_host32(n) (n)
|
||||
#define be_to_host32(n) wpa_swap_32(n)
|
||||
#define host_to_be32(n) wpa_swap_32(n)
|
||||
|
||||
#define WPA_BYTE_SWAP_DEFINED
|
||||
|
||||
#endif /* __CYGWIN__ || CONFIG_NATIVE_WINDOWS */
|
||||
|
||||
|
||||
#ifndef WPA_BYTE_SWAP_DEFINED
|
||||
|
||||
#ifndef __BYTE_ORDER
|
||||
#ifndef __LITTLE_ENDIAN
|
||||
#ifndef __BIG_ENDIAN
|
||||
#define __LITTLE_ENDIAN 1234
|
||||
#define __BIG_ENDIAN 4321
|
||||
#if defined(sparc)
|
||||
#define __BYTE_ORDER __BIG_ENDIAN
|
||||
#endif
|
||||
#endif /* __BIG_ENDIAN */
|
||||
#endif /* __LITTLE_ENDIAN */
|
||||
#endif /* __BYTE_ORDER */
|
||||
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#define le_to_host16(n) ((__force u16) (le16) (n))
|
||||
#define host_to_le16(n) ((__force le16) (u16) (n))
|
||||
#define be_to_host16(n) __bswap_16((__force u16) (be16) (n))
|
||||
#define host_to_be16(n) ((__force be16) __bswap_16((n)))
|
||||
#define le_to_host32(n) ((__force u32) (le32) (n))
|
||||
#define host_to_le32(n) ((__force le32) (u32) (n))
|
||||
#define be_to_host32(n) __bswap_32((__force u32) (be32) (n))
|
||||
#define host_to_be32(n) ((__force be32) __bswap_32((n)))
|
||||
#define le_to_host64(n) ((__force u64) (le64) (n))
|
||||
#define host_to_le64(n) ((__force le64) (u64) (n))
|
||||
#define be_to_host64(n) __bswap_64((__force u64) (be64) (n))
|
||||
#define host_to_be64(n) ((__force be64) bswap_64((n)))
|
||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
#define le_to_host16(n) __bswap_16(n)
|
||||
#define host_to_le16(n) __bswap_16(n)
|
||||
#define be_to_host16(n) (n)
|
||||
#define host_to_be16(n) (n)
|
||||
#define le_to_host32(n) __bswap_32(n)
|
||||
#define be_to_host32(n) (n)
|
||||
#define host_to_be32(n) (n)
|
||||
#define le_to_host64(n) __bswap_64(n)
|
||||
#define host_to_le64(n) __bswap_64(n)
|
||||
#define be_to_host64(n) (n)
|
||||
#define host_to_be64(n) (n)
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
#define WORDS_BIGENDIAN
|
||||
#endif
|
||||
#else
|
||||
#error Could not determine CPU byte order
|
||||
#endif
|
||||
|
||||
#define WPA_BYTE_SWAP_DEFINED
|
||||
#endif /* !WPA_BYTE_SWAP_DEFINED */
|
||||
|
||||
|
||||
/* Macros for handling unaligned memory accesses */
|
||||
|
||||
#define WPA_GET_BE16(a) ((u16) (((a)[0] << 8) | (a)[1]))
|
||||
#define WPA_PUT_BE16(a, val) \
|
||||
do { \
|
||||
(a)[0] = ((u16) (val)) >> 8; \
|
||||
(a)[1] = ((u16) (val)) & 0xff; \
|
||||
} while (0)
|
||||
|
||||
#define WPA_GET_LE16(a) ((u16) (((a)[1] << 8) | (a)[0]))
|
||||
#define WPA_PUT_LE16(a, val) \
|
||||
do { \
|
||||
(a)[1] = ((u16) (val)) >> 8; \
|
||||
(a)[0] = ((u16) (val)) & 0xff; \
|
||||
} while (0)
|
||||
|
||||
#define WPA_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \
|
||||
((u32) (a)[2]))
|
||||
#define WPA_PUT_BE24(a, val) \
|
||||
do { \
|
||||
(a)[0] = (u8) ((((u32) (val)) >> 16) & 0xff); \
|
||||
(a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \
|
||||
(a)[2] = (u8) (((u32) (val)) & 0xff); \
|
||||
} while (0)
|
||||
|
||||
#define WPA_GET_BE32(a) ((((u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \
|
||||
(((u32) (a)[2]) << 8) | ((u32) (a)[3]))
|
||||
#define WPA_PUT_BE32(a, val) \
|
||||
do { \
|
||||
(a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \
|
||||
(a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \
|
||||
(a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \
|
||||
(a)[3] = (u8) (((u32) (val)) & 0xff); \
|
||||
} while (0)
|
||||
|
||||
#define WPA_GET_LE32(a) ((((u32) (a)[3]) << 24) | (((u32) (a)[2]) << 16) | \
|
||||
(((u32) (a)[1]) << 8) | ((u32) (a)[0]))
|
||||
#define WPA_PUT_LE32(a, val) \
|
||||
do { \
|
||||
(a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff); \
|
||||
(a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff); \
|
||||
(a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \
|
||||
(a)[0] = (u8) (((u32) (val)) & 0xff); \
|
||||
} while (0)
|
||||
|
||||
#define WPA_GET_BE64(a) ((((u64) (a)[0]) << 56) | (((u64) (a)[1]) << 48) | \
|
||||
(((u64) (a)[2]) << 40) | (((u64) (a)[3]) << 32) | \
|
||||
(((u64) (a)[4]) << 24) | (((u64) (a)[5]) << 16) | \
|
||||
(((u64) (a)[6]) << 8) | ((u64) (a)[7]))
|
||||
#define WPA_PUT_BE64(a, val) \
|
||||
do { \
|
||||
(a)[0] = (u8) (((u64) (val)) >> 56); \
|
||||
(a)[1] = (u8) (((u64) (val)) >> 48); \
|
||||
(a)[2] = (u8) (((u64) (val)) >> 40); \
|
||||
(a)[3] = (u8) (((u64) (val)) >> 32); \
|
||||
(a)[4] = (u8) (((u64) (val)) >> 24); \
|
||||
(a)[5] = (u8) (((u64) (val)) >> 16); \
|
||||
(a)[6] = (u8) (((u64) (val)) >> 8); \
|
||||
(a)[7] = (u8) (((u64) (val)) & 0xff); \
|
||||
} while (0)
|
||||
|
||||
#define WPA_GET_LE64(a) ((((u64) (a)[7]) << 56) | (((u64) (a)[6]) << 48) | \
|
||||
(((u64) (a)[5]) << 40) | (((u64) (a)[4]) << 32) | \
|
||||
(((u64) (a)[3]) << 24) | (((u64) (a)[2]) << 16) | \
|
||||
(((u64) (a)[1]) << 8) | ((u64) (a)[0]))
|
||||
|
||||
|
||||
#ifndef ETH_ALEN
|
||||
#define ETH_ALEN 6
|
||||
#endif
|
||||
//#ifndef IFNAMSIZ
|
||||
//#define IFNAMSIZ 16
|
||||
//#endif
|
||||
#ifndef ETH_P_ALL
|
||||
#define ETH_P_ALL 0x0003
|
||||
#endif
|
||||
#ifndef ETH_P_PAE
|
||||
#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
|
||||
#endif /* ETH_P_PAE */
|
||||
#ifndef ETH_P_EAPOL
|
||||
#define ETH_P_EAPOL ETH_P_PAE
|
||||
#endif /* ETH_P_EAPOL */
|
||||
#ifndef ETH_P_RSN_PREAUTH
|
||||
#define ETH_P_RSN_PREAUTH 0x88c7
|
||||
#endif /* ETH_P_RSN_PREAUTH */
|
||||
#ifndef ETH_P_RRB
|
||||
#define ETH_P_RRB 0x890D
|
||||
#endif /* ETH_P_RRB */
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define PRINTF_FORMAT(a,b) __attribute__ ((format (printf, (a), (b))))
|
||||
#define STRUCT_PACKED __attribute__ ((packed))
|
||||
#else
|
||||
#define PRINTF_FORMAT(a,b)
|
||||
#define STRUCT_PACKED
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ANSI_C_EXTRA
|
||||
|
||||
/* inline - define as __inline or just define it to be empty, if needed */
|
||||
#ifdef CONFIG_NO_INLINE
|
||||
#define inline
|
||||
#else
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
#ifndef __func__
|
||||
#define __func__ "__func__ not defined"
|
||||
#endif
|
||||
|
||||
#ifndef bswap_16
|
||||
#define bswap_16(a) ((((u16) (a) << 8) & 0xff00) | (((u16) (a) >> 8) & 0xff))
|
||||
#endif
|
||||
|
||||
#ifndef bswap_32
|
||||
#define bswap_32(a) ((((u32) (a) << 24) & 0xff000000) | \
|
||||
(((u32) (a) << 8) & 0xff0000) | \
|
||||
(((u32) (a) >> 8) & 0xff00) | \
|
||||
(((u32) (a) >> 24) & 0xff))
|
||||
#endif
|
||||
|
||||
#ifndef MSG_DONTWAIT
|
||||
#define MSG_DONTWAIT 0
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
void perror(const char *s);
|
||||
#endif /* _WIN32_WCE */
|
||||
|
||||
#endif /* CONFIG_ANSI_C_EXTRA */
|
||||
|
||||
#ifndef MAC2STR
|
||||
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
|
||||
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
#endif
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(x) (1 << (x))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Definitions for sparse validation
|
||||
* (http://kernel.org/pub/linux/kernel/people/josh/sparse/)
|
||||
*/
|
||||
#ifdef __CHECKER__
|
||||
#define __force __attribute__((force))
|
||||
#define __bitwise __attribute__((bitwise))
|
||||
#else
|
||||
#define __force
|
||||
#define __bitwise
|
||||
#endif
|
||||
|
||||
typedef u16 __bitwise be16;
|
||||
typedef u16 __bitwise le16;
|
||||
typedef u32 __bitwise be32;
|
||||
typedef u32 __bitwise le32;
|
||||
typedef u64 __bitwise be64;
|
||||
typedef u64 __bitwise le64;
|
||||
|
||||
#ifndef __must_check
|
||||
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
|
||||
#define __must_check __attribute__((__warn_unused_result__))
|
||||
#else
|
||||
#define __must_check
|
||||
#endif /* __GNUC__ */
|
||||
#endif /* __must_check */
|
||||
|
||||
int hwaddr_aton(const char *txt, u8 *addr);
|
||||
int hwaddr_aton2(const char *txt, u8 *addr);
|
||||
int hexstr2bin(const char *hex, u8 *buf, size_t len);
|
||||
void inc_byte_array(u8 *counter, size_t len);
|
||||
void wpa_get_ntp_timestamp(u8 *buf);
|
||||
int wpa_snprintf_hex(char *buf, size_t buf_size, const u8 *data, size_t len);
|
||||
int wpa_snprintf_hex_uppercase(char *buf, size_t buf_size, const u8 *data,
|
||||
size_t len);
|
||||
|
||||
#ifdef CONFIG_NATIVE_WINDOWS
|
||||
void wpa_unicode2ascii_inplace(TCHAR *str);
|
||||
TCHAR * wpa_strdup_tchar(const char *str);
|
||||
#else /* CONFIG_NATIVE_WINDOWS */
|
||||
#define wpa_unicode2ascii_inplace(s) do { } while (0)
|
||||
#define wpa_strdup_tchar(s) strdup((s))
|
||||
#endif /* CONFIG_NATIVE_WINDOWS */
|
||||
|
||||
const char * wpa_ssid_txt(const u8 *ssid, size_t ssid_len);
|
||||
char * wpa_config_parse_string(const char *value, size_t *len);
|
||||
|
||||
static inline int is_zero_ether_addr(const u8 *a)
|
||||
{
|
||||
return !(a[0] | a[1] | a[2] | a[3] | a[4] | a[5]);
|
||||
}
|
||||
|
||||
extern const struct eth_addr ethbroadcast;
|
||||
#define broadcast_ether_addr ðbroadcast
|
||||
|
||||
#include "wpabuf.h"
|
||||
#include "wpa_debug.h"
|
||||
|
||||
|
||||
/*
|
||||
* gcc 4.4 ends up generating strict-aliasing warnings about some very common
|
||||
* networking socket uses that do not really result in a real problem and
|
||||
* cannot be easily avoided with union-based type-punning due to struct
|
||||
* definitions including another struct in system header files. To avoid having
|
||||
* to fully disable strict-aliasing warnings, provide a mechanism to hide the
|
||||
* typecast from aliasing for now. A cleaner solution will hopefully be found
|
||||
* in the future to handle these cases.
|
||||
*/
|
||||
void * __hide_aliasing_typecast(void *foo);
|
||||
#define aliasing_hide_typecast(a,t) (t *) __hide_aliasing_typecast((a))
|
||||
|
||||
#endif /* COMMON_H */
|
307
tools/sdk/include/wpa_supplicant/wpa/defs.h
Normal file
307
tools/sdk/include/wpa_supplicant/wpa/defs.h
Normal file
@ -0,0 +1,307 @@
|
||||
/*
|
||||
* WPA Supplicant - Common definitions
|
||||
* Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef DEFS_H
|
||||
#define DEFS_H
|
||||
|
||||
#ifdef FALSE
|
||||
#undef FALSE
|
||||
#endif
|
||||
#ifdef TRUE
|
||||
#undef TRUE
|
||||
#endif
|
||||
typedef enum { FALSE = 0, TRUE = 1 } Boolean;
|
||||
|
||||
/*
|
||||
#define WPA_CIPHER_NONE BIT(0)
|
||||
#define WPA_CIPHER_WEP40 BIT(1)
|
||||
#define WPA_CIPHER_WEP104 BIT(2)
|
||||
#define WPA_CIPHER_TKIP BIT(3)
|
||||
#define WPA_CIPHER_CCMP BIT(4)
|
||||
#ifdef CONFIG_IEEE80211W
|
||||
#define WPA_CIPHER_AES_128_CMAC BIT(5)
|
||||
#endif
|
||||
*/
|
||||
|
||||
/*
|
||||
* NB: these values are ordered carefully; there are lots of
|
||||
* of implications in any reordering. Beware that 4 is used
|
||||
* only to indicate h/w TKIP MIC support in driver capabilities;
|
||||
* there is no separate cipher support (it's rolled into the
|
||||
* TKIP cipher support).
|
||||
*/
|
||||
#define IEEE80211_CIPHER_NONE 0 /* pseudo value */
|
||||
#define IEEE80211_CIPHER_TKIP 1
|
||||
#define IEEE80211_CIPHER_AES_OCB 2
|
||||
#define IEEE80211_CIPHER_AES_CCM 3
|
||||
#define IEEE80211_CIPHER_TKIPMIC 4 /* TKIP MIC capability */
|
||||
#define IEEE80211_CIPHER_CKIP 5
|
||||
#define IEEE80211_CIPHER_WEP 6
|
||||
#define IEEE80211_CIPHER_WEP40 7
|
||||
#define IEEE80211_CIPHER_WEP104 8
|
||||
|
||||
|
||||
#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE+2)
|
||||
|
||||
/* capability bits in ic_cryptocaps/iv_cryptocaps */
|
||||
#define IEEE80211_CRYPTO_NONE (1<<IEEE80211_CIPHER_NONE)
|
||||
#define IEEE80211_CRYPTO_WEP (1<<IEEE80211_CIPHER_WEP)
|
||||
#define IEEE80211_CRYPTO_WEP40 (1<<IEEE80211_CIPHER_WEP40)
|
||||
#define IEEE80211_CRYPTO_WEP104 (1<<IEEE80211_CIPHER_WEP104)
|
||||
#define IEEE80211_CRYPTO_TKIP (1<<IEEE80211_CIPHER_TKIP)
|
||||
#define IEEE80211_CRYPTO_AES_OCB (1<<IEEE80211_CIPHER_AES_OCB)
|
||||
#define IEEE80211_CRYPTO_AES_CCM (1<<IEEE80211_CIPHER_AES_CCM)
|
||||
#define IEEE80211_CRYPTO_TKIPMIC (1<<IEEE80211_CIPHER_TKIPMIC)
|
||||
#define IEEE80211_CRYPTO_CKIP (1<<IEEE80211_CIPHER_CKIP)
|
||||
|
||||
#define WPA_CIPHER_NONE IEEE80211_CRYPTO_NONE
|
||||
#define WPA_CIPHER_WEP40 IEEE80211_CRYPTO_WEP40
|
||||
#define WPA_CIPHER_WEP104 IEEE80211_CRYPTO_WEP104
|
||||
#define WPA_CIPHER_TKIP IEEE80211_CRYPTO_TKIP
|
||||
#define WPA_CIPHER_CCMP IEEE80211_CRYPTO_AES_CCM
|
||||
#ifdef CONFIG_IEEE80211W
|
||||
#define WPA_CIPHER_AES_128_CMAC IEEE80211_CRYPTO_AES_OCB
|
||||
#endif /* CONFIG_IEEE80211W */
|
||||
#define WPA_CIPHER_GCMP BIT(6)
|
||||
|
||||
#define WPA_KEY_MGMT_IEEE8021X BIT(0)
|
||||
#define WPA_KEY_MGMT_PSK BIT(1)
|
||||
#define WPA_KEY_MGMT_NONE BIT(2)
|
||||
#define WPA_KEY_MGMT_IEEE8021X_NO_WPA BIT(3)
|
||||
#define WPA_KEY_MGMT_WPA_NONE BIT(4)
|
||||
#define WPA_KEY_MGMT_FT_IEEE8021X BIT(5)
|
||||
#define WPA_KEY_MGMT_FT_PSK BIT(6)
|
||||
#define WPA_KEY_MGMT_IEEE8021X_SHA256 BIT(7)
|
||||
#define WPA_KEY_MGMT_PSK_SHA256 BIT(8)
|
||||
#define WPA_KEY_MGMT_WPS BIT(9)
|
||||
#define WPA_KEY_MGMT_CCKM BIT(14)
|
||||
|
||||
static inline int wpa_key_mgmt_wpa_ieee8021x(int akm)
|
||||
{
|
||||
return !!(akm & (WPA_KEY_MGMT_IEEE8021X |
|
||||
WPA_KEY_MGMT_FT_IEEE8021X |
|
||||
WPA_KEY_MGMT_CCKM |
|
||||
WPA_KEY_MGMT_IEEE8021X_SHA256));
|
||||
}
|
||||
|
||||
static inline int wpa_key_mgmt_wpa_psk(int akm)
|
||||
{
|
||||
return akm == WPA_KEY_MGMT_PSK ||
|
||||
akm == WPA_KEY_MGMT_FT_PSK ||
|
||||
akm == WPA_KEY_MGMT_PSK_SHA256;
|
||||
}
|
||||
|
||||
static inline int wpa_key_mgmt_ft(int akm)
|
||||
{
|
||||
return akm == WPA_KEY_MGMT_FT_PSK ||
|
||||
akm == WPA_KEY_MGMT_FT_IEEE8021X;
|
||||
}
|
||||
|
||||
static inline int wpa_key_mgmt_sha256(int akm)
|
||||
{
|
||||
return akm == WPA_KEY_MGMT_PSK_SHA256 ||
|
||||
akm == WPA_KEY_MGMT_IEEE8021X_SHA256;
|
||||
}
|
||||
|
||||
|
||||
#define WPA_PROTO_WPA BIT(0)
|
||||
#define WPA_PROTO_RSN BIT(1)
|
||||
|
||||
#define WPA_AUTH_ALG_OPEN BIT(0)
|
||||
#define WPA_AUTH_ALG_SHARED BIT(1)
|
||||
#define WPA_AUTH_ALG_LEAP BIT(2)
|
||||
#define WPA_AUTH_ALG_FT BIT(3)
|
||||
|
||||
|
||||
enum ieee80211_key_alg {
|
||||
ALG_WEP,
|
||||
ALG_TKIP,
|
||||
ALG_CCMP,
|
||||
ALG_AES_CMAC,
|
||||
};
|
||||
|
||||
enum wpa_alg {
|
||||
WPA_ALG_NONE =0,
|
||||
WPA_ALG_WEP40 = 1,
|
||||
WPA_ALG_TKIP = 2,
|
||||
WPA_ALG_CCMP = 3,
|
||||
WPA_ALG_WAPI = 4,
|
||||
WPA_ALG_WEP104 = 5,
|
||||
WPA_ALG_WEP,
|
||||
WPA_ALG_IGTK,
|
||||
WPA_ALG_PMK,
|
||||
WPA_ALG_GCMP
|
||||
};
|
||||
|
||||
/**
|
||||
* enum wpa_cipher - Cipher suites
|
||||
*/
|
||||
enum wpa_cipher {
|
||||
CIPHER_NONE,
|
||||
CIPHER_WEP40,
|
||||
CIPHER_TKIP,
|
||||
CIPHER_CCMP,
|
||||
CIPHER_WEP104
|
||||
};
|
||||
|
||||
/**
|
||||
* enum wpa_key_mgmt - Key management suites
|
||||
*/
|
||||
enum wpa_key_mgmt {
|
||||
KEY_MGMT_802_1X,
|
||||
KEY_MGMT_PSK,
|
||||
KEY_MGMT_NONE,
|
||||
KEY_MGMT_802_1X_NO_WPA,
|
||||
KEY_MGMT_WPA_NONE,
|
||||
KEY_MGMT_FT_802_1X,
|
||||
KEY_MGMT_FT_PSK,
|
||||
KEY_MGMT_802_1X_SHA256,
|
||||
KEY_MGMT_PSK_SHA256,
|
||||
KEY_MGMT_WPS
|
||||
};
|
||||
|
||||
/**
|
||||
* enum wpa_states - wpa_supplicant state
|
||||
*
|
||||
* These enumeration values are used to indicate the current wpa_supplicant
|
||||
* state (wpa_s->wpa_state). The current state can be retrieved with
|
||||
* wpa_supplicant_get_state() function and the state can be changed by calling
|
||||
* wpa_supplicant_set_state(). In WPA state machine (wpa.c and preauth.c), the
|
||||
* wrapper functions wpa_sm_get_state() and wpa_sm_set_state() should be used
|
||||
* to access the state variable.
|
||||
*/
|
||||
enum wpa_states {
|
||||
/**
|
||||
* WPA_DISCONNECTED - Disconnected state
|
||||
*
|
||||
* This state indicates that client is not associated, but is likely to
|
||||
* start looking for an access point. This state is entered when a
|
||||
* connection is lost.
|
||||
*/
|
||||
WPA_DISCONNECTED,
|
||||
|
||||
/**
|
||||
* WPA_INACTIVE - Inactive state (wpa_supplicant disabled)
|
||||
*
|
||||
* This state is entered if there are no enabled networks in the
|
||||
* configuration. wpa_supplicant is not trying to associate with a new
|
||||
* network and external interaction (e.g., ctrl_iface call to add or
|
||||
* enable a network) is needed to start association.
|
||||
*/
|
||||
WPA_INACTIVE,
|
||||
|
||||
/**
|
||||
* WPA_SCANNING - Scanning for a network
|
||||
*
|
||||
* This state is entered when wpa_supplicant starts scanning for a
|
||||
* network.
|
||||
*/
|
||||
WPA_SCANNING,
|
||||
|
||||
/**
|
||||
* WPA_AUTHENTICATING - Trying to authenticate with a BSS/SSID
|
||||
*
|
||||
* This state is entered when wpa_supplicant has found a suitable BSS
|
||||
* to authenticate with and the driver is configured to try to
|
||||
* authenticate with this BSS. This state is used only with drivers
|
||||
* that use wpa_supplicant as the SME.
|
||||
*/
|
||||
WPA_AUTHENTICATING,
|
||||
|
||||
/**
|
||||
* WPA_ASSOCIATING - Trying to associate with a BSS/SSID
|
||||
*
|
||||
* This state is entered when wpa_supplicant has found a suitable BSS
|
||||
* to associate with and the driver is configured to try to associate
|
||||
* with this BSS in ap_scan=1 mode. When using ap_scan=2 mode, this
|
||||
* state is entered when the driver is configured to try to associate
|
||||
* with a network using the configured SSID and security policy.
|
||||
*/
|
||||
WPA_ASSOCIATING,
|
||||
|
||||
/**
|
||||
* WPA_ASSOCIATED - Association completed
|
||||
*
|
||||
* This state is entered when the driver reports that association has
|
||||
* been successfully completed with an AP. If IEEE 802.1X is used
|
||||
* (with or without WPA/WPA2), wpa_supplicant remains in this state
|
||||
* until the IEEE 802.1X/EAPOL authentication has been completed.
|
||||
*/
|
||||
WPA_ASSOCIATED,
|
||||
|
||||
/**
|
||||
* WPA_4WAY_HANDSHAKE - WPA 4-Way Key Handshake in progress
|
||||
*
|
||||
* This state is entered when WPA/WPA2 4-Way Handshake is started. In
|
||||
* case of WPA-PSK, this happens when receiving the first EAPOL-Key
|
||||
* frame after association. In case of WPA-EAP, this state is entered
|
||||
* when the IEEE 802.1X/EAPOL authentication has been completed.
|
||||
*/
|
||||
WPA_FIRST_HALF_4WAY_HANDSHAKE,
|
||||
|
||||
WPA_LAST_HALF_4WAY_HANDSHAKE,
|
||||
|
||||
/**
|
||||
* WPA_GROUP_HANDSHAKE - WPA Group Key Handshake in progress
|
||||
*
|
||||
* This state is entered when 4-Way Key Handshake has been completed
|
||||
* (i.e., when the supplicant sends out message 4/4) and when Group
|
||||
* Key rekeying is started by the AP (i.e., when supplicant receives
|
||||
* message 1/2).
|
||||
*/
|
||||
WPA_GROUP_HANDSHAKE,
|
||||
|
||||
/**
|
||||
* WPA_COMPLETED - All authentication completed
|
||||
*
|
||||
* This state is entered when the full authentication process is
|
||||
* completed. In case of WPA2, this happens when the 4-Way Handshake is
|
||||
* successfully completed. With WPA, this state is entered after the
|
||||
* Group Key Handshake; with IEEE 802.1X (non-WPA) connection is
|
||||
* completed after dynamic keys are received (or if not used, after
|
||||
* the EAP authentication has been completed). With static WEP keys and
|
||||
* plaintext connections, this state is entered when an association
|
||||
* has been completed.
|
||||
*
|
||||
* This state indicates that the supplicant has completed its
|
||||
* processing for the association phase and that data connection is
|
||||
* fully configured.
|
||||
*/
|
||||
WPA_COMPLETED,
|
||||
|
||||
WPA_MIC_FAILURE, // first mic_error event occur
|
||||
|
||||
WPA_TKIP_COUNTERMEASURES //in countermeasure period that stop connect with ap in 60 sec
|
||||
};
|
||||
|
||||
#define MLME_SETPROTECTION_PROTECT_TYPE_NONE 0
|
||||
#define MLME_SETPROTECTION_PROTECT_TYPE_RX 1
|
||||
#define MLME_SETPROTECTION_PROTECT_TYPE_TX 2
|
||||
#define MLME_SETPROTECTION_PROTECT_TYPE_RX_TX 3
|
||||
|
||||
#define MLME_SETPROTECTION_KEY_TYPE_GROUP 0
|
||||
#define MLME_SETPROTECTION_KEY_TYPE_PAIRWISE 1
|
||||
|
||||
/**
|
||||
* enum hostapd_hw_mode - Hardware mode
|
||||
*/
|
||||
enum hostapd_hw_mode {
|
||||
HOSTAPD_MODE_IEEE80211B,
|
||||
HOSTAPD_MODE_IEEE80211G,
|
||||
HOSTAPD_MODE_IEEE80211A,
|
||||
HOSTAPD_MODE_IEEE80211AD,
|
||||
NUM_HOSTAPD_MODES
|
||||
};
|
||||
|
||||
#endif /* DEFS_H */
|
71
tools/sdk/include/wpa_supplicant/wpa/eapol_common.h
Normal file
71
tools/sdk/include/wpa_supplicant/wpa/eapol_common.h
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* EAPOL definitions shared between hostapd and wpa_supplicant
|
||||
* Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAPOL_COMMON_H
|
||||
#define EAPOL_COMMON_H
|
||||
|
||||
/* IEEE Std 802.1X-2004 */
|
||||
|
||||
struct ieee802_1x_hdr {
|
||||
u8 version;
|
||||
u8 type;
|
||||
be16 length;
|
||||
/* followed by length octets of data */
|
||||
} STRUCT_PACKED;
|
||||
|
||||
|
||||
#define EAPOL_VERSION 2
|
||||
|
||||
enum { IEEE802_1X_TYPE_EAP_PACKET = 0,
|
||||
IEEE802_1X_TYPE_EAPOL_START = 1,
|
||||
IEEE802_1X_TYPE_EAPOL_LOGOFF = 2,
|
||||
IEEE802_1X_TYPE_EAPOL_KEY = 3,
|
||||
IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4
|
||||
};
|
||||
|
||||
enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2,
|
||||
EAPOL_KEY_TYPE_WPA = 254 };
|
||||
|
||||
#define IEEE8021X_REPLAY_COUNTER_LEN 8
|
||||
#define IEEE8021X_KEY_SIGN_LEN 16
|
||||
#define IEEE8021X_KEY_IV_LEN 16
|
||||
|
||||
#define IEEE8021X_KEY_INDEX_FLAG 0x80
|
||||
#define IEEE8021X_KEY_INDEX_MASK 0x03
|
||||
|
||||
struct ieee802_1x_eapol_key {
|
||||
u8 type;
|
||||
/* Note: key_length is unaligned */
|
||||
u8 key_length[2];
|
||||
/* does not repeat within the life of the keying material used to
|
||||
* encrypt the Key field; 64-bit NTP timestamp MAY be used here */
|
||||
u8 replay_counter[IEEE8021X_REPLAY_COUNTER_LEN];
|
||||
u8 key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */
|
||||
u8 key_index; /* key flag in the most significant bit:
|
||||
* 0 = broadcast (default key),
|
||||
* 1 = unicast (key mapping key); key index is in the
|
||||
* 7 least significant bits */
|
||||
/* HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as
|
||||
* the key */
|
||||
u8 key_signature[IEEE8021X_KEY_SIGN_LEN];
|
||||
|
||||
/* followed by key: if packet body length = 44 + key length, then the
|
||||
* key field (of key_length bytes) contains the key in encrypted form;
|
||||
* if packet body length = 44, key field is absent and key_length
|
||||
* represents the number of least significant octets from
|
||||
* MS-MPPE-Send-Key attribute to be used as the keying material;
|
||||
* RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */
|
||||
} STRUCT_PACKED;
|
||||
|
||||
#endif /* EAPOL_COMMON_H */
|
312
tools/sdk/include/wpa_supplicant/wpa/hostapd.h
Normal file
312
tools/sdk/include/wpa_supplicant/wpa/hostapd.h
Normal file
@ -0,0 +1,312 @@
|
||||
/*
|
||||
* hostapd / Initialization and configuration
|
||||
* Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef HOSTAPD_H
|
||||
#define HOSTAPD_H
|
||||
|
||||
#include "wpa/defs.h"
|
||||
#include "wpa/ap_config.h"
|
||||
|
||||
struct wpa_driver_ops;
|
||||
struct wpa_ctrl_dst;
|
||||
struct radius_server_data;
|
||||
struct upnp_wps_device_sm;
|
||||
struct hostapd_data;
|
||||
struct sta_info;
|
||||
struct hostap_sta_driver_data;
|
||||
struct ieee80211_ht_capabilities;
|
||||
struct full_dynamic_vlan;
|
||||
enum wps_event;
|
||||
union wps_event_data;
|
||||
|
||||
struct hostapd_iface;
|
||||
|
||||
struct hapd_interfaces {
|
||||
int (*reload_config)(struct hostapd_iface *iface);
|
||||
struct hostapd_config * (*config_read_cb)(const char *config_fname);
|
||||
int (*ctrl_iface_init)(struct hostapd_data *hapd);
|
||||
void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
|
||||
int (*for_each_interface)(struct hapd_interfaces *interfaces,
|
||||
int (*cb)(struct hostapd_iface *iface,
|
||||
void *ctx), void *ctx);
|
||||
int (*driver_init)(struct hostapd_iface *iface);
|
||||
|
||||
size_t count;
|
||||
int global_ctrl_sock;
|
||||
char *global_iface_path;
|
||||
char *global_iface_name;
|
||||
struct hostapd_iface **iface;
|
||||
};
|
||||
|
||||
|
||||
struct hostapd_probereq_cb {
|
||||
int (*cb)(void *ctx, const u8 *sa, const u8 *da, const u8 *bssid,
|
||||
const u8 *ie, size_t ie_len, int ssi_signal);
|
||||
void *ctx;
|
||||
};
|
||||
|
||||
#define HOSTAPD_RATE_BASIC 0x00000001
|
||||
|
||||
struct hostapd_rate_data {
|
||||
int rate; /* rate in 100 kbps */
|
||||
int flags; /* HOSTAPD_RATE_ flags */
|
||||
};
|
||||
|
||||
struct hostapd_frame_info {
|
||||
u32 channel;
|
||||
u32 datarate;
|
||||
int ssi_signal; /* dBm */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* struct hostapd_data - hostapd per-BSS data structure
|
||||
*/
|
||||
struct hostapd_data {
|
||||
// struct hostapd_iface *iface;
|
||||
struct hostapd_config *iconf;
|
||||
struct hostapd_bss_config *conf;
|
||||
int interface_added; /* virtual interface added for this BSS */
|
||||
|
||||
u8 own_addr[ETH_ALEN];
|
||||
|
||||
int num_sta; /* number of entries in sta_list */
|
||||
// struct sta_info *sta_list; /* STA info list head */
|
||||
//#define STA_HASH_SIZE 256
|
||||
//#define STA_HASH(sta) (sta[5])
|
||||
// struct sta_info *sta_hash[STA_HASH_SIZE];
|
||||
|
||||
// /*
|
||||
// * Bitfield for indicating which AIDs are allocated. Only AID values
|
||||
// * 1-2007 are used and as such, the bit at index 0 corresponds to AID
|
||||
// * 1.
|
||||
// */
|
||||
//#define AID_WORDS ((2008 + 31) / 32)
|
||||
// u32 sta_aid[AID_WORDS];
|
||||
|
||||
// const struct wpa_driver_ops *driver;
|
||||
// void *drv_priv;
|
||||
|
||||
// void (*new_assoc_sta_cb)(struct hostapd_data *hapd,
|
||||
// struct sta_info *sta, int reassoc);
|
||||
|
||||
// void *msg_ctx; /* ctx for wpa_msg() calls */
|
||||
// void *msg_ctx_parent; /* parent interface ctx for wpa_msg() calls */
|
||||
|
||||
// struct radius_client_data *radius;
|
||||
// u32 acct_session_id_hi, acct_session_id_lo;
|
||||
// struct radius_das_data *radius_das;
|
||||
|
||||
// struct iapp_data *iapp;
|
||||
|
||||
// struct hostapd_cached_radius_acl *acl_cache;
|
||||
// struct hostapd_acl_query_data *acl_queries;
|
||||
|
||||
struct wpa_authenticator *wpa_auth;
|
||||
// struct eapol_authenticator *eapol_auth;
|
||||
|
||||
// struct rsn_preauth_interface *preauth_iface;
|
||||
// time_t michael_mic_failure;
|
||||
// int michael_mic_failures;
|
||||
// int tkip_countermeasures;
|
||||
|
||||
// int ctrl_sock;
|
||||
// struct wpa_ctrl_dst *ctrl_dst;
|
||||
|
||||
// void *ssl_ctx;
|
||||
// void *eap_sim_db_priv;
|
||||
// struct radius_server_data *radius_srv;
|
||||
|
||||
// int parameter_set_count;
|
||||
|
||||
/* Time Advertisement */
|
||||
// u8 time_update_counter;
|
||||
// struct wpabuf *time_adv;
|
||||
|
||||
#ifdef CONFIG_FULL_DYNAMIC_VLAN
|
||||
struct full_dynamic_vlan *full_dynamic_vlan;
|
||||
#endif /* CONFIG_FULL_DYNAMIC_VLAN */
|
||||
|
||||
// struct l2_packet_data *l2;
|
||||
// struct wps_context *wps;
|
||||
|
||||
// int beacon_set_done;
|
||||
// struct wpabuf *wps_beacon_ie;
|
||||
// struct wpabuf *wps_probe_resp_ie;
|
||||
#ifdef CONFIG_WPS
|
||||
unsigned int ap_pin_failures;
|
||||
unsigned int ap_pin_failures_consecutive;
|
||||
struct upnp_wps_device_sm *wps_upnp;
|
||||
unsigned int ap_pin_lockout_time;
|
||||
#endif /* CONFIG_WPS */
|
||||
|
||||
// struct hostapd_probereq_cb *probereq_cb;
|
||||
// size_t num_probereq_cb;
|
||||
|
||||
// void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
|
||||
// int freq);
|
||||
// void *public_action_cb_ctx;
|
||||
|
||||
// int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len,
|
||||
// int freq);
|
||||
// void *vendor_action_cb_ctx;
|
||||
|
||||
// void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr,
|
||||
// const u8 *uuid_e);
|
||||
// void *wps_reg_success_cb_ctx;
|
||||
|
||||
// void (*wps_event_cb)(void *ctx, enum wps_event event,
|
||||
// union wps_event_data *data);
|
||||
// void *wps_event_cb_ctx;
|
||||
|
||||
// void (*sta_authorized_cb)(void *ctx, const u8 *mac_addr,
|
||||
// int authorized, const u8 *p2p_dev_addr);
|
||||
// void *sta_authorized_cb_ctx;
|
||||
|
||||
// void (*setup_complete_cb)(void *ctx);
|
||||
// void *setup_complete_cb_ctx;
|
||||
|
||||
#ifdef CONFIG_P2P
|
||||
struct p2p_data *p2p;
|
||||
struct p2p_group *p2p_group;
|
||||
struct wpabuf *p2p_beacon_ie;
|
||||
struct wpabuf *p2p_probe_resp_ie;
|
||||
|
||||
/* Number of non-P2P association stations */
|
||||
int num_sta_no_p2p;
|
||||
|
||||
/* Periodic NoA (used only when no non-P2P clients in the group) */
|
||||
int noa_enabled;
|
||||
int noa_start;
|
||||
int noa_duration;
|
||||
#endif /* CONFIG_P2P */
|
||||
#ifdef CONFIG_INTERWORKING
|
||||
size_t gas_frag_limit;
|
||||
#endif /* CONFIG_INTERWORKING */
|
||||
|
||||
#ifdef CONFIG_SQLITE
|
||||
struct hostapd_eap_user tmp_eap_user;
|
||||
#endif /* CONFIG_SQLITE */
|
||||
};
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* struct hostapd_iface - hostapd per-interface data structure
|
||||
*/
|
||||
struct hostapd_iface {
|
||||
struct hapd_interfaces *interfaces;
|
||||
void *owner;
|
||||
char *config_fname;
|
||||
struct hostapd_config *conf;
|
||||
|
||||
size_t num_bss;
|
||||
struct hostapd_data **bss;
|
||||
|
||||
int num_ap; /* number of entries in ap_list */
|
||||
struct ap_info *ap_list; /* AP info list head */
|
||||
struct ap_info *ap_hash[STA_HASH_SIZE];
|
||||
struct ap_info *ap_iter_list;
|
||||
|
||||
unsigned int drv_flags;
|
||||
|
||||
/*
|
||||
* A bitmap of supported protocols for probe response offload. See
|
||||
* struct wpa_driver_capa in driver.h
|
||||
*/
|
||||
unsigned int probe_resp_offloads;
|
||||
|
||||
struct hostapd_hw_modes *hw_features;
|
||||
int num_hw_features;
|
||||
struct hostapd_hw_modes *current_mode;
|
||||
/* Rates that are currently used (i.e., filtered copy of
|
||||
* current_mode->channels */
|
||||
int num_rates;
|
||||
struct hostapd_rate_data *current_rates;
|
||||
int *basic_rates;
|
||||
int freq;
|
||||
|
||||
u16 hw_flags;
|
||||
|
||||
/* Number of associated Non-ERP stations (i.e., stations using 802.11b
|
||||
* in 802.11g BSS) */
|
||||
int num_sta_non_erp;
|
||||
|
||||
/* Number of associated stations that do not support Short Slot Time */
|
||||
int num_sta_no_short_slot_time;
|
||||
|
||||
/* Number of associated stations that do not support Short Preamble */
|
||||
int num_sta_no_short_preamble;
|
||||
|
||||
int olbc; /* Overlapping Legacy BSS Condition */
|
||||
|
||||
/* Number of HT associated stations that do not support greenfield */
|
||||
int num_sta_ht_no_gf;
|
||||
|
||||
/* Number of associated non-HT stations */
|
||||
int num_sta_no_ht;
|
||||
|
||||
/* Number of HT associated stations 20 MHz */
|
||||
int num_sta_ht_20mhz;
|
||||
|
||||
/* Overlapping BSS information */
|
||||
int olbc_ht;
|
||||
|
||||
u16 ht_op_mode;
|
||||
void (*scan_cb)(struct hostapd_iface *iface);
|
||||
};
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* hostapd.c */
|
||||
int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
|
||||
int (*cb)(struct hostapd_iface *iface,
|
||||
void *ctx), void *ctx);
|
||||
int hostapd_reload_config(struct hostapd_iface *iface);
|
||||
struct hostapd_data *
|
||||
hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
|
||||
struct hostapd_config *conf,
|
||||
struct hostapd_bss_config *bss);
|
||||
int hostapd_setup_interface(struct hostapd_iface *iface);
|
||||
int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
|
||||
void hostapd_interface_deinit(struct hostapd_iface *iface);
|
||||
void hostapd_interface_free(struct hostapd_iface *iface);
|
||||
void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
int reassoc);
|
||||
void hostapd_interface_deinit_free(struct hostapd_iface *iface);
|
||||
int hostapd_enable_iface(struct hostapd_iface *hapd_iface);
|
||||
int hostapd_reload_iface(struct hostapd_iface *hapd_iface);
|
||||
int hostapd_disable_iface(struct hostapd_iface *hapd_iface);
|
||||
int hostapd_add_iface(struct hapd_interfaces *ifaces, char *buf);
|
||||
int hostapd_remove_iface(struct hapd_interfaces *ifaces, char *buf);
|
||||
|
||||
/* utils.c */
|
||||
int hostapd_register_probereq_cb(struct hostapd_data *hapd,
|
||||
int (*cb)(void *ctx, const u8 *sa,
|
||||
const u8 *da, const u8 *bssid,
|
||||
const u8 *ie, size_t ie_len,
|
||||
int ssi_signal),
|
||||
void *ctx);
|
||||
void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
|
||||
|
||||
/* drv_callbacks.c (TODO: move to somewhere else?) */
|
||||
int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
|
||||
const u8 *ie, size_t ielen, int reassoc);
|
||||
void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
|
||||
void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr);
|
||||
int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da,
|
||||
const u8 *bssid, const u8 *ie, size_t ie_len,
|
||||
int ssi_signal);
|
||||
void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht,
|
||||
int offset);
|
||||
|
||||
const struct hostapd_eap_user *
|
||||
hostapd_get_eap_user(struct hostapd_data *hapd, const u8 *identity,
|
||||
size_t identity_len, int phase2);
|
||||
#endif
|
||||
|
||||
#endif /* HOSTAPD_H */
|
226
tools/sdk/include/wpa_supplicant/wpa/ieee80211_crypto.h
Normal file
226
tools/sdk/include/wpa_supplicant/wpa/ieee80211_crypto.h
Normal file
@ -0,0 +1,226 @@
|
||||
/*-
|
||||
* Copyright (c) 2001 Atsushi Onoe
|
||||
* Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* copyright (c) 2010-2011 Espressif System
|
||||
*/
|
||||
#ifndef _NET80211_IEEE80211_CRYPTO_H_
|
||||
#define _NET80211_IEEE80211_CRYPTO_H_
|
||||
|
||||
//#include "pp/esf_buf.h"
|
||||
|
||||
/*
|
||||
* 802.11 protocol crypto-related definitions.
|
||||
*/
|
||||
#define IEEE80211_KEYBUF_SIZE 16
|
||||
#define IEEE80211_MICBUF_SIZE (8+8) /* space for both tx+rx keys */
|
||||
|
||||
/*
|
||||
* Old WEP-style key. Deprecated.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
struct ieee80211_rsnparms {
|
||||
uint8_t rsn_mcastcipher; /* mcast/group cipher */
|
||||
uint8_t rsn_mcastkeylen; /* mcast key length */
|
||||
uint8_t rsn_ucastcipher; /* selected unicast cipher */
|
||||
uint8_t rsn_ucastkeylen; /* unicast key length */
|
||||
uint8_t rsn_keymgmt; /* selected key mgmt algo */
|
||||
uint16_t rsn_caps; /* capabilities */
|
||||
};
|
||||
#endif //0000
|
||||
|
||||
/*
|
||||
* Template for a supported cipher. Ciphers register with the
|
||||
* crypto code and are typically loaded as separate modules
|
||||
* (the null cipher is always present).
|
||||
* XXX may need refcnts
|
||||
*/
|
||||
|
||||
/*
|
||||
* Crypto key state. There is sufficient room for all supported
|
||||
* ciphers (see below). The underlying ciphers are handled
|
||||
* separately through loadable cipher modules that register with
|
||||
* the generic crypto support. A key has a reference to an instance
|
||||
* of the cipher; any per-key state is hung off wk_private by the
|
||||
* cipher when it is attached. Ciphers are automatically called
|
||||
* to detach and cleanup any such state when the key is deleted.
|
||||
*
|
||||
* The generic crypto support handles encap/decap of cipher-related
|
||||
* frame contents for both hardware- and software-based implementations.
|
||||
* A key requiring software crypto support is automatically flagged and
|
||||
* the cipher is expected to honor this and do the necessary work.
|
||||
* Ciphers such as TKIP may also support mixed hardware/software
|
||||
* encrypt/decrypt and MIC processing.
|
||||
*/
|
||||
typedef uint16_t ieee80211_keyix; /* h/w key index */
|
||||
|
||||
struct ieee80211_key {
|
||||
uint8_t wk_keylen; /* key length in bytes */
|
||||
uint8_t wk_pad;
|
||||
uint16_t wk_flags;
|
||||
#define IEEE80211_KEY_XMIT 0x0001 /* key used for xmit */
|
||||
#define IEEE80211_KEY_RECV 0x0002 /* key used for recv */
|
||||
#define IEEE80211_KEY_GROUP 0x0004 /* key used for WPA group operation */
|
||||
#define IEEE80211_KEY_SWENCRYPT 0x0010 /* host-based encrypt */
|
||||
#define IEEE80211_KEY_SWDECRYPT 0x0020 /* host-based decrypt */
|
||||
#define IEEE80211_KEY_SWENMIC 0x0040 /* host-based enmic */
|
||||
#define IEEE80211_KEY_SWDEMIC 0x0080 /* host-based demic */
|
||||
#define IEEE80211_KEY_DEVKEY 0x0100 /* device key request completed */
|
||||
#define IEEE80211_KEY_CIPHER0 0x1000 /* cipher-specific action 0 */
|
||||
#define IEEE80211_KEY_CIPHER1 0x2000 /* cipher-specific action 1 */
|
||||
#define IEEE80211_KEY_EMPTY 0x0000
|
||||
ieee80211_keyix wk_keyix; /* h/w key index */
|
||||
ieee80211_keyix wk_rxkeyix; /* optional h/w rx key index */
|
||||
uint8_t wk_key[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE];
|
||||
#define wk_txmic wk_key+IEEE80211_KEYBUF_SIZE+0 /* XXX can't () right */
|
||||
#define wk_rxmic wk_key+IEEE80211_KEYBUF_SIZE+8 /* XXX can't () right */
|
||||
/* key receive sequence counter */
|
||||
uint64_t wk_keyrsc[IEEE80211_TID_SIZE];
|
||||
uint64_t wk_keytsc; /* key transmit sequence counter */
|
||||
const struct ieee80211_cipher *wk_cipher;
|
||||
//void *wk_private; /* private cipher state */
|
||||
//uint8_t wk_macaddr[IEEE80211_ADDR_LEN]; //JLU: no need ...
|
||||
};
|
||||
#define IEEE80211_KEY_COMMON /* common flags passed in by apps */\
|
||||
(IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV | IEEE80211_KEY_GROUP)
|
||||
#define IEEE80211_KEY_DEVICE /* flags owned by device driver */\
|
||||
(IEEE80211_KEY_DEVKEY|IEEE80211_KEY_CIPHER0|IEEE80211_KEY_CIPHER1)
|
||||
|
||||
#define IEEE80211_KEY_SWCRYPT \
|
||||
(IEEE80211_KEY_SWENCRYPT | IEEE80211_KEY_SWDECRYPT)
|
||||
#define IEEE80211_KEY_SWMIC (IEEE80211_KEY_SWENMIC | IEEE80211_KEY_SWDEMIC)
|
||||
|
||||
//#define IEEE80211_KEYIX_NONE ((ieee80211_keyix) -1)
|
||||
|
||||
/*
|
||||
* NB: these values are ordered carefully; there are lots of
|
||||
* of implications in any reordering. Beware that 4 is used
|
||||
* only to indicate h/w TKIP MIC support in driver capabilities;
|
||||
* there is no separate cipher support (it's rolled into the
|
||||
* TKIP cipher support).
|
||||
*/
|
||||
#define IEEE80211_CIPHER_NONE 0 /* pseudo value */
|
||||
#define IEEE80211_CIPHER_TKIP 1
|
||||
#define IEEE80211_CIPHER_AES_OCB 2
|
||||
#define IEEE80211_CIPHER_AES_CCM 3
|
||||
#define IEEE80211_CIPHER_TKIPMIC 4 /* TKIP MIC capability */
|
||||
#define IEEE80211_CIPHER_CKIP 5
|
||||
#define IEEE80211_CIPHER_WEP 6
|
||||
#define IEEE80211_CIPHER_WEP40 7
|
||||
#define IEEE80211_CIPHER_WEP104 8
|
||||
|
||||
|
||||
#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE+2)
|
||||
|
||||
/* capability bits in ic_cryptocaps/iv_cryptocaps */
|
||||
#define IEEE80211_CRYPTO_NONE (1<<IEEE80211_CIPHER_NONE)
|
||||
#define IEEE80211_CRYPTO_WEP (1<<IEEE80211_CIPHER_WEP)
|
||||
#define IEEE80211_CRYPTO_WEP40 (1<<IEEE80211_CIPHER_WEP40)
|
||||
#define IEEE80211_CRYPTO_WEP104 (1<<IEEE80211_CIPHER_WEP104)
|
||||
#define IEEE80211_CRYPTO_TKIP (1<<IEEE80211_CIPHER_TKIP)
|
||||
#define IEEE80211_CRYPTO_AES_OCB (1<<IEEE80211_CIPHER_AES_OCB)
|
||||
#define IEEE80211_CRYPTO_AES_CCM (1<<IEEE80211_CIPHER_AES_CCM)
|
||||
#define IEEE80211_CRYPTO_TKIPMIC (1<<IEEE80211_CIPHER_TKIPMIC)
|
||||
#define IEEE80211_CRYPTO_CKIP (1<<IEEE80211_CIPHER_CKIP)
|
||||
|
||||
struct ieee80211_cipher {
|
||||
u_int ic_cipher; /* IEEE80211_CIPHER_* */
|
||||
u_int ic_header; /* size of privacy header (bytes) */
|
||||
u_int ic_trailer; /* size of privacy trailer (bytes) */
|
||||
u_int ic_miclen; /* size of mic trailer (bytes) */
|
||||
// int (*ic_setkey)(struct ieee80211_key *);
|
||||
int (*ic_encap)(struct ieee80211_key *, esf_buf_t *, uint8_t);
|
||||
int (*ic_decap)(struct ieee80211_key *, esf_buf_t *, int);
|
||||
#ifdef EAGLE_SW_MIC
|
||||
int (*ic_enmic)(struct ieee80211_key *, esf_buf_t *, int);
|
||||
int (*ic_demic)(struct ieee80211_key *, esf_buf_t *, int);
|
||||
#endif /* EAGLE_SW_CRYPTO */
|
||||
};
|
||||
|
||||
struct ieee80211com;
|
||||
struct ieee80211_conn;
|
||||
|
||||
#define IEEE80211_KEY_UNDEFINED(k) \
|
||||
((k)->wk_cipher == &ieee80211_cipher_none)
|
||||
|
||||
struct ieee80211_key *ieee80211_crypto_encap(struct ieee80211_conn *,
|
||||
esf_buf *);
|
||||
|
||||
struct ieee80211_key *ieee80211_crypto_decap(struct ieee80211_conn *,
|
||||
esf_buf *, int);
|
||||
|
||||
#if 0 //H/W MIC
|
||||
/*
|
||||
* Check and remove any MIC.
|
||||
*/
|
||||
static INLINE int
|
||||
ieee80211_crypto_demic(struct ieee80211vap *vap, struct ieee80211_key *k,
|
||||
esf_buf *m, int force)
|
||||
{
|
||||
const struct ieee80211_cipher *cip = k->wk_cipher;
|
||||
return (cip->ic_miclen > 0 ? cip->ic_demic(k, m, force) : 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add any MIC.
|
||||
*/
|
||||
static INLINE int
|
||||
ieee80211_crypto_enmic(struct ieee80211vap *vap,
|
||||
struct ieee80211_key *k, esf_buf *m, int force)
|
||||
{
|
||||
const struct ieee80211_cipher *cip = k->wk_cipher;
|
||||
return (cip->ic_miclen > 0 ? cip->ic_enmic(k, m, force) : 1);
|
||||
}
|
||||
#endif //0000
|
||||
|
||||
/*
|
||||
* Setup crypto support for a device/shared instance.
|
||||
*/
|
||||
void ieee80211_crypto_attach(struct ieee80211com *ic);
|
||||
|
||||
/*
|
||||
* Reset key state to an unused state. The crypto
|
||||
* key allocation mechanism insures other state (e.g.
|
||||
* key data) is properly setup before a key is used.
|
||||
*/
|
||||
static inline void
|
||||
ieee80211_crypto_resetkey(struct ieee80211_key *k)
|
||||
{
|
||||
k->wk_cipher = NULL;
|
||||
k->wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV;
|
||||
}
|
||||
|
||||
/*
|
||||
* Crypt-related notification methods.
|
||||
*/
|
||||
//void ieee80211_notify_replay_failure(const struct ieee80211_frame *, const struct ieee80211_key *,
|
||||
// uint64_t rsc, int tid);
|
||||
//void ieee80211_notify_michael_failure(const struct ieee80211_frame *, u_int keyix);
|
||||
|
||||
#endif /* _NET80211_IEEE80211_CRYPTO_H_ */
|
607
tools/sdk/include/wpa_supplicant/wpa/ieee802_11_defs.h
Normal file
607
tools/sdk/include/wpa_supplicant/wpa/ieee802_11_defs.h
Normal file
@ -0,0 +1,607 @@
|
||||
/*
|
||||
* IEEE 802.11 Frame type definitions
|
||||
* Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
|
||||
* Copyright (c) 2007-2008 Intel Corporation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef IEEE802_11_DEFS_H
|
||||
#define IEEE802_11_DEFS_H
|
||||
|
||||
/* IEEE 802.11 defines */
|
||||
|
||||
#define WLAN_FC_PVER 0x0003
|
||||
#define WLAN_FC_TODS 0x0100
|
||||
#define WLAN_FC_FROMDS 0x0200
|
||||
#define WLAN_FC_MOREFRAG 0x0400
|
||||
#define WLAN_FC_RETRY 0x0800
|
||||
#define WLAN_FC_PWRMGT 0x1000
|
||||
#define WLAN_FC_MOREDATA 0x2000
|
||||
#define WLAN_FC_ISWEP 0x4000
|
||||
#define WLAN_FC_ORDER 0x8000
|
||||
|
||||
#define WLAN_FC_GET_TYPE(fc) (((fc) & 0x000c) >> 2)
|
||||
#define WLAN_FC_GET_STYPE(fc) (((fc) & 0x00f0) >> 4)
|
||||
|
||||
#define WLAN_GET_SEQ_FRAG(seq) ((seq) & (BIT(3) | BIT(2) | BIT(1) | BIT(0)))
|
||||
#define WLAN_GET_SEQ_SEQ(seq) \
|
||||
(((seq) & (~(BIT(3) | BIT(2) | BIT(1) | BIT(0)))) >> 4)
|
||||
|
||||
#define WLAN_FC_TYPE_MGMT 0
|
||||
#define WLAN_FC_TYPE_CTRL 1
|
||||
#define WLAN_FC_TYPE_DATA 2
|
||||
|
||||
/* management */
|
||||
#define WLAN_FC_STYPE_ASSOC_REQ 0
|
||||
#define WLAN_FC_STYPE_ASSOC_RESP 1
|
||||
#define WLAN_FC_STYPE_REASSOC_REQ 2
|
||||
#define WLAN_FC_STYPE_REASSOC_RESP 3
|
||||
#define WLAN_FC_STYPE_PROBE_REQ 4
|
||||
#define WLAN_FC_STYPE_PROBE_RESP 5
|
||||
#define WLAN_FC_STYPE_BEACON 8
|
||||
#define WLAN_FC_STYPE_ATIM 9
|
||||
#define WLAN_FC_STYPE_DISASSOC 10
|
||||
#define WLAN_FC_STYPE_AUTH 11
|
||||
#define WLAN_FC_STYPE_DEAUTH 12
|
||||
#define WLAN_FC_STYPE_ACTION 13
|
||||
|
||||
/* control */
|
||||
#define WLAN_FC_STYPE_PSPOLL 10
|
||||
#define WLAN_FC_STYPE_RTS 11
|
||||
#define WLAN_FC_STYPE_CTS 12
|
||||
#define WLAN_FC_STYPE_ACK 13
|
||||
#define WLAN_FC_STYPE_CFEND 14
|
||||
#define WLAN_FC_STYPE_CFENDACK 15
|
||||
|
||||
/* data */
|
||||
#define WLAN_FC_STYPE_DATA 0
|
||||
#define WLAN_FC_STYPE_DATA_CFACK 1
|
||||
#define WLAN_FC_STYPE_DATA_CFPOLL 2
|
||||
#define WLAN_FC_STYPE_DATA_CFACKPOLL 3
|
||||
#define WLAN_FC_STYPE_NULLFUNC 4
|
||||
#define WLAN_FC_STYPE_CFACK 5
|
||||
#define WLAN_FC_STYPE_CFPOLL 6
|
||||
#define WLAN_FC_STYPE_CFACKPOLL 7
|
||||
#define WLAN_FC_STYPE_QOS_DATA 8
|
||||
|
||||
/* Authentication algorithms */
|
||||
#define WLAN_AUTH_OPEN 0
|
||||
#define WLAN_AUTH_SHARED_KEY 1
|
||||
#define WLAN_AUTH_FT 2
|
||||
#define WLAN_AUTH_LEAP 128
|
||||
|
||||
#define WLAN_AUTH_CHALLENGE_LEN 128
|
||||
|
||||
#define WLAN_CAPABILITY_ESS BIT(0)
|
||||
#define WLAN_CAPABILITY_IBSS BIT(1)
|
||||
#define WLAN_CAPABILITY_CF_POLLABLE BIT(2)
|
||||
#define WLAN_CAPABILITY_CF_POLL_REQUEST BIT(3)
|
||||
#define WLAN_CAPABILITY_PRIVACY BIT(4)
|
||||
#define WLAN_CAPABILITY_SHORT_PREAMBLE BIT(5)
|
||||
#define WLAN_CAPABILITY_PBCC BIT(6)
|
||||
#define WLAN_CAPABILITY_CHANNEL_AGILITY BIT(7)
|
||||
#define WLAN_CAPABILITY_SPECTRUM_MGMT BIT(8)
|
||||
#define WLAN_CAPABILITY_SHORT_SLOT_TIME BIT(10)
|
||||
#define WLAN_CAPABILITY_DSSS_OFDM BIT(13)
|
||||
|
||||
/* Status codes (IEEE 802.11-2007, 7.3.1.9, Table 7-23) */
|
||||
#define WLAN_STATUS_SUCCESS 0
|
||||
#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
|
||||
#define WLAN_STATUS_CAPS_UNSUPPORTED 10
|
||||
#define WLAN_STATUS_REASSOC_NO_ASSOC 11
|
||||
#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
|
||||
#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
|
||||
#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
|
||||
#define WLAN_STATUS_CHALLENGE_FAIL 15
|
||||
#define WLAN_STATUS_AUTH_TIMEOUT 16
|
||||
#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
|
||||
#define WLAN_STATUS_ASSOC_DENIED_RATES 18
|
||||
/* IEEE 802.11b */
|
||||
#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
|
||||
#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
|
||||
#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
|
||||
/* IEEE 802.11h */
|
||||
#define WLAN_STATUS_SPEC_MGMT_REQUIRED 22
|
||||
#define WLAN_STATUS_PWR_CAPABILITY_NOT_VALID 23
|
||||
#define WLAN_STATUS_SUPPORTED_CHANNEL_NOT_VALID 24
|
||||
/* IEEE 802.11g */
|
||||
#define WLAN_STATUS_ASSOC_DENIED_NO_SHORT_SLOT_TIME 25
|
||||
#define WLAN_STATUS_ASSOC_DENIED_NO_ER_PBCC 26
|
||||
#define WLAN_STATUS_ASSOC_DENIED_NO_DSSS_OFDM 27
|
||||
#define WLAN_STATUS_R0KH_UNREACHABLE 28
|
||||
/* IEEE 802.11w */
|
||||
#define WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY 30
|
||||
#define WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION 31
|
||||
#define WLAN_STATUS_UNSPECIFIED_QOS_FAILURE 32
|
||||
#define WLAN_STATUS_REQUEST_DECLINED 37
|
||||
#define WLAN_STATUS_INVALID_PARAMETERS 38
|
||||
/* IEEE 802.11i */
|
||||
#define WLAN_STATUS_INVALID_IE 40
|
||||
#define WLAN_STATUS_GROUP_CIPHER_NOT_VALID 41
|
||||
#define WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID 42
|
||||
#define WLAN_STATUS_AKMP_NOT_VALID 43
|
||||
#define WLAN_STATUS_UNSUPPORTED_RSN_IE_VERSION 44
|
||||
#define WLAN_STATUS_INVALID_RSN_IE_CAPAB 45
|
||||
#define WLAN_STATUS_CIPHER_REJECTED_PER_POLICY 46
|
||||
#define WLAN_STATUS_TS_NOT_CREATED 47
|
||||
#define WLAN_STATUS_DIRECT_LINK_NOT_ALLOWED 48
|
||||
#define WLAN_STATUS_DEST_STA_NOT_PRESENT 49
|
||||
#define WLAN_STATUS_DEST_STA_NOT_QOS_STA 50
|
||||
#define WLAN_STATUS_ASSOC_DENIED_LISTEN_INT_TOO_LARGE 51
|
||||
/* IEEE 802.11r */
|
||||
#define WLAN_STATUS_INVALID_FT_ACTION_FRAME_COUNT 52
|
||||
#define WLAN_STATUS_INVALID_PMKID 53
|
||||
#define WLAN_STATUS_INVALID_MDIE 54
|
||||
#define WLAN_STATUS_INVALID_FTIE 55
|
||||
|
||||
/* Reason codes (IEEE 802.11-2007, 7.3.1.7, Table 7-22) */
|
||||
#define WLAN_REASON_UNSPECIFIED 1
|
||||
#define WLAN_REASON_PREV_AUTH_NOT_VALID 2
|
||||
#define WLAN_REASON_DEAUTH_LEAVING 3
|
||||
#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
|
||||
#define WLAN_REASON_DISASSOC_AP_BUSY 5
|
||||
#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
|
||||
#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
|
||||
#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
|
||||
#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
|
||||
/* IEEE 802.11h */
|
||||
#define WLAN_REASON_PWR_CAPABILITY_NOT_VALID 10
|
||||
#define WLAN_REASON_SUPPORTED_CHANNEL_NOT_VALID 11
|
||||
/* IEEE 802.11i */
|
||||
#define WLAN_REASON_INVALID_IE 13
|
||||
#define WLAN_REASON_MICHAEL_MIC_FAILURE 14
|
||||
#define WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT 15
|
||||
#define WLAN_REASON_GROUP_KEY_UPDATE_TIMEOUT 16
|
||||
#define WLAN_REASON_IE_IN_4WAY_DIFFERS 17
|
||||
#define WLAN_REASON_GROUP_CIPHER_NOT_VALID 18
|
||||
#define WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID 19
|
||||
#define WLAN_REASON_AKMP_NOT_VALID 20
|
||||
#define WLAN_REASON_UNSUPPORTED_RSN_IE_VERSION 21
|
||||
#define WLAN_REASON_INVALID_RSN_IE_CAPAB 22
|
||||
#define WLAN_REASON_IEEE_802_1X_AUTH_FAILED 23
|
||||
#define WLAN_REASON_CIPHER_SUITE_REJECTED 24
|
||||
|
||||
|
||||
/* Information Element IDs */
|
||||
#define WLAN_EID_SSID 0
|
||||
#define WLAN_EID_SUPP_RATES 1
|
||||
#define WLAN_EID_FH_PARAMS 2
|
||||
#define WLAN_EID_DS_PARAMS 3
|
||||
#define WLAN_EID_CF_PARAMS 4
|
||||
#define WLAN_EID_TIM 5
|
||||
#define WLAN_EID_IBSS_PARAMS 6
|
||||
#define WLAN_EID_COUNTRY 7
|
||||
#define WLAN_EID_CHALLENGE 16
|
||||
/* EIDs defined by IEEE 802.11h - START */
|
||||
#define WLAN_EID_PWR_CONSTRAINT 32
|
||||
#define WLAN_EID_PWR_CAPABILITY 33
|
||||
#define WLAN_EID_TPC_REQUEST 34
|
||||
#define WLAN_EID_TPC_REPORT 35
|
||||
#define WLAN_EID_SUPPORTED_CHANNELS 36
|
||||
#define WLAN_EID_CHANNEL_SWITCH 37
|
||||
#define WLAN_EID_MEASURE_REQUEST 38
|
||||
#define WLAN_EID_MEASURE_REPORT 39
|
||||
#define WLAN_EID_QUITE 40
|
||||
#define WLAN_EID_IBSS_DFS 41
|
||||
/* EIDs defined by IEEE 802.11h - END */
|
||||
#define WLAN_EID_ERP_INFO 42
|
||||
#define WLAN_EID_HT_CAP 45
|
||||
#define WLAN_EID_RSN 48
|
||||
#define WLAN_EID_EXT_SUPP_RATES 50
|
||||
#define WLAN_EID_MOBILITY_DOMAIN 54
|
||||
#define WLAN_EID_FAST_BSS_TRANSITION 55
|
||||
#define WLAN_EID_TIMEOUT_INTERVAL 56
|
||||
#define WLAN_EID_RIC_DATA 57
|
||||
#define WLAN_EID_HT_OPERATION 61
|
||||
#define WLAN_EID_SECONDARY_CHANNEL_OFFSET 62
|
||||
#define WLAN_EID_20_40_BSS_COEXISTENCE 72
|
||||
#define WLAN_EID_20_40_BSS_INTOLERANT 73
|
||||
#define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74
|
||||
#define WLAN_EID_MMIE 76
|
||||
#define WLAN_EID_VENDOR_SPECIFIC 221
|
||||
|
||||
|
||||
/* Action frame categories (IEEE 802.11-2007, 7.3.1.11, Table 7-24) */
|
||||
#define WLAN_ACTION_SPECTRUM_MGMT 0
|
||||
#define WLAN_ACTION_QOS 1
|
||||
#define WLAN_ACTION_DLS 2
|
||||
#define WLAN_ACTION_BLOCK_ACK 3
|
||||
#define WLAN_ACTION_PUBLIC 4
|
||||
#define WLAN_ACTION_RADIO_MEASUREMENT 5
|
||||
#define WLAN_ACTION_FT 6
|
||||
#define WLAN_ACTION_HT 7
|
||||
#define WLAN_ACTION_SA_QUERY 8
|
||||
#define WLAN_ACTION_WMM 17 /* WMM Specification 1.1 */
|
||||
|
||||
/* SA Query Action frame (IEEE 802.11w/D8.0, 7.4.9) */
|
||||
#define WLAN_SA_QUERY_REQUEST 0
|
||||
#define WLAN_SA_QUERY_RESPONSE 1
|
||||
|
||||
#define WLAN_SA_QUERY_TR_ID_LEN 2
|
||||
|
||||
/* Timeout Interval Type */
|
||||
#define WLAN_TIMEOUT_REASSOC_DEADLINE 1
|
||||
#define WLAN_TIMEOUT_KEY_LIFETIME 2
|
||||
#define WLAN_TIMEOUT_ASSOC_COMEBACK 3
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(push, 1)
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
struct ieee80211_hdr {
|
||||
le16 frame_control;
|
||||
le16 duration_id;
|
||||
u8 addr1[6];
|
||||
u8 addr2[6];
|
||||
u8 addr3[6];
|
||||
le16 seq_ctrl;
|
||||
/* followed by 'u8 addr4[6];' if ToDS and FromDS is set in data frame
|
||||
*/
|
||||
} STRUCT_PACKED;
|
||||
|
||||
#define IEEE80211_DA_FROMDS addr1
|
||||
#define IEEE80211_BSSID_FROMDS addr2
|
||||
#define IEEE80211_SA_FROMDS addr3
|
||||
|
||||
#define IEEE80211_HDRLEN (sizeof(struct ieee80211_hdr))
|
||||
|
||||
#define IEEE80211_FC(type, stype) host_to_le16((type << 2) | (stype << 4))
|
||||
|
||||
struct ieee80211_mgmt {
|
||||
le16 frame_control;
|
||||
le16 duration;
|
||||
u8 da[6];
|
||||
u8 sa[6];
|
||||
u8 bssid[6];
|
||||
le16 seq_ctrl;
|
||||
union {
|
||||
struct {
|
||||
le16 auth_alg;
|
||||
le16 auth_transaction;
|
||||
le16 status_code;
|
||||
/* possibly followed by Challenge text */
|
||||
u8 variable[0];
|
||||
} STRUCT_PACKED auth;
|
||||
struct {
|
||||
le16 reason_code;
|
||||
} STRUCT_PACKED deauth;
|
||||
struct {
|
||||
le16 capab_info;
|
||||
le16 listen_interval;
|
||||
/* followed by SSID and Supported rates */
|
||||
u8 variable[0];
|
||||
} STRUCT_PACKED assoc_req;
|
||||
struct {
|
||||
le16 capab_info;
|
||||
le16 status_code;
|
||||
le16 aid;
|
||||
/* followed by Supported rates */
|
||||
u8 variable[0];
|
||||
} STRUCT_PACKED assoc_resp, reassoc_resp;
|
||||
struct {
|
||||
le16 capab_info;
|
||||
le16 listen_interval;
|
||||
u8 current_ap[6];
|
||||
/* followed by SSID and Supported rates */
|
||||
u8 variable[0];
|
||||
} STRUCT_PACKED reassoc_req;
|
||||
struct {
|
||||
le16 reason_code;
|
||||
} STRUCT_PACKED disassoc;
|
||||
struct {
|
||||
u8 timestamp[8];
|
||||
le16 beacon_int;
|
||||
le16 capab_info;
|
||||
/* followed by some of SSID, Supported rates,
|
||||
* FH Params, DS Params, CF Params, IBSS Params, TIM */
|
||||
u8 variable[0];
|
||||
} STRUCT_PACKED beacon;
|
||||
struct {
|
||||
/* only variable items: SSID, Supported rates */
|
||||
u8 variable[0];
|
||||
} STRUCT_PACKED probe_req;
|
||||
struct {
|
||||
u8 timestamp[8];
|
||||
le16 beacon_int;
|
||||
le16 capab_info;
|
||||
/* followed by some of SSID, Supported rates,
|
||||
* FH Params, DS Params, CF Params, IBSS Params */
|
||||
u8 variable[0];
|
||||
} STRUCT_PACKED probe_resp;
|
||||
struct {
|
||||
u8 category;
|
||||
union {
|
||||
struct {
|
||||
u8 action_code;
|
||||
u8 dialog_token;
|
||||
u8 status_code;
|
||||
u8 variable[0];
|
||||
} STRUCT_PACKED wmm_action;
|
||||
struct{
|
||||
u8 action_code;
|
||||
u8 element_id;
|
||||
u8 length;
|
||||
u8 switch_mode;
|
||||
u8 new_chan;
|
||||
u8 switch_count;
|
||||
} STRUCT_PACKED chan_switch;
|
||||
struct {
|
||||
u8 action;
|
||||
u8 sta_addr[ETH_ALEN];
|
||||
u8 target_ap_addr[ETH_ALEN];
|
||||
u8 variable[0]; /* FT Request */
|
||||
} STRUCT_PACKED ft_action_req;
|
||||
struct {
|
||||
u8 action;
|
||||
u8 sta_addr[ETH_ALEN];
|
||||
u8 target_ap_addr[ETH_ALEN];
|
||||
le16 status_code;
|
||||
u8 variable[0]; /* FT Request */
|
||||
} STRUCT_PACKED ft_action_resp;
|
||||
struct {
|
||||
u8 action;
|
||||
u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN];
|
||||
} STRUCT_PACKED sa_query_req;
|
||||
struct {
|
||||
u8 action; /* */
|
||||
u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN];
|
||||
} STRUCT_PACKED sa_query_resp;
|
||||
} u;
|
||||
} STRUCT_PACKED action;
|
||||
} u;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
|
||||
struct ieee80211_ht_capabilities {
|
||||
le16 ht_capabilities_info;
|
||||
u8 a_mpdu_params;
|
||||
u8 supported_mcs_set[16];
|
||||
le16 ht_extended_capabilities;
|
||||
le32 tx_bf_capability_info;
|
||||
u8 asel_capabilities;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
|
||||
struct ieee80211_ht_operation {
|
||||
u8 control_chan;
|
||||
u8 ht_param;
|
||||
le16 operation_mode;
|
||||
le16 stbc_param;
|
||||
u8 basic_set[16];
|
||||
} STRUCT_PACKED;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(pop)
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#define ERP_INFO_NON_ERP_PRESENT BIT(0)
|
||||
#define ERP_INFO_USE_PROTECTION BIT(1)
|
||||
#define ERP_INFO_BARKER_PREAMBLE_MODE BIT(2)
|
||||
|
||||
|
||||
#define HT_CAP_INFO_LDPC_CODING_CAP ((u16) BIT(0))
|
||||
#define HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET ((u16) BIT(1))
|
||||
#define HT_CAP_INFO_SMPS_MASK ((u16) (BIT(2) | BIT(3)))
|
||||
#define HT_CAP_INFO_SMPS_STATIC ((u16) 0)
|
||||
#define HT_CAP_INFO_SMPS_DYNAMIC ((u16) BIT(2))
|
||||
#define HT_CAP_INFO_SMPS_DISABLED ((u16) (BIT(2) | BIT(3)))
|
||||
#define HT_CAP_INFO_GREEN_FIELD ((u16) BIT(4))
|
||||
#define HT_CAP_INFO_SHORT_GI20MHZ ((u16) BIT(5))
|
||||
#define HT_CAP_INFO_SHORT_GI40MHZ ((u16) BIT(6))
|
||||
#define HT_CAP_INFO_TX_STBC ((u16) BIT(7))
|
||||
#define HT_CAP_INFO_RX_STBC_MASK ((u16) (BIT(8) | BIT(9)))
|
||||
#define HT_CAP_INFO_RX_STBC_1 ((u16) BIT(8))
|
||||
#define HT_CAP_INFO_RX_STBC_12 ((u16) BIT(9))
|
||||
#define HT_CAP_INFO_RX_STBC_123 ((u16) (BIT(8) | BIT(9)))
|
||||
#define HT_CAP_INFO_DELAYED_BA ((u16) BIT(10))
|
||||
#define HT_CAP_INFO_MAX_AMSDU_SIZE ((u16) BIT(11))
|
||||
#define HT_CAP_INFO_DSSS_CCK40MHZ ((u16) BIT(12))
|
||||
#define HT_CAP_INFO_PSMP_SUPP ((u16) BIT(13))
|
||||
#define HT_CAP_INFO_40MHZ_INTOLERANT ((u16) BIT(14))
|
||||
#define HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT ((u16) BIT(15))
|
||||
|
||||
|
||||
#define EXT_HT_CAP_INFO_PCO ((u16) BIT(0))
|
||||
#define EXT_HT_CAP_INFO_TRANS_TIME_OFFSET 1
|
||||
#define EXT_HT_CAP_INFO_MCS_FEEDBACK_OFFSET 8
|
||||
#define EXT_HT_CAP_INFO_HTC_SUPPORTED ((u16) BIT(10))
|
||||
#define EXT_HT_CAP_INFO_RD_RESPONDER ((u16) BIT(11))
|
||||
|
||||
|
||||
#define TX_BEAMFORM_CAP_TXBF_CAP ((u32) BIT(0))
|
||||
#define TX_BEAMFORM_CAP_RX_STAGGERED_SOUNDING_CAP ((u32) BIT(1))
|
||||
#define TX_BEAMFORM_CAP_TX_STAGGERED_SOUNDING_CAP ((u32) BIT(2))
|
||||
#define TX_BEAMFORM_CAP_RX_ZLF_CAP ((u32) BIT(3))
|
||||
#define TX_BEAMFORM_CAP_TX_ZLF_CAP ((u32) BIT(4))
|
||||
#define TX_BEAMFORM_CAP_IMPLICIT_ZLF_CAP ((u32) BIT(5))
|
||||
#define TX_BEAMFORM_CAP_CALIB_OFFSET 6
|
||||
#define TX_BEAMFORM_CAP_EXPLICIT_CSI_TXBF_CAP ((u32) BIT(8))
|
||||
#define TX_BEAMFORM_CAP_EXPLICIT_UNCOMPR_STEERING_MATRIX_CAP ((u32) BIT(9))
|
||||
#define TX_BEAMFORM_CAP_EXPLICIT_BF_CSI_FEEDBACK_CAP ((u32) BIT(10))
|
||||
#define TX_BEAMFORM_CAP_EXPLICIT_BF_CSI_FEEDBACK_OFFSET 11
|
||||
#define TX_BEAMFORM_CAP_EXPLICIT_UNCOMPR_STEERING_MATRIX_FEEDBACK_OFFSET 13
|
||||
#define TX_BEAMFORM_CAP_EXPLICIT_COMPRESSED_STEERING_MATRIX_FEEDBACK_OFFSET 15
|
||||
#define TX_BEAMFORM_CAP_MINIMAL_GROUPING_OFFSET 17
|
||||
#define TX_BEAMFORM_CAP_CSI_NUM_BEAMFORMER_ANT_OFFSET 19
|
||||
#define TX_BEAMFORM_CAP_UNCOMPRESSED_STEERING_MATRIX_BEAMFORMER_ANT_OFFSET 21
|
||||
#define TX_BEAMFORM_CAP_COMPRESSED_STEERING_MATRIX_BEAMFORMER_ANT_OFFSET 23
|
||||
#define TX_BEAMFORM_CAP_SCI_MAX_OF_ROWS_BEANFORMER_SUPPORTED_OFFSET 25
|
||||
|
||||
|
||||
#define ASEL_CAPABILITY_ASEL_CAPABLE ((u8) BIT(0))
|
||||
#define ASEL_CAPABILITY_EXPLICIT_CSI_FEEDBACK_BASED_TX_AS_CAP ((u8) BIT(1))
|
||||
#define ASEL_CAPABILITY_ANT_INDICES_FEEDBACK_BASED_TX_AS_CAP ((u8) BIT(2))
|
||||
#define ASEL_CAPABILITY_EXPLICIT_CSI_FEEDBACK_CAP ((u8) BIT(3))
|
||||
#define ASEL_CAPABILITY_ANT_INDICES_FEEDBACK_CAP ((u8) BIT(4))
|
||||
#define ASEL_CAPABILITY_RX_AS_CAP ((u8) BIT(5))
|
||||
#define ASEL_CAPABILITY_TX_SOUND_PPDUS_CAP ((u8) BIT(6))
|
||||
|
||||
#define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK ((u8) BIT(0) | BIT(1))
|
||||
#define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE ((u8) BIT(0))
|
||||
#define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW ((u8) BIT(0) | BIT(1))
|
||||
#define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH ((u8) BIT(2))
|
||||
#define HT_INFO_HT_PARAM_RIFS_MODE ((u8) BIT(3))
|
||||
#define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY ((u8) BIT(4))
|
||||
#define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY ((u8) BIT(5))
|
||||
|
||||
|
||||
#define OP_MODE_PURE 0
|
||||
#define OP_MODE_MAY_BE_LEGACY_STAS 1
|
||||
#define OP_MODE_20MHZ_HT_STA_ASSOCED 2
|
||||
#define OP_MODE_MIXED 3
|
||||
|
||||
#define HT_INFO_OPERATION_MODE_OP_MODE_MASK \
|
||||
((le16) (0x0001 | 0x0002))
|
||||
#define HT_INFO_OPERATION_MODE_OP_MODE_OFFSET 0
|
||||
#define HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT ((u8) BIT(2))
|
||||
#define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT ((u8) BIT(3))
|
||||
#define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT ((u8) BIT(4))
|
||||
|
||||
#define HT_INFO_STBC_PARAM_DUAL_BEACON ((u16) BIT(6))
|
||||
#define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT ((u16) BIT(7))
|
||||
#define HT_INFO_STBC_PARAM_SECONDARY_BCN ((u16) BIT(8))
|
||||
#define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED ((u16) BIT(9))
|
||||
#define HT_INFO_STBC_PARAM_PCO_ACTIVE ((u16) BIT(10))
|
||||
#define HT_INFO_STBC_PARAM_PCO_PHASE ((u16) BIT(11))
|
||||
|
||||
|
||||
#define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs)
|
||||
* 00:50:F2 */
|
||||
#define WPA_IE_VENDOR_TYPE 0x0050f201
|
||||
#define WPS_IE_VENDOR_TYPE 0x0050f204
|
||||
|
||||
#define WMM_OUI_TYPE 2
|
||||
#define WMM_OUI_SUBTYPE_INFORMATION_ELEMENT 0
|
||||
#define WMM_OUI_SUBTYPE_PARAMETER_ELEMENT 1
|
||||
#define WMM_OUI_SUBTYPE_TSPEC_ELEMENT 2
|
||||
#define WMM_VERSION 1
|
||||
|
||||
#define WMM_ACTION_CODE_ADDTS_REQ 0
|
||||
#define WMM_ACTION_CODE_ADDTS_RESP 1
|
||||
#define WMM_ACTION_CODE_DELTS 2
|
||||
|
||||
#define WMM_ADDTS_STATUS_ADMISSION_ACCEPTED 0
|
||||
#define WMM_ADDTS_STATUS_INVALID_PARAMETERS 1
|
||||
/* 2 - Reserved */
|
||||
#define WMM_ADDTS_STATUS_REFUSED 3
|
||||
/* 4-255 - Reserved */
|
||||
|
||||
/* WMM TSPEC Direction Field Values */
|
||||
#define WMM_TSPEC_DIRECTION_UPLINK 0
|
||||
#define WMM_TSPEC_DIRECTION_DOWNLINK 1
|
||||
/* 2 - Reserved */
|
||||
#define WMM_TSPEC_DIRECTION_BI_DIRECTIONAL 3
|
||||
|
||||
/*
|
||||
* WMM Information Element (used in (Re)Association Request frames; may also be
|
||||
* used in Beacon frames)
|
||||
*/
|
||||
struct wmm_information_element {
|
||||
/* Element ID: 221 (0xdd); Length: 7 */
|
||||
/* required fields for WMM version 1 */
|
||||
u8 oui[3]; /* 00:50:f2 */
|
||||
u8 oui_type; /* 2 */
|
||||
u8 oui_subtype; /* 0 */
|
||||
u8 version; /* 1 for WMM version 1.0 */
|
||||
u8 qos_info; /* AP/STA specific QoS info */
|
||||
|
||||
} STRUCT_PACKED;
|
||||
|
||||
#define WMM_AC_AIFSN_MASK 0x0f
|
||||
#define WMM_AC_AIFNS_SHIFT 0
|
||||
#define WMM_AC_ACM 0x10
|
||||
#define WMM_AC_ACI_MASK 0x60
|
||||
#define WMM_AC_ACI_SHIFT 5
|
||||
|
||||
#define WMM_AC_ECWMIN_MASK 0x0f
|
||||
#define WMM_AC_ECWMIN_SHIFT 0
|
||||
#define WMM_AC_ECWMAX_MASK 0xf0
|
||||
#define WMM_AC_ECWMAX_SHIFT 4
|
||||
|
||||
struct wmm_ac_parameter {
|
||||
u8 aci_aifsn; /* AIFSN, ACM, ACI */
|
||||
u8 cw; /* ECWmin, ECWmax (CW = 2^ECW - 1) */
|
||||
le16 txop_limit;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
/*
|
||||
* WMM Parameter Element (used in Beacon, Probe Response, and (Re)Association
|
||||
* Response frmaes)
|
||||
*/
|
||||
struct wmm_parameter_element {
|
||||
/* Element ID: 221 (0xdd); Length: 24 */
|
||||
/* required fields for WMM version 1 */
|
||||
u8 oui[3]; /* 00:50:f2 */
|
||||
u8 oui_type; /* 2 */
|
||||
u8 oui_subtype; /* 1 */
|
||||
u8 version; /* 1 for WMM version 1.0 */
|
||||
u8 qos_info; /* AP/STA specif QoS info */
|
||||
u8 reserved; /* 0 */
|
||||
struct wmm_ac_parameter ac[4]; /* AC_BE, AC_BK, AC_VI, AC_VO */
|
||||
|
||||
} STRUCT_PACKED;
|
||||
|
||||
/* WMM TSPEC Element */
|
||||
struct wmm_tspec_element {
|
||||
u8 eid; /* 221 = 0xdd */
|
||||
u8 length; /* 6 + 55 = 61 */
|
||||
u8 oui[3]; /* 00:50:f2 */
|
||||
u8 oui_type; /* 2 */
|
||||
u8 oui_subtype; /* 2 */
|
||||
u8 version; /* 1 */
|
||||
/* WMM TSPEC body (55 octets): */
|
||||
u8 ts_info[3];
|
||||
le16 nominal_msdu_size;
|
||||
le16 maximum_msdu_size;
|
||||
le32 minimum_service_interval;
|
||||
le32 maximum_service_interval;
|
||||
le32 inactivity_interval;
|
||||
le32 suspension_interval;
|
||||
le32 service_start_time;
|
||||
le32 minimum_data_rate;
|
||||
le32 mean_data_rate;
|
||||
le32 peak_data_rate;
|
||||
le32 maximum_burst_size;
|
||||
le32 delay_bound;
|
||||
le32 minimum_phy_rate;
|
||||
le16 surplus_bandwidth_allowance;
|
||||
le16 medium_time;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
|
||||
/* Access Categories / ACI to AC coding */
|
||||
enum {
|
||||
WMM_AC_BE = 0 /* Best Effort */,
|
||||
WMM_AC_BK = 1 /* Background */,
|
||||
WMM_AC_VI = 2 /* Video */,
|
||||
WMM_AC_VO = 3 /* Voice */
|
||||
};
|
||||
|
||||
|
||||
#define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */
|
||||
|
||||
#define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */
|
||||
|
||||
/* cipher suite selectors */
|
||||
#define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
|
||||
#define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
|
||||
#define WLAN_CIPHER_SUITE_TKIP 0x000FAC02
|
||||
/* reserved: 0x000FAC03 */
|
||||
#define WLAN_CIPHER_SUITE_CCMP 0x000FAC04
|
||||
#define WLAN_CIPHER_SUITE_WEP104 0x000FAC05
|
||||
#define WLAN_CIPHER_SUITE_AES_CMAC 0x000FAC06
|
||||
|
||||
/* AKM suite selectors */
|
||||
#define WLAN_AKM_SUITE_8021X 0x000FAC01
|
||||
#define WLAN_AKM_SUITE_PSK 0x000FAC02
|
||||
|
||||
#endif /* IEEE802_11_DEFS_H */
|
64
tools/sdk/include/wpa_supplicant/wpa/ieee802_1x.h
Normal file
64
tools/sdk/include/wpa_supplicant/wpa/ieee802_1x.h
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* hostapd / IEEE 802.1X-2004 Authenticator
|
||||
* Copyright (c) 2002-2012, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef IEEE802_1X_H
|
||||
#define IEEE802_1X_H
|
||||
|
||||
struct hostapd_data;
|
||||
struct sta_info;
|
||||
struct eapol_state_machine;
|
||||
struct hostapd_config;
|
||||
struct hostapd_bss_config;
|
||||
struct hostapd_radius_attr;
|
||||
struct radius_msg;
|
||||
|
||||
|
||||
void ieee802_1x_receive(struct hostapd_data *hapd, const u8 *sa, const u8 *buf,
|
||||
size_t len);
|
||||
|
||||
#if 0
|
||||
void ieee802_1x_new_station(struct hostapd_data *hapd, struct sta_info *sta);
|
||||
void ieee802_1x_free_station(struct sta_info *sta);
|
||||
|
||||
void ieee802_1x_tx_key(struct hostapd_data *hapd, struct sta_info *sta);
|
||||
void ieee802_1x_abort_auth(struct hostapd_data *hapd, struct sta_info *sta);
|
||||
void ieee802_1x_set_sta_authorized(struct hostapd_data *hapd,
|
||||
struct sta_info *sta, int authorized);
|
||||
void ieee802_1x_dump_state(FILE *f, const char *prefix, struct sta_info *sta);
|
||||
int ieee802_1x_init(struct hostapd_data *hapd);
|
||||
void ieee802_1x_deinit(struct hostapd_data *hapd);
|
||||
int ieee802_1x_tx_status(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
const u8 *buf, size_t len, int ack);
|
||||
int ieee802_1x_eapol_tx_status(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
const u8 *data, int len, int ack);
|
||||
u8 * ieee802_1x_get_identity(struct eapol_state_machine *sm, size_t *len);
|
||||
u8 * ieee802_1x_get_radius_class(struct eapol_state_machine *sm, size_t *len,
|
||||
int idx);
|
||||
struct wpabuf * ieee802_1x_get_radius_cui(struct eapol_state_machine *sm);
|
||||
const u8 * ieee802_1x_get_key(struct eapol_state_machine *sm, size_t *len);
|
||||
void ieee802_1x_notify_port_enabled(struct eapol_state_machine *sm,
|
||||
int enabled);
|
||||
void ieee802_1x_notify_port_valid(struct eapol_state_machine *sm,
|
||||
int valid);
|
||||
void ieee802_1x_notify_pre_auth(struct eapol_state_machine *sm, int pre_auth);
|
||||
int ieee802_1x_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen);
|
||||
int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
char *buf, size_t buflen);
|
||||
void hostapd_get_ntp_timestamp(u8 *buf);
|
||||
char *eap_type_text(u8 type);
|
||||
|
||||
const char *radius_mode_txt(struct hostapd_data *hapd);
|
||||
int radius_sta_rate(struct hostapd_data *hapd, struct sta_info *sta);
|
||||
|
||||
int add_common_radius_attr(struct hostapd_data *hapd,
|
||||
struct hostapd_radius_attr *req_attr,
|
||||
struct sta_info *sta,
|
||||
struct radius_msg *msg);
|
||||
#endif
|
||||
|
||||
#endif /* IEEE802_1X_H */
|
31
tools/sdk/include/wpa_supplicant/wpa/includes.h
Normal file
31
tools/sdk/include/wpa_supplicant/wpa/includes.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* wpa_supplicant/hostapd - Default include files
|
||||
* Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*
|
||||
* This header file is included into all C files so that commonly used header
|
||||
* files can be selected with OS specific ifdef blocks in one place instead of
|
||||
* having to have OS/C library specific selection in many files.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDES_H
|
||||
#define INCLUDES_H
|
||||
|
||||
/* Include possible build time configuration before including anything else */
|
||||
//#include "build_config.h" //don't need anymore
|
||||
|
||||
//#include <stdlib.h>
|
||||
//#include <stdio.h>
|
||||
//#include <string.h>
|
||||
//#include <ctype.h>
|
||||
//#include <time.h>
|
||||
|
||||
#endif /* INCLUDES_H */
|
101
tools/sdk/include/wpa_supplicant/wpa/list.h
Normal file
101
tools/sdk/include/wpa_supplicant/wpa/list.h
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Doubly-linked list
|
||||
* Copyright (c) 2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef LIST_H
|
||||
#define LIST_H
|
||||
|
||||
/**
|
||||
* struct dl_list - Doubly-linked list
|
||||
*/
|
||||
struct dl_list {
|
||||
struct dl_list *next;
|
||||
struct dl_list *prev;
|
||||
};
|
||||
|
||||
static inline void dl_list_init(struct dl_list *list)
|
||||
{
|
||||
list->next = list;
|
||||
list->prev = list;
|
||||
}
|
||||
|
||||
static inline void dl_list_add(struct dl_list *list, struct dl_list *item)
|
||||
{
|
||||
item->next = list->next;
|
||||
item->prev = list;
|
||||
list->next->prev = item;
|
||||
list->next = item;
|
||||
}
|
||||
|
||||
static inline void dl_list_add_tail(struct dl_list *list, struct dl_list *item)
|
||||
{
|
||||
dl_list_add(list->prev, item);
|
||||
}
|
||||
|
||||
static inline void dl_list_del(struct dl_list *item)
|
||||
{
|
||||
item->next->prev = item->prev;
|
||||
item->prev->next = item->next;
|
||||
item->next = NULL;
|
||||
item->prev = NULL;
|
||||
}
|
||||
|
||||
static inline int dl_list_empty(struct dl_list *list)
|
||||
{
|
||||
return list->next == list;
|
||||
}
|
||||
|
||||
static inline unsigned int dl_list_len(struct dl_list *list)
|
||||
{
|
||||
struct dl_list *item;
|
||||
int count = 0;
|
||||
for (item = list->next; item != list; item = item->next)
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(type, member) ((long) &((type *) 0)->member)
|
||||
#endif
|
||||
|
||||
#define dl_list_entry(item, type, member) \
|
||||
((type *) ((char *) item - offsetof(type, member)))
|
||||
|
||||
#define dl_list_first(list, type, member) \
|
||||
(dl_list_empty((list)) ? NULL : \
|
||||
dl_list_entry((list)->next, type, member))
|
||||
|
||||
#define dl_list_last(list, type, member) \
|
||||
(dl_list_empty((list)) ? NULL : \
|
||||
dl_list_entry((list)->prev, type, member))
|
||||
|
||||
#define dl_list_for_each(item, list, type, member) \
|
||||
for (item = dl_list_entry((list)->next, type, member); \
|
||||
&item->member != (list); \
|
||||
item = dl_list_entry(item->member.next, type, member))
|
||||
|
||||
#define dl_list_for_each_safe(item, n, list, type, member) \
|
||||
for (item = dl_list_entry((list)->next, type, member), \
|
||||
n = dl_list_entry(item->member.next, type, member); \
|
||||
&item->member != (list); \
|
||||
item = n, n = dl_list_entry(n->member.next, type, member))
|
||||
|
||||
#define dl_list_for_each_reverse(item, list, type, member) \
|
||||
for (item = dl_list_entry((list)->prev, type, member); \
|
||||
&item->member != (list); \
|
||||
item = dl_list_entry(item->member.prev, type, member))
|
||||
|
||||
#define DEFINE_DL_LIST(name) \
|
||||
struct dl_list name = { &(name), &(name) }
|
||||
|
||||
#endif /* LIST_H */
|
194
tools/sdk/include/wpa_supplicant/wpa/sta_info.h
Normal file
194
tools/sdk/include/wpa_supplicant/wpa/sta_info.h
Normal file
@ -0,0 +1,194 @@
|
||||
/*
|
||||
* hostapd / Station table
|
||||
* Copyright (c) 2002-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef STA_INFO_H
|
||||
#define STA_INFO_H
|
||||
|
||||
/* STA flags */
|
||||
#define WLAN_STA_AUTH BIT(0)
|
||||
#define WLAN_STA_ASSOC BIT(1)
|
||||
#define WLAN_STA_PS BIT(2)
|
||||
#define WLAN_STA_TIM BIT(3)
|
||||
#define WLAN_STA_PERM BIT(4)
|
||||
#define WLAN_STA_AUTHORIZED BIT(5)
|
||||
#define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
|
||||
#define WLAN_STA_SHORT_PREAMBLE BIT(7)
|
||||
#define WLAN_STA_PREAUTH BIT(8)
|
||||
#define WLAN_STA_WMM BIT(9)
|
||||
#define WLAN_STA_MFP BIT(10)
|
||||
#define WLAN_STA_HT BIT(11)
|
||||
#define WLAN_STA_WPS BIT(12)
|
||||
#define WLAN_STA_MAYBE_WPS BIT(13)
|
||||
#define WLAN_STA_WDS BIT(14)
|
||||
#define WLAN_STA_ASSOC_REQ_OK BIT(15)
|
||||
#define WLAN_STA_WPS2 BIT(16)
|
||||
#define WLAN_STA_GAS BIT(17)
|
||||
#define WLAN_STA_VHT BIT(18)
|
||||
#define WLAN_STA_PENDING_DISASSOC_CB BIT(29)
|
||||
#define WLAN_STA_PENDING_DEAUTH_CB BIT(30)
|
||||
#define WLAN_STA_NONERP BIT(31)
|
||||
|
||||
/* Maximum number of supported rates (from both Supported Rates and Extended
|
||||
* Supported Rates IEs). */
|
||||
#define WLAN_SUPP_RATES_MAX 32
|
||||
|
||||
|
||||
struct sta_info {
|
||||
struct sta_info *next; /* next entry in sta list */
|
||||
struct sta_info *hnext; /* next entry in hash table list */
|
||||
u8 addr[6];
|
||||
u16 aid; /* STA's unique AID (1 .. 2007) or 0 if not yet assigned */
|
||||
u32 flags; /* Bitfield of WLAN_STA_* */
|
||||
u16 capability;
|
||||
u16 listen_interval; /* or beacon_int for APs */
|
||||
u8 supported_rates[WLAN_SUPP_RATES_MAX];
|
||||
int supported_rates_len;
|
||||
// u8 qosinfo; /* Valid when WLAN_STA_WMM is set */
|
||||
|
||||
// unsigned int nonerp_set:1;
|
||||
// unsigned int no_short_slot_time_set:1;
|
||||
// unsigned int no_short_preamble_set:1;
|
||||
// unsigned int no_ht_gf_set:1;
|
||||
// unsigned int no_ht_set:1;
|
||||
// unsigned int ht_20mhz_set:1;
|
||||
// unsigned int no_p2p_set:1;
|
||||
|
||||
u16 auth_alg;
|
||||
// u8 previous_ap[6];
|
||||
|
||||
enum {
|
||||
STA_NULLFUNC = 0, STA_DISASSOC, STA_DEAUTH, STA_REMOVE
|
||||
} timeout_next;
|
||||
|
||||
// u16 deauth_reason;
|
||||
// u16 disassoc_reason;
|
||||
|
||||
/* IEEE 802.1X related data */
|
||||
// struct eapol_state_machine *eapol_sm;
|
||||
|
||||
/* IEEE 802.11f (IAPP) related data */
|
||||
// struct ieee80211_mgmt *last_assoc_req;
|
||||
|
||||
// u32 acct_session_id_hi;
|
||||
// u32 acct_session_id_lo;
|
||||
// time_t acct_session_start;
|
||||
// int acct_session_started;
|
||||
// int acct_terminate_cause; /* Acct-Terminate-Cause */
|
||||
// int acct_interim_interval; /* Acct-Interim-Interval */
|
||||
|
||||
// unsigned long last_rx_bytes;
|
||||
// unsigned long last_tx_bytes;
|
||||
// u32 acct_input_gigawords; /* Acct-Input-Gigawords */
|
||||
// u32 acct_output_gigawords; /* Acct-Output-Gigawords */
|
||||
|
||||
// u8 *challenge; /* IEEE 802.11 Shared Key Authentication Challenge */
|
||||
|
||||
struct wpa_state_machine *wpa_sm;
|
||||
// struct rsn_preauth_interface *preauth_iface;
|
||||
|
||||
struct hostapd_ssid *ssid; /* SSID selection based on (Re)AssocReq */
|
||||
// struct hostapd_ssid *ssid_probe; /* SSID selection based on ProbeReq */
|
||||
|
||||
// int vlan_id;
|
||||
/* PSKs from RADIUS authentication server */
|
||||
// struct hostapd_sta_wpa_psk_short *psk;
|
||||
|
||||
// char *identity; /* User-Name from RADIUS */
|
||||
// char *radius_cui; /* Chargeable-User-Identity from RADIUS */
|
||||
|
||||
// struct ieee80211_ht_capabilities *ht_capabilities;
|
||||
// struct ieee80211_vht_capabilities *vht_capabilities;
|
||||
|
||||
#ifdef CONFIG_IEEE80211W
|
||||
int sa_query_count; /* number of pending SA Query requests;
|
||||
* 0 = no SA Query in progress */
|
||||
int sa_query_timed_out;
|
||||
u8 *sa_query_trans_id; /* buffer of WLAN_SA_QUERY_TR_ID_LEN *
|
||||
* sa_query_count octets of pending SA Query
|
||||
* transaction identifiers */
|
||||
struct os_time sa_query_start;
|
||||
#endif /* CONFIG_IEEE80211W */
|
||||
|
||||
#ifdef CONFIG_INTERWORKING
|
||||
#define GAS_DIALOG_MAX 8 /* Max concurrent dialog number */
|
||||
struct gas_dialog_info *gas_dialog;
|
||||
u8 gas_dialog_next;
|
||||
#endif /* CONFIG_INTERWORKING */
|
||||
|
||||
// struct wpabuf *wps_ie; /* WPS IE from (Re)Association Request */
|
||||
// struct wpabuf *p2p_ie; /* P2P IE from (Re)Association Request */
|
||||
// struct wpabuf *hs20_ie; /* HS 2.0 IE from (Re)Association Request */
|
||||
|
||||
// struct os_time connected_time;
|
||||
|
||||
#ifdef CONFIG_SAE
|
||||
enum { SAE_INIT, SAE_COMMIT, SAE_CONFIRM } sae_state;
|
||||
u16 sae_send_confirm;
|
||||
#endif /* CONFIG_SAE */
|
||||
};
|
||||
|
||||
|
||||
/* Default value for maximum station inactivity. After AP_MAX_INACTIVITY has
|
||||
* passed since last received frame from the station, a nullfunc data frame is
|
||||
* sent to the station. If this frame is not acknowledged and no other frames
|
||||
* have been received, the station will be disassociated after
|
||||
* AP_DISASSOC_DELAY seconds. Similarly, the station will be deauthenticated
|
||||
* after AP_DEAUTH_DELAY seconds has passed after disassociation. */
|
||||
#define AP_MAX_INACTIVITY (5 * 60)
|
||||
#define AP_DISASSOC_DELAY (1)
|
||||
#define AP_DEAUTH_DELAY (1)
|
||||
/* Number of seconds to keep STA entry with Authenticated flag after it has
|
||||
* been disassociated. */
|
||||
#define AP_MAX_INACTIVITY_AFTER_DISASSOC (1 * 30)
|
||||
/* Number of seconds to keep STA entry after it has been deauthenticated. */
|
||||
#define AP_MAX_INACTIVITY_AFTER_DEAUTH (1 * 5)
|
||||
|
||||
|
||||
struct hostapd_data;
|
||||
|
||||
int ap_for_each_sta(struct hostapd_data *hapd,
|
||||
int (*cb)(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
void *ctx),
|
||||
void *ctx);
|
||||
struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta);
|
||||
void ap_sta_hash_add(struct hostapd_data *hapd, struct sta_info *sta);
|
||||
void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta);
|
||||
void hostapd_free_stas(struct hostapd_data *hapd);
|
||||
void ap_handle_timer(void *eloop_ctx, void *timeout_ctx);
|
||||
void ap_sta_session_timeout(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
u32 session_timeout);
|
||||
void ap_sta_no_session_timeout(struct hostapd_data *hapd,
|
||||
struct sta_info *sta);
|
||||
struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr);
|
||||
void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
u16 reason);
|
||||
void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
u16 reason);
|
||||
#ifdef CONFIG_WPS
|
||||
int ap_sta_wps_cancel(struct hostapd_data *hapd,
|
||||
struct sta_info *sta, void *ctx);
|
||||
#endif /* CONFIG_WPS */
|
||||
int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
int old_vlanid);
|
||||
void ap_sta_start_sa_query(struct hostapd_data *hapd, struct sta_info *sta);
|
||||
void ap_sta_stop_sa_query(struct hostapd_data *hapd, struct sta_info *sta);
|
||||
int ap_check_sa_query_timeout(struct hostapd_data *hapd, struct sta_info *sta);
|
||||
void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
const u8 *addr, u16 reason);
|
||||
|
||||
void ap_sta_set_authorized(struct hostapd_data *hapd,
|
||||
struct sta_info *sta, int authorized);
|
||||
static inline int ap_sta_is_authorized(struct sta_info *sta)
|
||||
{
|
||||
return sta->flags & WLAN_STA_AUTHORIZED;
|
||||
}
|
||||
|
||||
void ap_sta_deauth_cb(struct hostapd_data *hapd, struct sta_info *sta);
|
||||
void ap_sta_disassoc_cb(struct hostapd_data *hapd, struct sta_info *sta);
|
||||
|
||||
#endif /* STA_INFO_H */
|
138
tools/sdk/include/wpa_supplicant/wpa/state_machine.h
Normal file
138
tools/sdk/include/wpa_supplicant/wpa/state_machine.h
Normal file
@ -0,0 +1,138 @@
|
||||
/*
|
||||
* wpa_supplicant/hostapd - State machine definitions
|
||||
* Copyright (c) 2002-2005, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*
|
||||
* This file includes a set of pre-processor macros that can be used to
|
||||
* implement a state machine. In addition to including this header file, each
|
||||
* file implementing a state machine must define STATE_MACHINE_DATA to be the
|
||||
* data structure including state variables (enum machine_state,
|
||||
* Boolean changed), and STATE_MACHINE_DEBUG_PREFIX to be a string that is used
|
||||
* as a prefix for all debug messages. If SM_ENTRY_MA macro is used to define
|
||||
* a group of state machines with shared data structure, STATE_MACHINE_ADDR
|
||||
* needs to be defined to point to the MAC address used in debug output.
|
||||
* SM_ENTRY_M macro can be used to define similar group of state machines
|
||||
* without this additional debug info.
|
||||
*/
|
||||
|
||||
#ifndef STATE_MACHINE_H
|
||||
#define STATE_MACHINE_H
|
||||
|
||||
/**
|
||||
* SM_STATE - Declaration of a state machine function
|
||||
* @machine: State machine name
|
||||
* @state: State machine state
|
||||
*
|
||||
* This macro is used to declare a state machine function. It is used in place
|
||||
* of a C function definition to declare functions to be run when the state is
|
||||
* entered by calling SM_ENTER or SM_ENTER_GLOBAL.
|
||||
*/
|
||||
#define SM_STATE(machine, state) \
|
||||
static void ICACHE_FLASH_ATTR sm_ ## machine ## _ ## state ## _Enter(STATE_MACHINE_DATA *sm, \
|
||||
int global)
|
||||
|
||||
/**
|
||||
* SM_ENTRY - State machine function entry point
|
||||
* @machine: State machine name
|
||||
* @state: State machine state
|
||||
*
|
||||
* This macro is used inside each state machine function declared with
|
||||
* SM_STATE. SM_ENTRY should be in the beginning of the function body, but
|
||||
* after declaration of possible local variables. This macro prints debug
|
||||
* information about state transition and update the state machine state.
|
||||
*/
|
||||
#define SM_ENTRY(machine, state) \
|
||||
if (!global || sm->machine ## _state != machine ## _ ## state) { \
|
||||
sm->changed = TRUE; \
|
||||
wpa_printf(MSG_DEBUG, STATE_MACHINE_DEBUG_PREFIX ": " #machine \
|
||||
" entering state " #state); \
|
||||
} \
|
||||
sm->machine ## _state = machine ## _ ## state;
|
||||
|
||||
/**
|
||||
* SM_ENTRY_M - State machine function entry point for state machine group
|
||||
* @machine: State machine name
|
||||
* @_state: State machine state
|
||||
* @data: State variable prefix (full variable: prefix_state)
|
||||
*
|
||||
* This macro is like SM_ENTRY, but for state machine groups that use a shared
|
||||
* data structure for more than one state machine. Both machine and prefix
|
||||
* parameters are set to "sub-state machine" name. prefix is used to allow more
|
||||
* than one state variable to be stored in the same data structure.
|
||||
*/
|
||||
#define SM_ENTRY_M(machine, _state, data) \
|
||||
if (!global || sm->data ## _ ## state != machine ## _ ## _state) { \
|
||||
sm->changed = TRUE; \
|
||||
wpa_printf(MSG_DEBUG, STATE_MACHINE_DEBUG_PREFIX ": " \
|
||||
#machine " entering state " #_state); \
|
||||
} \
|
||||
sm->data ## _ ## state = machine ## _ ## _state;
|
||||
|
||||
/**
|
||||
* SM_ENTRY_MA - State machine function entry point for state machine group
|
||||
* @machine: State machine name
|
||||
* @_state: State machine state
|
||||
* @data: State variable prefix (full variable: prefix_state)
|
||||
*
|
||||
* This macro is like SM_ENTRY_M, but a MAC address is included in debug
|
||||
* output. STATE_MACHINE_ADDR has to be defined to point to the MAC address to
|
||||
* be included in debug.
|
||||
*/
|
||||
#define SM_ENTRY_MA(machine, _state, data) \
|
||||
if (!global || sm->data ## _ ## state != machine ## _ ## _state) { \
|
||||
sm->changed = TRUE; \
|
||||
wpa_printf(MSG_DEBUG, STATE_MACHINE_DEBUG_PREFIX ": " MACSTR " " \
|
||||
#machine " entering state " #_state"\n", \
|
||||
MAC2STR(STATE_MACHINE_ADDR)); \
|
||||
} \
|
||||
sm->data ## _ ## state = machine ## _ ## _state;
|
||||
|
||||
/**
|
||||
* SM_ENTER - Enter a new state machine state
|
||||
* @machine: State machine name
|
||||
* @state: State machine state
|
||||
*
|
||||
* This macro expands to a function call to a state machine function defined
|
||||
* with SM_STATE macro. SM_ENTER is used in a state machine step function to
|
||||
* move the state machine to a new state.
|
||||
*/
|
||||
#define SM_ENTER(machine, state) \
|
||||
sm_ ## machine ## _ ## state ## _Enter(sm, 0)
|
||||
|
||||
/**
|
||||
* SM_ENTER_GLOBAL - Enter a new state machine state based on global rule
|
||||
* @machine: State machine name
|
||||
* @state: State machine state
|
||||
*
|
||||
* This macro is like SM_ENTER, but this is used when entering a new state
|
||||
* based on a global (not specific to any particular state) rule. A separate
|
||||
* macro is used to avoid unwanted debug message floods when the same global
|
||||
* rule is forcing a state machine to remain in on state.
|
||||
*/
|
||||
#define SM_ENTER_GLOBAL(machine, state) \
|
||||
sm_ ## machine ## _ ## state ## _Enter(sm, 1)
|
||||
|
||||
/**
|
||||
* SM_STEP - Declaration of a state machine step function
|
||||
* @machine: State machine name
|
||||
*
|
||||
* This macro is used to declare a state machine step function. It is used in
|
||||
* place of a C function definition to declare a function that is used to move
|
||||
* state machine to a new state based on state variables. This function uses
|
||||
* SM_ENTER and SM_ENTER_GLOBAL macros to enter new state.
|
||||
*/
|
||||
#define SM_STEP(machine) \
|
||||
static void ICACHE_FLASH_ATTR sm_ ## machine ## _Step(STATE_MACHINE_DATA *sm)
|
||||
|
||||
/**
|
||||
* SM_STEP_RUN - Call the state machine step function
|
||||
* @machine: State machine name
|
||||
*
|
||||
* This macro expands to a function call to a state machine step function
|
||||
* defined with SM_STEP macro.
|
||||
*/
|
||||
#define SM_STEP_RUN(machine) sm_ ## machine ## _Step(sm)
|
||||
|
||||
#endif /* STATE_MACHINE_H */
|
193
tools/sdk/include/wpa_supplicant/wpa/wpa.h
Normal file
193
tools/sdk/include/wpa_supplicant/wpa/wpa.h
Normal file
@ -0,0 +1,193 @@
|
||||
/*
|
||||
* wpa_supplicant - WPA definitions
|
||||
* Copyright (c) 2003-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef WPA_H
|
||||
#define WPA_H
|
||||
|
||||
#include "c_types.h"
|
||||
#include "os_type.h"
|
||||
#include "common.h"
|
||||
#include "ets_sys.h"
|
||||
#include "wpa/defs.h"
|
||||
#include "wpa/wpa_common.h"
|
||||
|
||||
//#include "net80211/ieee80211_var.h"
|
||||
//#include "net80211/ieee80211_node.h"
|
||||
|
||||
#define WPA_SM_STATE(_sm) ((_sm)->wpa_state)
|
||||
|
||||
struct wpa_sm;
|
||||
|
||||
int wpa_sm_rx_eapol(u8 *src_addr, u8 *buf, u32 len);
|
||||
|
||||
#define WPA_ASSERT ASSERT
|
||||
|
||||
struct install_key {
|
||||
int mic_errors_seen; /* Michael MIC errors with the current PTK */
|
||||
int keys_cleared;
|
||||
enum wpa_alg alg;
|
||||
u8 addr[ETH_ALEN];
|
||||
int key_idx;
|
||||
int set_tx;
|
||||
u8 seq[10];
|
||||
u8 key[32];
|
||||
};
|
||||
|
||||
/**
|
||||
* struct wpa_sm - Internal WPA state machine data
|
||||
*/
|
||||
struct wpa_sm {
|
||||
u8 pmk[PMK_LEN];
|
||||
size_t pmk_len;
|
||||
|
||||
// char *passphrase; //wlan password
|
||||
// u8 *ssid; //wlan network name
|
||||
// size_t ssid_len;
|
||||
|
||||
struct wpa_ptk ptk, tptk;
|
||||
int ptk_set, tptk_set;
|
||||
u8 snonce[WPA_NONCE_LEN];
|
||||
u8 anonce[WPA_NONCE_LEN]; /* ANonce from the last 1/4 msg */
|
||||
int renew_snonce;
|
||||
u8 rx_replay_counter[WPA_REPLAY_COUNTER_LEN];
|
||||
int rx_replay_counter_set;
|
||||
u8 request_counter[WPA_REPLAY_COUNTER_LEN];
|
||||
|
||||
// void *network_ctx;
|
||||
|
||||
unsigned int pairwise_cipher;
|
||||
unsigned int group_cipher;
|
||||
unsigned int key_mgmt;
|
||||
unsigned int mgmt_group_cipher;
|
||||
|
||||
int rsn_enabled; /* Whether RSN is enabled in configuration */
|
||||
|
||||
int countermeasures; /*TKIP countermeasures state flag, 1:in countermeasures state*/
|
||||
os_timer_t cm_timer;
|
||||
|
||||
u8 *assoc_wpa_ie; /* Own WPA/RSN IE from (Re)AssocReq */
|
||||
size_t assoc_wpa_ie_len;
|
||||
|
||||
u8 eapol_version;
|
||||
|
||||
int wpa_ptk_rekey;
|
||||
u8 own_addr[ETH_ALEN];
|
||||
|
||||
u8 bssid[ETH_ALEN];
|
||||
|
||||
unsigned int proto;
|
||||
enum wpa_states wpa_state;
|
||||
|
||||
u8 *ap_wpa_ie, *ap_rsn_ie;
|
||||
size_t ap_wpa_ie_len, ap_rsn_ie_len;
|
||||
|
||||
struct install_key install_ptk;
|
||||
struct install_key install_gtk;
|
||||
int key_entry_valid; //present current avaliable entry for bssid, for pairkey:0,5,10,15,20, gtk: pairkey_no+i (i:1~4)
|
||||
|
||||
// char *msg; //send eapol msg buff
|
||||
// size_t msg_len; //msg length:6 + sizeof(eth) + data_len
|
||||
|
||||
// struct netif *ifp;
|
||||
struct pbuf *pb;
|
||||
|
||||
void (* sendto) (struct pbuf *pb);
|
||||
void (*config_assoc_ie) (uint8 proto, u8 *assoc_buf, u32 assoc_wpa_ie_len);
|
||||
void (*install_ppkey) (enum wpa_alg alg, uint8 *addr, int key_idx, int set_tx,
|
||||
uint8 *seq, size_t seq_len, uint8 *key, size_t key_len, int key_entry_valid);
|
||||
void (*wpa_deauthenticate)(uint8 reason_code);
|
||||
void (*wpa_neg_complete)();
|
||||
struct wpa_gtk_data gd; //used for calllback save param
|
||||
uint16 key_info; //used for txcallback param
|
||||
};
|
||||
|
||||
struct l2_ethhdr {
|
||||
u8 h_dest[ETH_ALEN];
|
||||
u8 h_source[ETH_ALEN];
|
||||
be16 h_proto;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
/**
|
||||
* set_key - Configure encryption key
|
||||
* @ifname: Interface name (for multi-SSID/VLAN support)
|
||||
* @priv: private driver interface data
|
||||
* @alg: encryption algorithm (%WPA_ALG_NONE, %WPA_ALG_WEP,
|
||||
* %WPA_ALG_TKIP, %WPA_ALG_CCMP, %WPA_ALG_IGTK, %WPA_ALG_PMK);
|
||||
* %WPA_ALG_NONE clears the key.
|
||||
* @addr: address of the peer STA or ff:ff:ff:ff:ff:ff for
|
||||
* broadcast/default keys
|
||||
* @key_idx: key index (0..3), usually 0 for unicast keys; 0..4095 for
|
||||
* IGTK
|
||||
* @set_tx: configure this key as the default Tx key (only used when
|
||||
* driver does not support separate unicast/individual key
|
||||
* @seq: sequence number/packet number, seq_len octets, the next
|
||||
* packet number to be used for in replay protection; configured
|
||||
* for Rx keys (in most cases, this is only used with broadcast
|
||||
* keys and set to zero for unicast keys)
|
||||
* @seq_len: length of the seq, depends on the algorithm:
|
||||
* TKIP: 6 octets, CCMP: 6 octets, IGTK: 6 octets
|
||||
* @key: key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key,
|
||||
* 8-byte Rx Mic Key
|
||||
* @key_len: length of the key buffer in octets (WEP: 5 or 13,
|
||||
* TKIP: 32, CCMP: 16, IGTK: 16)
|
||||
*
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* Configure the given key for the kernel driver. If the driver
|
||||
* supports separate individual keys (4 default keys + 1 individual),
|
||||
* addr can be used to determine whether the key is default or
|
||||
* individual. If only 4 keys are supported, the default key with key
|
||||
* index 0 is used as the individual key. STA must be configured to use
|
||||
* it as the default Tx key (set_tx is set) and accept Rx for all the
|
||||
* key indexes. In most cases, WPA uses only key indexes 1 and 2 for
|
||||
* broadcast keys, so key index 0 is available for this kind of
|
||||
* configuration.
|
||||
*
|
||||
* Please note that TKIP keys include separate TX and RX MIC keys and
|
||||
* some drivers may expect them in different order than wpa_supplicant
|
||||
* is using. If the TX/RX keys are swapped, all TKIP encrypted packets
|
||||
* will tricker Michael MIC errors. This can be fixed by changing the
|
||||
* order of MIC keys by swapping te bytes 16..23 and 24..31 of the key
|
||||
* in driver_*.c set_key() implementation, see driver_ndis.c for an
|
||||
* example on how this can be done.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* send_eapol - Optional function for sending EAPOL packets
|
||||
* @priv: private driver interface data
|
||||
* @dest: Destination MAC address
|
||||
* @proto: Ethertype
|
||||
* @data: EAPOL packet starting with IEEE 802.1X header
|
||||
* @data_len: Size of the EAPOL packet
|
||||
*
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This optional function can be used to override l2_packet operations
|
||||
* with driver specific functionality. If this function pointer is set,
|
||||
* l2_packet module is not used at all and the driver interface code is
|
||||
* responsible for receiving and sending all EAPOL packets. The
|
||||
* received EAPOL packets are sent to core code with EVENT_EAPOL_RX
|
||||
* event. The driver interface is required to implement get_mac_addr()
|
||||
* handler if send_eapol() is used.
|
||||
*/
|
||||
|
||||
#define KEYENTRY_TABLE_MAP(key_entry_valid) ((key_entry_valid)%5)
|
||||
|
||||
void pp_michael_mic_failure(uint16 isunicast);
|
||||
|
||||
void wpa_sm_set_state(enum wpa_states state);
|
||||
|
||||
#endif /* WPA_H */
|
||||
|
292
tools/sdk/include/wpa_supplicant/wpa/wpa_auth.h
Normal file
292
tools/sdk/include/wpa_supplicant/wpa/wpa_auth.h
Normal file
@ -0,0 +1,292 @@
|
||||
/*
|
||||
* hostapd - IEEE 802.11i-2004 / WPA Authenticator
|
||||
* Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef WPA_AUTH_H
|
||||
#define WPA_AUTH_H
|
||||
|
||||
#include "wpa/defs.h"
|
||||
#include "wpa/eapol_common.h"
|
||||
#include "wpa/wpa_common.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(push, 1)
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* IEEE Std 802.11r-2008, 11A.10.3 - Remote request/response frame definition
|
||||
*/
|
||||
struct ft_rrb_frame {
|
||||
u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
|
||||
u8 packet_type; /* FT_PACKET_REQUEST/FT_PACKET_RESPONSE */
|
||||
le16 action_length; /* little endian length of action_frame */
|
||||
u8 ap_address[ETH_ALEN];
|
||||
/*
|
||||
* Followed by action_length bytes of FT Action frame (from Category
|
||||
* field to the end of Action Frame body.
|
||||
*/
|
||||
} STRUCT_PACKED;
|
||||
|
||||
#define RSN_REMOTE_FRAME_TYPE_FT_RRB 1
|
||||
|
||||
#define FT_PACKET_REQUEST 0
|
||||
#define FT_PACKET_RESPONSE 1
|
||||
/* Vendor-specific types for R0KH-R1KH protocol; not defined in 802.11r */
|
||||
#define FT_PACKET_R0KH_R1KH_PULL 200
|
||||
#define FT_PACKET_R0KH_R1KH_RESP 201
|
||||
#define FT_PACKET_R0KH_R1KH_PUSH 202
|
||||
|
||||
#define FT_R0KH_R1KH_PULL_DATA_LEN 44
|
||||
#define FT_R0KH_R1KH_RESP_DATA_LEN 76
|
||||
#define FT_R0KH_R1KH_PUSH_DATA_LEN 88
|
||||
|
||||
struct ft_r0kh_r1kh_pull_frame {
|
||||
u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
|
||||
u8 packet_type; /* FT_PACKET_R0KH_R1KH_PULL */
|
||||
le16 data_length; /* little endian length of data (44) */
|
||||
u8 ap_address[ETH_ALEN];
|
||||
|
||||
u8 nonce[16];
|
||||
u8 pmk_r0_name[WPA_PMK_NAME_LEN];
|
||||
u8 r1kh_id[FT_R1KH_ID_LEN];
|
||||
u8 s1kh_id[ETH_ALEN];
|
||||
u8 pad[4]; /* 8-octet boundary for AES key wrap */
|
||||
u8 key_wrap_extra[8];
|
||||
} STRUCT_PACKED;
|
||||
|
||||
struct ft_r0kh_r1kh_resp_frame {
|
||||
u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
|
||||
u8 packet_type; /* FT_PACKET_R0KH_R1KH_RESP */
|
||||
le16 data_length; /* little endian length of data (76) */
|
||||
u8 ap_address[ETH_ALEN];
|
||||
|
||||
u8 nonce[16]; /* copied from pull */
|
||||
u8 r1kh_id[FT_R1KH_ID_LEN]; /* copied from pull */
|
||||
u8 s1kh_id[ETH_ALEN]; /* copied from pull */
|
||||
u8 pmk_r1[PMK_LEN];
|
||||
u8 pmk_r1_name[WPA_PMK_NAME_LEN];
|
||||
le16 pairwise;
|
||||
u8 pad[2]; /* 8-octet boundary for AES key wrap */
|
||||
u8 key_wrap_extra[8];
|
||||
} STRUCT_PACKED;
|
||||
|
||||
struct ft_r0kh_r1kh_push_frame {
|
||||
u8 frame_type; /* RSN_REMOTE_FRAME_TYPE_FT_RRB */
|
||||
u8 packet_type; /* FT_PACKET_R0KH_R1KH_PUSH */
|
||||
le16 data_length; /* little endian length of data (88) */
|
||||
u8 ap_address[ETH_ALEN];
|
||||
|
||||
/* Encrypted with AES key-wrap */
|
||||
u8 timestamp[4]; /* current time in seconds since unix epoch, little
|
||||
* endian */
|
||||
u8 r1kh_id[FT_R1KH_ID_LEN];
|
||||
u8 s1kh_id[ETH_ALEN];
|
||||
u8 pmk_r0_name[WPA_PMK_NAME_LEN];
|
||||
u8 pmk_r1[PMK_LEN];
|
||||
u8 pmk_r1_name[WPA_PMK_NAME_LEN];
|
||||
le16 pairwise;
|
||||
u8 pad[6]; /* 8-octet boundary for AES key wrap */
|
||||
u8 key_wrap_extra[8];
|
||||
} STRUCT_PACKED;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(pop)
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
|
||||
/* per STA state machine data */
|
||||
|
||||
struct wpa_authenticator;
|
||||
struct wpa_state_machine;
|
||||
struct rsn_pmksa_cache_entry;
|
||||
struct eapol_state_machine;
|
||||
|
||||
|
||||
struct ft_remote_r0kh {
|
||||
struct ft_remote_r0kh *next;
|
||||
u8 addr[ETH_ALEN];
|
||||
u8 id[FT_R0KH_ID_MAX_LEN];
|
||||
size_t id_len;
|
||||
u8 key[16];
|
||||
};
|
||||
|
||||
|
||||
struct ft_remote_r1kh {
|
||||
struct ft_remote_r1kh *next;
|
||||
u8 addr[ETH_ALEN];
|
||||
u8 id[FT_R1KH_ID_LEN];
|
||||
u8 key[16];
|
||||
};
|
||||
|
||||
|
||||
struct wpa_auth_config {
|
||||
int wpa;
|
||||
int wpa_key_mgmt;
|
||||
int wpa_pairwise;
|
||||
int wpa_group;
|
||||
int wpa_group_rekey;
|
||||
int wpa_strict_rekey;
|
||||
int wpa_gmk_rekey;
|
||||
int wpa_ptk_rekey;
|
||||
int rsn_pairwise;
|
||||
int rsn_preauth;
|
||||
int eapol_version;
|
||||
int peerkey;
|
||||
int wmm_enabled;
|
||||
int wmm_uapsd;
|
||||
int disable_pmksa_caching;
|
||||
int okc;
|
||||
int tx_status;
|
||||
#ifdef CONFIG_IEEE80211W
|
||||
enum mfp_options ieee80211w;
|
||||
#endif /* CONFIG_IEEE80211W */
|
||||
#ifdef CONFIG_IEEE80211R
|
||||
#define SSID_LEN 32
|
||||
u8 ssid[SSID_LEN];
|
||||
size_t ssid_len;
|
||||
u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
|
||||
u8 r0_key_holder[FT_R0KH_ID_MAX_LEN];
|
||||
size_t r0_key_holder_len;
|
||||
u8 r1_key_holder[FT_R1KH_ID_LEN];
|
||||
u32 r0_key_lifetime;
|
||||
u32 reassociation_deadline;
|
||||
struct ft_remote_r0kh *r0kh_list;
|
||||
struct ft_remote_r1kh *r1kh_list;
|
||||
int pmk_r1_push;
|
||||
int ft_over_ds;
|
||||
#endif /* CONFIG_IEEE80211R */
|
||||
int disable_gtk;
|
||||
int ap_mlme;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
LOGGER_DEBUG, LOGGER_INFO, LOGGER_WARNING
|
||||
} logger_level;
|
||||
|
||||
typedef enum {
|
||||
WPA_EAPOL_portEnabled, WPA_EAPOL_portValid, WPA_EAPOL_authorized,
|
||||
WPA_EAPOL_portControl_Auto, WPA_EAPOL_keyRun, WPA_EAPOL_keyAvailable,
|
||||
WPA_EAPOL_keyDone, WPA_EAPOL_inc_EapolFramesTx
|
||||
} wpa_eapol_variable;
|
||||
|
||||
struct wpa_auth_callbacks {
|
||||
void *ctx;
|
||||
void (*logger)(void *ctx, const u8 *addr, logger_level level,
|
||||
const char *txt);
|
||||
void (*disconnect)(void *ctx, const u8 *addr, u16 reason);
|
||||
int (*mic_failure_report)(void *ctx, const u8 *addr);
|
||||
void (*set_eapol)(void *ctx, const u8 *addr, wpa_eapol_variable var,
|
||||
int value);
|
||||
int (*get_eapol)(void *ctx, const u8 *addr, wpa_eapol_variable var);
|
||||
const u8 * (*get_psk)(void *ctx, const u8 *addr, const u8 *prev_psk);
|
||||
int (*get_msk)(void *ctx, const u8 *addr, u8 *msk, size_t *len);
|
||||
int (*set_key)(void *ctx, int vlan_id, enum wpa_alg alg,
|
||||
const u8 *addr, int idx, u8 *key, size_t key_len);
|
||||
int (*get_seqnum)(void *ctx, const u8 *addr, int idx, u8 *seq);
|
||||
int (*send_eapol)(void *ctx, const u8 *addr, const u8 *data,
|
||||
size_t data_len, int encrypt);
|
||||
int (*for_each_sta)(void *ctx, int (*cb)(struct wpa_state_machine *sm,
|
||||
void *ctx), void *cb_ctx);
|
||||
int (*for_each_auth)(void *ctx, int (*cb)(struct wpa_authenticator *a,
|
||||
void *ctx), void *cb_ctx);
|
||||
int (*send_ether)(void *ctx, const u8 *dst, u16 proto, const u8 *data,
|
||||
size_t data_len);
|
||||
#ifdef CONFIG_IEEE80211R
|
||||
struct wpa_state_machine * (*add_sta)(void *ctx, const u8 *sta_addr);
|
||||
int (*send_ft_action)(void *ctx, const u8 *dst,
|
||||
const u8 *data, size_t data_len);
|
||||
int (*add_tspec)(void *ctx, const u8 *sta_addr, u8 *tspec_ie,
|
||||
size_t tspec_ielen);
|
||||
#endif /* CONFIG_IEEE80211R */
|
||||
};
|
||||
|
||||
struct wpa_authenticator * wpa_init(const u8 *addr,
|
||||
struct wpa_auth_config *conf,
|
||||
struct wpa_auth_callbacks *cb);
|
||||
int wpa_init_keys(struct wpa_authenticator *wpa_auth);
|
||||
void wpa_deinit(struct wpa_authenticator *wpa_auth);
|
||||
int wpa_reconfig(struct wpa_authenticator *wpa_auth,
|
||||
struct wpa_auth_config *conf);
|
||||
|
||||
enum {
|
||||
WPA_IE_OK, WPA_INVALID_IE, WPA_INVALID_GROUP, WPA_INVALID_PAIRWISE,
|
||||
WPA_INVALID_AKMP, WPA_NOT_ENABLED, WPA_ALLOC_FAIL,
|
||||
WPA_MGMT_FRAME_PROTECTION_VIOLATION, WPA_INVALID_MGMT_GROUP_CIPHER,
|
||||
WPA_INVALID_MDIE, WPA_INVALID_PROTO
|
||||
};
|
||||
|
||||
int wpa_validate_wpa_ie(struct wpa_authenticator *wpa_auth,
|
||||
struct wpa_state_machine *sm,
|
||||
const u8 *wpa_ie, size_t wpa_ie_len/*,
|
||||
const u8 *mdie, size_t mdie_len*/);
|
||||
int wpa_auth_uses_mfp(struct wpa_state_machine *sm);
|
||||
struct wpa_state_machine *
|
||||
wpa_auth_sta_init(struct wpa_authenticator *wpa_auth, const u8 *addr);
|
||||
int wpa_auth_sta_associated(struct wpa_authenticator *wpa_auth,
|
||||
struct wpa_state_machine *sm);
|
||||
void wpa_auth_sta_no_wpa(struct wpa_state_machine *sm);
|
||||
void wpa_auth_sta_deinit(struct wpa_state_machine *sm);
|
||||
void wpa_receive(struct wpa_authenticator *wpa_auth,
|
||||
struct wpa_state_machine *sm,
|
||||
u8 *data, size_t data_len);
|
||||
typedef enum {
|
||||
WPA_AUTH, WPA_ASSOC, WPA_DISASSOC, WPA_DEAUTH, WPA_REAUTH,
|
||||
WPA_REAUTH_EAPOL, WPA_ASSOC_FT
|
||||
} wpa_event;
|
||||
void wpa_remove_ptk(struct wpa_state_machine *sm);
|
||||
int wpa_auth_sm_event(struct wpa_state_machine *sm, wpa_event event);
|
||||
void wpa_auth_sm_notify(struct wpa_state_machine *sm);
|
||||
void wpa_gtk_rekey(struct wpa_authenticator *wpa_auth);
|
||||
int wpa_get_mib(struct wpa_authenticator *wpa_auth, char *buf, size_t buflen);
|
||||
int wpa_get_mib_sta(struct wpa_state_machine *sm, char *buf, size_t buflen);
|
||||
void wpa_auth_countermeasures_start(struct wpa_authenticator *wpa_auth);
|
||||
int wpa_auth_pairwise_set(struct wpa_state_machine *sm);
|
||||
int wpa_auth_get_pairwise(struct wpa_state_machine *sm);
|
||||
int wpa_auth_sta_key_mgmt(struct wpa_state_machine *sm);
|
||||
int wpa_auth_sta_wpa_version(struct wpa_state_machine *sm);
|
||||
int wpa_auth_sta_clear_pmksa(struct wpa_state_machine *sm,
|
||||
struct rsn_pmksa_cache_entry *entry);
|
||||
struct rsn_pmksa_cache_entry *
|
||||
wpa_auth_sta_get_pmksa(struct wpa_state_machine *sm);
|
||||
void wpa_auth_sta_local_mic_failure_report(struct wpa_state_machine *sm);
|
||||
const u8 * wpa_auth_get_wpa_ie(struct wpa_authenticator *wpa_auth,
|
||||
size_t *len);
|
||||
int wpa_auth_pmksa_add(struct wpa_state_machine *sm, const u8 *pmk,
|
||||
int session_timeout, struct eapol_state_machine *eapol);
|
||||
int wpa_auth_pmksa_add_preauth(struct wpa_authenticator *wpa_auth,
|
||||
const u8 *pmk, size_t len, const u8 *sta_addr,
|
||||
int session_timeout,
|
||||
struct eapol_state_machine *eapol);
|
||||
int wpa_auth_sta_set_vlan(struct wpa_state_machine *sm, int vlan_id);
|
||||
void wpa_auth_eapol_key_tx_status(struct wpa_authenticator *wpa_auth,
|
||||
struct wpa_state_machine *sm, int ack);
|
||||
|
||||
#ifdef CONFIG_IEEE80211R
|
||||
u8 * wpa_sm_write_assoc_resp_ies(struct wpa_state_machine *sm, u8 *pos,
|
||||
size_t max_len, int auth_alg,
|
||||
const u8 *req_ies, size_t req_ies_len);
|
||||
void wpa_ft_process_auth(struct wpa_state_machine *sm, const u8 *bssid,
|
||||
u16 auth_transaction, const u8 *ies, size_t ies_len,
|
||||
void (*cb)(void *ctx, const u8 *dst, const u8 *bssid,
|
||||
u16 auth_transaction, u16 resp,
|
||||
const u8 *ies, size_t ies_len),
|
||||
void *ctx);
|
||||
u16 wpa_ft_validate_reassoc(struct wpa_state_machine *sm, const u8 *ies,
|
||||
size_t ies_len);
|
||||
int wpa_ft_action_rx(struct wpa_state_machine *sm, const u8 *data, size_t len);
|
||||
int wpa_ft_rrb_rx(struct wpa_authenticator *wpa_auth, const u8 *src_addr,
|
||||
const u8 *data, size_t data_len);
|
||||
void wpa_ft_push_pmk_r1(struct wpa_authenticator *wpa_auth, const u8 *addr);
|
||||
#endif /* CONFIG_IEEE80211R */
|
||||
|
||||
void wpa_wnmsleep_rekey_gtk(struct wpa_state_machine *sm);
|
||||
void wpa_set_wnmsleep(struct wpa_state_machine *sm, int flag);
|
||||
int wpa_wnmsleep_gtk_subelem(struct wpa_state_machine *sm, u8 *pos);
|
||||
int wpa_wnmsleep_igtk_subelem(struct wpa_state_machine *sm, u8 *pos);
|
||||
|
||||
int wpa_auth_uses_sae(struct wpa_state_machine *sm);
|
||||
|
||||
#endif /* WPA_AUTH_H */
|
234
tools/sdk/include/wpa_supplicant/wpa/wpa_auth_i.h
Normal file
234
tools/sdk/include/wpa_supplicant/wpa/wpa_auth_i.h
Normal file
@ -0,0 +1,234 @@
|
||||
/*
|
||||
* hostapd - IEEE 802.11i-2004 / WPA Authenticator: Internal definitions
|
||||
* Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef WPA_AUTH_I_H
|
||||
#define WPA_AUTH_I_H
|
||||
|
||||
/* max(dot11RSNAConfigGroupUpdateCount,dot11RSNAConfigPairwiseUpdateCount) */
|
||||
#define RSNA_MAX_EAPOL_RETRIES 4
|
||||
|
||||
struct wpa_group;
|
||||
|
||||
struct wpa_stsl_negotiation {
|
||||
struct wpa_stsl_negotiation *next;
|
||||
u8 initiator[ETH_ALEN];
|
||||
u8 peer[ETH_ALEN];
|
||||
};
|
||||
|
||||
|
||||
struct wpa_state_machine {
|
||||
struct wpa_authenticator *wpa_auth;
|
||||
struct wpa_group *group;
|
||||
|
||||
u8 addr[ETH_ALEN];
|
||||
|
||||
enum {
|
||||
WPA_PTK_INITIALIZE, WPA_PTK_DISCONNECT, WPA_PTK_DISCONNECTED,
|
||||
WPA_PTK_AUTHENTICATION, WPA_PTK_AUTHENTICATION2,
|
||||
WPA_PTK_INITPMK, WPA_PTK_INITPSK, WPA_PTK_PTKSTART,
|
||||
WPA_PTK_PTKCALCNEGOTIATING, WPA_PTK_PTKCALCNEGOTIATING2,
|
||||
WPA_PTK_PTKINITNEGOTIATING, WPA_PTK_PTKINITDONE
|
||||
} wpa_ptk_state;
|
||||
|
||||
enum {
|
||||
WPA_PTK_GROUP_IDLE = 0,
|
||||
WPA_PTK_GROUP_REKEYNEGOTIATING,
|
||||
WPA_PTK_GROUP_REKEYESTABLISHED,
|
||||
WPA_PTK_GROUP_KEYERROR
|
||||
} wpa_ptk_group_state;
|
||||
|
||||
Boolean Init;
|
||||
Boolean DeauthenticationRequest;
|
||||
Boolean AuthenticationRequest;
|
||||
Boolean ReAuthenticationRequest;
|
||||
Boolean Disconnect;
|
||||
int TimeoutCtr;
|
||||
int GTimeoutCtr;
|
||||
Boolean TimeoutEvt;
|
||||
Boolean EAPOLKeyReceived;
|
||||
Boolean EAPOLKeyPairwise;
|
||||
Boolean EAPOLKeyRequest;
|
||||
Boolean MICVerified;
|
||||
Boolean GUpdateStationKeys;
|
||||
u8 ANonce[WPA_NONCE_LEN];
|
||||
u8 SNonce[WPA_NONCE_LEN];
|
||||
u8 PMK[PMK_LEN];
|
||||
struct wpa_ptk PTK;
|
||||
Boolean PTK_valid;
|
||||
Boolean pairwise_set;
|
||||
int keycount;
|
||||
Boolean Pair;
|
||||
struct wpa_key_replay_counter {
|
||||
u8 counter[WPA_REPLAY_COUNTER_LEN];
|
||||
Boolean valid;
|
||||
} key_replay[RSNA_MAX_EAPOL_RETRIES],
|
||||
prev_key_replay[RSNA_MAX_EAPOL_RETRIES];
|
||||
Boolean PInitAKeys; /* WPA only, not in IEEE 802.11i */
|
||||
Boolean PTKRequest; /* not in IEEE 802.11i state machine */
|
||||
Boolean has_GTK;
|
||||
Boolean PtkGroupInit; /* init request for PTK Group state machine */
|
||||
|
||||
u8 *last_rx_eapol_key; /* starting from IEEE 802.1X header */
|
||||
size_t last_rx_eapol_key_len;
|
||||
|
||||
unsigned int changed:1;
|
||||
unsigned int in_step_loop:1;
|
||||
unsigned int pending_deinit:1;
|
||||
unsigned int started:1;
|
||||
unsigned int mgmt_frame_prot:1;
|
||||
unsigned int rx_eapol_key_secure:1;
|
||||
unsigned int update_snonce:1;
|
||||
#ifdef CONFIG_IEEE80211R
|
||||
unsigned int ft_completed:1;
|
||||
unsigned int pmk_r1_name_valid:1;
|
||||
#endif /* CONFIG_IEEE80211R */
|
||||
unsigned int is_wnmsleep:1;
|
||||
|
||||
u8 req_replay_counter[WPA_REPLAY_COUNTER_LEN];
|
||||
int req_replay_counter_used;
|
||||
|
||||
u8 *wpa_ie;
|
||||
size_t wpa_ie_len;
|
||||
|
||||
enum {
|
||||
WPA_VERSION_NO_WPA = 0 /* WPA not used */,
|
||||
WPA_VERSION_WPA = 1 /* WPA / IEEE 802.11i/D3.0 */,
|
||||
WPA_VERSION_WPA2 = 2 /* WPA2 / IEEE 802.11i */
|
||||
} wpa;
|
||||
int pairwise; /* Pairwise cipher suite, WPA_CIPHER_* */
|
||||
int wpa_key_mgmt; /* the selected WPA_KEY_MGMT_* */
|
||||
// struct rsn_pmksa_cache_entry *pmksa;
|
||||
|
||||
// u32 dot11RSNAStatsTKIPLocalMICFailures;
|
||||
// u32 dot11RSNAStatsTKIPRemoteMICFailures;
|
||||
|
||||
#ifdef CONFIG_IEEE80211R
|
||||
u8 xxkey[PMK_LEN]; /* PSK or the second 256 bits of MSK */
|
||||
size_t xxkey_len;
|
||||
u8 pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name derived from FT Auth
|
||||
* Request */
|
||||
u8 r0kh_id[FT_R0KH_ID_MAX_LEN]; /* R0KH-ID from FT Auth Request */
|
||||
size_t r0kh_id_len;
|
||||
u8 sup_pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name from EAPOL-Key
|
||||
* message 2/4 */
|
||||
u8 *assoc_resp_ftie;
|
||||
#endif /* CONFIG_IEEE80211R */
|
||||
|
||||
int pending_1_of_4_timeout;
|
||||
};
|
||||
|
||||
|
||||
/* per group key state machine data */
|
||||
struct wpa_group {
|
||||
struct wpa_group *next;
|
||||
int vlan_id;
|
||||
|
||||
Boolean GInit;
|
||||
int GKeyDoneStations;
|
||||
Boolean GTKReKey;
|
||||
int GTK_len;
|
||||
int GN, GM;
|
||||
Boolean GTKAuthenticator;
|
||||
u8 Counter[WPA_NONCE_LEN];
|
||||
|
||||
enum {
|
||||
WPA_GROUP_GTK_INIT = 0,
|
||||
WPA_GROUP_SETKEYS, WPA_GROUP_SETKEYSDONE
|
||||
} wpa_group_state;
|
||||
|
||||
u8 GMK[WPA_GMK_LEN];
|
||||
u8 GTK[2][WPA_GTK_MAX_LEN];
|
||||
u8 GNonce[WPA_NONCE_LEN];
|
||||
Boolean changed;
|
||||
Boolean first_sta_seen;
|
||||
Boolean reject_4way_hs_for_entropy;
|
||||
#ifdef CONFIG_IEEE80211W
|
||||
u8 IGTK[2][WPA_IGTK_LEN];
|
||||
int GN_igtk, GM_igtk;
|
||||
#endif /* CONFIG_IEEE80211W */
|
||||
};
|
||||
|
||||
|
||||
struct wpa_ft_pmk_cache;
|
||||
|
||||
/* per authenticator data */
|
||||
struct wpa_authenticator {
|
||||
struct wpa_group *group;
|
||||
|
||||
// unsigned int dot11RSNAStatsTKIPRemoteMICFailures;
|
||||
// u32 dot11RSNAAuthenticationSuiteSelected;
|
||||
// u32 dot11RSNAPairwiseCipherSelected;
|
||||
// u32 dot11RSNAGroupCipherSelected;
|
||||
// u8 dot11RSNAPMKIDUsed[PMKID_LEN];
|
||||
// u32 dot11RSNAAuthenticationSuiteRequested; /* FIX: update */
|
||||
// u32 dot11RSNAPairwiseCipherRequested; /* FIX: update */
|
||||
// u32 dot11RSNAGroupCipherRequested; /* FIX: update */
|
||||
// unsigned int dot11RSNATKIPCounterMeasuresInvoked;
|
||||
// unsigned int dot11RSNA4WayHandshakeFailures;
|
||||
|
||||
// struct wpa_stsl_negotiation *stsl_negotiations;
|
||||
|
||||
struct wpa_auth_config conf;
|
||||
// struct wpa_auth_callbacks cb;
|
||||
|
||||
u8 *wpa_ie;
|
||||
size_t wpa_ie_len;
|
||||
|
||||
u8 addr[ETH_ALEN];
|
||||
|
||||
// struct rsn_pmksa_cache *pmksa;
|
||||
// struct wpa_ft_pmk_cache *ft_pmk_cache;
|
||||
};
|
||||
|
||||
|
||||
int wpa_write_rsn_ie(struct wpa_auth_config *conf, u8 *buf, size_t len,
|
||||
const u8 *pmkid);
|
||||
#if 0
|
||||
void wpa_auth_logger(struct wpa_authenticator *wpa_auth, const u8 *addr,
|
||||
logger_level level, const char *txt);
|
||||
void wpa_auth_vlogger(struct wpa_authenticator *wpa_auth, const u8 *addr,
|
||||
logger_level level, const char *fmt, ...);
|
||||
#endif
|
||||
void __wpa_send_eapol(struct wpa_authenticator *wpa_auth,
|
||||
struct wpa_state_machine *sm, int key_info,
|
||||
const u8 *key_rsc, const u8 *nonce,
|
||||
const u8 *kde, size_t kde_len,
|
||||
int keyidx, int encr, int force_version);
|
||||
int wpa_auth_for_each_sta(struct wpa_authenticator *wpa_auth,
|
||||
int (*cb)(struct wpa_state_machine *sm, void *ctx),
|
||||
void *cb_ctx);
|
||||
int wpa_auth_for_each_auth(struct wpa_authenticator *wpa_auth,
|
||||
int (*cb)(struct wpa_authenticator *a, void *ctx),
|
||||
void *cb_ctx);
|
||||
|
||||
#ifdef CONFIG_PEERKEY
|
||||
int wpa_stsl_remove(struct wpa_authenticator *wpa_auth,
|
||||
struct wpa_stsl_negotiation *neg);
|
||||
void wpa_smk_error(struct wpa_authenticator *wpa_auth,
|
||||
struct wpa_state_machine *sm, struct wpa_eapol_key *key);
|
||||
void wpa_smk_m1(struct wpa_authenticator *wpa_auth,
|
||||
struct wpa_state_machine *sm, struct wpa_eapol_key *key);
|
||||
void wpa_smk_m3(struct wpa_authenticator *wpa_auth,
|
||||
struct wpa_state_machine *sm, struct wpa_eapol_key *key);
|
||||
#endif /* CONFIG_PEERKEY */
|
||||
|
||||
#ifdef CONFIG_IEEE80211R
|
||||
int wpa_write_mdie(struct wpa_auth_config *conf, u8 *buf, size_t len);
|
||||
int wpa_write_ftie(struct wpa_auth_config *conf, const u8 *r0kh_id,
|
||||
size_t r0kh_id_len,
|
||||
const u8 *anonce, const u8 *snonce,
|
||||
u8 *buf, size_t len, const u8 *subelem,
|
||||
size_t subelem_len);
|
||||
int wpa_auth_derive_ptk_ft(struct wpa_state_machine *sm, const u8 *pmk,
|
||||
struct wpa_ptk *ptk, size_t ptk_len);
|
||||
struct wpa_ft_pmk_cache * wpa_ft_pmk_cache_init(void);
|
||||
void wpa_ft_pmk_cache_deinit(struct wpa_ft_pmk_cache *cache);
|
||||
void wpa_ft_install_ptk(struct wpa_state_machine *sm);
|
||||
#endif /* CONFIG_IEEE80211R */
|
||||
|
||||
#endif /* WPA_AUTH_I_H */
|
50
tools/sdk/include/wpa_supplicant/wpa/wpa_auth_ie.h
Normal file
50
tools/sdk/include/wpa_supplicant/wpa/wpa_auth_ie.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* hostapd - WPA/RSN IE and KDE definitions
|
||||
* Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef WPA_AUTH_IE_H
|
||||
#define WPA_AUTH_IE_H
|
||||
|
||||
struct wpa_eapol_ie_parse {
|
||||
const u8 *wpa_ie;
|
||||
size_t wpa_ie_len;
|
||||
const u8 *rsn_ie;
|
||||
size_t rsn_ie_len;
|
||||
const u8 *pmkid;
|
||||
const u8 *gtk;
|
||||
size_t gtk_len;
|
||||
const u8 *mac_addr;
|
||||
size_t mac_addr_len;
|
||||
#ifdef CONFIG_PEERKEY
|
||||
const u8 *smk;
|
||||
size_t smk_len;
|
||||
const u8 *nonce;
|
||||
size_t nonce_len;
|
||||
const u8 *lifetime;
|
||||
size_t lifetime_len;
|
||||
const u8 *error;
|
||||
size_t error_len;
|
||||
#endif /* CONFIG_PEERKEY */
|
||||
#ifdef CONFIG_IEEE80211W
|
||||
const u8 *igtk;
|
||||
size_t igtk_len;
|
||||
#endif /* CONFIG_IEEE80211W */
|
||||
#ifdef CONFIG_IEEE80211R
|
||||
const u8 *mdie;
|
||||
size_t mdie_len;
|
||||
const u8 *ftie;
|
||||
size_t ftie_len;
|
||||
#endif /* CONFIG_IEEE80211R */
|
||||
};
|
||||
|
||||
int wpa_parse_kde_ies(const u8 *buf, size_t len,
|
||||
struct wpa_eapol_ie_parse *ie);
|
||||
u8 * wpa_add_kde(u8 *pos, u32 kde, const u8 *data, size_t data_len,
|
||||
const u8 *data2, size_t data2_len);
|
||||
int wpa_auth_gen_wpa_ie(struct wpa_authenticator *wpa_auth);
|
||||
|
||||
#endif /* WPA_AUTH_IE_H */
|
332
tools/sdk/include/wpa_supplicant/wpa/wpa_common.h
Normal file
332
tools/sdk/include/wpa_supplicant/wpa/wpa_common.h
Normal file
@ -0,0 +1,332 @@
|
||||
/*
|
||||
* WPA definitions shared between hostapd and wpa_supplicant
|
||||
* Copyright (c) 2002-2008, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#include "os.h"
|
||||
#ifndef WPA_COMMON_H
|
||||
#define WPA_COMMON_H
|
||||
|
||||
#define WPA_MAX_SSID_LEN 32
|
||||
|
||||
/* IEEE 802.11i */
|
||||
#define PMKID_LEN 16
|
||||
#define PMK_LEN 32
|
||||
#define WPA_REPLAY_COUNTER_LEN 8
|
||||
#define WPA_NONCE_LEN 32
|
||||
#define WPA_KEY_RSC_LEN 8
|
||||
#define WPA_GMK_LEN 32
|
||||
#define WPA_GTK_MAX_LEN 32
|
||||
|
||||
#define WPA_SELECTOR_LEN 4
|
||||
#define WPA_VERSION 1
|
||||
#define RSN_SELECTOR_LEN 4
|
||||
#define RSN_VERSION 1
|
||||
|
||||
#define RSN_SELECTOR(a, b, c, d) \
|
||||
((((u32) (a)) << 24) | (((u32) (b)) << 16) | (((u32) (c)) << 8) | \
|
||||
(u32) (d))
|
||||
|
||||
#define WPA_AUTH_KEY_MGMT_NONE RSN_SELECTOR(0x00, 0x50, 0xf2, 0)
|
||||
#define WPA_AUTH_KEY_MGMT_UNSPEC_802_1X RSN_SELECTOR(0x00, 0x50, 0xf2, 1)
|
||||
#define WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X RSN_SELECTOR(0x00, 0x50, 0xf2, 2)
|
||||
#define WPA_CIPHER_SUITE_NONE RSN_SELECTOR(0x00, 0x50, 0xf2, 0)
|
||||
#define WPA_CIPHER_SUITE_WEP40 RSN_SELECTOR(0x00, 0x50, 0xf2, 1)
|
||||
#define WPA_CIPHER_SUITE_TKIP RSN_SELECTOR(0x00, 0x50, 0xf2, 2)
|
||||
#if 0
|
||||
#define WPA_CIPHER_SUITE_WRAP RSN_SELECTOR(0x00, 0x50, 0xf2, 3)
|
||||
#endif
|
||||
#define WPA_CIPHER_SUITE_CCMP RSN_SELECTOR(0x00, 0x50, 0xf2, 4)
|
||||
#define WPA_CIPHER_SUITE_WEP104 RSN_SELECTOR(0x00, 0x50, 0xf2, 5)
|
||||
|
||||
|
||||
#define RSN_AUTH_KEY_MGMT_UNSPEC_802_1X RSN_SELECTOR(0x00, 0x0f, 0xac, 1)
|
||||
#define RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X RSN_SELECTOR(0x00, 0x0f, 0xac, 2)
|
||||
#ifdef CONFIG_IEEE80211R
|
||||
#define RSN_AUTH_KEY_MGMT_FT_802_1X RSN_SELECTOR(0x00, 0x0f, 0xac, 3)
|
||||
#define RSN_AUTH_KEY_MGMT_FT_PSK RSN_SELECTOR(0x00, 0x0f, 0xac, 4)
|
||||
#endif /* CONFIG_IEEE80211R */
|
||||
#define RSN_AUTH_KEY_MGMT_802_1X_SHA256 RSN_SELECTOR(0x00, 0x0f, 0xac, 5)
|
||||
#define RSN_AUTH_KEY_MGMT_PSK_SHA256 RSN_SELECTOR(0x00, 0x0f, 0xac, 6)
|
||||
|
||||
#define RSN_CIPHER_SUITE_NONE RSN_SELECTOR(0x00, 0x0f, 0xac, 0)
|
||||
#define RSN_CIPHER_SUITE_WEP40 RSN_SELECTOR(0x00, 0x0f, 0xac, 1)
|
||||
#define RSN_CIPHER_SUITE_TKIP RSN_SELECTOR(0x00, 0x0f, 0xac, 2)
|
||||
#if 0
|
||||
#define RSN_CIPHER_SUITE_WRAP RSN_SELECTOR(0x00, 0x0f, 0xac, 3)
|
||||
#endif
|
||||
#define RSN_CIPHER_SUITE_CCMP RSN_SELECTOR(0x00, 0x0f, 0xac, 4)
|
||||
#define RSN_CIPHER_SUITE_WEP104 RSN_SELECTOR(0x00, 0x0f, 0xac, 5)
|
||||
#ifdef CONFIG_IEEE80211W
|
||||
#define RSN_CIPHER_SUITE_AES_128_CMAC RSN_SELECTOR(0x00, 0x0f, 0xac, 6)
|
||||
#endif /* CONFIG_IEEE80211W */
|
||||
#define RSN_CIPHER_SUITE_NO_GROUP_ADDRESSED RSN_SELECTOR(0x00, 0x0f, 0xac, 7)
|
||||
#define RSN_CIPHER_SUITE_GCMP RSN_SELECTOR(0x00, 0x0f, 0xac, 8)
|
||||
|
||||
/* EAPOL-Key Key Data Encapsulation
|
||||
* GroupKey and PeerKey require encryption, otherwise, encryption is optional.
|
||||
*/
|
||||
#define RSN_KEY_DATA_GROUPKEY RSN_SELECTOR(0x00, 0x0f, 0xac, 1)
|
||||
#if 0
|
||||
#define RSN_KEY_DATA_STAKEY RSN_SELECTOR(0x00, 0x0f, 0xac, 2)
|
||||
#endif
|
||||
#define RSN_KEY_DATA_MAC_ADDR RSN_SELECTOR(0x00, 0x0f, 0xac, 3)
|
||||
#define RSN_KEY_DATA_PMKID RSN_SELECTOR(0x00, 0x0f, 0xac, 4)
|
||||
#ifdef CONFIG_PEERKEY
|
||||
#define RSN_KEY_DATA_SMK RSN_SELECTOR(0x00, 0x0f, 0xac, 5)
|
||||
#define RSN_KEY_DATA_NONCE RSN_SELECTOR(0x00, 0x0f, 0xac, 6)
|
||||
#define RSN_KEY_DATA_LIFETIME RSN_SELECTOR(0x00, 0x0f, 0xac, 7)
|
||||
#define RSN_KEY_DATA_ERROR RSN_SELECTOR(0x00, 0x0f, 0xac, 8)
|
||||
#endif /* CONFIG_PEERKEY */
|
||||
#ifdef CONFIG_IEEE80211W
|
||||
#define RSN_KEY_DATA_IGTK RSN_SELECTOR(0x00, 0x0f, 0xac, 9)
|
||||
#endif /* CONFIG_IEEE80211W */
|
||||
|
||||
#define WPA_OUI_TYPE RSN_SELECTOR(0x00, 0x50, 0xf2, 1)
|
||||
|
||||
#define RSN_SELECTOR_PUT(a, val) WPA_PUT_BE32((u8 *) (a), (val))
|
||||
#define RSN_SELECTOR_GET(a) WPA_GET_BE32((const u8 *) (a))
|
||||
|
||||
#define RSN_NUM_REPLAY_COUNTERS_1 0
|
||||
#define RSN_NUM_REPLAY_COUNTERS_2 1
|
||||
#define RSN_NUM_REPLAY_COUNTERS_4 2
|
||||
#define RSN_NUM_REPLAY_COUNTERS_16 3
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(push, 1)
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#ifdef CONFIG_IEEE80211W
|
||||
#define WPA_IGTK_LEN 16
|
||||
#endif /* CONFIG_IEEE80211W */
|
||||
|
||||
|
||||
/* IEEE 802.11, 7.3.2.25.3 RSN Capabilities */
|
||||
#define WPA_CAPABILITY_PREAUTH BIT(0)
|
||||
#define WPA_CAPABILITY_NO_PAIRWISE BIT(1)
|
||||
/* B2-B3: PTKSA Replay Counter */
|
||||
/* B4-B5: GTKSA Replay Counter */
|
||||
#define WPA_CAPABILITY_MFPR BIT(6)
|
||||
#define WPA_CAPABILITY_MFPC BIT(7)
|
||||
#define WPA_CAPABILITY_PEERKEY_ENABLED BIT(9)
|
||||
|
||||
|
||||
/* IEEE 802.11r */
|
||||
#define MOBILITY_DOMAIN_ID_LEN 2
|
||||
#define FT_R0KH_ID_MAX_LEN 48
|
||||
#define FT_R1KH_ID_LEN 6
|
||||
#define WPA_PMK_NAME_LEN 16
|
||||
|
||||
|
||||
/* IEEE 802.11, 8.5.2 EAPOL-Key frames */
|
||||
#define WPA_KEY_INFO_TYPE_MASK ((u16) (BIT(0) | BIT(1) | BIT(2)))
|
||||
#define WPA_KEY_INFO_TYPE_HMAC_MD5_RC4 BIT(0)
|
||||
#define WPA_KEY_INFO_TYPE_HMAC_SHA1_AES BIT(1)
|
||||
#define WPA_KEY_INFO_TYPE_AES_128_CMAC 3
|
||||
#define WPA_KEY_INFO_KEY_TYPE BIT(3) /* 1 = Pairwise, 0 = Group key */
|
||||
/* bit4..5 is used in WPA, but is reserved in IEEE 802.11i/RSN */
|
||||
#define WPA_KEY_INFO_KEY_INDEX_MASK (BIT(4) | BIT(5))
|
||||
#define WPA_KEY_INFO_KEY_INDEX_SHIFT 4
|
||||
#define WPA_KEY_INFO_INSTALL BIT(6) /* pairwise */
|
||||
#define WPA_KEY_INFO_TXRX BIT(6) /* group */
|
||||
#define WPA_KEY_INFO_ACK BIT(7)
|
||||
#define WPA_KEY_INFO_MIC BIT(8)
|
||||
#define WPA_KEY_INFO_SECURE BIT(9)
|
||||
#define WPA_KEY_INFO_ERROR BIT(10)
|
||||
#define WPA_KEY_INFO_REQUEST BIT(11)
|
||||
#define WPA_KEY_INFO_ENCR_KEY_DATA BIT(12) /* IEEE 802.11i/RSN only */
|
||||
#define WPA_KEY_INFO_SMK_MESSAGE BIT(13)
|
||||
|
||||
|
||||
struct wpa_eapol_key {
|
||||
u8 type;
|
||||
/* Note: key_info, key_length, and key_data_length are unaligned */
|
||||
u8 key_info[2]; /* big endian */
|
||||
u8 key_length[2]; /* big endian */
|
||||
u8 replay_counter[WPA_REPLAY_COUNTER_LEN];
|
||||
u8 key_nonce[WPA_NONCE_LEN];
|
||||
u8 key_iv[16];
|
||||
u8 key_rsc[WPA_KEY_RSC_LEN];
|
||||
u8 key_id[8]; /* Reserved in IEEE 802.11i/RSN */
|
||||
u8 key_mic[16];
|
||||
u8 key_data_length[2]; /* big endian */
|
||||
/* followed by key_data_length bytes of key_data */
|
||||
} STRUCT_PACKED;
|
||||
|
||||
/**
|
||||
* struct wpa_ptk - WPA Pairwise Transient Key
|
||||
* IEEE Std 802.11i-2004 - 8.5.1.2 Pairwise key hierarchy
|
||||
*/
|
||||
struct wpa_ptk {
|
||||
u8 kck[16]; /* EAPOL-Key Key Confirmation Key (KCK) */
|
||||
u8 kek[16]; /* EAPOL-Key Key Encryption Key (KEK) */
|
||||
u8 tk1[16]; /* Temporal Key 1 (TK1) */
|
||||
union {
|
||||
u8 tk2[16]; /* Temporal Key 2 (TK2) */
|
||||
struct {
|
||||
u8 tx_mic_key[8];
|
||||
u8 rx_mic_key[8];
|
||||
} auth;
|
||||
} u;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
struct wpa_gtk_data {
|
||||
enum wpa_alg alg;
|
||||
int tx, key_rsc_len, keyidx;
|
||||
u8 gtk[32];
|
||||
int gtk_len;
|
||||
};
|
||||
|
||||
|
||||
/* WPA IE version 1
|
||||
* 00-50-f2:1 (OUI:OUI type)
|
||||
* 0x01 0x00 (version; little endian)
|
||||
* (all following fields are optional:)
|
||||
* Group Suite Selector (4 octets) (default: TKIP)
|
||||
* Pairwise Suite Count (2 octets, little endian) (default: 1)
|
||||
* Pairwise Suite List (4 * n octets) (default: TKIP)
|
||||
* Authenticated Key Management Suite Count (2 octets, little endian)
|
||||
* (default: 1)
|
||||
* Authenticated Key Management Suite List (4 * n octets)
|
||||
* (default: unspec 802.1X)
|
||||
* WPA Capabilities (2 octets, little endian) (default: 0)
|
||||
*/
|
||||
|
||||
struct wpa_ie_hdr {
|
||||
u8 elem_id;
|
||||
u8 len;
|
||||
u8 oui[4]; /* 24-bit OUI followed by 8-bit OUI type */
|
||||
u8 version[2]; /* little endian */
|
||||
} STRUCT_PACKED;
|
||||
|
||||
|
||||
/* 1/4: PMKID
|
||||
* 2/4: RSN IE
|
||||
* 3/4: one or two RSN IEs + GTK IE (encrypted)
|
||||
* 4/4: empty
|
||||
* 1/2: GTK IE (encrypted)
|
||||
* 2/2: empty
|
||||
*/
|
||||
|
||||
/* RSN IE version 1
|
||||
* 0x01 0x00 (version; little endian)
|
||||
* (all following fields are optional:)
|
||||
* Group Suite Selector (4 octets) (default: CCMP)
|
||||
* Pairwise Suite Count (2 octets, little endian) (default: 1)
|
||||
* Pairwise Suite List (4 * n octets) (default: CCMP)
|
||||
* Authenticated Key Management Suite Count (2 octets, little endian)
|
||||
* (default: 1)
|
||||
* Authenticated Key Management Suite List (4 * n octets)
|
||||
* (default: unspec 802.1X)
|
||||
* RSN Capabilities (2 octets, little endian) (default: 0)
|
||||
* PMKID Count (2 octets) (default: 0)
|
||||
* PMKID List (16 * n octets)
|
||||
* Management Group Cipher Suite (4 octets) (default: AES-128-CMAC)
|
||||
*/
|
||||
|
||||
struct rsn_ie_hdr {
|
||||
u8 elem_id; /* WLAN_EID_RSN */
|
||||
u8 len;
|
||||
u8 version[2]; /* little endian */
|
||||
} STRUCT_PACKED;
|
||||
|
||||
|
||||
#ifdef CONFIG_PEERKEY
|
||||
enum {
|
||||
STK_MUI_4WAY_STA_AP = 1,
|
||||
STK_MUI_4WAY_STAT_STA = 2,
|
||||
STK_MUI_GTK = 3,
|
||||
STK_MUI_SMK = 4
|
||||
};
|
||||
|
||||
enum {
|
||||
STK_ERR_STA_NR = 1,
|
||||
STK_ERR_STA_NRSN = 2,
|
||||
STK_ERR_CPHR_NS = 3,
|
||||
STK_ERR_NO_STSL = 4
|
||||
};
|
||||
#endif /* CONFIG_PEERKEY */
|
||||
|
||||
struct rsn_error_kde {
|
||||
be16 mui;
|
||||
be16 error_type;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
#ifdef CONFIG_IEEE80211W
|
||||
struct wpa_igtk_kde {
|
||||
u8 keyid[2];
|
||||
u8 pn[6];
|
||||
u8 igtk[WPA_IGTK_LEN];
|
||||
} STRUCT_PACKED;
|
||||
#endif /* CONFIG_IEEE80211W */
|
||||
|
||||
#ifdef CONFIG_IEEE80211R
|
||||
struct rsn_mdie {
|
||||
u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
|
||||
u8 ft_capab;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
#define RSN_FT_CAPAB_FT_OVER_DS BIT(0)
|
||||
#define RSN_FT_CAPAB_FT_RESOURCE_REQ_SUPP BIT(1)
|
||||
|
||||
struct rsn_ftie {
|
||||
u8 mic_control[2];
|
||||
u8 mic[16];
|
||||
u8 anonce[WPA_NONCE_LEN];
|
||||
u8 snonce[WPA_NONCE_LEN];
|
||||
/* followed by optional parameters */
|
||||
} STRUCT_PACKED;
|
||||
|
||||
#define FTIE_SUBELEM_R1KH_ID 1
|
||||
#define FTIE_SUBELEM_GTK 2
|
||||
#define FTIE_SUBELEM_R0KH_ID 3
|
||||
#define FTIE_SUBELEM_IGTK 4
|
||||
|
||||
struct rsn_rdie {
|
||||
u8 id;
|
||||
u8 descr_count;
|
||||
le16 status_code;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
#endif /* CONFIG_IEEE80211R */
|
||||
|
||||
struct wpa_ie_data {
|
||||
int proto;
|
||||
int pairwise_cipher;
|
||||
int group_cipher;
|
||||
int key_mgmt;
|
||||
int capabilities;
|
||||
size_t num_pmkid;
|
||||
const u8 *pmkid;
|
||||
int mgmt_group_cipher;
|
||||
};
|
||||
|
||||
const char * wpa_cipher_txt(int cipher);
|
||||
|
||||
int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
|
||||
struct wpa_ie_data *data);
|
||||
|
||||
int wpa_eapol_key_mic(const u8 *key, int ver, const u8 *buf, size_t len,
|
||||
u8 *mic);
|
||||
int wpa_compare_rsn_ie(int ft_initial_assoc,
|
||||
const u8 *ie1, size_t ie1len,
|
||||
const u8 *ie2, size_t ie2len);
|
||||
|
||||
void wpa_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const char *label,
|
||||
const u8 *addr1, const u8 *addr2,
|
||||
const u8 *nonce1, const u8 *nonce2,
|
||||
u8 *ptk, size_t ptk_len, int use_sha256);
|
||||
|
||||
void rsn_pmkid(const u8 *pmk, size_t pmk_len, const u8 *aa, const u8 *spa,
|
||||
u8 *pmkid, int use_sha256);
|
||||
|
||||
#endif /* WPA_COMMON_H */
|
193
tools/sdk/include/wpa_supplicant/wpa/wpa_debug.h
Normal file
193
tools/sdk/include/wpa_supplicant/wpa/wpa_debug.h
Normal file
@ -0,0 +1,193 @@
|
||||
/*
|
||||
* wpa_supplicant/hostapd / Debug prints
|
||||
* Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef WPA_DEBUG_H
|
||||
#define WPA_DEBUG_H
|
||||
|
||||
|
||||
enum { MSG_MSGDUMP, MSG_DEBUG, MSG_INFO, MSG_WARNING, MSG_ERROR };
|
||||
|
||||
/** EAP authentication completed successfully */
|
||||
#define WPA_EVENT_EAP_SUCCESS "CTRL-EVENT-EAP-SUCCESS "
|
||||
|
||||
int wpa_debug_open_file(const char *path);
|
||||
void wpa_debug_close_file(void);
|
||||
|
||||
/**
|
||||
* wpa_debug_printf_timestamp - Print timestamp for debug output
|
||||
*
|
||||
* This function prints a timestamp in seconds_from_1970.microsoconds
|
||||
* format if debug output has been configured to include timestamps in debug
|
||||
* messages.
|
||||
*/
|
||||
void wpa_debug_print_timestamp(void);
|
||||
|
||||
/**
|
||||
* wpa_printf - conditional printf
|
||||
* @level: priority level (MSG_*) of the message
|
||||
* @fmt: printf format string, followed by optional arguments
|
||||
*
|
||||
* This function is used to print conditional debugging and error messages. The
|
||||
* output may be directed to stdout, stderr, and/or syslog based on
|
||||
* configuration.
|
||||
*
|
||||
* Note: New line '\n' is added to the end of the text when printing to stdout.
|
||||
*/
|
||||
//#define DEBUG_PRINT
|
||||
//#define MSG_PRINT
|
||||
|
||||
/**
|
||||
* wpa_hexdump - conditional hex dump
|
||||
* @level: priority level (MSG_*) of the message
|
||||
* @title: title of for the message
|
||||
* @buf: data buffer to be dumped
|
||||
* @len: length of the buf
|
||||
*
|
||||
* This function is used to print conditional debugging and error messages. The
|
||||
* 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...) ets_printf(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,
|
||||
const struct wpabuf *buf)
|
||||
{
|
||||
wpa_hexdump(level, title, wpabuf_head(buf), wpabuf_len(buf));
|
||||
}
|
||||
|
||||
/**
|
||||
* wpa_hexdump_key - conditional hex dump, hide keys
|
||||
* @level: priority level (MSG_*) of the message
|
||||
* @title: title of for the message
|
||||
* @buf: data buffer to be dumped
|
||||
* @len: length of the buf
|
||||
*
|
||||
* This function is used to print conditional debugging and error messages. The
|
||||
* output may be directed to stdout, stderr, and/or syslog based on
|
||||
* configuration. The contents of buf is printed out has hex dump. This works
|
||||
* like wpa_hexdump(), but by default, does not include secret keys (passwords,
|
||||
* etc.) in debug output.
|
||||
*/
|
||||
void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len);
|
||||
|
||||
|
||||
static inline void wpa_hexdump_buf_key(int level, const char *title,
|
||||
const struct wpabuf *buf)
|
||||
{
|
||||
wpa_hexdump_key(level, title, wpabuf_head(buf), wpabuf_len(buf));
|
||||
}
|
||||
|
||||
/**
|
||||
* wpa_hexdump_ascii - conditional hex dump
|
||||
* @level: priority level (MSG_*) of the message
|
||||
* @title: title of for the message
|
||||
* @buf: data buffer to be dumped
|
||||
* @len: length of the buf
|
||||
*
|
||||
* This function is used to print conditional debugging and error messages. The
|
||||
* output may be directed to stdout, stderr, and/or syslog based on
|
||||
* configuration. The contents of buf is printed out has hex dump with both
|
||||
* the hex numbers and ASCII characters (for printable range) are shown. 16
|
||||
* bytes per line will be shown.
|
||||
*/
|
||||
void wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
|
||||
size_t len);
|
||||
|
||||
/**
|
||||
* wpa_hexdump_ascii_key - conditional hex dump, hide keys
|
||||
* @level: priority level (MSG_*) of the message
|
||||
* @title: title of for the message
|
||||
* @buf: data buffer to be dumped
|
||||
* @len: length of the buf
|
||||
*
|
||||
* This function is used to print conditional debugging and error messages. The
|
||||
* output may be directed to stdout, stderr, and/or syslog based on
|
||||
* configuration. The contents of buf is printed out has hex dump with both
|
||||
* the hex numbers and ASCII characters (for printable range) are shown. 16
|
||||
* bytes per line will be shown. This works like wpa_hexdump_ascii(), but by
|
||||
* default, does not include secret keys (passwords, etc.) in debug output.
|
||||
*/
|
||||
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(...)
|
||||
#endif
|
||||
|
||||
#define wpa_auth_logger
|
||||
#define wpa_auth_vlogger
|
||||
|
||||
/**
|
||||
* wpa_msg - Conditional printf for default target and ctrl_iface monitors
|
||||
* @ctx: Pointer to context data; this is the ctx variable registered
|
||||
* with struct wpa_driver_ops::init()
|
||||
* @level: priority level (MSG_*) of the message
|
||||
* @fmt: printf format string, followed by optional arguments
|
||||
*
|
||||
* This function is used to print conditional debugging and error messages. The
|
||||
* output may be directed to stdout, stderr, and/or syslog based on
|
||||
* configuration. This function is like wpa_printf(), but it also sends the
|
||||
* same message to all attached ctrl_iface monitors.
|
||||
*
|
||||
* Note: New line '\n' is added to the end of the text when printing to stdout.
|
||||
*/
|
||||
void wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
|
||||
|
||||
/**
|
||||
* wpa_msg_ctrl - Conditional printf for ctrl_iface monitors
|
||||
* @ctx: Pointer to context data; this is the ctx variable registered
|
||||
* with struct wpa_driver_ops::init()
|
||||
* @level: priority level (MSG_*) of the message
|
||||
* @fmt: printf format string, followed by optional arguments
|
||||
*
|
||||
* This function is used to print conditional debugging and error messages.
|
||||
* This function is like wpa_msg(), but it sends the output only to the
|
||||
* attached ctrl_iface monitors. In other words, it can be used for frequent
|
||||
* events that do not need to be sent to syslog.
|
||||
*/
|
||||
void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
|
||||
PRINTF_FORMAT(3, 4);
|
||||
|
||||
typedef void (*wpa_msg_cb_func)(void *ctx, int level, const char *txt,
|
||||
size_t len);
|
||||
|
||||
typedef void (*eloop_timeout_handler)(void *eloop_data, void *user_ctx);
|
||||
|
||||
int eloop_cancel_timeout(eloop_timeout_handler handler,
|
||||
void *eloop_data, void *user_data);
|
||||
|
||||
int eloop_register_timeout(unsigned int secs, unsigned int usecs,
|
||||
eloop_timeout_handler handler,
|
||||
void *eloop_data, void *user_data);
|
||||
|
||||
|
||||
#endif /* WPA_DEBUG_H */
|
89
tools/sdk/include/wpa_supplicant/wpa/wpa_i.h
Normal file
89
tools/sdk/include/wpa_supplicant/wpa/wpa_i.h
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Internal WPA/RSN supplicant state machine definitions
|
||||
* Copyright (c) 2004-2010, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef WPA_I_H
|
||||
#define WPA_I_H
|
||||
|
||||
/**
|
||||
* set_key - Configure encryption key
|
||||
* @ifname: Interface name (for multi-SSID/VLAN support)
|
||||
* @priv: private driver interface data
|
||||
* @alg: encryption algorithm (%WPA_ALG_NONE, %WPA_ALG_WEP,
|
||||
* %WPA_ALG_TKIP, %WPA_ALG_CCMP, %WPA_ALG_IGTK, %WPA_ALG_PMK);
|
||||
* %WPA_ALG_NONE clears the key.
|
||||
* @addr: address of the peer STA or ff:ff:ff:ff:ff:ff for
|
||||
* broadcast/default keys
|
||||
* @key_idx: key index (0..3), usually 0 for unicast keys; 0..4095 for
|
||||
* IGTK
|
||||
* @set_tx: configure this key as the default Tx key (only used when
|
||||
* driver does not support separate unicast/individual key
|
||||
* @seq: sequence number/packet number, seq_len octets, the next
|
||||
* packet number to be used for in replay protection; configured
|
||||
* for Rx keys (in most cases, this is only used with broadcast
|
||||
* keys and set to zero for unicast keys)
|
||||
* @seq_len: length of the seq, depends on the algorithm:
|
||||
* TKIP: 6 octets, CCMP: 6 octets, IGTK: 6 octets
|
||||
* @key: key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key,
|
||||
* 8-byte Rx Mic Key
|
||||
* @key_len: length of the key buffer in octets (WEP: 5 or 13,
|
||||
* TKIP: 32, CCMP: 16, IGTK: 16)
|
||||
*
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* Configure the given key for the kernel driver. If the driver
|
||||
* supports separate individual keys (4 default keys + 1 individual),
|
||||
* addr can be used to determine whether the key is default or
|
||||
* individual. If only 4 keys are supported, the default key with key
|
||||
* index 0 is used as the individual key. STA must be configured to use
|
||||
* it as the default Tx key (set_tx is set) and accept Rx for all the
|
||||
* key indexes. In most cases, WPA uses only key indexes 1 and 2 for
|
||||
* broadcast keys, so key index 0 is available for this kind of
|
||||
* configuration.
|
||||
*
|
||||
* Please note that TKIP keys include separate TX and RX MIC keys and
|
||||
* some drivers may expect them in different order than wpa_supplicant
|
||||
* is using. If the TX/RX keys are swapped, all TKIP encrypted packets
|
||||
* will tricker Michael MIC errors. This can be fixed by changing the
|
||||
* order of MIC keys by swapping te bytes 16..23 and 24..31 of the key
|
||||
* in driver_*.c set_key() implementation, see driver_ndis.c for an
|
||||
* example on how this can be done.
|
||||
*/
|
||||
|
||||
typedef void (* WPA_SEND_FUNC)(struct pbuf *pb);
|
||||
|
||||
typedef void (* WPA_SET_ASSOC_IE)(uint8 proto, u8 *assoc_buf, u32 assoc_wpa_ie_len);
|
||||
|
||||
typedef void (*WPA_INSTALL_KEY) (enum wpa_alg alg, uint8 *addr, int key_idx, int set_tx,
|
||||
uint8 *seq, size_t seq_len, uint8 *key, size_t key_len, int key_entry_valid);
|
||||
|
||||
typedef void (*WPA_DEAUTH)(uint8 reason_code);
|
||||
|
||||
typedef void (*WPA_NEG_COMPLETE)();
|
||||
|
||||
void wpa_register(char * payload, WPA_SEND_FUNC snd_func, \
|
||||
WPA_SET_ASSOC_IE set_assoc_ie_func, \
|
||||
WPA_INSTALL_KEY ppinstallkey, \
|
||||
WPA_DEAUTH wpa_deauth, \
|
||||
WPA_NEG_COMPLETE wpa_neg_complete);
|
||||
|
||||
#include "pp/esf_buf.h"
|
||||
void eapol_txcb(esf_buf_t *eb);
|
||||
|
||||
void wpa_set_profile(uint32 wpa_proto);
|
||||
|
||||
void wpa_set_bss(char *macddr, char * bssid, uint8 pairwise_cipher, uint8 group_cipher, char *passphrase, u8 *ssid, size_t ssid_len);
|
||||
|
||||
int wpa_sm_rx_eapol(u8 *src_addr, u8 *buf, u32 len);
|
||||
#endif /* WPA_I_H */
|
||||
|
56
tools/sdk/include/wpa_supplicant/wpa/wpa_ie.h
Normal file
56
tools/sdk/include/wpa_supplicant/wpa/wpa_ie.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* wpa_supplicant - WPA/RSN IE and KDE definitions
|
||||
* Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef WPA_IE_H
|
||||
#define WPA_IE_H
|
||||
|
||||
struct wpa_eapol_ie_parse {
|
||||
const u8 *wpa_ie;
|
||||
size_t wpa_ie_len;
|
||||
const u8 *rsn_ie;
|
||||
size_t rsn_ie_len;
|
||||
const u8 *pmkid;
|
||||
const u8 *gtk;
|
||||
size_t gtk_len;
|
||||
const u8 *mac_addr;
|
||||
size_t mac_addr_len;
|
||||
#ifdef CONFIG_PEERKEY
|
||||
const u8 *smk;
|
||||
size_t smk_len;
|
||||
const u8 *nonce;
|
||||
size_t nonce_len;
|
||||
const u8 *lifetime;
|
||||
size_t lifetime_len;
|
||||
const u8 *error;
|
||||
size_t error_len;
|
||||
#endif /* CONFIG_PEERKEY */
|
||||
#ifdef CONFIG_IEEE80211W
|
||||
const u8 *igtk;
|
||||
size_t igtk_len;
|
||||
#endif /* CONFIG_IEEE80211W */
|
||||
#ifdef CONFIG_IEEE80211R
|
||||
const u8 *mdie;
|
||||
size_t mdie_len;
|
||||
const u8 *ftie;
|
||||
size_t ftie_len;
|
||||
const u8 *reassoc_deadline;
|
||||
const u8 *key_lifetime;
|
||||
#endif /* CONFIG_IEEE80211R */
|
||||
};
|
||||
|
||||
int wpa_supplicant_parse_ies(const u8 *buf, size_t len,
|
||||
struct wpa_eapol_ie_parse *ie);
|
||||
int wpa_gen_wpa_ie(struct wpa_sm *sm, u8 *wpa_ie, size_t wpa_ie_len);
|
||||
|
||||
#endif /* WPA_IE_H */
|
168
tools/sdk/include/wpa_supplicant/wpa/wpabuf.h
Normal file
168
tools/sdk/include/wpa_supplicant/wpa/wpabuf.h
Normal file
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Dynamic data buffer
|
||||
* Copyright (c) 2007-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef WPABUF_H
|
||||
#define WPABUF_H
|
||||
|
||||
/*
|
||||
* Internal data structure for wpabuf. Please do not touch this directly from
|
||||
* elsewhere. This is only defined in header file to allow inline functions
|
||||
* from this file to access data.
|
||||
*/
|
||||
struct wpabuf {
|
||||
size_t size; /* total size of the allocated buffer */
|
||||
size_t used; /* length of data in the buffer */
|
||||
u8 *ext_data; /* pointer to external data; NULL if data follows
|
||||
* struct wpabuf */
|
||||
/* optionally followed by the allocated buffer */
|
||||
};
|
||||
|
||||
|
||||
int wpabuf_resize(struct wpabuf **buf, size_t add_len);
|
||||
struct wpabuf * wpabuf_alloc(size_t len);
|
||||
struct wpabuf * wpabuf_alloc_ext_data(u8 *data, size_t len);
|
||||
struct wpabuf * wpabuf_alloc_copy(const void *data, size_t len);
|
||||
struct wpabuf * wpabuf_dup(const struct wpabuf *src);
|
||||
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);
|
||||
|
||||
|
||||
/**
|
||||
* wpabuf_size - Get the currently allocated size of a wpabuf buffer
|
||||
* @buf: wpabuf buffer
|
||||
* Returns: Currently allocated size of the buffer
|
||||
*/
|
||||
static inline size_t wpabuf_size(const struct wpabuf *buf)
|
||||
{
|
||||
return buf->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* wpabuf_len - Get the current length of a wpabuf buffer data
|
||||
* @buf: wpabuf buffer
|
||||
* Returns: Currently used length of the buffer
|
||||
*/
|
||||
static inline size_t wpabuf_len(const struct wpabuf *buf)
|
||||
{
|
||||
return buf->used;
|
||||
}
|
||||
|
||||
/**
|
||||
* wpabuf_tailroom - Get size of available tail room in the end of the buffer
|
||||
* @buf: wpabuf buffer
|
||||
* Returns: Tail room (in bytes) of available space in the end of the buffer
|
||||
*/
|
||||
static inline size_t wpabuf_tailroom(const struct wpabuf *buf)
|
||||
{
|
||||
return buf->size - buf->used;
|
||||
}
|
||||
|
||||
/**
|
||||
* wpabuf_head - Get pointer to the head of the buffer data
|
||||
* @buf: wpabuf buffer
|
||||
* Returns: Pointer to the head of the buffer data
|
||||
*/
|
||||
static inline const void * wpabuf_head(const struct wpabuf *buf)
|
||||
{
|
||||
if (buf->ext_data)
|
||||
return buf->ext_data;
|
||||
return buf + 1;
|
||||
}
|
||||
|
||||
static inline const u8 * wpabuf_head_u8(const struct wpabuf *buf)
|
||||
{
|
||||
return wpabuf_head(buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* wpabuf_mhead - Get modifiable pointer to the head of the buffer data
|
||||
* @buf: wpabuf buffer
|
||||
* Returns: Pointer to the head of the buffer data
|
||||
*/
|
||||
static inline void * wpabuf_mhead(struct wpabuf *buf)
|
||||
{
|
||||
if (buf->ext_data)
|
||||
return buf->ext_data;
|
||||
return buf + 1;
|
||||
}
|
||||
|
||||
static inline u8 * wpabuf_mhead_u8(struct wpabuf *buf)
|
||||
{
|
||||
return wpabuf_mhead(buf);
|
||||
}
|
||||
|
||||
static inline void wpabuf_put_u8(struct wpabuf *buf, u8 data)
|
||||
{
|
||||
u8 *pos = wpabuf_put(buf, 1);
|
||||
*pos = data;
|
||||
}
|
||||
|
||||
static inline void wpabuf_put_le16(struct wpabuf *buf, u16 data)
|
||||
{
|
||||
u8 *pos = wpabuf_put(buf, 2);
|
||||
WPA_PUT_LE16(pos, data);
|
||||
}
|
||||
|
||||
static inline void wpabuf_put_le32(struct wpabuf *buf, u32 data)
|
||||
{
|
||||
u8 *pos = wpabuf_put(buf, 4);
|
||||
WPA_PUT_LE32(pos, data);
|
||||
}
|
||||
|
||||
static inline void wpabuf_put_be16(struct wpabuf *buf, u16 data)
|
||||
{
|
||||
u8 *pos = wpabuf_put(buf, 2);
|
||||
WPA_PUT_BE16(pos, data);
|
||||
}
|
||||
|
||||
static inline void wpabuf_put_be24(struct wpabuf *buf, u32 data)
|
||||
{
|
||||
u8 *pos = wpabuf_put(buf, 3);
|
||||
WPA_PUT_BE24(pos, data);
|
||||
}
|
||||
|
||||
static inline void wpabuf_put_be32(struct wpabuf *buf, u32 data)
|
||||
{
|
||||
u8 *pos = wpabuf_put(buf, 4);
|
||||
WPA_PUT_BE32(pos, data);
|
||||
}
|
||||
|
||||
static inline void wpabuf_put_data(struct wpabuf *buf, const void *data,
|
||||
size_t len)
|
||||
{
|
||||
if (data)
|
||||
os_memcpy(wpabuf_put(buf, len), data, len);
|
||||
}
|
||||
|
||||
static inline void wpabuf_put_buf(struct wpabuf *dst,
|
||||
const struct wpabuf *src)
|
||||
{
|
||||
wpabuf_put_data(dst, wpabuf_head(src), wpabuf_len(src));
|
||||
}
|
||||
|
||||
static inline void wpabuf_set(struct wpabuf *buf, const void *data, size_t len)
|
||||
{
|
||||
buf->ext_data = (u8 *) data;
|
||||
buf->size = buf->used = len;
|
||||
}
|
||||
|
||||
static inline void wpabuf_put_str(struct wpabuf *dst, const char *str)
|
||||
{
|
||||
wpabuf_put_data(dst, str, os_strlen(str));
|
||||
}
|
||||
|
||||
#endif /* WPABUF_H */
|
31
tools/sdk/include/wpa_supplicant/wpa/wpas_glue.h
Normal file
31
tools/sdk/include/wpa_supplicant/wpa/wpas_glue.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* WPA Supplicant - Glue code to setup EAPOL and RSN modules
|
||||
* Copyright (c) 2003-2008, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef WPAS_GLUE_H
|
||||
#define WPAS_GLUE_H
|
||||
|
||||
u8 * wpa_sm_alloc_eapol(struct wpa_sm *sm, u8 type,
|
||||
const void *data, u16 data_len,
|
||||
size_t *msg_len, void **data_pos);
|
||||
|
||||
int wpa_sm_mlme_setprotection(struct wpa_sm *sm, const u8 *addr,
|
||||
int protect_type, int key_type);
|
||||
|
||||
void wpa_sm_deauthenticate(struct wpa_sm *sm, uint8 reason_code);
|
||||
|
||||
void wpa_sm_disassociate(struct wpa_sm *sm, int reason_code);
|
||||
|
||||
int wpa_sm_get_beacon_ie(struct wpa_sm *sm);
|
||||
|
||||
#endif /* WPAS_GLUE_H */
|
24
tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap.h
Normal file
24
tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* EAP peer state machine functions (RFC 4137)
|
||||
* Copyright (c) 2004-2012, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_H
|
||||
#define EAP_H
|
||||
|
||||
#include "wpa/defs.h"
|
||||
#include "eap/eap_defs.h"
|
||||
|
||||
struct eap_sm;
|
||||
|
||||
struct eap_method_type {
|
||||
int vendor;
|
||||
u32 method;
|
||||
};
|
||||
|
||||
const u8 * eap_get_eapKeyData(struct eap_sm *sm, size_t *len);
|
||||
|
||||
#endif /* EAP_H */
|
23
tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap_common.h
Normal file
23
tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap_common.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* EAP common peer/server definitions
|
||||
* Copyright (c) 2004-2012, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_COMMON_H
|
||||
#define EAP_COMMON_H
|
||||
|
||||
#include "wpa/wpabuf.h"
|
||||
|
||||
int eap_hdr_len_valid(const struct wpabuf *msg, size_t min_payload);
|
||||
const u8 * eap_hdr_validate(int vendor, EapType eap_type,
|
||||
const struct wpabuf *msg, size_t *plen);
|
||||
struct wpabuf * eap_msg_alloc(int vendor, EapType type, size_t payload_len,
|
||||
u8 code, u8 identifier);
|
||||
void eap_update_len(struct wpabuf *msg);
|
||||
u8 eap_get_id(const struct wpabuf *msg);
|
||||
EapType eap_get_type(const struct wpabuf *msg);
|
||||
|
||||
#endif /* EAP_COMMON_H */
|
220
tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap_config.h
Normal file
220
tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap_config.h
Normal file
@ -0,0 +1,220 @@
|
||||
/*
|
||||
* EAP peer configuration data
|
||||
* Copyright (c) 2003-2013, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_CONFIG_H
|
||||
#define EAP_CONFIG_H
|
||||
|
||||
/**
|
||||
* struct eap_peer_config - EAP peer configuration/credentials
|
||||
*/
|
||||
struct eap_peer_config {
|
||||
/**
|
||||
* identity - EAP Identity
|
||||
*
|
||||
* This field is used to set the real user identity or NAI (for
|
||||
* EAP-PSK/PAX/SAKE/GPSK).
|
||||
*/
|
||||
u8 *identity;
|
||||
|
||||
/**
|
||||
* identity_len - EAP Identity length
|
||||
*/
|
||||
size_t identity_len;
|
||||
|
||||
/**
|
||||
* password - Password string for EAP
|
||||
*
|
||||
* This field can include either the plaintext password (default
|
||||
* option) or a NtPasswordHash (16-byte MD4 hash of the unicode
|
||||
* presentation of the password) if flags field has
|
||||
* EAP_CONFIG_FLAGS_PASSWORD_NTHASH bit set to 1. NtPasswordHash can
|
||||
* only be used with authentication mechanism that use this hash as the
|
||||
* starting point for operation: MSCHAP and MSCHAPv2 (EAP-MSCHAPv2,
|
||||
* EAP-TTLS/MSCHAPv2, EAP-TTLS/MSCHAP, LEAP).
|
||||
*
|
||||
* In addition, this field is used to configure a pre-shared key for
|
||||
* EAP-PSK/PAX/SAKE/GPSK. The length of the PSK must be 16 for EAP-PSK
|
||||
* and EAP-PAX and 32 for EAP-SAKE. EAP-GPSK can use a variable length
|
||||
* PSK.
|
||||
*/
|
||||
u8 *password;
|
||||
|
||||
/**
|
||||
* password_len - Length of password field
|
||||
*/
|
||||
size_t password_len;
|
||||
|
||||
/**
|
||||
* ca_cert - File path to CA certificate file (PEM/DER)
|
||||
*
|
||||
* This file can have one or more trusted CA certificates. If ca_cert
|
||||
* and ca_path are not included, server certificate will not be
|
||||
* verified. This is insecure and a trusted CA certificate should
|
||||
* always be configured when using EAP-TLS/TTLS/PEAP. Full path to the
|
||||
* file should be used since working directory may change when
|
||||
* wpa_supplicant is run in the background.
|
||||
*
|
||||
* Alternatively, a named configuration blob can be used by setting
|
||||
* this to blob://blob_name.
|
||||
*
|
||||
* Alternatively, this can be used to only perform matching of the
|
||||
* server certificate (SHA-256 hash of the DER encoded X.509
|
||||
* certificate). In this case, the possible CA certificates in the
|
||||
* server certificate chain are ignored and only the server certificate
|
||||
* is verified. This is configured with the following format:
|
||||
* hash:://server/sha256/cert_hash_in_hex
|
||||
* For example: "hash://server/sha256/
|
||||
* 5a1bc1296205e6fdbe3979728efe3920798885c1c4590b5f90f43222d239ca6a"
|
||||
*
|
||||
* On Windows, trusted CA certificates can be loaded from the system
|
||||
* certificate store by setting this to cert_store://name, e.g.,
|
||||
* ca_cert="cert_store://CA" or ca_cert="cert_store://ROOT".
|
||||
* Note that when running wpa_supplicant as an application, the user
|
||||
* certificate store (My user account) is used, whereas computer store
|
||||
* (Computer account) is used when running wpasvc as a service.
|
||||
*/
|
||||
u8 *ca_cert;
|
||||
|
||||
/**
|
||||
* ca_path - Directory path for CA certificate files (PEM)
|
||||
*
|
||||
* This path may contain multiple CA certificates in OpenSSL format.
|
||||
* Common use for this is to point to system trusted CA list which is
|
||||
* often installed into directory like /etc/ssl/certs. If configured,
|
||||
* these certificates are added to the list of trusted CAs. ca_cert
|
||||
* may also be included in that case, but it is not required.
|
||||
*/
|
||||
u8 *ca_path;
|
||||
|
||||
/**
|
||||
* client_cert - File path to client certificate file (PEM/DER)
|
||||
*
|
||||
* This field is used with EAP method that use TLS authentication.
|
||||
* Usually, this is only configured for EAP-TLS, even though this could
|
||||
* in theory be used with EAP-TTLS and EAP-PEAP, too. Full path to the
|
||||
* file should be used since working directory may change when
|
||||
* wpa_supplicant is run in the background.
|
||||
*
|
||||
* Alternatively, a named configuration blob can be used by setting
|
||||
* this to blob://blob_name.
|
||||
*/
|
||||
u8 *client_cert;
|
||||
|
||||
/**
|
||||
* private_key - File path to client private key file (PEM/DER/PFX)
|
||||
*
|
||||
* When PKCS#12/PFX file (.p12/.pfx) is used, client_cert should be
|
||||
* commented out. Both the private key and certificate will be read
|
||||
* from the PKCS#12 file in this case. Full path to the file should be
|
||||
* used since working directory may change when wpa_supplicant is run
|
||||
* in the background.
|
||||
*
|
||||
* Windows certificate store can be used by leaving client_cert out and
|
||||
* configuring private_key in one of the following formats:
|
||||
*
|
||||
* cert://substring_to_match
|
||||
*
|
||||
* hash://certificate_thumbprint_in_hex
|
||||
*
|
||||
* For example: private_key="hash://63093aa9c47f56ae88334c7b65a4"
|
||||
*
|
||||
* Note that when running wpa_supplicant as an application, the user
|
||||
* certificate store (My user account) is used, whereas computer store
|
||||
* (Computer account) is used when running wpasvc as a service.
|
||||
*
|
||||
* Alternatively, a named configuration blob can be used by setting
|
||||
* this to blob://blob_name.
|
||||
*/
|
||||
u8 *private_key;
|
||||
|
||||
/**
|
||||
* private_key_passwd - Password for private key file
|
||||
*
|
||||
* If left out, this will be asked through control interface.
|
||||
*/
|
||||
u8 *private_key_passwd;
|
||||
|
||||
char *phase1;
|
||||
|
||||
/**
|
||||
* pin - PIN for USIM, GSM SIM, and smartcards
|
||||
*
|
||||
* This field is used to configure PIN for SIM and smartcards for
|
||||
* EAP-SIM and EAP-AKA. In addition, this is used with EAP-TLS if a
|
||||
* smartcard is used for private key operations.
|
||||
*
|
||||
* If left out, this will be asked through control interface.
|
||||
*/
|
||||
char *pin;
|
||||
|
||||
/**
|
||||
* fragment_size - Maximum EAP fragment size in bytes (default 1398)
|
||||
*
|
||||
* This value limits the fragment size for EAP methods that support
|
||||
* fragmentation (e.g., EAP-TLS and EAP-PEAP). This value should be set
|
||||
* small enough to make the EAP messages fit in MTU of the network
|
||||
* interface used for EAPOL. The default value is suitable for most
|
||||
* cases.
|
||||
*/
|
||||
int fragment_size;
|
||||
|
||||
#define EAP_CONFIG_FLAGS_PASSWORD_NTHASH BIT(0)
|
||||
#define EAP_CONFIG_FLAGS_EXT_PASSWORD BIT(1)
|
||||
/**
|
||||
* flags - Network configuration flags (bitfield)
|
||||
*
|
||||
* This variable is used for internal flags to describe further details
|
||||
* for the network parameters.
|
||||
* bit 0 = password is represented as a 16-byte NtPasswordHash value
|
||||
* instead of plaintext password
|
||||
* bit 1 = password is stored in external storage; the value in the
|
||||
* password field is the name of that external entry
|
||||
*/
|
||||
u32 flags;
|
||||
|
||||
/**
|
||||
* ocsp - Whether to use/require OCSP to check server certificate
|
||||
*
|
||||
* 0 = do not use OCSP stapling (TLS certificate status extension)
|
||||
* 1 = try to use OCSP stapling, but not require response
|
||||
* 2 = require valid OCSP stapling response
|
||||
*/
|
||||
int ocsp;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* struct wpa_config_blob - Named configuration blob
|
||||
*
|
||||
* This data structure is used to provide storage for binary objects to store
|
||||
* abstract information like certificates and private keys inlined with the
|
||||
* configuration data.
|
||||
*/
|
||||
struct wpa_config_blob {
|
||||
/**
|
||||
* name - Blob name
|
||||
*/
|
||||
char *name;
|
||||
|
||||
/**
|
||||
* data - Pointer to binary data
|
||||
*/
|
||||
u8 *data;
|
||||
|
||||
/**
|
||||
* len - Length of binary data
|
||||
*/
|
||||
size_t len;
|
||||
|
||||
/**
|
||||
* next - Pointer to next blob in the configuration
|
||||
*/
|
||||
struct wpa_config_blob *next;
|
||||
};
|
||||
|
||||
#endif /* EAP_CONFIG_H */
|
92
tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap_defs.h
Normal file
92
tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap_defs.h
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* EAP server/peer: Shared EAP definitions
|
||||
* Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_DEFS_H
|
||||
#define EAP_DEFS_H
|
||||
|
||||
/* RFC 3748 - Extensible Authentication Protocol (EAP) */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(push, 1)
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
struct eap_hdr {
|
||||
u8 code;
|
||||
u8 identifier;
|
||||
be16 length; /* including code and identifier; network byte order */
|
||||
/* followed by length-4 octets of data */
|
||||
} STRUCT_PACKED;
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(pop)
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
enum { EAP_CODE_REQUEST = 1, EAP_CODE_RESPONSE = 2, EAP_CODE_SUCCESS = 3,
|
||||
EAP_CODE_FAILURE = 4 };
|
||||
|
||||
/* EAP Request and Response data begins with one octet Type. Success and
|
||||
* Failure do not have additional data. */
|
||||
|
||||
/*
|
||||
* EAP Method Types as allocated by IANA:
|
||||
* http://www.iana.org/assignments/eap-numbers
|
||||
*/
|
||||
typedef enum {
|
||||
EAP_TYPE_NONE = 0,
|
||||
EAP_TYPE_IDENTITY = 1 /* RFC 3748 */,
|
||||
EAP_TYPE_NOTIFICATION = 2 /* RFC 3748 */,
|
||||
EAP_TYPE_NAK = 3 /* Response only, RFC 3748 */,
|
||||
EAP_TYPE_MD5 = 4, /* RFC 3748 */
|
||||
EAP_TYPE_OTP = 5 /* RFC 3748 */,
|
||||
EAP_TYPE_GTC = 6, /* RFC 3748 */
|
||||
EAP_TYPE_TLS = 13 /* RFC 2716 */,
|
||||
EAP_TYPE_LEAP = 17 /* Cisco proprietary */,
|
||||
EAP_TYPE_SIM = 18 /* RFC 4186 */,
|
||||
EAP_TYPE_TTLS = 21 /* RFC 5281 */,
|
||||
EAP_TYPE_AKA = 23 /* RFC 4187 */,
|
||||
EAP_TYPE_PEAP = 25 /* draft-josefsson-pppext-eap-tls-eap-06.txt */,
|
||||
EAP_TYPE_MSCHAPV2 = 26 /* draft-kamath-pppext-eap-mschapv2-00.txt */,
|
||||
EAP_TYPE_TLV = 33 /* draft-josefsson-pppext-eap-tls-eap-07.txt */,
|
||||
EAP_TYPE_TNC = 38 /* TNC IF-T v1.0-r3; note: tentative assignment;
|
||||
* type 38 has previously been allocated for
|
||||
* EAP-HTTP Digest, (funk.com) */,
|
||||
EAP_TYPE_FAST = 43 /* RFC 4851 */,
|
||||
EAP_TYPE_PAX = 46 /* RFC 4746 */,
|
||||
EAP_TYPE_PSK = 47 /* RFC 4764 */,
|
||||
EAP_TYPE_SAKE = 48 /* RFC 4763 */,
|
||||
EAP_TYPE_IKEV2 = 49 /* RFC 5106 */,
|
||||
EAP_TYPE_AKA_PRIME = 50 /* RFC 5448 */,
|
||||
EAP_TYPE_GPSK = 51 /* RFC 5433 */,
|
||||
EAP_TYPE_PWD = 52 /* RFC 5931 */,
|
||||
EAP_TYPE_EKE = 53 /* RFC 6124 */,
|
||||
EAP_TYPE_EXPANDED = 254 /* RFC 3748 */
|
||||
} EapType;
|
||||
|
||||
|
||||
/* SMI Network Management Private Enterprise Code for vendor specific types */
|
||||
enum {
|
||||
EAP_VENDOR_IETF = 0,
|
||||
EAP_VENDOR_MICROSOFT = 0x000137 /* Microsoft */,
|
||||
EAP_VENDOR_WFA = 0x00372A /* Wi-Fi Alliance */,
|
||||
EAP_VENDOR_HOSTAP = 39068 /* hostapd/wpa_supplicant project */
|
||||
};
|
||||
|
||||
struct eap_expand {
|
||||
u8 vendor_id[3];
|
||||
be32 vendor_type;
|
||||
u8 opcode;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
#define EAP_VENDOR_UNAUTH_TLS EAP_VENDOR_HOSTAP
|
||||
#define EAP_VENDOR_TYPE_UNAUTH_TLS 1
|
||||
|
||||
#define EAP_MSK_LEN 64
|
||||
#define EAP_EMSK_LEN 64
|
||||
|
||||
#endif /* EAP_DEFS_H */
|
88
tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap_i.h
Normal file
88
tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap_i.h
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* EAP peer state machines internal structures (RFC 4137)
|
||||
* Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_I_H
|
||||
#define EAP_I_H
|
||||
|
||||
#include "wpa/wpabuf.h"
|
||||
#include "eap.h"
|
||||
#include "eap_common.h"
|
||||
#include "eap_config.h"
|
||||
|
||||
/* RFC 4137 - EAP Peer state machine */
|
||||
|
||||
typedef enum {
|
||||
DECISION_FAIL, DECISION_COND_SUCC, DECISION_UNCOND_SUCC
|
||||
} EapDecision;
|
||||
|
||||
typedef enum {
|
||||
METHOD_NONE, METHOD_INIT, METHOD_CONT, METHOD_MAY_CONT, METHOD_DONE
|
||||
} EapMethodState;
|
||||
|
||||
/**
|
||||
* struct eap_method_ret - EAP return values from struct eap_method::process()
|
||||
*
|
||||
* These structure contains OUT variables for the interface between peer state
|
||||
* machine and methods (RFC 4137, Sect. 4.2). eapRespData will be returned as
|
||||
* the return value of struct eap_method::process() so it is not included in
|
||||
* this structure.
|
||||
*/
|
||||
struct eap_method_ret {
|
||||
/**
|
||||
* ignore - Whether method decided to drop the current packed (OUT)
|
||||
*/
|
||||
Boolean ignore;
|
||||
|
||||
/**
|
||||
* methodState - Method-specific state (IN/OUT)
|
||||
*/
|
||||
EapMethodState methodState;
|
||||
|
||||
/**
|
||||
* decision - Authentication decision (OUT)
|
||||
*/
|
||||
EapDecision decision;
|
||||
|
||||
/**
|
||||
* allowNotifications - Whether method allows notifications (OUT)
|
||||
*/
|
||||
Boolean allowNotifications;
|
||||
};
|
||||
|
||||
#define CLIENT_CERT_NAME "CLC"
|
||||
#define CA_CERT_NAME "CAC"
|
||||
#define PRIVATE_KEY_NAME "PVK"
|
||||
#define BLOB_NAME_LEN 3
|
||||
#define BLOB_NUM 2
|
||||
|
||||
/**
|
||||
* struct eap_sm - EAP state machine data
|
||||
*/
|
||||
struct eap_sm {
|
||||
void *eap_method_priv;
|
||||
|
||||
void *ssl_ctx;
|
||||
|
||||
unsigned int workaround;
|
||||
/////////////////////////////////////////////////
|
||||
struct pbuf *outbuf;
|
||||
struct wpa_config_blob blob[BLOB_NUM];
|
||||
struct eap_peer_config config;
|
||||
u8 current_identifier;
|
||||
u8 ownaddr[ETH_ALEN];
|
||||
#ifdef USE_WPA2_TASK
|
||||
#define SIG_WPA2_NUM 2
|
||||
u8 wpa2_sig_cnt[SIG_WPA2_NUM];
|
||||
#endif
|
||||
u8 finish_state;
|
||||
};
|
||||
|
||||
struct eap_peer_config * eap_get_config(struct eap_sm *sm);
|
||||
const struct wpa_config_blob * eap_get_config_blob(struct eap_sm *sm, const char *name);
|
||||
|
||||
#endif /* EAP_I_H */
|
25
tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap_tls.h
Normal file
25
tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap_tls.h
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* EAP peer: EAP-TLS/PEAP/TTLS/FAST common functions
|
||||
* Copyright (c) 2004-2009, 2012, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_TLS_H
|
||||
#define EAP_TLS_H
|
||||
|
||||
#include "eap_i.h"
|
||||
#include "eap_common.h"
|
||||
#include "eap.h"
|
||||
#include "wpa/wpabuf.h"
|
||||
|
||||
void * eap_tls_init(struct eap_sm *sm);
|
||||
void eap_tls_deinit(struct eap_sm *sm, void *priv);
|
||||
struct wpabuf * eap_tls_process(struct eap_sm *sm, void *priv,
|
||||
struct eap_method_ret *ret,
|
||||
const struct wpabuf *reqData);
|
||||
|
||||
u8 * eap_tls_getKey(struct eap_sm *sm, void *priv, size_t *len);
|
||||
|
||||
#endif /* EAP_TLS_H */
|
131
tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap_tls_common.h
Normal file
131
tools/sdk/include/wpa_supplicant/wpa2/eap_peer/eap_tls_common.h
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* EAP peer: EAP-TLS/PEAP/TTLS/FAST common functions
|
||||
* Copyright (c) 2004-2009, 2012, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_TLS_COMMON_H
|
||||
#define EAP_TLS_COMMON_H
|
||||
|
||||
/**
|
||||
* struct eap_ssl_data - TLS data for EAP methods
|
||||
*/
|
||||
struct eap_ssl_data {
|
||||
/**
|
||||
* conn - TLS connection context data from tls_connection_init()
|
||||
*/
|
||||
struct tls_connection *conn;
|
||||
|
||||
/**
|
||||
* tls_out - TLS message to be sent out in fragments
|
||||
*/
|
||||
struct wpabuf *tls_out;
|
||||
|
||||
/**
|
||||
* tls_out_pos - The current position in the outgoing TLS message
|
||||
*/
|
||||
size_t tls_out_pos;
|
||||
|
||||
/**
|
||||
* tls_out_limit - Maximum fragment size for outgoing TLS messages
|
||||
*/
|
||||
size_t tls_out_limit;
|
||||
|
||||
/**
|
||||
* tls_in - Received TLS message buffer for re-assembly
|
||||
*/
|
||||
struct wpabuf *tls_in;
|
||||
|
||||
/**
|
||||
* tls_in_left - Number of remaining bytes in the incoming TLS message
|
||||
*/
|
||||
size_t tls_in_left;
|
||||
|
||||
/**
|
||||
* tls_in_total - Total number of bytes in the incoming TLS message
|
||||
*/
|
||||
size_t tls_in_total;
|
||||
|
||||
/**
|
||||
* phase2 - Whether this TLS connection is used in EAP phase 2 (tunnel)
|
||||
*/
|
||||
int phase2;
|
||||
|
||||
/**
|
||||
* include_tls_length - Whether the TLS length field is included even
|
||||
* if the TLS data is not fragmented
|
||||
*/
|
||||
int include_tls_length;
|
||||
|
||||
/**
|
||||
* eap - EAP state machine allocated with eap_peer_sm_init()
|
||||
*/
|
||||
struct eap_sm *eap;
|
||||
|
||||
/**
|
||||
* ssl_ctx - TLS library context to use for the connection
|
||||
*/
|
||||
void *ssl_ctx;
|
||||
|
||||
/**
|
||||
* eap_type - EAP method used in Phase 1 (EAP_TYPE_TLS/PEAP/TTLS/FAST)
|
||||
*/
|
||||
u8 eap_type;
|
||||
};
|
||||
|
||||
|
||||
/* EAP TLS Flags */
|
||||
#define EAP_TLS_FLAGS_LENGTH_INCLUDED 0x80
|
||||
#define EAP_TLS_FLAGS_MORE_FRAGMENTS 0x40
|
||||
#define EAP_TLS_FLAGS_START 0x20
|
||||
#define EAP_TLS_VERSION_MASK 0x07
|
||||
|
||||
/* could be up to 128 bytes, but only the first 64 bytes are used */
|
||||
#define EAP_TLS_KEY_LEN 64
|
||||
|
||||
/* dummy type used as a flag for UNAUTH-TLS */
|
||||
#define EAP_UNAUTH_TLS_TYPE 255
|
||||
|
||||
|
||||
int eap_peer_tls_ssl_init(struct eap_sm *sm, struct eap_ssl_data *data,
|
||||
struct eap_peer_config *config, u8 eap_type);
|
||||
void eap_peer_tls_ssl_deinit(struct eap_sm *sm, struct eap_ssl_data *data);
|
||||
u8 * eap_peer_tls_derive_key(struct eap_sm *sm, struct eap_ssl_data *data,
|
||||
const char *label, size_t len);
|
||||
u8 * eap_peer_tls_derive_session_id(struct eap_sm *sm,
|
||||
struct eap_ssl_data *data, u8 eap_type,
|
||||
size_t *len);
|
||||
int eap_peer_tls_process_helper(struct eap_sm *sm, struct eap_ssl_data *data,
|
||||
EapType eap_type, int peap_version,
|
||||
u8 id, const u8 *in_data, size_t in_len,
|
||||
struct wpabuf **out_data);
|
||||
struct wpabuf * eap_peer_tls_build_ack(u8 id, EapType eap_type,
|
||||
int peap_version);
|
||||
int eap_peer_tls_reauth_init(struct eap_sm *sm, struct eap_ssl_data *data);
|
||||
int eap_peer_tls_status(struct eap_sm *sm, struct eap_ssl_data *data,
|
||||
char *buf, size_t buflen, int verbose);
|
||||
const u8 * eap_peer_tls_process_init(struct eap_sm *sm,
|
||||
struct eap_ssl_data *data,
|
||||
EapType eap_type,
|
||||
struct eap_method_ret *ret,
|
||||
const struct wpabuf *reqData,
|
||||
size_t *len, u8 *flags);
|
||||
void eap_peer_tls_reset_input(struct eap_ssl_data *data);
|
||||
void eap_peer_tls_reset_output(struct eap_ssl_data *data);
|
||||
int eap_peer_tls_decrypt(struct eap_sm *sm, struct eap_ssl_data *data,
|
||||
const struct wpabuf *in_data,
|
||||
struct wpabuf **in_decrypted);
|
||||
int eap_peer_tls_encrypt(struct eap_sm *sm, struct eap_ssl_data *data,
|
||||
EapType eap_type, int peap_version, u8 id,
|
||||
const struct wpabuf *in_data,
|
||||
struct wpabuf **out_data);
|
||||
int eap_peer_select_phase2_methods(struct eap_peer_config *config,
|
||||
const char *prefix,
|
||||
struct eap_method_type **types,
|
||||
size_t *num_types);
|
||||
int eap_peer_tls_phase2_nak(struct eap_method_type *types, size_t num_types,
|
||||
struct eap_hdr *hdr, struct wpabuf **resp);
|
||||
|
||||
#endif /* EAP_TLS_COMMON_H */
|
66
tools/sdk/include/wpa_supplicant/wpa2/tls/asn1.h
Normal file
66
tools/sdk/include/wpa_supplicant/wpa2/tls/asn1.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* ASN.1 DER parsing
|
||||
* Copyright (c) 2006, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef ASN1_H
|
||||
#define ASN1_H
|
||||
|
||||
#define ASN1_TAG_EOC 0x00 /* not used with DER */
|
||||
#define ASN1_TAG_BOOLEAN 0x01
|
||||
#define ASN1_TAG_INTEGER 0x02
|
||||
#define ASN1_TAG_BITSTRING 0x03
|
||||
#define ASN1_TAG_OCTETSTRING 0x04
|
||||
#define ASN1_TAG_NULL 0x05
|
||||
#define ASN1_TAG_OID 0x06
|
||||
#define ASN1_TAG_OBJECT_DESCRIPTOR 0x07 /* not yet parsed */
|
||||
#define ASN1_TAG_EXTERNAL 0x08 /* not yet parsed */
|
||||
#define ASN1_TAG_REAL 0x09 /* not yet parsed */
|
||||
#define ASN1_TAG_ENUMERATED 0x0A /* not yet parsed */
|
||||
#define ASN1_TAG_UTF8STRING 0x0C /* not yet parsed */
|
||||
#define ANS1_TAG_RELATIVE_OID 0x0D
|
||||
#define ASN1_TAG_SEQUENCE 0x10 /* shall be constructed */
|
||||
#define ASN1_TAG_SET 0x11
|
||||
#define ASN1_TAG_NUMERICSTRING 0x12 /* not yet parsed */
|
||||
#define ASN1_TAG_PRINTABLESTRING 0x13
|
||||
#define ASN1_TAG_TG1STRING 0x14 /* not yet parsed */
|
||||
#define ASN1_TAG_VIDEOTEXSTRING 0x15 /* not yet parsed */
|
||||
#define ASN1_TAG_IA5STRING 0x16
|
||||
#define ASN1_TAG_UTCTIME 0x17
|
||||
#define ASN1_TAG_GENERALIZEDTIME 0x18 /* not yet parsed */
|
||||
#define ASN1_TAG_GRAPHICSTRING 0x19 /* not yet parsed */
|
||||
#define ASN1_TAG_VISIBLESTRING 0x1A
|
||||
#define ASN1_TAG_GENERALSTRING 0x1B /* not yet parsed */
|
||||
#define ASN1_TAG_UNIVERSALSTRING 0x1C /* not yet parsed */
|
||||
#define ASN1_TAG_BMPSTRING 0x1D /* not yet parsed */
|
||||
|
||||
#define ASN1_CLASS_UNIVERSAL 0
|
||||
#define ASN1_CLASS_APPLICATION 1
|
||||
#define ASN1_CLASS_CONTEXT_SPECIFIC 2
|
||||
#define ASN1_CLASS_PRIVATE 3
|
||||
|
||||
|
||||
struct asn1_hdr {
|
||||
const u8 *payload;
|
||||
u8 identifier, class, constructed;
|
||||
unsigned int tag, length;
|
||||
};
|
||||
|
||||
#define ASN1_MAX_OID_LEN 20
|
||||
struct asn1_oid {
|
||||
unsigned long oid[ASN1_MAX_OID_LEN];
|
||||
size_t len;
|
||||
};
|
||||
|
||||
|
||||
int asn1_get_next(const u8 *buf, size_t len, struct asn1_hdr *hdr);
|
||||
int asn1_parse_oid(const u8 *buf, size_t len, struct asn1_oid *oid);
|
||||
int asn1_get_oid(const u8 *buf, size_t len, struct asn1_oid *oid,
|
||||
const u8 **next);
|
||||
void asn1_oid_to_str(struct asn1_oid *oid, char *buf, size_t len);
|
||||
unsigned long asn1_bit_string_to_long(const u8 *buf, size_t len);
|
||||
|
||||
#endif /* ASN1_H */
|
38
tools/sdk/include/wpa_supplicant/wpa2/tls/bignum.h
Normal file
38
tools/sdk/include/wpa_supplicant/wpa2/tls/bignum.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Big number math
|
||||
* Copyright (c) 2006, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef BIGNUM_H
|
||||
#define BIGNUM_H
|
||||
|
||||
struct bignum;
|
||||
|
||||
struct bignum * bignum_init(void);
|
||||
void bignum_deinit(struct bignum *n);
|
||||
size_t bignum_get_unsigned_bin_len(struct bignum *n);
|
||||
int bignum_get_unsigned_bin(const struct bignum *n, u8 *buf, size_t *len);
|
||||
int bignum_set_unsigned_bin(struct bignum *n, const u8 *buf, size_t len);
|
||||
int bignum_cmp(const struct bignum *a, const struct bignum *b);
|
||||
int bignum_cmp_d(const struct bignum *a, unsigned long b);
|
||||
int bignum_add(const struct bignum *a, const struct bignum *b,
|
||||
struct bignum *c);
|
||||
int bignum_sub(const struct bignum *a, const struct bignum *b,
|
||||
struct bignum *c);
|
||||
int bignum_mul(const struct bignum *a, const struct bignum *b,
|
||||
struct bignum *c);
|
||||
int bignum_mulmod(const struct bignum *a, const struct bignum *b,
|
||||
const struct bignum *c, struct bignum *d);
|
||||
int bignum_exptmod(const struct bignum *a, const struct bignum *b,
|
||||
const struct bignum *c, struct bignum *d);
|
||||
|
||||
#endif /* BIGNUM_H */
|
3443
tools/sdk/include/wpa_supplicant/wpa2/tls/libtommath.h
Normal file
3443
tools/sdk/include/wpa_supplicant/wpa2/tls/libtommath.h
Normal file
File diff suppressed because it is too large
Load Diff
22
tools/sdk/include/wpa_supplicant/wpa2/tls/pkcs1.h
Normal file
22
tools/sdk/include/wpa_supplicant/wpa2/tls/pkcs1.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* PKCS #1 (RSA Encryption)
|
||||
* Copyright (c) 2006-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef PKCS1_H
|
||||
#define PKCS1_H
|
||||
|
||||
int pkcs1_encrypt(int block_type, struct crypto_rsa_key *key,
|
||||
int use_private, const u8 *in, size_t inlen,
|
||||
u8 *out, size_t *outlen);
|
||||
int pkcs1_v15_private_key_decrypt(struct crypto_rsa_key *key,
|
||||
const u8 *in, size_t inlen,
|
||||
u8 *out, size_t *outlen);
|
||||
int pkcs1_decrypt_public_key(struct crypto_rsa_key *key,
|
||||
const u8 *crypt, size_t crypt_len,
|
||||
u8 *plain, size_t *plain_len);
|
||||
|
||||
#endif /* PKCS1_H */
|
16
tools/sdk/include/wpa_supplicant/wpa2/tls/pkcs5.h
Normal file
16
tools/sdk/include/wpa_supplicant/wpa2/tls/pkcs5.h
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* PKCS #5 (Password-based Encryption)
|
||||
* Copyright (c) 2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef PKCS5_H
|
||||
#define PKCS5_H
|
||||
|
||||
u8 * pkcs5_decrypt(const u8 *enc_alg, size_t enc_alg_len,
|
||||
const u8 *enc_data, size_t enc_data_len,
|
||||
const char *passwd, size_t *data_len);
|
||||
|
||||
#endif /* PKCS5_H */
|
16
tools/sdk/include/wpa_supplicant/wpa2/tls/pkcs8.h
Normal file
16
tools/sdk/include/wpa_supplicant/wpa2/tls/pkcs8.h
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* PKCS #8 (Private-key information syntax)
|
||||
* Copyright (c) 2006-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef PKCS8_H
|
||||
#define PKCS8_H
|
||||
|
||||
struct crypto_private_key * pkcs8_key_import(const u8 *buf, size_t len);
|
||||
struct crypto_private_key *
|
||||
pkcs8_enc_key_import(const u8 *buf, size_t len, const char *passwd);
|
||||
|
||||
#endif /* PKCS8_H */
|
23
tools/sdk/include/wpa_supplicant/wpa2/tls/rsa.h
Normal file
23
tools/sdk/include/wpa_supplicant/wpa2/tls/rsa.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* RSA
|
||||
* Copyright (c) 2006, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef RSA_H
|
||||
#define RSA_H
|
||||
|
||||
struct crypto_rsa_key;
|
||||
|
||||
struct crypto_rsa_key *
|
||||
crypto_rsa_import_public_key(const u8 *buf, size_t len);
|
||||
struct crypto_rsa_key *
|
||||
crypto_rsa_import_private_key(const u8 *buf, size_t len);
|
||||
size_t crypto_rsa_get_modulus_len(struct crypto_rsa_key *key);
|
||||
int crypto_rsa_exptmod(const u8 *in, size_t inlen, u8 *out, size_t *outlen,
|
||||
struct crypto_rsa_key *key, int use_private);
|
||||
void crypto_rsa_free(struct crypto_rsa_key *key);
|
||||
|
||||
#endif /* RSA_H */
|
537
tools/sdk/include/wpa_supplicant/wpa2/tls/tls.h
Normal file
537
tools/sdk/include/wpa_supplicant/wpa2/tls/tls.h
Normal file
@ -0,0 +1,537 @@
|
||||
/*
|
||||
* SSL/TLS interface definition
|
||||
* Copyright (c) 2004-2013, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef TLS_H
|
||||
#define TLS_H
|
||||
|
||||
struct tls_connection;
|
||||
|
||||
struct tls_keys {
|
||||
const u8 *master_key; /* TLS master secret */
|
||||
size_t master_key_len;
|
||||
const u8 *client_random;
|
||||
size_t client_random_len;
|
||||
const u8 *server_random;
|
||||
size_t server_random_len;
|
||||
};
|
||||
|
||||
enum tls_event {
|
||||
TLS_CERT_CHAIN_SUCCESS,
|
||||
TLS_CERT_CHAIN_FAILURE,
|
||||
TLS_PEER_CERTIFICATE,
|
||||
TLS_ALERT
|
||||
};
|
||||
|
||||
/*
|
||||
* Note: These are used as identifier with external programs and as such, the
|
||||
* values must not be changed.
|
||||
*/
|
||||
enum tls_fail_reason {
|
||||
TLS_FAIL_UNSPECIFIED = 0,
|
||||
TLS_FAIL_UNTRUSTED = 1,
|
||||
TLS_FAIL_REVOKED = 2,
|
||||
TLS_FAIL_NOT_YET_VALID = 3,
|
||||
TLS_FAIL_EXPIRED = 4,
|
||||
TLS_FAIL_SUBJECT_MISMATCH = 5,
|
||||
TLS_FAIL_ALTSUBJECT_MISMATCH = 6,
|
||||
TLS_FAIL_BAD_CERTIFICATE = 7,
|
||||
TLS_FAIL_SERVER_CHAIN_PROBE = 8
|
||||
};
|
||||
|
||||
union tls_event_data {
|
||||
struct {
|
||||
int depth;
|
||||
const char *subject;
|
||||
enum tls_fail_reason reason;
|
||||
const char *reason_txt;
|
||||
const struct wpabuf *cert;
|
||||
} cert_fail;
|
||||
|
||||
struct {
|
||||
int depth;
|
||||
const char *subject;
|
||||
const struct wpabuf *cert;
|
||||
const u8 *hash;
|
||||
size_t hash_len;
|
||||
} peer_cert;
|
||||
|
||||
struct {
|
||||
int is_local;
|
||||
const char *type;
|
||||
const char *description;
|
||||
} alert;
|
||||
};
|
||||
|
||||
struct tls_config {
|
||||
const char *opensc_engine_path;
|
||||
const char *pkcs11_engine_path;
|
||||
const char *pkcs11_module_path;
|
||||
int fips_mode;
|
||||
int cert_in_cb;
|
||||
|
||||
void (*event_cb)(void *ctx, enum tls_event ev,
|
||||
union tls_event_data *data);
|
||||
void *cb_ctx;
|
||||
};
|
||||
|
||||
#define TLS_CONN_ALLOW_SIGN_RSA_MD5 BIT(0)
|
||||
#define TLS_CONN_DISABLE_TIME_CHECKS BIT(1)
|
||||
#define TLS_CONN_DISABLE_SESSION_TICKET BIT(2)
|
||||
#define TLS_CONN_REQUEST_OCSP BIT(3)
|
||||
#define TLS_CONN_REQUIRE_OCSP BIT(4)
|
||||
|
||||
/**
|
||||
* struct tls_connection_params - Parameters for TLS connection
|
||||
* @ca_cert: File or reference name for CA X.509 certificate in PEM or DER
|
||||
* format
|
||||
* @ca_cert_blob: ca_cert as inlined data or %NULL if not used
|
||||
* @ca_cert_blob_len: ca_cert_blob length
|
||||
* @ca_path: Path to CA certificates (OpenSSL specific)
|
||||
* @subject_match: String to match in the subject of the peer certificate or
|
||||
* %NULL to allow all subjects
|
||||
* @altsubject_match: String to match in the alternative subject of the peer
|
||||
* certificate or %NULL to allow all alternative subjects
|
||||
* @client_cert: File or reference name for client X.509 certificate in PEM or
|
||||
* DER format
|
||||
* @client_cert_blob: client_cert as inlined data or %NULL if not used
|
||||
* @client_cert_blob_len: client_cert_blob length
|
||||
* @private_key: File or reference name for client private key in PEM or DER
|
||||
* format (traditional format (RSA PRIVATE KEY) or PKCS#8 (PRIVATE KEY)
|
||||
* @private_key_blob: private_key as inlined data or %NULL if not used
|
||||
* @private_key_blob_len: private_key_blob length
|
||||
* @private_key_passwd: Passphrase for decrypted private key, %NULL if no
|
||||
* passphrase is used.
|
||||
* @dh_file: File name for DH/DSA data in PEM format, or %NULL if not used
|
||||
* @dh_blob: dh_file as inlined data or %NULL if not used
|
||||
* @dh_blob_len: dh_blob length
|
||||
* @engine: 1 = use engine (e.g., a smartcard) for private key operations
|
||||
* (this is OpenSSL specific for now)
|
||||
* @engine_id: engine id string (this is OpenSSL specific for now)
|
||||
* @ppin: pointer to the pin variable in the configuration
|
||||
* (this is OpenSSL specific for now)
|
||||
* @key_id: the private key's id when using engine (this is OpenSSL
|
||||
* specific for now)
|
||||
* @cert_id: the certificate's id when using engine
|
||||
* @ca_cert_id: the CA certificate's id when using engine
|
||||
* @flags: Parameter options (TLS_CONN_*)
|
||||
* @ocsp_stapling_response: DER encoded file with cached OCSP stapling response
|
||||
* or %NULL if OCSP is not enabled
|
||||
*
|
||||
* TLS connection parameters to be configured with tls_connection_set_params()
|
||||
* and tls_global_set_params().
|
||||
*
|
||||
* Certificates and private key can be configured either as a reference name
|
||||
* (file path or reference to certificate store) or by providing the same data
|
||||
* as a pointer to the data in memory. Only one option will be used for each
|
||||
* field.
|
||||
*/
|
||||
struct tls_connection_params {
|
||||
const char *ca_cert;
|
||||
const u8 *ca_cert_blob;
|
||||
size_t ca_cert_blob_len;
|
||||
const char *ca_path;
|
||||
const char *subject_match;
|
||||
const char *altsubject_match;
|
||||
const char *client_cert;
|
||||
const u8 *client_cert_blob;
|
||||
size_t client_cert_blob_len;
|
||||
const char *private_key;
|
||||
const u8 *private_key_blob;
|
||||
size_t private_key_blob_len;
|
||||
const char *private_key_passwd;
|
||||
const char *dh_file;
|
||||
const u8 *dh_blob;
|
||||
size_t dh_blob_len;
|
||||
|
||||
/* OpenSSL specific variables */
|
||||
int engine;
|
||||
const char *engine_id;
|
||||
const char *pin;
|
||||
const char *key_id;
|
||||
const char *cert_id;
|
||||
const char *ca_cert_id;
|
||||
|
||||
unsigned int flags;
|
||||
const char *ocsp_stapling_response;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* tls_init - Initialize TLS library
|
||||
* @conf: Configuration data for TLS library
|
||||
* Returns: Context data to be used as tls_ctx in calls to other functions,
|
||||
* or %NULL on failure.
|
||||
*
|
||||
* Called once during program startup and once for each RSN pre-authentication
|
||||
* session. In other words, there can be two concurrent TLS contexts. If global
|
||||
* library initialization is needed (i.e., one that is shared between both
|
||||
* authentication types), the TLS library wrapper should maintain a reference
|
||||
* counter and do global initialization only when moving from 0 to 1 reference.
|
||||
*/
|
||||
void * tls_init(void);
|
||||
|
||||
/**
|
||||
* tls_deinit - Deinitialize TLS library
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
*
|
||||
* Called once during program shutdown and once for each RSN pre-authentication
|
||||
* session. If global library deinitialization is needed (i.e., one that is
|
||||
* shared between both authentication types), the TLS library wrapper should
|
||||
* maintain a reference counter and do global deinitialization only when moving
|
||||
* from 1 to 0 references.
|
||||
*/
|
||||
void tls_deinit(void *tls_ctx);
|
||||
|
||||
/**
|
||||
* tls_get_errors - Process pending errors
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* Returns: Number of found error, 0 if no errors detected.
|
||||
*
|
||||
* Process all pending TLS errors.
|
||||
*/
|
||||
int tls_get_errors(void *tls_ctx);
|
||||
|
||||
/**
|
||||
* tls_connection_init - Initialize a new TLS connection
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* Returns: Connection context data, conn for other function calls
|
||||
*/
|
||||
struct tls_connection * tls_connection_init(void *tls_ctx);
|
||||
|
||||
/**
|
||||
* tls_connection_deinit - Free TLS connection data
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
*
|
||||
* Release all resources allocated for TLS connection.
|
||||
*/
|
||||
void tls_connection_deinit(void *tls_ctx, struct tls_connection *conn);
|
||||
|
||||
/**
|
||||
* tls_connection_established - Has the TLS connection been completed?
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* Returns: 1 if TLS connection has been completed, 0 if not.
|
||||
*/
|
||||
int tls_connection_established(void *tls_ctx, struct tls_connection *conn);
|
||||
|
||||
/**
|
||||
* tls_connection_shutdown - Shutdown TLS connection
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* Shutdown current TLS connection without releasing all resources. New
|
||||
* connection can be started by using the same conn without having to call
|
||||
* tls_connection_init() or setting certificates etc. again. The new
|
||||
* connection should try to use session resumption.
|
||||
*/
|
||||
int tls_connection_shutdown(void *tls_ctx, struct tls_connection *conn);
|
||||
|
||||
enum {
|
||||
TLS_SET_PARAMS_ENGINE_PRV_VERIFY_FAILED = -3,
|
||||
TLS_SET_PARAMS_ENGINE_PRV_INIT_FAILED = -2
|
||||
};
|
||||
|
||||
/**
|
||||
* tls_connection_set_params - Set TLS connection parameters
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @params: Connection parameters
|
||||
* Returns: 0 on success, -1 on failure,
|
||||
* TLS_SET_PARAMS_ENGINE_PRV_INIT_FAILED (-2) on possible PIN error causing
|
||||
* PKCS#11 engine failure, or
|
||||
* TLS_SET_PARAMS_ENGINE_PRV_VERIFY_FAILED (-3) on failure to verify the
|
||||
* PKCS#11 engine private key.
|
||||
*/
|
||||
int __must_check
|
||||
tls_connection_set_params(void *tls_ctx, struct tls_connection *conn,
|
||||
const struct tls_connection_params *params);
|
||||
|
||||
/**
|
||||
* tls_global_set_params - Set TLS parameters for all TLS connection
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @params: Global TLS parameters
|
||||
* Returns: 0 on success, -1 on failure,
|
||||
* TLS_SET_PARAMS_ENGINE_PRV_INIT_FAILED (-2) on possible PIN error causing
|
||||
* PKCS#11 engine failure, or
|
||||
* TLS_SET_PARAMS_ENGINE_PRV_VERIFY_FAILED (-3) on failure to verify the
|
||||
* PKCS#11 engine private key.
|
||||
*/
|
||||
int __must_check tls_global_set_params(
|
||||
void *tls_ctx, const struct tls_connection_params *params);
|
||||
|
||||
/**
|
||||
* tls_global_set_verify - Set global certificate verification options
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @check_crl: 0 = do not verify CRLs, 1 = verify CRL for the user certificate,
|
||||
* 2 = verify CRL for all certificates
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int __must_check tls_global_set_verify(void *tls_ctx, int check_crl);
|
||||
|
||||
/**
|
||||
* tls_connection_set_verify - Set certificate verification options
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @verify_peer: 1 = verify peer certificate
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int __must_check tls_connection_set_verify(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
int verify_peer);
|
||||
|
||||
/**
|
||||
* tls_connection_get_keys - Get master key and random data from TLS connection
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @keys: Structure of key/random data (filled on success)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int __must_check tls_connection_get_keys(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
struct tls_keys *keys);
|
||||
|
||||
/**
|
||||
* tls_connection_prf - Use TLS-PRF to derive keying material
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @label: Label (e.g., description of the key) for PRF
|
||||
* @server_random_first: seed is 0 = client_random|server_random,
|
||||
* 1 = server_random|client_random
|
||||
* @out: Buffer for output data from TLS-PRF
|
||||
* @out_len: Length of the output buffer
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function is optional to implement if tls_connection_get_keys() provides
|
||||
* access to master secret and server/client random values. If these values are
|
||||
* not exported from the TLS library, tls_connection_prf() is required so that
|
||||
* further keying material can be derived from the master secret. If not
|
||||
* implemented, the function will still need to be defined, but it can just
|
||||
* return -1. Example implementation of this function is in tls_prf_sha1_md5()
|
||||
* when it is called with seed set to client_random|server_random (or
|
||||
* server_random|client_random).
|
||||
*/
|
||||
int __must_check tls_connection_prf(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
const char *label,
|
||||
int server_random_first,
|
||||
u8 *out, size_t out_len);
|
||||
|
||||
/**
|
||||
* tls_connection_handshake - Process TLS handshake (client side)
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @in_data: Input data from TLS server
|
||||
* @appl_data: Pointer to application data pointer, or %NULL if dropped
|
||||
* Returns: Output data, %NULL on failure
|
||||
*
|
||||
* The caller is responsible for freeing the returned output data. If the final
|
||||
* handshake message includes application data, this is decrypted and
|
||||
* appl_data (if not %NULL) is set to point this data. The caller is
|
||||
* responsible for freeing appl_data.
|
||||
*
|
||||
* This function is used during TLS handshake. The first call is done with
|
||||
* in_data == %NULL and the library is expected to return ClientHello packet.
|
||||
* This packet is then send to the server and a response from server is given
|
||||
* to TLS library by calling this function again with in_data pointing to the
|
||||
* TLS message from the server.
|
||||
*
|
||||
* If the TLS handshake fails, this function may return %NULL. However, if the
|
||||
* TLS library has a TLS alert to send out, that should be returned as the
|
||||
* output data. In this case, tls_connection_get_failed() must return failure
|
||||
* (> 0).
|
||||
*
|
||||
* tls_connection_established() should return 1 once the TLS handshake has been
|
||||
* completed successfully.
|
||||
*/
|
||||
struct wpabuf * tls_connection_handshake(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
const struct wpabuf *in_data,
|
||||
struct wpabuf **appl_data);
|
||||
|
||||
struct wpabuf * tls_connection_handshake2(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
const struct wpabuf *in_data,
|
||||
struct wpabuf **appl_data,
|
||||
int *more_data_needed);
|
||||
|
||||
/**
|
||||
* tls_connection_server_handshake - Process TLS handshake (server side)
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @in_data: Input data from TLS peer
|
||||
* @appl_data: Pointer to application data pointer, or %NULL if dropped
|
||||
* Returns: Output data, %NULL on failure
|
||||
*
|
||||
* The caller is responsible for freeing the returned output data.
|
||||
*/
|
||||
struct wpabuf * tls_connection_server_handshake(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
const struct wpabuf *in_data,
|
||||
struct wpabuf **appl_data);
|
||||
|
||||
/**
|
||||
* tls_connection_encrypt - Encrypt data into TLS tunnel
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @in_data: Plaintext data to be encrypted
|
||||
* Returns: Encrypted TLS data or %NULL on failure
|
||||
*
|
||||
* This function is used after TLS handshake has been completed successfully to
|
||||
* send data in the encrypted tunnel. The caller is responsible for freeing the
|
||||
* returned output data.
|
||||
*/
|
||||
struct wpabuf * tls_connection_encrypt(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
const struct wpabuf *in_data);
|
||||
|
||||
/**
|
||||
* tls_connection_decrypt - Decrypt data from TLS tunnel
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @in_data: Encrypted TLS data
|
||||
* Returns: Decrypted TLS data or %NULL on failure
|
||||
*
|
||||
* This function is used after TLS handshake has been completed successfully to
|
||||
* receive data from the encrypted tunnel. The caller is responsible for
|
||||
* freeing the returned output data.
|
||||
*/
|
||||
struct wpabuf * tls_connection_decrypt(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
const struct wpabuf *in_data);
|
||||
|
||||
struct wpabuf * tls_connection_decrypt2(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
const struct wpabuf *in_data,
|
||||
int *more_data_needed);
|
||||
|
||||
/**
|
||||
* tls_connection_resumed - Was session resumption used
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* Returns: 1 if current session used session resumption, 0 if not
|
||||
*/
|
||||
int tls_connection_resumed(void *tls_ctx, struct tls_connection *conn);
|
||||
|
||||
enum {
|
||||
TLS_CIPHER_NONE,
|
||||
TLS_CIPHER_RC4_SHA /* 0x0005 */,
|
||||
TLS_CIPHER_AES128_SHA /* 0x002f */,
|
||||
TLS_CIPHER_RSA_DHE_AES128_SHA /* 0x0031 */,
|
||||
TLS_CIPHER_ANON_DH_AES128_SHA /* 0x0034 */
|
||||
};
|
||||
|
||||
/**
|
||||
* tls_connection_set_cipher_list - Configure acceptable cipher suites
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @ciphers: Zero (TLS_CIPHER_NONE) terminated list of allowed ciphers
|
||||
* (TLS_CIPHER_*).
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int __must_check tls_connection_set_cipher_list(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
u8 *ciphers);
|
||||
|
||||
/**
|
||||
* tls_get_cipher - Get current cipher name
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @buf: Buffer for the cipher name
|
||||
* @buflen: buf size
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* Get the name of the currently used cipher.
|
||||
*/
|
||||
int __must_check tls_get_cipher(void *tls_ctx, struct tls_connection *conn,
|
||||
char *buf, size_t buflen);
|
||||
|
||||
/**
|
||||
* tls_connection_enable_workaround - Enable TLS workaround options
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function is used to enable connection-specific workaround options for
|
||||
* buffer SSL/TLS implementations.
|
||||
*/
|
||||
int __must_check tls_connection_enable_workaround(void *tls_ctx,
|
||||
struct tls_connection *conn);
|
||||
|
||||
/**
|
||||
* tls_connection_client_hello_ext - Set TLS extension for ClientHello
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @ext_type: Extension type
|
||||
* @data: Extension payload (%NULL to remove extension)
|
||||
* @data_len: Extension payload length
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int __must_check tls_connection_client_hello_ext(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
int ext_type, const u8 *data,
|
||||
size_t data_len);
|
||||
|
||||
/**
|
||||
* tls_connection_get_failed - Get connection failure status
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
*
|
||||
* Returns >0 if connection has failed, 0 if not.
|
||||
*/
|
||||
int tls_connection_get_failed(void *tls_ctx, struct tls_connection *conn);
|
||||
|
||||
/**
|
||||
* tls_connection_get_read_alerts - Get connection read alert status
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* Returns: Number of times a fatal read (remote end reported error) has
|
||||
* happened during this connection.
|
||||
*/
|
||||
int tls_connection_get_read_alerts(void *tls_ctx, struct tls_connection *conn);
|
||||
|
||||
/**
|
||||
* tls_connection_get_write_alerts - Get connection write alert status
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* Returns: Number of times a fatal write (locally detected error) has happened
|
||||
* during this connection.
|
||||
*/
|
||||
int tls_connection_get_write_alerts(void *tls_ctx,
|
||||
struct tls_connection *conn);
|
||||
|
||||
/**
|
||||
* tls_connection_get_keyblock_size - Get TLS key_block size
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* Returns: Size of the key_block for the negotiated cipher suite or -1 on
|
||||
* failure
|
||||
*/
|
||||
int tls_connection_get_keyblock_size(void *tls_ctx,
|
||||
struct tls_connection *conn);
|
||||
|
||||
/**
|
||||
* tls_capabilities - Get supported TLS capabilities
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* Returns: Bit field of supported TLS capabilities (TLS_CAPABILITY_*)
|
||||
*/
|
||||
unsigned int tls_capabilities(void *tls_ctx);
|
||||
|
||||
typedef int (*tls_session_ticket_cb)
|
||||
(void *ctx, const u8 *ticket, size_t len, const u8 *client_random,
|
||||
const u8 *server_random, u8 *master_secret);
|
||||
|
||||
int __must_check tls_connection_set_session_ticket_cb(
|
||||
void *tls_ctx, struct tls_connection *conn,
|
||||
tls_session_ticket_cb cb, void *ctx);
|
||||
|
||||
int tls_prf_sha1_md5(const u8 *secret, size_t secret_len, const char *label,
|
||||
const u8 *seed, size_t seed_len, u8 *out, size_t outlen);
|
||||
|
||||
#endif /* TLS_H */
|
54
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_client.h
Normal file
54
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_client.h
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* TLS v1.0/v1.1/v1.2 client (RFC 2246, RFC 4346, RFC 5246)
|
||||
* Copyright (c) 2006-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef TLSV1_CLIENT_H
|
||||
#define TLSV1_CLIENT_H
|
||||
|
||||
#include "tlsv1_cred.h"
|
||||
|
||||
struct tlsv1_client;
|
||||
|
||||
int tlsv1_client_global_init(void);
|
||||
void tlsv1_client_global_deinit(void);
|
||||
struct tlsv1_client * tlsv1_client_init(void);
|
||||
void tlsv1_client_deinit(struct tlsv1_client *conn);
|
||||
int tlsv1_client_established(struct tlsv1_client *conn);
|
||||
int tlsv1_client_prf(struct tlsv1_client *conn, const char *label,
|
||||
int server_random_first, u8 *out, size_t out_len);
|
||||
u8 * tlsv1_client_handshake(struct tlsv1_client *conn,
|
||||
const u8 *in_data, size_t in_len,
|
||||
size_t *out_len, u8 **appl_data,
|
||||
size_t *appl_data_len, int *need_more_data);
|
||||
int tlsv1_client_encrypt(struct tlsv1_client *conn,
|
||||
const u8 *in_data, size_t in_len,
|
||||
u8 *out_data, size_t out_len);
|
||||
struct wpabuf * tlsv1_client_decrypt(struct tlsv1_client *conn,
|
||||
const u8 *in_data, size_t in_len,
|
||||
int *need_more_data);
|
||||
int tlsv1_client_get_cipher(struct tlsv1_client *conn, char *buf,
|
||||
size_t buflen);
|
||||
int tlsv1_client_shutdown(struct tlsv1_client *conn);
|
||||
int tlsv1_client_resumed(struct tlsv1_client *conn);
|
||||
int tlsv1_client_hello_ext(struct tlsv1_client *conn, int ext_type,
|
||||
const u8 *data, size_t data_len);
|
||||
int tlsv1_client_get_keys(struct tlsv1_client *conn, struct tls_keys *keys);
|
||||
int tlsv1_client_get_keyblock_size(struct tlsv1_client *conn);
|
||||
int tlsv1_client_set_cipher_list(struct tlsv1_client *conn, u8 *ciphers);
|
||||
int tlsv1_client_set_cred(struct tlsv1_client *conn,
|
||||
struct tlsv1_credentials *cred);
|
||||
void tlsv1_client_set_time_checks(struct tlsv1_client *conn, int enabled);
|
||||
|
||||
typedef int (*tlsv1_client_session_ticket_cb)
|
||||
(void *ctx, const u8 *ticket, size_t len, const u8 *client_random,
|
||||
const u8 *server_random, u8 *master_secret);
|
||||
|
||||
void tlsv1_client_set_session_ticket_cb(struct tlsv1_client *conn,
|
||||
tlsv1_client_session_ticket_cb cb,
|
||||
void *ctx);
|
||||
|
||||
#endif /* TLSV1_CLIENT_H */
|
84
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_client_i.h
Normal file
84
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_client_i.h
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* TLSv1 client - internal structures
|
||||
* Copyright (c) 2006-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef TLSV1_CLIENT_I_H
|
||||
#define TLSV1_CLIENT_I_H
|
||||
|
||||
struct tlsv1_client {
|
||||
enum {
|
||||
CLIENT_HELLO, SERVER_HELLO, SERVER_CERTIFICATE,
|
||||
SERVER_KEY_EXCHANGE, SERVER_CERTIFICATE_REQUEST,
|
||||
SERVER_HELLO_DONE, CLIENT_KEY_EXCHANGE, CHANGE_CIPHER_SPEC,
|
||||
SERVER_CHANGE_CIPHER_SPEC, SERVER_FINISHED, ACK_FINISHED,
|
||||
ESTABLISHED, FAILED
|
||||
} state;
|
||||
|
||||
struct tlsv1_record_layer rl;
|
||||
|
||||
u8 session_id[TLS_SESSION_ID_MAX_LEN];
|
||||
size_t session_id_len;
|
||||
u8 client_random[TLS_RANDOM_LEN];
|
||||
u8 server_random[TLS_RANDOM_LEN];
|
||||
u8 master_secret[TLS_MASTER_SECRET_LEN];
|
||||
|
||||
u8 alert_level;
|
||||
u8 alert_description;
|
||||
|
||||
unsigned int certificate_requested:1;
|
||||
unsigned int session_resumed:1;
|
||||
unsigned int session_ticket_included:1;
|
||||
unsigned int use_session_ticket:1;
|
||||
unsigned int disable_time_checks:1;
|
||||
|
||||
struct crypto_public_key *server_rsa_key;
|
||||
|
||||
struct tls_verify_hash verify;
|
||||
|
||||
#define MAX_CIPHER_COUNT 30
|
||||
u16 cipher_suites[MAX_CIPHER_COUNT];
|
||||
size_t num_cipher_suites;
|
||||
|
||||
u16 prev_cipher_suite;
|
||||
|
||||
u8 *client_hello_ext;
|
||||
size_t client_hello_ext_len;
|
||||
|
||||
/* The prime modulus used for Diffie-Hellman */
|
||||
u8 *dh_p;
|
||||
size_t dh_p_len;
|
||||
/* The generator used for Diffie-Hellman */
|
||||
u8 *dh_g;
|
||||
size_t dh_g_len;
|
||||
/* The server's Diffie-Hellman public value */
|
||||
u8 *dh_ys;
|
||||
size_t dh_ys_len;
|
||||
|
||||
struct tlsv1_credentials *cred;
|
||||
|
||||
tlsv1_client_session_ticket_cb session_ticket_cb;
|
||||
void *session_ticket_cb_ctx;
|
||||
|
||||
struct wpabuf *partial_input;
|
||||
};
|
||||
|
||||
|
||||
void tls_alert(struct tlsv1_client *conn, u8 level, u8 description);
|
||||
void tlsv1_client_free_dh(struct tlsv1_client *conn);
|
||||
int tls_derive_pre_master_secret(u8 *pre_master_secret);
|
||||
int tls_derive_keys(struct tlsv1_client *conn,
|
||||
const u8 *pre_master_secret, size_t pre_master_secret_len);
|
||||
u8 * tls_send_client_hello(struct tlsv1_client *conn, size_t *out_len);
|
||||
u8 * tlsv1_client_send_alert(struct tlsv1_client *conn, u8 level,
|
||||
u8 description, size_t *out_len);
|
||||
u8 * tlsv1_client_handshake_write(struct tlsv1_client *conn, size_t *out_len,
|
||||
int no_appl_data);
|
||||
int tlsv1_client_process_handshake(struct tlsv1_client *conn, u8 ct,
|
||||
const u8 *buf, size_t *len,
|
||||
u8 **out_data, size_t *out_len);
|
||||
|
||||
#endif /* TLSV1_CLIENT_I_H */
|
261
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_common.h
Normal file
261
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_common.h
Normal file
@ -0,0 +1,261 @@
|
||||
/*
|
||||
* TLSv1 common definitions
|
||||
* Copyright (c) 2006-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef TLSV1_COMMON_H
|
||||
#define TLSV1_COMMON_H
|
||||
|
||||
#include "crypto/crypto.h"
|
||||
|
||||
#define TLS_VERSION_1 0x0301 /* TLSv1 */
|
||||
#define TLS_VERSION_1_1 0x0302 /* TLSv1.1 */
|
||||
#define TLS_VERSION_1_2 0x0303 /* TLSv1.2 */
|
||||
#ifdef CONFIG_TLSV12
|
||||
#define TLS_VERSION TLS_VERSION_1_2
|
||||
#else /* CONFIG_TLSV12 */
|
||||
#ifdef CONFIG_TLSV11
|
||||
#define TLS_VERSION TLS_VERSION_1_1
|
||||
#else /* CONFIG_TLSV11 */
|
||||
#define TLS_VERSION TLS_VERSION_1
|
||||
#endif /* CONFIG_TLSV11 */
|
||||
#endif /* CONFIG_TLSV12 */
|
||||
#define TLS_RANDOM_LEN 32
|
||||
#define TLS_PRE_MASTER_SECRET_LEN 48
|
||||
#define TLS_MASTER_SECRET_LEN 48
|
||||
#define TLS_SESSION_ID_MAX_LEN 32
|
||||
#define TLS_VERIFY_DATA_LEN 12
|
||||
|
||||
/* HandshakeType */
|
||||
enum {
|
||||
TLS_HANDSHAKE_TYPE_HELLO_REQUEST = 0,
|
||||
TLS_HANDSHAKE_TYPE_CLIENT_HELLO = 1,
|
||||
TLS_HANDSHAKE_TYPE_SERVER_HELLO = 2,
|
||||
TLS_HANDSHAKE_TYPE_NEW_SESSION_TICKET = 4 /* RFC 4507 */,
|
||||
TLS_HANDSHAKE_TYPE_CERTIFICATE = 11,
|
||||
TLS_HANDSHAKE_TYPE_SERVER_KEY_EXCHANGE = 12,
|
||||
TLS_HANDSHAKE_TYPE_CERTIFICATE_REQUEST = 13,
|
||||
TLS_HANDSHAKE_TYPE_SERVER_HELLO_DONE = 14,
|
||||
TLS_HANDSHAKE_TYPE_CERTIFICATE_VERIFY = 15,
|
||||
TLS_HANDSHAKE_TYPE_CLIENT_KEY_EXCHANGE = 16,
|
||||
TLS_HANDSHAKE_TYPE_FINISHED = 20,
|
||||
TLS_HANDSHAKE_TYPE_CERTIFICATE_URL = 21 /* RFC 4366 */,
|
||||
TLS_HANDSHAKE_TYPE_CERTIFICATE_STATUS = 22 /* RFC 4366 */
|
||||
};
|
||||
|
||||
/* CipherSuite */
|
||||
#define TLS_NULL_WITH_NULL_NULL 0x0000 /* RFC 2246 */
|
||||
#define TLS_RSA_WITH_NULL_MD5 0x0001 /* RFC 2246 */
|
||||
#define TLS_RSA_WITH_NULL_SHA 0x0002 /* RFC 2246 */
|
||||
#define TLS_RSA_EXPORT_WITH_RC4_40_MD5 0x0003 /* RFC 2246 */
|
||||
#define TLS_RSA_WITH_RC4_128_MD5 0x0004 /* RFC 2246 */
|
||||
#define TLS_RSA_WITH_RC4_128_SHA 0x0005 /* RFC 2246 */
|
||||
#define TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 0x0006 /* RFC 2246 */
|
||||
#define TLS_RSA_WITH_IDEA_CBC_SHA 0x0007 /* RFC 2246 */
|
||||
#define TLS_RSA_EXPORT_WITH_DES40_CBC_SHA 0x0008 /* RFC 2246 */
|
||||
#define TLS_RSA_WITH_DES_CBC_SHA 0x0009 /* RFC 2246 */
|
||||
#define TLS_RSA_WITH_3DES_EDE_CBC_SHA 0x000A /* RFC 2246 */
|
||||
#define TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA 0x000B /* RFC 2246 */
|
||||
#define TLS_DH_DSS_WITH_DES_CBC_SHA 0x000C /* RFC 2246 */
|
||||
#define TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA 0x000D /* RFC 2246 */
|
||||
#define TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA 0x000E /* RFC 2246 */
|
||||
#define TLS_DH_RSA_WITH_DES_CBC_SHA 0x000F /* RFC 2246 */
|
||||
#define TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA 0x0010 /* RFC 2246 */
|
||||
#define TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA 0x0011 /* RFC 2246 */
|
||||
#define TLS_DHE_DSS_WITH_DES_CBC_SHA 0x0012 /* RFC 2246 */
|
||||
#define TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA 0x0013 /* RFC 2246 */
|
||||
#define TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA 0x0014 /* RFC 2246 */
|
||||
#define TLS_DHE_RSA_WITH_DES_CBC_SHA 0x0015 /* RFC 2246 */
|
||||
#define TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA 0x0016 /* RFC 2246 */
|
||||
#define TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 0x0017 /* RFC 2246 */
|
||||
#define TLS_DH_anon_WITH_RC4_128_MD5 0x0018 /* RFC 2246 */
|
||||
#define TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA 0x0019 /* RFC 2246 */
|
||||
#define TLS_DH_anon_WITH_DES_CBC_SHA 0x001A /* RFC 2246 */
|
||||
#define TLS_DH_anon_WITH_3DES_EDE_CBC_SHA 0x001B /* RFC 2246 */
|
||||
#define TLS_RSA_WITH_AES_128_CBC_SHA 0x002F /* RFC 3268 */
|
||||
#define TLS_DH_DSS_WITH_AES_128_CBC_SHA 0x0030 /* RFC 3268 */
|
||||
#define TLS_DH_RSA_WITH_AES_128_CBC_SHA 0x0031 /* RFC 3268 */
|
||||
#define TLS_DHE_DSS_WITH_AES_128_CBC_SHA 0x0032 /* RFC 3268 */
|
||||
#define TLS_DHE_RSA_WITH_AES_128_CBC_SHA 0x0033 /* RFC 3268 */
|
||||
#define TLS_DH_anon_WITH_AES_128_CBC_SHA 0x0034 /* RFC 3268 */
|
||||
#define TLS_RSA_WITH_AES_256_CBC_SHA 0x0035 /* RFC 3268 */
|
||||
#define TLS_DH_DSS_WITH_AES_256_CBC_SHA 0x0036 /* RFC 3268 */
|
||||
#define TLS_DH_RSA_WITH_AES_256_CBC_SHA 0x0037 /* RFC 3268 */
|
||||
#define TLS_DHE_DSS_WITH_AES_256_CBC_SHA 0x0038 /* RFC 3268 */
|
||||
#define TLS_DHE_RSA_WITH_AES_256_CBC_SHA 0x0039 /* RFC 3268 */
|
||||
#define TLS_DH_anon_WITH_AES_256_CBC_SHA 0x003A /* RFC 3268 */
|
||||
#define TLS_RSA_WITH_NULL_SHA256 0x003B /* RFC 5246 */
|
||||
#define TLS_RSA_WITH_AES_128_CBC_SHA256 0x003C /* RFC 5246 */
|
||||
#define TLS_RSA_WITH_AES_256_CBC_SHA256 0x003D /* RFC 5246 */
|
||||
#define TLS_DH_DSS_WITH_AES_128_CBC_SHA256 0x003E /* RFC 5246 */
|
||||
#define TLS_DH_RSA_WITH_AES_128_CBC_SHA256 0x003F /* RFC 5246 */
|
||||
#define TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 0x0040 /* RFC 5246 */
|
||||
#define TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 0x0067 /* RFC 5246 */
|
||||
#define TLS_DH_DSS_WITH_AES_256_CBC_SHA256 0x0068 /* RFC 5246 */
|
||||
#define TLS_DH_RSA_WITH_AES_256_CBC_SHA256 0x0069 /* RFC 5246 */
|
||||
#define TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 0x006A /* RFC 5246 */
|
||||
#define TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 0x006B /* RFC 5246 */
|
||||
#define TLS_DH_anon_WITH_AES_128_CBC_SHA256 0x006C /* RFC 5246 */
|
||||
#define TLS_DH_anon_WITH_AES_256_CBC_SHA256 0x006D /* RFC 5246 */
|
||||
|
||||
/* CompressionMethod */
|
||||
#define TLS_COMPRESSION_NULL 0
|
||||
|
||||
/* HashAlgorithm */
|
||||
enum {
|
||||
TLS_HASH_ALG_NONE = 0,
|
||||
TLS_HASH_ALG_MD5 = 1,
|
||||
TLS_HASH_ALG_SHA1 = 2,
|
||||
TLS_HASH_ALG_SHA224 = 3,
|
||||
TLS_HASH_ALG_SHA256 = 4,
|
||||
TLS_HASH_ALG_SHA384 = 5,
|
||||
TLS_HASH_ALG_SHA512 = 6
|
||||
};
|
||||
|
||||
/* SignatureAlgorithm */
|
||||
enum {
|
||||
TLS_SIGN_ALG_ANONYMOUS = 0,
|
||||
TLS_SIGN_ALG_RSA = 1,
|
||||
TLS_SIGN_ALG_DSA = 2,
|
||||
TLS_SIGN_ALG_ECDSA = 3,
|
||||
};
|
||||
|
||||
/* AlertLevel */
|
||||
#define TLS_ALERT_LEVEL_WARNING 1
|
||||
#define TLS_ALERT_LEVEL_FATAL 2
|
||||
|
||||
/* AlertDescription */
|
||||
#define TLS_ALERT_CLOSE_NOTIFY 0
|
||||
#define TLS_ALERT_UNEXPECTED_MESSAGE 10
|
||||
#define TLS_ALERT_BAD_RECORD_MAC 20
|
||||
#define TLS_ALERT_DECRYPTION_FAILED 21
|
||||
#define TLS_ALERT_RECORD_OVERFLOW 22
|
||||
#define TLS_ALERT_DECOMPRESSION_FAILURE 30
|
||||
#define TLS_ALERT_HANDSHAKE_FAILURE 40
|
||||
#define TLS_ALERT_BAD_CERTIFICATE 42
|
||||
#define TLS_ALERT_UNSUPPORTED_CERTIFICATE 43
|
||||
#define TLS_ALERT_CERTIFICATE_REVOKED 44
|
||||
#define TLS_ALERT_CERTIFICATE_EXPIRED 45
|
||||
#define TLS_ALERT_CERTIFICATE_UNKNOWN 46
|
||||
#define TLS_ALERT_ILLEGAL_PARAMETER 47
|
||||
#define TLS_ALERT_UNKNOWN_CA 48
|
||||
#define TLS_ALERT_ACCESS_DENIED 49
|
||||
#define TLS_ALERT_DECODE_ERROR 50
|
||||
#define TLS_ALERT_DECRYPT_ERROR 51
|
||||
#define TLS_ALERT_EXPORT_RESTRICTION 60
|
||||
#define TLS_ALERT_PROTOCOL_VERSION 70
|
||||
#define TLS_ALERT_INSUFFICIENT_SECURITY 71
|
||||
#define TLS_ALERT_INTERNAL_ERROR 80
|
||||
#define TLS_ALERT_USER_CANCELED 90
|
||||
#define TLS_ALERT_NO_RENEGOTIATION 100
|
||||
#define TLS_ALERT_UNSUPPORTED_EXTENSION 110 /* RFC 4366 */
|
||||
#define TLS_ALERT_CERTIFICATE_UNOBTAINABLE 111 /* RFC 4366 */
|
||||
#define TLS_ALERT_UNRECOGNIZED_NAME 112 /* RFC 4366 */
|
||||
#define TLS_ALERT_BAD_CERTIFICATE_STATUS_RESPONSE 113 /* RFC 4366 */
|
||||
#define TLS_ALERT_BAD_CERTIFICATE_HASH_VALUE 114 /* RFC 4366 */
|
||||
|
||||
/* ChangeCipherSpec */
|
||||
enum {
|
||||
TLS_CHANGE_CIPHER_SPEC = 1
|
||||
};
|
||||
|
||||
/* TLS Extensions */
|
||||
#define TLS_EXT_SERVER_NAME 0 /* RFC 4366 */
|
||||
#define TLS_EXT_MAX_FRAGMENT_LENGTH 1 /* RFC 4366 */
|
||||
#define TLS_EXT_CLIENT_CERTIFICATE_URL 2 /* RFC 4366 */
|
||||
#define TLS_EXT_TRUSTED_CA_KEYS 3 /* RFC 4366 */
|
||||
#define TLS_EXT_TRUNCATED_HMAC 4 /* RFC 4366 */
|
||||
#define TLS_EXT_STATUS_REQUEST 5 /* RFC 4366 */
|
||||
#define TLS_EXT_SESSION_TICKET 35 /* RFC 4507 */
|
||||
|
||||
#define TLS_EXT_PAC_OPAQUE TLS_EXT_SESSION_TICKET /* EAP-FAST terminology */
|
||||
|
||||
|
||||
typedef enum {
|
||||
TLS_KEY_X_NULL,
|
||||
TLS_KEY_X_RSA,
|
||||
TLS_KEY_X_RSA_EXPORT,
|
||||
TLS_KEY_X_DH_DSS_EXPORT,
|
||||
TLS_KEY_X_DH_DSS,
|
||||
TLS_KEY_X_DH_RSA_EXPORT,
|
||||
TLS_KEY_X_DH_RSA,
|
||||
TLS_KEY_X_DHE_DSS_EXPORT,
|
||||
TLS_KEY_X_DHE_DSS,
|
||||
TLS_KEY_X_DHE_RSA_EXPORT,
|
||||
TLS_KEY_X_DHE_RSA,
|
||||
TLS_KEY_X_DH_anon_EXPORT,
|
||||
TLS_KEY_X_DH_anon
|
||||
} tls_key_exchange;
|
||||
|
||||
typedef enum {
|
||||
TLS_CIPHER_NULL,
|
||||
TLS_CIPHER_RC4_40,
|
||||
TLS_CIPHER_RC4_128,
|
||||
TLS_CIPHER_RC2_CBC_40,
|
||||
TLS_CIPHER_IDEA_CBC,
|
||||
TLS_CIPHER_DES40_CBC,
|
||||
TLS_CIPHER_DES_CBC,
|
||||
TLS_CIPHER_3DES_EDE_CBC,
|
||||
TLS_CIPHER_AES_128_CBC,
|
||||
TLS_CIPHER_AES_256_CBC
|
||||
} tls_cipher;
|
||||
|
||||
typedef enum {
|
||||
TLS_HASH_NULL,
|
||||
TLS_HASH_MD5,
|
||||
TLS_HASH_SHA,
|
||||
TLS_HASH_SHA256
|
||||
} tls_hash;
|
||||
|
||||
struct tls_cipher_suite {
|
||||
u16 suite;
|
||||
tls_key_exchange key_exchange;
|
||||
tls_cipher cipher;
|
||||
tls_hash hash;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
TLS_CIPHER_STREAM,
|
||||
TLS_CIPHER_BLOCK
|
||||
} tls_cipher_type;
|
||||
|
||||
struct tls_cipher_data {
|
||||
tls_cipher cipher;
|
||||
tls_cipher_type type;
|
||||
size_t key_material;
|
||||
size_t expanded_key_material;
|
||||
size_t block_size; /* also iv_size */
|
||||
enum crypto_cipher_alg alg;
|
||||
};
|
||||
|
||||
|
||||
struct tls_verify_hash {
|
||||
struct crypto_hash *md5_client;
|
||||
struct crypto_hash *sha1_client;
|
||||
struct crypto_hash *sha256_client;
|
||||
struct crypto_hash *md5_server;
|
||||
struct crypto_hash *sha1_server;
|
||||
struct crypto_hash *sha256_server;
|
||||
struct crypto_hash *md5_cert;
|
||||
struct crypto_hash *sha1_cert;
|
||||
struct crypto_hash *sha256_cert;
|
||||
};
|
||||
|
||||
|
||||
const struct tls_cipher_suite * tls_get_cipher_suite(u16 suite);
|
||||
const struct tls_cipher_data * tls_get_cipher_data(tls_cipher cipher);
|
||||
int tls_server_key_exchange_allowed(tls_cipher cipher);
|
||||
int tls_parse_cert(const u8 *buf, size_t len, struct crypto_public_key **pk);
|
||||
int tls_verify_hash_init(struct tls_verify_hash *verify);
|
||||
void tls_verify_hash_add(struct tls_verify_hash *verify, const u8 *buf,
|
||||
size_t len);
|
||||
void tls_verify_hash_free(struct tls_verify_hash *verify);
|
||||
int tls_version_ok(u16 ver);
|
||||
const char * tls_version_str(u16 ver);
|
||||
int tls_prf(u16 ver, const u8 *secret, size_t secret_len, const char *label,
|
||||
const u8 *seed, size_t seed_len, u8 *out, size_t outlen);
|
||||
|
||||
#endif /* TLSV1_COMMON_H */
|
40
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_cred.h
Normal file
40
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_cred.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* TLSv1 credentials
|
||||
* Copyright (c) 2006-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef TLSV1_CRED_H
|
||||
#define TLSV1_CRED_H
|
||||
|
||||
struct tlsv1_credentials {
|
||||
struct x509_certificate *trusted_certs;
|
||||
struct x509_certificate *cert;
|
||||
struct crypto_private_key *key;
|
||||
|
||||
/* Diffie-Hellman parameters */
|
||||
u8 *dh_p; /* prime */
|
||||
size_t dh_p_len;
|
||||
u8 *dh_g; /* generator */
|
||||
size_t dh_g_len;
|
||||
};
|
||||
|
||||
|
||||
struct tlsv1_credentials * tlsv1_cred_alloc(void);
|
||||
void tlsv1_cred_free(struct tlsv1_credentials *cred);
|
||||
int tlsv1_set_ca_cert(struct tlsv1_credentials *cred, const char *cert,
|
||||
const u8 *cert_blob, size_t cert_blob_len,
|
||||
const char *path);
|
||||
int tlsv1_set_cert(struct tlsv1_credentials *cred, const char *cert,
|
||||
const u8 *cert_blob, size_t cert_blob_len);
|
||||
int tlsv1_set_private_key(struct tlsv1_credentials *cred,
|
||||
const char *private_key,
|
||||
const char *private_key_passwd,
|
||||
const u8 *private_key_blob,
|
||||
size_t private_key_blob_len);
|
||||
int tlsv1_set_dhparams(struct tlsv1_credentials *cred, const char *dh_file,
|
||||
const u8 *dh_blob, size_t dh_blob_len);
|
||||
|
||||
#endif /* TLSV1_CRED_H */
|
71
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_record.h
Normal file
71
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_record.h
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* TLSv1 Record Protocol
|
||||
* Copyright (c) 2006-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef TLSV1_RECORD_H
|
||||
#define TLSV1_RECORD_H
|
||||
|
||||
#include "crypto/crypto.h"
|
||||
|
||||
#define TLS_MAX_WRITE_MAC_SECRET_LEN 32
|
||||
#define TLS_MAX_WRITE_KEY_LEN 32
|
||||
#define TLS_MAX_IV_LEN 16
|
||||
#define TLS_MAX_KEY_BLOCK_LEN (2 * (TLS_MAX_WRITE_MAC_SECRET_LEN + \
|
||||
TLS_MAX_WRITE_KEY_LEN + TLS_MAX_IV_LEN))
|
||||
|
||||
#define TLS_SEQ_NUM_LEN 8
|
||||
#define TLS_RECORD_HEADER_LEN 5
|
||||
|
||||
/* ContentType */
|
||||
enum {
|
||||
TLS_CONTENT_TYPE_CHANGE_CIPHER_SPEC = 20,
|
||||
TLS_CONTENT_TYPE_ALERT = 21,
|
||||
TLS_CONTENT_TYPE_HANDSHAKE = 22,
|
||||
TLS_CONTENT_TYPE_APPLICATION_DATA = 23
|
||||
};
|
||||
|
||||
struct tlsv1_record_layer {
|
||||
u16 tls_version;
|
||||
|
||||
u8 write_mac_secret[TLS_MAX_WRITE_MAC_SECRET_LEN];
|
||||
u8 read_mac_secret[TLS_MAX_WRITE_MAC_SECRET_LEN];
|
||||
u8 write_key[TLS_MAX_WRITE_KEY_LEN];
|
||||
u8 read_key[TLS_MAX_WRITE_KEY_LEN];
|
||||
u8 write_iv[TLS_MAX_IV_LEN];
|
||||
u8 read_iv[TLS_MAX_IV_LEN];
|
||||
|
||||
size_t hash_size;
|
||||
size_t key_material_len;
|
||||
size_t iv_size; /* also block_size */
|
||||
|
||||
enum crypto_hash_alg hash_alg;
|
||||
enum crypto_cipher_alg cipher_alg;
|
||||
|
||||
u8 write_seq_num[TLS_SEQ_NUM_LEN];
|
||||
u8 read_seq_num[TLS_SEQ_NUM_LEN];
|
||||
|
||||
u16 cipher_suite;
|
||||
u16 write_cipher_suite;
|
||||
u16 read_cipher_suite;
|
||||
|
||||
struct crypto_cipher *write_cbc;
|
||||
struct crypto_cipher *read_cbc;
|
||||
};
|
||||
|
||||
|
||||
int tlsv1_record_set_cipher_suite(struct tlsv1_record_layer *rl,
|
||||
u16 cipher_suite);
|
||||
int tlsv1_record_change_write_cipher(struct tlsv1_record_layer *rl);
|
||||
int tlsv1_record_change_read_cipher(struct tlsv1_record_layer *rl);
|
||||
int tlsv1_record_send(struct tlsv1_record_layer *rl, u8 content_type, u8 *buf,
|
||||
size_t buf_size, const u8 *payload, size_t payload_len,
|
||||
size_t *out_len);
|
||||
int tlsv1_record_receive(struct tlsv1_record_layer *rl,
|
||||
const u8 *in_data, size_t in_len,
|
||||
u8 *out_data, size_t *out_len, u8 *alert);
|
||||
|
||||
#endif /* TLSV1_RECORD_H */
|
48
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_server.h
Normal file
48
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_server.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* TLS v1.0/v1.1/v1.2 server (RFC 2246, RFC 4346, RFC 5246)
|
||||
* Copyright (c) 2006-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef TLSV1_SERVER_H
|
||||
#define TLSV1_SERVER_H
|
||||
|
||||
#include "tlsv1_cred.h"
|
||||
|
||||
struct tlsv1_server;
|
||||
|
||||
int tlsv1_server_global_init(void);
|
||||
void tlsv1_server_global_deinit(void);
|
||||
struct tlsv1_server * tlsv1_server_init(struct tlsv1_credentials *cred);
|
||||
void tlsv1_server_deinit(struct tlsv1_server *conn);
|
||||
int tlsv1_server_established(struct tlsv1_server *conn);
|
||||
int tlsv1_server_prf(struct tlsv1_server *conn, const char *label,
|
||||
int server_random_first, u8 *out, size_t out_len);
|
||||
u8 * tlsv1_server_handshake(struct tlsv1_server *conn,
|
||||
const u8 *in_data, size_t in_len, size_t *out_len);
|
||||
int tlsv1_server_encrypt(struct tlsv1_server *conn,
|
||||
const u8 *in_data, size_t in_len,
|
||||
u8 *out_data, size_t out_len);
|
||||
int tlsv1_server_decrypt(struct tlsv1_server *conn,
|
||||
const u8 *in_data, size_t in_len,
|
||||
u8 *out_data, size_t out_len);
|
||||
int tlsv1_server_get_cipher(struct tlsv1_server *conn, char *buf,
|
||||
size_t buflen);
|
||||
int tlsv1_server_shutdown(struct tlsv1_server *conn);
|
||||
int tlsv1_server_resumed(struct tlsv1_server *conn);
|
||||
int tlsv1_server_get_keys(struct tlsv1_server *conn, struct tls_keys *keys);
|
||||
int tlsv1_server_get_keyblock_size(struct tlsv1_server *conn);
|
||||
int tlsv1_server_set_cipher_list(struct tlsv1_server *conn, u8 *ciphers);
|
||||
int tlsv1_server_set_verify(struct tlsv1_server *conn, int verify_peer);
|
||||
|
||||
typedef int (*tlsv1_server_session_ticket_cb)
|
||||
(void *ctx, const u8 *ticket, size_t len, const u8 *client_random,
|
||||
const u8 *server_random, u8 *master_secret);
|
||||
|
||||
void tlsv1_server_set_session_ticket_cb(struct tlsv1_server *conn,
|
||||
tlsv1_server_session_ticket_cb cb,
|
||||
void *ctx);
|
||||
|
||||
#endif /* TLSV1_SERVER_H */
|
71
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_server_i.h
Normal file
71
tools/sdk/include/wpa_supplicant/wpa2/tls/tlsv1_server_i.h
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* TLSv1 server - internal structures
|
||||
* Copyright (c) 2006-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef TLSV1_SERVER_I_H
|
||||
#define TLSV1_SERVER_I_H
|
||||
|
||||
struct tlsv1_server {
|
||||
enum {
|
||||
CLIENT_HELLO, SERVER_HELLO, SERVER_CERTIFICATE,
|
||||
SERVER_KEY_EXCHANGE, SERVER_CERTIFICATE_REQUEST,
|
||||
SERVER_HELLO_DONE, CLIENT_CERTIFICATE, CLIENT_KEY_EXCHANGE,
|
||||
CERTIFICATE_VERIFY, CHANGE_CIPHER_SPEC, CLIENT_FINISHED,
|
||||
SERVER_CHANGE_CIPHER_SPEC, SERVER_FINISHED,
|
||||
ESTABLISHED, FAILED
|
||||
} state;
|
||||
|
||||
struct tlsv1_record_layer rl;
|
||||
|
||||
u8 session_id[TLS_SESSION_ID_MAX_LEN];
|
||||
size_t session_id_len;
|
||||
u8 client_random[TLS_RANDOM_LEN];
|
||||
u8 server_random[TLS_RANDOM_LEN];
|
||||
u8 master_secret[TLS_MASTER_SECRET_LEN];
|
||||
|
||||
u8 alert_level;
|
||||
u8 alert_description;
|
||||
|
||||
struct crypto_public_key *client_rsa_key;
|
||||
|
||||
struct tls_verify_hash verify;
|
||||
|
||||
#define MAX_CIPHER_COUNT 30
|
||||
u16 cipher_suites[MAX_CIPHER_COUNT];
|
||||
size_t num_cipher_suites;
|
||||
|
||||
u16 cipher_suite;
|
||||
|
||||
struct tlsv1_credentials *cred;
|
||||
|
||||
int verify_peer;
|
||||
u16 client_version;
|
||||
|
||||
u8 *session_ticket;
|
||||
size_t session_ticket_len;
|
||||
|
||||
tlsv1_server_session_ticket_cb session_ticket_cb;
|
||||
void *session_ticket_cb_ctx;
|
||||
|
||||
int use_session_ticket;
|
||||
|
||||
u8 *dh_secret;
|
||||
size_t dh_secret_len;
|
||||
};
|
||||
|
||||
|
||||
void tlsv1_server_alert(struct tlsv1_server *conn, u8 level, u8 description);
|
||||
int tlsv1_server_derive_keys(struct tlsv1_server *conn,
|
||||
const u8 *pre_master_secret,
|
||||
size_t pre_master_secret_len);
|
||||
u8 * tlsv1_server_handshake_write(struct tlsv1_server *conn, size_t *out_len);
|
||||
u8 * tlsv1_server_send_alert(struct tlsv1_server *conn, u8 level,
|
||||
u8 description, size_t *out_len);
|
||||
int tlsv1_server_process_handshake(struct tlsv1_server *conn, u8 ct,
|
||||
const u8 *buf, size_t *len);
|
||||
|
||||
#endif /* TLSV1_SERVER_I_H */
|
123
tools/sdk/include/wpa_supplicant/wpa2/tls/x509v3.h
Normal file
123
tools/sdk/include/wpa_supplicant/wpa2/tls/x509v3.h
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* X.509v3 certificate parsing and processing
|
||||
* Copyright (c) 2006-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef X509V3_H
|
||||
#define X509V3_H
|
||||
|
||||
#include "asn1.h"
|
||||
|
||||
struct x509_algorithm_identifier {
|
||||
struct asn1_oid oid;
|
||||
};
|
||||
|
||||
struct x509_name_attr {
|
||||
enum x509_name_attr_type {
|
||||
X509_NAME_ATTR_NOT_USED,
|
||||
X509_NAME_ATTR_DC,
|
||||
X509_NAME_ATTR_CN,
|
||||
X509_NAME_ATTR_C,
|
||||
X509_NAME_ATTR_L,
|
||||
X509_NAME_ATTR_ST,
|
||||
X509_NAME_ATTR_O,
|
||||
X509_NAME_ATTR_OU
|
||||
} type;
|
||||
char *value;
|
||||
};
|
||||
|
||||
#define X509_MAX_NAME_ATTRIBUTES 20
|
||||
|
||||
struct x509_name {
|
||||
struct x509_name_attr attr[X509_MAX_NAME_ATTRIBUTES];
|
||||
size_t num_attr;
|
||||
char *email; /* emailAddress */
|
||||
|
||||
/* from alternative name extension */
|
||||
char *alt_email; /* rfc822Name */
|
||||
char *dns; /* dNSName */
|
||||
char *uri; /* uniformResourceIdentifier */
|
||||
u8 *ip; /* iPAddress */
|
||||
size_t ip_len; /* IPv4: 4, IPv6: 16 */
|
||||
struct asn1_oid rid; /* registeredID */
|
||||
};
|
||||
|
||||
struct x509_certificate {
|
||||
struct x509_certificate *next;
|
||||
enum { X509_CERT_V1 = 0, X509_CERT_V2 = 1, X509_CERT_V3 = 2 } version;
|
||||
unsigned long serial_number;
|
||||
struct x509_algorithm_identifier signature;
|
||||
struct x509_name issuer;
|
||||
struct x509_name subject;
|
||||
os_time_t not_before;
|
||||
os_time_t not_after;
|
||||
struct x509_algorithm_identifier public_key_alg;
|
||||
u8 *public_key;
|
||||
size_t public_key_len;
|
||||
struct x509_algorithm_identifier signature_alg;
|
||||
u8 *sign_value;
|
||||
size_t sign_value_len;
|
||||
|
||||
/* Extensions */
|
||||
unsigned int extensions_present;
|
||||
#define X509_EXT_BASIC_CONSTRAINTS (1 << 0)
|
||||
#define X509_EXT_PATH_LEN_CONSTRAINT (1 << 1)
|
||||
#define X509_EXT_KEY_USAGE (1 << 2)
|
||||
#define X509_EXT_SUBJECT_ALT_NAME (1 << 3)
|
||||
#define X509_EXT_ISSUER_ALT_NAME (1 << 4)
|
||||
|
||||
/* BasicConstraints */
|
||||
int ca; /* cA */
|
||||
unsigned long path_len_constraint; /* pathLenConstraint */
|
||||
|
||||
/* KeyUsage */
|
||||
unsigned long key_usage;
|
||||
#define X509_KEY_USAGE_DIGITAL_SIGNATURE (1 << 0)
|
||||
#define X509_KEY_USAGE_NON_REPUDIATION (1 << 1)
|
||||
#define X509_KEY_USAGE_KEY_ENCIPHERMENT (1 << 2)
|
||||
#define X509_KEY_USAGE_DATA_ENCIPHERMENT (1 << 3)
|
||||
#define X509_KEY_USAGE_KEY_AGREEMENT (1 << 4)
|
||||
#define X509_KEY_USAGE_KEY_CERT_SIGN (1 << 5)
|
||||
#define X509_KEY_USAGE_CRL_SIGN (1 << 6)
|
||||
#define X509_KEY_USAGE_ENCIPHER_ONLY (1 << 7)
|
||||
#define X509_KEY_USAGE_DECIPHER_ONLY (1 << 8)
|
||||
|
||||
/*
|
||||
* The DER format certificate follows struct x509_certificate. These
|
||||
* pointers point to that buffer.
|
||||
*/
|
||||
const u8 *cert_start;
|
||||
size_t cert_len;
|
||||
const u8 *tbs_cert_start;
|
||||
size_t tbs_cert_len;
|
||||
};
|
||||
|
||||
enum {
|
||||
X509_VALIDATE_OK,
|
||||
X509_VALIDATE_BAD_CERTIFICATE,
|
||||
X509_VALIDATE_UNSUPPORTED_CERTIFICATE,
|
||||
X509_VALIDATE_CERTIFICATE_REVOKED,
|
||||
X509_VALIDATE_CERTIFICATE_EXPIRED,
|
||||
X509_VALIDATE_CERTIFICATE_UNKNOWN,
|
||||
X509_VALIDATE_UNKNOWN_CA
|
||||
};
|
||||
|
||||
void x509_certificate_free(struct x509_certificate *cert);
|
||||
struct x509_certificate * x509_certificate_parse(const u8 *buf, size_t len);
|
||||
void x509_name_string(struct x509_name *name, char *buf, size_t len);
|
||||
int x509_name_compare(struct x509_name *a, struct x509_name *b);
|
||||
void x509_certificate_chain_free(struct x509_certificate *cert);
|
||||
int x509_certificate_check_signature(struct x509_certificate *issuer,
|
||||
struct x509_certificate *cert);
|
||||
int x509_certificate_chain_validate(struct x509_certificate *trusted,
|
||||
struct x509_certificate *chain,
|
||||
int *reason, int disable_time_checks);
|
||||
struct x509_certificate *
|
||||
x509_certificate_get_subject(struct x509_certificate *chain,
|
||||
struct x509_name *name);
|
||||
int x509_certificate_self_signed(struct x509_certificate *cert);
|
||||
|
||||
#endif /* X509V3_H */
|
17
tools/sdk/include/wpa_supplicant/wpa2/utils/base64.h
Normal file
17
tools/sdk/include/wpa_supplicant/wpa2/utils/base64.h
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Base64 encoding/decoding (RFC1341)
|
||||
* Copyright (c) 2005, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef BASE64_H
|
||||
#define BASE64_H
|
||||
|
||||
unsigned char * _base64_encode(const unsigned char *src, size_t len,
|
||||
size_t *out_len);
|
||||
unsigned char * _base64_decode(const unsigned char *src, size_t len,
|
||||
size_t *out_len);
|
||||
|
||||
#endif /* BASE64_H */
|
33
tools/sdk/include/wpa_supplicant/wpa2/utils/ext_password.h
Normal file
33
tools/sdk/include/wpa_supplicant/wpa2/utils/ext_password.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* External password backend
|
||||
* Copyright (c) 2012, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EXT_PASSWORD_H
|
||||
#define EXT_PASSWORD_H
|
||||
|
||||
struct ext_password_data;
|
||||
|
||||
#ifdef CONFIG_EXT_PASSWORD
|
||||
|
||||
struct ext_password_data * ext_password_init(const char *backend,
|
||||
const char *params);
|
||||
void ext_password_deinit(struct ext_password_data *data);
|
||||
|
||||
struct wpabuf * ext_password_get(struct ext_password_data *data,
|
||||
const char *name);
|
||||
void ext_password_free(struct wpabuf *pw);
|
||||
|
||||
#else /* CONFIG_EXT_PASSWORD */
|
||||
|
||||
#define ext_password_init(b, p) ((void *) 1)
|
||||
#define ext_password_deinit(d) do { } while (0)
|
||||
#define ext_password_get(d, n) (NULL)
|
||||
#define ext_password_free(p) do { } while (0)
|
||||
|
||||
#endif /* CONFIG_EXT_PASSWORD */
|
||||
|
||||
#endif /* EXT_PASSWORD_H */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user