mirror of
https://github.com/sengeiou/realtek_ameba_mp_sdk.git
synced 2025-07-31 20:11:04 +00:00
ameba micropython sdk first commit
This commit is contained in:
commit
8508ee6139
5619 changed files with 1874619 additions and 0 deletions
BIN
sdk/ARCHIVE_LIB/btgap.a
Normal file
BIN
sdk/ARCHIVE_LIB/btgap.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/btmesh_dev.a
Normal file
BIN
sdk/ARCHIVE_LIB/btmesh_dev.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/btmesh_prov.a
Normal file
BIN
sdk/ARCHIVE_LIB/btmesh_prov.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_arduino.a
Executable file
BIN
sdk/ARCHIVE_LIB/lib_arduino.a
Executable file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_bt.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_bt.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_cmsis_dsp.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_cmsis_dsp.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_coap.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_coap.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_dct.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_dct.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_eap.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_eap.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_http2.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_http2.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_httpc.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_httpc.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_httpd.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_httpd.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_m4a_self.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_m4a_self.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_mdns.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_mdns.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_tftp.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_tftp.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_usbd.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_usbd.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_usbh.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_usbh.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_user.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_user.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_websocket.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_websocket.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_wifi_fw.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_wifi_fw.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_wifi_ucps_fw.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_wifi_ucps_fw.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_wlan.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_wlan.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_wlan_mp.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_wlan_mp.a
Normal file
Binary file not shown.
BIN
sdk/ARCHIVE_LIB/lib_wps.a
Normal file
BIN
sdk/ARCHIVE_LIB/lib_wps.a
Normal file
Binary file not shown.
5
sdk/component/common/api/at_cmd/atcmd_bt.h
Normal file
5
sdk/component/common/api/at_cmd/atcmd_bt.h
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#ifndef __ATCMD_BT_H__
|
||||
#define __ATCMD_BT_H__
|
||||
|
||||
#endif /* __ATCMD_BT_H__ */
|
||||
|
||||
12
sdk/component/common/api/at_cmd/atcmd_bt_ivt.h
Normal file
12
sdk/component/common/api/at_cmd/atcmd_bt_ivt.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef __ATCMD_BT_IVT_H__
|
||||
#define __ATCMD_BT_IVT_H__
|
||||
#include "bt_gatt.h"
|
||||
#include "bt_spp.h"
|
||||
|
||||
extern tBT_GattConnIF bt_peer_conn_if;
|
||||
extern tBT_SppConnIF spp_conn_if;
|
||||
extern tBT_GattConnIF gatt_initiator_conn;
|
||||
extern tBT_SppConnIF spp_client_conn;
|
||||
extern tBT_AddressStru bt_paring_dev;
|
||||
|
||||
#endif /* __ATCMD_BT_IVT_H__ */
|
||||
18
sdk/component/common/api/at_cmd/atcmd_fs.h
Normal file
18
sdk/component/common/api/at_cmd/atcmd_fs.h
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef __ATCMD_FS_H__
|
||||
#define __ATCMD_FS_H__
|
||||
|
||||
#include "diag.h"
|
||||
#define RTW_ENABLE_FATFS_INFO
|
||||
|
||||
#ifdef RTW_ENABLE_FATFS_INFO
|
||||
#define AT_INFO(fmt, args...) DBG_8195A("\r\n" fmt,## args)
|
||||
#define AT_ERROR(fmt, args...) DBG_8195A("\r\n" fmt,## args)
|
||||
#define AT_WARN(fmt, args...) DBG_8195A("\r\n" fmt,## args)
|
||||
#else
|
||||
#define AT_INFO(fmt, args...)
|
||||
#define AT_ERROR(fmt, args...) DBG_8195A("\r\n" fmt,## args)
|
||||
#define AT_WARN(fmt, args...)
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
0
sdk/component/common/api/at_cmd/atcmd_haier.h
Normal file
0
sdk/component/common/api/at_cmd/atcmd_haier.h
Normal file
5
sdk/component/common/api/at_cmd/atcmd_internal.h
Normal file
5
sdk/component/common/api/at_cmd/atcmd_internal.h
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#ifndef __ATCMD_SYS_H__
|
||||
#define __ATCMD_SYS_H__
|
||||
|
||||
|
||||
#endif
|
||||
106
sdk/component/common/api/at_cmd/atcmd_lwip.h
Normal file
106
sdk/component/common/api/at_cmd/atcmd_lwip.h
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
#ifndef __ATCMD_LWIP_H__
|
||||
#define __ATCMD_LWIP_H__
|
||||
|
||||
#include "main.h"
|
||||
#include "osdep_service.h"
|
||||
#include <lwip/opt.h>
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/api.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/igmp.h"
|
||||
#include "lwip/inet.h"
|
||||
#include "lwip/tcp.h"
|
||||
#include "lwip/raw.h"
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/tcpip.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/netdb.h"
|
||||
#include "lwip_netconf.h"
|
||||
|
||||
#define _AT_TRANSPORT_MODE_ "ATP1"
|
||||
#define _AT_TRANSPORT_LOCAL_PORT_ "ATP2"
|
||||
#define _AT_TRANSPORT_REMOTE_IP_ "ATP3"
|
||||
#define _AT_TRANSPORT_REMOTE_PORT_ "ATP4"
|
||||
#define _AT_TRANSPORT_START_SERVER_ "ATP5"
|
||||
#define _AT_TRANSPORT_START_CLIENT_ "ATP6"
|
||||
#define _AT_TRANSPORT_SHOW_SETTING_ "ATP?"
|
||||
#define _AT_TRANSPORT_RECEIVE_DATA_ "ATR0"
|
||||
#define _AT_TRANSPORT_RECEIVE_PACKET_SIZE_ "ATR1"
|
||||
#define _AT_TRANSPORT_WRITE_DATA_ "ATRA"
|
||||
#define _AT_TRANSPORT_WRITE_PACKET_SIZE_ "ATRB"
|
||||
|
||||
#define NODE_MODE_TCP 0
|
||||
#define NODE_MODE_UDP 1
|
||||
#define NODE_MODE_SSL 2
|
||||
|
||||
#define NODE_ROLE_SERVER 0
|
||||
#define NODE_ROLE_CLIENT 1
|
||||
#define NODE_ROLE_SEED 2
|
||||
|
||||
#define INVALID_SOCKET_ID (-1)
|
||||
|
||||
//parameters
|
||||
#ifndef NET_IF_NUM
|
||||
#define NET_IF_NUM 2
|
||||
#endif
|
||||
|
||||
#define ATCMD_LWIP_TASK_PRIORITY (tskIDLE_PRIORITY + 1)
|
||||
|
||||
#if ATCMD_VER == ATVER_2
|
||||
|
||||
#ifndef ATCMD_SUPPORT_SSL
|
||||
#define ATCMD_SUPPORT_SSL 0
|
||||
#endif
|
||||
|
||||
#define SERVER "127.0.0.1"
|
||||
|
||||
#define NUM_NS (MEMP_NUM_NETCONN) //maximum number of node and seed, same as NUM_SOCKETS
|
||||
|
||||
#define ETH_MAX_MTU 1500
|
||||
|
||||
#define INVALID_CON_ID (-1)
|
||||
|
||||
#define RECV_SELECT_TIMEOUT_SEC (0)
|
||||
#define RECV_SELECT_TIMEOUT_USEC (20000) //20ms
|
||||
|
||||
typedef struct ns
|
||||
{
|
||||
int con_id;
|
||||
int sockfd;
|
||||
s8_t role;
|
||||
int protocol;
|
||||
u32_t addr;
|
||||
u16_t port;
|
||||
u32_t local_addr;
|
||||
u16_t local_port;
|
||||
xTaskHandle handletask;
|
||||
struct ns* next;
|
||||
struct ns* nextseed;
|
||||
#if (ATCMD_VER == ATVER_2) && ATCMD_SUPPORT_SSL
|
||||
void *context;
|
||||
#endif
|
||||
} node;
|
||||
|
||||
extern xTaskHandle atcmd_lwip_tt_task;
|
||||
extern _sema atcmd_lwip_tt_sema;
|
||||
extern volatile int atcmd_lwip_tt_datasize;
|
||||
extern volatile int atcmd_lwip_tt_lasttickcnt;
|
||||
#define ATCMD_LWIP_TT_MAX_DELAY_TIME_MS (20) //transparent transmission interval
|
||||
|
||||
extern int atcmd_lwip_is_tt_mode(void);
|
||||
extern void atcmd_lwip_set_tt_mode(int enable);
|
||||
int atcmd_lwip_send_data(node *curnode, u8 *data, u16 data_sz, struct sockaddr_in cli_addr);
|
||||
int atcmd_lwip_receive_data(node *curnode, u8 *buffer, u16 buffer_size, int *recv_size,
|
||||
u8_t *udp_clientaddr, u16_t *udp_clientport);
|
||||
node* create_node(int mode, s8_t role);
|
||||
void init_node_pool(void);
|
||||
void delete_node(node *n);
|
||||
int hang_node(node* insert_node);
|
||||
int hang_seednode(node* main_node ,node* insert_node);
|
||||
node *seek_node(int con_id);
|
||||
node *tryget_node(int n);
|
||||
void atcmd_lwip_set_rx_buffer(unsigned char *buf, int bufsize);
|
||||
#endif
|
||||
|
||||
|
||||
#endif //#ifndef __ATCMD_LWIP_H__
|
||||
14
sdk/component/common/api/at_cmd/atcmd_mp.h
Normal file
14
sdk/component/common/api/at_cmd/atcmd_mp.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef __ATCMD_MP_H__
|
||||
#define __ATCMD_MP_H__
|
||||
|
||||
#define CONFIG_ATCMD_MP_EXT0 0 //support MP ext0 AT command
|
||||
#define CONFIG_ATCMD_MP_EXT1 0 //support MP ext1 AT command
|
||||
#define CONFIG_ATCMD_MP_EXT2 1 //support MP ext2 AT command
|
||||
|
||||
typedef struct _at_command_mp_ext_item_{
|
||||
char *mp_ext_cmd;
|
||||
int (*mp_ext_fun)(void **argv, int argc);
|
||||
char *mp_ext_usage;
|
||||
}at_mp_ext_item_t;
|
||||
|
||||
#endif
|
||||
5
sdk/component/common/api/at_cmd/atcmd_sys.h
Normal file
5
sdk/component/common/api/at_cmd/atcmd_sys.h
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#ifndef __ATCMD_SYS_H__
|
||||
#define __ATCMD_SYS_H__
|
||||
|
||||
|
||||
#endif
|
||||
253
sdk/component/common/api/at_cmd/atcmd_wifi.h
Normal file
253
sdk/component/common/api/at_cmd/atcmd_wifi.h
Normal file
|
|
@ -0,0 +1,253 @@
|
|||
#ifndef __ATCMD_WIFI_H__
|
||||
#define __ATCMD_WIFI_H__
|
||||
#include "main.h"
|
||||
#include "lwip_netconf.h"
|
||||
|
||||
#ifndef WLAN0_NAME
|
||||
#define WLAN0_NAME "wlan0"
|
||||
#endif
|
||||
#ifndef WLAN1_NAME
|
||||
#define WLAN1_NAME "wlan1"
|
||||
#endif
|
||||
/* Give default value if not defined */
|
||||
#ifndef NET_IF_NUM
|
||||
#ifdef CONFIG_CONCURRENT_MODE
|
||||
#define NET_IF_NUM ((CONFIG_ETHERNET) + (CONFIG_WLAN) + 1)
|
||||
#else
|
||||
#define NET_IF_NUM ((CONFIG_ETHERNET) + (CONFIG_WLAN))
|
||||
#endif // end of CONFIG_CONCURRENT_MODE
|
||||
#endif // end of NET_IF_NUM
|
||||
|
||||
/*Static IP ADDRESS*/
|
||||
#ifndef IP_ADDR0
|
||||
#define IP_ADDR0 192
|
||||
#define IP_ADDR1 168
|
||||
#define IP_ADDR2 1
|
||||
#define IP_ADDR3 80
|
||||
#endif
|
||||
|
||||
/*NETMASK*/
|
||||
#ifndef NETMASK_ADDR0
|
||||
#define NETMASK_ADDR0 255
|
||||
#define NETMASK_ADDR1 255
|
||||
#define NETMASK_ADDR2 255
|
||||
#define NETMASK_ADDR3 0
|
||||
#endif
|
||||
|
||||
/*Gateway Address*/
|
||||
#ifndef GW_ADDR0
|
||||
#define GW_ADDR0 192
|
||||
#define GW_ADDR1 168
|
||||
#define GW_ADDR2 1
|
||||
#define GW_ADDR3 1
|
||||
#endif
|
||||
|
||||
/*Static IP ADDRESS*/
|
||||
#ifndef AP_IP_ADDR0
|
||||
#define AP_IP_ADDR0 192
|
||||
#define AP_IP_ADDR1 168
|
||||
#define AP_IP_ADDR2 43
|
||||
#define AP_IP_ADDR3 1
|
||||
#endif
|
||||
|
||||
/*NETMASK*/
|
||||
#ifndef AP_NETMASK_ADDR0
|
||||
#define AP_NETMASK_ADDR0 255
|
||||
#define AP_NETMASK_ADDR1 255
|
||||
#define AP_NETMASK_ADDR2 255
|
||||
#define AP_NETMASK_ADDR3 0
|
||||
#endif
|
||||
|
||||
/*Gateway Address*/
|
||||
#ifndef AP_GW_ADDR0
|
||||
#define AP_GW_ADDR0 192
|
||||
#define AP_GW_ADDR1 168
|
||||
#define AP_GW_ADDR2 43
|
||||
#define AP_GW_ADDR3 1
|
||||
#endif
|
||||
|
||||
#if (defined(CONFIG_EXAMPLE_UART_ATCMD) && (CONFIG_EXAMPLE_UART_ATCMD))
|
||||
#include "wifi_structures.h"
|
||||
#include <wlan_fast_connect/example_wlan_fast_connect.h>
|
||||
typedef struct _UART_LOG_CONF_{
|
||||
u32 BaudRate;
|
||||
u8 DataBits;
|
||||
u8 StopBits;
|
||||
u8 Parity;
|
||||
u8 FlowControl;
|
||||
}UART_LOG_CONF, *PUART_LOG_CONF;
|
||||
|
||||
#define ATCMD_WIFI_CONN_STORE_MAX_NUM (1)
|
||||
struct atcmd_wifi_conf{
|
||||
int32_t auto_enable;
|
||||
rtw_wifi_setting_t setting;
|
||||
int32_t reconn_num;
|
||||
int32_t reconn_last_index;
|
||||
struct wlan_fast_reconnect reconn[ATCMD_WIFI_CONN_STORE_MAX_NUM];
|
||||
};
|
||||
|
||||
#define ATCMD_LWIP_CONN_STORE_MAX_NUM (1)
|
||||
struct atcmd_lwip_conn_info{
|
||||
int32_t role; //client, server or seed
|
||||
uint32_t protocol; //tcp or udp
|
||||
uint32_t remote_addr; //remote ip
|
||||
uint32_t remote_port; //remote port
|
||||
uint32_t local_addr; //locale ip, not used yet
|
||||
uint32_t local_port; //locale port, not used yet
|
||||
uint32_t reserved; //reserve for further use
|
||||
};
|
||||
struct atcmd_lwip_conf {
|
||||
int32_t enable; //enable or not
|
||||
int32_t conn_num;
|
||||
int32_t last_index;
|
||||
int32_t reserved; //reserve for further use
|
||||
struct atcmd_lwip_conn_info conn[ATCMD_LWIP_CONN_STORE_MAX_NUM];
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
AT_PARTITION_ALL = 0,
|
||||
AT_PARTITION_UART = 1,
|
||||
AT_PARTITION_WIFI = 2,
|
||||
AT_PARTITION_LWIP = 3
|
||||
} AT_PARTITION;
|
||||
|
||||
typedef enum {
|
||||
AT_PARTITION_READ = 0,
|
||||
AT_PARTITION_WRITE = 1,
|
||||
AT_PARTITION_ERASE = 2
|
||||
} AT_PARTITION_OP;
|
||||
|
||||
//first segment for uart
|
||||
#if !defined(UART_SETTING_BACKUP_SECTOR)
|
||||
#define UART_SETTING_BACKUP_SECTOR (0x8000)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_PLATFORM_8721D)
|
||||
#define UART_SETTING_BACKUP_SECTOR (0x2000)
|
||||
#endif
|
||||
|
||||
#define UART_CONF_DATA_OFFSET (0)
|
||||
#define UART_CONF_DATA_SIZE ((((sizeof(UART_LOG_CONF)-1)>>2) + 1)<<2)
|
||||
|
||||
//second segment for wifi config
|
||||
#define WIFI_CONF_DATA_OFFSET (UART_CONF_DATA_OFFSET+UART_CONF_DATA_SIZE)
|
||||
#define WIFI_CONF_DATA_SIZE ((((sizeof(struct atcmd_wifi_conf)-1)>>2) + 1)<<2)
|
||||
|
||||
//fouth segment for lwip config
|
||||
#define LWIP_CONF_DATA_OFFSET (WIFI_CONF_DATA_OFFSET+WIFI_CONF_DATA_SIZE)
|
||||
#define LWIP_CONF_DATA_SIZE ((((sizeof(struct atcmd_lwip_conf)-1)>>2) + 1)<<2)
|
||||
|
||||
extern void atcmd_update_partition_info(AT_PARTITION id, AT_PARTITION_OP ops, u8 *data, u16 len);
|
||||
|
||||
#define ATSTRING_LEN (LOG_SERVICE_BUFLEN)
|
||||
extern char at_string[ATSTRING_LEN];
|
||||
|
||||
extern unsigned char gAT_Echo; // default echo on
|
||||
//extern void uart_at_lock(void);
|
||||
//extern void uart_at_unlock(void);
|
||||
extern void uart_at_send_string(char *str);
|
||||
extern void uart_at_send_buf(u8 *buf, u32 len);
|
||||
|
||||
#define at_printf(fmt, args...) do{\
|
||||
/*uart_at_lock();*/\
|
||||
snprintf(at_string, ATSTRING_LEN, fmt, ##args); \
|
||||
uart_at_send_string(at_string);\
|
||||
/*uart_at_unlock();*/\
|
||||
}while(0)
|
||||
#define at_print_data(data, size) do{\
|
||||
/*uart_at_lock();*/\
|
||||
uart_at_send_buf(data, size);\
|
||||
/*uart_at_unlock();*/\
|
||||
}while(0)
|
||||
|
||||
#elif (defined(CONFIG_EXAMPLE_SPI_ATCMD) && (CONFIG_EXAMPLE_SPI_ATCMD))
|
||||
|
||||
#include "wifi_structures.h"
|
||||
#include <wlan_fast_connect/example_wlan_fast_connect.h>
|
||||
|
||||
typedef struct _SPI_LOG_CONF_{
|
||||
int frequency;
|
||||
int bits;
|
||||
int mode;
|
||||
}SPI_LOG_CONF, *PSPI_LOG_CONF;
|
||||
|
||||
#define ATCMD_WIFI_CONN_STORE_MAX_NUM (1)
|
||||
struct atcmd_wifi_conf{
|
||||
int32_t auto_enable;
|
||||
rtw_wifi_setting_t setting;
|
||||
int32_t reconn_num;
|
||||
int32_t reconn_last_index;
|
||||
struct wlan_fast_reconnect reconn[ATCMD_WIFI_CONN_STORE_MAX_NUM];
|
||||
};
|
||||
|
||||
#define ATCMD_LWIP_CONN_STORE_MAX_NUM (1)
|
||||
struct atcmd_lwip_conn_info{
|
||||
int32_t role; //client, server or seed
|
||||
uint32_t protocol; //tcp or udp
|
||||
uint32_t remote_addr; //remote ip
|
||||
uint32_t remote_port; //remote port
|
||||
uint32_t local_addr; //locale ip, not used yet
|
||||
uint32_t local_port; //locale port, not used yet
|
||||
uint32_t reserved; //reserve for further use
|
||||
};
|
||||
struct atcmd_lwip_conf {
|
||||
int32_t enable; //enable or not
|
||||
int32_t conn_num;
|
||||
int32_t last_index;
|
||||
int32_t reserved; //reserve for further use
|
||||
struct atcmd_lwip_conn_info conn[ATCMD_LWIP_CONN_STORE_MAX_NUM];
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
AT_PARTITION_ALL = 0,
|
||||
AT_PARTITION_SPI = 1,
|
||||
AT_PARTITION_WIFI = 2,
|
||||
AT_PARTITION_LWIP = 3
|
||||
} AT_PARTITION;
|
||||
|
||||
typedef enum {
|
||||
AT_PARTITION_READ = 0,
|
||||
AT_PARTITION_WRITE = 1,
|
||||
AT_PARTITION_ERASE = 2
|
||||
} AT_PARTITION_OP;
|
||||
|
||||
//first segment for uart
|
||||
#define SPI_SETTING_BACKUP_SECTOR (0x8000)
|
||||
#define SPI_CONF_DATA_OFFSET (0)
|
||||
#define SPI_CONF_DATA_SIZE ((((sizeof(SPI_LOG_CONF)-1)>>2) + 1)<<2)
|
||||
|
||||
//second segment for wifi config
|
||||
#define WIFI_CONF_DATA_OFFSET (SPI_CONF_DATA_OFFSET+SPI_CONF_DATA_SIZE)
|
||||
#define WIFI_CONF_DATA_SIZE ((((sizeof(struct atcmd_wifi_conf)-1)>>2) + 1)<<2)
|
||||
|
||||
//fouth segment for lwip config
|
||||
#define LWIP_CONF_DATA_OFFSET (WIFI_CONF_DATA_OFFSET+WIFI_CONF_DATA_SIZE)
|
||||
#define LWIP_CONF_DATA_SIZE ((((sizeof(struct atcmd_lwip_conf)-1)>>2) + 1)<<2)
|
||||
|
||||
extern void atcmd_update_partition_info(AT_PARTITION id, AT_PARTITION_OP ops, u8 *data, u16 len);
|
||||
|
||||
#define ATSTRING_LEN (LOG_SERVICE_BUFLEN)
|
||||
extern char at_string[ATSTRING_LEN];
|
||||
|
||||
extern void spi_at_send_string(char *str);
|
||||
extern void spi_at_send_buf(u8 *buf, u32 len);
|
||||
|
||||
#define at_printf(fmt, args...) do{\
|
||||
/*spi_at_lock();*/\
|
||||
snprintf(at_string, ATSTRING_LEN, fmt, ##args); \
|
||||
spi_at_send_string(at_string);\
|
||||
/*spi_at_unlock();*/\
|
||||
}while(0)
|
||||
#define at_print_data(data, size) do{\
|
||||
/*spi_at_lock();*/\
|
||||
spi_at_send_buf(data, size);\
|
||||
/*spi_at_unlock();*/\
|
||||
}while(0)
|
||||
|
||||
#else // #elif CONFIG_EXAMPLE_SPI_ATCMD
|
||||
|
||||
#define at_printf(fmt, args...) do{printf(fmt, ##args);}while(0)
|
||||
#define at_print_data(data, size) do{__rtl_memDump(data, size, NULL);}while(0)
|
||||
#endif//#if (defined(CONFIG_EXAMPLE_UART_ATCMD) && CONFIG_EXAMPLE_UART_ATCMD)
|
||||
|
||||
#endif
|
||||
128
sdk/component/common/api/at_cmd/log_service.h
Normal file
128
sdk/component/common/api/at_cmd/log_service.h
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
#ifndef LOG_SERVICE_H
|
||||
#define LOG_SERVICE_H
|
||||
|
||||
#include "dlist.h"
|
||||
/*
|
||||
* Include user defined options first. Anything not defined in these files
|
||||
* will be set to standard values. Override anything you dont like!
|
||||
*/
|
||||
#if defined(CONFIG_PLATFORM_8195A) || defined(CONFIG_PLATFORM_8711B) || defined(CONFIG_PLATFORM_8721D)|| defined(CONFIG_PLATFORM_8710C)
|
||||
#include "platform_opts.h"
|
||||
#include "platform_stdlib.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
//#ifdef __ICCARM__
|
||||
//#define STRINGIFY(s) #s
|
||||
//#define SECTION(_name) _Pragma( STRINGIFY(location=_name))
|
||||
//#define log_module_init(fn) \
|
||||
// SECTION(".data.log_init") __root static void* log_##fn = (void*)fn
|
||||
//#elif defined(__CC_ARM)
|
||||
//#define log_module_init(fn) \
|
||||
//static void* log_##fn __attribute__((section(".data.log_init"))) = (void*)fn;
|
||||
//#define DiagPrintf printf
|
||||
//#elif defined(__GNUC__)
|
||||
//#define log_module_init(fn) \
|
||||
//static void* log_##fn __attribute__((section(".data.log_init"))) = (void*)fn;
|
||||
//#else
|
||||
//#error "not implement"
|
||||
//#endif
|
||||
*/
|
||||
#define log_module_init(fn)
|
||||
|
||||
#define ATC_INDEX_NUM 32
|
||||
|
||||
#ifndef SUPPORT_LOG_SERVICE
|
||||
#define SUPPORT_LOG_SERVICE 1
|
||||
#endif
|
||||
|
||||
//LOG_SERVICE_BUFLEN: default, only 63 bytes could be used for keeping input
|
||||
// cmd, the last byte is for string end ('\0').
|
||||
#ifndef LOG_SERVICE_BUFLEN
|
||||
#define LOG_SERVICE_BUFLEN 64
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_LOG_HISTORY
|
||||
#define CONFIG_LOG_HISTORY 0
|
||||
#if CONFIG_LOG_HISTORY
|
||||
#define LOG_HISTORY_LEN 5
|
||||
#endif
|
||||
#endif //#ifndef CONFIG_LOG_HISTORY
|
||||
|
||||
#ifndef MAX_ARGC
|
||||
#define MAX_ARGC 18
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_LOG_SERVICE_LOCK
|
||||
#define CONFIG_LOG_SERVICE_LOCK 0 // //to protect log_buf[], only one command processed per time
|
||||
#endif
|
||||
|
||||
#define AT_BIT(n) (1<<n)
|
||||
#define AT_FLAG_DUMP AT_BIT(0)
|
||||
#define AT_FLAG_EDIT AT_BIT(1)
|
||||
#define AT_FLAG_ADC AT_BIT(2)
|
||||
#define AT_FLAG_GPIO AT_BIT(3)
|
||||
#define AT_FLAG_OTA AT_BIT(4)
|
||||
#define AT_FLAG_NFC AT_BIT(5)
|
||||
#define AT_FLAG_OS AT_BIT(6)
|
||||
#define AT_FLAG_LWIP AT_BIT(7)
|
||||
#define AT_FLAG_COMMON AT_BIT(8)
|
||||
#define AT_FLAG_WIFI AT_BIT(9)
|
||||
#define AT_FLAG_RDP AT_BIT(10)
|
||||
|
||||
enum{
|
||||
AT_DBG_OFF = 0,
|
||||
AT_DBG_ALWAYS,
|
||||
AT_DBG_ERROR,
|
||||
AT_DBG_WARNING,
|
||||
AT_DBG_INFO
|
||||
};
|
||||
|
||||
extern unsigned char gDbgLevel;
|
||||
extern unsigned int gDbgFlag;
|
||||
|
||||
#define AT_PRINTK(...) \
|
||||
do{ \
|
||||
printf(__VA_ARGS__); \
|
||||
printf("\r\n"); \
|
||||
}while(0)
|
||||
#define _AT_PRINTK(...) printf(__VA_ARGS__)
|
||||
#define AT_DBG_MSG(flag, level, ...) \
|
||||
do{ \
|
||||
if(((flag) & gDbgFlag) && (level <= gDbgLevel)){ \
|
||||
AT_PRINTK(__VA_ARGS__); \
|
||||
} \
|
||||
}while(0)
|
||||
#define _AT_DBG_MSG(flag, level, ...) \
|
||||
do{ \
|
||||
if(((flag) & gDbgFlag) && (level <= gDbgLevel)){ \
|
||||
_AT_PRINTK(__VA_ARGS__); \
|
||||
} \
|
||||
}while(0)
|
||||
|
||||
#ifndef SUPPORT_INTERACTIVE_MODE
|
||||
#define SUPPORT_INTERACTIVE_MODE 0
|
||||
#endif //#ifndef SUPPORT_INTERACTIVE_MODE
|
||||
|
||||
typedef void (*log_init_t)(void);
|
||||
typedef void (*log_act_t)(void*);
|
||||
typedef struct _at_command_item_{
|
||||
char *log_cmd;
|
||||
log_act_t at_act;
|
||||
struct list_head node;
|
||||
}log_item_t;
|
||||
|
||||
void log_service_add_table(log_item_t *tbl, int len);
|
||||
int parse_param(char *buf, char **argv);
|
||||
#if CONFIG_LOG_SERVICE_LOCK
|
||||
void log_service_lock_init(void);
|
||||
void log_service_lock(void);
|
||||
u32 log_service_lock_timeout(u32 ms);
|
||||
void log_service_unlock(void);
|
||||
#endif
|
||||
|
||||
#define C_NUM_AT_CMD 4 //"ATxx", 4 characters
|
||||
#define C_NUM_AT_CMD_DLT 1 //"=", 1 charater
|
||||
#define STR_END_OF_ATCMD_RET "\r\n\n# " //each AT command response will end with this string
|
||||
#define STR_END_OF_ATDATA_RET "\r\n\n> " //data transparent transmission indicator
|
||||
#endif
|
||||
85
sdk/component/common/api/lwip_netconf.h
Normal file
85
sdk/component/common/api/lwip_netconf.h
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*
|
||||
* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __NETCONF_H
|
||||
#define __NETCONF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "tcpip.h"
|
||||
#include "lwip/init.h" //for lwip version control
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <platform/platform_stdlib.h>
|
||||
#include "platform_opts.h"
|
||||
#include "autoconf.h"
|
||||
|
||||
#include "lwip/err.h"
|
||||
// macros
|
||||
/* Give default value if not defined */
|
||||
#ifndef NET_IF_NUM
|
||||
#ifdef CONFIG_CONCURRENT_MODE
|
||||
#define NET_IF_NUM ((CONFIG_ETHERNET) + (CONFIG_WLAN) + 1)
|
||||
#else
|
||||
#define NET_IF_NUM ((CONFIG_ETHERNET) + (CONFIG_WLAN))
|
||||
#endif // end of CONFIG_CONCURRENT_MODE
|
||||
#endif // end of NET_IF_NUM
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
DHCP_START=0,
|
||||
DHCP_WAIT_ADDRESS,
|
||||
DHCP_ADDRESS_ASSIGNED,
|
||||
DHCP_RELEASE_IP,
|
||||
DHCP_STOP,
|
||||
DHCP_TIMEOUT
|
||||
} DHCP_State_TypeDef;
|
||||
|
||||
/* Extern functions ------------------------------------------------------------*/
|
||||
void wifi_rx_beacon_hdl( char* buf, int buf_len, int flags, void* userdata);
|
||||
void rtw_wakelock_timeout(u32 timeoutms);
|
||||
/** Release a DHCP lease. */
|
||||
err_t dhcp_release_unicast(struct netif *netif);
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void LwIP_Init(void);
|
||||
void LwIP_ReleaseIP(uint8_t idx);
|
||||
uint8_t LwIP_DHCP(uint8_t idx, uint8_t dhcp_state);
|
||||
unsigned char* LwIP_GetMAC(struct netif *pnetif);
|
||||
unsigned char* LwIP_GetIP(struct netif *pnetif);
|
||||
unsigned char* LwIP_GetGW(struct netif *pnetif);
|
||||
uint8_t* LwIP_GetMASK(struct netif *pnetif);
|
||||
uint8_t* LwIP_GetBC(struct netif *pnetif);
|
||||
#if LWIP_DNS
|
||||
void LwIP_GetDNS(struct ip_addr* dns);
|
||||
void LwIP_SetDNS(struct ip_addr* dns);
|
||||
#endif
|
||||
void LwIP_UseStaticIP(struct netif *pnetif);
|
||||
#if LWIP_AUTOIP
|
||||
void LwIP_AUTOIP(struct netif *pnetif);
|
||||
#endif
|
||||
#if LWIP_IPV6
|
||||
void LwIP_AUTOIP_IPv6(struct netif *pnetif);
|
||||
#endif
|
||||
uint32_t LWIP_Get_Dynamic_Sleep_Interval(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __NETCONF_H */
|
||||
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
435
sdk/component/common/api/network/include/lwipopts.h
Normal file
435
sdk/component/common/api/network/include/lwipopts.h
Normal file
|
|
@ -0,0 +1,435 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*
|
||||
* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef LWIP_HDR_LWIPOPTS_H
|
||||
#define LWIP_HDR_LWIPOPTS_H
|
||||
|
||||
#include <platform/platform_stdlib.h>
|
||||
#include "platform_opts.h"
|
||||
#define WIFI_LOGO_CERTIFICATION_CONFIG 0 //for ping 10k test buffer setting
|
||||
|
||||
/**
|
||||
* SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
|
||||
* critical regions during buffer allocation, deallocation and memory
|
||||
* allocation and deallocation.
|
||||
*/
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
|
||||
/* Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores
|
||||
should be used instead */
|
||||
#define LWIP_COMPAT_MUTEX 1
|
||||
|
||||
#define ETHARP_TRUST_IP_MAC 0
|
||||
#define IP_REASSEMBLY 1
|
||||
#define IP_FRAG 1
|
||||
#define ARP_QUEUEING 0
|
||||
|
||||
/**
|
||||
* NO_SYS==1: Provides VERY minimal functionality. Otherwise,
|
||||
* use lwIP facilities.
|
||||
*/
|
||||
#define NO_SYS 0
|
||||
|
||||
#ifndef CONFIG_DYNAMIC_TICKLESS
|
||||
#define CONFIG_DYNAMIC_TICKLESS 0
|
||||
#endif
|
||||
|
||||
/* ---------- Memory options ---------- */
|
||||
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
|
||||
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
|
||||
byte alignment -> define MEM_ALIGNMENT to 2. */
|
||||
#define MEM_ALIGNMENT 4
|
||||
|
||||
/* MEM_SIZE: the size of the heap memory. If the application will send
|
||||
a lot of data that needs to be copied, this should be set high. */
|
||||
#if WIFI_LOGO_CERTIFICATION_CONFIG
|
||||
#define MEM_SIZE (10*1024) //for ping 10k test
|
||||
#elif CONFIG_ETHERNET
|
||||
#define MEM_SIZE (6*1024) //for iperf test
|
||||
#elif defined(CONFIG_HIGH_TP_TEST) && CONFIG_HIGH_TP_TEST
|
||||
#define MEM_SIZE (23*1024)
|
||||
#elif defined(CONFIG_PLATFORM_8721D)
|
||||
#define MEM_SIZE (7*1024)
|
||||
#else
|
||||
#define MEM_SIZE (5*1024)
|
||||
#endif
|
||||
|
||||
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
|
||||
sends a lot of data out of ROM (or other static memory), this
|
||||
should be set high. */
|
||||
#define MEMP_NUM_PBUF 100
|
||||
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
||||
per active UDP "connection". */
|
||||
#define MEMP_NUM_UDP_PCB 6
|
||||
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
|
||||
connections. */
|
||||
#define MEMP_NUM_TCP_PCB 10
|
||||
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
|
||||
connections. */
|
||||
#define MEMP_NUM_TCP_PCB_LISTEN 5
|
||||
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
|
||||
segments. */
|
||||
#ifdef CONFIG_HIGH_TP_TEST
|
||||
#define MEMP_NUM_TCP_SEG 60
|
||||
#else
|
||||
#define MEMP_NUM_TCP_SEG 20
|
||||
#endif
|
||||
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
|
||||
timeouts. */
|
||||
#define MEMP_NUM_SYS_TIMEOUT 10
|
||||
|
||||
#define MEMP_NUM_NETCONN 8
|
||||
|
||||
/* ---------- Pbuf options ---------- */
|
||||
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
|
||||
#if WIFI_LOGO_CERTIFICATION_CONFIG
|
||||
#define PBUF_POOL_SIZE 30 //for ping 10k test
|
||||
#define IP_REASS_MAXAGE 1
|
||||
#elif defined(CONFIG_HIGH_TP_TEST) && CONFIG_HIGH_TP_TEST
|
||||
#define PBUF_POOL_SIZE 60
|
||||
#else
|
||||
#define PBUF_POOL_SIZE 20
|
||||
#endif
|
||||
|
||||
/* IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled.*/
|
||||
#if WIFI_LOGO_CERTIFICATION_CONFIG
|
||||
#define IP_REASS_MAX_PBUFS 30 //for ping 10k test
|
||||
#else
|
||||
#define IP_REASS_MAX_PBUFS 10
|
||||
#endif
|
||||
|
||||
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
|
||||
#define PBUF_POOL_BUFSIZE 508
|
||||
|
||||
|
||||
/* ---------- TCP options ---------- */
|
||||
#define LWIP_TCP 1
|
||||
#define TCP_TTL 255
|
||||
|
||||
/* Controls if TCP should queue segments that arrive out of
|
||||
order. Define to 0 if your device is low on memory. */
|
||||
#define TCP_QUEUE_OOSEQ 1
|
||||
|
||||
/* TCP Maximum segment size. */
|
||||
#define TCP_MSS (1500 - 40) /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */
|
||||
|
||||
/* TCP sender buffer space (bytes). */
|
||||
#ifdef CONFIG_HIGH_TP_TEST
|
||||
#define TCP_SND_BUF (10*TCP_MSS)
|
||||
#else
|
||||
#define TCP_SND_BUF (5*TCP_MSS)
|
||||
#endif
|
||||
/* TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least
|
||||
as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */
|
||||
|
||||
#ifdef CONFIG_HIGH_TP_TEST
|
||||
#define TCP_SND_QUEUELEN (6* TCP_SND_BUF/TCP_MSS)
|
||||
#else
|
||||
#define TCP_SND_QUEUELEN (4* TCP_SND_BUF/TCP_MSS)
|
||||
#endif
|
||||
|
||||
/* TCP receive window. */
|
||||
#ifdef CONFIG_HIGH_TP_TEST
|
||||
#define TCP_WND (8*TCP_MSS)
|
||||
#elif defined(CONFIG_PLATFORM_8721D)
|
||||
#define TCP_WND (5*TCP_MSS)
|
||||
#else
|
||||
#define TCP_WND (2*TCP_MSS)
|
||||
#endif
|
||||
|
||||
/* ---------- ICMP options ---------- */
|
||||
#define LWIP_ICMP 1
|
||||
|
||||
/* ---------- ARP options ----------- */
|
||||
#define LWIP_ARP 1
|
||||
|
||||
/* ---------- DHCP options ---------- */
|
||||
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
|
||||
interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
|
||||
turning this on does currently not work. */
|
||||
#define LWIP_DHCP 1
|
||||
|
||||
|
||||
/* ---------- UDP options ---------- */
|
||||
#define LWIP_UDP 1
|
||||
#define UDP_TTL 255
|
||||
/* ---------- DNS options ---------- */
|
||||
#define LWIP_DNS 1
|
||||
|
||||
/* ---------- UPNP options --------- */
|
||||
#define LWIP_UPNP 0
|
||||
|
||||
/* ---------- SO_SNDRCVTIMEO_NONSTANDARD options --------- */
|
||||
#define LWIP_SO_SNDRCVTIMEO_NONSTANDARD 1
|
||||
|
||||
/* ---------- SO_REUSE options --------- */
|
||||
#define SO_REUSE 1
|
||||
|
||||
/* Support Multicast */
|
||||
#define LWIP_IGMP 1
|
||||
#define LWIP_RAND() rand()
|
||||
extern unsigned int sys_now(void);
|
||||
#define LWIP_SRAND() srand(sys_now())
|
||||
|
||||
#define LWIP_MTU_ADJUST 1
|
||||
|
||||
/* Support TCP Keepalive */
|
||||
#define LWIP_TCP_KEEPALIVE 1
|
||||
|
||||
/*LWIP_UART_ADAPTER==1: Enable LWIP_UART_ADAPTER when CONFIG_GAGENT is enabled,
|
||||
because some GAGENT functions denpond on the following macro definitions.*/
|
||||
#define LWIP_UART_ADAPTER 0
|
||||
|
||||
#if LWIP_UART_ADAPTER || CONFIG_ETHERNET
|
||||
#undef LWIP_SO_SNDTIMEO
|
||||
#define LWIP_SO_SNDTIMEO 1
|
||||
|
||||
#undef SO_REUSE
|
||||
#define SO_REUSE 1
|
||||
|
||||
#undef MEMP_NUM_NETCONN
|
||||
#define MEMP_NUM_NETCONN 10
|
||||
|
||||
#undef TCP_WND
|
||||
#define TCP_WND (4*TCP_MSS)
|
||||
|
||||
#define TCP_KEEPIDLE_DEFAULT 10000UL
|
||||
#define TCP_KEEPINTVL_DEFAULT 1000UL
|
||||
#define TCP_KEEPCNT_DEFAULT 10U
|
||||
#endif
|
||||
|
||||
#if (defined(CONFIG_EXAMPLE_UART_ATCMD) && (CONFIG_EXAMPLE_UART_ATCMD)) \
|
||||
|| (defined(CONFIG_EXAMPLE_SPI_ATCMD) && (CONFIG_EXAMPLE_SPI_ATCMD))
|
||||
#undef LWIP_SO_SNDTIMEO
|
||||
#define LWIP_SO_SNDTIMEO 1
|
||||
|
||||
#undef SO_REUSE
|
||||
#define SO_REUSE 1
|
||||
|
||||
#undef SO_REUSE_RXTOALL
|
||||
#define SO_REUSE_RXTOALL 1
|
||||
|
||||
#undef MEMP_NUM_NETCONN
|
||||
#define MEMP_NUM_NETCONN 10
|
||||
|
||||
#undef MEMP_NUM_TCP_PCB
|
||||
#define MEMP_NUM_TCP_PCB (MEMP_NUM_NETCONN)
|
||||
|
||||
#undef MEMP_NUM_UDP_PCB
|
||||
#define MEMP_NUM_UDP_PCB (MEMP_NUM_NETCONN)
|
||||
|
||||
#undef TCP_WND
|
||||
#define TCP_WND (4*TCP_MSS)
|
||||
|
||||
#define TCP_KEEPIDLE_DEFAULT 10000UL
|
||||
#define TCP_KEEPINTVL_DEFAULT 1000UL
|
||||
#define TCP_KEEPCNT_DEFAULT 10U
|
||||
|
||||
#define ERRNO 1
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_EXAMPLE_AMAZON_ALEXA) && CONFIG_EXAMPLE_AMAZON_ALEXA
|
||||
|
||||
#undef TCP_WND
|
||||
#define TCP_WND (4*TCP_MSS)
|
||||
|
||||
#undef TCP_SND_BUF
|
||||
#define TCP_SND_BUF (10*TCP_MSS)
|
||||
|
||||
#undef TCP_SND_QUEUELEN
|
||||
#define TCP_SND_QUEUELEN (4* TCP_SND_BUF/TCP_MSS)
|
||||
|
||||
#undef MEMP_NUM_TCP_SEG
|
||||
#define MEMP_NUM_TCP_SEG 40
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_VIDEO_APPLICATION) && CONFIG_VIDEO_APPLICATION
|
||||
#undef MEM_SIZE
|
||||
#define MEM_SIZE (20*1024)
|
||||
|
||||
#undef MEMP_NUM_TCP_SEG
|
||||
#define MEMP_NUM_TCP_SEG 60
|
||||
|
||||
#undef PBUF_POOL_SIZE
|
||||
#define PBUF_POOL_SIZE 60
|
||||
|
||||
#undef MEMP_NUM_NETBUF
|
||||
#define MEMP_NUM_NETBUF 60
|
||||
|
||||
#undef DEFAULT_UDP_RECVMBOX_SIZE
|
||||
#define DEFAULT_UDP_RECVMBOX_SIZE 60
|
||||
|
||||
#undef IP_REASS_MAX_PBUFS
|
||||
#define IP_REASS_MAX_PBUFS 40
|
||||
|
||||
#undef TCP_SND_BUF
|
||||
#define TCP_SND_BUF (10*TCP_MSS)
|
||||
|
||||
#undef TCP_SND_QUEUELEN
|
||||
#define TCP_SND_QUEUELEN (6*TCP_SND_BUF/TCP_MSS)
|
||||
|
||||
#undef TCP_WND
|
||||
#define TCP_WND (4*TCP_MSS)
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO_SDK
|
||||
//#undef MEMP_NUM_NETBUF
|
||||
//#define MEMP_NUM_NETBUF 8
|
||||
|
||||
//#undef MEMP_NUM_NETCONN
|
||||
//#define MEMP_NUM_NETCONN 16
|
||||
#endif // end of #ifdef ARDUINO_SDK
|
||||
|
||||
/* ---------- Statistics options ---------- */
|
||||
#define LWIP_STATS 0
|
||||
#define LWIP_PROVIDE_ERRNO 1
|
||||
|
||||
|
||||
/*
|
||||
--------------------------------------
|
||||
---------- Checksum options ----------
|
||||
--------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
Certain platform allows computing and verifying the IP, UDP, TCP and ICMP checksums by hardware:
|
||||
- To use this feature let the following define uncommented.
|
||||
- To disable it and process by CPU comment the the checksum.
|
||||
*/
|
||||
//Do checksum by lwip - WLAN nic does not support Checksum offload
|
||||
//#define CHECKSUM_BY_HARDWARE
|
||||
|
||||
|
||||
#ifdef CHECKSUM_BY_HARDWARE
|
||||
/* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/
|
||||
#define CHECKSUM_GEN_IP 0
|
||||
/* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/
|
||||
#define CHECKSUM_GEN_UDP 0
|
||||
/* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/
|
||||
#define CHECKSUM_GEN_TCP 0
|
||||
/* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/
|
||||
#define CHECKSUM_CHECK_IP 0
|
||||
/* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/
|
||||
#define CHECKSUM_CHECK_UDP 0
|
||||
/* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/
|
||||
#define CHECKSUM_CHECK_TCP 0
|
||||
#else
|
||||
/* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/
|
||||
#define CHECKSUM_GEN_IP 1
|
||||
/* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/
|
||||
#define CHECKSUM_GEN_UDP 1
|
||||
/* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/
|
||||
#define CHECKSUM_GEN_TCP 1
|
||||
/* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/
|
||||
#define CHECKSUM_CHECK_IP 1
|
||||
/* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/
|
||||
#define CHECKSUM_CHECK_UDP 1
|
||||
/* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/
|
||||
#define CHECKSUM_CHECK_TCP 1
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
----------------------------------------------
|
||||
---------- Sequential layer options ----------
|
||||
----------------------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
|
||||
*/
|
||||
#define LWIP_NETCONN 1
|
||||
|
||||
/*
|
||||
------------------------------------
|
||||
---------- Socket options ----------
|
||||
------------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
|
||||
*/
|
||||
#define LWIP_SOCKET 1
|
||||
|
||||
/*
|
||||
-----------------------------------
|
||||
---------- DEBUG options ----------
|
||||
-----------------------------------
|
||||
*/
|
||||
|
||||
#define LWIP_DEBUG 0
|
||||
|
||||
|
||||
/*
|
||||
---------------------------------
|
||||
---------- OS options ----------
|
||||
---------------------------------
|
||||
*/
|
||||
|
||||
#define TCPIP_THREAD_STACKSIZE 1000
|
||||
#define TCPIP_MBOX_SIZE 6
|
||||
#define DEFAULT_UDP_RECVMBOX_SIZE 6
|
||||
#define DEFAULT_TCP_RECVMBOX_SIZE 6
|
||||
#define DEFAULT_RAW_RECVMBOX_SIZE 6
|
||||
#define DEFAULT_ACCEPTMBOX_SIZE 6
|
||||
#define DEFAULT_THREAD_STACKSIZE 500
|
||||
#define TCPIP_THREAD_PRIO (configMAX_PRIORITIES - 2)
|
||||
|
||||
/* Added by Realtek. For DHCP server reply unicast DHCP packets before the ip actually assigned. */
|
||||
#define ETHARP_SUPPORT_STATIC_ENTRIES 1
|
||||
|
||||
/* Added by Realtek start */
|
||||
#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1
|
||||
#define LWIP_DNS_LEGACY_SUPPORT 0
|
||||
/* Added by Realtek end */
|
||||
|
||||
/* Extra options for lwip_v2.0.2 which should not affect lwip_v1.4.1 */
|
||||
#define LWIP_TCPIP_CORE_LOCKING 0
|
||||
#define ERRNO 1
|
||||
#define LWIP_TCPIP_TIMEOUT 1
|
||||
#define LWIP_SO_RCVTIMEO 1
|
||||
#define LWIP_SO_SNDTIMEO 1
|
||||
#define LWIP_SOCKET_SET_ERRNO 1
|
||||
#undef LWIP_DEBUG
|
||||
#define LWIP_RAW 1
|
||||
#define LWIP_AUTOIP 1
|
||||
#define TCPIP_THREAD_NAME "TCP_IP"
|
||||
|
||||
#define LWIP_IPV6 0
|
||||
#if LWIP_IPV6
|
||||
#undef MEMP_NUM_SYS_TIMEOUT
|
||||
#define MEMP_NUM_SYS_TIMEOUT 13
|
||||
#endif
|
||||
|
||||
/*CONFIG_LIBCOAP_ON is defined to 1 in the lib_coap project options preprocessor defined symbol
|
||||
*CONFIG_EXAMPLE_COAP_SERVER and CONFIG_EXAMPLE_COAP_CLIENT is defined in platform_opts.h
|
||||
*/
|
||||
#if CONFIG_EXAMPLE_COAP_SERVER || CONFIG_EXAMPLE_COAP_CLIENT || (defined(CONFIG_LIBCOAP_ON) && (CONFIG_LIBCOAP_ON))
|
||||
#define LWIP_TIMEVAL_PRIVATE 1
|
||||
#undef SO_REUSE
|
||||
#define SO_REUSE 1
|
||||
#undef MEMP_NUM_NETCONN
|
||||
#define MEMP_NUM_NETCONN 20
|
||||
#define MEMP_USE_CUSTOM_POOLS 1
|
||||
#undef LWIP_IPV6
|
||||
#define LWIP_IPV6 1
|
||||
#define ERRNO 1
|
||||
|
||||
#if defined(LWIP_IPV6) && (LWIP_IPV6==1)
|
||||
#undef MEMP_NUM_SYS_TIMEOUT
|
||||
#define MEMP_NUM_SYS_TIMEOUT 20
|
||||
#ifndef xchar
|
||||
#define xchar(i) ((i) < 10 ? '0' + (i) : 'A' + (i) - 10)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "lwip/init.h" //for version control
|
||||
|
||||
#endif /* LWIP_HDR_LWIPOPTS_H */
|
||||
33
sdk/component/common/api/network/include/lwippools.h
Normal file
33
sdk/component/common/api/network/include/lwippools.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/** Memory pool definitions for the libcoap when used with lwIP (which has its
|
||||
* own mechanism for quickly allocating chunks of data with known sizes). Has
|
||||
* to be findable by lwIP (ie. an #include <lwippools.h> must either directly
|
||||
* include this or include something more generic which includes this), and
|
||||
* MEMP_USE_CUSTOM_POOLS has to be set in lwipopts.h. */
|
||||
//added for libcoap
|
||||
|
||||
#include <coap/net.h>
|
||||
#include <coap/subscribe.h>
|
||||
#include <coap/resource.h>
|
||||
|
||||
#ifndef MEMP_NUM_COAPCONTEXT
|
||||
#define MEMP_NUM_COAPCONTEXT 2
|
||||
#endif
|
||||
#ifndef MEMP_NUM_COAPNODE
|
||||
#define MEMP_NUM_COAPNODE 4
|
||||
#endif
|
||||
#ifndef MEMP_NUM_COAP_SUBSCRIPTION
|
||||
#define MEMP_NUM_COAP_SUBSCRIPTION 4
|
||||
#endif
|
||||
#ifndef MEMP_NUM_COAPRESOURCE
|
||||
#define MEMP_NUM_COAPRESOURCE 10
|
||||
#endif
|
||||
#ifndef MEMP_NUM_COAPRESOURCEATTR
|
||||
#define MEMP_NUM_COAPRESOURCEATTR 20
|
||||
#endif
|
||||
|
||||
LWIP_MEMPOOL(COAP_CONTEXT, MEMP_NUM_COAPCONTEXT, sizeof(coap_context_t), "COAP_CONTEXT")
|
||||
LWIP_MEMPOOL(COAP_NODE, MEMP_NUM_COAPNODE, sizeof(coap_queue_t), "COAP_NODE")
|
||||
LWIP_MEMPOOL(COAP_subscription, MEMP_NUM_COAP_SUBSCRIPTION, sizeof(coap_subscription_t), "COAP_subscription")
|
||||
LWIP_MEMPOOL(COAP_RESOURCE, MEMP_NUM_COAPRESOURCE, sizeof(coap_resource_t), "COAP_RESOURCE")
|
||||
LWIP_MEMPOOL(COAP_RESOURCEATTR, MEMP_NUM_COAPRESOURCEATTR, sizeof(coap_attr_t), "COAP_RESOURCEATTR")
|
||||
|
||||
68
sdk/component/common/api/network/include/main.h
Normal file
68
sdk/component/common/api/network/include/main.h
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#include <autoconf.h>
|
||||
|
||||
#define CONFIG_WLAN 1
|
||||
|
||||
|
||||
/* Header file declaration*/
|
||||
void wlan_network();
|
||||
|
||||
|
||||
/* Interactive Mode */
|
||||
#define SERIAL_DEBUG_RX 1
|
||||
#if defined(__ICCARM__)
|
||||
static
|
||||
#endif
|
||||
char uart_buf[64];
|
||||
|
||||
|
||||
/* WLAN and Netork */
|
||||
#define STA_MODE_SSID "ap" /* Set SSID here */
|
||||
#define AP_MODE_SSID "wlan_ap_ssid" /* Set SSID here */
|
||||
#define AP_DEFAULT_CH 6
|
||||
#define WLAN0_NAME "wlan0"
|
||||
#define WLAN1_NAME "wlan1"
|
||||
#define WPA_PASSPHRASE "1234567890" /* Max 32 cahracters */
|
||||
#define WEP40_KEY {0x12, 0x34, 0x56, 0x78, 0x90}
|
||||
|
||||
/*Static IP ADDRESS*/
|
||||
#define IP_ADDR0 192
|
||||
#define IP_ADDR1 168
|
||||
#define IP_ADDR2 1
|
||||
#define IP_ADDR3 80
|
||||
|
||||
/*NETMASK*/
|
||||
#define NETMASK_ADDR0 255
|
||||
#define NETMASK_ADDR1 255
|
||||
#define NETMASK_ADDR2 255
|
||||
#define NETMASK_ADDR3 0
|
||||
|
||||
/*Gateway Address*/
|
||||
#define GW_ADDR0 192
|
||||
#define GW_ADDR1 168
|
||||
#define GW_ADDR2 1
|
||||
#define GW_ADDR3 1
|
||||
|
||||
/*******************************************/
|
||||
|
||||
/*Static IP ADDRESS*/
|
||||
#define AP_IP_ADDR0 192
|
||||
#define AP_IP_ADDR1 168
|
||||
#define AP_IP_ADDR2 43
|
||||
#define AP_IP_ADDR3 1
|
||||
|
||||
/*NETMASK*/
|
||||
#define AP_NETMASK_ADDR0 255
|
||||
#define AP_NETMASK_ADDR1 255
|
||||
#define AP_NETMASK_ADDR2 255
|
||||
#define AP_NETMASK_ADDR3 0
|
||||
|
||||
/*Gateway Address*/
|
||||
#define AP_GW_ADDR0 192
|
||||
#define AP_GW_ADDR1 168
|
||||
#define AP_GW_ADDR2 43
|
||||
#define AP_GW_ADDR3 1
|
||||
|
||||
#endif
|
||||
21
sdk/component/common/api/network/include/main_test.h
Normal file
21
sdk/component/common/api/network/include/main_test.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
//----------------------------------------------------------------------------//
|
||||
#ifndef __MAIN_TEST_H
|
||||
#define __MAIN_TEST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported test functions ------------------------------------------------------- */
|
||||
void do_ping_test(char *ip, int size, int count, int interval);
|
||||
void do_ping_call(char *ip, int loop, int count);
|
||||
void interactive_question(char *question, char *choice, char *buf, int buf_size);
|
||||
void start_interactive_mode(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __MAIN_TEST_H
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
50
sdk/component/common/api/network/include/netconf.h
Normal file
50
sdk/component/common/api/network/include/netconf.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file netconf.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 07-October-2011
|
||||
* @brief This file contains all the functions prototypes for the netconf.c
|
||||
* file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
||||
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
||||
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
||||
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __NETCONF_H
|
||||
#define __NETCONF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// TODO: remove this file
|
||||
#include "lwip_netconf.h"
|
||||
#if 0
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void LwIP_Init(void);
|
||||
void LwIP_DHCP(void);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __NETCONF_H */
|
||||
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
8
sdk/component/common/api/network/include/rtl8195a_it.h
Normal file
8
sdk/component/common/api/network/include/rtl8195a_it.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
#ifndef __RTL8195A_IT_H_
|
||||
#define __RTL8195A_IT_H_
|
||||
|
||||
|
||||
int irq_alloc_wlan(void *contex);
|
||||
|
||||
#endif //__RTL8195A_IT_H_
|
||||
46
sdk/component/common/api/network/include/util.h
Normal file
46
sdk/component/common/api/network/include/util.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#ifndef _UTIL_H
|
||||
#define _UTIL_H
|
||||
|
||||
#include <wireless.h>
|
||||
#include <wlan_intf.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "wifi_util.h"
|
||||
#if 0
|
||||
typedef enum _WIFI_EVENT_INDICATE{
|
||||
WIFI_EVENT_CONNECT = 0,
|
||||
WIFI_EVENT_DISCONNECT = 1,
|
||||
WIFI_EVENT_FOURWAY_HANDSHAKE_DONE = 2,
|
||||
}WIFI_EVENT_INDICATE;
|
||||
|
||||
int wext_get_ssid(const char *ifname, __u8 *ssid);
|
||||
int wext_set_ssid(const char *ifname, const __u8 *ssid, __u16 ssid_len);
|
||||
int wext_set_auth_param(const char *ifname, __u16 idx, __u32 value);
|
||||
int wext_set_key_ext(const char *ifname, __u16 alg, const __u8 *addr, int key_idx, int set_tx, const __u8 *seq, __u16 seq_len, __u8 *key, __u16 key_len);
|
||||
int wext_get_enc_ext(const char *ifname, __u16 *alg);
|
||||
int wext_set_passphrase(const char *ifname, const __u8 *passphrase, __u16 passphrase_len);
|
||||
int wext_get_passphrase(const char *ifname, __u8 *passphrase);
|
||||
int wext_set_mode(const char *ifname, int mode);
|
||||
int wext_get_mode(const char *ifname, int *mode);
|
||||
int wext_set_ap_ssid(const char *ifname, const __u8 *ssid, __u16 ssid_len);
|
||||
int wext_set_country(const char *ifname, char *country_code);
|
||||
int wext_get_rssi(const char *ifname, int *rssi);
|
||||
int wext_set_channel(const char *ifname, __u8 ch);
|
||||
int wext_get_channel(const char *ifname, __u8 *ch);
|
||||
int wext_set_scan(const char *ifname, char *buf, __u16 buf_len);
|
||||
int wext_get_scan(const char *ifname, char *buf, __u16 buf_len);
|
||||
int wext_mp_command(const char *ifname, char *cmd, int show_msg);
|
||||
int wext_wifi_priv(const char *ifname, int argc, char **argv);
|
||||
void wext_wlan_indicate(unsigned int cmd, union iwreq_data *wrqu, char *extra);
|
||||
#endif
|
||||
|
||||
#define wext_handshake_done rltk_wlan_handshake_done
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _UTIL_H */
|
||||
74
sdk/component/common/api/nfc/nfc_ndef.h
Normal file
74
sdk/component/common/api/nfc/nfc_ndef.h
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* NFC tag type 2 APIs
|
||||
*
|
||||
* Copyright (c) 2015 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NFC_EN
|
||||
|
||||
#ifndef NFC_NDEF_H
|
||||
#define NFC_NDEF_H
|
||||
|
||||
#define NFC_NDEF_TNF_EMPTY 0x0
|
||||
#define NFC_NDEF_TNF_WELL_KNOWN 0x1
|
||||
#define NFC_NDEF_TNF_MIME_MEDIA_TYPE 0x2
|
||||
#define NFC_NDEF_TNF_ABSOLUTE_URI 0x3
|
||||
#define NFC_NDEF_TNF_EXTERNAL 0x4
|
||||
#define NFC_NDEF_TNF_UNKNOWN 0x5
|
||||
#define NFC_NDEF_TNF_UNCHANGED 0x6
|
||||
#define NFC_NDEF_TNF_RESERVED 0x7
|
||||
|
||||
// RTD type for TNF_WELL_KNOWN
|
||||
#define NFC_NDEF_RTD_WELL_KNOWN_TEXT "T"
|
||||
#define NFC_NDEF_RTD_WELL_KNOWN_SMART_POSTER "Sp"
|
||||
#define NFC_NDEF_RTD_WELL_KNOWN_URI "U"
|
||||
#define NFC_NDEF_RTD_WELL_KNOWN_HANDOVER_REQUEST "Hr"
|
||||
#define NFC_NDEF_RTD_WELL_KNOWN_HANDOVER_SELECT "Hs"
|
||||
#define NFC_NDEF_RTD_WELL_KNOWN_HANDOVER_CARRIER "Hc"
|
||||
#define NFC_NDEF_RTD_WELL_KNOWN_SIGNATURE "Sig"
|
||||
|
||||
// RTD type for TNF_EXTERNAL
|
||||
#define NFC_NDEF_RTD_EXTERNAL_AAR "com.android:pkg"
|
||||
|
||||
// identifier code for RTD type well known uri
|
||||
#define NFC_NDEF_RTD_WELL_KNOWN_URI_NA 0x00
|
||||
#define NFC_NDEF_RTD_WELL_KNOWN_URI_HTTP_WWW 0x01
|
||||
#define NFC_NDEF_RTD_WELL_KNOWN_URI_HTTPS_WWW 0x02
|
||||
#define NFC_NDEF_RTD_WELL_KNOWN_URI_HTTP 0x03
|
||||
#define NFC_NDEF_RTD_WELL_KNOWN_URI_HTTPS 0x04
|
||||
#define NFC_NDEF_RTD_WELL_KNOWN_URI_TEL 0x05
|
||||
#define NFC_NDEF_RTD_WELL_KNOWN_URI_MAILTO 0x06
|
||||
|
||||
typedef struct {
|
||||
unsigned char flag_mb;
|
||||
unsigned char flag_me;
|
||||
unsigned char flag_cf;
|
||||
unsigned char flag_sr;
|
||||
unsigned char flag_il;
|
||||
unsigned char tnf;
|
||||
|
||||
unsigned char record_type_len;
|
||||
unsigned char *record_type;
|
||||
|
||||
unsigned char id_len;
|
||||
unsigned char *id;
|
||||
|
||||
unsigned int payload_len;
|
||||
unsigned char *payload;
|
||||
} nfc_ndef;
|
||||
|
||||
nfc_ndef* nfc_ndef_parse_byte(unsigned char *buf, unsigned int buf_size);
|
||||
unsigned int nfc_ndef_length(nfc_ndef *ndef);
|
||||
unsigned int nfc_ndef_convert_byte(nfc_ndef *ndef, unsigned char *buf, unsigned int buf_size);
|
||||
void nfc_ndef_free(nfc_ndef *ndef);
|
||||
void nfc_ndef_dump(nfc_ndef *ndef);
|
||||
|
||||
nfc_ndef* nfc_ndef_get_well_known_text(const char *text);
|
||||
nfc_ndef* nfc_ndef_get_well_known_uri(unsigned char identifier_code, const char *uri);
|
||||
nfc_ndef* nfc_ndef_get_external_aar(const char *app_name);
|
||||
|
||||
#endif
|
||||
#endif // end of #ifdef CONFIG_NFC_EN
|
||||
67
sdk/component/common/api/nfc/nfc_tag_type2_api.h
Normal file
67
sdk/component/common/api/nfc/nfc_tag_type2_api.h
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* NFC tag type 2 APIs
|
||||
*
|
||||
* Copyright (c) 2015 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NFC_EN
|
||||
|
||||
#ifndef _NFC_TAG_TYPE2_API_H
|
||||
#define _NFC_TAG_TYPE2_API_H
|
||||
|
||||
#define NFC_TAG_PAGE_SIZE 42
|
||||
#define NFC_TAG_UID_LENGTH 7
|
||||
|
||||
#define NFC_TAG_PAGE_USERDATA_SIZE 36 // page 4~39
|
||||
|
||||
#define NFC_TLV_TYPE_NULL 0x00
|
||||
#define NFC_TLV_TYPE_LOCK_CTRL 0x01
|
||||
#define NFC_TLV_TYPE_MEM_CTRL 0x02
|
||||
#define NFC_TLV_TYPE_NDEF_MSG 0x03
|
||||
#define NFC_TLV_TYPE_PROPRIETARY 0xfd
|
||||
#define NFC_TLV_TYPE_TERMINATOR 0xfe
|
||||
|
||||
// variable definitions
|
||||
|
||||
// NFC PAGES
|
||||
typedef struct {
|
||||
unsigned int data;
|
||||
unsigned char lock;
|
||||
unsigned char dirty;
|
||||
} nfc_tag_type2_page;
|
||||
|
||||
typedef struct {
|
||||
nfc_tag_type2_page pages[NFC_TAG_PAGE_SIZE];
|
||||
unsigned char uid[NFC_TAG_UID_LENGTH];
|
||||
} nfc_tag_type2;
|
||||
|
||||
// NFC TAG TLV
|
||||
#define NFC_MAX_TLV_SIZE 5
|
||||
|
||||
typedef struct {
|
||||
unsigned char type;
|
||||
unsigned char len;
|
||||
unsigned char *value;
|
||||
} nfc_tlv;
|
||||
|
||||
typedef struct {
|
||||
int size;
|
||||
nfc_tlv tlv[NFC_MAX_TLV_SIZE];
|
||||
} nfc_tlvs;
|
||||
|
||||
// function prototypes
|
||||
int nfc_tag_type2_init(nfc_tag_type2 *tag, unsigned int pages[NFC_TAG_PAGE_SIZE], unsigned int pagesize);
|
||||
void nfc_tag_type2_init_default(nfc_tag_type2 *tag, unsigned char uid[NFC_TAG_UID_LENGTH]);
|
||||
void nfc_tag_type2_dump(nfc_tag_type2 *tag);
|
||||
|
||||
nfc_tlvs* nfc_parse_tlvs(nfc_tag_type2 *tag);
|
||||
int nfc_overwrite_tlv(nfc_tlvs *tlvs, unsigned type, unsigned char *buf, unsigned int buf_size);
|
||||
unsigned int nfc_tlvs_convert_page(nfc_tlvs *tlvs, unsigned int *page_buf, unsigned int page_buf_size);
|
||||
void nfc_free_tlvs(nfc_tlvs *tlvs);
|
||||
void nfc_dump_tlvs(nfc_tlvs *tlvs);
|
||||
|
||||
#endif
|
||||
#endif // end of #ifdef CONFIG_NFC_EN
|
||||
279
sdk/component/common/api/platform/dlist.h
Normal file
279
sdk/component/common/api/platform/dlist.h
Normal file
|
|
@ -0,0 +1,279 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* 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 __LIST_H
|
||||
#define __LIST_H
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
#ifndef inline
|
||||
#define inline __inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* This file is from Linux Kernel (include/linux/list.h)
|
||||
* and modified by simply removing hardware prefetching of list items.
|
||||
* Here by copyright, credits attributed to wherever they belong.
|
||||
* Kulesh Shanmugasundaram (kulesh [squiggly] isis.poly.edu)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Simple doubly linked list implementation.
|
||||
*
|
||||
* Some of the internal functions ("__xxx") are useful when
|
||||
* manipulating whole lists rather than single entries, as
|
||||
* sometimes we already know the next/prev entries and we can
|
||||
* generate better code by using them directly rather than
|
||||
* using the generic single-entry routines.
|
||||
*/
|
||||
|
||||
struct list_head {
|
||||
struct list_head *next, *prev;
|
||||
};
|
||||
|
||||
#define LIST_HEAD_INIT(name) { &(name), &(name) }
|
||||
|
||||
#define LIST_HEAD(name) \
|
||||
struct list_head name = LIST_HEAD_INIT(name)
|
||||
|
||||
#define INIT_LIST_HEAD(ptr) do { \
|
||||
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Insert a new entry between two known consecutive entries.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static inline void __list_add(struct list_head *newitem,
|
||||
struct list_head *prev,
|
||||
struct list_head *next)
|
||||
{
|
||||
next->prev = newitem;
|
||||
newitem->next = next;
|
||||
newitem->prev = prev;
|
||||
prev->next = newitem;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_add - add a new entry
|
||||
* @new: new entry to be added
|
||||
* @head: list head to add it after
|
||||
*
|
||||
* Insert a new entry after the specified head.
|
||||
* This is good for implementing stacks.
|
||||
*/
|
||||
static inline void list_add(struct list_head *newitem, struct list_head *head)
|
||||
{
|
||||
__list_add(newitem, head, head->next);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_add_tail - add a new entry
|
||||
* @new: new entry to be added
|
||||
* @head: list head to add it before
|
||||
*
|
||||
* Insert a new entry before the specified head.
|
||||
* This is useful for implementing queues.
|
||||
*/
|
||||
static inline void list_add_tail(struct list_head *newitem, struct list_head *head)
|
||||
{
|
||||
__list_add(newitem, head->prev, head);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete a list entry by making the prev/next entries
|
||||
* point to each other.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static inline void __list_del(struct list_head *prev, struct list_head *next)
|
||||
{
|
||||
next->prev = prev;
|
||||
prev->next = next;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_del - deletes entry from list.
|
||||
* @entry: the element to delete from the list.
|
||||
* Note: list_empty on entry does not return true after this, the entry is in an undefined state.
|
||||
*/
|
||||
static inline void list_del(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
entry->next = (struct list_head *) 0;
|
||||
entry->prev = (struct list_head *) 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_del_init - deletes entry from list and reinitialize it.
|
||||
* @entry: the element to delete from the list.
|
||||
*/
|
||||
static inline void list_del_init(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
INIT_LIST_HEAD(entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_move - delete from one list and add as another's head
|
||||
* @list: the entry to move
|
||||
* @head: the head that will precede our entry
|
||||
*/
|
||||
static inline void list_move(struct list_head *list, struct list_head *head)
|
||||
{
|
||||
__list_del(list->prev, list->next);
|
||||
list_add(list, head);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_move_tail - delete from one list and add as another's tail
|
||||
* @list: the entry to move
|
||||
* @head: the head that will follow our entry
|
||||
*/
|
||||
static inline void list_move_tail(struct list_head *list,
|
||||
struct list_head *head)
|
||||
{
|
||||
__list_del(list->prev, list->next);
|
||||
list_add_tail(list, head);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_empty - tests whether a list is empty
|
||||
* @head: the list to test.
|
||||
*/
|
||||
static inline int list_empty(struct list_head *head)
|
||||
{
|
||||
return head->next == head;
|
||||
}
|
||||
|
||||
static inline void __list_splice(struct list_head *list,
|
||||
struct list_head *head)
|
||||
{
|
||||
struct list_head *first = list->next;
|
||||
struct list_head *last = list->prev;
|
||||
struct list_head *at = head->next;
|
||||
|
||||
first->prev = head;
|
||||
head->next = first;
|
||||
|
||||
last->next = at;
|
||||
at->prev = last;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_splice - join two lists
|
||||
* @list: the new list to add.
|
||||
* @head: the place to add it in the first list.
|
||||
*/
|
||||
static inline void list_splice(struct list_head *list, struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list))
|
||||
__list_splice(list, head);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_splice_init - join two lists and reinitialise the emptied list.
|
||||
* @list: the new list to add.
|
||||
* @head: the place to add it in the first list.
|
||||
*
|
||||
* The list at @list is reinitialised
|
||||
*/
|
||||
static inline void list_splice_init(struct list_head *list,
|
||||
struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list)) {
|
||||
__list_splice(list, head);
|
||||
INIT_LIST_HEAD(list);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* list_entry - get the struct for this entry
|
||||
* @ptr: the &struct list_head pointer.
|
||||
* @type: the type of the struct this is embedded in.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_entry(ptr, type, member) \
|
||||
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
|
||||
|
||||
/**
|
||||
* list_first_entry - get the first element from a list
|
||||
* @ptr: the list head to take the element from.
|
||||
* @type: the type of the struct this is embedded in.
|
||||
* @member: the name of the list_head within the struct.
|
||||
*
|
||||
* Note, that list is expected to be not empty.
|
||||
*/
|
||||
|
||||
#define list_first_entry(ptr, type, member) \
|
||||
list_entry((ptr)->next, type, member)
|
||||
|
||||
|
||||
/**
|
||||
* list_for_each - iterate over a list
|
||||
* @pos: the &struct list_head to use as a loop counter.
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each(pos, head) \
|
||||
for (pos = (head)->next; pos != (head); \
|
||||
pos = pos->next)
|
||||
/**
|
||||
* list_for_each_prev - iterate over a list backwards
|
||||
* @pos: the &struct list_head to use as a loop counter.
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each_prev(pos, head) \
|
||||
for (pos = (head)->prev; pos != (head); \
|
||||
pos = pos->prev)
|
||||
|
||||
/**
|
||||
* list_for_each_safe - iterate over a list safe against removal of list entry
|
||||
* @pos: the &struct list_head to use as a loop counter.
|
||||
* @n: another &struct list_head to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each_safe(pos, n, head) \
|
||||
for (pos = (head)->next, n = pos->next; pos != (head); \
|
||||
pos = n, n = pos->next)
|
||||
|
||||
/**
|
||||
* list_for_each_entry - iterate over list of given type
|
||||
* @pos: the type * to use as a loop counter.
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_for_each_entry(pos, head, member, type) \
|
||||
for (pos = list_entry((head)->next, type, member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry(pos->member.next, type, member))
|
||||
|
||||
/**
|
||||
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
|
||||
* @pos: the type * to use as a loop counter.
|
||||
* @n: another type * to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_for_each_entry_safe(pos, n, head, member, type) \
|
||||
for (pos = list_entry((head)->next, type, member), \
|
||||
n = list_entry(pos->member.next, type, member); \
|
||||
&pos->member != (head); \
|
||||
pos = n, n = list_entry(n->member.next, type, member))
|
||||
|
||||
#endif
|
||||
|
||||
64
sdk/component/common/api/platform/platform_stdlib.h
Normal file
64
sdk/component/common/api/platform/platform_stdlib.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* 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 __PLATFORM_STDLIB_H__
|
||||
#define __PLATFORM_STDLIB_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_PLATFORM_8195A)+\
|
||||
defined(CONFIG_PLATFORM_8711B)+\
|
||||
defined(CONFIG_PLATFORM_8721D)+\
|
||||
defined(CONFIG_PLATFORM_8195BHP)+\
|
||||
defined(USE_STM322xG_EVAL)+\
|
||||
defined(USE_STM324xG_EVAL)+\
|
||||
defined(CONFIG_PLATFOMR_CUSTOMER_RTOS)+\
|
||||
defined(STM32F10X_XL) > 1
|
||||
#error "Cannot define two or more platform at one time"
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_PLATFORM_8195A)
|
||||
#include "platform_stdlib_rtl8195a.h"
|
||||
#elif defined (CONFIG_PLATFORM_8711B)
|
||||
#include "platform_stdlib_rtl8711b.h"
|
||||
#elif defined (CONFIG_PLATFORM_8721D)
|
||||
#include "platform_stdlib_rtl8721d.h"
|
||||
#elif defined(CONFIG_PLATFORM_8195BHP)
|
||||
#include "platform_stdlib_rtl8195bhp.h"
|
||||
#elif defined(USE_STM322xG_EVAL) || defined(USE_STM324xG_EVAL) || defined(STM32F10X_XL)
|
||||
#include "platform_stdlib_stm32.h"
|
||||
#elif defined(CONFIG_PLATFOMR_CUSTOMER_RTOS)
|
||||
#include "platform_stdlib_customer.h"
|
||||
#elif defined (CONFIG_PLATFORM_8710C)
|
||||
#include "platform_stdlib_rtl8710c.h"
|
||||
#else
|
||||
#error "Undefined Platform stdlib"
|
||||
#endif
|
||||
|
||||
|
||||
#if (CONFIG_PLATFORM_AMEBA_X == 0)
|
||||
#ifndef CONFIG_PLATFOMR_CUSTOMER_RTOS
|
||||
#include "basic_types.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //__PLATFORM_STDLIB_H__
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef PLATFORM_STDLIB_CUSTOMER_H
|
||||
#define PLATFORM_STDLIB_CUSTOMER_H
|
||||
|
||||
#include <customer_rtos_service.h>
|
||||
|
||||
#endif // PLATFORM_STDLIB_CUSTOMER_H
|
||||
168
sdk/component/common/api/platform/platform_stdlib_rtl8195a.h
Normal file
168
sdk/component/common/api/platform/platform_stdlib_rtl8195a.h
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
#ifndef PLATFORM_STDLIB_RTL8195A_H
|
||||
#define PLATFORM_STDLIB_RTL8195A_H
|
||||
|
||||
#define USE_CLIB_PATCH 0
|
||||
|
||||
|
||||
#if defined (__GNUC__)
|
||||
/* build rom should set USE_RTL_ROM_CLIB=0 */
|
||||
#if !defined(CONFIG_MBED_ENABLED)
|
||||
#include <rt_lib_rom.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BUILD_ROM) || defined(CONFIG_MBED_ENABLED)
|
||||
#define USE_RTL_ROM_CLIB 0
|
||||
#else
|
||||
#define BUFFERED_PRINTF 0
|
||||
#define USE_RTL_ROM_CLIB 1
|
||||
#endif
|
||||
|
||||
#if defined (__IARSTDLIB__)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "diag.h"
|
||||
|
||||
#define strsep(str, delim) _strsep(str, delim)
|
||||
#elif defined (__CC_ARM)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "diag.h"
|
||||
#define strsep(str, delim) _strsep(str, delim)
|
||||
#elif defined (CONFIG_MBED_ENABLED)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "diag.h"
|
||||
|
||||
#define strsep(str, delim) _strsep(str, delim)
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "diag.h"
|
||||
#include "strproc.h"
|
||||
#include "basic_types.h"
|
||||
#include "hal_misc.h"
|
||||
#if USE_RTL_ROM_CLIB
|
||||
#include "rtl_lib.h"
|
||||
#endif
|
||||
|
||||
#undef printf
|
||||
#undef sprintf
|
||||
#undef snprintf
|
||||
#undef atoi
|
||||
#undef memcmp
|
||||
#undef memcpy
|
||||
#undef memset
|
||||
#undef strcmp
|
||||
#undef strcpy
|
||||
#undef strlen
|
||||
#undef strncmp
|
||||
#undef strncpy
|
||||
#undef strsep
|
||||
#undef strtok
|
||||
#if USE_RTL_ROM_CLIB
|
||||
#undef memchr
|
||||
#undef memmove
|
||||
#undef strcat
|
||||
#undef strchr
|
||||
#undef strncat
|
||||
#undef strstr
|
||||
#endif
|
||||
|
||||
#if USE_RTL_ROM_CLIB
|
||||
#if BUFFERED_PRINTF
|
||||
extern int buffered_printf(const char* fmt, ...);
|
||||
#define printf buffered_printf
|
||||
#else
|
||||
#define printf rtl_printf
|
||||
#endif
|
||||
|
||||
#define sprintf rtl_sprintf
|
||||
#define snprintf rtl_snprintf
|
||||
#define memchr rtl_memchr
|
||||
#define memcmp rtl_memcmp
|
||||
#define memcpy rtl_memcpy
|
||||
#define memmove rtl_memmove
|
||||
#define memset rtl_memset
|
||||
#define strcat rtl_strcat
|
||||
#define strchr rtl_strchr
|
||||
#define strcmp(s1, s2) rtl_strcmp((const char *)s1, (const char *)s2)
|
||||
#define strcpy rtl_strcpy
|
||||
#define strlen(str) rtl_strlen((const char *)str)
|
||||
#define strncat rtl_strncat
|
||||
#define strncmp(s1, s2, n) rtl_strncmp((const char *)s1, (const char *)s2, n)
|
||||
#define strncpy rtl_strncpy
|
||||
#define strstr rtl_strstr
|
||||
#define strsep rtl_strsep
|
||||
#define strtok rtl_strtok
|
||||
#else
|
||||
#if USE_CLIB_PATCH
|
||||
extern int DiagSscanfPatch(const char *buf, const char *fmt, ...);
|
||||
extern char* DiagStrtokPatch(char *str, const char* delim);
|
||||
extern char* DiagStrstrPatch(char *string, char *substring);
|
||||
extern int DiagSnPrintfPatch(char *buf, size_t size, const char *fmt, ...);
|
||||
extern u32 DiagPrintfPatch(const char *fmt, ...);
|
||||
extern u32 DiagSPrintfPatch(u8 *buf, const char *fmt, ...);
|
||||
#define printf DiagPrintfPatch
|
||||
#define sprintf DiagSPrintfPatch
|
||||
#define snprintf DiagSnPrintfPatch
|
||||
#define strstr(a, b) DiagStrstrPatch((char *)(a), (char *)(b))
|
||||
#define strtok DiagStrtokPatch
|
||||
#else
|
||||
#define printf DiagPrintf
|
||||
#define sprintf(fmt, arg...) DiagSPrintf((u8*)fmt, ##arg)
|
||||
#if defined (__GNUC__)
|
||||
#define snprintf DiagSnPrintf // NULL function
|
||||
#define strstr(str1, str2) prvStrStr(str1, str2) // NULL function
|
||||
#endif
|
||||
#define strtok(str, delim) _strsep(str, delim)
|
||||
#endif
|
||||
#define memcmp(dst, src, sz) _memcmp(dst, src, sz)
|
||||
#define memcpy(dst, src, sz) _memcpy(dst, src, sz)
|
||||
#define memset(dst, val, sz) _memset(dst, val, sz)
|
||||
#define strchr(s, c) _strchr(s, c) // for B-cut ROM
|
||||
#define strcmp(str1, str2) prvStrCmp((const unsigned char *) str1, (const unsigned char *) str2)
|
||||
#define strcpy(dest, src) _strcpy(dest, src)
|
||||
#define strlen(str) prvStrLen((const unsigned char *) str)
|
||||
#define strncmp(str1, str2, cnt) _strncmp(str1, str2, cnt)
|
||||
#define strncpy(dest, src, count) _strncpy(dest, src, count)
|
||||
#define strsep(str, delim) _strsep(str, delim)
|
||||
#endif
|
||||
|
||||
#define atoi(str) prvAtoi(str)
|
||||
#define strpbrk(cs, ct) _strpbrk(cs, ct) // for B-cut ROM
|
||||
|
||||
#if USE_CLIB_PATCH
|
||||
#undef sscanf
|
||||
#define sscanf DiagSscanfPatch
|
||||
#else
|
||||
#if defined (__GNUC__)
|
||||
#undef sscanf //_sscanf
|
||||
//extern int DiagSscanfPatch(const char *buf, const char *fmt, ...);
|
||||
//#define sscanf DiagSscanfPatch
|
||||
#define sscanf sscanf // use libc sscanf
|
||||
#endif
|
||||
#endif
|
||||
#endif // defined (__IARSTDLIB__)
|
||||
|
||||
//
|
||||
// memory management
|
||||
//
|
||||
#if defined(CONFIG_MBED_ENABLED)
|
||||
//use libc memory functions
|
||||
#else
|
||||
extern void *pvPortMalloc( size_t xWantedSize );
|
||||
extern void vPortFree( void *pv );
|
||||
#define malloc pvPortMalloc
|
||||
#define free vPortFree
|
||||
#endif
|
||||
|
||||
|
||||
#endif // PLATFORM_STDLIB_RTL8195A_H
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef PLATFORM_STDLIB_RTL8195BHP_H
|
||||
#define PLATFORM_STDLIB_RTL8195BHP_H
|
||||
|
||||
|
||||
#undef USE_RTL_ROM_CLIB
|
||||
#define USE_RTL_ROM_CLIB 0
|
||||
|
||||
#if 1
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "basic_types.h"
|
||||
//#include <diag.h>
|
||||
|
||||
//#undef rt_printf
|
||||
//#define rt_printf stdio_printf_stubs.rt_printf
|
||||
//#define printf rt_printf
|
||||
|
||||
|
||||
//
|
||||
// memory management
|
||||
//
|
||||
//extern void *pvPortMalloc( size_t xWantedSize );
|
||||
//extern void vPortFree( void *pv );
|
||||
//#define malloc pvPortMalloc
|
||||
//#define free vPortFree
|
||||
#endif
|
||||
|
||||
#endif //PLATFORM_STDLIB_RTL8195BHP_H
|
||||
43
sdk/component/common/api/platform/platform_stdlib_rtl8710c.h
Normal file
43
sdk/component/common/api/platform/platform_stdlib_rtl8710c.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#ifndef PLATFORM_STDLIB_RTL8710C_H
|
||||
#define PLATFORM_STDLIB_RTL8710C_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#undef USE_RTL_ROM_CLIB
|
||||
#define USE_RTL_ROM_CLIB 0
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "basic_types.h"
|
||||
|
||||
#if 0 //because sscanf in rom lib is not working!
|
||||
#include "rt_printf.h" //stdio_printf_stubs
|
||||
#if !defined(CONFIG_BUILD_SECURE)
|
||||
#undef sscanf
|
||||
#define sscanf(buf,...) (stdio_printf_stubs.rt_sscanf)(buf, __VA_ARGS__)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (__GNUC__)
|
||||
#define CONFIG_PLATFORM_AMEBA_X 1
|
||||
extern int __wrap_printf(const char * fmt,...);
|
||||
char *__wrap_strtok(char *s, char const *ct);
|
||||
#undef printf //libc may redefine to puts/putchar
|
||||
#define printf __wrap_printf
|
||||
#undef malloc //libc will redefine to malloc_r
|
||||
#define malloc pvPortMalloc
|
||||
#undef strtok //libc will redefine to strtok_r
|
||||
#define strtok __wrap_strtok
|
||||
#endif
|
||||
|
||||
//This section is not defined in 8710c's section_config.h. Be compatible with 8195A
|
||||
#define SRAM_BD_DATA_SECTION SECTION(".sram.bss")
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //PLATFORM_STDLIB_RTL8710C_H
|
||||
117
sdk/component/common/api/platform/platform_stdlib_rtl8711b.h
Normal file
117
sdk/component/common/api/platform/platform_stdlib_rtl8711b.h
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
#ifndef PLATFORM_STDLIB_RTL8711B_H
|
||||
#define PLATFORM_STDLIB_RTL8711B_H
|
||||
|
||||
#define USE_CLIB_PATCH 0
|
||||
|
||||
#if defined(CONFIG_BUILD_ROM) || defined(CONFIG_MBED_ENABLED)
|
||||
#define USE_RTL_ROM_CLIB 0
|
||||
#else
|
||||
#define BUFFERED_PRINTF 0
|
||||
#define USE_RTL_ROM_CLIB 1
|
||||
#endif
|
||||
|
||||
#if defined (__IARSTDLIB__)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h> /* va_list */
|
||||
#include "diag.h"
|
||||
|
||||
#define strsep(str, delim) _strsep(str, delim)
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h> /* va_list */
|
||||
#include "diag.h"
|
||||
#include "strproc.h"
|
||||
#include "memproc.h"
|
||||
#include "basic_types.h"
|
||||
#if USE_RTL_ROM_CLIB
|
||||
#include "rtl_lib.h"
|
||||
#include "rom_libc_string.h"
|
||||
#endif
|
||||
|
||||
#undef printf
|
||||
#undef sprintf
|
||||
#undef snprintf
|
||||
#undef memchr
|
||||
#undef memcmp
|
||||
#undef memcpy
|
||||
#undef memset
|
||||
#undef memmove
|
||||
#undef strcmp
|
||||
#undef strcpy
|
||||
#undef strlen
|
||||
#undef strncmp
|
||||
#undef strncpy
|
||||
#undef strsep
|
||||
#undef strtok
|
||||
#undef strcat
|
||||
#undef strchr
|
||||
#undef strncat
|
||||
#undef strstr
|
||||
#undef atol
|
||||
#undef atoi
|
||||
#undef strpbrk
|
||||
|
||||
#if USE_RTL_ROM_CLIB
|
||||
#if BUFFERED_PRINTF
|
||||
extern int buffered_printf(const char* fmt, ...);
|
||||
#define printf buffered_printf
|
||||
#else
|
||||
#define printf rtl_printf
|
||||
#endif
|
||||
#define sprintf rtl_sprintf
|
||||
#define snprintf rtl_snprintf
|
||||
#define vsnprintf rtl_vsnprintf
|
||||
#else
|
||||
#define printf DiagPrintf
|
||||
#define sprintf(fmt, arg...) DiagSPrintf((u8*)fmt, ##arg)
|
||||
#define snprintf DiagSnPrintf // NULL function
|
||||
#define vsnprintf(buf, size, fmt, ap) VSprintf(buf, fmt, ap)
|
||||
#endif
|
||||
#define memchr __rtl_memchr_v1_00
|
||||
#define memcmp(dst, src, sz) _memcmp(dst, src, sz)
|
||||
#define memcpy(dst, src, sz) _memcpy(dst, src, sz)
|
||||
#define memmove __rtl_memmove_v1_00
|
||||
#define memset(dst, val, sz) _memset(dst, val, sz)
|
||||
|
||||
#define strchr(s, c) _strchr(s, c) // for B-cut ROM
|
||||
#define strcmp(str1, str2) prvStrCmp((const unsigned char *) str1, (const unsigned char *) str2)
|
||||
#define strcpy(dest, src) _strcpy(dest, src)
|
||||
#define strlen(str) prvStrLen((const unsigned char *) str)
|
||||
#define strsep(str, delim) _strsep(str, delim)
|
||||
#define strstr(str1, str2) prvStrStr(str1, str2) // NULL function
|
||||
#define strtok(str, delim) prvStrtok(str, delim)//_strsep(str, delim)
|
||||
#define strcat __rtl_strcat_v1_00
|
||||
|
||||
#define strncmp(str1, str2, cnt) _strncmp(str1, str2, cnt)
|
||||
#define strncpy(dest, src, count) _strncpy(dest, src, count)
|
||||
#define strncat __rtl_strncat_v1_00
|
||||
|
||||
#define atol(str) strtol(str,NULL,10)
|
||||
#define atoi(str) prvAtoi(str)
|
||||
#define strpbrk(cs, ct) _strpbrk(cs, ct) // for B-cut ROM
|
||||
#if defined (__GNUC__)
|
||||
#undef sscanf
|
||||
#define sscanf _sscanf_patch
|
||||
#define rand Rand
|
||||
#define srand
|
||||
#endif
|
||||
//extern int _sscanf_patch(const char *buf, const char *fmt, ...);
|
||||
//#define sscanf _sscanf_patch
|
||||
|
||||
|
||||
#endif // defined (__IARSTDLIB__)
|
||||
|
||||
//
|
||||
// memory management
|
||||
//
|
||||
extern void *pvPortMalloc( size_t xWantedSize );
|
||||
extern void vPortFree( void *pv );
|
||||
#define malloc pvPortMalloc
|
||||
#define free vPortFree
|
||||
|
||||
#endif // PLATFORM_STDLIB_RTL8711B_H
|
||||
105
sdk/component/common/api/platform/platform_stdlib_rtl8721d.h
Normal file
105
sdk/component/common/api/platform/platform_stdlib_rtl8721d.h
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
#ifndef PLATFORM_STDLIB_8721D_H
|
||||
#define PLATFORM_STDLIB_8721D_H
|
||||
|
||||
#define CONFIG_PLATFORM_AMEBA_X 1
|
||||
|
||||
#if defined (__IARSTDLIB__)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h> /* va_list */
|
||||
#include "diag.h"
|
||||
|
||||
#define strsep(str, delim) _strsep(str, delim)
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h> /* va_list */
|
||||
#include "diag.h"
|
||||
#include "strproc.h"
|
||||
#include "memproc.h"
|
||||
#include "basic_types.h"
|
||||
#include "rtl8721d.h"
|
||||
#include "rtl8721d_ram_libc.h"
|
||||
#ifndef STD_PRINTF
|
||||
#undef printf
|
||||
#undef vsnprintf
|
||||
#undef sprintf
|
||||
#undef snprintf
|
||||
#undef sscanf
|
||||
#endif
|
||||
#undef memchr
|
||||
#undef memcmp
|
||||
#undef memcpy
|
||||
#undef memset
|
||||
#undef memmove
|
||||
#undef strcmp
|
||||
#undef strcpy
|
||||
#undef strlen
|
||||
#undef strncmp
|
||||
#undef strncpy
|
||||
#undef strsep
|
||||
#undef strtok
|
||||
#undef strcat
|
||||
#undef strchr
|
||||
#undef strncat
|
||||
#undef strstr
|
||||
#undef atol
|
||||
#undef atoi
|
||||
#undef strpbrk
|
||||
#undef strtoul
|
||||
#undef strtol
|
||||
#undef rand
|
||||
#ifndef STD_PRINTF
|
||||
#define printf _rtl_printf
|
||||
#define sprintf _rtl_sprintf
|
||||
#define snprintf _rtl_snprintf // NULL function
|
||||
#define vsnprintf _rtl_vsnprintf
|
||||
#define sscanf _rtl_sscanf //if use sscanf in std libc.a, please delete _strtol_r symbol in rlx8721d_rom_symbol_acut.ld
|
||||
#endif
|
||||
#define memchr _memchr
|
||||
#define memcmp _memcmp
|
||||
#define memcpy _memcpy //memcpy_gdma(dst, src, sz)
|
||||
#define memmove _memmove
|
||||
#define memset _memset
|
||||
|
||||
#define strchr(s, c) _strchr(s, c) // for B-cut ROM
|
||||
#define strcmp(str1, str2) _strcmp(str1, str2)
|
||||
#define strcpy _strcpy
|
||||
#define strlen _strlen
|
||||
#define strsep(str, delim) _strsep(str, delim)
|
||||
#define strstr(str1, str2) _strstr(str1, str2) // NULL function
|
||||
#define strtok(str, delim) _strtok(str, delim)//_strsep(str, delim)
|
||||
#define strcat _strcat
|
||||
|
||||
#define strncmp(str1, str2, cnt) _strncmp(str1, str2, cnt)
|
||||
#define strncpy(dest, src, count) _strncpy(dest, src, count)
|
||||
#define strncat _strncat
|
||||
|
||||
#define strtoul(str, endp, base) _strtoul(str, endp, base)
|
||||
#define strtol(str, endp, base) _strtol(str, endp, base)
|
||||
|
||||
#define atol(str) _strtol(str,NULL,10)
|
||||
#define atoi(str) _stratoi(str)
|
||||
#define strpbrk(cs, ct) _strpbrk(cs, ct) // for B-cut ROM
|
||||
#define rand Rand
|
||||
#define srand
|
||||
|
||||
//extern int _sscanf_patch(const char *buf, const char *fmt, ...);
|
||||
//#define sscanf _sscanf_patch
|
||||
|
||||
|
||||
#endif // defined (__IARSTDLIB__)
|
||||
|
||||
extern void *pvPortMalloc( size_t xWantedSize );
|
||||
extern void vPortFree( void *pv );
|
||||
extern void *pvPortReAlloc( void *pv, size_t xWantedSize );
|
||||
#define malloc pvPortMalloc
|
||||
#define free vPortFree
|
||||
#define realloc pvPortReAlloc
|
||||
#define calloc rtw_calloc
|
||||
|
||||
|
||||
#endif // PLATFORM_STDLIB_8721D_H
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef PLATFORM_STDLIB_STM32_H
|
||||
#define PLATFORM_STDLIB_STM32_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#endif // PLATFORM_STDLIB_STM32_H
|
||||
385
sdk/component/common/api/wifi/rtw_wowlan/wifi_wowlan.h
Normal file
385
sdk/component/common/api/wifi/rtw_wowlan/wifi_wowlan.h
Normal file
|
|
@ -0,0 +1,385 @@
|
|||
#ifndef _WIFI_WOWLAN_H_
|
||||
#define _WIFI_WOWLAN_H_
|
||||
|
||||
#include <platform_stdlib.h>
|
||||
#include <osdep_service.h>
|
||||
|
||||
#define WOWLAN_DBG 1
|
||||
|
||||
enum{
|
||||
WOWLAN_DBG_OFF = 0,
|
||||
WOWLAN_DBG_ALWAYS,
|
||||
WOWLAN_DBG_ERROR,
|
||||
WOWLAN_DBG_WARNING,
|
||||
WOWLAN_DBG_INFO
|
||||
};
|
||||
|
||||
#if WOWLAN_DBG
|
||||
//#define WOWLAN_DUMP_MSG
|
||||
#define WOWLAN_DUMP_MSG_1 //dump packet when setting
|
||||
static unsigned char gWowlanDbgLevel = WOWLAN_DBG_ERROR;
|
||||
#define WOWLAN_PRINTK(fmt, args...) printf(fmt"\r\n",## args)
|
||||
#define _WOWLAN_PRINTK(fmt, args...) printf(fmt,## args)
|
||||
#define WOWLAN_DBG_MSG(level, fmt, args...) \
|
||||
do{ \
|
||||
if(level <= gWowlanDbgLevel){ \
|
||||
WOWLAN_PRINTK(fmt,## args); \
|
||||
} \
|
||||
}while(0)
|
||||
#else
|
||||
#define WOWLAN_PRINTK(fmt, args...)
|
||||
#define WOWLAN_DBG_MSG(level, fmt, args...)
|
||||
#endif
|
||||
|
||||
#ifndef u8
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
#endif
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(x) ((u32)1 << (x))
|
||||
#endif
|
||||
|
||||
#ifndef le16_to_cpu //need a general definition for the whole system
|
||||
#define cpu_to_le32(x) ((u32)(x))
|
||||
#define le32_to_cpu(x) ((u32)(x))
|
||||
#define cpu_to_le16(x) ((u16)(x))
|
||||
#define le16_to_cpu(x) ((u16)(x))
|
||||
#endif
|
||||
|
||||
#ifndef IP_FMT
|
||||
#define IP_FMT "%d.%d.%d.%d"
|
||||
#endif
|
||||
|
||||
#ifndef IP_ARG
|
||||
#define IP_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3]
|
||||
#endif
|
||||
|
||||
#ifndef MAC_FMT
|
||||
#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
#endif
|
||||
|
||||
#ifndef MAC_ARG
|
||||
#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
|
||||
#endif
|
||||
|
||||
#ifndef ETH_ALEN
|
||||
#define ETH_ALEN 6
|
||||
#endif
|
||||
|
||||
#ifndef ethhdr
|
||||
struct ethhdr
|
||||
{
|
||||
unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
|
||||
unsigned char h_source[ETH_ALEN]; /* source ether addr */
|
||||
unsigned short h_proto; /* packet type ID field */
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef wowlan_memcpy
|
||||
#define wowlan_memcpy(d, s, n) rtw_memcpy((void*)(d), ((void*)(s)), (n))
|
||||
#endif
|
||||
|
||||
#ifndef wowlan_malloc
|
||||
#define wowlan_malloc(sz) rtw_malloc(sz)
|
||||
#endif
|
||||
|
||||
#ifndef wowlan_zmalloc
|
||||
#define wowlan_zmalloc(sz) rtw_zmalloc(sz)
|
||||
#endif
|
||||
|
||||
#ifndef wowlan_memset
|
||||
#define wowlan_memset(pbuf, c, sz) rtw_memset(pbuf, c, sz)
|
||||
#endif
|
||||
|
||||
#ifndef wowlan_mfree
|
||||
#define wowlan_mfree(p, sz) rtw_mfree(((u8*)(p)), (sz))
|
||||
#endif
|
||||
|
||||
#ifndef wowlan_memcmp
|
||||
#define wowlan_memcmp(s1, s2, n) rtw_memcmp(((void*)(s1)), ((void*)(s2)), (n))
|
||||
#endif
|
||||
|
||||
#ifndef wowlan_mdelay_os
|
||||
#define wowlan_mdelay_os(ms) rtw_mdelay_os(ms)
|
||||
#endif
|
||||
|
||||
/*Mutex services*/
|
||||
typedef _mutex _wowlock;
|
||||
|
||||
__inline static void _init_wowlock(_wowlock *plock)
|
||||
{
|
||||
rtw_mutex_init(plock);
|
||||
}
|
||||
|
||||
__inline static void _free_wowlock(_wowlock *plock)
|
||||
{
|
||||
rtw_mutex_free(plock);
|
||||
}
|
||||
|
||||
__inline static void _enter_wowlock(_wowlock *plock)
|
||||
{
|
||||
rtw_mutex_get(plock);
|
||||
}
|
||||
|
||||
__inline static void _exit_wowlock(_wowlock *plock)
|
||||
{
|
||||
rtw_mutex_put(plock);
|
||||
}
|
||||
|
||||
/*Timer services*/
|
||||
typedef _timerHandle _wowTimer;
|
||||
#define TMR_AUTO_RELOAD_EN _TRUE
|
||||
#define TMR_AUTO_RELOAD_DIS _FALSE
|
||||
|
||||
__inline static void
|
||||
_wowlan_init_timer(_wowTimer *ptimer, void *adapter, TIMER_FUN pfunc,void* cntx, const char *name, u32 auto_reload)
|
||||
{
|
||||
*ptimer = rtw_timerCreate(
|
||||
(signed const char *)name, // Just a text name, not used by the RTOS kernel.
|
||||
TIMER_MAX_DELAY, // Timer Period, not 0
|
||||
auto_reload, // Whether timer will auto-load themselves when expires
|
||||
cntx, // Uniq id used to identify which timer expire..
|
||||
pfunc // Timer callback
|
||||
);
|
||||
}
|
||||
|
||||
__inline static void
|
||||
_wowlan_set_timer(_wowTimer *ptimer, u32 delay_time_ms)
|
||||
{
|
||||
if(rtw_timerChangePeriod(*ptimer, rtw_ms_to_systime(delay_time_ms), TIMER_MAX_DELAY) == _FAIL)
|
||||
WOWLAN_PRINTK("Fail to set timer period");
|
||||
}
|
||||
|
||||
__inline static void
|
||||
_wowlan_cancel_timer(_wowTimer *ptimer)
|
||||
{
|
||||
rtw_timerStop(*ptimer, TIMER_MAX_DELAY);
|
||||
}
|
||||
|
||||
__inline static void
|
||||
_wowlan_del_timer(_wowTimer *ptimer)
|
||||
{
|
||||
rtw_timerDelete(*ptimer, TIMER_MAX_DELAY);
|
||||
}
|
||||
|
||||
__inline static void *
|
||||
_wowlan_get_timer_cntx(_wowTimer timer)
|
||||
{
|
||||
#ifdef PLATFORM_FREERTOS
|
||||
#include <FreeRTOS.h>
|
||||
#include <timers.h>
|
||||
return pvTimerGetTimerID(timer);
|
||||
#else
|
||||
#error "_wowlan_get_timer_cntx is not defined"
|
||||
#endif
|
||||
}
|
||||
|
||||
enum rtw_wowlan_wakeup_reason {
|
||||
RTW_WOWLAN_WAKEUP_BY_PATTERN = BIT(0),
|
||||
RTW_WOWLAN_WAKEUP_BY_DISCONNECTION = BIT(1),
|
||||
RTW_WOWLAN_WAKEUP_MAX = 0x7FFFFFFF
|
||||
};
|
||||
|
||||
enum rtw_wowlan_cmd_id{
|
||||
RTW_WOWLAN_CMD_ENABLE = 0x01, // enable wowlan service
|
||||
RTW_WOWLAN_CMD_PATTERNS = 0x02, // wowlan pattern setting
|
||||
RTW_WOWLAN_CMD_PROT_OFFLOAD_CONFIG = 0x03, //ARP offload setting
|
||||
RTW_WOWLAN_CMD_GET_STATUS = 0x04, // get rtw_wowlan_status
|
||||
RTW_WOWLAN_CMD_CLEAR_ALL = 0x05, //clear wowlan content
|
||||
RTW_WOWLAN_CMD_KEEPALIVE = 0x06, //for keep alive packet setting
|
||||
RTW_WOWLAN_CMD_MAX = 0xff
|
||||
};
|
||||
|
||||
#define RTW_WOWLAN_MAX_RX_FILTERS (5)
|
||||
#define RTW_WOWLAN_RX_FILTER_MAX_FIELDS (8)
|
||||
#define RTW_WOWLAN_ID_OFFSET (100) //to match some application, ID starts from 100
|
||||
#define RTW_WOWLAN_MIN_FILTERS_ID (RTW_WOWLAN_ID_OFFSET)
|
||||
#define RTW_WOWLAN_MAX_FILTERS_ID (RTW_WOWLAN_ID_OFFSET+RTW_WOWLAN_MAX_RX_FILTERS-1)
|
||||
|
||||
struct rtw_wowlan_rx_filter_field {
|
||||
u16 offset;
|
||||
u8 len;
|
||||
u8 flags;
|
||||
u8 *mask;
|
||||
u8 *pattern;
|
||||
};
|
||||
|
||||
struct rtw_wowlan_rx_filter {
|
||||
u8 action;
|
||||
u8 offset;
|
||||
u8 num_fields;
|
||||
struct rtw_wowlan_rx_filter_field fields[RTW_WOWLAN_RX_FILTER_MAX_FIELDS];
|
||||
};
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined (__GNUC__)
|
||||
#pragma pack(1)
|
||||
#else
|
||||
#error "this structure needs to be packed!"
|
||||
#endif
|
||||
struct rtw_wowlan_status {
|
||||
u32 wakeup_reasons; //record wake up reason
|
||||
u32 filter_id; //record which pattern is matched
|
||||
};
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined (__GNUC__)
|
||||
#pragma pack()
|
||||
#else
|
||||
#error "this structure needs to be packed!"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* struct rtw_wowlan_keepalive_packet
|
||||
*
|
||||
* @payload_len: data payload length
|
||||
* @payload: data payload buffer
|
||||
* @data_interval: interval at which to send data packets
|
||||
**/
|
||||
#define RTW_WOWLAN_MAX_KPALIVE_PKT 3
|
||||
#define RTW_WOWLAN_MAX_KPALIVE_PKT_SZ 512
|
||||
struct rtw_wowlan_keepalive_packet{
|
||||
u8 packet_id;
|
||||
int payload_len;
|
||||
u8 *payload;
|
||||
u32 data_interval;
|
||||
_wowTimer keepalive_tmr;
|
||||
};
|
||||
|
||||
struct rtw_wowlan_ops {
|
||||
int (*DevWowlanInit)(void);
|
||||
int (*DevWowlanEnable)(void);
|
||||
int (*DevWowlanDisable)(void);
|
||||
int (*DevWowlanWakeUp)(void);
|
||||
int (*DevWowlanSleep)(void);
|
||||
};
|
||||
|
||||
/**
|
||||
* enum rtw_wowlan_proto_offloads - enabled protocol offloads
|
||||
* @RTW_WOWLAN_PROTO_OFFLOAD_ARP: ARP data is enabled
|
||||
*/
|
||||
enum rtw_wowlan_proto_offloads {
|
||||
RTW_WOWLAN_PROTO_OFFLOAD_ARP = BIT(0),
|
||||
RTW_WOWLAN_PROTO_OFFLOAD_MAX = 0x7FFFFFFF
|
||||
};
|
||||
|
||||
/**
|
||||
* struct rtw_wowlan_proto_offload_common - ARP/NS offload common part
|
||||
* @enabled: enable flags
|
||||
* @remote_ipv4_addr: remote address to answer to (or zero if all)
|
||||
* @host_ipv4_addr: our IPv4 address to respond to queries for
|
||||
* @arp_mac_addr: our MAC address for ARP responses
|
||||
* @reserved: unused
|
||||
*/
|
||||
struct rtw_wowlan_proto_offload_common{
|
||||
int proto_enabled;
|
||||
u32 remote_ipv4_addr;
|
||||
u32 host_ipv4_addr;
|
||||
u8 host_mac_addr[ETH_ALEN];
|
||||
u16 reserved;
|
||||
};
|
||||
|
||||
struct rtw_wowlan {
|
||||
_wowlock wow_mutex;
|
||||
bool enabled;
|
||||
struct rtw_wowlan_status status;
|
||||
struct rtw_wowlan_ops ops;
|
||||
struct rtw_wowlan_proto_offload_common proto;
|
||||
bool proto_offload_enabled;
|
||||
struct rtw_wowlan_rx_filter *rx_filter[RTW_WOWLAN_MAX_RX_FILTERS];
|
||||
bool rx_filter_enabled[RTW_WOWLAN_MAX_RX_FILTERS];/* RX Data filter rule state - enabled/disabled */
|
||||
struct rtw_wowlan_keepalive_packet *tx_keepalive[RTW_WOWLAN_MAX_KPALIVE_PKT];
|
||||
bool tx_keepalive_enabled[RTW_WOWLAN_MAX_KPALIVE_PKT];/* TX keep avlive rule state - enabled/disabled */
|
||||
};
|
||||
|
||||
#define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 )
|
||||
#define cpMacAddr(des,src) ((des)[0]=(src)[0],(des)[1]=(src)[1],(des)[2]=(src)[2],(des)[3]=(src)[3],(des)[4]=(src)[4],(des)[5]=(src)[5])
|
||||
#define cpIpAddr(des,src) ((des)[0]=(src)[0],(des)[1]=(src)[1],(des)[2]=(src)[2],(des)[3]=(src)[3])
|
||||
|
||||
#define RTW_WOWLAN_GET_ARP_PKT_OPERATION(__pHeader) ReadEF2Byte( ((u8*)(__pHeader)) + 6)
|
||||
#define RTW_WOWLAN_GET_ARP_PKT_SENDER_MAC_ADDR(__pHeader, _val) cpMacAddr((u8*)(_val), ((u8*)(__pHeader))+8)
|
||||
#define RTW_WOWLAN_GET_ARP_PKT_SENDER_IP_ADDR(__pHeader, _val) cpIpAddr((u8*)(_val), ((u8*)(__pHeader))+14)
|
||||
#define RTW_WOWLAN_GET_ARP_PKT_TARGET_MAC_ADDR(__pHeader, _val) cpMacAddr((u8*)(_val), ((u8*)(__pHeader))+18)
|
||||
#define RTW_WOWLAN_GET_ARP_PKT_TARGET_IP_ADDR(__pHeader, _val) cpIpAddr((u8*)(_val), ((u8*)(__pHeader))+24)
|
||||
|
||||
#define RTW_WOWLAN_SET_ARP_PKT_HW(__pHeader, __Value) WriteEF2Byte( ((u8*)(__pHeader)) + 0, __Value)
|
||||
#define RTW_WOWLAN_SET_ARP_PKT_PROTOCOL(__pHeader, __Value) WriteEF2Byte( ((u8*)(__pHeader)) + 2, __Value)
|
||||
#define RTW_WOWLAN_SET_ARP_PKT_HW_ADDR_LEN(__pHeader, __Value) WriteEF1Byte( ((u8*)(__pHeader)) + 4, __Value)
|
||||
#define RTW_WOWLAN_SET_ARP_PKT_PROTOCOL_ADDR_LEN(__pHeader, __Value) WriteEF1Byte( ((u8*)(__pHeader)) + 5, __Value)
|
||||
#define RTW_WOWLAN_SET_ARP_PKT_OPERATION(__pHeader, __Value) WriteEF2Byte( ((u8*)(__pHeader)) + 6, __Value)
|
||||
#define RTW_WOWLAN_SET_ARP_PKT_SENDER_MAC_ADDR(__pHeader, _val) cpMacAddr(((u8*)(__pHeader))+8, (u8*)(_val))
|
||||
#define RTW_WOWLAN_SET_ARP_PKT_SENDER_IP_ADDR(__pHeader, _val) cpIpAddr(((u8*)(__pHeader))+14, (u8*)(_val))
|
||||
#define RTW_WOWLAN_SET_ARP_PKT_TARGET_MAC_ADDR(__pHeader, _val) cpMacAddr(((u8*)(__pHeader))+18, (u8*)(_val))
|
||||
#define RTW_WOWLAN_SET_ARP_PKT_TARGET_IP_ADDR(__pHeader, _val) cpIpAddr(((u8*)(__pHeader))+24, (u8*)(_val))
|
||||
|
||||
#define RTW_WOWLAN_ARP_PKT_LEN 0x2A
|
||||
#define RTW_WOWLAN_ARP_PKT_OPERATION_REQ 0x0100 //arp request
|
||||
#define RTW_WOWLAN_ARP_PKT_OPERATION_RSP 0x0200 //arp response
|
||||
|
||||
extern u8 key_2char2num(u8 hch, u8 lch);
|
||||
extern _LONG_CALL_ void __rtl_memDump_v1_00(const u8 *start, u32 size, char * strHeader);
|
||||
#define rtw_wowlan_DumpForBytes(pData, Len) __rtl_memDump_v1_00(pData, Len, NULL)
|
||||
|
||||
#define PWOWLAN_TO_STATUS(pwowlan) (&pwowlan->status)
|
||||
#define PWOWLAN_TO_OPS(pwowlan) (&pwowlan->ops)
|
||||
#define PWOWLAN_TO_PROTO(pwowlan) (&pwowlan->proto)
|
||||
#define PWOWLAN_TO_RX_FILTER(pwowlan) (pwowlan->rx_filter)
|
||||
#define PWOWLAN_TO_TX_KEEPALIVE(pwowlan) (pwowlan->tx_keepalive)
|
||||
|
||||
/**
|
||||
* rtw_wowlan_init: initialize wowlan service
|
||||
* arg: None
|
||||
* return: _SUCCESS or _FAIL
|
||||
*/
|
||||
extern int rtw_wowlan_init(void);
|
||||
|
||||
/**
|
||||
* cmd_wowlan_service: input commands to configure wowlan service
|
||||
* arg:
|
||||
* @argc: number of input parameter
|
||||
* @argv: content of input string
|
||||
* return: None
|
||||
*/
|
||||
extern void cmd_wowlan_service(int argc, char **argv);
|
||||
|
||||
/**
|
||||
* rtw_wowlan_process_rx_packet: entry for packet process in wowlan service once it starts
|
||||
* arg:
|
||||
* @rx_pkt: receive packet from wlan/ethernet
|
||||
* @pkt_len: receive packet length
|
||||
* return: _SUCCESS or _FAIL
|
||||
*/
|
||||
extern int rtw_wowlan_process_rx_packet(char *rx_pkt, u16 pkt_len);
|
||||
|
||||
/**
|
||||
* rtw_wowlan_wakeup_process: wake up process once the reasons are matched,
|
||||
* refer to enum rtw_wowlan_wakeup_reason
|
||||
* arg:
|
||||
* @reason: wake up reason, refer to enum rtw_wowlan_wakeup_reason
|
||||
* return: None
|
||||
*/
|
||||
extern void rtw_wowlan_wakeup_process(int reason);
|
||||
|
||||
/**
|
||||
* rtw_wowlan_is_enabled: if wowlan service is already enabled
|
||||
* this function is called in rx path and wifi_inidication when wowlan service is running
|
||||
* arg: None
|
||||
* return: _True if enable or _False if disable
|
||||
*/
|
||||
extern int rtw_wowlan_is_enabled(void);
|
||||
|
||||
/**
|
||||
* rtw_wowlan_get_wk_reason: query wake up reason, refer to enum rtw_wowlan_wakeup_reason
|
||||
* arg: None
|
||||
* return: wakeup_reason
|
||||
*/
|
||||
extern int rtw_wowlan_get_wk_reason(void);
|
||||
|
||||
/**
|
||||
* rtw_wowlan_dev_sleep: sleep process on Ameba side, pull control for example
|
||||
* this function is linked to dev_wowlan_sleep_process() in dev_wowlan.c
|
||||
* arg: None
|
||||
* return: None
|
||||
*/
|
||||
extern void rtw_wowlan_dev_sleep(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,326 @@
|
|||
/*
|
||||
* WPA Supplicant - Common definitions
|
||||
* Copyright (c) 2004-2015, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README 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)
|
||||
#define WPA_CIPHER_AES_128_CMAC BIT(5)
|
||||
#define WPA_CIPHER_GCMP BIT(6)
|
||||
#define WPA_CIPHER_SMS4 BIT(7)
|
||||
#define WPA_CIPHER_GCMP_256 BIT(8)
|
||||
#define WPA_CIPHER_CCMP_256 BIT(9)
|
||||
#define WPA_CIPHER_BIP_GMAC_128 BIT(11)
|
||||
#define WPA_CIPHER_BIP_GMAC_256 BIT(12)
|
||||
#define WPA_CIPHER_BIP_CMAC_256 BIT(13)
|
||||
#define WPA_CIPHER_GTK_NOT_USED BIT(14)
|
||||
|
||||
#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_SAE BIT(10)
|
||||
#define WPA_KEY_MGMT_FT_SAE BIT(11)
|
||||
#define WPA_KEY_MGMT_WAPI_PSK BIT(12)
|
||||
#define WPA_KEY_MGMT_WAPI_CERT BIT(13)
|
||||
#define WPA_KEY_MGMT_CCKM BIT(14)
|
||||
#define WPA_KEY_MGMT_OSEN BIT(15)
|
||||
#define WPA_KEY_MGMT_IEEE8021X_SUITE_B BIT(16)
|
||||
#define WPA_KEY_MGMT_IEEE8021X_SUITE_B_192 BIT(17)
|
||||
|
||||
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_OSEN |
|
||||
WPA_KEY_MGMT_IEEE8021X_SHA256 |
|
||||
WPA_KEY_MGMT_IEEE8021X_SUITE_B |
|
||||
WPA_KEY_MGMT_IEEE8021X_SUITE_B_192));
|
||||
}
|
||||
|
||||
static inline int wpa_key_mgmt_wpa_psk(int akm)
|
||||
{
|
||||
return !!(akm & (WPA_KEY_MGMT_PSK |
|
||||
WPA_KEY_MGMT_FT_PSK |
|
||||
WPA_KEY_MGMT_PSK_SHA256 |
|
||||
WPA_KEY_MGMT_SAE |
|
||||
WPA_KEY_MGMT_FT_SAE));
|
||||
}
|
||||
|
||||
static inline int wpa_key_mgmt_ft(int akm)
|
||||
{
|
||||
return !!(akm & (WPA_KEY_MGMT_FT_PSK |
|
||||
WPA_KEY_MGMT_FT_IEEE8021X |
|
||||
WPA_KEY_MGMT_FT_SAE));
|
||||
}
|
||||
|
||||
static inline int wpa_key_mgmt_sae(int akm)
|
||||
{
|
||||
return !!(akm & (WPA_KEY_MGMT_SAE |
|
||||
WPA_KEY_MGMT_FT_SAE));
|
||||
}
|
||||
|
||||
static inline int wpa_key_mgmt_sha256(int akm)
|
||||
{
|
||||
return !!(akm & (WPA_KEY_MGMT_PSK_SHA256 |
|
||||
WPA_KEY_MGMT_IEEE8021X_SHA256 |
|
||||
WPA_KEY_MGMT_OSEN |
|
||||
WPA_KEY_MGMT_IEEE8021X_SUITE_B));
|
||||
}
|
||||
|
||||
static inline int wpa_key_mgmt_sha384(int akm)
|
||||
{
|
||||
return !!(akm & WPA_KEY_MGMT_IEEE8021X_SUITE_B_192);
|
||||
}
|
||||
|
||||
static inline int wpa_key_mgmt_suite_b(int akm)
|
||||
{
|
||||
return !!(akm & (WPA_KEY_MGMT_IEEE8021X_SUITE_B |
|
||||
WPA_KEY_MGMT_IEEE8021X_SUITE_B_192));
|
||||
}
|
||||
|
||||
static inline int wpa_key_mgmt_wpa(int akm)
|
||||
{
|
||||
return wpa_key_mgmt_wpa_ieee8021x(akm) ||
|
||||
wpa_key_mgmt_wpa_psk(akm) ||
|
||||
wpa_key_mgmt_sae(akm);
|
||||
}
|
||||
|
||||
static inline int wpa_key_mgmt_wpa_any(int akm)
|
||||
{
|
||||
return wpa_key_mgmt_wpa(akm) || (akm & WPA_KEY_MGMT_WPA_NONE);
|
||||
}
|
||||
|
||||
static inline int wpa_key_mgmt_cckm(int akm)
|
||||
{
|
||||
return akm == WPA_KEY_MGMT_CCKM;
|
||||
}
|
||||
|
||||
|
||||
#define WPA_PROTO_WPA BIT(0)
|
||||
#define WPA_PROTO_RSN BIT(1)
|
||||
#define WPA_PROTO_WAPI BIT(2)
|
||||
#define WPA_PROTO_OSEN BIT(3)
|
||||
|
||||
#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)
|
||||
#define WPA_AUTH_ALG_SAE BIT(4)
|
||||
|
||||
|
||||
enum wpa_alg {
|
||||
WPA_ALG_NONE,
|
||||
WPA_ALG_WEP,
|
||||
WPA_ALG_TKIP,
|
||||
WPA_ALG_CCMP,
|
||||
WPA_ALG_IGTK,
|
||||
WPA_ALG_PMK,
|
||||
WPA_ALG_GCMP,
|
||||
WPA_ALG_SMS4,
|
||||
WPA_ALG_KRK,
|
||||
WPA_ALG_GCMP_256,
|
||||
WPA_ALG_CCMP_256,
|
||||
WPA_ALG_BIP_GMAC_128,
|
||||
WPA_ALG_BIP_GMAC_256,
|
||||
WPA_ALG_BIP_CMAC_256
|
||||
};
|
||||
|
||||
/**
|
||||
* 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_INTERFACE_DISABLED - Interface disabled
|
||||
*
|
||||
* This state is entered if the network interface is disabled, e.g.,
|
||||
* due to rfkill. wpa_supplicant refuses any new operations that would
|
||||
* use the radio until the interface has been enabled.
|
||||
*/
|
||||
WPA_INTERFACE_DISABLED,
|
||||
|
||||
/**
|
||||
* 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_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
|
||||
};
|
||||
|
||||
#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,
|
||||
HOSTAPD_MODE_IEEE80211ANY,
|
||||
NUM_HOSTAPD_MODES
|
||||
};
|
||||
|
||||
/**
|
||||
* enum wpa_ctrl_req_type - Control interface request types
|
||||
*/
|
||||
enum wpa_ctrl_req_type {
|
||||
WPA_CTRL_REQ_UNKNOWN,
|
||||
WPA_CTRL_REQ_EAP_IDENTITY,
|
||||
WPA_CTRL_REQ_EAP_PASSWORD,
|
||||
WPA_CTRL_REQ_EAP_NEW_PASSWORD,
|
||||
WPA_CTRL_REQ_EAP_PIN,
|
||||
WPA_CTRL_REQ_EAP_OTP,
|
||||
WPA_CTRL_REQ_EAP_PASSPHRASE,
|
||||
WPA_CTRL_REQ_SIM,
|
||||
WPA_CTRL_REQ_PSK_PASSPHRASE,
|
||||
NUM_WPA_CTRL_REQS
|
||||
};
|
||||
|
||||
/* Maximum number of EAP methods to store for EAP server user information */
|
||||
#define EAP_MAX_METHODS 8
|
||||
|
||||
enum mesh_plink_state {
|
||||
PLINK_LISTEN = 1,
|
||||
PLINK_OPEN_SENT,
|
||||
PLINK_OPEN_RCVD,
|
||||
PLINK_CNF_RCVD,
|
||||
PLINK_ESTAB,
|
||||
PLINK_HOLDING,
|
||||
PLINK_BLOCKED,
|
||||
};
|
||||
|
||||
enum set_band {
|
||||
WPA_SETBAND_AUTO,
|
||||
WPA_SETBAND_5G,
|
||||
WPA_SETBAND_2G
|
||||
};
|
||||
|
||||
#endif /* DEFS_H */
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* IEEE 802.11 Common routines
|
||||
* 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_11_COMMON_H
|
||||
#define IEEE802_11_COMMON_H
|
||||
|
||||
/* Parsed Information Elements */
|
||||
struct ieee802_11_elems {
|
||||
const u8 *ssid;
|
||||
const u8 *supp_rates;
|
||||
const u8 *fh_params;
|
||||
const u8 *ds_params;
|
||||
const u8 *cf_params;
|
||||
const u8 *tim;
|
||||
const u8 *ibss_params;
|
||||
const u8 *challenge;
|
||||
const u8 *erp_info;
|
||||
const u8 *ext_supp_rates;
|
||||
const u8 *wpa_ie;
|
||||
const u8 *rsn_ie;
|
||||
const u8 *wmm; /* WMM Information or Parameter Element */
|
||||
const u8 *wmm_tspec;
|
||||
const u8 *wps_ie;
|
||||
const u8 *power_cap;
|
||||
const u8 *supp_channels;
|
||||
const u8 *mdie;
|
||||
const u8 *ftie;
|
||||
const u8 *timeout_int;
|
||||
const u8 *ht_capabilities;
|
||||
const u8 *ht_operation;
|
||||
const u8 *vht_capabilities;
|
||||
const u8 *vht_operation;
|
||||
const u8 *vendor_ht_cap;
|
||||
const u8 *p2p;
|
||||
const u8 *wfd;
|
||||
const u8 *link_id;
|
||||
const u8 *interworking;
|
||||
const u8 *hs20;
|
||||
const u8 *ext_capab;
|
||||
const u8 *bss_max_idle_period;
|
||||
const u8 *ssid_list;
|
||||
|
||||
u8 ssid_len;
|
||||
u8 supp_rates_len;
|
||||
u8 fh_params_len;
|
||||
u8 ds_params_len;
|
||||
u8 cf_params_len;
|
||||
u8 tim_len;
|
||||
u8 ibss_params_len;
|
||||
u8 challenge_len;
|
||||
u8 erp_info_len;
|
||||
u8 ext_supp_rates_len;
|
||||
u8 wpa_ie_len;
|
||||
u8 rsn_ie_len;
|
||||
u8 wmm_len; /* 7 = WMM Information; 24 = WMM Parameter */
|
||||
u8 wmm_tspec_len;
|
||||
u8 wps_ie_len;
|
||||
u8 power_cap_len;
|
||||
u8 supp_channels_len;
|
||||
u8 mdie_len;
|
||||
u8 ftie_len;
|
||||
u8 timeout_int_len;
|
||||
u8 ht_capabilities_len;
|
||||
u8 ht_operation_len;
|
||||
u8 vht_capabilities_len;
|
||||
u8 vht_operation_len;
|
||||
u8 vendor_ht_cap_len;
|
||||
u8 p2p_len;
|
||||
u8 wfd_len;
|
||||
u8 interworking_len;
|
||||
u8 hs20_len;
|
||||
u8 ext_capab_len;
|
||||
u8 ssid_list_len;
|
||||
};
|
||||
|
||||
typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes;
|
||||
|
||||
ParseRes ieee802_11_parse_elems(const u8 *start, size_t len,
|
||||
struct ieee802_11_elems *elems,
|
||||
int show_errors);
|
||||
int ieee802_11_ie_count(const u8 *ies, size_t ies_len);
|
||||
struct wpabuf * ieee802_11_vendor_ie_concat(const u8 *ies, size_t ies_len,
|
||||
u32 oui_type);
|
||||
struct ieee80211_hdr;
|
||||
//const u8 * get_hdr_bssid(const struct ieee80211_hdr *hdr, size_t len);
|
||||
|
||||
struct hostapd_wmm_ac_params {
|
||||
int cwmin;
|
||||
int cwmax;
|
||||
int aifs;
|
||||
int txop_limit; /* in units of 32us */
|
||||
int admission_control_mandatory;
|
||||
};
|
||||
|
||||
int hostapd_config_wmm_ac(struct hostapd_wmm_ac_params wmm_ac_params[],
|
||||
const char *name, const char *val);
|
||||
|
||||
#endif /* IEEE802_11_COMMON_H */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,460 @@
|
|||
/*
|
||||
* WPA Supplicant / wrapper functions for crypto libraries
|
||||
* Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README 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);
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* crypto_get_random - Generate cryptographically strong pseudy-random bytes
|
||||
* @buf: Buffer for data
|
||||
* @len: Number of bytes to generate
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* If the PRNG does not have enough entropy to ensure unpredictable byte
|
||||
* sequence, this functions must return -1.
|
||||
*/
|
||||
int crypto_get_random(void *buf, size_t len);
|
||||
|
||||
#endif /* CRYPTO_H */
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* DES and 3DES-EDE ciphers
|
||||
* 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 DES_I_H
|
||||
#define DES_I_H
|
||||
|
||||
struct des3_key_s {
|
||||
u32 ek[3][32];
|
||||
u32 dk[3][32];
|
||||
};
|
||||
|
||||
void des_key_setup(const u8 *key, u32 *ek, u32 *dk);
|
||||
void des_block_encrypt(const u8 *plain, const u32 *ek, u8 *crypt);
|
||||
void des_block_decrypt(const u8 *crypt, const u32 *dk, u8 *plain);
|
||||
|
||||
void des3_key_setup(const u8 *key, struct des3_key_s *dkey);
|
||||
void des3_encrypt(const u8 *plain, const struct des3_key_s *key, u8 *crypt);
|
||||
void des3_decrypt(const u8 *crypt, const struct des3_key_s *key, u8 *plain);
|
||||
|
||||
#endif /* DES_I_H */
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef DH_GROUP5_H
|
||||
#define DH_GROUP5_H
|
||||
|
||||
void *dh5_init(struct wpabuf **priv, struct wpabuf **publ);
|
||||
void *dh5_init_fixed(const struct wpabuf *priv, const 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 */
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Diffie-Hellman groups
|
||||
* Copyright (c) 2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README 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;
|
||||
#if (CONFIG_SAE_DH_SUPPORT == 1)
|
||||
const u8 *order;
|
||||
size_t order_len;
|
||||
unsigned int safe_prime:1;
|
||||
#endif
|
||||
};
|
||||
|
||||
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 */
|
||||
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* WPA Supplicant / shared MSCHAPV2 helper functions / RFC 2433 / RFC 2759
|
||||
* Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef MS_FUNCS_H
|
||||
#define MS_FUNCS_H
|
||||
|
||||
int generate_nt_response(const u8 *auth_challenge, const u8 *peer_challenge,
|
||||
const u8 *username, size_t username_len,
|
||||
const u8 *password, size_t password_len,
|
||||
u8 *response);
|
||||
int generate_nt_response_pwhash(const u8 *auth_challenge,
|
||||
const u8 *peer_challenge,
|
||||
const u8 *username, size_t username_len,
|
||||
const u8 *password_hash,
|
||||
u8 *response);
|
||||
int generate_authenticator_response(const u8 *password, size_t password_len,
|
||||
const u8 *peer_challenge,
|
||||
const u8 *auth_challenge,
|
||||
const u8 *username, size_t username_len,
|
||||
const u8 *nt_response, u8 *response);
|
||||
int generate_authenticator_response_pwhash(
|
||||
const u8 *password_hash,
|
||||
const u8 *peer_challenge, const u8 *auth_challenge,
|
||||
const u8 *username, size_t username_len,
|
||||
const u8 *nt_response, u8 *response);
|
||||
int nt_challenge_response(const u8 *challenge, const u8 *password,
|
||||
size_t password_len, u8 *response);
|
||||
|
||||
void challenge_response(const u8 *challenge, const u8 *password_hash,
|
||||
u8 *response);
|
||||
int challenge_hash(const u8 *peer_challenge, const u8 *auth_challenge,
|
||||
const u8 *username, size_t username_len, u8 *challenge);
|
||||
int nt_password_hash(const u8 *password, size_t password_len,
|
||||
u8 *password_hash);
|
||||
int hash_nt_password_hash(const u8 *password_hash, u8 *password_hash_hash);
|
||||
int get_master_key(const u8 *password_hash_hash, const u8 *nt_response,
|
||||
u8 *master_key);
|
||||
int get_asymetric_start_key(const u8 *master_key, u8 *session_key,
|
||||
size_t session_key_len, int is_send,
|
||||
int is_server);
|
||||
int __must_check encrypt_pw_block_with_password_hash(
|
||||
const u8 *password, size_t password_len,
|
||||
const u8 *password_hash, u8 *pw_block);
|
||||
int __must_check new_password_encrypted_with_old_nt_password_hash(
|
||||
const u8 *new_password, size_t new_password_len,
|
||||
const u8 *old_password, size_t old_password_len,
|
||||
u8 *encrypted_pw_block);
|
||||
void nt_password_hash_encrypted_with_block(const u8 *password_hash,
|
||||
const u8 *block, u8 *cypher);
|
||||
int old_nt_password_hash_encrypted_with_new_nt_password_hash(
|
||||
const u8 *new_password, size_t new_password_len,
|
||||
const u8 *old_password, size_t old_password_len,
|
||||
u8 *encrypted_password_hash);
|
||||
|
||||
#endif /* MS_FUNCS_H */
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Random number generator
|
||||
* Copyright (c) 2010-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef RANDOM_H
|
||||
#define RANDOM_H
|
||||
|
||||
#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);
|
||||
int random_pool_ready(void);
|
||||
void random_mark_pool_ready(void);
|
||||
#endif /* CONFIG_NO_RANDOM_POOL */
|
||||
#endif /* RANDOM_H */
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* AES-128 CBC
|
||||
*
|
||||
* Copyright (c) 2003-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
#ifndef ROM_WPS_AES_CBC_H
|
||||
#define ROM_WPS_AES_CBC_H
|
||||
|
||||
int rom_aes_128_cbc_encrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len);
|
||||
int rom_aes_128_cbc_decrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len);
|
||||
|
||||
#endif /* ROM_WPS_AES_CBC_H */
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* AES functions
|
||||
* Copyright (c) 2003-2006, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef ROM_WPS_AES_H
|
||||
#define ROM_WPS_AES_H
|
||||
|
||||
#define AES_BLOCK_SIZE 16
|
||||
|
||||
//void *aes_encrypt_init(const u8 *key, size_t len);
|
||||
void *rom_aes_encrypt_init(unsigned char *mem, const u8 *key, size_t len);
|
||||
|
||||
#if 1
|
||||
void rom_aes_internal_encrypt(void *ctx, const u8 *plain, u8 *crypt);
|
||||
#else
|
||||
void aes_encrypt(void *ctx, const u8 *plain, u8 *crypt);
|
||||
#endif
|
||||
void rom_aes_encrypt_deinit(void *ctx);
|
||||
|
||||
//void *aes_decrypt_init(const u8 *key, size_t len);
|
||||
void *rom_aes_decrypt_init(unsigned char *mem, const u8 *key, size_t len);
|
||||
|
||||
#if 1
|
||||
void rom_aes_internal_decrypt(void *ctx, const u8 *plain, u8 *crypt);
|
||||
#else
|
||||
void aes_decrypt(void *ctx, const u8 *crypt, u8 *plain);
|
||||
#endif
|
||||
void rom_aes_decrypt_deinit(void *ctx);
|
||||
|
||||
|
||||
#if 0
|
||||
void *aes_encrypt_init(const u8 *key, size_t len)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *aes_decrypt_init(const u8 *key, size_t len)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define aes_encrypt(...) do { } while (0)
|
||||
#define aes_encrypt_deinit(...) do { } while (0)
|
||||
|
||||
#define aes_decrypt(...) do { } while (0)
|
||||
#define aes_decrypt_deinit(...) do { } while (0)
|
||||
#endif
|
||||
|
||||
#endif /* ROM_WPS_AES_H */
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* AES (Rijndael) cipher
|
||||
* 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 ROM_WPS_AES_I_H
|
||||
#define ROM_WPS_AES_I_H
|
||||
|
||||
#include "rom_wps_aes.h"
|
||||
|
||||
/* #define FULL_UNROLL */
|
||||
#ifndef AES_SMALL_TABLES
|
||||
#define AES_SMALL_TABLES
|
||||
#endif
|
||||
extern const u32 rom_wps_Te0[256];
|
||||
extern const u32 rom_wps_Te1[256];
|
||||
extern const u32 rom_wps_Te2[256];
|
||||
extern const u32 rom_wps_Te3[256];
|
||||
extern const u32 rom_wps_Te4[256];
|
||||
extern const u32 rom_wps_Td0[256];
|
||||
extern const u32 rom_wps_Td1[256];
|
||||
extern const u32 rom_wps_Td2[256];
|
||||
extern const u32 rom_wps_Td3[256];
|
||||
extern const u32 rom_wps_Td4[256];
|
||||
extern const u32 rom_wps_rcon[10];
|
||||
extern const u8 rom_wps_Td4s[256];
|
||||
extern const u8 rom_wps_rcons[10];
|
||||
|
||||
|
||||
#ifndef AES_SMALL_TABLES
|
||||
|
||||
#define WPS_RCON(i) rom_wps_rcon[(i)]
|
||||
|
||||
#define WPS_TE0(i) rom_wps_Te0[((i) >> 24) & 0xff]
|
||||
#define WPS_TE1(i) rom_wps_Te1[((i) >> 16) & 0xff]
|
||||
#define WPS_TE2(i) rom_wps_Te2[((i) >> 8) & 0xff]
|
||||
#define WPS_TE3(i) rom_wps_Te3[(i) & 0xff]
|
||||
#define WPS_TE41(i) (rom_wps_Te4[((i) >> 24) & 0xff] & 0xff000000)
|
||||
#define WPS_TE42(i) (rom_wps_Te4[((i) >> 16) & 0xff] & 0x00ff0000)
|
||||
#define WPS_TE43(i) (rom_wps_Te4[((i) >> 8) & 0xff] & 0x0000ff00)
|
||||
#define WPS_TE44(i) (rom_wps_Te4[(i) & 0xff] & 0x000000ff)
|
||||
#define WPS_TE421(i) (rom_wps_Te4[((i) >> 16) & 0xff] & 0xff000000)
|
||||
#define WPS_TE432(i) (rom_wps_Te4[((i) >> 8) & 0xff] & 0x00ff0000)
|
||||
#define WPS_TE443(i) (rom_wps_Te4[(i) & 0xff] & 0x0000ff00)
|
||||
#define WPS_TE414(i) (rom_wps_Te4[((i) >> 24) & 0xff] & 0x000000ff)
|
||||
#define WPS_TE411(i) (rom_wps_Te4[((i) >> 24) & 0xff] & 0xff000000)
|
||||
#define WPS_TE422(i) (rom_wps_Te4[((i) >> 16) & 0xff] & 0x00ff0000)
|
||||
#define WPS_TE433(i) (rom_wps_Te4[((i) >> 8) & 0xff] & 0x0000ff00)
|
||||
#define WPS_TE444(i) (rom_wps_Te4[(i) & 0xff] & 0x000000ff)
|
||||
#define WPS_TE4(i) (rom_wps_Te4[(i)] & 0x000000ff)
|
||||
|
||||
#define WPS_TD0(i) rom_wps_Td0[((i) >> 24) & 0xff]
|
||||
#define WPS_TD1(i) rom_wps_Td1[((i) >> 16) & 0xff]
|
||||
#define WPS_TD2(i) rom_wps_Td2[((i) >> 8) & 0xff]
|
||||
#define WPS_TD3(i) rom_wps_Td3[(i) & 0xff]
|
||||
#define WPS_TD41(i) (rom_wps_Td4[((i) >> 24) & 0xff] & 0xff000000)
|
||||
#define WPS_TD42(i) (rom_wps_Td4[((i) >> 16) & 0xff] & 0x00ff0000)
|
||||
#define WPS_TD43(i) (rom_wps_Td4[((i) >> 8) & 0xff] & 0x0000ff00)
|
||||
#define WPS_TD44(i) (rom_wps_Td4[(i) & 0xff] & 0x000000ff)
|
||||
#define WPS_TD0_(i) rom_wps_Td0[(i) & 0xff]
|
||||
#define WPS_TD1_(i) rom_wps_Td1[(i) & 0xff]
|
||||
#define WPS_TD2_(i) rom_wps_Td2[(i) & 0xff]
|
||||
#define WPS_TD3_(i) rom_wps_Td3[(i) & 0xff]
|
||||
|
||||
|
||||
|
||||
#else /* AES_SMALL_TABLES */
|
||||
|
||||
#define WPS_RCON(i) (rom_wps_rcons[(i)] << 24)
|
||||
|
||||
#if 0
|
||||
static inline u32 wps_rotr(u32 val, int bits)
|
||||
{
|
||||
return (val >> bits) | (val << (32 - bits));
|
||||
}
|
||||
#else
|
||||
#define wps_rotr(val, bits) ((u32)((((u32) val) >> (int) bits) | (((u32) val) << (32 - (int) bits))))
|
||||
#endif
|
||||
|
||||
#define WPS_TE0(i) rom_wps_Te0[((i) >> 24) & 0xff]
|
||||
#define WPS_TE1(i) wps_rotr(rom_wps_Te0[((i) >> 16) & 0xff], 8)
|
||||
#define WPS_TE2(i) wps_rotr(rom_wps_Te0[((i) >> 8) & 0xff], 16)
|
||||
#define WPS_TE3(i) wps_rotr(rom_wps_Te0[(i) & 0xff], 24)
|
||||
#define WPS_TE41(i) ((rom_wps_Te0[((i) >> 24) & 0xff] << 8) & 0xff000000)
|
||||
#define WPS_TE42(i) (rom_wps_Te0[((i) >> 16) & 0xff] & 0x00ff0000)
|
||||
#define WPS_TE43(i) (rom_wps_Te0[((i) >> 8) & 0xff] & 0x0000ff00)
|
||||
#define WPS_TE44(i) ((rom_wps_Te0[(i) & 0xff] >> 8) & 0x000000ff)
|
||||
#define WPS_TE421(i) ((rom_wps_Te0[((i) >> 16) & 0xff] << 8) & 0xff000000)
|
||||
#define WPS_TE432(i) (rom_wps_Te0[((i) >> 8) & 0xff] & 0x00ff0000)
|
||||
#define WPS_TE443(i) (rom_wps_Te0[(i) & 0xff] & 0x0000ff00)
|
||||
#define WPS_TE414(i) ((rom_wps_Te0[((i) >> 24) & 0xff] >> 8) & 0x000000ff)
|
||||
#define WPS_TE411(i) ((rom_wps_Te0[((i) >> 24) & 0xff] << 8) & 0xff000000)
|
||||
#define WPS_TE422(i) (rom_wps_Te0[((i) >> 16) & 0xff] & 0x00ff0000)
|
||||
#define WPS_TE433(i) (rom_wps_Te0[((i) >> 8) & 0xff] & 0x0000ff00)
|
||||
#define WPS_TE444(i) ((rom_wps_Te0[(i) & 0xff] >> 8) & 0x000000ff)
|
||||
#define WPS_TE4(i) ((rom_wps_Te0[(i)] >> 8) & 0x000000ff)
|
||||
|
||||
#define WPS_TD0(i) rom_wps_Td0[((i) >> 24) & 0xff]
|
||||
#define WPS_TD1(i) wps_rotr(rom_wps_Td0[((i) >> 16) & 0xff], 8)
|
||||
#define WPS_TD2(i) wps_rotr(rom_wps_Td0[((i) >> 8) & 0xff], 16)
|
||||
#define WPS_TD3(i) wps_rotr(rom_wps_Td0[(i) & 0xff], 24)
|
||||
#define WPS_TD41(i) (rom_wps_Td4s[((i) >> 24) & 0xff] << 24)
|
||||
#define WPS_TD42(i) (rom_wps_Td4s[((i) >> 16) & 0xff] << 16)
|
||||
#define WPS_TD43(i) (rom_wps_Td4s[((i) >> 8) & 0xff] << 8)
|
||||
#define WPS_TD44(i) (rom_wps_Td4s[(i) & 0xff])
|
||||
#define WPS_TD0_(i) rom_wps_Td0[(i) & 0xff]
|
||||
#define WPS_TD1_(i) wps_rotr(rom_wps_Td0[(i) & 0xff], 8)
|
||||
#define WPS_TD2_(i) wps_rotr(rom_wps_Td0[(i) & 0xff], 16)
|
||||
#define WPS_TD3_(i) wps_rotr(rom_wps_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 WPS_AES_PRIV_SIZE (4* 44)//(4 * 4 * 15 + 4)
|
||||
#define WPS_AES_PRIV_NR_POS (4 * 15)
|
||||
|
||||
//int rijndaelKeySetupEnc(u32 rk[], const u8 cipherKey[], int keyBits);
|
||||
void rom_rijndaelKeySetupEnc(u32 rk[/*44*/], const u8 cipherKey[]);
|
||||
|
||||
#endif /* ROM_WPS_AES_I_H */
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* SHA-256 internal definitions
|
||||
* Copyright (c) 2003-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef ROM_WPS_SHA256_I_H
|
||||
#define ROM_WPS_SHA256_I_H
|
||||
|
||||
#define SHA256_BLOCK_SIZE 64
|
||||
|
||||
//extern struct sha256_state;
|
||||
|
||||
struct wps_sha256_state {
|
||||
u64 length;
|
||||
u32 state[8], curlen;
|
||||
u8 buf[64];
|
||||
};
|
||||
|
||||
|
||||
static void sha256_init(struct wps_sha256_state *md);
|
||||
static int wps_sha256_process(struct wps_sha256_state *md, const unsigned char *in,
|
||||
unsigned long inlen);
|
||||
static int sha256_done(struct wps_sha256_state *md, unsigned char *out);
|
||||
|
||||
#endif /* ROM_WPS_SHA256_I_H */
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* SHA256 hash implementation and interface functions
|
||||
* Copyright (c) 2003-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
#ifndef ROM_WPS_SHA256_H
|
||||
#define ROM_WPS_SHA256_H
|
||||
#define SHA256_MAC_LEN 32
|
||||
int rom_hmac_sha256_vector(const u8 *key, size_t key_len, size_t num_elem,
|
||||
const u8 *addr[], const size_t *len, u8 *mac);
|
||||
int rom_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);
|
||||
void tls_prf_sha256(const u8 *secret, size_t secret_len,
|
||||
const char *label, const u8 *seed, size_t seed_len,
|
||||
u8 *out, size_t outlen);
|
||||
|
||||
int rom_sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len,
|
||||
u8 *mac);
|
||||
#endif /* ROM_WPS_SHA256_H */
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* SHA1 hash implementation and interface functions
|
||||
* Copyright (c) 2003-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README 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_sha1_md5(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 u8 *ssid, size_t ssid_len,
|
||||
int iterations, u8 *buf, size_t buflen);
|
||||
#endif /* SHA1_H */
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* SHA1 internal definitions
|
||||
* Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README 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 */
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* SHA256 hash implementation and interface functions
|
||||
* Copyright (c) 2003-2014, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef SHA256_H
|
||||
#define SHA256_H
|
||||
|
||||
#define SHA256_MAC_LEN 32
|
||||
|
||||
int hmac_sha256_vector(const u8 *key, size_t key_len, size_t num_elem,
|
||||
const u8 *addr[], const size_t *len, u8 *mac);
|
||||
int 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);
|
||||
void sha256_prf_bits(const u8 *key, size_t key_len, const char *label,
|
||||
const u8 *data, size_t data_len, u8 *buf,
|
||||
size_t buf_len_bits);
|
||||
void tls_prf_sha256(const u8 *secret, size_t secret_len,
|
||||
const char *label, const u8 *seed, size_t seed_len,
|
||||
u8 *out, size_t outlen);
|
||||
int hmac_sha256_kdf(const u8 *secret, size_t secret_len,
|
||||
const char *label, const u8 *seed, size_t seed_len,
|
||||
u8 *out, size_t outlen);
|
||||
|
||||
#endif /* SHA256_H */
|
||||
|
|
@ -0,0 +1,589 @@
|
|||
/*
|
||||
* 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_random {
|
||||
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,
|
||||
TLS_FAIL_DOMAIN_SUFFIX_MISMATCH = 9,
|
||||
TLS_FAIL_DOMAIN_MISMATCH = 10,
|
||||
};
|
||||
|
||||
|
||||
#define TLS_MAX_ALT_SUBJECT 10
|
||||
|
||||
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;
|
||||
const char *altsubject[TLS_MAX_ALT_SUBJECT];
|
||||
int num_altsubject;
|
||||
} 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;
|
||||
const char *openssl_ciphers;
|
||||
unsigned int tls_session_lifetime;
|
||||
|
||||
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)
|
||||
#define TLS_CONN_DISABLE_TLSv1_1 BIT(5)
|
||||
#define TLS_CONN_DISABLE_TLSv1_2 BIT(6)
|
||||
#define TLS_CONN_EAP_FAST BIT(7)
|
||||
#define TLS_CONN_DISABLE_TLSv1_0 BIT(8)
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @suffix_match: String to suffix match in the dNSName or CN of the peer
|
||||
* certificate or %NULL to allow all domain names. This may allow subdomains an
|
||||
* wildcard certificates. Each domain name label must have a full match.
|
||||
* @domain_match: String to match in the dNSName or CN of the peer
|
||||
* certificate or %NULL to allow all domain names. This requires a full,
|
||||
* case-insensitive match.
|
||||
* @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
|
||||
* @openssl_ciphers: OpenSSL cipher configuration
|
||||
* @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 *suffix_match;
|
||||
const char *domain_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;
|
||||
const char *openssl_ciphers;
|
||||
|
||||
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.
|
||||
*/
|
||||
//ssl_context * tls_init(const struct tls_config *conf);
|
||||
void * tls_init(const struct tls_config *conf);
|
||||
|
||||
/**
|
||||
* 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_BAD_PIN = -4,
|
||||
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 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, or
|
||||
* TLS_SET_PARAMS_ENGINE_PRV_BAD_PIN (-4) on PIN error causing PKCS#11 engine
|
||||
* failure.
|
||||
*/
|
||||
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 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, or
|
||||
* TLS_SET_PARAMS_ENGINE_PRV_BAD_PIN (-4) on PIN error causing PKCS#11 engine
|
||||
* failure.
|
||||
*/
|
||||
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
|
||||
* @flags: Connection flags (TLS_CONN_*)
|
||||
* @session_ctx: Session caching context or %NULL to use default
|
||||
* @session_ctx_len: Length of @session_ctx in bytes.
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int __must_check tls_connection_set_verify(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
int verify_peer,
|
||||
unsigned int flags,
|
||||
const u8 *session_ctx,
|
||||
size_t session_ctx_len);
|
||||
|
||||
/**
|
||||
* tls_connection_get_random - Get random data from TLS connection
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @data: Structure of client/server random data (filled on success)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int __must_check tls_connection_get_random(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
struct tls_random *data);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @skip_keyblock: Skip TLS key block from the beginning of PRF output
|
||||
* @out: Buffer for output data from TLS-PRF
|
||||
* @out_len: Length of the output buffer
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* tls_connection_prf() is required so that further keying material can be
|
||||
* derived from the master secret. 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). For TLSv1.2 and
|
||||
* newer, a different PRF is needed, though.
|
||||
*/
|
||||
int __must_check tls_connection_prf(void *tls_ctx,
|
||||
struct tls_connection *conn,
|
||||
const char *label,
|
||||
int server_random_first,
|
||||
int skip_keyblock,
|
||||
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_version - Get the current TLS version number
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
* @conn: Connection context data from tls_connection_init()
|
||||
* @buf: Buffer for returning the TLS version number
|
||||
* @buflen: buf size
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* Get the currently used TLS version number.
|
||||
*/
|
||||
int __must_check tls_get_version(void *tls_ctx, struct tls_connection *conn,
|
||||
char *buf, size_t buflen);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
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);
|
||||
|
||||
void tls_connection_set_log_cb(struct tls_connection *conn,
|
||||
void (*log_cb)(void *ctx, const char *msg),
|
||||
void *ctx);
|
||||
|
||||
#define TLS_BREAK_VERIFY_DATA BIT(0)
|
||||
#define TLS_BREAK_SRV_KEY_X_HASH BIT(1)
|
||||
#define TLS_BREAK_SRV_KEY_X_SIGNATURE BIT(2)
|
||||
#define TLS_DHE_PRIME_511B BIT(3)
|
||||
#define TLS_DHE_PRIME_767B BIT(4)
|
||||
#define TLS_DHE_PRIME_15 BIT(5)
|
||||
#define TLS_DHE_PRIME_58B BIT(6)
|
||||
#define TLS_DHE_NON_PRIME BIT(7)
|
||||
|
||||
void tls_connection_set_test_flags(struct tls_connection *conn, u32 flags);
|
||||
|
||||
int tls_get_library_version(char *buf, size_t buf_len);
|
||||
|
||||
void tls_connection_set_success_data(struct tls_connection *conn,
|
||||
struct wpabuf *data);
|
||||
|
||||
void tls_connection_set_success_data_resumed(struct tls_connection *conn);
|
||||
|
||||
const struct wpabuf *
|
||||
tls_connection_get_success_data(struct tls_connection *conn);
|
||||
|
||||
void tls_connection_remove_session(struct tls_connection *conn);
|
||||
|
||||
#endif /* TLS_H */
|
||||
|
|
@ -0,0 +1,314 @@
|
|||
/*
|
||||
* 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 "utils/wpabuf.h"
|
||||
#include "eap_defs.h"
|
||||
|
||||
|
||||
#if 0 // not using this
|
||||
typedef unsigned char Boolean;
|
||||
|
||||
struct eap_method {
|
||||
/**
|
||||
* vendor - EAP Vendor-ID (EAP_VENDOR_*) (0 = IETF)
|
||||
*/
|
||||
int vendor;
|
||||
|
||||
/**
|
||||
* method - EAP type number (EAP_TYPE_*)
|
||||
*/
|
||||
EapType method;
|
||||
|
||||
/**
|
||||
* name - Name of the method (e.g., "TLS")
|
||||
*/
|
||||
const char *name;
|
||||
|
||||
/**
|
||||
* init - Initialize an EAP method
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* Returns: Pointer to allocated private data, or %NULL on failure
|
||||
*
|
||||
* This function is used to initialize the EAP method explicitly
|
||||
* instead of using METHOD_INIT state as specific in RFC 4137. The
|
||||
* method is expected to initialize it method-specific state and return
|
||||
* a pointer that will be used as the priv argument to other calls.
|
||||
*/
|
||||
void * (*init)();
|
||||
|
||||
/**
|
||||
* deinit - Deinitialize an EAP method
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
*
|
||||
* Deinitialize the EAP method and free any allocated private data.
|
||||
*/
|
||||
void (*deinit)(void *priv);
|
||||
|
||||
/**
|
||||
* process - Process an EAP request
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
* @ret: Return values from EAP request validation and processing
|
||||
* @reqData: EAP request to be processed (eapReqData)
|
||||
* Returns: Pointer to allocated EAP response packet (eapRespData)
|
||||
*
|
||||
* This function is a combination of m.check(), m.process(), and
|
||||
* m.buildResp() procedures defined in section 4.4 of RFC 4137 In other
|
||||
* words, this function validates the incoming request, processes it,
|
||||
* and build a response packet. m.check() and m.process() return values
|
||||
* are returned through struct eap_method_ret *ret variable. Caller is
|
||||
* responsible for freeing the returned EAP response packet.
|
||||
*/
|
||||
struct wpabuf * (*process)(void *priv,
|
||||
//struct eap_method_ret *ret,
|
||||
const struct wpabuf *reqData);
|
||||
|
||||
/**
|
||||
* isKeyAvailable - Find out whether EAP method has keying material
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
* Returns: %TRUE if key material (eapKeyData) is available
|
||||
*/
|
||||
//Boolean (*isKeyAvailable)(struct eap_sm *sm, void *priv);
|
||||
|
||||
/**
|
||||
* getKey - Get EAP method specific keying material (eapKeyData)
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
* @len: Pointer to variable to store key length (eapKeyDataLen)
|
||||
* Returns: Keying material (eapKeyData) or %NULL if not available
|
||||
*
|
||||
* This function can be used to get the keying material from the EAP
|
||||
* method. The key may already be stored in the method-specific private
|
||||
* data or this function may derive the key.
|
||||
*/
|
||||
//u8 * (*getKey)(struct eap_sm *sm, void *priv, size_t *len);
|
||||
|
||||
/**
|
||||
* get_status - Get EAP method status
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
* @buf: Buffer for status information
|
||||
* @buflen: Maximum buffer length
|
||||
* @verbose: Whether to include verbose status information
|
||||
* Returns: Number of bytes written to buf
|
||||
*
|
||||
* Query EAP method for status information. This function fills in a
|
||||
* text area with current status information from the EAP method. If
|
||||
* the buffer (buf) is not large enough, status information will be
|
||||
* truncated to fit the buffer.
|
||||
*/
|
||||
//int (*get_status)(struct eap_sm *sm, void *priv, char *buf,
|
||||
// size_t buflen, int verbose);
|
||||
|
||||
/**
|
||||
* has_reauth_data - Whether method is ready for fast reauthentication
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
* Returns: %TRUE or %FALSE based on whether fast reauthentication is
|
||||
* possible
|
||||
*
|
||||
* This function is an optional handler that only EAP methods
|
||||
* supporting fast re-authentication need to implement.
|
||||
*/
|
||||
//Boolean (*has_reauth_data)(struct eap_sm *sm, void *priv);
|
||||
|
||||
/**
|
||||
* deinit_for_reauth - Release data that is not needed for fast re-auth
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
*
|
||||
* This function is an optional handler that only EAP methods
|
||||
* supporting fast re-authentication need to implement. This is called
|
||||
* when authentication has been completed and EAP state machine is
|
||||
* requesting that enough state information is maintained for fast
|
||||
* re-authentication
|
||||
*/
|
||||
//void (*deinit_for_reauth)(struct eap_sm *sm, void *priv);
|
||||
|
||||
/**
|
||||
* init_for_reauth - Prepare for start of fast re-authentication
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
*
|
||||
* This function is an optional handler that only EAP methods
|
||||
* supporting fast re-authentication need to implement. This is called
|
||||
* when EAP authentication is started and EAP state machine is
|
||||
* requesting fast re-authentication to be used.
|
||||
*/
|
||||
//void * (*init_for_reauth)(struct eap_sm *sm, void *priv);
|
||||
|
||||
/**
|
||||
* get_identity - Get method specific identity for re-authentication
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
* @len: Length of the returned identity
|
||||
* Returns: Pointer to the method specific identity or %NULL if default
|
||||
* identity is to be used
|
||||
*
|
||||
* This function is an optional handler that only EAP methods
|
||||
* that use method specific identity need to implement.
|
||||
*/
|
||||
//const u8 * (*get_identity)(struct eap_sm *sm, void *priv, size_t *len);
|
||||
|
||||
/**
|
||||
* free - Free EAP method data
|
||||
* @method: Pointer to the method data registered with
|
||||
* eap_peer_method_register().
|
||||
*
|
||||
* This function will be called when the EAP method is being
|
||||
* unregistered. If the EAP method allocated resources during
|
||||
* registration (e.g., allocated struct eap_method), they should be
|
||||
* freed in this function. No other method functions will be called
|
||||
* after this call. If this function is not defined (i.e., function
|
||||
* pointer is %NULL), a default handler is used to release the method
|
||||
* data with free(method). This is suitable for most cases.
|
||||
*/
|
||||
//void (*free)(struct eap_method *method);
|
||||
|
||||
#define EAP_PEER_METHOD_INTERFACE_VERSION 1
|
||||
/**
|
||||
* version - Version of the EAP peer method interface
|
||||
*
|
||||
* The EAP peer method implementation should set this variable to
|
||||
* EAP_PEER_METHOD_INTERFACE_VERSION. This is used to verify that the
|
||||
* EAP method is using supported API version when using dynamically
|
||||
* loadable EAP methods.
|
||||
*/
|
||||
int version;
|
||||
|
||||
/**
|
||||
* next - Pointer to the next EAP method
|
||||
*
|
||||
* This variable is used internally in the EAP method registration code
|
||||
* to create a linked list of registered EAP methods.
|
||||
*/
|
||||
//struct eap_method *next;
|
||||
|
||||
#ifdef CONFIG_DYNAMIC_EAP_METHODS
|
||||
/**
|
||||
* dl_handle - Handle for the dynamic library
|
||||
*
|
||||
* This variable is used internally in the EAP method registration code
|
||||
* to store a handle for the dynamic library. If the method is linked
|
||||
* in statically, this is %NULL.
|
||||
*/
|
||||
void *dl_handle;
|
||||
#endif /* CONFIG_DYNAMIC_EAP_METHODS */
|
||||
|
||||
/**
|
||||
* get_emsk - Get EAP method specific keying extended material (EMSK)
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
* @len: Pointer to a variable to store EMSK length
|
||||
* Returns: EMSK or %NULL if not available
|
||||
*
|
||||
* This function can be used to get the extended keying material from
|
||||
* the EAP method. The key may already be stored in the method-specific
|
||||
* private data or this function may derive the key.
|
||||
*/
|
||||
//u8 * (*get_emsk)(struct eap_sm *sm, void *priv, size_t *len);
|
||||
|
||||
/**
|
||||
* getSessionId - Get EAP method specific Session-Id
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
* @len: Pointer to a variable to store Session-Id length
|
||||
* Returns: Session-Id or %NULL if not available
|
||||
*
|
||||
* This function can be used to get the Session-Id from the EAP method.
|
||||
* The Session-Id may already be stored in the method-specific private
|
||||
* data or this function may derive the Session-Id.
|
||||
*/
|
||||
//u8 * (*getSessionId)(struct eap_sm *sm, void *priv, size_t *len);
|
||||
};
|
||||
#endif
|
||||
|
||||
struct eap_server_method {
|
||||
int vendor;
|
||||
EapType method;
|
||||
const char *name;
|
||||
|
||||
void * (*init)(char *identity,char identity_len);
|
||||
//void * (*initPickUp)(struct eap_sm *sm);
|
||||
void (*reset)(void *priv);
|
||||
|
||||
struct wpabuf * (*buildReq)(void *priv, u8 id);
|
||||
int (*getTimeout)(void *priv);
|
||||
unsigned char (*check)(void *priv,
|
||||
struct wpabuf *respData);
|
||||
void (*process)(void *priv,
|
||||
struct wpabuf *respData);
|
||||
unsigned char (*isDone)(void *priv);
|
||||
u8 * (*getKey)(void *priv, size_t *len);
|
||||
/* isSuccess is not specified in draft-ietf-eap-statemachine-05.txt,
|
||||
* but it is useful in implementing Policy.getDecision() */
|
||||
unsigned char (*isSuccess)(void *priv);
|
||||
|
||||
/**
|
||||
* free - Free EAP method data
|
||||
* @method: Pointer to the method data registered with
|
||||
* eap_server_method_register().
|
||||
*
|
||||
* This function will be called when the EAP method is being
|
||||
* unregistered. If the EAP method allocated resources during
|
||||
* registration (e.g., allocated struct eap_method), they should be
|
||||
* freed in this function. No other method functions will be called
|
||||
* after this call. If this function is not defined (i.e., function
|
||||
* pointer is %NULL), a default handler is used to release the method
|
||||
* data with free(method). This is suitable for most cases.
|
||||
*/
|
||||
//void (*free)(struct eap_method *method);
|
||||
|
||||
#define EAP_SERVER_METHOD_INTERFACE_VERSION 1
|
||||
/**
|
||||
* version - Version of the EAP server method interface
|
||||
*
|
||||
* The EAP server method implementation should set this variable to
|
||||
* EAP_SERVER_METHOD_INTERFACE_VERSION. This is used to verify that the
|
||||
* EAP method is using supported API version when using dynamically
|
||||
* loadable EAP methods.
|
||||
*/
|
||||
int version;
|
||||
|
||||
/**
|
||||
* next - Pointer to the next EAP method
|
||||
*
|
||||
* This variable is used internally in the EAP method registration code
|
||||
* to create a linked list of registered EAP methods.
|
||||
*/
|
||||
//struct eap_method *next;
|
||||
|
||||
/**
|
||||
* get_emsk - Get EAP method specific keying extended material (EMSK)
|
||||
* @sm: Pointer to EAP state machine allocated with eap_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
* @len: Pointer to a variable to store EMSK length
|
||||
* Returns: EMSK or %NULL if not available
|
||||
*
|
||||
* This function can be used to get the extended keying material from
|
||||
* the EAP method. The key may already be stored in the method-specific
|
||||
* private data or this function may derive the key.
|
||||
*/
|
||||
//u8 * (*get_emsk)(struct eap_sm *sm, void *priv, size_t *len);
|
||||
};
|
||||
|
||||
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 */
|
||||
|
|
@ -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_CODE_INITIATE = 5,
|
||||
EAP_CODE_FINISH = 6
|
||||
};
|
||||
|
||||
/* 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_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 */,
|
||||
EAP_VENDOR_WFA_NEW = 40808 /* Wi-Fi Alliance */
|
||||
};
|
||||
|
||||
#define EAP_VENDOR_UNAUTH_TLS EAP_VENDOR_HOSTAP
|
||||
#define EAP_VENDOR_TYPE_UNAUTH_TLS 1
|
||||
|
||||
#define EAP_VENDOR_WFA_UNAUTH_TLS 13
|
||||
|
||||
#define EAP_MSK_LEN 64
|
||||
#define EAP_EMSK_LEN 64
|
||||
|
||||
#endif /* EAP_DEFS_H */
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* EAP-PEAP common routines
|
||||
* Copyright (c) 2008-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_PEAP_COMMON_H
|
||||
#define EAP_PEAP_COMMON_H
|
||||
|
||||
int peap_prfplus(int version, const u8 *key, size_t key_len,
|
||||
const char *label, const u8 *seed, size_t seed_len,
|
||||
u8 *buf, size_t buf_len);
|
||||
|
||||
#endif /* EAP_PEAP_COMMON_H */
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* EAP-TLV definitions (draft-josefsson-pppext-eap-tls-eap-10.txt)
|
||||
* Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef EAP_TLV_COMMON_H
|
||||
#define EAP_TLV_COMMON_H
|
||||
|
||||
/* EAP-TLV TLVs (draft-josefsson-ppext-eap-tls-eap-10.txt) */
|
||||
#define EAP_TLV_RESULT_TLV 3 /* Acknowledged Result */
|
||||
#define EAP_TLV_NAK_TLV 4
|
||||
#define EAP_TLV_ERROR_CODE_TLV 5
|
||||
#define EAP_TLV_CONNECTION_BINDING_TLV 6
|
||||
#define EAP_TLV_VENDOR_SPECIFIC_TLV 7
|
||||
#define EAP_TLV_URI_TLV 8
|
||||
#define EAP_TLV_EAP_PAYLOAD_TLV 9
|
||||
#define EAP_TLV_INTERMEDIATE_RESULT_TLV 10
|
||||
#define EAP_TLV_PAC_TLV 11 /* RFC 5422, Section 4.2 */
|
||||
#define EAP_TLV_CRYPTO_BINDING_TLV 12
|
||||
#define EAP_TLV_CALLING_STATION_ID_TLV 13
|
||||
#define EAP_TLV_CALLED_STATION_ID_TLV 14
|
||||
#define EAP_TLV_NAS_PORT_TYPE_TLV 15
|
||||
#define EAP_TLV_SERVER_IDENTIFIER_TLV 16
|
||||
#define EAP_TLV_IDENTITY_TYPE_TLV 17
|
||||
#define EAP_TLV_SERVER_TRUSTED_ROOT_TLV 18
|
||||
#define EAP_TLV_REQUEST_ACTION_TLV 19
|
||||
#define EAP_TLV_PKCS7_TLV 20
|
||||
|
||||
#define EAP_TLV_RESULT_SUCCESS 1
|
||||
#define EAP_TLV_RESULT_FAILURE 2
|
||||
|
||||
#define EAP_TLV_TYPE_MANDATORY 0x8000
|
||||
#define EAP_TLV_TYPE_MASK 0x3fff
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(push, 1)
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
struct eap_tlv_hdr {
|
||||
be16 tlv_type;
|
||||
be16 length;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
struct eap_tlv_nak_tlv {
|
||||
be16 tlv_type;
|
||||
be16 length;
|
||||
be32 vendor_id;
|
||||
be16 nak_type;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
struct eap_tlv_result_tlv {
|
||||
be16 tlv_type;
|
||||
be16 length;
|
||||
be16 status;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
/* RFC 4851, Section 4.2.7 - Intermediate-Result TLV */
|
||||
struct eap_tlv_intermediate_result_tlv {
|
||||
be16 tlv_type;
|
||||
be16 length;
|
||||
be16 status;
|
||||
/* Followed by optional TLVs */
|
||||
} STRUCT_PACKED;
|
||||
|
||||
/* RFC 4851, Section 4.2.8 - Crypto-Binding TLV */
|
||||
struct eap_tlv_crypto_binding_tlv {
|
||||
be16 tlv_type;
|
||||
be16 length;
|
||||
u8 reserved;
|
||||
u8 version;
|
||||
u8 received_version;
|
||||
u8 subtype;
|
||||
u8 nonce[32];
|
||||
u8 compound_mac[20];
|
||||
} STRUCT_PACKED;
|
||||
|
||||
struct eap_tlv_pac_ack_tlv {
|
||||
be16 tlv_type;
|
||||
be16 length;
|
||||
be16 pac_type;
|
||||
be16 pac_len;
|
||||
be16 result;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
/* RFC 4851, Section 4.2.9 - Request-Action TLV */
|
||||
struct eap_tlv_request_action_tlv {
|
||||
be16 tlv_type;
|
||||
be16 length;
|
||||
be16 action;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
/* RFC 5422, Section 4.2.6 - PAC-Type TLV */
|
||||
struct eap_tlv_pac_type_tlv {
|
||||
be16 tlv_type; /* PAC_TYPE_PAC_TYPE */
|
||||
be16 length;
|
||||
be16 pac_type;
|
||||
} STRUCT_PACKED;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(pop)
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#define EAP_TLV_CRYPTO_BINDING_SUBTYPE_REQUEST 0
|
||||
#define EAP_TLV_CRYPTO_BINDING_SUBTYPE_RESPONSE 1
|
||||
|
||||
#define EAP_TLV_ACTION_PROCESS_TLV 1
|
||||
#define EAP_TLV_ACTION_NEGOTIATE_EAP 2
|
||||
|
||||
#endif /* EAP_TLV_COMMON_H */
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* EAP server/peer: EAP-TTLS (RFC 5281)
|
||||
* 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_TTLS_H
|
||||
#define EAP_TTLS_H
|
||||
|
||||
struct ttls_avp {
|
||||
be32 avp_code;
|
||||
be32 avp_length; /* 8-bit flags, 24-bit length;
|
||||
* length includes AVP header */
|
||||
/* optional 32-bit Vendor-ID */
|
||||
/* Data */
|
||||
};
|
||||
|
||||
struct ttls_avp_vendor {
|
||||
be32 avp_code;
|
||||
be32 avp_length; /* 8-bit flags, 24-bit length;
|
||||
* length includes AVP header */
|
||||
be32 vendor_id;
|
||||
/* Data */
|
||||
};
|
||||
|
||||
#define AVP_FLAGS_VENDOR 0x80
|
||||
#define AVP_FLAGS_MANDATORY 0x40
|
||||
|
||||
#define AVP_PAD(start, pos) \
|
||||
do { \
|
||||
int __pad; \
|
||||
__pad = (4 - (((pos) - (start)) & 3)) & 3; \
|
||||
os_memset((pos), 0, __pad); \
|
||||
pos += __pad; \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* RFC 2865 */
|
||||
#define RADIUS_ATTR_USER_NAME 1
|
||||
#define RADIUS_ATTR_USER_PASSWORD 2
|
||||
#define RADIUS_ATTR_CHAP_PASSWORD 3
|
||||
#define RADIUS_ATTR_REPLY_MESSAGE 18
|
||||
#define RADIUS_ATTR_CHAP_CHALLENGE 60
|
||||
#define RADIUS_ATTR_EAP_MESSAGE 79
|
||||
|
||||
/* RFC 2548 */
|
||||
#define RADIUS_VENDOR_ID_MICROSOFT 311
|
||||
#define RADIUS_ATTR_MS_CHAP_RESPONSE 1
|
||||
#define RADIUS_ATTR_MS_CHAP_ERROR 2
|
||||
#define RADIUS_ATTR_MS_CHAP_NT_ENC_PW 6
|
||||
#define RADIUS_ATTR_MS_CHAP_CHALLENGE 11
|
||||
#define RADIUS_ATTR_MS_CHAP2_RESPONSE 25
|
||||
#define RADIUS_ATTR_MS_CHAP2_SUCCESS 26
|
||||
#define RADIUS_ATTR_MS_CHAP2_CPW 27
|
||||
|
||||
#define EAP_TTLS_MSCHAPV2_CHALLENGE_LEN 16
|
||||
#define EAP_TTLS_MSCHAPV2_RESPONSE_LEN 50
|
||||
#define EAP_TTLS_MSCHAP_CHALLENGE_LEN 8
|
||||
#define EAP_TTLS_MSCHAP_RESPONSE_LEN 50
|
||||
#define EAP_TTLS_CHAP_CHALLENGE_LEN 16
|
||||
#define EAP_TTLS_CHAP_PASSWORD_LEN 16
|
||||
|
||||
#endif /* EAP_TTLS_H */
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* EAP-WSC definitions for Wi-Fi Protected Setup
|
||||
* Copyright (c) 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_WSC_COMMON_H
|
||||
#define EAP_WSC_COMMON_H
|
||||
|
||||
#include "wps/wps.h"
|
||||
|
||||
#define EAP_VENDOR_TYPE_WSC 1
|
||||
|
||||
#define WSC_FLAGS_MF 0x01
|
||||
#define WSC_FLAGS_LF 0x02
|
||||
|
||||
#define WSC_ID_REGISTRAR "WFA-SimpleConfig-Registrar-1-0"
|
||||
#define WSC_ID_REGISTRAR_LEN 30
|
||||
#define WSC_ID_ENROLLEE "WFA-SimpleConfig-Enrollee-1-0"
|
||||
#define WSC_ID_ENROLLEE_LEN 29
|
||||
|
||||
#define WSC_FRAGMENT_SIZE 1400
|
||||
|
||||
#ifdef FAIL
|
||||
#undef FAIL
|
||||
#endif
|
||||
|
||||
enum wsc_state{
|
||||
WAIT_START=0,
|
||||
START,
|
||||
MESG,
|
||||
FRAG_ACK,
|
||||
WAIT_FRAG_ACK,
|
||||
DONE,
|
||||
FAIL,
|
||||
};
|
||||
|
||||
//move from eap_wsc.h and eap_server_wsc.h to here.
|
||||
//enum wsc_state { WAIT_START, START, MESG, FRAG_ACK, WAIT_FRAG_ACK, DONE, FAIL };
|
||||
|
||||
struct eap_wsc_data {
|
||||
enum wsc_state state ;
|
||||
int registrar;
|
||||
struct wpabuf *in_buf;
|
||||
struct wpabuf *out_buf;
|
||||
enum wsc_op_code in_op_code, out_op_code;
|
||||
size_t out_used; //global used ?
|
||||
size_t fragment_size;
|
||||
struct wps_data *wps; // allocate by wsc_init()
|
||||
//struct wps_context *wps_ctx; // non-use
|
||||
int ext_reg_timeout; //server must need it?
|
||||
struct wpabuf *last_reqdata;
|
||||
os_timer retrans_timer;
|
||||
int MaxRetrans;
|
||||
};
|
||||
struct wpabuf * eap_wsc_build_frag_ack(u8 id, u8 code);
|
||||
|
||||
#endif /* EAP_WSC_COMMON_H */
|
||||
|
|
@ -0,0 +1,343 @@
|
|||
/*
|
||||
* 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 "common/defs.h"
|
||||
#include "wps/wps_defs.h"
|
||||
#include "eap_common/eap_defs.h"
|
||||
|
||||
#include "eap_methods.h"
|
||||
|
||||
|
||||
struct eap_sm;
|
||||
struct wpa_config_blob;
|
||||
struct wpabuf;
|
||||
|
||||
struct eap_method_type {
|
||||
int vendor;
|
||||
u32 method;
|
||||
};
|
||||
|
||||
//#ifdef IEEE8021X_EAPOL
|
||||
|
||||
/**
|
||||
* enum eapol_bool_var - EAPOL boolean state variables for EAP state machine
|
||||
*
|
||||
* These variables are used in the interface between EAP peer state machine and
|
||||
* lower layer. These are defined in RFC 4137, Sect. 4.1. Lower layer code is
|
||||
* expected to maintain these variables and register a callback functions for
|
||||
* EAP state machine to get and set the variables.
|
||||
*/
|
||||
enum eapol_bool_var {
|
||||
/**
|
||||
* EAPOL_eapSuccess - EAP SUCCESS state reached
|
||||
*
|
||||
* EAP state machine reads and writes this value.
|
||||
*/
|
||||
EAPOL_eapSuccess,
|
||||
|
||||
/**
|
||||
* EAPOL_eapRestart - Lower layer request to restart authentication
|
||||
*
|
||||
* Set to TRUE in lower layer, FALSE in EAP state machine.
|
||||
*/
|
||||
EAPOL_eapRestart,
|
||||
|
||||
/**
|
||||
* EAPOL_eapFail - EAP FAILURE state reached
|
||||
*
|
||||
* EAP state machine writes this value.
|
||||
*/
|
||||
EAPOL_eapFail,
|
||||
|
||||
/**
|
||||
* EAPOL_eapResp - Response to send
|
||||
*
|
||||
* Set to TRUE in EAP state machine, FALSE in lower layer.
|
||||
*/
|
||||
EAPOL_eapResp,
|
||||
|
||||
/**
|
||||
* EAPOL_eapNoResp - Request has been process; no response to send
|
||||
*
|
||||
* Set to TRUE in EAP state machine, FALSE in lower layer.
|
||||
*/
|
||||
EAPOL_eapNoResp,
|
||||
|
||||
/**
|
||||
* EAPOL_eapReq - EAP request available from lower layer
|
||||
*
|
||||
* Set to TRUE in lower layer, FALSE in EAP state machine.
|
||||
*/
|
||||
EAPOL_eapReq,
|
||||
|
||||
/**
|
||||
* EAPOL_portEnabled - Lower layer is ready for communication
|
||||
*
|
||||
* EAP state machines reads this value.
|
||||
*/
|
||||
EAPOL_portEnabled,
|
||||
|
||||
/**
|
||||
* EAPOL_altAccept - Alternate indication of success (RFC3748)
|
||||
*
|
||||
* EAP state machines reads this value.
|
||||
*/
|
||||
EAPOL_altAccept,
|
||||
|
||||
/**
|
||||
* EAPOL_altReject - Alternate indication of failure (RFC3748)
|
||||
*
|
||||
* EAP state machines reads this value.
|
||||
*/
|
||||
EAPOL_altReject,
|
||||
|
||||
/**
|
||||
* EAPOL_eapTriggerStart - EAP-based trigger to send EAPOL-Start
|
||||
*
|
||||
* EAP state machine writes this value.
|
||||
*/
|
||||
EAPOL_eapTriggerStart
|
||||
};
|
||||
|
||||
/**
|
||||
* enum eapol_int_var - EAPOL integer state variables for EAP state machine
|
||||
*
|
||||
* These variables are used in the interface between EAP peer state machine and
|
||||
* lower layer. These are defined in RFC 4137, Sect. 4.1. Lower layer code is
|
||||
* expected to maintain these variables and register a callback functions for
|
||||
* EAP state machine to get and set the variables.
|
||||
*/
|
||||
enum eapol_int_var {
|
||||
/**
|
||||
* EAPOL_idleWhile - Outside time for EAP peer timeout
|
||||
*
|
||||
* This integer variable is used to provide an outside timer that the
|
||||
* external (to EAP state machine) code must decrement by one every
|
||||
* second until the value reaches zero. This is used in the same way as
|
||||
* EAPOL state machine timers. EAP state machine reads and writes this
|
||||
* value.
|
||||
*/
|
||||
EAPOL_idleWhile
|
||||
};
|
||||
|
||||
/**
|
||||
* struct eapol_callbacks - Callback functions from EAP to lower layer
|
||||
*
|
||||
* This structure defines the callback functions that EAP state machine
|
||||
* requires from the lower layer (usually EAPOL state machine) for updating
|
||||
* state variables and requesting information. eapol_ctx from
|
||||
* eap_peer_sm_init() call will be used as the ctx parameter for these
|
||||
* callback functions.
|
||||
*/
|
||||
struct eapol_callbacks {
|
||||
/**
|
||||
* get_config - Get pointer to the current network configuration
|
||||
* @ctx: eapol_ctx from eap_peer_sm_init() call
|
||||
*/
|
||||
struct eap_peer_config *(*get_config)(void *ctx);
|
||||
|
||||
/**
|
||||
* get_bool - Get a boolean EAPOL state variable
|
||||
* @variable: EAPOL boolean variable to get
|
||||
* Returns: Value of the EAPOL variable
|
||||
*/
|
||||
Boolean (*get_bool)(void *ctx, enum eapol_bool_var variable);
|
||||
|
||||
/**
|
||||
* set_bool - Set a boolean EAPOL state variable
|
||||
* @ctx: eapol_ctx from eap_peer_sm_init() call
|
||||
* @variable: EAPOL boolean variable to set
|
||||
* @value: Value for the EAPOL variable
|
||||
*/
|
||||
void (*set_bool)(void *ctx, enum eapol_bool_var variable,
|
||||
Boolean value);
|
||||
|
||||
/**
|
||||
* get_int - Get an integer EAPOL state variable
|
||||
* @ctx: eapol_ctx from eap_peer_sm_init() call
|
||||
* @variable: EAPOL integer variable to get
|
||||
* Returns: Value of the EAPOL variable
|
||||
*/
|
||||
unsigned int (*get_int)(void *ctx, enum eapol_int_var variable);
|
||||
|
||||
/**
|
||||
* set_int - Set an integer EAPOL state variable
|
||||
* @ctx: eapol_ctx from eap_peer_sm_init() call
|
||||
* @variable: EAPOL integer variable to set
|
||||
* @value: Value for the EAPOL variable
|
||||
*/
|
||||
void (*set_int)(void *ctx, enum eapol_int_var variable,
|
||||
unsigned int value);
|
||||
|
||||
/**
|
||||
* get_eapReqData - Get EAP-Request data
|
||||
* @ctx: eapol_ctx from eap_peer_sm_init() call
|
||||
* @len: Pointer to variable that will be set to eapReqDataLen
|
||||
* Returns: Reference to eapReqData (EAP state machine will not free
|
||||
* this) or %NULL if eapReqData not available.
|
||||
*/
|
||||
struct wpabuf * (*get_eapReqData)(void *ctx);
|
||||
|
||||
/**
|
||||
* set_config_blob - Set named configuration blob
|
||||
* @ctx: eapol_ctx from eap_peer_sm_init() call
|
||||
* @blob: New value for the blob
|
||||
*
|
||||
* Adds a new configuration blob or replaces the current value of an
|
||||
* existing blob.
|
||||
*/
|
||||
void (*set_config_blob)(void *ctx, struct wpa_config_blob *blob);
|
||||
|
||||
/**
|
||||
* get_config_blob - Get a named configuration blob
|
||||
* @ctx: eapol_ctx from eap_peer_sm_init() call
|
||||
* @name: Name of the blob
|
||||
* Returns: Pointer to blob data or %NULL if not found
|
||||
*/
|
||||
const struct wpa_config_blob * (*get_config_blob)(void *ctx,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* notify_pending - Notify that a pending request can be retried
|
||||
* @ctx: eapol_ctx from eap_peer_sm_init() call
|
||||
*
|
||||
* An EAP method can perform a pending operation (e.g., to get a
|
||||
* response from an external process). Once the response is available,
|
||||
* this callback function can be used to request EAPOL state machine to
|
||||
* retry delivering the previously received (and still unanswered) EAP
|
||||
* request to EAP state machine.
|
||||
*/
|
||||
void (*notify_pending)(void *ctx);
|
||||
|
||||
/**
|
||||
* eap_param_needed - Notify that EAP parameter is needed
|
||||
* @ctx: eapol_ctx from eap_peer_sm_init() call
|
||||
* @field: Field indicator (e.g., WPA_CTRL_REQ_EAP_IDENTITY)
|
||||
* @txt: User readable text describing the required parameter
|
||||
*/
|
||||
void (*eap_param_needed)(void *ctx, enum wpa_ctrl_req_type field,
|
||||
const char *txt);
|
||||
|
||||
/**
|
||||
* notify_cert - Notification of a peer certificate
|
||||
* @ctx: eapol_ctx from eap_peer_sm_init() call
|
||||
* @depth: Depth in certificate chain (0 = server)
|
||||
* @subject: Subject of the peer certificate
|
||||
* @cert_hash: SHA-256 hash of the certificate
|
||||
* @cert: Peer certificate
|
||||
*/
|
||||
void (*notify_cert)(void *ctx, int depth, const char *subject,
|
||||
const char *altsubject[], int num_altsubject,
|
||||
const char *cert_hash, const struct wpabuf *cert);
|
||||
|
||||
/**
|
||||
* notify_status - Notification of the current EAP state
|
||||
* @ctx: eapol_ctx from eap_peer_sm_init() call
|
||||
* @status: Step in the process of EAP authentication
|
||||
* @parameter: Step-specific parameter, e.g., EAP method name
|
||||
*/
|
||||
void (*notify_status)(void *ctx, const char *status,
|
||||
const char *parameter);
|
||||
|
||||
/**
|
||||
* set_anon_id - Set or add anonymous identity
|
||||
* @ctx: eapol_ctx from eap_peer_sm_init() call
|
||||
* @id: Anonymous identity (e.g., EAP-SIM pseudonym) or %NULL to clear
|
||||
* @len: Length of anonymous identity in octets
|
||||
*/
|
||||
void (*set_anon_id)(void *ctx, const u8 *id, size_t len);
|
||||
};
|
||||
|
||||
/**
|
||||
* struct eap_config - Configuration for EAP state machine
|
||||
*/
|
||||
struct eap_config {
|
||||
/**
|
||||
* opensc_engine_path - OpenSC engine for OpenSSL engine support
|
||||
*
|
||||
* Usually, path to engine_opensc.so.
|
||||
*/
|
||||
const char *opensc_engine_path;
|
||||
/**
|
||||
* pkcs11_engine_path - PKCS#11 engine for OpenSSL engine support
|
||||
*
|
||||
* Usually, path to engine_pkcs11.so.
|
||||
*/
|
||||
const char *pkcs11_engine_path;
|
||||
/**
|
||||
* pkcs11_module_path - OpenSC PKCS#11 module for OpenSSL engine
|
||||
*
|
||||
* Usually, path to opensc-pkcs11.so.
|
||||
*/
|
||||
const char *pkcs11_module_path;
|
||||
/**
|
||||
* openssl_ciphers - OpenSSL cipher string
|
||||
*
|
||||
* This is an OpenSSL specific configuration option for configuring the
|
||||
* default ciphers. If not set, "DEFAULT:!EXP:!LOW" is used as the
|
||||
* default.
|
||||
*/
|
||||
const char *openssl_ciphers;
|
||||
/**
|
||||
* wps - WPS context data
|
||||
*
|
||||
* This is only used by EAP-WSC and can be left %NULL if not available.
|
||||
*/
|
||||
struct wps_context *wps;
|
||||
|
||||
/**
|
||||
* cert_in_cb - Include server certificates in callback
|
||||
*/
|
||||
int cert_in_cb;
|
||||
};
|
||||
|
||||
struct eap_sm * eap_peer_sm_init(void *eapol_ctx,
|
||||
struct eapol_callbacks *eapol_cb,
|
||||
void *msg_ctx, struct eap_config *conf);
|
||||
void eap_peer_sm_deinit(struct eap_sm *sm);
|
||||
int eap_peer_sm_step(struct eap_sm *sm);
|
||||
void eap_sm_abort(struct eap_sm *sm);
|
||||
int eap_sm_get_status(struct eap_sm *sm, char *buf, size_t buflen,
|
||||
int verbose);
|
||||
const char * eap_sm_get_method_name(struct eap_sm *sm);
|
||||
struct wpabuf * eap_sm_buildIdentity(struct eap_sm *sm, int id, int encrypted);
|
||||
void eap_sm_request_identity(struct eap_sm *sm);
|
||||
void eap_sm_request_password(struct eap_sm *sm);
|
||||
void eap_sm_request_new_password(struct eap_sm *sm);
|
||||
void eap_sm_request_pin(struct eap_sm *sm);
|
||||
void eap_sm_request_otp(struct eap_sm *sm, const char *msg, size_t msg_len);
|
||||
void eap_sm_request_passphrase(struct eap_sm *sm);
|
||||
void eap_sm_notify_ctrl_attached(struct eap_sm *sm);
|
||||
u32 eap_get_phase2_type(const char *name, int *vendor);
|
||||
struct eap_method_type * eap_get_phase2_types(struct eap_peer_config *config,
|
||||
size_t *count);
|
||||
void eap_set_fast_reauth(struct eap_sm *sm, int enabled);
|
||||
void eap_set_workaround(struct eap_sm *sm, unsigned int workaround);
|
||||
void eap_set_force_disabled(struct eap_sm *sm, int disabled);
|
||||
int eap_key_available(struct eap_sm *sm);
|
||||
void eap_notify_success(struct eap_sm *sm);
|
||||
void eap_notify_lower_layer_success(struct eap_sm *sm);
|
||||
const u8 * eap_get_eapSessionId(struct eap_sm *sm, size_t *len);
|
||||
const u8 * eap_get_eapKeyData(struct eap_sm *sm, size_t *len);
|
||||
struct wpabuf * eap_get_eapRespData(struct eap_sm *sm);
|
||||
void eap_register_scard_ctx(struct eap_sm *sm, void *ctx);
|
||||
void eap_invalidate_cached_session(struct eap_sm *sm);
|
||||
|
||||
int eap_is_wps_pbc_enrollee(struct eap_peer_config *conf);
|
||||
int eap_is_wps_pin_enrollee(struct eap_peer_config *conf);
|
||||
|
||||
struct ext_password_data;
|
||||
void eap_sm_set_ext_pw_ctx(struct eap_sm *sm, struct ext_password_data *ext);
|
||||
void eap_set_anon_id(struct eap_sm *sm, const u8 *id, size_t len);
|
||||
|
||||
//#endif /* IEEE8021X_EAPOL */
|
||||
|
||||
#endif /* EAP_H */
|
||||
|
|
@ -0,0 +1,774 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* anonymous_identity - Anonymous EAP Identity
|
||||
*
|
||||
* This field is used for unencrypted use with EAP types that support
|
||||
* different tunnelled identity, e.g., EAP-TTLS, in order to reveal the
|
||||
* real identity (identity field) only to the authentication server.
|
||||
*
|
||||
* If not set, the identity field will be used for both unencrypted and
|
||||
* protected fields.
|
||||
*
|
||||
* This field can also be used with EAP-SIM/AKA/AKA' to store the
|
||||
* pseudonym identity.
|
||||
*/
|
||||
u8 *anonymous_identity;
|
||||
|
||||
/**
|
||||
* anonymous_identity_len - Length of anonymous_identity
|
||||
*/
|
||||
size_t anonymous_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.
|
||||
*/
|
||||
char *private_key_passwd;
|
||||
|
||||
/**
|
||||
* dh_file - File path to DH/DSA parameters file (in PEM format)
|
||||
*
|
||||
* This is an optional configuration file for setting parameters for an
|
||||
* ephemeral DH key exchange. In most cases, the default RSA
|
||||
* authentication does not use this configuration. However, it is
|
||||
* possible setup RSA to use ephemeral DH key exchange. In addition,
|
||||
* ciphers with DSA keys always use ephemeral DH keys. This can be used
|
||||
* to achieve forward secrecy. If the file is in DSA parameters format,
|
||||
* it will be automatically converted into DH params. 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 *dh_file;
|
||||
|
||||
/**
|
||||
* subject_match - Constraint for server certificate subject
|
||||
*
|
||||
* This substring is matched against the subject of the authentication
|
||||
* server certificate. If this string is set, the server sertificate is
|
||||
* only accepted if it contains this string in the subject. The subject
|
||||
* string is in following format:
|
||||
*
|
||||
* /C=US/ST=CA/L=San Francisco/CN=Test AS/emailAddress=as@n.example.com
|
||||
*
|
||||
* Note: Since this is a substring match, this cannot be used securily
|
||||
* to do a suffix match against a possible domain name in the CN entry.
|
||||
* For such a use case, domain_suffix_match should be used instead.
|
||||
*/
|
||||
u8 *subject_match;
|
||||
|
||||
/**
|
||||
* altsubject_match - Constraint for server certificate alt. subject
|
||||
*
|
||||
* Semicolon separated string of entries to be matched against the
|
||||
* alternative subject name of the authentication server certificate.
|
||||
* If this string is set, the server sertificate is only accepted if it
|
||||
* contains one of the entries in an alternative subject name
|
||||
* extension.
|
||||
*
|
||||
* altSubjectName string is in following format: TYPE:VALUE
|
||||
*
|
||||
* Example: EMAIL:server@example.com
|
||||
* Example: DNS:server.example.com;DNS:server2.example.com
|
||||
*
|
||||
* Following types are supported: EMAIL, DNS, URI
|
||||
*/
|
||||
u8 *altsubject_match;
|
||||
|
||||
/**
|
||||
* domain_suffix_match - Constraint for server domain name
|
||||
*
|
||||
* If set, this FQDN is used as a suffix match requirement for the
|
||||
* server certificate in SubjectAltName dNSName element(s). If a
|
||||
* matching dNSName is found, this constraint is met. If no dNSName
|
||||
* values are present, this constraint is matched against SubjectName CN
|
||||
* using same suffix match comparison. Suffix match here means that the
|
||||
* host/domain name is compared one label at a time starting from the
|
||||
* top-level domain and all the labels in domain_suffix_match shall be
|
||||
* included in the certificate. The certificate may include additional
|
||||
* sub-level labels in addition to the required labels.
|
||||
*
|
||||
* For example, domain_suffix_match=example.com would match
|
||||
* test.example.com but would not match test-example.com.
|
||||
*/
|
||||
char *domain_suffix_match;
|
||||
|
||||
/**
|
||||
* domain_match - Constraint for server domain name
|
||||
*
|
||||
* If set, this FQDN is used as a full match requirement for the
|
||||
* server certificate in SubjectAltName dNSName element(s). If a
|
||||
* matching dNSName is found, this constraint is met. If no dNSName
|
||||
* values are present, this constraint is matched against SubjectName CN
|
||||
* using same full match comparison. This behavior is similar to
|
||||
* domain_suffix_match, but has the requirement of a full match, i.e.,
|
||||
* no subdomains or wildcard matches are allowed. Case-insensitive
|
||||
* comparison is used, so "Example.com" matches "example.com", but would
|
||||
* not match "test.Example.com".
|
||||
*/
|
||||
char *domain_match;
|
||||
|
||||
/**
|
||||
* ca_cert2 - File path to CA certificate file (PEM/DER) (Phase 2)
|
||||
*
|
||||
* This file can have one or more trusted CA certificates. If ca_cert2
|
||||
* and ca_path2 are not included, server certificate will not be
|
||||
* verified. This is insecure and a trusted CA certificate should
|
||||
* always be configured. Full path to the file should be used since
|
||||
* working directory may change when wpa_supplicant is run in the
|
||||
* background.
|
||||
*
|
||||
* This field is like ca_cert, but used for phase 2 (inside
|
||||
* EAP-TTLS/PEAP/FAST tunnel) authentication.
|
||||
*
|
||||
* Alternatively, a named configuration blob can be used by setting
|
||||
* this to blob://blob_name.
|
||||
*/
|
||||
u8 *ca_cert2;
|
||||
|
||||
/**
|
||||
* ca_path2 - Directory path for CA certificate files (PEM) (Phase 2)
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This field is like ca_path, but used for phase 2 (inside
|
||||
* EAP-TTLS/PEAP/FAST tunnel) authentication.
|
||||
*/
|
||||
u8 *ca_path2;
|
||||
|
||||
/**
|
||||
* client_cert2 - File path to client certificate file
|
||||
*
|
||||
* This field is like client_cert, but used for phase 2 (inside
|
||||
* EAP-TTLS/PEAP/FAST tunnel) authentication. 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_cert2;
|
||||
|
||||
/**
|
||||
* private_key2 - File path to client private key file
|
||||
*
|
||||
* This field is like private_key, but used for phase 2 (inside
|
||||
* EAP-TTLS/PEAP/FAST tunnel) authentication. 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 *private_key2;
|
||||
|
||||
/**
|
||||
* private_key2_passwd - Password for private key file
|
||||
*
|
||||
* This field is like private_key_passwd, but used for phase 2 (inside
|
||||
* EAP-TTLS/PEAP/FAST tunnel) authentication.
|
||||
*/
|
||||
char *private_key2_passwd;
|
||||
|
||||
/**
|
||||
* dh_file2 - File path to DH/DSA parameters file (in PEM format)
|
||||
*
|
||||
* This field is like dh_file, but used for phase 2 (inside
|
||||
* EAP-TTLS/PEAP/FAST tunnel) authentication. 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 *dh_file2;
|
||||
|
||||
/**
|
||||
* subject_match2 - Constraint for server certificate subject
|
||||
*
|
||||
* This field is like subject_match, but used for phase 2 (inside
|
||||
* EAP-TTLS/PEAP/FAST tunnel) authentication.
|
||||
*/
|
||||
u8 *subject_match2;
|
||||
|
||||
/**
|
||||
* altsubject_match2 - Constraint for server certificate alt. subject
|
||||
*
|
||||
* This field is like altsubject_match, but used for phase 2 (inside
|
||||
* EAP-TTLS/PEAP/FAST tunnel) authentication.
|
||||
*/
|
||||
u8 *altsubject_match2;
|
||||
|
||||
/**
|
||||
* domain_suffix_match2 - Constraint for server domain name
|
||||
*
|
||||
* This field is like domain_suffix_match, but used for phase 2 (inside
|
||||
* EAP-TTLS/PEAP/FAST tunnel) authentication.
|
||||
*/
|
||||
char *domain_suffix_match2;
|
||||
|
||||
/**
|
||||
* domain_match2 - Constraint for server domain name
|
||||
*
|
||||
* This field is like domain_match, but used for phase 2 (inside
|
||||
* EAP-TTLS/PEAP/FAST tunnel) authentication.
|
||||
*/
|
||||
char *domain_match2;
|
||||
|
||||
/**
|
||||
* eap_methods - Allowed EAP methods
|
||||
*
|
||||
* (vendor=EAP_VENDOR_IETF,method=EAP_TYPE_NONE) terminated list of
|
||||
* allowed EAP methods or %NULL if all methods are accepted.
|
||||
*/
|
||||
struct eap_method_type *eap_methods;
|
||||
|
||||
/**
|
||||
* phase1 - Phase 1 (outer authentication) parameters
|
||||
*
|
||||
* String with field-value pairs, e.g., "peapver=0" or
|
||||
* "peapver=1 peaplabel=1".
|
||||
*
|
||||
* 'peapver' can be used to force which PEAP version (0 or 1) is used.
|
||||
*
|
||||
* 'peaplabel=1' can be used to force new label, "client PEAP
|
||||
* encryption", to be used during key derivation when PEAPv1 or newer.
|
||||
*
|
||||
* Most existing PEAPv1 implementation seem to be using the old label,
|
||||
* "client EAP encryption", and wpa_supplicant is now using that as the
|
||||
* default value.
|
||||
*
|
||||
* Some servers, e.g., Radiator, may require peaplabel=1 configuration
|
||||
* to interoperate with PEAPv1; see eap_testing.txt for more details.
|
||||
*
|
||||
* 'peap_outer_success=0' can be used to terminate PEAP authentication
|
||||
* on tunneled EAP-Success. This is required with some RADIUS servers
|
||||
* that implement draft-josefsson-pppext-eap-tls-eap-05.txt (e.g.,
|
||||
* Lucent NavisRadius v4.4.0 with PEAP in "IETF Draft 5" mode).
|
||||
*
|
||||
* include_tls_length=1 can be used to force wpa_supplicant to include
|
||||
* TLS Message Length field in all TLS messages even if they are not
|
||||
* fragmented.
|
||||
*
|
||||
* sim_min_num_chal=3 can be used to configure EAP-SIM to require three
|
||||
* challenges (by default, it accepts 2 or 3).
|
||||
*
|
||||
* result_ind=1 can be used to enable EAP-SIM and EAP-AKA to use
|
||||
* protected result indication.
|
||||
*
|
||||
* fast_provisioning option can be used to enable in-line provisioning
|
||||
* of EAP-FAST credentials (PAC):
|
||||
* 0 = disabled,
|
||||
* 1 = allow unauthenticated provisioning,
|
||||
* 2 = allow authenticated provisioning,
|
||||
* 3 = allow both unauthenticated and authenticated provisioning
|
||||
*
|
||||
* fast_max_pac_list_len=num option can be used to set the maximum
|
||||
* number of PAC entries to store in a PAC list (default: 10).
|
||||
*
|
||||
* fast_pac_format=binary option can be used to select binary format
|
||||
* for storing PAC entries in order to save some space (the default
|
||||
* text format uses about 2.5 times the size of minimal binary format).
|
||||
*
|
||||
* crypto_binding option can be used to control PEAPv0 cryptobinding
|
||||
* behavior:
|
||||
* 0 = do not use cryptobinding (default)
|
||||
* 1 = use cryptobinding if server supports it
|
||||
* 2 = require cryptobinding
|
||||
*
|
||||
* EAP-WSC (WPS) uses following options: pin=Device_Password and
|
||||
* uuid=Device_UUID
|
||||
*
|
||||
* For wired IEEE 802.1X authentication, "allow_canned_success=1" can be
|
||||
* used to configure a mode that allows EAP-Success (and EAP-Failure)
|
||||
* without going through authentication step. Some switches use such
|
||||
* sequence when forcing the port to be authorized/unauthorized or as a
|
||||
* fallback option if the authentication server is unreachable. By
|
||||
* default, wpa_supplicant discards such frames to protect against
|
||||
* potential attacks by rogue devices, but this option can be used to
|
||||
* disable that protection for cases where the server/authenticator does
|
||||
* not need to be authenticated.
|
||||
*/
|
||||
char *phase1;
|
||||
|
||||
/**
|
||||
* phase2 - Phase2 (inner authentication with TLS tunnel) parameters
|
||||
*
|
||||
* String with field-value pairs, e.g., "auth=MSCHAPV2" for EAP-PEAP or
|
||||
* "autheap=MSCHAPV2 autheap=MD5" for EAP-TTLS. "mschapv2_retry=0" can
|
||||
* be used to disable MSCHAPv2 password retry in authentication failure
|
||||
* cases.
|
||||
*/
|
||||
char *phase2;
|
||||
|
||||
/**
|
||||
* pcsc - Parameters for PC/SC smartcard interface for USIM and GSM SIM
|
||||
*
|
||||
* This field is used to configure PC/SC smartcard interface.
|
||||
* Currently, the only configuration is whether this field is %NULL (do
|
||||
* not use PC/SC) or non-NULL (e.g., "") to enable PC/SC.
|
||||
*
|
||||
* This field is used for EAP-SIM and EAP-AKA.
|
||||
*/
|
||||
char *pcsc;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* engine - Enable OpenSSL engine (e.g., for smartcard access)
|
||||
*
|
||||
* This is used if private key operations for EAP-TLS are performed
|
||||
* using a smartcard.
|
||||
*/
|
||||
int engine;
|
||||
|
||||
/**
|
||||
* engine_id - Engine ID for OpenSSL engine
|
||||
*
|
||||
* "opensc" to select OpenSC engine or "pkcs11" to select PKCS#11
|
||||
* engine.
|
||||
*
|
||||
* This is used if private key operations for EAP-TLS are performed
|
||||
* using a smartcard.
|
||||
*/
|
||||
char *engine_id;
|
||||
|
||||
/**
|
||||
* engine2 - Enable OpenSSL engine (e.g., for smartcard) (Phase 2)
|
||||
*
|
||||
* This is used if private key operations for EAP-TLS are performed
|
||||
* using a smartcard.
|
||||
*
|
||||
* This field is like engine, but used for phase 2 (inside
|
||||
* EAP-TTLS/PEAP/FAST tunnel) authentication.
|
||||
*/
|
||||
int engine2;
|
||||
|
||||
|
||||
/**
|
||||
* pin2 - PIN for USIM, GSM SIM, and smartcards (Phase 2)
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This field is like pin2, but used for phase 2 (inside
|
||||
* EAP-TTLS/PEAP/FAST tunnel) authentication.
|
||||
*
|
||||
* If left out, this will be asked through control interface.
|
||||
*/
|
||||
char *pin2;
|
||||
|
||||
/**
|
||||
* engine2_id - Engine ID for OpenSSL engine (Phase 2)
|
||||
*
|
||||
* "opensc" to select OpenSC engine or "pkcs11" to select PKCS#11
|
||||
* engine.
|
||||
*
|
||||
* This is used if private key operations for EAP-TLS are performed
|
||||
* using a smartcard.
|
||||
*
|
||||
* This field is like engine_id, but used for phase 2 (inside
|
||||
* EAP-TTLS/PEAP/FAST tunnel) authentication.
|
||||
*/
|
||||
char *engine2_id;
|
||||
|
||||
|
||||
/**
|
||||
* key_id - Key ID for OpenSSL engine
|
||||
*
|
||||
* This is used if private key operations for EAP-TLS are performed
|
||||
* using a smartcard.
|
||||
*/
|
||||
char *key_id;
|
||||
|
||||
/**
|
||||
* cert_id - Cert ID for OpenSSL engine
|
||||
*
|
||||
* This is used if the certificate operations for EAP-TLS are performed
|
||||
* using a smartcard.
|
||||
*/
|
||||
char *cert_id;
|
||||
|
||||
/**
|
||||
* ca_cert_id - CA Cert ID for OpenSSL engine
|
||||
*
|
||||
* This is used if the CA certificate for EAP-TLS is on a smartcard.
|
||||
*/
|
||||
char *ca_cert_id;
|
||||
|
||||
/**
|
||||
* key2_id - Key ID for OpenSSL engine (phase2)
|
||||
*
|
||||
* This is used if private key operations for EAP-TLS are performed
|
||||
* using a smartcard.
|
||||
*/
|
||||
char *key2_id;
|
||||
|
||||
/**
|
||||
* cert2_id - Cert ID for OpenSSL engine (phase2)
|
||||
*
|
||||
* This is used if the certificate operations for EAP-TLS are performed
|
||||
* using a smartcard.
|
||||
*/
|
||||
char *cert2_id;
|
||||
|
||||
/**
|
||||
* ca_cert2_id - CA Cert ID for OpenSSL engine (phase2)
|
||||
*
|
||||
* This is used if the CA certificate for EAP-TLS is on a smartcard.
|
||||
*/
|
||||
char *ca_cert2_id;
|
||||
|
||||
/**
|
||||
* otp - One-time-password
|
||||
*
|
||||
* This field should not be set in configuration step. It is only used
|
||||
* internally when OTP is entered through the control interface.
|
||||
*/
|
||||
u8 *otp;
|
||||
|
||||
/**
|
||||
* otp_len - Length of the otp field
|
||||
*/
|
||||
size_t otp_len;
|
||||
|
||||
/**
|
||||
* pending_req_identity - Whether there is a pending identity request
|
||||
*
|
||||
* This field should not be set in configuration step. It is only used
|
||||
* internally when control interface is used to request needed
|
||||
* information.
|
||||
*/
|
||||
int pending_req_identity;
|
||||
|
||||
/**
|
||||
* pending_req_password - Whether there is a pending password request
|
||||
*
|
||||
* This field should not be set in configuration step. It is only used
|
||||
* internally when control interface is used to request needed
|
||||
* information.
|
||||
*/
|
||||
int pending_req_password;
|
||||
|
||||
/**
|
||||
* pending_req_pin - Whether there is a pending PIN request
|
||||
*
|
||||
* This field should not be set in configuration step. It is only used
|
||||
* internally when control interface is used to request needed
|
||||
* information.
|
||||
*/
|
||||
int pending_req_pin;
|
||||
|
||||
/**
|
||||
* pending_req_new_password - Pending password update request
|
||||
*
|
||||
* This field should not be set in configuration step. It is only used
|
||||
* internally when control interface is used to request needed
|
||||
* information.
|
||||
*/
|
||||
int pending_req_new_password;
|
||||
|
||||
/**
|
||||
* pending_req_passphrase - Pending passphrase request
|
||||
*
|
||||
* This field should not be set in configuration step. It is only used
|
||||
* internally when control interface is used to request needed
|
||||
* information.
|
||||
*/
|
||||
int pending_req_passphrase;
|
||||
|
||||
/**
|
||||
* pending_req_otp - Whether there is a pending OTP request
|
||||
*
|
||||
* This field should not be set in configuration step. It is only used
|
||||
* internally when control interface is used to request needed
|
||||
* information.
|
||||
*/
|
||||
char *pending_req_otp;
|
||||
|
||||
/**
|
||||
* pending_req_otp_len - Length of the pending OTP request
|
||||
*/
|
||||
size_t pending_req_otp_len;
|
||||
|
||||
/**
|
||||
* pac_file - File path or blob name for the PAC entries (EAP-FAST)
|
||||
*
|
||||
* wpa_supplicant will need to be able to create this file and write
|
||||
* updates to it when PAC is being provisioned or refreshed. 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.
|
||||
*/
|
||||
char *pac_file;
|
||||
|
||||
/**
|
||||
* mschapv2_retry - MSCHAPv2 retry in progress
|
||||
*
|
||||
* This field is used internally by EAP-MSCHAPv2 and should not be set
|
||||
* as part of configuration.
|
||||
*/
|
||||
int mschapv2_retry;
|
||||
|
||||
/**
|
||||
* new_password - New password for password update
|
||||
*
|
||||
* This field is used during MSCHAPv2 password update. This is normally
|
||||
* requested from the user through the control interface and not set
|
||||
* from configuration.
|
||||
*/
|
||||
u8 *new_password;
|
||||
|
||||
/**
|
||||
* new_password_len - Length of new_password field
|
||||
*/
|
||||
size_t new_password_len;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* external_sim_resp - Response from external SIM processing
|
||||
*
|
||||
* This field should not be set in configuration step. It is only used
|
||||
* internally when control interface is used to request external
|
||||
* SIM/USIM processing.
|
||||
*/
|
||||
char *external_sim_resp;
|
||||
|
||||
/**
|
||||
* sim_num - User selected SIM identifier
|
||||
*
|
||||
* This variable is used for identifying which SIM is used if the system
|
||||
* has more than one.
|
||||
*/
|
||||
int sim_num;
|
||||
|
||||
/**
|
||||
* openssl_ciphers - OpenSSL cipher string
|
||||
*
|
||||
* This is an OpenSSL specific configuration option for configuring the
|
||||
* ciphers for this connection. If not set, the default cipher suite
|
||||
* list is used.
|
||||
*/
|
||||
char *openssl_ciphers;
|
||||
|
||||
/**
|
||||
* erp - Whether EAP Re-authentication Protocol (ERP) is enabled
|
||||
*/
|
||||
int erp;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 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 */
|
||||
|
|
@ -0,0 +1,391 @@
|
|||
/*
|
||||
* 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 "utils/wpabuf.h"
|
||||
#include "eap.h"
|
||||
|
||||
#include "eap_common/eap_common.h"
|
||||
|
||||
/* RFC 4137 - EAP Peer state machine */
|
||||
//#if 0
|
||||
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.
|
||||
*/
|
||||
// we don't use it
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* struct eap_method - EAP method interface
|
||||
* This structure defines the EAP method interface. Each method will need to
|
||||
* register its own EAP type, EAP name, and set of function pointers for method
|
||||
* specific operations. This interface is based on section 4.4 of RFC 4137.
|
||||
*/
|
||||
|
||||
struct eap_method {
|
||||
/**
|
||||
* vendor - EAP Vendor-ID (EAP_VENDOR_*) (0 = IETF)
|
||||
*/
|
||||
int vendor;
|
||||
|
||||
/**
|
||||
* method - EAP type number (EAP_TYPE_*)
|
||||
*/
|
||||
EapType method;
|
||||
|
||||
/**
|
||||
* name - Name of the method (e.g., "TLS")
|
||||
*/
|
||||
const char *name;
|
||||
|
||||
/**
|
||||
* init - Initialize an EAP method
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* Returns: Pointer to allocated private data, or %NULL on failure
|
||||
*
|
||||
* This function is used to initialize the EAP method explicitly
|
||||
* instead of using METHOD_INIT state as specific in RFC 4137. The
|
||||
* method is expected to initialize it method-specific state and return
|
||||
* a pointer that will be used as the priv argument to other calls.
|
||||
*/
|
||||
void * (*init)(struct eap_sm *sm);
|
||||
|
||||
/**
|
||||
* deinit - Deinitialize an EAP method
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
*
|
||||
* Deinitialize the EAP method and free any allocated private data.
|
||||
*/
|
||||
void (*deinit)(struct eap_sm *sm, void *priv);
|
||||
|
||||
/**
|
||||
* process - Process an EAP request
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
* @ret: Return values from EAP request validation and processing
|
||||
* @reqData: EAP request to be processed (eapReqData)
|
||||
* Returns: Pointer to allocated EAP response packet (eapRespData)
|
||||
*
|
||||
* This function is a combination of m.check(), m.process(), and
|
||||
* m.buildResp() procedures defined in section 4.4 of RFC 4137 In other
|
||||
* words, this function validates the incoming request, processes it,
|
||||
* and build a response packet. m.check() and m.process() return values
|
||||
* are returned through struct eap_method_ret *ret variable. Caller is
|
||||
* responsible for freeing the returned EAP response packet.
|
||||
*/
|
||||
struct wpabuf * (*process)(struct eap_sm *sm, void *priv,
|
||||
struct eap_method_ret *ret,
|
||||
const struct wpabuf *reqData);
|
||||
|
||||
/**
|
||||
* isKeyAvailable - Find out whether EAP method has keying material
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
* Returns: %TRUE if key material (eapKeyData) is available
|
||||
*/
|
||||
Boolean (*isKeyAvailable)(struct eap_sm *sm, void *priv);
|
||||
|
||||
/**
|
||||
* getKey - Get EAP method specific keying material (eapKeyData)
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
* @len: Pointer to variable to store key length (eapKeyDataLen)
|
||||
* Returns: Keying material (eapKeyData) or %NULL if not available
|
||||
*
|
||||
* This function can be used to get the keying material from the EAP
|
||||
* method. The key may already be stored in the method-specific private
|
||||
* data or this function may derive the key.
|
||||
*/
|
||||
u8 * (*getKey)(struct eap_sm *sm, void *priv, size_t *len);
|
||||
|
||||
/**
|
||||
* get_status - Get EAP method status
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
* @buf: Buffer for status information
|
||||
* @buflen: Maximum buffer length
|
||||
* @verbose: Whether to include verbose status information
|
||||
* Returns: Number of bytes written to buf
|
||||
*
|
||||
* Query EAP method for status information. This function fills in a
|
||||
* text area with current status information from the EAP method. If
|
||||
* the buffer (buf) is not large enough, status information will be
|
||||
* truncated to fit the buffer.
|
||||
*/
|
||||
int (*get_status)(struct eap_sm *sm, void *priv, char *buf,
|
||||
size_t buflen, int verbose);
|
||||
|
||||
/**
|
||||
* has_reauth_data - Whether method is ready for fast reauthentication
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
* Returns: %TRUE or %FALSE based on whether fast reauthentication is
|
||||
* possible
|
||||
*
|
||||
* This function is an optional handler that only EAP methods
|
||||
* supporting fast re-authentication need to implement.
|
||||
*/
|
||||
Boolean (*has_reauth_data)(struct eap_sm *sm, void *priv);
|
||||
|
||||
/**
|
||||
* deinit_for_reauth - Release data that is not needed for fast re-auth
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
*
|
||||
* This function is an optional handler that only EAP methods
|
||||
* supporting fast re-authentication need to implement. This is called
|
||||
* when authentication has been completed and EAP state machine is
|
||||
* requesting that enough state information is maintained for fast
|
||||
* re-authentication
|
||||
*/
|
||||
void (*deinit_for_reauth)(struct eap_sm *sm, void *priv);
|
||||
|
||||
/**
|
||||
* init_for_reauth - Prepare for start of fast re-authentication
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
*
|
||||
* This function is an optional handler that only EAP methods
|
||||
* supporting fast re-authentication need to implement. This is called
|
||||
* when EAP authentication is started and EAP state machine is
|
||||
* requesting fast re-authentication to be used.
|
||||
*/
|
||||
void * (*init_for_reauth)(struct eap_sm *sm, void *priv);
|
||||
|
||||
/**
|
||||
* get_identity - Get method specific identity for re-authentication
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
* @len: Length of the returned identity
|
||||
* Returns: Pointer to the method specific identity or %NULL if default
|
||||
* identity is to be used
|
||||
*
|
||||
* This function is an optional handler that only EAP methods
|
||||
* that use method specific identity need to implement.
|
||||
*/
|
||||
const u8 * (*get_identity)(struct eap_sm *sm, void *priv, size_t *len);
|
||||
|
||||
/**
|
||||
* free - Free EAP method data
|
||||
* @method: Pointer to the method data registered with
|
||||
* eap_peer_method_register().
|
||||
*
|
||||
* This function will be called when the EAP method is being
|
||||
* unregistered. If the EAP method allocated resources during
|
||||
* registration (e.g., allocated struct eap_method), they should be
|
||||
* freed in this function. No other method functions will be called
|
||||
* after this call. If this function is not defined (i.e., function
|
||||
* pointer is %NULL), a default handler is used to release the method
|
||||
* data with free(method). This is suitable for most cases.
|
||||
*/
|
||||
void (*free)(struct eap_method *method);
|
||||
|
||||
#define EAP_PEER_METHOD_INTERFACE_VERSION 1
|
||||
/**
|
||||
* version - Version of the EAP peer method interface
|
||||
*
|
||||
* The EAP peer method implementation should set this variable to
|
||||
* EAP_PEER_METHOD_INTERFACE_VERSION. This is used to verify that the
|
||||
* EAP method is using supported API version when using dynamically
|
||||
* loadable EAP methods.
|
||||
*/
|
||||
int version;
|
||||
|
||||
/**
|
||||
* next - Pointer to the next EAP method
|
||||
*
|
||||
* This variable is used internally in the EAP method registration code
|
||||
* to create a linked list of registered EAP methods.
|
||||
*/
|
||||
struct eap_method *next;
|
||||
|
||||
#ifdef CONFIG_DYNAMIC_EAP_METHODS
|
||||
/**
|
||||
* dl_handle - Handle for the dynamic library
|
||||
*
|
||||
* This variable is used internally in the EAP method registration code
|
||||
* to store a handle for the dynamic library. If the method is linked
|
||||
* in statically, this is %NULL.
|
||||
*/
|
||||
void *dl_handle;
|
||||
#endif /* CONFIG_DYNAMIC_EAP_METHODS */
|
||||
|
||||
/**
|
||||
* get_emsk - Get EAP method specific keying extended material (EMSK)
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
* @len: Pointer to a variable to store EMSK length
|
||||
* Returns: EMSK or %NULL if not available
|
||||
*
|
||||
* This function can be used to get the extended keying material from
|
||||
* the EAP method. The key may already be stored in the method-specific
|
||||
* private data or this function may derive the key.
|
||||
*/
|
||||
u8 * (*get_emsk)(struct eap_sm *sm, void *priv, size_t *len);
|
||||
|
||||
/**
|
||||
* getSessionId - Get EAP method specific Session-Id
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @priv: Pointer to private EAP method data from eap_method::init()
|
||||
* @len: Pointer to a variable to store Session-Id length
|
||||
* Returns: Session-Id or %NULL if not available
|
||||
*
|
||||
* This function can be used to get the Session-Id from the EAP method.
|
||||
* The Session-Id may already be stored in the method-specific private
|
||||
* data or this function may derive the Session-Id.
|
||||
*/
|
||||
u8 * (*getSessionId)(struct eap_sm *sm, void *priv, size_t *len);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* struct eap_sm - EAP state machine data
|
||||
*/
|
||||
|
||||
struct eap_sm {
|
||||
enum {
|
||||
EAP_INITIALIZE, EAP_DISABLED, EAP_IDLE, EAP_RECEIVED,
|
||||
EAP_GET_METHOD, EAP_METHOD, EAP_SEND_RESPONSE, EAP_DISCARD,
|
||||
EAP_IDENTITY, EAP_NOTIFICATION, EAP_RETRANSMIT, EAP_SUCCESS,
|
||||
EAP_FAILURE
|
||||
} EAP_state;
|
||||
/* Long-term local variables */
|
||||
EapType selectedMethod;
|
||||
EapMethodState methodState;
|
||||
int lastId;
|
||||
struct wpabuf *lastRespData;
|
||||
EapDecision decision;
|
||||
/* Short-term local variables */
|
||||
Boolean rxReq;
|
||||
Boolean rxSuccess;
|
||||
Boolean rxFailure;
|
||||
int reqId;
|
||||
EapType reqMethod;
|
||||
int reqVendor;
|
||||
u32 reqVendorMethod;
|
||||
Boolean ignore;
|
||||
/* Constants */
|
||||
int ClientTimeout;
|
||||
|
||||
/* Miscellaneous variables */
|
||||
Boolean allowNotifications; /* peer state machine <-> methods */
|
||||
struct wpabuf *eapRespData; /* peer to lower layer */
|
||||
Boolean eapKeyAvailable; /* peer to lower layer */
|
||||
u8 *eapKeyData; /* peer to lower layer */
|
||||
size_t eapKeyDataLen; /* peer to lower layer */
|
||||
u8 *eapSessionId; /* peer to lower layer */
|
||||
size_t eapSessionIdLen; /* peer to lower layer */
|
||||
const struct eap_method *m; /* selected EAP method */
|
||||
/* not defined in RFC 4137 */
|
||||
Boolean changed;
|
||||
void *eapol_ctx;
|
||||
struct eapol_callbacks *eapol_cb;
|
||||
void *eap_method_priv;
|
||||
int init_phase2;
|
||||
int fast_reauth;
|
||||
Boolean reauthInit;
|
||||
u32 erp_seq;
|
||||
|
||||
Boolean rxResp /* LEAP only */;
|
||||
Boolean leap_done;
|
||||
Boolean peap_done;
|
||||
u8 req_md5[16]; /* MD5() of the current EAP packet */
|
||||
u8 last_md5[16]; /* MD5() of the previously received EAP packet; used
|
||||
* in duplicate request detection. */
|
||||
|
||||
u8 req_sha1[20];
|
||||
u8 last_sha1[20];
|
||||
|
||||
void *msg_ctx;
|
||||
void *scard_ctx;
|
||||
void *ssl_ctx;
|
||||
void *ssl_ctx2;
|
||||
|
||||
unsigned int workaround;
|
||||
|
||||
/* Optional challenges generated in Phase 1 (EAP-FAST) */
|
||||
u8 *peer_challenge, *auth_challenge;
|
||||
|
||||
int num_rounds;
|
||||
int force_disabled;
|
||||
|
||||
struct wps_context *wps;
|
||||
|
||||
int prev_failure;
|
||||
struct eap_peer_config *last_config;
|
||||
|
||||
struct ext_password_data *ext_pw;
|
||||
struct wpabuf *ext_pw_buf;
|
||||
|
||||
unsigned int expected_failure:1;
|
||||
|
||||
//struct dl_list erp_keys; /* struct eap_erp_key */
|
||||
};
|
||||
|
||||
|
||||
const u8 * eap_get_config_identity(struct eap_sm *sm, size_t *len);
|
||||
const u8 * eap_get_config_password(struct eap_sm *sm, size_t *len);
|
||||
const u8 * eap_get_config_password2(struct eap_sm *sm, size_t *len, int *hash);
|
||||
const u8 * eap_get_config_new_password(struct eap_sm *sm, size_t *len);
|
||||
const u8 * eap_get_config_otp(struct eap_sm *sm, size_t *len);
|
||||
void eap_clear_config_otp(struct eap_sm *sm);
|
||||
const char * eap_get_config_phase1(struct eap_sm *sm);
|
||||
const char * eap_get_config_phase2(struct eap_sm *sm);
|
||||
int eap_get_config_fragment_size(struct eap_sm *sm);
|
||||
struct eap_peer_config * eap_get_config(struct eap_sm *sm);
|
||||
void eap_set_config_blob(struct eap_sm *sm, struct wpa_config_blob *blob);
|
||||
const struct wpa_config_blob *
|
||||
eap_get_config_blob(struct eap_sm *sm, const char *name);
|
||||
void eap_notify_pending(struct eap_sm *sm);
|
||||
int eap_allowed_method(struct eap_sm *sm, int vendor, u32 method);
|
||||
//#endif
|
||||
#endif /* EAP_I_H */
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* EAP peer: Method registration
|
||||
* 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_METHODS_H
|
||||
#define EAP_METHODS_H
|
||||
//#if 0
|
||||
//#include "../api/wifi/wps/wps_eap_defs.h"
|
||||
#include "eap_common/eap_defs.h"
|
||||
|
||||
const struct eap_method * eap_peer_get_eap_method(int vendor, EapType method);
|
||||
const struct eap_method * eap_peer_get_methods(size_t *count);
|
||||
|
||||
struct eap_method * eap_peer_method_alloc(int version, int vendor,
|
||||
EapType method, const char *name);
|
||||
void eap_peer_method_free(struct eap_method *method);
|
||||
int eap_peer_method_register(struct eap_method *method);
|
||||
|
||||
|
||||
//#if defined(IEEE8021X_EAPOL)
|
||||
|
||||
EapType eap_peer_get_type(const char *name, int *vendor);
|
||||
const char * eap_get_name(int vendor, EapType type);
|
||||
size_t eap_get_names(char *buf, size_t buflen);
|
||||
char ** eap_get_names_as_string_array(size_t *num);
|
||||
void eap_peer_unregister_methods(void);
|
||||
|
||||
//#else /* IEEE8021X_EAPOL */
|
||||
#if 0
|
||||
static inline EapType eap_peer_get_type(const char *name, int *vendor)
|
||||
{
|
||||
*vendor = EAP_VENDOR_IETF;
|
||||
return EAP_TYPE_NONE;
|
||||
}
|
||||
|
||||
static inline const char * eap_get_name(int vendor, EapType type)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline size_t eap_get_names(char *buf, size_t buflen)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int eap_peer_register_methods(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void eap_peer_unregister_methods(void)
|
||||
{
|
||||
}
|
||||
|
||||
static inline char ** eap_get_names_as_string_array(size_t *num)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
//#endif /* IEEE8021X_EAPOL */
|
||||
|
||||
|
||||
#ifdef CONFIG_DYNAMIC_EAP_METHODS
|
||||
|
||||
int eap_peer_method_load(const char *so);
|
||||
int eap_peer_method_unload(struct eap_method *method);
|
||||
|
||||
#else /* CONFIG_DYNAMIC_EAP_METHODS */
|
||||
|
||||
static inline int eap_peer_method_load(const char *so)
|
||||
{
|
||||
|
||||
/* To avoid gcc warnings */
|
||||
( void ) so;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int eap_peer_method_unload(struct eap_method *method)
|
||||
{
|
||||
|
||||
/* To avoid gcc warnings */
|
||||
( void ) method;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_DYNAMIC_EAP_METHODS */
|
||||
|
||||
/* EAP peer method registration calls for statically linked in methods */
|
||||
int eap_peer_md5_register(void);
|
||||
int eap_peer_tls_register(void);
|
||||
int eap_peer_unauth_tls_register(void);
|
||||
int eap_peer_mschapv2_register(void);
|
||||
int eap_peer_peap_register(void);
|
||||
int eap_peer_ttls_register(void);
|
||||
int eap_peer_gtc_register(void);
|
||||
int eap_peer_otp_register(void);
|
||||
int eap_peer_sim_register(void);
|
||||
int eap_peer_leap_register(void);
|
||||
int eap_peer_psk_register(void);
|
||||
int eap_peer_aka_register(void);
|
||||
int eap_peer_aka_prime_register(void);
|
||||
int eap_peer_fast_register(void);
|
||||
int eap_peer_pax_register(void);
|
||||
int eap_peer_sake_register(void);
|
||||
int eap_peer_gpsk_register(void);
|
||||
int eap_peer_wsc_register(void);
|
||||
int eap_peer_ikev2_register(void);
|
||||
int eap_peer_vendor_test_register(void);
|
||||
int eap_peer_tnc_register(void);
|
||||
int eap_peer_pwd_register(void);
|
||||
//#endif
|
||||
#endif /* EAP_METHODS_H */
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* 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
|
||||
#define EAP_WFA_UNAUTH_TLS_TYPE 254
|
||||
|
||||
|
||||
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 struct wpabuf *in_data,
|
||||
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 */
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef EAP_WSC_H
|
||||
#define EAP_WSC_H
|
||||
|
||||
#ifdef FAIL
|
||||
#undef FAIL
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
enum wsc_state{ WAIT_START, MESG, FRAG_ACK, WAIT_FRAG_ACK, DONE, FAIL };
|
||||
|
||||
|
||||
struct eap_wsc_data {
|
||||
enum wsc_state state ;
|
||||
int registrar;
|
||||
struct wpabuf *in_buf;
|
||||
struct wpabuf *out_buf;
|
||||
enum wsc_op_code in_op_code, out_op_code;
|
||||
size_t out_used; //global used ?
|
||||
size_t fragment_size;
|
||||
struct wps_data *wps; // allocate by wsc_init()
|
||||
//struct wps_context *wps_ctx; // non-use
|
||||
};
|
||||
#endif
|
||||
int eap_peer_wsc_register(void);
|
||||
#endif /* EAP_WSC_H */
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* MSCHAPV2 (RFC 2759)
|
||||
* Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef MSCHAPV2_H
|
||||
#define MSCHAPV2_H
|
||||
|
||||
#define MSCHAPV2_CHAL_LEN 16
|
||||
#define MSCHAPV2_NT_RESPONSE_LEN 24
|
||||
#define MSCHAPV2_AUTH_RESPONSE_LEN 20
|
||||
#define MSCHAPV2_MASTER_KEY_LEN 16
|
||||
|
||||
const u8 * mschapv2_remove_domain(const u8 *username, size_t *len);
|
||||
int mschapv2_derive_response(const u8 *username, size_t username_len,
|
||||
const u8 *password, size_t password_len,
|
||||
int pwhash,
|
||||
const u8 *auth_challenge,
|
||||
const u8 *peer_challenge,
|
||||
u8 *nt_response, u8 *auth_response,
|
||||
u8 *master_key);
|
||||
int mschapv2_verify_auth_response(const u8 *auth_response,
|
||||
const u8 *buf, size_t buf_len);
|
||||
|
||||
#endif /* MSCHAPV2_H */
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef EAP_SERVER_WSC_H
|
||||
#define EAP_SERVER_WSC_H
|
||||
|
||||
#ifdef FAIL
|
||||
#undef FAIL
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
enum wsc_state{ WAIT_START, MESG, FRAG_ACK, WAIT_FRAG_ACK, DONE, FAIL };
|
||||
|
||||
|
||||
struct eap_wsc_data {
|
||||
enum wsc_state state ;
|
||||
int registrar;
|
||||
struct wpabuf *in_buf;
|
||||
struct wpabuf *out_buf;
|
||||
enum wsc_op_code in_op_code, out_op_code;
|
||||
size_t out_used; //global used ?
|
||||
size_t fragment_size;
|
||||
struct wps_data *wps; // allocate by wsc_init()
|
||||
//struct wps_context *wps_ctx; // non-use
|
||||
};
|
||||
#endif
|
||||
int eap_server_wsc_register(void);
|
||||
|
||||
#endif /* EAP_WSC_H */
|
||||
1790
sdk/component/common/api/wifi/rtw_wpa_supplicant/src/p2p/p2p.h
Normal file
1790
sdk/component/common/api/wifi/rtw_wpa_supplicant/src/p2p/p2p.h
Normal file
File diff suppressed because it is too large
Load diff
765
sdk/component/common/api/wifi/rtw_wpa_supplicant/src/p2p/p2p_i.h
Normal file
765
sdk/component/common/api/wifi/rtw_wpa_supplicant/src/p2p/p2p_i.h
Normal file
|
|
@ -0,0 +1,765 @@
|
|||
/*
|
||||
* P2P - Internal definitions for P2P module
|
||||
* Copyright (c) 2009-2010, Atheros Communications
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef P2P_I_H
|
||||
#define P2P_I_H
|
||||
|
||||
#include "utils/wpa_list.h"
|
||||
#include "p2p.h"
|
||||
|
||||
enum p2p_go_state {
|
||||
UNKNOWN_GO,
|
||||
LOCAL_GO,
|
||||
REMOTE_GO
|
||||
};
|
||||
|
||||
#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
|
||||
#define P2P_DEV_REPORTED BIT(1)
|
||||
#define P2P_DEV_NOT_YET_READY BIT(2)
|
||||
#define P2P_DEV_SD_INFO BIT(3)
|
||||
#define P2P_DEV_SD_SCHEDULE BIT(4)
|
||||
#define P2P_DEV_PD_PEER_DISPLAY BIT(5)
|
||||
#define P2P_DEV_PD_PEER_KEYPAD BIT(6)
|
||||
#define P2P_DEV_USER_REJECTED BIT(7)
|
||||
#define P2P_DEV_PEER_WAITING_RESPONSE BIT(8)
|
||||
#define P2P_DEV_PREFER_PERSISTENT_GROUP BIT(9)
|
||||
#define P2P_DEV_WAIT_GO_NEG_RESPONSE BIT(10)
|
||||
#define P2P_DEV_WAIT_GO_NEG_CONFIRM BIT(11)
|
||||
#define P2P_DEV_GROUP_CLIENT_ONLY BIT(12)
|
||||
#define P2P_DEV_FORCE_FREQ BIT(13)
|
||||
#define P2P_DEV_PD_FOR_JOIN BIT(14)
|
||||
#define P2P_DEV_REPORTED_ONCE BIT(15)
|
||||
#define P2P_DEV_PREFER_PERSISTENT_RECONN BIT(16)
|
||||
#define P2P_DEV_PD_BEFORE_GO_NEG BIT(17)
|
||||
|
||||
/**
|
||||
* struct p2p_device - P2P Device data (internal to P2P module)
|
||||
*/
|
||||
struct p2p_device {
|
||||
struct dl_list list;
|
||||
struct os_time last_seen;
|
||||
int listen_freq;
|
||||
enum p2p_wps_method wps_method;
|
||||
|
||||
struct p2p_peer_info info;
|
||||
|
||||
/*
|
||||
* If the peer was discovered based on an interface address (e.g., GO
|
||||
* from Beacon/Probe Response), the interface address is stored here.
|
||||
* p2p_device_addr must still be set in such a case to the unique
|
||||
* identifier for the P2P Device.
|
||||
*/
|
||||
u8 interface_addr[ETH_ALEN];
|
||||
|
||||
/*
|
||||
* P2P Device Address of the GO in whose group this P2P Device is a
|
||||
* client.
|
||||
*/
|
||||
u8 member_in_go_dev[ETH_ALEN];
|
||||
|
||||
/*
|
||||
* P2P Interface Address of the GO in whose group this P2P Device is a
|
||||
* client.
|
||||
*/
|
||||
u8 member_in_go_iface[ETH_ALEN];
|
||||
|
||||
int go_neg_req_sent;
|
||||
enum p2p_go_state go_state;
|
||||
u8 dialog_token;
|
||||
u8 intended_addr[ETH_ALEN];
|
||||
|
||||
char country[3];
|
||||
struct p2p_channels channels;
|
||||
int oper_freq;
|
||||
u8 oper_ssid[32];
|
||||
size_t oper_ssid_len;
|
||||
|
||||
/**
|
||||
* req_config_methods - Pending provision discovery methods
|
||||
*/
|
||||
u16 req_config_methods;
|
||||
|
||||
/**
|
||||
* wps_prov_info - Stored provisioning WPS config method
|
||||
*
|
||||
* This is used to store pending WPS config method between Provisioning
|
||||
* Discovery and connection to a running group.
|
||||
*/
|
||||
u16 wps_prov_info;
|
||||
|
||||
unsigned int flags;
|
||||
|
||||
int status; /* enum p2p_status_code */
|
||||
unsigned int wait_count;
|
||||
unsigned int connect_reqs;
|
||||
unsigned int invitation_reqs;
|
||||
|
||||
u16 ext_listen_period;
|
||||
u16 ext_listen_interval;
|
||||
|
||||
u8 go_timeout;
|
||||
u8 client_timeout;
|
||||
};
|
||||
|
||||
struct p2p_sd_query {
|
||||
struct p2p_sd_query *next;
|
||||
u8 peer[ETH_ALEN];
|
||||
int for_all_peers;
|
||||
int wsd; /* Wi-Fi Display Service Discovery Request */
|
||||
struct wpabuf *tlvs;
|
||||
};
|
||||
|
||||
struct p2p_pending_action_tx {
|
||||
unsigned int freq;
|
||||
u8 dst[ETH_ALEN];
|
||||
u8 src[ETH_ALEN];
|
||||
u8 bssid[ETH_ALEN];
|
||||
size_t len;
|
||||
unsigned int wait_time;
|
||||
/* Followed by len octets of the frame */
|
||||
};
|
||||
|
||||
enum p2p_role {
|
||||
P2P_R_DISABLE = 0,
|
||||
P2P_R_DEVICE = 1,
|
||||
P2P_R_CLIENT = 2,
|
||||
P2P_R_GO = 3
|
||||
};
|
||||
|
||||
enum p2p_state {
|
||||
/**
|
||||
* P2P_IDLE - Idle 0
|
||||
*/
|
||||
P2P_IDLE,
|
||||
|
||||
/**
|
||||
* P2P_SEARCH - Search (Device Discovery) 1
|
||||
*/
|
||||
P2P_SEARCH,
|
||||
|
||||
/**
|
||||
* P2P_CONNECT - Trying to start GO Negotiation 2
|
||||
*/
|
||||
P2P_CONNECT,
|
||||
|
||||
/**
|
||||
* P2P_CONNECT_LISTEN - Listen during GO Negotiation start 3
|
||||
*/
|
||||
P2P_CONNECT_LISTEN,
|
||||
|
||||
/**
|
||||
* P2P_GO_NEG - In GO Negotiation 4
|
||||
*/
|
||||
P2P_GO_NEG,
|
||||
|
||||
/**
|
||||
* P2P_LISTEN_ONLY - Listen only 5
|
||||
*/
|
||||
P2P_LISTEN_ONLY,
|
||||
|
||||
/**
|
||||
* P2P_WAIT_PEER_CONNECT - Waiting peer in List for GO Neg 6
|
||||
*/
|
||||
P2P_WAIT_PEER_CONNECT,
|
||||
|
||||
/**
|
||||
* P2P_WAIT_PEER_IDLE - Waiting peer idle for GO Neg 7
|
||||
*/
|
||||
P2P_WAIT_PEER_IDLE,
|
||||
|
||||
/**
|
||||
* P2P_SD_DURING_FIND - Service Discovery during find 8
|
||||
*/
|
||||
P2P_SD_DURING_FIND,
|
||||
|
||||
/**
|
||||
* P2P_PROVISIONING - Provisioning (during group formation) 9
|
||||
*/
|
||||
P2P_PROVISIONING,
|
||||
|
||||
/**
|
||||
* P2P_PD_DURING_FIND - Provision Discovery during find
|
||||
*/
|
||||
P2P_PD_DURING_FIND,
|
||||
|
||||
/**
|
||||
* P2P_INVITE - Trying to start Invite
|
||||
*/
|
||||
P2P_INVITE,
|
||||
|
||||
/**
|
||||
* P2P_INVITE_LISTEN - Listen during Invite
|
||||
*/
|
||||
P2P_INVITE_LISTEN,
|
||||
|
||||
/**
|
||||
* P2P_SEARCH_WHEN_READY - Waiting to start Search
|
||||
*/
|
||||
P2P_SEARCH_WHEN_READY,
|
||||
|
||||
/**
|
||||
* P2P_CONTINUE_SEARCH_WHEN_READY - Waiting to continue Search
|
||||
*/
|
||||
P2P_CONTINUE_SEARCH_WHEN_READY
|
||||
};
|
||||
|
||||
enum p2p_pending_action_state {
|
||||
P2P_NO_PENDING_ACTION,
|
||||
P2P_PENDING_GO_NEG_REQUEST,
|
||||
P2P_PENDING_GO_NEG_RESPONSE,
|
||||
P2P_PENDING_GO_NEG_RESPONSE_FAILURE,
|
||||
P2P_PENDING_GO_NEG_CONFIRM,
|
||||
P2P_PENDING_SD,
|
||||
P2P_PENDING_PD,
|
||||
P2P_PENDING_INVITATION_REQUEST,
|
||||
P2P_PENDING_INVITATION_RESPONSE,
|
||||
P2P_PENDING_DEV_DISC_REQUEST,
|
||||
P2P_PENDING_DEV_DISC_RESPONSE,
|
||||
P2P_PENDING_GO_DISC_REQ
|
||||
};
|
||||
|
||||
/**
|
||||
* struct p2p_data - P2P module data (internal to P2P module)
|
||||
*/
|
||||
struct p2p_data {
|
||||
/**
|
||||
* cfg - P2P module configuration
|
||||
*
|
||||
* This is included in the same memory allocation with the
|
||||
* struct p2p_data and as such, must not be freed separately.
|
||||
*/
|
||||
struct p2p_config *cfg;
|
||||
|
||||
/**
|
||||
* state - The current P2P state
|
||||
*/
|
||||
enum p2p_state state;
|
||||
|
||||
/**
|
||||
* min_disc_int - minDiscoverableInterval
|
||||
*/
|
||||
int min_disc_int;
|
||||
|
||||
/**
|
||||
* max_disc_int - maxDiscoverableInterval
|
||||
*/
|
||||
int max_disc_int;
|
||||
|
||||
/**
|
||||
* max_disc_tu - Maximum number of TUs for discoverable interval
|
||||
*/
|
||||
int max_disc_tu;
|
||||
|
||||
/**
|
||||
* devices - List of known P2P Device peers
|
||||
*/
|
||||
struct dl_list devices;
|
||||
|
||||
/**
|
||||
* go_neg_peer - Pointer to GO Negotiation peer
|
||||
*/
|
||||
struct p2p_device *go_neg_peer;
|
||||
|
||||
/* GO Negotiation data */
|
||||
|
||||
/**
|
||||
* intended_addr - Local Intended P2P Interface Address
|
||||
*
|
||||
* This address is used during group owner negotiation as the Intended
|
||||
* P2P Interface Address and the group interface will be created with
|
||||
* address as the local address in case of successfully completed
|
||||
* negotiation.
|
||||
*/
|
||||
u8 intended_addr[ETH_ALEN];
|
||||
|
||||
/**
|
||||
* go_intent - Local GO Intent to be used during GO Negotiation
|
||||
*/
|
||||
u8 go_intent;
|
||||
|
||||
/**
|
||||
* next_tie_breaker - Next tie-breaker value to use in GO Negotiation
|
||||
*/
|
||||
u8 next_tie_breaker;
|
||||
|
||||
/**
|
||||
* ssid - Selected SSID for GO Negotiation (if local end will be GO)
|
||||
*/
|
||||
u8 ssid[32];
|
||||
|
||||
/**
|
||||
* ssid_len - ssid length in octets
|
||||
*/
|
||||
size_t ssid_len;
|
||||
|
||||
/**
|
||||
* ssid_set - Whether SSID is already set for GO Negotiation
|
||||
*/
|
||||
int ssid_set;
|
||||
|
||||
/**
|
||||
* Regulatory class for own operational channel
|
||||
*/
|
||||
u8 op_reg_class;
|
||||
|
||||
/**
|
||||
* op_channel - Own operational channel
|
||||
*/
|
||||
u8 op_channel;
|
||||
|
||||
/**
|
||||
* channels - Own supported regulatory classes and channels
|
||||
*
|
||||
* List of supposerted channels per regulatory class. The regulatory
|
||||
* classes are defined in IEEE Std 802.11-2007 Annex J and the
|
||||
* numbering of the clases depends on the configured country code.
|
||||
*/
|
||||
struct p2p_channels channels;
|
||||
|
||||
enum p2p_pending_action_state pending_action_state;
|
||||
|
||||
unsigned int pending_listen_freq;
|
||||
unsigned int pending_listen_sec;
|
||||
unsigned int pending_listen_usec;
|
||||
|
||||
u8 dev_capab;
|
||||
|
||||
int in_listen;
|
||||
int drv_in_listen;
|
||||
|
||||
//add for timer.
|
||||
os_timer scan_timer;
|
||||
os_timer find_timer;
|
||||
os_timer expiration_timer;
|
||||
os_timer neg_timer;
|
||||
// os_timer invite_timer;
|
||||
os_timer watch_state_timer;
|
||||
|
||||
/**
|
||||
* invite_peer - Pointer to Invite peer
|
||||
*/
|
||||
struct p2p_device *invite_peer;
|
||||
|
||||
const u8 *invite_go_dev_addr;
|
||||
u8 invite_go_dev_addr_buf[ETH_ALEN];
|
||||
|
||||
/**
|
||||
* sd_peer - Pointer to Service Discovery peer
|
||||
*/
|
||||
struct p2p_device *sd_peer;
|
||||
|
||||
/**
|
||||
* sd_query - Pointer to Service Discovery query
|
||||
*/
|
||||
struct p2p_sd_query *sd_query;
|
||||
|
||||
/**
|
||||
* sd_queries - Pending service discovery queries
|
||||
*/
|
||||
struct p2p_sd_query *sd_queries;
|
||||
|
||||
/**
|
||||
* srv_update_indic - Service Update Indicator for local services
|
||||
*/
|
||||
u16 srv_update_indic;
|
||||
|
||||
struct wpabuf *sd_resp; /* Fragmented SD response */
|
||||
u8 sd_resp_addr[ETH_ALEN];
|
||||
u8 sd_resp_dialog_token;
|
||||
size_t sd_resp_pos; /* Offset in sd_resp */
|
||||
u8 sd_frag_id;
|
||||
|
||||
struct wpabuf *sd_rx_resp; /* Reassembled SD response */
|
||||
u16 sd_rx_update_indic;
|
||||
|
||||
/* P2P Invitation data */
|
||||
enum p2p_invite_role inv_role;
|
||||
u8 inv_bssid[ETH_ALEN];
|
||||
int inv_bssid_set;
|
||||
u8 inv_ssid[32];
|
||||
size_t inv_ssid_len;
|
||||
u8 inv_sa[ETH_ALEN];
|
||||
u8 inv_group_bssid[ETH_ALEN];
|
||||
u8 *inv_group_bssid_ptr;
|
||||
u8 inv_go_dev_addr[ETH_ALEN];
|
||||
u8 inv_status;
|
||||
int inv_op_freq;
|
||||
int inv_persistent;
|
||||
|
||||
enum p2p_discovery_type find_type;
|
||||
unsigned int last_p2p_find_timeout;
|
||||
u8 last_prog_scan_class;
|
||||
u8 last_prog_scan_chan;
|
||||
int p2p_scan_running;
|
||||
enum p2p_after_scan {
|
||||
P2P_AFTER_SCAN_NOTHING,
|
||||
P2P_AFTER_SCAN_LISTEN,
|
||||
P2P_AFTER_SCAN_CONNECT
|
||||
} start_after_scan;
|
||||
u8 after_scan_peer[ETH_ALEN];
|
||||
struct p2p_pending_action_tx *after_scan_tx;
|
||||
|
||||
/* Requested device types for find/search */
|
||||
unsigned int num_req_dev_types;
|
||||
u8 *req_dev_types;
|
||||
u8 *find_dev_id;
|
||||
u8 find_dev_id_buf[ETH_ALEN];
|
||||
|
||||
struct p2p_group **groups;
|
||||
size_t num_groups;
|
||||
|
||||
struct p2p_device *pending_client_disc_go;
|
||||
u8 pending_client_disc_addr[ETH_ALEN];
|
||||
u8 pending_dev_disc_dialog_token;
|
||||
u8 pending_dev_disc_addr[ETH_ALEN];
|
||||
int pending_dev_disc_freq;
|
||||
unsigned int pending_client_disc_freq;
|
||||
|
||||
int ext_listen_only;
|
||||
unsigned int ext_listen_period;
|
||||
unsigned int ext_listen_interval;
|
||||
unsigned int ext_listen_interval_sec;
|
||||
unsigned int ext_listen_interval_usec;
|
||||
|
||||
u8 peer_filter[ETH_ALEN];
|
||||
|
||||
int cross_connect;
|
||||
|
||||
int best_freq_24;
|
||||
int best_freq_5;
|
||||
int best_freq_overall;
|
||||
|
||||
/**
|
||||
* wps_vendor_ext - WPS Vendor Extensions to add
|
||||
*/
|
||||
struct wpabuf *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT];
|
||||
|
||||
/*
|
||||
* user_initiated_pd - Whether a PD request is user initiated or not.
|
||||
*/
|
||||
u8 user_initiated_pd;
|
||||
|
||||
/*
|
||||
* Keep track of which peer a given PD request was sent to.
|
||||
* Used to raise a timeout alert in case there is no response.
|
||||
*/
|
||||
u8 pending_pd_devaddr[ETH_ALEN];
|
||||
|
||||
/*
|
||||
* Retry counter for provision discovery requests when issued
|
||||
* in IDLE state.
|
||||
*/
|
||||
int pd_retries;
|
||||
|
||||
u8 go_timeout;
|
||||
u8 client_timeout;
|
||||
|
||||
/* Extra delay in milliseconds between search iterations */
|
||||
unsigned int search_delay;
|
||||
int in_search_delay;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct p2p_message - Parsed P2P message (or P2P IE)
|
||||
*/
|
||||
struct p2p_message {
|
||||
struct wpabuf *p2p_attributes;
|
||||
struct wpabuf *wps_attributes;
|
||||
struct wpabuf *wfd_subelems;
|
||||
|
||||
u8 dialog_token;
|
||||
|
||||
const u8 *capability;
|
||||
const u8 *go_intent;
|
||||
const u8 *status;
|
||||
const u8 *listen_channel;
|
||||
const u8 *operating_channel;
|
||||
const u8 *channel_list;
|
||||
u8 channel_list_len;
|
||||
const u8 *config_timeout;
|
||||
const u8 *intended_addr;
|
||||
const u8 *group_bssid;
|
||||
const u8 *invitation_flags;
|
||||
|
||||
const u8 *group_info;
|
||||
size_t group_info_len;
|
||||
|
||||
const u8 *group_id;
|
||||
size_t group_id_len;
|
||||
|
||||
const u8 *device_id;
|
||||
|
||||
const u8 *manageability;
|
||||
|
||||
const u8 *noa;
|
||||
size_t noa_len;
|
||||
|
||||
const u8 *ext_listen_timing;
|
||||
|
||||
const u8 *minor_reason_code;
|
||||
|
||||
/* P2P Device Info */
|
||||
const u8 *p2p_device_info;
|
||||
size_t p2p_device_info_len;
|
||||
const u8 *p2p_device_addr;
|
||||
const u8 *pri_dev_type;
|
||||
u8 num_sec_dev_types;
|
||||
char device_name[33];
|
||||
u16 config_methods;
|
||||
|
||||
/* WPS IE */
|
||||
u16 dev_password_id;
|
||||
u16 wps_config_methods;
|
||||
const u8 *wps_pri_dev_type;
|
||||
const u8 *wps_sec_dev_type_list;
|
||||
size_t wps_sec_dev_type_list_len;
|
||||
const u8 *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT];
|
||||
size_t wps_vendor_ext_len[P2P_MAX_WPS_VENDOR_EXT];
|
||||
const u8 *manufacturer;
|
||||
size_t manufacturer_len;
|
||||
const u8 *model_name;
|
||||
size_t model_name_len;
|
||||
const u8 *model_number;
|
||||
size_t model_number_len;
|
||||
const u8 *serial_number;
|
||||
size_t serial_number_len;
|
||||
|
||||
/* DS Parameter Set IE */
|
||||
const u8 *ds_params;
|
||||
|
||||
/* SSID IE */
|
||||
const u8 *ssid;
|
||||
};
|
||||
|
||||
struct p2p_context
|
||||
{
|
||||
u32 role;
|
||||
u32 state;
|
||||
struct p2p_data *p2p;
|
||||
char p2p_pin[10];
|
||||
//TODO auto GO
|
||||
//struct p2p_go_neg_results *go_params;
|
||||
os_timer group_formation_timer;
|
||||
os_timer long_listen_timer;
|
||||
os_timer group_idle_timer;
|
||||
struct p2p_group *group;
|
||||
u8 oper_chnl;
|
||||
char group_ssid[33];
|
||||
u8 go_dev_addr[ETH_ALEN];
|
||||
char passphrase[64];
|
||||
u8 persistent;
|
||||
u8 p2p_long_listen;
|
||||
u8 p2p_pd_before_go_neg;
|
||||
/**
|
||||
* p2p_group_idle - Maximum idle time in seconds for P2P group
|
||||
*
|
||||
* This value controls how long a P2P group is maintained after there
|
||||
* is no other members in the group. As a GO, this means no associated
|
||||
* stations in the group. As a P2P client, this means no GO seen in
|
||||
* scan results. The maximum idle time is specified in seconds with 0
|
||||
* indicating no time limit, i.e., the P2P group remains in active
|
||||
* state indefinitely until explicitly removed. As a P2P client, the
|
||||
* maximum idle time of P2P_MAX_CLIENT_IDLE seconds is enforced, i.e.,
|
||||
* this parameter is mainly meant for GO use and for P2P client, it can
|
||||
* only be used to reduce the default timeout to smaller value. A
|
||||
* special value -1 can be used to configure immediate removal of the
|
||||
* group for P2P client role on any disconnection after the data
|
||||
* connection has been established.
|
||||
*/
|
||||
int p2p_group_idle;
|
||||
int persistent_reconnect;
|
||||
int max_num_sta;
|
||||
|
||||
u8 pending_action_tx;
|
||||
u8 pending_action_src[ETH_ALEN];
|
||||
u8 pending_action_dst[ETH_ALEN];
|
||||
u8 pending_action_bssid[ETH_ALEN];
|
||||
unsigned int pending_action_freq;
|
||||
};
|
||||
|
||||
#define P2P_MAX_GROUP_ENTRIES 50
|
||||
|
||||
struct p2p_group_info {
|
||||
unsigned int num_clients;
|
||||
struct p2p_client_info {
|
||||
const u8 *p2p_device_addr;
|
||||
const u8 *p2p_interface_addr;
|
||||
u8 dev_capab;
|
||||
u16 config_methods;
|
||||
const u8 *pri_dev_type;
|
||||
u8 num_sec_dev_types;
|
||||
const u8 *sec_dev_types;
|
||||
const char *dev_name;
|
||||
size_t dev_name_len;
|
||||
} client[P2P_MAX_GROUP_ENTRIES];
|
||||
};
|
||||
|
||||
|
||||
/* p2p_utils.c */
|
||||
int p2p_random(char *buf, size_t len);
|
||||
int p2p_channel_to_freq(const char *country, int reg_class, int channel);
|
||||
int p2p_freq_to_channel(const char *country, unsigned int freq, u8 *reg_class,
|
||||
u8 *channel);
|
||||
void p2p_channels_intersect(const struct p2p_channels *a,
|
||||
const struct p2p_channels *b,
|
||||
struct p2p_channels *res);
|
||||
int p2p_channels_includes(const struct p2p_channels *channels, u8 reg_class,
|
||||
u8 channel);
|
||||
|
||||
/* p2p_parse.c */
|
||||
int p2p_parse_p2p_ie(const struct wpabuf *buf, struct p2p_message *msg);
|
||||
int p2p_parse_ies(const u8 *data, size_t len, struct p2p_message *msg);
|
||||
int p2p_parse(const u8 *data, size_t len, struct p2p_message *msg);
|
||||
void p2p_parse_free(struct p2p_message *msg);
|
||||
int p2p_attr_text(struct wpabuf *data, char *buf, char *end);
|
||||
int p2p_group_info_parse(const u8 *gi, size_t gi_len,
|
||||
struct p2p_group_info *info);
|
||||
|
||||
/* p2p_build.c */
|
||||
|
||||
struct p2p_noa_desc {
|
||||
u8 count_type;
|
||||
u32 duration;
|
||||
u32 interval;
|
||||
u32 start_time;
|
||||
};
|
||||
|
||||
/* p2p_group.c */
|
||||
const u8 * p2p_group_get_interface_addr(struct p2p_group *group);
|
||||
u8 p2p_group_presence_req(struct p2p_group *group,
|
||||
const u8 *client_interface_addr,
|
||||
const u8 *noa, size_t noa_len);
|
||||
int p2p_group_is_group_id_match(struct p2p_group *group, const u8 *group_id,
|
||||
size_t group_id_len);
|
||||
void p2p_group_update_ies(struct p2p_group *group);
|
||||
struct wpabuf * p2p_group_get_wfd_ie(struct p2p_group *g);
|
||||
|
||||
|
||||
void p2p_buf_add_action_hdr(struct wpabuf *buf, u8 subtype, u8 dialog_token);
|
||||
void p2p_buf_add_public_action_hdr(struct wpabuf *buf, u8 subtype,
|
||||
u8 dialog_token);
|
||||
u8 * p2p_buf_add_ie_hdr(struct wpabuf *buf);
|
||||
void p2p_buf_add_status(struct wpabuf *buf, u8 status);
|
||||
void p2p_buf_add_device_info(struct wpabuf *buf, struct p2p_data *p2p,
|
||||
struct p2p_device *peer);
|
||||
void p2p_buf_add_device_id(struct wpabuf *buf, const u8 *dev_addr);
|
||||
void p2p_buf_update_ie_hdr(struct wpabuf *buf, u8 *len);
|
||||
void p2p_buf_add_capability(struct wpabuf *buf, u8 dev_capab, u8 group_capab);
|
||||
void p2p_buf_add_go_intent(struct wpabuf *buf, u8 go_intent);
|
||||
void p2p_buf_add_listen_channel(struct wpabuf *buf, const char *country,
|
||||
u8 reg_class, u8 channel);
|
||||
void p2p_buf_add_operating_channel(struct wpabuf *buf, const char *country,
|
||||
u8 reg_class, u8 channel);
|
||||
void p2p_buf_add_channel_list(struct wpabuf *buf, const char *country,
|
||||
struct p2p_channels *chan);
|
||||
void p2p_buf_add_config_timeout(struct wpabuf *buf, u8 go_timeout,
|
||||
u8 client_timeout);
|
||||
void p2p_buf_add_intended_addr(struct wpabuf *buf, const u8 *interface_addr);
|
||||
void p2p_buf_add_group_bssid(struct wpabuf *buf, const u8 *bssid);
|
||||
void p2p_buf_add_group_id(struct wpabuf *buf, const u8 *dev_addr,
|
||||
const u8 *ssid, size_t ssid_len);
|
||||
void p2p_buf_add_invitation_flags(struct wpabuf *buf, u8 flags);
|
||||
void p2p_buf_add_noa(struct wpabuf *buf, u8 noa_index, u8 opp_ps, u8 ctwindow,
|
||||
struct p2p_noa_desc *desc1, struct p2p_noa_desc *desc2);
|
||||
void p2p_buf_add_ext_listen_timing(struct wpabuf *buf, u16 period,
|
||||
u16 interval);
|
||||
void p2p_buf_add_p2p_interface(struct wpabuf *buf, struct p2p_data *p2p);
|
||||
void p2p_build_wps_ie(struct p2p_data *p2p, struct wpabuf *buf, int pw_id,
|
||||
int all_attr);
|
||||
|
||||
/* p2p_sd.c */
|
||||
struct p2p_sd_query * p2p_pending_sd_req(struct p2p_data *p2p,
|
||||
struct p2p_device *dev);
|
||||
void p2p_free_sd_queries(struct p2p_data *p2p);
|
||||
void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
|
||||
const u8 *data, size_t len, int rx_freq);
|
||||
void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
|
||||
const u8 *data, size_t len, int rx_freq);
|
||||
void p2p_rx_gas_comeback_req(struct p2p_data *p2p, const u8 *sa,
|
||||
const u8 *data, size_t len, int rx_freq);
|
||||
void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
|
||||
const u8 *data, size_t len, int rx_freq);
|
||||
int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev);
|
||||
|
||||
/* p2p_go_neg.c */
|
||||
int p2p_peer_channels_check(struct p2p_data *p2p, struct p2p_channels *own,
|
||||
struct p2p_device *dev,
|
||||
const u8 *channel_list, size_t channel_list_len);
|
||||
void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
|
||||
const u8 *data, size_t len, int rx_freq);
|
||||
void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
|
||||
const u8 *data, size_t len, int rx_freq);
|
||||
void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
|
||||
const u8 *data, size_t len);
|
||||
int p2p_connect_send(struct p2p_data *p2p, struct p2p_device *dev);
|
||||
u16 p2p_wps_method_pw_id(enum p2p_wps_method wps_method);
|
||||
void p2p_reselect_channel(struct p2p_data *p2p,
|
||||
struct p2p_channels *intersection);
|
||||
|
||||
/* p2p_pd.c */
|
||||
void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa,
|
||||
const u8 *data, size_t len, int rx_freq);
|
||||
void p2p_process_prov_disc_resp(struct p2p_data *p2p, const u8 *sa,
|
||||
const u8 *data, size_t len);
|
||||
int p2p_send_prov_disc_req(struct p2p_data *p2p, struct p2p_device *dev,
|
||||
int join, int force_freq);
|
||||
void p2p_reset_pending_pd(struct p2p_data *p2p);
|
||||
|
||||
/* p2p_invitation.c */
|
||||
void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
|
||||
const u8 *data, size_t len, int rx_freq);
|
||||
void p2p_process_invitation_resp(struct p2p_data *p2p, const u8 *sa,
|
||||
const u8 *data, size_t len);
|
||||
int p2p_invite_send(struct p2p_data *p2p, struct p2p_device *dev,
|
||||
const u8 *go_dev_addr);
|
||||
void p2p_invitation_req_cb(struct p2p_data *p2p, int success);
|
||||
void p2p_invitation_resp_cb(struct p2p_data *p2p, int success);
|
||||
|
||||
/* p2p_dev_disc.c */
|
||||
void p2p_process_dev_disc_req(struct p2p_data *p2p, const u8 *sa,
|
||||
const u8 *data, size_t len, int rx_freq);
|
||||
void p2p_dev_disc_req_cb(struct p2p_data *p2p, int success);
|
||||
int p2p_send_dev_disc_req(struct p2p_data *p2p, struct p2p_device *dev);
|
||||
void p2p_dev_disc_resp_cb(struct p2p_data *p2p, int success);
|
||||
void p2p_process_dev_disc_resp(struct p2p_data *p2p, const u8 *sa,
|
||||
const u8 *data, size_t len);
|
||||
void p2p_go_disc_req_cb(struct p2p_data *p2p, int success);
|
||||
void p2p_process_go_disc_req(struct p2p_data *p2p, const u8 *da, const u8 *sa,
|
||||
const u8 *data, size_t len, int rx_freq);
|
||||
|
||||
/* p2p.c */
|
||||
void p2p_set_state(struct p2p_data *p2p, int new_state);
|
||||
void p2p_set_timeout(struct p2p_data *p2p, unsigned int sec,
|
||||
unsigned int usec);
|
||||
void p2p_clear_timeout(struct p2p_data *p2p);
|
||||
void p2p_continue_find(struct p2p_data *p2p);
|
||||
struct p2p_device * p2p_add_dev_from_go_neg_req(struct p2p_data *p2p,
|
||||
const u8 *addr,
|
||||
struct p2p_message *msg);
|
||||
void p2p_add_dev_info(struct p2p_data *p2p, const u8 *addr,
|
||||
struct p2p_device *dev, struct p2p_message *msg);
|
||||
int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq,
|
||||
unsigned int age_ms, int level, const u8 *ies,
|
||||
size_t ies_len, int scan_res);
|
||||
struct p2p_device * p2p_get_device(struct p2p_data *p2p, const u8 *addr);
|
||||
struct p2p_device * p2p_get_device_interface(struct p2p_data *p2p,
|
||||
const u8 *addr);
|
||||
void p2p_go_neg_failed(struct p2p_data *p2p, struct p2p_device *peer,
|
||||
int status);
|
||||
void p2p_go_complete(struct p2p_data *p2p, struct p2p_device *peer);
|
||||
int p2p_match_dev_type(struct p2p_data *p2p, struct wpabuf *wps);
|
||||
int dev_type_list_match(const u8 *dev_type, const u8 *req_dev_type[],
|
||||
size_t num_req_dev_type);
|
||||
struct wpabuf * p2p_build_probe_resp_ies(struct p2p_data *p2p);
|
||||
void p2p_build_ssid(struct p2p_data *p2p, u8 *ssid, size_t *ssid_len);
|
||||
int p2p_send_action(struct p2p_data *p2p, unsigned int freq, const u8 *dst,
|
||||
const u8 *src, const u8 *bssid, const u8 *buf,
|
||||
size_t len, unsigned int wait_time);
|
||||
void p2p_stop_listen_for_freq(struct p2p_data *p2p, int freq);
|
||||
|
||||
#endif /* P2P_I_H */
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Big number math
|
||||
* 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 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);
|
||||
#if 0
|
||||
int bignum_mulmod(const struct bignum *a, const struct bignum *b,
|
||||
const struct bignum *c, struct bignum *d);
|
||||
#endif
|
||||
int bignum_exptmod(const struct bignum *a, const struct bignum *b,
|
||||
const struct bignum *c, struct bignum *d);
|
||||
#endif /* BIGNUM_H */
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* wpa_supplicant/hostapd - Build time configuration defines
|
||||
* Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*
|
||||
* This header file can be used to define configuration defines that were
|
||||
* originally defined in Makefile. This is mainly meant for IDE use or for
|
||||
* systems that do not have suitable 'make' tool. In these cases, it may be
|
||||
* easier to have a single place for defining all the needed C pre-processor
|
||||
* defines.
|
||||
*/
|
||||
|
||||
#ifndef BUILD_CONFIG_H
|
||||
#define BUILD_CONFIG_H
|
||||
|
||||
/* Insert configuration defines, e.g., #define EAP_MD5, here, if needed. */
|
||||
|
||||
#ifdef CONFIG_WIN32_DEFAULTS
|
||||
#define CONFIG_NATIVE_WINDOWS
|
||||
#define CONFIG_ANSI_C_EXTRA
|
||||
#define CONFIG_WINPCAP
|
||||
#define IEEE8021X_EAPOL
|
||||
#define PKCS12_FUNCS
|
||||
#define PCSC_FUNCS
|
||||
#define CONFIG_CTRL_IFACE
|
||||
#define CONFIG_CTRL_IFACE_NAMED_PIPE
|
||||
#define CONFIG_DRIVER_NDIS
|
||||
#define CONFIG_NDIS_EVENTS_INTEGRATED
|
||||
#define CONFIG_DEBUG_FILE
|
||||
#define EAP_MD5
|
||||
#define EAP_TLS
|
||||
#define EAP_MSCHAPv2
|
||||
#define EAP_PEAP
|
||||
#define EAP_TTLS
|
||||
#define EAP_GTC
|
||||
#define EAP_OTP
|
||||
#define EAP_LEAP
|
||||
#define EAP_TNC
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
|
||||
#ifdef USE_INTERNAL_CRYPTO
|
||||
#define CONFIG_TLS_INTERNAL_CLIENT
|
||||
#define CONFIG_INTERNAL_LIBTOMMATH
|
||||
#define CONFIG_CRYPTO_INTERNAL
|
||||
#endif /* USE_INTERNAL_CRYPTO */
|
||||
#endif /* CONFIG_WIN32_DEFAULTS */
|
||||
|
||||
#ifdef CONFIG_XCODE_DEFAULTS
|
||||
#define CONFIG_DRIVER_OSX
|
||||
#define CONFIG_BACKEND_FILE
|
||||
#define IEEE8021X_EAPOL
|
||||
#define PKCS12_FUNCS
|
||||
#define CONFIG_CTRL_IFACE
|
||||
#define CONFIG_CTRL_IFACE_UNIX
|
||||
#define CONFIG_DEBUG_FILE
|
||||
#define EAP_MD5
|
||||
#define EAP_TLS
|
||||
#define EAP_MSCHAPv2
|
||||
#define EAP_PEAP
|
||||
#define EAP_TTLS
|
||||
#define EAP_GTC
|
||||
#define EAP_OTP
|
||||
#define EAP_LEAP
|
||||
#define EAP_TNC
|
||||
#define CONFIG_WPS
|
||||
#define EAP_WSC
|
||||
|
||||
#ifdef USE_INTERNAL_CRYPTO
|
||||
#define CONFIG_TLS_INTERNAL_CLIENT
|
||||
#define CONFIG_INTERNAL_LIBTOMMATH
|
||||
#define CONFIG_CRYPTO_INTERNAL
|
||||
#endif /* USE_INTERNAL_CRYPTO */
|
||||
#endif /* CONFIG_XCODE_DEFAULTS */
|
||||
|
||||
#endif /* BUILD_CONFIG_H */
|
||||
|
|
@ -0,0 +1,548 @@
|
|||
/*
|
||||
* wpa_supplicant/hostapd / common helper functions, etc.
|
||||
* Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#include "utils/os.h"
|
||||
#define TO_TEST_WPS 0
|
||||
#define ETH_ALEN 6
|
||||
|
||||
#if defined(__linux__) || defined(__GLIBC__)
|
||||
#include <endian.h>
|
||||
#include <byteswap.h>
|
||||
#endif /* __linux__ */
|
||||
|
||||
#if defined(PLATFORM_FREERTOS)
|
||||
//#include "little_endian.h"
|
||||
//#include "basic_types.h"
|
||||
#endif /* PLATFORM_FREERTOS */
|
||||
|
||||
|
||||
#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 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 */
|
||||
|
||||
#ifndef WPA_TYPES_DEFINED
|
||||
#ifdef CONFIG_USE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
//#include <stdint.h>
|
||||
#endif
|
||||
#if 0
|
||||
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;
|
||||
#endif
|
||||
#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
|
||||
#if 0
|
||||
#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 */
|
||||
#else
|
||||
#ifndef __LITTLE_ENDIAN
|
||||
#define __LITTLE_ENDIAN 1234
|
||||
#endif
|
||||
#ifndef __BIG_ENDIAN
|
||||
#define __BIG_ENDIAN 4321
|
||||
#endif
|
||||
#ifndef __BYTE_ORDER
|
||||
#define __BYTE_ORDER __LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#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_80211_ENCAP
|
||||
#define ETH_P_80211_ENCAP 0x890d /* TDLS comes under this category */
|
||||
#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 */
|
||||
|
||||
|
||||
#if 0 //#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"
|
||||
|
||||
/*
|
||||
* Compact form for string representation of MAC address
|
||||
* To be used, e.g., for constructing dbus paths for P2P Devices
|
||||
*/
|
||||
#define COMPACT_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_compact_aton(const char *txt, u8 *addr);
|
||||
int hwaddr_aton2(const char *txt, u8 *addr);
|
||||
int hex2byte(const char *hex);
|
||||
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 */
|
||||
|
||||
void printf_encode(char *txt, size_t maxlen, const u8 *data, size_t len);
|
||||
size_t printf_decode(u8 *buf, size_t maxlen, const char *str);
|
||||
|
||||
const char * wpa_ssid_txt(const u8 *ssid, size_t ssid_len);
|
||||
|
||||
char * wpa_config_parse_string(const char *value, size_t *len);
|
||||
int is_hex(const u8 *data, size_t len);
|
||||
size_t merge_byte_arrays(u8 *res, size_t res_len,
|
||||
const u8 *src1, size_t src1_len,
|
||||
const u8 *src2, size_t src2_len);
|
||||
|
||||
static inline int is_zero_ether_addr(const u8 *a)
|
||||
{
|
||||
return !(a[0] | a[1] | a[2] | a[3] | a[4] | a[5]);
|
||||
}
|
||||
|
||||
static inline int is_broadcast_ether_addr(const u8 *a)
|
||||
{
|
||||
return (a[0] & a[1] & a[2] & a[3] & a[4] & a[5]) == 0xff;
|
||||
}
|
||||
|
||||
#define broadcast_ether_addr (const u8 *) "\xff\xff\xff\xff\xff\xff"
|
||||
|
||||
#include "wpa_debug.h"
|
||||
|
||||
|
||||
char * dup_binstr(const void *src, size_t len);
|
||||
struct wpa_freq_range_list {
|
||||
struct wpa_freq_range {
|
||||
unsigned int min;
|
||||
unsigned int max;
|
||||
} *range;
|
||||
unsigned int num;
|
||||
};
|
||||
|
||||
int freq_range_list_parse(struct wpa_freq_range_list *res, const char *value);
|
||||
int freq_range_list_includes(const struct wpa_freq_range_list *list,
|
||||
unsigned int freq);
|
||||
char * freq_range_list_str(const struct wpa_freq_range_list *list);
|
||||
|
||||
int int_array_len(const int *a);
|
||||
void int_array_concat(int **res, const int *a);
|
||||
void int_array_sort_unique(int *a);
|
||||
void int_array_add_unique(int **res, int a);
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
|
||||
void str_clear_free(char *str);
|
||||
void bin_clear_free(void *bin, size_t len);
|
||||
|
||||
int random_mac_addr(u8 *addr);
|
||||
int random_mac_addr_keep_oui(u8 *addr);
|
||||
|
||||
const char * cstr_token(const char *str, const char *delim, const char **last);
|
||||
char * str_token(char *str, const char *delim, char **context);
|
||||
size_t utf8_escape(const char *inp, size_t in_size,
|
||||
char *outp, size_t out_size);
|
||||
size_t utf8_unescape(const char *inp, size_t in_size,
|
||||
char *outp, size_t out_size);
|
||||
int is_ctrl_char(char c);
|
||||
|
||||
#ifndef bswap_16
|
||||
#define bswap_16(a) ((((u16) (a) << 8) & 0xff00) | (((u16) (a) >> 8) & 0xff))
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* 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))
|
||||
|
||||
#ifdef CONFIG_VALGRIND
|
||||
#include <valgrind/memcheck.h>
|
||||
#define WPA_MEM_DEFINED(ptr, len) VALGRIND_MAKE_MEM_DEFINED((ptr), (len))
|
||||
#else /* CONFIG_VALGRIND */
|
||||
#define WPA_MEM_DEFINED(ptr, len) do { } while (0)
|
||||
#endif /* CONFIG_VALGRIND */
|
||||
|
||||
#endif /* COMMON_H */
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
#ifndef INCLUDES_H
|
||||
#define INCLUDES_H
|
||||
|
||||
#define CONFIG_NO_STDOUT_DEBUG
|
||||
|
||||
#ifndef CONFIG_NO_STDOUT_DEBUG
|
||||
|
||||
/* Event messages with fixed prefix */
|
||||
/** Authentication completed successfully and data connection enabled */
|
||||
#define WPA_EVENT_CONNECTED "CTRL-EVENT-CONNECTED "
|
||||
/** Disconnected, data connection is not available */
|
||||
#define WPA_EVENT_DISCONNECTED "CTRL-EVENT-DISCONNECTED "
|
||||
/** Association rejected during connection attempt */
|
||||
#define WPA_EVENT_ASSOC_REJECT "CTRL-EVENT-ASSOC-REJECT "
|
||||
/** Authentication rejected during connection attempt */
|
||||
#define WPA_EVENT_AUTH_REJECT "CTRL-EVENT-AUTH-REJECT "
|
||||
/** wpa_supplicant is exiting */
|
||||
#define WPA_EVENT_TERMINATING "CTRL-EVENT-TERMINATING "
|
||||
/** Password change was completed successfully */
|
||||
#define WPA_EVENT_PASSWORD_CHANGED "CTRL-EVENT-PASSWORD-CHANGED "
|
||||
/** EAP-Request/Notification received */
|
||||
#define WPA_EVENT_EAP_NOTIFICATION "CTRL-EVENT-EAP-NOTIFICATION "
|
||||
/** EAP authentication started (EAP-Request/Identity received) */
|
||||
#define WPA_EVENT_EAP_STARTED "CTRL-EVENT-EAP-STARTED "
|
||||
/** EAP method proposed by the server */
|
||||
#define WPA_EVENT_EAP_PROPOSED_METHOD "CTRL-EVENT-EAP-PROPOSED-METHOD "
|
||||
/** EAP method selected */
|
||||
#define WPA_EVENT_EAP_METHOD "CTRL-EVENT-EAP-METHOD "
|
||||
/** EAP peer certificate from TLS */
|
||||
#define WPA_EVENT_EAP_PEER_CERT "CTRL-EVENT-EAP-PEER-CERT "
|
||||
/** EAP peer certificate alternative subject name component from TLS */
|
||||
#define WPA_EVENT_EAP_PEER_ALT "CTRL-EVENT-EAP-PEER-ALT "
|
||||
/** EAP TLS certificate chain validation error */
|
||||
#define WPA_EVENT_EAP_TLS_CERT_ERROR "CTRL-EVENT-EAP-TLS-CERT-ERROR "
|
||||
/** EAP status */
|
||||
#define WPA_EVENT_EAP_STATUS "CTRL-EVENT-EAP-STATUS "
|
||||
/** EAP authentication completed successfully */
|
||||
#define WPA_EVENT_EAP_SUCCESS "CTRL-EVENT-EAP-SUCCESS "
|
||||
/** EAP authentication failed (EAP-Failure received) */
|
||||
#define WPA_EVENT_EAP_FAILURE "CTRL-EVENT-EAP-FAILURE "
|
||||
/** Network block temporarily disabled (e.g., due to authentication failure) */
|
||||
#define WPA_EVENT_TEMP_DISABLED "CTRL-EVENT-SSID-TEMP-DISABLED "
|
||||
/** Temporarily disabled network block re-enabled */
|
||||
#define WPA_EVENT_REENABLED "CTRL-EVENT-SSID-REENABLED "
|
||||
/** New scan started */
|
||||
#define WPA_EVENT_SCAN_STARTED "CTRL-EVENT-SCAN-STARTED "
|
||||
/** New scan results available */
|
||||
#define WPA_EVENT_SCAN_RESULTS "CTRL-EVENT-SCAN-RESULTS "
|
||||
/** Scan command failed */
|
||||
#define WPA_EVENT_SCAN_FAILED "CTRL-EVENT-SCAN-FAILED "
|
||||
/** wpa_supplicant state change */
|
||||
#define WPA_EVENT_STATE_CHANGE "CTRL-EVENT-STATE-CHANGE "
|
||||
/** A new BSS entry was added (followed by BSS entry id and BSSID) */
|
||||
#define WPA_EVENT_BSS_ADDED "CTRL-EVENT-BSS-ADDED "
|
||||
/** A BSS entry was removed (followed by BSS entry id and BSSID) */
|
||||
#define WPA_EVENT_BSS_REMOVED "CTRL-EVENT-BSS-REMOVED "
|
||||
/** No suitable network was found */
|
||||
#define WPA_EVENT_NETWORK_NOT_FOUND "CTRL-EVENT-NETWORK-NOT-FOUND "
|
||||
/** Change in the signal level was reported by the driver */
|
||||
#define WPA_EVENT_SIGNAL_CHANGE "CTRL-EVENT-SIGNAL-CHANGE "
|
||||
/** Regulatory domain channel */
|
||||
#define WPA_EVENT_REGDOM_CHANGE "CTRL-EVENT-REGDOM-CHANGE "
|
||||
|
||||
/** RSN IBSS 4-way handshakes completed with specified peer */
|
||||
#define IBSS_RSN_COMPLETED "IBSS-RSN-COMPLETED "
|
||||
|
||||
/** Notification of frequency conflict due to a concurrent operation.
|
||||
*
|
||||
* The indicated network is disabled and needs to be re-enabled before it can
|
||||
* be used again.
|
||||
*/
|
||||
#define WPA_EVENT_FREQ_CONFLICT "CTRL-EVENT-FREQ-CONFLICT "
|
||||
/** Frequency ranges that the driver recommends to avoid */
|
||||
#define WPA_EVENT_AVOID_FREQ "CTRL-EVENT-AVOID-FREQ "
|
||||
/** WPS overlap detected in PBC mode */
|
||||
#define WPS_EVENT_OVERLAP "WPS-OVERLAP-DETECTED "
|
||||
/** Available WPS AP with active PBC found in scan results */
|
||||
#define WPS_EVENT_AP_AVAILABLE_PBC "WPS-AP-AVAILABLE-PBC "
|
||||
/** Available WPS AP with our address as authorized in scan results */
|
||||
#define WPS_EVENT_AP_AVAILABLE_AUTH "WPS-AP-AVAILABLE-AUTH "
|
||||
/** Available WPS AP with recently selected PIN registrar found in scan results
|
||||
*/
|
||||
#define WPS_EVENT_AP_AVAILABLE_PIN "WPS-AP-AVAILABLE-PIN "
|
||||
/** Available WPS AP found in scan results */
|
||||
#define WPS_EVENT_AP_AVAILABLE "WPS-AP-AVAILABLE "
|
||||
/** A new credential received */
|
||||
#define WPS_EVENT_CRED_RECEIVED "WPS-CRED-RECEIVED "
|
||||
/** M2D received */
|
||||
#define WPS_EVENT_M2D "WPS-M2D "
|
||||
/** WPS registration failed after M2/M2D */
|
||||
#define WPS_EVENT_FAIL "WPS-FAIL "
|
||||
/** WPS registration completed successfully */
|
||||
#define WPS_EVENT_SUCCESS "WPS-SUCCESS "
|
||||
/** WPS enrollment attempt timed out and was terminated */
|
||||
#define WPS_EVENT_TIMEOUT "WPS-TIMEOUT "
|
||||
/* PBC mode was activated */
|
||||
#define WPS_EVENT_ACTIVE "WPS-PBC-ACTIVE "
|
||||
/* PBC mode was disabled */
|
||||
#define WPS_EVENT_DISABLE "WPS-PBC-DISABLE "
|
||||
|
||||
#define WPS_EVENT_ENROLLEE_SEEN "WPS-ENROLLEE-SEEN "
|
||||
|
||||
#define WPS_EVENT_OPEN_NETWORK "WPS-OPEN-NETWORK "
|
||||
|
||||
/* WPS ER events */
|
||||
#define WPS_EVENT_ER_AP_ADD "WPS-ER-AP-ADD "
|
||||
#define WPS_EVENT_ER_AP_REMOVE "WPS-ER-AP-REMOVE "
|
||||
#define WPS_EVENT_ER_ENROLLEE_ADD "WPS-ER-ENROLLEE-ADD "
|
||||
#define WPS_EVENT_ER_ENROLLEE_REMOVE "WPS-ER-ENROLLEE-REMOVE "
|
||||
#define WPS_EVENT_ER_AP_SETTINGS "WPS-ER-AP-SETTINGS "
|
||||
#define WPS_EVENT_ER_SET_SEL_REG "WPS-ER-AP-SET-SEL-REG "
|
||||
|
||||
#endif /* CONFIG_NO_STDOUT_DEBUG */
|
||||
|
||||
//#define DBG_871X(...) vTaskDelay(100)
|
||||
//DBG_871X_LEVEL(_drv_always_, "no beacon for a long time, disconnect or roaming\n");
|
||||
//#define DBG_871X(...) DBG_871X_LEVEL(_drv_always_,...)
|
||||
|
||||
#endif /* INCLUDES_H */
|
||||
603
sdk/component/common/api/wifi/rtw_wpa_supplicant/src/utils/os.h
Normal file
603
sdk/component/common/api/wifi/rtw_wpa_supplicant/src/utils/os.h
Normal file
|
|
@ -0,0 +1,603 @@
|
|||
/*
|
||||
* OS specific functions
|
||||
* Copyright (c) 2005-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef OS_H
|
||||
#define OS_H
|
||||
|
||||
//#include "basic_types.h"
|
||||
#include <autoconf.h>
|
||||
#include "osdep_service.h"
|
||||
#if defined(PLATFORM_ALIOS)
|
||||
#include "alios/wrapper.h"
|
||||
#else
|
||||
#include "freertos/wrapper.h"
|
||||
#endif
|
||||
#include "utils/rom/rom_wps_os.h"
|
||||
|
||||
|
||||
typedef void* xqueue_handle_t;
|
||||
|
||||
typedef long os_time_t;
|
||||
|
||||
typedef _timer os_timer;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
};
|
||||
|
||||
struct os_reltime {
|
||||
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);
|
||||
|
||||
int os_get_reltime(struct os_reltime *t);
|
||||
/* Helper macros for handling struct os_time */
|
||||
/* (&timeout->time, &tmp->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);
|
||||
|
||||
struct os_tm {
|
||||
int sec; /* 0..59 or 60 for leap seconds */
|
||||
int min; /* 0..59 */
|
||||
int hour; /* 0..23 */
|
||||
int day; /* 1..31 */
|
||||
int month; /* 1..12 */
|
||||
int year; /* Four digit year */
|
||||
};
|
||||
|
||||
int os_gmtime(os_time_t t, struct os_tm *tm);
|
||||
|
||||
/* Helpers for handling struct os_time */
|
||||
|
||||
/* Helpers for handling struct os_reltime */
|
||||
|
||||
static inline int os_reltime_before(struct os_reltime *a,
|
||||
struct os_reltime *b)
|
||||
{
|
||||
return os_time_before(a,b);
|
||||
}
|
||||
|
||||
|
||||
static inline void os_reltime_sub(struct os_reltime *a, struct os_reltime *b,
|
||||
struct os_reltime *res)
|
||||
{
|
||||
os_time_sub(a,b,res);
|
||||
}
|
||||
|
||||
|
||||
static inline void os_reltime_age(struct os_reltime *start,
|
||||
struct os_reltime *age)
|
||||
{
|
||||
struct os_reltime now;
|
||||
|
||||
os_get_time((struct os_time *)&now);
|
||||
os_reltime_sub(&now, start, age);
|
||||
}
|
||||
|
||||
|
||||
static inline int os_reltime_expired(struct os_reltime *now,
|
||||
struct os_reltime *ts,
|
||||
os_time_t timeout_secs)
|
||||
{
|
||||
struct os_reltime age;
|
||||
|
||||
os_reltime_sub(now, ts, &age);
|
||||
return (age.sec > timeout_secs) ||
|
||||
(age.sec == timeout_secs && age.usec > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
//#if 0
|
||||
/**
|
||||
* os_zalloc - Allocate and zero memory
|
||||
* @size: Number of bytes to allocate
|
||||
* Returns: Pointer to allocated and zeroed memory or %NULL on failure
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
void * os_zalloc(size_t size);
|
||||
|
||||
/**
|
||||
* os_calloc - Allocate and zero memory for an array
|
||||
* @nmemb: Number of members in the array
|
||||
* @size: Number of bytes in each member
|
||||
* Returns: Pointer to allocated and zeroed memory or %NULL on failure
|
||||
*
|
||||
* This function can be used as a wrapper for os_zalloc(nmemb * size) when an
|
||||
* allocation is used for an array. The main benefit over os_zalloc() is in
|
||||
* having an extra check to catch integer overflows in multiplication.
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
static inline void * os_calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
if (size && nmemb > (~(size_t) 0) / size)
|
||||
return NULL;
|
||||
return os_zalloc(nmemb * size);
|
||||
}
|
||||
//#endif
|
||||
|
||||
|
||||
static inline int os_memcmp_const(const void *a, const void *b, size_t len)
|
||||
{
|
||||
const u8 *aa = a;
|
||||
const u8 *bb = b;
|
||||
size_t i;
|
||||
u8 res;
|
||||
|
||||
for (res = 0, i = 0; i < len; i++)
|
||||
res |= aa[i] ^ bb[i];
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef OS_NO_C_LIB_DEFINES
|
||||
|
||||
/**
|
||||
* os_malloc - Allocate dynamic memory
|
||||
* @size: Size of the buffer to allocate
|
||||
* Returns: Allocated buffer or %NULL on failure
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
void * os_malloc(size_t size);
|
||||
|
||||
/**
|
||||
* os_realloc - Re-allocate dynamic memory
|
||||
* @ptr: Old buffer from os_malloc() or os_realloc()
|
||||
* @size: Size of the new buffer
|
||||
* Returns: Allocated buffer or %NULL on failure
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
* If re-allocation fails, %NULL is returned and the original buffer (ptr) is
|
||||
* not freed and caller is still responsible for freeing it.
|
||||
*/
|
||||
void * os_realloc(void *ptr, size_t size);
|
||||
|
||||
/**
|
||||
* os_free - Free dynamic memory
|
||||
* @ptr: Old buffer from os_malloc() or os_realloc(); can be %NULL
|
||||
*/
|
||||
void os_free(void *ptr);
|
||||
|
||||
/**
|
||||
* os_memcpy - Copy memory area
|
||||
* @dest: Destination
|
||||
* @src: Source
|
||||
* @n: Number of bytes to copy
|
||||
* Returns: dest
|
||||
*
|
||||
* The memory areas src and dst must not overlap. os_memmove() can be used with
|
||||
* overlapping memory.
|
||||
*/
|
||||
void * os_memcpy(void *dest, const void *src, size_t n);
|
||||
|
||||
/**
|
||||
* os_memmove - Copy memory area
|
||||
* @dest: Destination
|
||||
* @src: Source
|
||||
* @n: Number of bytes to copy
|
||||
* Returns: dest
|
||||
*
|
||||
* The memory areas src and dst may overlap.
|
||||
*/
|
||||
void *os_memmove(void *dest, const void *src, size_t n);
|
||||
|
||||
/**
|
||||
* os_memset - Fill memory with a constant byte
|
||||
* @s: Memory area to be filled
|
||||
* @c: Constant byte
|
||||
* @n: Number of bytes started from s to fill with c
|
||||
* Returns: s
|
||||
*/
|
||||
void *os_memset(void *s, int c, size_t n);
|
||||
|
||||
/**
|
||||
* os_memcmp - Compare memory areas
|
||||
* @s1: First buffer
|
||||
* @s2: Second buffer
|
||||
* @n: Maximum numbers of octets to compare
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greater than s2. Only first n
|
||||
* characters will be compared.
|
||||
*/
|
||||
int os_memcmp(const void *s1, const void *s2, size_t n);
|
||||
|
||||
/**
|
||||
* os_strdup - Duplicate a string
|
||||
* @s: Source string
|
||||
* Returns: Allocated buffer with the string copied into it or %NULL on failure
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
char *os_strdup(const char *s);
|
||||
|
||||
/**
|
||||
* os_strlen - Calculate the length of a string
|
||||
* @s: '\0' terminated string
|
||||
* Returns: Number of characters in s (not counting the '\0' terminator)
|
||||
*/
|
||||
size_t os_strlen(const char *s);
|
||||
|
||||
/**
|
||||
* os_strcasecmp - Compare two strings ignoring case
|
||||
* @s1: First string
|
||||
* @s2: Second string
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greatred than s2
|
||||
*/
|
||||
int os_strcasecmp(const char *s1, const char *s2);
|
||||
|
||||
/**
|
||||
* os_strncasecmp - Compare two strings ignoring case
|
||||
* @s1: First string
|
||||
* @s2: Second string
|
||||
* @n: Maximum numbers of characters to compare
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greater than s2. Only first n
|
||||
* characters will be compared.
|
||||
*/
|
||||
int os_strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
|
||||
/**
|
||||
* os_strchr - Locate the first occurrence of a character in string
|
||||
* @s: String
|
||||
* @c: Character to search for
|
||||
* Returns: Pointer to the matched character or %NULL if not found
|
||||
*/
|
||||
char *os_strchr(const char *s, int c);
|
||||
|
||||
/**
|
||||
* os_strrchr - Locate the last occurrence of a character in string
|
||||
* @s: String
|
||||
* @c: Character to search for
|
||||
* Returns: Pointer to the matched character or %NULL if not found
|
||||
*/
|
||||
char *os_strrchr(const char *s, int c);
|
||||
|
||||
/**
|
||||
* os_strcmp - Compare two strings
|
||||
* @s1: First string
|
||||
* @s2: Second string
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greatred than s2
|
||||
*/
|
||||
int os_strcmp(const char *s1, const char *s2);
|
||||
|
||||
/**
|
||||
* os_strncmp - Compare two strings
|
||||
* @s1: First string
|
||||
* @s2: Second string
|
||||
* @n: Maximum numbers of characters to compare
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greater than s2. Only first n
|
||||
* characters will be compared.
|
||||
*/
|
||||
int os_strncmp(const char *s1, const char *s2, size_t n);
|
||||
|
||||
/**
|
||||
* os_strncpy - Copy a string
|
||||
* @dest: Destination
|
||||
* @src: Source
|
||||
* @n: Maximum number of characters to copy
|
||||
* Returns: dest
|
||||
*/
|
||||
char *os_strncpy(char *dest, const char *src, size_t n);
|
||||
|
||||
/**
|
||||
* os_strstr - Locate a substring
|
||||
* @haystack: String (haystack) to search from
|
||||
* @needle: Needle to search from haystack
|
||||
* Returns: Pointer to the beginning of the substring or %NULL if not found
|
||||
*/
|
||||
char *os_strstr(const char *haystack, const char *needle);
|
||||
|
||||
/**
|
||||
* os_snprintf - Print to a memory buffer
|
||||
* @str: Memory buffer to print into
|
||||
* @size: Maximum length of the str buffer
|
||||
* @format: printf format
|
||||
* Returns: Number of characters printed (not including trailing '\0').
|
||||
*
|
||||
* If the output buffer is truncated, number of characters which would have
|
||||
* been written is returned. Since some C libraries return -1 in such a case,
|
||||
* the caller must be prepared on that value, too, to indicate truncation.
|
||||
*
|
||||
* Note: Some C library implementations of snprintf() may not guarantee null
|
||||
* termination in case the output is truncated. The OS wrapper function of
|
||||
* os_snprintf() should provide this guarantee, i.e., to null terminate the
|
||||
* output buffer if a C library version of the function is used and if that
|
||||
* function does not guarantee null termination.
|
||||
*
|
||||
* If the target system does not include snprintf(), see, e.g.,
|
||||
* http://www.ijs.si/software/snprintf/ for an example of a portable
|
||||
* implementation of snprintf.
|
||||
*/
|
||||
int os_snprintf(char *str, size_t size, const char *format, ...);
|
||||
|
||||
#else /* OS_NO_C_LIB_DEFINES */
|
||||
|
||||
#if !defined(CONFIG_PLATFORM_8195A) && !defined(CONFIG_PLATFORM_8711B) && !defined(CONFIG_PLATFORM_8721D)
|
||||
#ifdef CONFIG_MEM_MONITOR
|
||||
u8* os_malloc(u32 sz);
|
||||
void os_mfree(u8 *pbuf, u32 sz);
|
||||
#ifndef os_free
|
||||
#define os_free(p, sz) os_mfree(((u8*)(p)), (sz))
|
||||
#endif
|
||||
#else
|
||||
#ifndef os_malloc
|
||||
#define os_malloc(sz) _rtw_malloc(sz)
|
||||
#endif
|
||||
#ifndef os_free
|
||||
#define os_free(p, sz) _rtw_mfree(((u8*)(p)), (sz))
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
extern void *os_zalloc(size_t size);
|
||||
extern char *os_strdup(const char *string_copy_from);
|
||||
|
||||
#ifndef os_sleep
|
||||
#define os_sleep(s, us) rtw_mdelay_os((s)*1000 + (us)/1000)
|
||||
#endif
|
||||
#ifndef os_memcpy
|
||||
#define os_memcpy(d, s, n) rtw_memcpy((void*)(d), ((void*)(s)), (n))
|
||||
#endif
|
||||
#ifndef os_memmove
|
||||
#define os_memmove(d, s, n) memmove((d), (s), (n))
|
||||
#endif
|
||||
#ifndef os_memset
|
||||
#define os_memset(pbuf, c, sz) rtw_memset(pbuf, c, sz)
|
||||
#endif
|
||||
#ifndef os_memcmp
|
||||
#define os_memcmp(s1, s2, n) rtw_memcmp(((void*)(s1)), ((void*)(s2)), (n))
|
||||
#endif
|
||||
#ifndef os_memcmp_p2p
|
||||
#define os_memcmp_p2p(s1, s2, n) memcmp((s1), (s2), (n))
|
||||
#endif
|
||||
#ifndef os_get_random_bytes
|
||||
#define os_get_random_bytes(d,sz) rtw_get_random_bytes(((void*)(d)), (sz))
|
||||
#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_init_timer
|
||||
#define os_init_timer(t, p, f, x, n) rtw_init_timer((t), (p), (f), (x), (n))
|
||||
#endif
|
||||
#ifndef os_set_timer
|
||||
#define os_set_timer(t, d) rtw_set_timer((t), (d))
|
||||
#endif
|
||||
#ifndef os_cancel_timer
|
||||
#define os_cancel_timer(t) rtw_cancel_timer(t)
|
||||
#endif
|
||||
#ifndef os_del_timer
|
||||
#define os_del_timer(t) rtw_del_timer(t)
|
||||
#endif
|
||||
#ifndef os_atoi
|
||||
#define os_atoi(s) rtw_atoi(s)
|
||||
#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
|
||||
#define os_strrchr(s, c) strrchr((s), (c))
|
||||
#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 snprintf
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* OS_NO_C_LIB_DEFINES */
|
||||
|
||||
|
||||
static inline void * os_realloc_array(void *ptr, size_t nmemb, size_t size)
|
||||
{
|
||||
if (size && nmemb > (~(size_t) 0) / size)
|
||||
return NULL;
|
||||
if(ptr == NULL){
|
||||
return os_malloc(nmemb * size);
|
||||
}
|
||||
else{
|
||||
return os_realloc(ptr, nmemb * size, nmemb * size);
|
||||
}
|
||||
}
|
||||
|
||||
void *os_xqueue_create(unsigned long uxQueueLength, unsigned long uxItemSize) ;
|
||||
|
||||
int os_xqueue_receive(xqueue_handle_t xQueue, void * const pvBuffer, unsigned long xSecsToWait);
|
||||
|
||||
void os_xqueue_delete(xqueue_handle_t xQueue );
|
||||
|
||||
int os_xqueue_send(xqueue_handle_t xQueue, const void * const pvItemToQueue, unsigned long xSecsToWait);
|
||||
|
||||
|
||||
#endif /* OS_H */
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* OS specific functions
|
||||
* Copyright (c) 2005-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef ROM_WPS_OS_H
|
||||
#define ROM_WPS_OS_H
|
||||
|
||||
#if defined(CONFIG_PLATFORM_8195A) || defined(CONFIG_PLATFORM_8711B) || defined(CONFIG_PLATFORM_8721D)
|
||||
|
||||
#include <rom_wlan_ram_map.h>
|
||||
extern struct _rom_wlan_ram_map rom_wlan_ram_map;
|
||||
#define os_malloc(sz) rom_wlan_ram_map.rtw_malloc(sz)
|
||||
#define os_free(p, sz) rom_wlan_ram_map.rtw_mfree(((u8*)(p)), (sz))
|
||||
|
||||
#endif
|
||||
|
||||
extern u8 *WPS_realloc(u8 *old_buf, u32 old_sz, u32 new_sz);
|
||||
#define os_realloc(p, os, ns) WPS_realloc(((u8*)(p)),(os),(ns))
|
||||
|
||||
#endif /* ROM_WPS_OS_H */
|
||||
|
|
@ -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 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, \
|
||||
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 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 */
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Backtrace debugging
|
||||
* 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 TRACE_H
|
||||
#define TRACE_H
|
||||
|
||||
#define WPA_TRACE_LEN 16
|
||||
|
||||
#ifdef WPA_TRACE
|
||||
#include <execinfo.h>
|
||||
|
||||
#include "list.h"
|
||||
|
||||
#define WPA_TRACE_INFO void *btrace[WPA_TRACE_LEN]; int btrace_num;
|
||||
|
||||
struct wpa_trace_ref {
|
||||
struct dl_list list;
|
||||
const void *addr;
|
||||
WPA_TRACE_INFO
|
||||
};
|
||||
#define WPA_TRACE_REF(name) struct wpa_trace_ref wpa_trace_ref_##name
|
||||
|
||||
#define wpa_trace_dump(title, ptr) \
|
||||
wpa_trace_dump_func((title), (ptr)->btrace, (ptr)->btrace_num)
|
||||
void wpa_trace_dump_func(const char *title, void **btrace, int btrace_num);
|
||||
#define wpa_trace_record(ptr) \
|
||||
(ptr)->btrace_num = backtrace((ptr)->btrace, WPA_TRACE_LEN)
|
||||
void wpa_trace_show(const char *title);
|
||||
#define wpa_trace_add_ref(ptr, name, addr) \
|
||||
wpa_trace_add_ref_func(&(ptr)->wpa_trace_ref_##name, (addr))
|
||||
/* wpa_trace_add_ref(timeout, eloop, eloop_data)
|
||||
-> wpa_trace_add_ref_func(&(timeout)->wpa_trace_ref_eloop, (eloop_data))
|
||||
*/
|
||||
|
||||
void wpa_trace_add_ref_func(struct wpa_trace_ref *ref, const void *addr);
|
||||
#define wpa_trace_remove_ref(ptr, name, addr) \
|
||||
do { \
|
||||
if ((addr)) \
|
||||
dl_list_del(&(ptr)->wpa_trace_ref_##name.list); \
|
||||
} while (0)
|
||||
void wpa_trace_check_ref(const void *addr);
|
||||
|
||||
#else /* WPA_TRACE */
|
||||
|
||||
#define WPA_TRACE_INFO
|
||||
#define WPA_TRACE_REF(n)
|
||||
#define wpa_trace_dump(title, ptr) do { } while (0)
|
||||
#define wpa_trace_record(ptr) do { } while (0)
|
||||
#define wpa_trace_show(title) do { } while (0)
|
||||
#define wpa_trace_add_ref(ptr, name, addr) do { } while (0)
|
||||
#define wpa_trace_remove_ref(ptr, name, addr) do { } while (0)
|
||||
#define wpa_trace_check_ref(addr) do { } while (0)
|
||||
|
||||
#endif /* WPA_TRACE */
|
||||
|
||||
|
||||
#ifdef WPA_TRACE_BFD
|
||||
|
||||
void wpa_trace_dump_funcname(const char *title, void *pc);
|
||||
|
||||
#else /* WPA_TRACE_BFD */
|
||||
|
||||
#define wpa_trace_dump_funcname(title, pc) do { } while (0)
|
||||
|
||||
#endif /* WPA_TRACE_BFD */
|
||||
#endif /* TRACE_H */
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Universally Unique IDentifier (UUID)
|
||||
* Copyright (c) 2008, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef UUID_H
|
||||
#define UUID_H
|
||||
|
||||
#include <platform/platform_stdlib.h>
|
||||
#define UUID_LEN 16
|
||||
|
||||
int uuid_str2bin(const char *str, u8 *bin);
|
||||
static int uuid_bin2str(const u8 *bin, char *str, size_t max_len)
|
||||
{
|
||||
int len;
|
||||
len = os_snprintf(str, max_len, "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
|
||||
"%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
bin[0], bin[1], bin[2], bin[3],
|
||||
bin[4], bin[5], bin[6], bin[7],
|
||||
bin[8], bin[9], bin[10], bin[11],
|
||||
bin[12], bin[13], bin[14], bin[15]);
|
||||
if (len < 0 || (size_t) len >= max_len)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
int is_nil_uuid(const u8 *uuid);
|
||||
|
||||
#endif /* UUID_H */
|
||||
|
|
@ -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 WPABASE64_H
|
||||
#define WPABASE64_H
|
||||
|
||||
unsigned char * wpa_base64_encode(const unsigned char *src, size_t len,
|
||||
size_t *out_len);
|
||||
unsigned char * wpa_base64_decode(const unsigned char *src, size_t len,
|
||||
size_t *out_len);
|
||||
|
||||
#endif /* BASE64_H */
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* wpa_supplicant/hostapd / Debug prints
|
||||
* Copyright (c) 2002-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_DEBUG_H
|
||||
#define WPA_DEBUG_H
|
||||
|
||||
#include "utils/wpabuf.h"
|
||||
/* Debugging function - conditional printf and hex dump. Driver wrappers can
|
||||
* use these for debugging purposes. */
|
||||
|
||||
enum {
|
||||
MSG_EXCESSIVE, MSG_MSGDUMP, MSG_DEBUG, MSG_INFO, MSG_ALWAYS, MSG_WARNING, MSG_ERROR
|
||||
};
|
||||
|
||||
|
||||
#define wpa_debug_print_timestamp() do { } while (0)
|
||||
#define wpa_hexdump(l,t,b,le) do { } while (0)
|
||||
#define wpa_hexdump_buf_key(l,t,b) do { } while (0)
|
||||
#define wpa_hexdump_ascii_key(l,t,b,le) do { } while (0)
|
||||
#define wpa_debug_open_file(p) do { } while (0)
|
||||
#define wpa_debug_close_file() do { } while (0)
|
||||
#define wpa_dbg(args...) do { } while (0)
|
||||
#define wpa_msg_ctrl(args...) do { } while (0)
|
||||
#define wpa_msg_register_cb(f) do { } while (0)
|
||||
#define wpa_msg_register_ifname_cb(f) do { } while (0)
|
||||
static inline int wpa_debug_reopen_file(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#define wprintf(fmt, arg...) printf("[%d] "fmt, rtw_get_current_time(),##arg)
|
||||
|
||||
#ifdef CONFIG_NO_STDOUT_DEBUG
|
||||
#define wpa_printf(args...) do { } while (0)
|
||||
#define wpa_hexdump_buf(l,t,b) do { } while (0)
|
||||
#define wpa_hexdump_key(l,t,b,le) do { } while (0)
|
||||
#define wpa_hexdump_ascii(l,t,b,le) do { } while (0)
|
||||
#define wpa_msg(args...) do { } while (0)
|
||||
#else
|
||||
//void wpa_printf(int level, const char *fmt, ...);
|
||||
#define wpa_printf(level, fmt, arg...) \
|
||||
do {\
|
||||
if (level >= MSG_INFO) {\
|
||||
{\
|
||||
printf("\r\n%d:", rtw_get_current_time());\
|
||||
printf(fmt, ##arg);\
|
||||
printf("\n\r");\
|
||||
} \
|
||||
}\
|
||||
}while(0)
|
||||
#define wpa_msg(ctx,level,fmt,arg...) wpa_printf((level),(fmt), ##arg)
|
||||
void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len);
|
||||
void wpa_hexdump_buf(int level, const char *title,
|
||||
const struct wpabuf *buf);
|
||||
void wpa_hexdump_ascii(int level, const char *title, const void *buf,
|
||||
size_t len);
|
||||
|
||||
#ifdef EAPOL_TEST
|
||||
#define WPA_ASSERT(a) \
|
||||
do { \
|
||||
if (!(a)) { \
|
||||
printf("WPA_ASSERT FAILED '" #a "' " \
|
||||
"%s %s:%d\n", \
|
||||
__FUNCTION__, __FILE__, __LINE__); \
|
||||
exit(1); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define WPA_ASSERT(a) do { } while (0)
|
||||
#endif
|
||||
#endif //CONFIG_NO_STDOUT_DEBUG
|
||||
|
||||
#endif /* WPA_DEBUG_H */
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* Doubly-linked list
|
||||
* 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 WPALIST_H
|
||||
#define WPALIST_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 */
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue