mirror of
https://github.com/cwyark/sdk-ameba-v4.0b_without_nda_gcc.git
synced 2025-07-31 20:31:07 +00:00
Initial commit
This commit is contained in:
commit
6f665866d6
3358 changed files with 1106791 additions and 0 deletions
149
component/common/api/wifi/rtw_wowlan/dev_wowlan.c
Normal file
149
component/common/api/wifi/rtw_wowlan/dev_wowlan.c
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
#include <PinNames.h>
|
||||
#include <pinmap.h>
|
||||
#include <gpio_api.h>
|
||||
#include <wifi_wowlan.h>
|
||||
#include <freertos_pmu.h>
|
||||
#include <wifi_conf.h>
|
||||
|
||||
#define CONFIG_WOWLAN_DEV_NT96658 //build for Nova NT96658
|
||||
//#define CONFIG_WOWLAN_DEV_OV788 //build for OmniVision OV788
|
||||
|
||||
#if defined(CONFIG_WOWLAN_DEV_NT96658) && defined(CONFIG_WOWLAN_DEV_OV788)
|
||||
#error "CONFIG_WOWLAN_DEV_NT96658 and CONFIG_WOWLAN_DEV_OV788 are mutually exclusive. "
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_WOWLAN_DEV_NT96658
|
||||
#define WOW_WIFI_IN_PIN PE_4 //JTAG pin, so JTAG must be disable before using this pin as wakeup pin
|
||||
#define WOW_TRIGGER_INTERVAL 500
|
||||
#elif defined(CONFIG_WOWLAN_DEV_OV788)
|
||||
#define WOW_WIFI_IN_PIN PD_5
|
||||
#define WOW_WLAN_ON_PIN PB_3
|
||||
#define WOW_TRIGGER_INTERVAL 200
|
||||
#else
|
||||
#error "Either CONFIG_WOWLAN_DEV_NT96658 or CONFIG_WOWLAN_DEV_OV788 should be defined, but not both. "
|
||||
#endif
|
||||
|
||||
//pin assignment for SDIO, default pull high
|
||||
#define SD_D2 PA_0
|
||||
#define SD_D3 PA_1
|
||||
#define SD_CMD PA_2
|
||||
#define SD_CLK PA_3
|
||||
#define SD_D0 PA_4
|
||||
#define SD_D1 PA_5
|
||||
#define SD_CD PA_6
|
||||
|
||||
gpio_t wow_gpio_wifi_in; //WOWLAN WAKEUP TRIGGER PORT
|
||||
gpio_t wow_gpio_wlan_on; //RECORD WOWLAN STATUS: 1:OFF, 0:ON
|
||||
|
||||
int dev_wowlan_init(void){
|
||||
WOWLAN_PRINTK("WOWLAN: device init!");
|
||||
|
||||
#ifdef CONFIG_WOWLAN_DEV_OV788
|
||||
// Initial WLAN_ON pin
|
||||
gpio_init(&wow_gpio_wlan_on, WOW_WLAN_ON_PIN);
|
||||
gpio_dir(&wow_gpio_wlan_on, PIN_OUTPUT);
|
||||
gpio_mode(&wow_gpio_wlan_on, PullNone);
|
||||
gpio_write(&wow_gpio_wlan_on, 1);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dev_wowlan_enable(void){
|
||||
WOWLAN_PRINTK("WOWLAN: device enable!");
|
||||
|
||||
// Init WIFI_IN pin (wakeup pin)
|
||||
gpio_init(&wow_gpio_wifi_in, WOW_WIFI_IN_PIN);
|
||||
gpio_dir(&wow_gpio_wifi_in, PIN_OUTPUT);
|
||||
gpio_mode(&wow_gpio_wifi_in, PullNone);
|
||||
gpio_write(&wow_gpio_wifi_in, 0);
|
||||
|
||||
#ifdef CONFIG_WOWLAN_DEV_OV788
|
||||
gpio_write(&wow_gpio_wlan_on, 0);
|
||||
#endif
|
||||
|
||||
#if CONFIG_WLAN
|
||||
wifi_set_power_mode(0xff, 1);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dev_wowlan_wakeup_process(void){
|
||||
WOWLAN_PRINTK("WOWLAN: device wake up!");
|
||||
|
||||
#if defined(CONFIG_WOWLAN_DEV_NT96658) || defined(CONFIG_WOWLAN_DEV_OV788)
|
||||
#if defined(configUSE_WAKELOCK_PMU) && (configUSE_WAKELOCK_PMU == 1)
|
||||
//acquire wakelock to keep system awake
|
||||
pmu_acquire_wakelock(PMU_SDIO_DEVICE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_WOWLAN_DEV_OV788
|
||||
//record wowlan status
|
||||
gpio_write(&wow_gpio_wlan_on, 1);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_WOWLAN_DEV_NT96658)
|
||||
//restore SDIO pin status for bus communication
|
||||
pin_mode(SD_D0, PullUp);
|
||||
pin_mode(SD_D1, PullUp);
|
||||
pin_mode(SD_D2, PullUp);
|
||||
pin_mode(SD_D3, PullUp);
|
||||
pin_mode(SD_CMD, PullUp);
|
||||
pin_mode(SD_CLK, PullDown);
|
||||
#endif
|
||||
|
||||
//send signal to awake host
|
||||
gpio_write(&wow_gpio_wifi_in, 0);
|
||||
wowlan_mdelay_os(WOW_TRIGGER_INTERVAL);
|
||||
gpio_write(&wow_gpio_wifi_in, 1);
|
||||
wowlan_mdelay_os(WOW_TRIGGER_INTERVAL);
|
||||
gpio_write(&wow_gpio_wifi_in, 0);
|
||||
wowlan_mdelay_os(WOW_TRIGGER_INTERVAL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dev_wowlan_sleep_process(void){
|
||||
|
||||
#if defined(CONFIG_WOWLAN_DEV_NT96658)
|
||||
//pull control for SDIO pin only when host is already power off
|
||||
if(rtw_wowlan_is_enabled() && (rtw_wowlan_get_wk_reason() == 0)){
|
||||
WOWLAN_PRINTK("pull control");
|
||||
//configure SDIO pin status for avoiding current leakage
|
||||
pin_mode(SD_D0, PullNone);
|
||||
pin_mode(SD_D1, PullNone);
|
||||
pin_mode(SD_D2, PullNone);
|
||||
pin_mode(SD_D3, PullNone);
|
||||
pin_mode(SD_CMD, PullNone);
|
||||
pin_mode(SD_CLK, PullNone);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dev_wowlan_disable(void){
|
||||
WOWLAN_PRINTK("WOWLAN: device disable!");
|
||||
|
||||
#if CONFIG_WLAN
|
||||
wifi_set_power_mode(0xff, 0);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_WOWLAN_DEV_OV788
|
||||
gpio_write(&wow_gpio_wlan_on, 1);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dev_wowlan_ops_init(void *dev_ops){
|
||||
struct rtw_wowlan_ops *ops = (struct rtw_wowlan_ops *)dev_ops;
|
||||
WOWLAN_PRINTK("WOWLAN: device ops init!");
|
||||
ops->DevWowlanInit = dev_wowlan_init;
|
||||
ops->DevWowlanEnable = dev_wowlan_enable;
|
||||
ops->DevWowlanDisable = dev_wowlan_disable;
|
||||
ops->DevWowlanWakeUp = dev_wowlan_wakeup_process;
|
||||
ops->DevWowlanSleep = dev_wowlan_sleep_process;
|
||||
}
|
||||
385
component/common/api/wifi/rtw_wowlan/wifi_wowlan.h
Normal file
385
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
|
||||
589
component/common/api/wifi/rtw_wpa_supplicant/src/crypto/tls.h
Normal file
589
component/common/api/wifi/rtw_wpa_supplicant/src/crypto/tls.h
Normal file
|
|
@ -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 */
|
||||
File diff suppressed because it is too large
Load diff
548
component/common/api/wifi/rtw_wpa_supplicant/src/utils/common.h
Normal file
548
component/common/api/wifi/rtw_wpa_supplicant/src/utils/common.h
Normal file
|
|
@ -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 */
|
||||
594
component/common/api/wifi/rtw_wpa_supplicant/src/utils/os.h
Normal file
594
component/common/api/wifi/rtw_wpa_supplicant/src/utils/os.h
Normal file
|
|
@ -0,0 +1,594 @@
|
|||
/*
|
||||
* 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"
|
||||
#include "freertos/wrapper.h"
|
||||
#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)
|
||||
#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;
|
||||
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,119 @@
|
|||
/*
|
||||
* OS specific functions for UNIX/POSIX systems
|
||||
* 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.
|
||||
*/
|
||||
#include "utils/os.h"
|
||||
|
||||
//#ifdef CONFIG_WPS
|
||||
|
||||
#if !defined(CONFIG_PLATFORM_8195A) && !defined(CONFIG_PLATFORM_8711B)
|
||||
#ifdef CONFIG_MEM_MONITOR
|
||||
#if CONFIG_MEM_MONITOR & MEM_MONITOR_LEAK
|
||||
_list wpa_mem_table;
|
||||
int wpa_mem_used_num;
|
||||
//int wpa_mem_used_size;
|
||||
#endif
|
||||
extern int min_free_heap_size;
|
||||
u8* os_malloc(u32 sz)
|
||||
{
|
||||
int free_heap_size = rtw_getFreeHeapSize();
|
||||
u8 *pbuf = _rtw_malloc(sz);
|
||||
#if CONFIG_MEM_MONITOR & MEM_MONITOR_LEAK
|
||||
add_mem_usage(&wpa_mem_table, pbuf, sz, &wpa_mem_used_num, MEM_MONITOR_FLAG_WPAS);
|
||||
#else
|
||||
add_mem_usage(NULL, pbuf, sz, NULL, MEM_MONITOR_FLAG_WPAS);
|
||||
#endif
|
||||
if(min_free_heap_size > free_heap_size)
|
||||
min_free_heap_size = free_heap_size;
|
||||
return pbuf;
|
||||
}
|
||||
|
||||
void os_mfree(u8 *pbuf, u32 sz)
|
||||
{
|
||||
_rtw_mfree(pbuf, sz);
|
||||
#if CONFIG_MEM_MONITOR & MEM_MONITOR_LEAK
|
||||
del_mem_usage(&wpa_mem_table, pbuf, &wpa_mem_used_num, MEM_MONITOR_FLAG_WPAS);
|
||||
#else
|
||||
del_mem_usage(NULL, pbuf, NULL, MEM_MONITOR_FLAG_WPAS);
|
||||
#endif
|
||||
}
|
||||
#endif//CONFIG_MEM_MONITOR
|
||||
|
||||
#endif// !defined(CONFIG_PLATFORM_8195A)
|
||||
|
||||
#ifndef OS_NO_C_LIB_DEFINES
|
||||
char *os_strdup(const char *string_copy_from)
|
||||
{
|
||||
char *string_copy_to = NULL;
|
||||
string_copy_to = os_zalloc(strlen(string_copy_from) + 1);
|
||||
os_memcpy((void *)string_copy_to, string_copy_from, strlen(string_copy_from));
|
||||
string_copy_to[strlen(string_copy_from)] = '\0';
|
||||
return string_copy_to;
|
||||
}
|
||||
#endif
|
||||
|
||||
int os_get_random(unsigned char *buf, size_t len)
|
||||
{
|
||||
//TODO implement it
|
||||
rtw_get_random_bytes(buf, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int os_get_time(struct os_time *t){
|
||||
unsigned int tt = rtw_get_current_time();
|
||||
t->sec = (os_time_t) (tt / 1000);
|
||||
t->usec = (os_time_t) (tt % 1000)*1000;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int os_get_reltime(struct os_reltime *t){
|
||||
os_get_time((struct os_time *)t);
|
||||
return 0;
|
||||
}
|
||||
#if 0
|
||||
void *os_xqueue_create(unsigned long uxQueueLength, unsigned long uxItemSize)
|
||||
{
|
||||
return xQueueCreate( uxQueueLength, uxItemSize );
|
||||
}
|
||||
|
||||
int os_xqueue_receive(xqueue_handle_t xQueue, void * const pvBuffer, unsigned long xSecsToWait)
|
||||
{
|
||||
return xQueueReceive((xQueueHandle)xQueue, pvBuffer, (portTickType)(xSecsToWait*configTICK_RATE_HZ));
|
||||
}
|
||||
|
||||
void os_xqueue_delete(xqueue_handle_t xQueue )
|
||||
{
|
||||
vQueueDelete((xQueueHandle)xQueue);
|
||||
}
|
||||
|
||||
int os_xqueue_send(xqueue_handle_t xQueue, const void * const pvItemToQueue, unsigned long xSecsToWait)
|
||||
{
|
||||
return xQueueSendToBack((xQueueHandle)xQueue, pvItemToQueue, (portTickType)(xSecsToWait*configTICK_RATE_HZ));
|
||||
}
|
||||
#else
|
||||
void *os_xqueue_create(unsigned long uxQueueLength, unsigned long uxItemSize)
|
||||
{
|
||||
void* xQueue = NULL;
|
||||
rtw_init_xqueue(&xQueue, "queue", uxItemSize, uxQueueLength);
|
||||
return xQueue;
|
||||
}
|
||||
|
||||
int os_xqueue_receive(xqueue_handle_t xQueue, void * const pvBuffer, unsigned long xSecsToWait)
|
||||
{
|
||||
return rtw_pop_from_xqueue(&xQueue, pvBuffer, xSecsToWait*1000);
|
||||
}
|
||||
|
||||
void os_xqueue_delete(xqueue_handle_t xQueue )
|
||||
{
|
||||
rtw_deinit_xqueue(&xQueue);
|
||||
}
|
||||
|
||||
int os_xqueue_send(xqueue_handle_t xQueue, const void * const pvItemToQueue, unsigned long xSecsToWait)
|
||||
{
|
||||
return rtw_push_to_xqueue(&xQueue, (void*)pvItemToQueue, xSecsToWait*1000);
|
||||
}
|
||||
#endif
|
||||
//#endif
|
||||
|
|
@ -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)
|
||||
|
||||
#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,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,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 */
|
||||
188
component/common/api/wifi/rtw_wpa_supplicant/src/utils/wpabuf.h
Normal file
188
component/common/api/wifi/rtw_wpa_supplicant/src/utils/wpabuf.h
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
/*
|
||||
* Dynamic data buffer
|
||||
* Copyright (c) 2007-2012, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef WPABUF_H
|
||||
#define WPABUF_H
|
||||
|
||||
/* wpabuf::buf is a pointer to external data */
|
||||
#define WPABUF_FLAG_EXT_DATA BIT(0)
|
||||
|
||||
/*
|
||||
* Internal data structure for wpabuf. Please do not touch this directly from
|
||||
* elsewhere. This is only defined in header file to allow inline functions
|
||||
* from this file to access data.
|
||||
*/
|
||||
struct wpabuf {
|
||||
size_t size; /* total size of the allocated buffer (i.e allocated buffer size)*/
|
||||
size_t used; /* length of data in the buffer (i.e data length) */
|
||||
u8 *buf; /* pointer to the head of the buffer (i.e buffer address) */
|
||||
unsigned int flags;
|
||||
/* optionally followed by the allocated buffer */
|
||||
};
|
||||
|
||||
|
||||
int wpabuf_resize(struct wpabuf **buf, size_t add_len);
|
||||
struct wpabuf * wpabuf_alloc(size_t len);
|
||||
struct wpabuf * wpabuf_alloc_ext_data(u8 *data, size_t len);
|
||||
struct wpabuf * wpabuf_alloc_copy(const void *data, size_t len);
|
||||
struct wpabuf * wpabuf_dup(const struct wpabuf *src);
|
||||
void wpabuf_free(struct wpabuf *buf);
|
||||
void * wpabuf_put(struct wpabuf *buf, size_t len);
|
||||
struct wpabuf * wpabuf_concat(struct wpabuf *a, struct wpabuf *b);
|
||||
struct wpabuf * wpabuf_zeropad(struct wpabuf *buf, size_t len);
|
||||
void wpabuf_printf(struct wpabuf *buf, char *fmt, ...) PRINTF_FORMAT(2, 3);
|
||||
|
||||
|
||||
/**
|
||||
* wpabuf_size - Get the currently allocated size of a wpabuf buffer
|
||||
* @buf: wpabuf buffer
|
||||
* Returns: Currently allocated size of the buffer
|
||||
*/
|
||||
static inline size_t wpabuf_size(const struct wpabuf *buf)
|
||||
{
|
||||
return buf->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* wpabuf_len - Get the current length of a wpabuf buffer data
|
||||
* @buf: wpabuf buffer
|
||||
* Returns: Currently used length of the buffer
|
||||
*/
|
||||
static inline size_t wpabuf_len(const struct wpabuf *buf)
|
||||
{
|
||||
return buf->used;
|
||||
}
|
||||
|
||||
/**
|
||||
* wpabuf_tailroom - Get size of available tail room in the end of the buffer
|
||||
* @buf: wpabuf buffer
|
||||
* Returns: Tail room (in bytes) of available space in the end of the buffer
|
||||
*/
|
||||
static inline size_t wpabuf_tailroom(const struct wpabuf *buf)
|
||||
{
|
||||
return buf->size - buf->used;
|
||||
}
|
||||
|
||||
/**
|
||||
* wpabuf_head - Get pointer to the head of the buffer data
|
||||
* @buf: wpabuf buffer
|
||||
* Returns: Pointer to the head of the buffer data
|
||||
*/
|
||||
static inline const void *wpabuf_head(const struct wpabuf *buf)
|
||||
{
|
||||
return buf->buf;
|
||||
}
|
||||
|
||||
static inline const u8 *wpabuf_head_u8(const struct wpabuf *buf)
|
||||
{
|
||||
return wpabuf_head(buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* wpabuf_mhead - Get modifiable pointer to the head of the buffer data
|
||||
* @buf: wpabuf buffer
|
||||
* Returns: Pointer to the head of the buffer data
|
||||
*/
|
||||
static inline void *wpabuf_mhead(struct wpabuf *buf)
|
||||
{
|
||||
return buf->buf;
|
||||
}
|
||||
|
||||
static inline u8 *wpabuf_mhead_u8(struct wpabuf *buf)
|
||||
{
|
||||
return wpabuf_mhead(buf);
|
||||
}
|
||||
|
||||
static inline void wpabuf_put_u8(struct wpabuf *buf, u8 data)
|
||||
{
|
||||
u8 *pos = NULL;
|
||||
if ( buf == NULL)
|
||||
return;
|
||||
pos = wpabuf_put(buf, 1);
|
||||
*pos = data;
|
||||
}
|
||||
|
||||
static inline void wpabuf_put_le16(struct wpabuf *buf, u16 data)
|
||||
{
|
||||
u8 *pos = NULL;
|
||||
if ( buf == NULL)
|
||||
return;
|
||||
pos = wpabuf_put(buf, 2);
|
||||
WPA_PUT_LE16(pos, data);
|
||||
}
|
||||
|
||||
static inline void wpabuf_put_le32(struct wpabuf *buf, u32 data)
|
||||
{
|
||||
u8 *pos = NULL;
|
||||
if ( buf == NULL)
|
||||
return;
|
||||
pos = wpabuf_put(buf, 4);
|
||||
WPA_PUT_LE32(pos, data);
|
||||
}
|
||||
|
||||
static inline void wpabuf_put_be16(struct wpabuf *buf, u16 data)
|
||||
{
|
||||
u8 *pos = NULL;
|
||||
if ( buf == NULL)
|
||||
return;
|
||||
pos = wpabuf_put(buf, 2);
|
||||
WPA_PUT_BE16(pos, data);
|
||||
}
|
||||
|
||||
static inline void wpabuf_put_be24(struct wpabuf *buf, u32 data)
|
||||
{
|
||||
u8 *pos = NULL;
|
||||
if ( buf == NULL)
|
||||
return;
|
||||
pos = wpabuf_put(buf, 3);
|
||||
WPA_PUT_BE24(pos, data);
|
||||
}
|
||||
|
||||
static inline void wpabuf_put_be32(struct wpabuf *buf, u32 data)
|
||||
{
|
||||
u8 *pos = NULL;
|
||||
if ( buf == NULL)
|
||||
return;
|
||||
pos = wpabuf_put(buf, 4);
|
||||
WPA_PUT_BE32(pos, data);
|
||||
}
|
||||
|
||||
// encr >> 16 B 64 - 16 = 48
|
||||
static inline void wpabuf_put_data(struct wpabuf *buf, const void *data, size_t len)
|
||||
{
|
||||
if ( buf == NULL)
|
||||
return;
|
||||
if (data)
|
||||
os_memcpy(wpabuf_put(buf, len), data, len);
|
||||
}
|
||||
|
||||
static inline void wpabuf_put_buf(struct wpabuf *dst,
|
||||
const struct wpabuf *src)
|
||||
{
|
||||
if ( dst == NULL)
|
||||
return;
|
||||
wpabuf_put_data(dst, wpabuf_head(src), wpabuf_len(src));
|
||||
}
|
||||
|
||||
static inline void wpabuf_set(struct wpabuf *buf, const void *data, size_t len)
|
||||
{
|
||||
if ( buf == NULL)
|
||||
return;
|
||||
buf->buf = (u8 *) data;
|
||||
buf->flags = WPABUF_FLAG_EXT_DATA;
|
||||
buf->size = buf->used = len;
|
||||
}
|
||||
|
||||
static inline void wpabuf_put_str(struct wpabuf *dst, const char *str)
|
||||
{
|
||||
if ( dst == NULL)
|
||||
return;
|
||||
wpabuf_put_data(dst, str, os_strlen(str));
|
||||
}
|
||||
|
||||
#endif /* WPABUF_H */
|
||||
324
component/common/api/wifi/rtw_wpa_supplicant/src/wps/wps_defs.h
Normal file
324
component/common/api/wifi/rtw_wpa_supplicant/src/wps/wps_defs.h
Normal file
|
|
@ -0,0 +1,324 @@
|
|||
|
||||
/*
|
||||
* Wi-Fi Protected Setup - message definitions
|
||||
* 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 WPS_DEFS_H
|
||||
#define WPS_DEFS_H
|
||||
|
||||
#ifdef CONFIG_WPS2
|
||||
#define WPS_VERSION 0x20
|
||||
#else /* CONFIG_WPS2 */
|
||||
#define WPS_VERSION 0x10
|
||||
#endif /* CONFIG_WPS2 */
|
||||
|
||||
/* Diffie-Hellman 1536-bit MODP Group; RFC 3526, Group 5 */
|
||||
#define WPS_DH_GROUP (5)
|
||||
|
||||
#define WPS_UUID_LEN (16)
|
||||
#define WPS_NONCE_LEN (16)
|
||||
#define WPS_AUTHENTICATOR_LEN (8)
|
||||
#define WPS_AUTHKEY_LEN (32)
|
||||
#define WPS_KEYWRAPKEY_LEN (16)
|
||||
#define WPS_EMSK_LEN (32)
|
||||
#define WPS_PSK_LEN (16)
|
||||
#define WPS_SECRET_NONCE_LEN (16)
|
||||
#define WPS_HASH_LEN (32)
|
||||
#define WPS_KWA_LEN (8)
|
||||
#define WPS_MGMTAUTHKEY_LEN (32)
|
||||
#define WPS_MGMTENCKEY_LEN (16)
|
||||
#define WPS_MGMT_KEY_ID_LEN (16)
|
||||
#define WPS_OOB_DEVICE_PASSWORD_MIN_LEN (16)
|
||||
#define WPS_OOB_DEVICE_PASSWORD_LEN (32)
|
||||
#define WPS_OOB_PUBKEY_HASH_LEN (20)
|
||||
|
||||
/* Attribute Types */
|
||||
enum wps_attribute {
|
||||
ATTR_AP_CHANNEL = 0x1001,
|
||||
ATTR_ASSOC_STATE = 0x1002,
|
||||
ATTR_AUTH_TYPE = 0x1003,
|
||||
ATTR_AUTH_TYPE_FLAGS = 0x1004,
|
||||
ATTR_AUTHENTICATOR = 0x1005,
|
||||
ATTR_CONFIG_METHODS = 0x1008,
|
||||
ATTR_CONFIG_ERROR = 0x1009,
|
||||
ATTR_CONFIRM_URL4 = 0x100a,
|
||||
ATTR_CONFIRM_URL6 = 0x100b,
|
||||
ATTR_CONN_TYPE = 0x100c,
|
||||
ATTR_CONN_TYPE_FLAGS = 0x100d,
|
||||
ATTR_CRED = 0x100e,
|
||||
ATTR_ENCR_TYPE = 0x100f,
|
||||
ATTR_ENCR_TYPE_FLAGS = 0x1010,
|
||||
ATTR_DEV_NAME = 0x1011,
|
||||
ATTR_DEV_PASSWORD_ID = 0x1012,
|
||||
ATTR_E_HASH1 = 0x1014,
|
||||
ATTR_E_HASH2 = 0x1015,
|
||||
ATTR_E_SNONCE1 = 0x1016,
|
||||
ATTR_E_SNONCE2 = 0x1017,
|
||||
ATTR_ENCR_SETTINGS = 0x1018,
|
||||
ATTR_ENROLLEE_NONCE = 0x101a,
|
||||
ATTR_FEATURE_ID = 0x101b,
|
||||
ATTR_IDENTITY = 0x101c,
|
||||
ATTR_IDENTITY_PROOF = 0x101d,
|
||||
ATTR_KEY_WRAP_AUTH = 0x101e,
|
||||
ATTR_KEY_ID = 0x101f,
|
||||
ATTR_MAC_ADDR = 0x1020,
|
||||
ATTR_MANUFACTURER = 0x1021,
|
||||
ATTR_MSG_TYPE = 0x1022,
|
||||
ATTR_MODEL_NAME = 0x1023,
|
||||
ATTR_MODEL_NUMBER = 0x1024,
|
||||
ATTR_NETWORK_INDEX = 0x1026,
|
||||
ATTR_NETWORK_KEY = 0x1027,
|
||||
ATTR_NETWORK_KEY_INDEX = 0x1028,
|
||||
ATTR_NEW_DEVICE_NAME = 0x1029,
|
||||
ATTR_NEW_PASSWORD = 0x102a,
|
||||
ATTR_OOB_DEVICE_PASSWORD = 0x102c,
|
||||
ATTR_OS_VERSION = 0x102d,
|
||||
ATTR_POWER_LEVEL = 0x102f,
|
||||
ATTR_PSK_CURRENT = 0x1030,
|
||||
ATTR_PSK_MAX = 0x1031,
|
||||
ATTR_PUBLIC_KEY = 0x1032,
|
||||
ATTR_RADIO_ENABLE = 0x1033,
|
||||
ATTR_REBOOT = 0x1034,
|
||||
ATTR_REGISTRAR_CURRENT = 0x1035,
|
||||
ATTR_REGISTRAR_ESTABLISHED = 0x1036,
|
||||
ATTR_REGISTRAR_LIST = 0x1037,
|
||||
ATTR_REGISTRAR_MAX = 0x1038,
|
||||
ATTR_REGISTRAR_NONCE = 0x1039,
|
||||
ATTR_REQUEST_TYPE = 0x103a,
|
||||
ATTR_RESPONSE_TYPE = 0x103b,
|
||||
ATTR_RF_BANDS = 0x103c,
|
||||
ATTR_R_HASH1 = 0x103d,
|
||||
ATTR_R_HASH2 = 0x103e,
|
||||
ATTR_R_SNONCE1 = 0x103f,
|
||||
ATTR_R_SNONCE2 = 0x1040,
|
||||
ATTR_SELECTED_REGISTRAR = 0x1041,
|
||||
ATTR_SERIAL_NUMBER = 0x1042,
|
||||
ATTR_WPS_STATE = 0x1044,
|
||||
ATTR_SSID = 0x1045,
|
||||
ATTR_TOTAL_NETWORKS = 0x1046,
|
||||
ATTR_UUID_E = 0x1047,
|
||||
ATTR_UUID_R = 0x1048,
|
||||
ATTR_VENDOR_EXT = 0x1049,
|
||||
ATTR_VERSION = 0x104a,
|
||||
ATTR_X509_CERT_REQ = 0x104b,
|
||||
ATTR_X509_CERT = 0x104c,
|
||||
ATTR_EAP_IDENTITY = 0x104d,
|
||||
ATTR_MSG_COUNTER = 0x104e,
|
||||
ATTR_PUBKEY_HASH = 0x104f,
|
||||
ATTR_REKEY_KEY = 0x1050,
|
||||
ATTR_KEY_LIFETIME = 0x1051,
|
||||
ATTR_PERMITTED_CFG_METHODS = 0x1052,
|
||||
ATTR_SELECTED_REGISTRAR_CONFIG_METHODS = 0x1053,
|
||||
ATTR_PRIMARY_DEV_TYPE = 0x1054,
|
||||
ATTR_SECONDARY_DEV_TYPE_LIST = 0x1055,
|
||||
ATTR_PORTABLE_DEV = 0x1056,
|
||||
ATTR_AP_SETUP_LOCKED = 0x1057,
|
||||
ATTR_APPLICATION_EXT = 0x1058,
|
||||
ATTR_EAP_TYPE = 0x1059,
|
||||
ATTR_IV = 0x1060,
|
||||
ATTR_KEY_PROVIDED_AUTO = 0x1061,
|
||||
ATTR_802_1X_ENABLED = 0x1062,
|
||||
ATTR_APPSESSIONKEY = 0x1063,
|
||||
ATTR_WEPTRANSMITKEY = 0x1064,
|
||||
ATTR_REQUESTED_DEV_TYPE = 0x106a,
|
||||
ATTR_EXTENSIBILITY_TEST = 0x10fa /* _NOT_ defined in the spec */
|
||||
};
|
||||
|
||||
#define WPS_VENDOR_ID_WFA 14122
|
||||
|
||||
/* WFA Vendor Extension subelements */
|
||||
enum {
|
||||
WFA_ELEM_VERSION2 = 0x00,
|
||||
WFA_ELEM_AUTHORIZEDMACS = 0x01,
|
||||
WFA_ELEM_NETWORK_KEY_SHAREABLE = 0x02,
|
||||
WFA_ELEM_REQUEST_TO_ENROLL = 0x03,
|
||||
WFA_ELEM_SETTINGS_DELAY_TIME = 0x04
|
||||
};
|
||||
|
||||
/* Device Password ID */
|
||||
enum wps_dev_password_id {
|
||||
DEV_PW_DEFAULT = 0x0000,
|
||||
DEV_PW_USER_SPECIFIED = 0x0001,
|
||||
DEV_PW_MACHINE_SPECIFIED = 0x0002,
|
||||
DEV_PW_REKEY = 0x0003,
|
||||
DEV_PW_PUSHBUTTON = 0x0004,
|
||||
DEV_PW_REGISTRAR_SPECIFIED = 0x0005
|
||||
};
|
||||
|
||||
/* Message Type */
|
||||
enum wps_msg_type {
|
||||
WPS_START = 0x00,
|
||||
WPS_Beacon = 0x01,
|
||||
WPS_ProbeRequest = 0x02,
|
||||
WPS_ProbeResponse = 0x03,
|
||||
WPS_M1 = 0x04,
|
||||
WPS_M2 = 0x05,
|
||||
WPS_M2D = 0x06,
|
||||
WPS_M3 = 0x07,
|
||||
WPS_M4 = 0x08,
|
||||
WPS_M5 = 0x09,
|
||||
WPS_M6 = 0x0a,
|
||||
WPS_M7 = 0x0b,
|
||||
WPS_M8 = 0x0c,
|
||||
WPS_WSC_ACK = 0x0d,
|
||||
WPS_WSC_NACK = 0x0e,
|
||||
WPS_WSC_DONE = 0x0f
|
||||
};
|
||||
|
||||
/* Authentication Type Flags */
|
||||
#define WPS_AUTH_OPEN 0x0001
|
||||
#define WPS_AUTH_WPAPSK 0x0002
|
||||
#define WPS_AUTH_SHARED 0x0004
|
||||
#define WPS_AUTH_WPA 0x0008
|
||||
#define WPS_AUTH_WPA2 0x0010
|
||||
#define WPS_AUTH_WPA2PSK 0x0020
|
||||
#define WPS_AUTH_TYPES (WPS_AUTH_OPEN | WPS_AUTH_WPAPSK | WPS_AUTH_SHARED | \
|
||||
WPS_AUTH_WPA | WPS_AUTH_WPA2 | WPS_AUTH_WPA2PSK)
|
||||
|
||||
/* Encryption Type Flags */
|
||||
#define WPS_ENCR_NONE 0x0001
|
||||
#define WPS_ENCR_WEP 0x0002
|
||||
#define WPS_ENCR_TKIP 0x0004
|
||||
#define WPS_ENCR_AES 0x0008
|
||||
#define WPS_ENCR_TYPES (WPS_ENCR_NONE | WPS_ENCR_WEP | WPS_ENCR_TKIP | \
|
||||
WPS_ENCR_AES)
|
||||
|
||||
/* Configuration Error */
|
||||
enum wps_config_error {
|
||||
WPS_CFG_NO_ERROR = 0,
|
||||
WPS_CFG_OOB_IFACE_READ_ERROR = 1,
|
||||
WPS_CFG_DECRYPTION_CRC_FAILURE = 2,
|
||||
WPS_CFG_24_CHAN_NOT_SUPPORTED = 3,
|
||||
WPS_CFG_50_CHAN_NOT_SUPPORTED = 4,
|
||||
WPS_CFG_SIGNAL_TOO_WEAK = 5,
|
||||
WPS_CFG_NETWORK_AUTH_FAILURE = 6,
|
||||
WPS_CFG_NETWORK_ASSOC_FAILURE = 7,
|
||||
WPS_CFG_NO_DHCP_RESPONSE = 8,
|
||||
WPS_CFG_FAILED_DHCP_CONFIG = 9,
|
||||
WPS_CFG_IP_ADDR_CONFLICT = 10,
|
||||
WPS_CFG_NO_CONN_TO_REGISTRAR = 11,
|
||||
WPS_CFG_MULTIPLE_PBC_DETECTED = 12,
|
||||
WPS_CFG_ROGUE_SUSPECTED = 13,
|
||||
WPS_CFG_DEVICE_BUSY = 14,
|
||||
WPS_CFG_SETUP_LOCKED = 15,
|
||||
WPS_CFG_MSG_TIMEOUT = 16,
|
||||
WPS_CFG_REG_SESS_TIMEOUT = 17,
|
||||
WPS_CFG_DEV_PASSWORD_AUTH_FAILURE = 18
|
||||
};
|
||||
|
||||
/* RF Bands */
|
||||
#define WPS_RF_24GHZ (0x01)
|
||||
#define WPS_RF_50GHZ (0x02)
|
||||
|
||||
/* Config Methods */
|
||||
#define WPS_CONFIG_USBA (0x0001)
|
||||
#define WPS_CONFIG_ETHERNET (0x0002)
|
||||
#define WPS_CONFIG_LABEL (0x0004)
|
||||
#define WPS_CONFIG_DISPLAY (0x0008)
|
||||
#define WPS_CONFIG_EXT_NFC_TOKEN (0x0010)
|
||||
#define WPS_CONFIG_INT_NFC_TOKEN (0x0020)
|
||||
#define WPS_CONFIG_NFC_INTERFACE (0x0040)
|
||||
#define WPS_CONFIG_PUSHBUTTON (0x0080)
|
||||
#define WPS_CONFIG_KEYPAD (0x0100)
|
||||
|
||||
#ifdef CONFIG_WPS2
|
||||
#define WPS_CONFIG_VIRT_PUSHBUTTON (0x0280)
|
||||
#define WPS_CONFIG_PHY_PUSHBUTTON (0x0480)
|
||||
#define WPS_CONFIG_VIRT_DISPLAY (0x2008)
|
||||
#define WPS_CONFIG_PHY_DISPLAY (0x4008)
|
||||
#endif /* CONFIG_WPS2 */
|
||||
|
||||
/* Connection Type Flags */
|
||||
#define WPS_CONN_ESS (0x01)
|
||||
#define WPS_CONN_IBSS (0x02)
|
||||
|
||||
/* Wi-Fi Protected Setup State */
|
||||
enum wps_state {
|
||||
WPS_STATE_NOT_CONFIGURED = 1,
|
||||
WPS_STATE_CONFIGURED = 2
|
||||
};
|
||||
|
||||
/* Association State */
|
||||
enum wps_assoc_state {
|
||||
WPS_ASSOC_NOT_ASSOC = 0,
|
||||
WPS_ASSOC_CONN_SUCCESS = 1,
|
||||
WPS_ASSOC_CFG_FAILURE = 2,
|
||||
WPS_ASSOC_FAILURE = 3,
|
||||
WPS_ASSOC_IP_FAILURE = 4
|
||||
};
|
||||
|
||||
|
||||
#define WPS_DEV_OUI_WFA (0x0050f204)
|
||||
|
||||
enum wps_dev_categ {
|
||||
WPS_DEV_COMPUTER = 1,
|
||||
WPS_DEV_INPUT = 2,
|
||||
WPS_DEV_PRINTER = 3,
|
||||
WPS_DEV_CAMERA = 4,
|
||||
WPS_DEV_STORAGE = 5,
|
||||
WPS_DEV_NETWORK_INFRA = 6,
|
||||
WPS_DEV_DISPLAY = 7,
|
||||
WPS_DEV_MULTIMEDIA = 8,
|
||||
WPS_DEV_GAMING = 9,
|
||||
WPS_DEV_PHONE = 10
|
||||
};
|
||||
|
||||
enum wps_dev_subcateg {
|
||||
WPS_DEV_COMPUTER_PC = 1,
|
||||
WPS_DEV_COMPUTER_SERVER = 2,
|
||||
WPS_DEV_COMPUTER_MEDIA_CENTER = 3,
|
||||
|
||||
WPS_DEV_PRINTER_PRINTER = 1,
|
||||
WPS_DEV_PRINTER_SCANNER = 2,
|
||||
|
||||
WPS_DEV_CAMERA_DIGITAL_STILL_CAMERA = 1,
|
||||
|
||||
WPS_DEV_STORAGE_NAS = 1,
|
||||
|
||||
WPS_DEV_NETWORK_INFRA_AP = 1,
|
||||
WPS_DEV_NETWORK_INFRA_ROUTER = 2,
|
||||
WPS_DEV_NETWORK_INFRA_SWITCH = 3,
|
||||
|
||||
WPS_DEV_DISPLAY_TV = 1,
|
||||
WPS_DEV_DISPLAY_PICTURE_FRAME = 2,
|
||||
WPS_DEV_DISPLAY_PROJECTOR = 3,
|
||||
|
||||
WPS_DEV_MULTIMEDIA_DAR = 1,
|
||||
WPS_DEV_MULTIMEDIA_PVR = 2,
|
||||
WPS_DEV_MULTIMEDIA_MCX = 3,
|
||||
|
||||
WPS_DEV_GAMING_XBOX = 1,
|
||||
WPS_DEV_GAMING_XBOX360 = 2,
|
||||
WPS_DEV_GAMING_PLAYSTATION = 3,
|
||||
|
||||
WPS_DEV_PHONE_WINDOWS_MOBILE = 1
|
||||
};
|
||||
|
||||
|
||||
/* Request Type */
|
||||
enum wps_request_type {
|
||||
WPS_REQ_ENROLLEE_INFO = 0,
|
||||
WPS_REQ_ENROLLEE = 1,
|
||||
WPS_REQ_REGISTRAR = 2,
|
||||
WPS_REQ_WLAN_MANAGER_REGISTRAR = 3
|
||||
};
|
||||
|
||||
/* Response Type */
|
||||
enum wps_response_type {
|
||||
WPS_RESP_ENROLLEE_INFO = 0,
|
||||
WPS_RESP_ENROLLEE = 1,
|
||||
WPS_RESP_REGISTRAR = 2,
|
||||
WPS_RESP_AP = 3
|
||||
};
|
||||
|
||||
/* Walk Time for push button configuration (in seconds) */
|
||||
#define WPS_PBC_WALK_TIME (120)
|
||||
|
||||
#define WPS_MAX_AUTHORIZED_MACS (5)
|
||||
|
||||
#endif /* WPS_DEFS_H */
|
||||
|
||||
|
|
@ -0,0 +1,606 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "main.h"
|
||||
#include "queue.h"
|
||||
#include "utils/os.h"
|
||||
#include <lwip_netconf.h>
|
||||
#include <lwip/netif.h>
|
||||
#include "wifi/wifi_conf.h"
|
||||
#include <platform/platform_stdlib.h>
|
||||
|
||||
#define WLAN0_NAME "wlan0"
|
||||
#ifndef ENABLE
|
||||
#define ENABLE (1)
|
||||
#endif
|
||||
#ifndef DISABLE
|
||||
#define DISABLE (0)
|
||||
#endif
|
||||
|
||||
u8 eap_phase = 0;
|
||||
u8 eap_method = 0;
|
||||
|
||||
// eap config arguments
|
||||
char *eap_target_ssid = NULL;
|
||||
char *eap_identity = NULL;
|
||||
char *eap_password = NULL;
|
||||
// if set eap_ca_cert and defined(EAP_SSL_VERIFY_SERVER), client will verify server's cert
|
||||
const unsigned char *eap_ca_cert = NULL;
|
||||
// if set eap_client_cert, eap_client_key, and defined(EAP_SSL_VERIFY_CLIENT), client will send its cert to server
|
||||
const unsigned char *eap_client_cert = NULL;
|
||||
const unsigned char *eap_client_key = NULL;
|
||||
char *eap_client_key_pwd = NULL;
|
||||
|
||||
void eap_eapol_recvd_hdl(char *buf, int buf_len, int flags, void* handler_user_data);
|
||||
void eap_eapol_start_hdl(char *buf, int buf_len, int flags, void* handler_user_data);
|
||||
static int connect_by_open_system(char *target_ssid);
|
||||
|
||||
void set_eap_phase(unsigned char is_trigger_eap){
|
||||
eap_phase = is_trigger_eap;
|
||||
}
|
||||
|
||||
int get_eap_phase(void){
|
||||
return eap_phase;
|
||||
}
|
||||
|
||||
int get_eap_method(void){
|
||||
return eap_method;
|
||||
}
|
||||
|
||||
void reset_config(void){
|
||||
eap_target_ssid = NULL;
|
||||
eap_identity = NULL;
|
||||
eap_password = NULL;
|
||||
eap_ca_cert = NULL;
|
||||
eap_client_cert = NULL;
|
||||
eap_client_key = NULL;
|
||||
eap_client_key_pwd = NULL;
|
||||
}
|
||||
|
||||
void judge_station_disconnect(void)
|
||||
{
|
||||
int mode = 0;
|
||||
unsigned char ssid[33];
|
||||
|
||||
wext_get_mode(WLAN0_NAME, &mode);
|
||||
|
||||
switch(mode) {
|
||||
case IW_MODE_MASTER: //In AP mode
|
||||
wifi_off();
|
||||
vTaskDelay(20);
|
||||
wifi_on(RTW_MODE_STA);
|
||||
break;
|
||||
case IW_MODE_INFRA: //In STA mode
|
||||
if(wext_get_ssid(WLAN0_NAME, ssid) > 0)
|
||||
wifi_disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void eap_disconnected_hdl(char *buf, int buf_len, int flags, void* handler_user_data){
|
||||
// printf("disconnected\n");
|
||||
wifi_unreg_event_handler(WIFI_EVENT_EAPOL_RECVD, eap_eapol_recvd_hdl);
|
||||
wifi_unreg_event_handler(WIFI_EVENT_DISCONNECT, eap_disconnected_hdl);
|
||||
eap_peer_unregister_methods();
|
||||
eap_sm_deinit();
|
||||
//reset_config();
|
||||
}
|
||||
|
||||
/*
|
||||
void eap_config(void){
|
||||
eap_target_ssid = "Test_eap";
|
||||
eap_identity = "guest2";
|
||||
eap_password = "test2";
|
||||
|
||||
eap_client_cert = \
|
||||
"-----BEGIN CERTIFICATE-----\r\n" \
|
||||
"MIIC9zCCAd8CAQMwDQYJKoZIhvcNAQEEBQAwgZMxCzAJBgNVBAYTAkZSMQ8wDQYD\r\n" \
|
||||
"VQQIEwZSYWRpdXMxEjAQBgNVBAcTCVNvbWV3aGVyZTEVMBMGA1UEChMMRXhhbXBs\r\n" \
|
||||
"ZSBJbmMuMSAwHgYJKoZIhvcNAQkBFhFhZG1pbkBleGFtcGxlLmNvbTEmMCQGA1UE\r\n" \
|
||||
"AxMdRXhhbXBsZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMTYwMzE1MDgwNzEx\r\n" \
|
||||
"WhcNMTcwMzE1MDgwNzExWjBzMQswCQYDVQQGEwJGUjEPMA0GA1UECBMGUmFkaXVz\r\n" \
|
||||
"MRUwEwYDVQQKEwxFeGFtcGxlIEluYy4xGjAYBgNVBAMUEXVzZXIyQGV4YW1wbGUu\r\n" \
|
||||
"Y29tMSAwHgYJKoZIhvcNAQkBFhF1c2VyMkBleGFtcGxlLmNvbTCBnzANBgkqhkiG\r\n" \
|
||||
"9w0BAQEFAAOBjQAwgYkCgYEAqESlV4OYfBcIgZ+Cs8mWpiBjhvKoa0/kIe7saqhC\r\n" \
|
||||
"e5q4snox0jdkUpLcc4vOs3vQ7ZGnimqTltA9oF6XNUzTWW4vlJTKEfrCWK085l7c\r\n" \
|
||||
"DHFvHavH3E6vuP71lI7jq4PLXbo2TvZK+uBul4ozjzVWihaZBtz8eLHq446h/D/p\r\n" \
|
||||
"kzkCAwEAATANBgkqhkiG9w0BAQQFAAOCAQEAAfhVAIkNdeeUNJud720uUHVnIcxz\r\n" \
|
||||
"GXWI+Svi1qchuTEnRNhLwXmnE+A0WWSHyfdR6FvzdT3xtz3K50iOif8jY2gCGkSK\r\n" \
|
||||
"8RjKr97228SwbrGO9y9+dYIjH1uz9cBpoVKcpzdsWpKObrDPDYyReHSWo99jM2+O\r\n" \
|
||||
"vfJxnBw4PLiBj7Q0/dpd6o4JXyp7Cxa0mB4/+cZqjCzzuKfuK3WP7j6laMCV6mg4\r\n" \
|
||||
"wRZ528IdwDqB7OOqsDm1PVQM8vzny9PM6ikWUCRTVNQJN8RDLkrHR3FRjy15YLdt\r\n" \
|
||||
"yOfDqVnT/z0wGBaxnNziSJjqPGHPpRi4bJFGXwXOhtknKmciKzfj9/npoQ==\r\n" \
|
||||
"-----END CERTIFICATE-----\r\n";
|
||||
|
||||
eap_client_key = \
|
||||
"-----BEGIN RSA PRIVATE KEY-----\r\n" \
|
||||
"MIICXQIBAAKBgQCoRKVXg5h8FwiBn4KzyZamIGOG8qhrT+Qh7uxqqEJ7mriyejHS\r\n" \
|
||||
"N2RSktxzi86ze9DtkaeKapOW0D2gXpc1TNNZbi+UlMoR+sJYrTzmXtwMcW8dq8fc\r\n" \
|
||||
"Tq+4/vWUjuOrg8tdujZO9kr64G6XijOPNVaKFpkG3Px4serjjqH8P+mTOQIDAQAB\r\n" \
|
||||
"AoGARI+LyweshssfxSkIKVc3EcNaqi6PHwJzUrw2ChM624AkR1xwllXJg7ehKVdK\r\n" \
|
||||
"xmjprRLO8CASuL1qjsBb3fTKnBl+sIVxIFS0AI4Y3ri8VUKbangvSsI7pCzAFry7\r\n" \
|
||||
"p1gmy9WWRV2ZEa+dV8xcrjb3bloT7hcdeLehgBCvExJIQM0CQQDXlSAKdW3AhYyj\r\n" \
|
||||
"1A+pfyBSGxJbpSwNyyWgwHIHHjxendxmdUbrc8EbAu1eNKbP58TLgdCZsKcMonAv\r\n" \
|
||||
"MY1Y2/nnAkEAx9CrUaCU8pJqXTRypM5JtexLKnYMJhpnA9uUILBQOq4Oe0eruyF5\r\n" \
|
||||
"SaSxhyJYXY491ahWYPF0PTb3jkUhoN+l3wJBAJZthjgGDJlEFwjSFkOtYz4nib3N\r\n" \
|
||||
"GVpeoFj1MBvrazCScpJDz0LIOLzCZCNSFfwIu3dNk+NKMqZMSn+D0h9pD40CQQC5\r\n" \
|
||||
"K9n4NXaTLbjAU2CC9mE85JPr76XmkcUxwAWQHZTcLH1jJdIyAx1hb+zNLLjzSmRn\r\n" \
|
||||
"Yi9ae6ibKhtUjyBQ87HFAkA2Bb3z7NUx+AA2g2HZocFZFShBxylACyQkl8FAFZtf\r\n" \
|
||||
"osudmKdFQHyAWuBMex4tpz/OLTqJ1ecL1JQeC7OvlpEX\r\n" \
|
||||
"-----END RSA PRIVATE KEY-----\r\n";
|
||||
|
||||
eap_ca_cert = \
|
||||
"-----BEGIN CERTIFICATE-----\r\n" \
|
||||
"MIIEpzCCA4+gAwIBAgIJAPvZaozpdfjkMA0GCSqGSIb3DQEBCwUAMIGTMQswCQYD\r\n" \
|
||||
"VQQGEwJGUjEPMA0GA1UECBMGUmFkaXVzMRIwEAYDVQQHEwlTb21ld2hlcmUxFTAT\r\n" \
|
||||
"BgNVBAoTDEV4YW1wbGUgSW5jLjEgMB4GCSqGSIb3DQEJARYRYWRtaW5AZXhhbXBs\r\n" \
|
||||
"ZS5jb20xJjAkBgNVBAMTHUV4YW1wbGUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4X\r\n" \
|
||||
"DTE2MDMxNDExMjU0OVoXDTE2MDQxMzExMjU0OVowgZMxCzAJBgNVBAYTAkZSMQ8w\r\n" \
|
||||
"DQYDVQQIEwZSYWRpdXMxEjAQBgNVBAcTCVNvbWV3aGVyZTEVMBMGA1UEChMMRXhh\r\n" \
|
||||
"bXBsZSBJbmMuMSAwHgYJKoZIhvcNAQkBFhFhZG1pbkBleGFtcGxlLmNvbTEmMCQG\r\n" \
|
||||
"A1UEAxMdRXhhbXBsZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0GCSqGSIb3\r\n" \
|
||||
"DQEBAQUAA4IBDwAwggEKAoIBAQC9pireu0aCDLNfMaGv3vId7RXjUhQwSK0jV2Oc\r\n" \
|
||||
"SyvlKWH3P/N+5kLrP2iL6SCzyETVDXZ0vOsAMjcBF0zHp16prXV0d51cTUqeWBb0\r\n" \
|
||||
"I5UnGxleIuuOfSg8zLUJoBWZPqLv++eZ5WgOKHt7SXocjvg7TU5t/TMB0Y8OCz3H\r\n" \
|
||||
"CW2vJ/XKMgMA9HDUu4g57cJu88i1JPRpyFaz/HIQBc7+UNb9z+q09uTZKWTmEMqi\r\n" \
|
||||
"E2U0EEIs7EtbxnOze1/8C4XNlmztrEdwvu6UEBU/TFkUoh9M646NkkBK7wP9n9pv\r\n" \
|
||||
"T0nPQRJiiCrICzVqUtlEi9lIKpbBSMbQ0KzrGF7lGTgm4rz9AgMBAAGjgfswgfgw\r\n" \
|
||||
"HQYDVR0OBBYEFIVyecka74kvOKIW0BjlTc/B+a2NMIHIBgNVHSMEgcAwgb2AFIVy\r\n" \
|
||||
"ecka74kvOKIW0BjlTc/B+a2NoYGZpIGWMIGTMQswCQYDVQQGEwJGUjEPMA0GA1UE\r\n" \
|
||||
"CBMGUmFkaXVzMRIwEAYDVQQHEwlTb21ld2hlcmUxFTATBgNVBAoTDEV4YW1wbGUg\r\n" \
|
||||
"SW5jLjEgMB4GCSqGSIb3DQEJARYRYWRtaW5AZXhhbXBsZS5jb20xJjAkBgNVBAMT\r\n" \
|
||||
"HUV4YW1wbGUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5ggkA+9lqjOl1+OQwDAYDVR0T\r\n" \
|
||||
"BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAZYHM26sxbKOckVqJJ1QY0U2QFlGP\r\n" \
|
||||
"1GYd8v27znxdnRmSonDvv3GjFfhwoyDk0JUuxkK/33ikCxihrgoO/EQTY9BV2OpW\r\n" \
|
||||
"qkB1PDtb3i5ZRNvfjmW0pVA4p+GmdTGaEE5pTlcVnorzVrUeFKaZakb+IDFYzmeF\r\n" \
|
||||
"xp8B3Bb5wvinDligLOaJnSlgS8QeeIab9HZfaVTTuPmVK6zE6D54Y0dJPnykvDdE\r\n" \
|
||||
"cGN0FC+migfilFjJgkDJ0r78nwes55L8zjoofiZuO03rrHww6ARc3v1jYzAufddk\r\n" \
|
||||
"QTiZHgjlMQb2XXMmXLn8kBgoDnqkXFNe8j0h8uxIJSrjOoIyn1h1wvX5/w==\r\n" \
|
||||
"-----END CERTIFICATE-----\r\n";
|
||||
}
|
||||
*/
|
||||
|
||||
int eap_start(char *method){
|
||||
#ifdef CONFIG_ENABLE_EAP
|
||||
int ret = -1;
|
||||
|
||||
//unsigned long tick1 = xTaskGetTickCount();
|
||||
//unsigned long tick2;
|
||||
|
||||
if(rltk_wlan_running(WLAN1_IDX)){
|
||||
printf("\n\rNot support con-current mode!\n\r");
|
||||
return -1;
|
||||
}
|
||||
|
||||
judge_station_disconnect();
|
||||
|
||||
#if CONFIG_ENABLE_PEAP
|
||||
if(strcmp(method,"peap") == 0){
|
||||
ret = set_eap_peap_method();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_ENABLE_TLS
|
||||
if(strcmp(method,"tls") == 0){
|
||||
ret = set_eap_tls_method();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_ENABLE_TTLS
|
||||
if(strcmp(method,"ttls") == 0){
|
||||
ret = set_eap_ttls_method();
|
||||
}
|
||||
#endif
|
||||
|
||||
if(ret == -1){
|
||||
printf("\r\neap method %s not supported\r\n", method);
|
||||
return -1;
|
||||
}
|
||||
|
||||
eap_method = get_eap_ctx_method();
|
||||
|
||||
printf("\n==================== %s_start ====================\n", method);
|
||||
|
||||
//eap_config();
|
||||
|
||||
set_eap_phase(ENABLE);
|
||||
wifi_reg_event_handler(WIFI_EVENT_EAPOL_START, eap_eapol_start_hdl, NULL);
|
||||
wifi_reg_event_handler(WIFI_EVENT_EAPOL_RECVD, eap_eapol_recvd_hdl, NULL);
|
||||
|
||||
|
||||
|
||||
ret = connect_by_open_system(eap_target_ssid);
|
||||
|
||||
#if CONFIG_LWIP_LAYER
|
||||
/* Start DHCPClient */
|
||||
if(ret == 0)
|
||||
LwIP_DHCP(0, DHCP_START);
|
||||
#endif
|
||||
|
||||
wifi_unreg_event_handler(WIFI_EVENT_EAPOL_START, eap_eapol_start_hdl);
|
||||
|
||||
// for re-authentication when session timeout
|
||||
wifi_reg_event_handler(WIFI_EVENT_DISCONNECT, eap_disconnected_hdl, NULL);
|
||||
//wifi_unreg_event_handler(WIFI_EVENT_EAPOL_RECVD, eap_eapol_recvd_hdl);
|
||||
|
||||
set_eap_phase(DISABLE);
|
||||
|
||||
// eap failed, disconnect
|
||||
if(ret != 0){
|
||||
judge_station_disconnect();
|
||||
eap_disconnected_hdl(NULL, 0, 0, NULL);
|
||||
rtw_msleep_os(200); //wait handler done
|
||||
printf("\r\nERROR: connect to AP by %s failed\n", method);
|
||||
}
|
||||
|
||||
eap_sm_deinit();
|
||||
printf("\n==================== %s_finish ====================\n", method);
|
||||
|
||||
//tick2 = xTaskGetTickCount();
|
||||
//printf("\r\nConnected after %dms.\n", (tick2-tick1));
|
||||
|
||||
return ret;
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int connect_by_open_system(char *target_ssid)
|
||||
{
|
||||
int retry_count = 0, ret;
|
||||
|
||||
if (target_ssid != NULL) {
|
||||
while (1) {
|
||||
rtw_msleep_os(500); //wait scan complete.
|
||||
ret = wifi_connect(target_ssid,
|
||||
RTW_SECURITY_OPEN,
|
||||
NULL,
|
||||
strlen(target_ssid),
|
||||
0,
|
||||
0,
|
||||
NULL);
|
||||
if (ret == RTW_SUCCESS) {
|
||||
//printf("\r\n[EAP]Associate with AP success\n");
|
||||
break;
|
||||
}
|
||||
if (retry_count == 0) {
|
||||
//printf("\r\n[EAP]Associate with AP failed %d\n", ret);
|
||||
return -1;
|
||||
}
|
||||
retry_count --;
|
||||
printf("Retry connection...\n");
|
||||
|
||||
judge_station_disconnect();
|
||||
set_eap_phase(ENABLE);
|
||||
}
|
||||
} else {
|
||||
printf("\r\n[EAP]Target SSID is NULL\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void eap_autoreconnect_thread(void *method)
|
||||
{
|
||||
eap_start((char*)method);
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void eap_autoreconnect_hdl(u8 method_id){
|
||||
#ifdef CONFIG_ENABLE_EAP
|
||||
char *method;
|
||||
switch(method_id){
|
||||
case 25: // EAP_TYPE_PEAP
|
||||
method = "peap";
|
||||
break;
|
||||
case 13: // EAP_TYPE_TLS
|
||||
method = "tls";
|
||||
break;
|
||||
case 21: // EAP_TYPE_TTLS
|
||||
method = "ttls";
|
||||
break;
|
||||
default:
|
||||
printf("invalid eap method\n");
|
||||
return;
|
||||
}
|
||||
if(xTaskCreate(eap_autoreconnect_thread, ((const char*)"eap_autoreconnect_thread"), 1024, (void*) method, tskIDLE_PRIORITY + 1, NULL) != pdPASS)
|
||||
printf("\n\r%s xTaskCreate failed\n", __FUNCTION__);
|
||||
#endif
|
||||
}
|
||||
|
||||
// copy from ssl_client_ext.c
|
||||
#if CONFIG_USE_POLARSSL
|
||||
|
||||
#include <polarssl/ssl.h>
|
||||
#include <polarssl/memory.h>
|
||||
|
||||
int max_buf_bio_size = SSL_BUFFER_LEN;
|
||||
|
||||
#if ENABLE_EAP_SSL_VERIFY_CLIENT
|
||||
static x509_crt* _cli_crt = NULL;
|
||||
static pk_context* _clikey_rsa = NULL;
|
||||
#endif
|
||||
|
||||
#if ENABLE_EAP_SSL_VERIFY_SERVER
|
||||
static x509_crt* _ca_crt = NULL;
|
||||
|
||||
static int eap_verify(void *data, x509_crt *crt, int depth, int *flags)
|
||||
{
|
||||
|
||||
//char buf[1024];
|
||||
((void) data);
|
||||
|
||||
printf("\nVerify requested for (Depth %d):\n", depth);
|
||||
//x509_crt_info(buf, sizeof(buf) - 1, "", crt);
|
||||
//printf("%s", buf);
|
||||
|
||||
if(((*flags) & BADCERT_EXPIRED) != 0)
|
||||
printf("server certificate has expired\n");
|
||||
|
||||
if(((*flags) & BADCERT_REVOKED) != 0)
|
||||
printf(" ! server certificate has been revoked\n");
|
||||
|
||||
if(((*flags) & BADCERT_CN_MISMATCH) != 0)
|
||||
printf(" ! CN mismatch\n");
|
||||
|
||||
if(((*flags) & BADCERT_NOT_TRUSTED) != 0)
|
||||
printf(" ! self-signed or not signed by a trusted CA\n");
|
||||
|
||||
if(((*flags) & BADCRL_NOT_TRUSTED) != 0)
|
||||
printf(" ! CRL not trusted\n");
|
||||
|
||||
if(((*flags) & BADCRL_EXPIRED) != 0)
|
||||
printf(" ! CRL expired\n");
|
||||
|
||||
if(((*flags) & BADCERT_OTHER) != 0)
|
||||
printf(" ! other (unknown) flag\n");
|
||||
|
||||
if((*flags) == 0)
|
||||
printf(" Certificate verified without error flags\n");
|
||||
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
int eap_cert_init(void)
|
||||
{
|
||||
#if ENABLE_EAP_SSL_VERIFY_CLIENT
|
||||
if(eap_client_cert != NULL && eap_client_key != NULL){
|
||||
_cli_crt = polarssl_malloc(sizeof(x509_crt));
|
||||
|
||||
if(_cli_crt)
|
||||
x509_crt_init(_cli_crt);
|
||||
else
|
||||
return -1;
|
||||
|
||||
_clikey_rsa = polarssl_malloc(sizeof(pk_context));
|
||||
|
||||
if(_clikey_rsa)
|
||||
pk_init(_clikey_rsa);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_EAP_SSL_VERIFY_SERVER
|
||||
if(eap_ca_cert != NULL){
|
||||
_ca_crt = polarssl_malloc(sizeof(x509_crt));
|
||||
|
||||
if(_ca_crt)
|
||||
x509_crt_init(_ca_crt);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void eap_client_cert_free(void)
|
||||
{
|
||||
#if ENABLE_EAP_SSL_VERIFY_CLIENT
|
||||
if(eap_client_cert != NULL && eap_client_key != NULL){
|
||||
if(_cli_crt) {
|
||||
x509_crt_free(_cli_crt);
|
||||
polarssl_free(_cli_crt);
|
||||
_cli_crt = NULL;
|
||||
}
|
||||
|
||||
if(_clikey_rsa) {
|
||||
pk_free(_clikey_rsa);
|
||||
polarssl_free(_clikey_rsa);
|
||||
_clikey_rsa = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void eap_server_cert_free(void)
|
||||
{
|
||||
#if ENABLE_EAP_SSL_VERIFY_SERVER
|
||||
if(eap_ca_cert != NULL){
|
||||
if(_ca_crt) {
|
||||
x509_crt_free(_ca_crt);
|
||||
polarssl_free(_ca_crt);
|
||||
_ca_crt = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int eap_cert_setup(ssl_context *ssl)
|
||||
{
|
||||
#if ENABLE_EAP_SSL_VERIFY_CLIENT
|
||||
if(eap_client_cert != NULL && eap_client_key != NULL){
|
||||
if(x509_crt_parse(_cli_crt, eap_client_cert, strlen(eap_client_cert)) != 0)
|
||||
return -1;
|
||||
|
||||
if(pk_parse_key(_clikey_rsa, eap_client_key, strlen(eap_client_key), eap_client_key_pwd, strlen(eap_client_key_pwd)) != 0)
|
||||
return -1;
|
||||
|
||||
ssl_set_own_cert(ssl, _cli_crt, _clikey_rsa);
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_EAP_SSL_VERIFY_SERVER
|
||||
if(eap_ca_cert != NULL){
|
||||
if(x509_crt_parse(_ca_crt, eap_ca_cert, strlen(eap_ca_cert)) != 0)
|
||||
return -1;
|
||||
ssl_set_ca_chain(ssl, _ca_crt, NULL, NULL);
|
||||
ssl_set_authmode(ssl, SSL_VERIFY_REQUIRED);
|
||||
ssl_set_verify(ssl, eap_verify, NULL);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif CONFIG_USE_MBEDTLS
|
||||
|
||||
#include <mbedtls/config.h>
|
||||
#include <mbedtls/platform.h>
|
||||
#include <mbedtls/ssl.h>
|
||||
#include <mbedtls/ssl_internal.h>
|
||||
|
||||
int max_buf_bio_size = MBEDTLS_SSL_BUFFER_LEN;
|
||||
|
||||
struct eap_tls{
|
||||
void *ssl;
|
||||
void *conf;
|
||||
void *fd;
|
||||
};
|
||||
|
||||
#if ENABLE_EAP_SSL_VERIFY_CLIENT
|
||||
static mbedtls_x509_crt* _cli_crt = NULL;
|
||||
static mbedtls_pk_context* _clikey_rsa = NULL;
|
||||
#endif
|
||||
|
||||
#if ENABLE_EAP_SSL_VERIFY_SERVER
|
||||
static mbedtls_x509_crt* _ca_crt = NULL;
|
||||
|
||||
static int eap_verify(void *data, mbedtls_x509_crt *crt, int depth, int *flags)
|
||||
{
|
||||
|
||||
//char buf[1024];
|
||||
((void) data);
|
||||
|
||||
printf("\nVerify requested for (Depth %d):\n", depth);
|
||||
//mbedtls_x509_crt_info(buf, sizeof(buf) - 1, "", crt);
|
||||
//printf("%s", buf);
|
||||
|
||||
if(((*flags) & MBEDTLS_X509_BADCERT_EXPIRED) != 0)
|
||||
printf("server certificate has expired\n");
|
||||
|
||||
if(((*flags) & MBEDTLS_X509_BADCERT_REVOKED) != 0)
|
||||
printf(" ! server certificate has been revoked\n");
|
||||
|
||||
if(((*flags) & MBEDTLS_X509_BADCERT_CN_MISMATCH) != 0)
|
||||
printf(" ! CN mismatch\n");
|
||||
|
||||
if(((*flags) & MBEDTLS_X509_BADCERT_NOT_TRUSTED) != 0)
|
||||
printf(" ! self-signed or not signed by a trusted CA\n");
|
||||
|
||||
if(((*flags) & MBEDTLS_X509_BADCRL_NOT_TRUSTED) != 0)
|
||||
printf(" ! CRL not trusted\n");
|
||||
|
||||
if(((*flags) & MBEDTLS_X509_BADCRL_EXPIRED) != 0)
|
||||
printf(" ! CRL expired\n");
|
||||
|
||||
if(((*flags) & MBEDTLS_X509_BADCERT_OTHER) != 0)
|
||||
printf(" ! other (unknown) flag\n");
|
||||
|
||||
if((*flags) == 0)
|
||||
printf(" Certificate verified without error flags\n");
|
||||
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
int eap_cert_init(void)
|
||||
{
|
||||
#if ENABLE_EAP_SSL_VERIFY_CLIENT
|
||||
if(eap_client_cert != NULL && eap_client_key != NULL){
|
||||
_cli_crt = mbedtls_calloc(1, sizeof(mbedtls_x509_crt));
|
||||
|
||||
if(_cli_crt)
|
||||
mbedtls_x509_crt_init(_cli_crt);
|
||||
else
|
||||
return -1;
|
||||
|
||||
_clikey_rsa = mbedtls_calloc(1, sizeof(mbedtls_pk_context));
|
||||
|
||||
if(_clikey_rsa)
|
||||
mbedtls_pk_init(_clikey_rsa);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_EAP_SSL_VERIFY_SERVER
|
||||
if(eap_ca_cert != NULL){
|
||||
_ca_crt = mbedtls_calloc(1, sizeof(mbedtls_x509_crt));
|
||||
|
||||
if(_ca_crt)
|
||||
mbedtls_x509_crt_init(_ca_crt);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void eap_client_cert_free(void)
|
||||
{
|
||||
#if ENABLE_EAP_SSL_VERIFY_CLIENT
|
||||
if(eap_client_cert != NULL && eap_client_key != NULL){
|
||||
if(_cli_crt) {
|
||||
mbedtls_x509_crt_free(_cli_crt);
|
||||
mbedtls_free(_cli_crt);
|
||||
_cli_crt = NULL;
|
||||
}
|
||||
|
||||
if(_clikey_rsa) {
|
||||
mbedtls_pk_free(_clikey_rsa);
|
||||
mbedtls_free(_clikey_rsa);
|
||||
_clikey_rsa = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void eap_server_cert_free(void)
|
||||
{
|
||||
#if ENABLE_EAP_SSL_VERIFY_SERVER
|
||||
if(eap_ca_cert != NULL){
|
||||
if(_ca_crt) {
|
||||
mbedtls_x509_crt_free(_ca_crt);
|
||||
mbedtls_free(_ca_crt);
|
||||
_ca_crt = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int eap_cert_setup(struct eap_tls *tls_context)
|
||||
{
|
||||
#if ENABLE_EAP_SSL_VERIFY_CLIENT
|
||||
if(eap_client_cert != NULL && eap_client_key != NULL){
|
||||
if(mbedtls_x509_crt_parse(_cli_crt, eap_client_cert, strlen(eap_client_cert)+1) != 0)
|
||||
return -1;
|
||||
|
||||
if(mbedtls_pk_parse_key(_clikey_rsa, eap_client_key, strlen(eap_client_key)+1, eap_client_key_pwd, strlen(eap_client_key_pwd)+1) != 0)
|
||||
return -1;
|
||||
|
||||
mbedtls_ssl_conf_own_cert(tls_context->conf, _cli_crt, _clikey_rsa);
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_EAP_SSL_VERIFY_SERVER
|
||||
if(eap_ca_cert != NULL){
|
||||
if(mbedtls_x509_crt_parse(_ca_crt, eap_ca_cert, strlen(eap_ca_cert)+1) != 0)
|
||||
return -1;
|
||||
mbedtls_ssl_conf_ca_chain(tls_context->conf, _ca_crt, NULL);
|
||||
mbedtls_ssl_conf_authmode(tls_context->conf, MBEDTLS_SSL_VERIFY_REQUIRED);
|
||||
mbedtls_ssl_conf_verify(tls_context->conf, eap_verify, NULL);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /*CONFIG_USE_MBEDTLS*/
|
||||
|
|
@ -0,0 +1,269 @@
|
|||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
#include "utils/os.h"
|
||||
#include <lwip/netif.h>
|
||||
#include <wifi/wifi_conf.h>
|
||||
#include "wps/wps_defs.h"
|
||||
|
||||
#if CONFIG_ENABLE_P2P
|
||||
enum p2p_wps_method {
|
||||
WPS_NOT_READY, WPS_PIN_DISPLAY, WPS_PIN_KEYPAD, WPS_PBC
|
||||
};
|
||||
|
||||
/*NETMASK*/
|
||||
#define P2P_NETMASK_ADDR0 255
|
||||
#define P2P_NETMASK_ADDR1 255
|
||||
#define P2P_NETMASK_ADDR2 255
|
||||
#define P2P_NETMASK_ADDR3 0
|
||||
|
||||
/*Gateway Address*/
|
||||
#define P2P_GW_ADDR0 192
|
||||
#define P2P_GW_ADDR1 168
|
||||
#define P2P_GW_ADDR2 42
|
||||
#define P2P_GW_ADDR3 1
|
||||
|
||||
#define P2P_GO_NEGO_RESULT_SIZE 376//256
|
||||
|
||||
xqueue_handle_t queue_for_p2p_nego;
|
||||
|
||||
extern void dhcps_init(struct netif * pnetif);
|
||||
|
||||
static int hex2num(char c)
|
||||
{
|
||||
if (c >= '0' && c <= '9')
|
||||
return c - '0';
|
||||
if (c >= 'a' && c <= 'f')
|
||||
return c - 'a' + 10;
|
||||
if (c >= 'A' && c <= 'F')
|
||||
return c - 'A' + 10;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* hwaddr_aton - Convert ASCII string to MAC address (colon-delimited format)
|
||||
* @txt: MAC address as a string (e.g., "00:11:22:33:44:55")
|
||||
* @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes)
|
||||
* Returns: 0 on success, -1 on failure (e.g., string not a MAC address)
|
||||
*/
|
||||
int hwaddr_aton(const char *txt, u8 *addr)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
int a, b;
|
||||
|
||||
a = hex2num(*txt++);
|
||||
if (a < 0)
|
||||
return -1;
|
||||
b = hex2num(*txt++);
|
||||
if (b < 0)
|
||||
return -1;
|
||||
*addr++ = (a << 4) | b;
|
||||
if (i < 5 && *txt++ != ':')
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wifi_start_p2p_go(char *ssid, char *passphrase, u8 channel)
|
||||
{
|
||||
extern struct netif xnetif[NET_IF_NUM];
|
||||
struct netif * pnetif = &xnetif[0];
|
||||
struct ip_addr ipaddr;
|
||||
struct ip_addr netmask;
|
||||
struct ip_addr gw;
|
||||
|
||||
IP4_ADDR(&ipaddr, P2P_GW_ADDR0, P2P_GW_ADDR1, P2P_GW_ADDR2, P2P_GW_ADDR3);
|
||||
IP4_ADDR(&netmask, P2P_NETMASK_ADDR0, P2P_NETMASK_ADDR1 , P2P_NETMASK_ADDR2, P2P_NETMASK_ADDR3);
|
||||
IP4_ADDR(&gw, P2P_GW_ADDR0, P2P_GW_ADDR1, P2P_GW_ADDR2, P2P_GW_ADDR3);
|
||||
netif_set_addr(pnetif, &ipaddr, &netmask,&gw);
|
||||
|
||||
// start ap
|
||||
if(wifi_start_ap(ssid,
|
||||
RTW_SECURITY_WPA2_AES_PSK,
|
||||
passphrase,
|
||||
strlen(ssid),
|
||||
strlen(passphrase),
|
||||
channel
|
||||
) != RTW_SUCCESS) {
|
||||
printf("\n\rERROR: Operation failed!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
netif_set_default(pnetif);
|
||||
|
||||
// start dhcp server
|
||||
dhcps_init(pnetif);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void app_callback(char *msg)
|
||||
{
|
||||
//From Application
|
||||
}
|
||||
|
||||
void cmd_wifi_p2p_start(int argc, char **argv)
|
||||
{
|
||||
extern struct netif xnetif[NET_IF_NUM];
|
||||
int listen_ch = 1;
|
||||
int op_ch = 5;
|
||||
int go_intent = 1;
|
||||
#if 1
|
||||
u32 r = 0;
|
||||
os_get_random((u8 *) &r, sizeof(r));
|
||||
go_intent = r%15+1; /*1-15*/
|
||||
|
||||
os_get_random((u8 *) &r, sizeof(r));
|
||||
listen_ch = 1 + (r % 3) * 5;
|
||||
|
||||
os_get_random((u8 *) &r, sizeof(r));
|
||||
op_ch = 1 + (r % 3) * 5;
|
||||
#endif
|
||||
wifi_off();
|
||||
os_sleep(0, 20000);
|
||||
wifi_on(RTW_MODE_P2P);
|
||||
wifi_p2p_init(xnetif[0].hwaddr, go_intent, listen_ch, op_ch);
|
||||
}
|
||||
|
||||
int cmd_wifi_p2p_auto_go_start(int argc, char **argv)
|
||||
{
|
||||
u8 *passphrase = "12345678";
|
||||
u8 channel = 6; // 1, 6, 11
|
||||
const char *ssid_in = "DIRECT-34-Ameba";
|
||||
const char *dev_name = "Ameba1234"; // max strlen 32
|
||||
const char *manufacturer = "by customer"; // max strlen 64
|
||||
const char *model_name = "customer"; // max strlen 32
|
||||
const char *model_number = "v2.0"; // max strlen 32
|
||||
const char *serial_number = "9"; // max strlen 32
|
||||
const u8 pri_dev_type[8] = {0x00,0x0A,0x00,0x50,0xF2,0x04,0x00,0x01}; // category ID:0x00,0x0A; sub category ID:0x00,0x01
|
||||
u8 res[P2P_GO_NEGO_RESULT_SIZE];
|
||||
u16 config_methods = WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD | WPS_CONFIG_PUSHBUTTON;
|
||||
|
||||
if(!is_wifi_p2p_initialized())
|
||||
return -1;
|
||||
|
||||
wifi_p2p_set_dev_name(dev_name);
|
||||
wifi_p2p_set_manufacturer(manufacturer);
|
||||
wifi_p2p_set_model_name(model_name);
|
||||
wifi_p2p_set_model_number(model_number);
|
||||
wifi_p2p_set_serial_number(serial_number);
|
||||
wifi_p2p_set_pri_dev_type(pri_dev_type);
|
||||
wifi_p2p_set_ssid(ssid_in);
|
||||
wifi_p2p_set_config_methods(config_methods);
|
||||
wifi_p2p_init_auto_go_params(res, passphrase, channel);
|
||||
wifi_p2p_start_auto_go(res);
|
||||
return 0;
|
||||
}
|
||||
void cmd_wifi_p2p_stop(int argc, char **argv)
|
||||
{
|
||||
wifi_p2p_deinit();
|
||||
wifi_off();
|
||||
}
|
||||
|
||||
void cmd_p2p_listen(int argc, char **argv)
|
||||
{
|
||||
u32 timeout = 0;
|
||||
|
||||
if(argc == 2){
|
||||
timeout = os_atoi((u8*)argv[1]);
|
||||
printf("\r\n%s(): timeout=%d\n", __func__, timeout);
|
||||
if(timeout > 3600)
|
||||
timeout = 3600;
|
||||
}
|
||||
wifi_cmd_p2p_listen(timeout);
|
||||
}
|
||||
|
||||
void cmd_p2p_find(int argc, char **argv)
|
||||
{
|
||||
wifi_cmd_p2p_find();
|
||||
}
|
||||
|
||||
void cmd_p2p_peers(int argc, char **argv)
|
||||
{
|
||||
wifi_cmd_p2p_peers();
|
||||
}
|
||||
|
||||
void cmd_p2p_info(int argc, char **argv)
|
||||
{
|
||||
wifi_cmd_p2p_info();
|
||||
}
|
||||
|
||||
void cmd_p2p_disconnect(int argc, char **argv)
|
||||
{
|
||||
wifi_cmd_p2p_disconnect();
|
||||
}
|
||||
|
||||
void cmd_p2p_connect(int argc, char **argv)
|
||||
{
|
||||
enum p2p_wps_method config_method = WPS_PBC;
|
||||
char *pin = NULL;
|
||||
u8 dest[ETH_ALEN] = {0x44, 0x6d, 0x57, 0xd7, 0xce, 0x41};
|
||||
u8 res[P2P_GO_NEGO_RESULT_SIZE];
|
||||
int ret = 0, result = 0;
|
||||
|
||||
#if 1
|
||||
if((argc != 2) && (argc != 3) && (argc != 4)) {
|
||||
printf("\n\rUsage: p2p_connect DEST_ADDR [pbc|pin] [pin code]\n");
|
||||
printf("\n\rExample: p2p_connect 00:e0:4c:87:00:15 pin 12345678\n");
|
||||
return;
|
||||
}
|
||||
if (hwaddr_aton(argv[1], dest)){
|
||||
printf("\r\nP2P_CONNECT: dest address is not correct!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
//printf("\r\nDEST: %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n", dest[0], dest[1], dest[2], dest[3], dest[4], dest[5]);
|
||||
config_method = WPS_PBC;
|
||||
if(argc == 3) {
|
||||
if(os_strncmp(argv[2], "pbc", 3) == 0)
|
||||
config_method = WPS_PBC;
|
||||
else if(os_strncmp(argv[2], "pin", 3) == 0){
|
||||
config_method = WPS_PIN_DISPLAY;
|
||||
}else{
|
||||
printf("\n\rUnknown config method!\n");
|
||||
printf("\n\rUsage: p2p_connect DEST_ADDR [pbc|pin] \n");
|
||||
printf("\n\rExample: p2p_connect 00:e0:4c:87:00:15 pin\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(argc == 4) {
|
||||
if(os_strncmp(argv[2], "pin", 3) == 0){
|
||||
config_method = WPS_PIN_KEYPAD;
|
||||
pin = argv[3];
|
||||
}else{
|
||||
printf("\n\rUnknown config method!\n");
|
||||
printf("\n\rUsage: p2p_connect DEST_ADDR [pbc|pin] [pin code]\n");
|
||||
printf("\n\rExample: p2p_connect 00:e0:4c:87:00:15 pin 12345678\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
#else //For test
|
||||
u8 dest1[ETH_ALEN] = {0xea, 0x92, 0xa4, 0x9b, 0x61, 0xd6}; //NEXUS 4
|
||||
//u8 dest1[ETH_ALEN] = {0x0e, 0x37, 0xdc, 0xfc, 0xc4, 0x12}; //HUAWEI U9508_c001
|
||||
//u8 dest1[ETH_ALEN] = {0x42, 0xcb, 0xa8, 0xd3, 0x2c, 0x50}; //HUAWEI G610-T00
|
||||
os_memcpy(dest, dest1, ETH_ALEN);
|
||||
config_method = WPS_PBC;
|
||||
#endif
|
||||
|
||||
if (queue_for_p2p_nego!= NULL) {
|
||||
os_xqueue_delete(queue_for_p2p_nego);
|
||||
queue_for_p2p_nego = NULL;
|
||||
}
|
||||
queue_for_p2p_nego = os_xqueue_create(1, P2P_GO_NEGO_RESULT_SIZE);
|
||||
if(queue_for_p2p_nego != NULL) {
|
||||
ret = wifi_cmd_p2p_connect(dest, config_method, pin);
|
||||
if(ret == 0)
|
||||
result = os_xqueue_receive(queue_for_p2p_nego, res, 15);
|
||||
|
||||
os_xqueue_delete(queue_for_p2p_nego);
|
||||
queue_for_p2p_nego = NULL;
|
||||
|
||||
if((ret == 0) || (result == 0))
|
||||
wifi_p2p_start_wps(res);
|
||||
}
|
||||
}
|
||||
|
||||
#endif //CONFIG_ENABLE_P2P
|
||||
File diff suppressed because it is too large
Load diff
1988
component/common/api/wifi/wifi_conf.c
Normal file
1988
component/common/api/wifi/wifi_conf.c
Normal file
File diff suppressed because it is too large
Load diff
877
component/common/api/wifi/wifi_conf.h
Normal file
877
component/common/api/wifi/wifi_conf.h
Normal file
|
|
@ -0,0 +1,877 @@
|
|||
//----------------------------------------------------------------------------//
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file wifi_conf.h
|
||||
* @author
|
||||
* @version
|
||||
* @brief This file provides user interface for Wi-Fi station and AP mode configuration
|
||||
* base on the functionalities provided by Realtek Wi-Fi driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* 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 __WIFI_API_H
|
||||
#define __WIFI_API_H
|
||||
|
||||
/** @addtogroup nic NIC
|
||||
* @ingroup wlan
|
||||
* @brief NIC functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "wifi_constants.h"
|
||||
#include "wifi_structures.h"
|
||||
#include "wifi_util.h"
|
||||
#include "wifi_ind.h"
|
||||
#include <platform/platform_stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
#define RTW_ENABLE_API_INFO
|
||||
|
||||
#ifdef RTW_ENABLE_API_INFO
|
||||
#define RTW_API_INFO(args) do {printf args;} while(0)
|
||||
#else
|
||||
#define RTW_API_INFO(args)
|
||||
#endif
|
||||
|
||||
#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
|
||||
#define CMP_MAC( 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])))
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
#define SCAN_LONGEST_WAIT_TIME (4500)
|
||||
|
||||
|
||||
#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
|
||||
#define PSCAN_ENABLE 0x01 //enable for partial channel scan
|
||||
#define PSCAN_FAST_SURVEY 0x02 //set to select scan time to FAST_SURVEY_TO, otherwise SURVEY_TO
|
||||
#define PSCAN_SIMPLE_CONFIG 0x04 //set to select scan time to FAST_SURVEY_TO and resend probe request
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/** Scan result callback function pointer type
|
||||
*
|
||||
* @param result_ptr : A pointer to the pointer that indicates where to put the next scan result
|
||||
* @param user_data : User provided data
|
||||
*/
|
||||
typedef void (*rtw_scan_result_callback_t)( rtw_scan_result_t** result_ptr, void* user_data );
|
||||
typedef rtw_result_t (*rtw_scan_result_handler_t)( rtw_scan_handler_result_t* malloced_scan_result );
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
typedef struct {
|
||||
char *buf;
|
||||
int buf_len;
|
||||
} scan_buf_arg;
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
typedef struct internal_scan_handler{
|
||||
rtw_scan_result_t** pap_details;
|
||||
rtw_scan_result_t * ap_details;
|
||||
int scan_cnt;
|
||||
rtw_bool_t scan_complete;
|
||||
unsigned char max_ap_size;
|
||||
rtw_scan_result_handler_t gscan_result_handler;
|
||||
#if SCAN_USE_SEMAPHORE
|
||||
void *scan_semaphore;
|
||||
#else
|
||||
int scan_running;
|
||||
#endif
|
||||
void* user_data;
|
||||
unsigned int scan_start_time;
|
||||
} internal_scan_handler_t;
|
||||
|
||||
typedef struct {
|
||||
rtw_network_info_t network_info;
|
||||
void *join_sema;
|
||||
} internal_join_result_t;
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
/**
|
||||
* @brief Initialize Realtek WiFi API System.
|
||||
* - Initialize the required parts of the software platform.
|
||||
* i.e. worker, event registering, semaphore, etc.
|
||||
* - Initialize the RTW API thread which handles the asynchronous event.
|
||||
* @return RTW_SUCCESS if initialization is successful, RTW_ERROR otherwise
|
||||
*/
|
||||
int wifi_manager_init(void);
|
||||
|
||||
/**
|
||||
* @brief Join a Wi-Fi network.
|
||||
* Scan for, associate and authenticate with a Wi-Fi network.
|
||||
* On successful return, the system is ready to send data packets.
|
||||
*
|
||||
* @param[in] ssid: A null terminated string containing the SSID name of the network to join.
|
||||
* @param[in] security_type: Authentication type:
|
||||
* - RTW_SECURITY_OPEN - Open Security
|
||||
* - RTW_SECURITY_WEP_PSK - WEP Security with open authentication
|
||||
* - RTW_SECURITY_WEP_SHARED - WEP Security with shared authentication
|
||||
* - RTW_SECURITY_WPA_TKIP_PSK - WPA Security
|
||||
* - RTW_SECURITY_WPA2_AES_PSK - WPA2 Security using AES cipher
|
||||
* - RTW_SECURITY_WPA2_TKIP_PSK - WPA2 Security using TKIP cipher
|
||||
* - RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers
|
||||
* @param[in] password: A byte array containing either the cleartext security key for WPA/WPA2
|
||||
* secured networks, or a pointer to an array of rtw_wep_key_t
|
||||
* structures for WEP secured networks.
|
||||
* @param[in] ssid_len: The length of the SSID in bytes.
|
||||
* @param[in] password_len: The length of the security_key in bytes.
|
||||
* @param[in] key_id: The index of the wep key (0, 1, 2, or 3). If not using it, leave it with value -1.
|
||||
* @param[in] semaphore: A user provided semaphore that is flagged when the join is complete. If not using it, leave it with NULL value.
|
||||
* @return RTW_SUCCESS: when the system is joined and ready to send data packets.
|
||||
* @return RTW_ERROR: if an error occurred.
|
||||
* @note Please make sure the Wi-Fi is enabled before invoking this function. (@ref wifi_on())
|
||||
*/
|
||||
int wifi_connect(
|
||||
char *ssid,
|
||||
rtw_security_t security_type,
|
||||
char *password,
|
||||
int ssid_len,
|
||||
int password_len,
|
||||
int key_id,
|
||||
void *semaphore);
|
||||
|
||||
/**
|
||||
* @brief Join a Wi-Fi network with specified BSSID.
|
||||
* Scan for, associate and authenticate with a Wi-Fi network.
|
||||
* On successful return, the system is ready to send data packets.
|
||||
* @param[in] bssid: The specified BSSID to connect.
|
||||
* @param[in] ssid: A null terminated string containing the SSID name of the network to join.
|
||||
* @param[in] security_type: Authentication type:
|
||||
* - RTW_SECURITY_OPEN - Open Security
|
||||
* - RTW_SECURITY_WEP_PSK - WEP Security with open authentication
|
||||
* - RTW_SECURITY_WEP_SHARED - WEP Security with shared authentication
|
||||
* - RTW_SECURITY_WPA_TKIP_PSK - WPA Security
|
||||
* - RTW_SECURITY_WPA2_AES_PSK - WPA2 Security using AES cipher
|
||||
* - RTW_SECURITY_WPA2_TKIP_PSK - WPA2 Security using TKIP cipher
|
||||
* - RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers
|
||||
* @param[in] password: A byte array containing either the cleartext security key for WPA/WPA2
|
||||
* secured networks, or a pointer to an array of rtw_wep_key_t
|
||||
* structures for WEP secured networks.
|
||||
* @param[in] ssid_len: The length of the SSID in bytes.
|
||||
* @param[in] password_len: The length of the security_key in bytes.
|
||||
* @param[in] key_id: The index of the wep key.
|
||||
* @param[in] semaphore: A user provided semaphore that is flagged when the join is complete.
|
||||
* @return RTW_SUCCESS: when the system is joined and ready to send data packets.
|
||||
* @return RTW_ERROR: if an error occurred.
|
||||
* @note Please make sure the Wi-Fi is enabled before invoking this function. (@ref wifi_on())
|
||||
* @note The difference between @ref wifi_connect_bssid() and @ref wifi_connect() is that BSSID has higher priority as the basis of connection in @ref wifi_connect_bssid.
|
||||
*/
|
||||
int wifi_connect_bssid(
|
||||
unsigned char bssid[ETH_ALEN],
|
||||
char *ssid,
|
||||
rtw_security_t security_type,
|
||||
char *password,
|
||||
int bssid_len,
|
||||
int ssid_len,
|
||||
int password_len,
|
||||
int key_id,
|
||||
void *semaphore);
|
||||
|
||||
/**
|
||||
* @brief Disassociates from current Wi-Fi network.
|
||||
* @param None
|
||||
* @return RTW_SUCCESS: On successful disassociation from the AP.
|
||||
* @return RTW_ERROR: If an error occurred.
|
||||
*/
|
||||
int wifi_disconnect(void);
|
||||
|
||||
/**
|
||||
* @brief Check if Wi-Fi has connected to AP before dhcp.
|
||||
* @param None
|
||||
* @return RTW_SUCCESS: If conneced.
|
||||
* @return RTW_ERROR: If not connect.
|
||||
*/
|
||||
int wifi_is_connected_to_ap(void);
|
||||
|
||||
/**
|
||||
* @brief Check if the specified interface is up.
|
||||
* @param[in] interface: The interface can be set as RTW_STA_INTERFACE or RTW_AP_INTERFACE. (@ref rtw_interface_t)
|
||||
* @return If the function succeeds, the return value is 1. Otherwise, return 0.
|
||||
*/
|
||||
int wifi_is_up(rtw_interface_t interface);
|
||||
|
||||
/** Determines if a particular interface is ready to transceive ethernet packets
|
||||
*
|
||||
* @param Radio interface to check, options are
|
||||
* RTW_STA_INTERFACE, RTW_AP_INTERFACE
|
||||
* @return RTW_SUCCESS : if the interface is ready to
|
||||
* transceive ethernet packets
|
||||
* @return RTW_NOTFOUND : no AP with a matching SSID was
|
||||
* found
|
||||
* @return RTW_NOT_AUTHENTICATED: a matching AP was found but
|
||||
* it won't let you
|
||||
* authenticate. This can
|
||||
* occur if this device is
|
||||
* in the block list on the
|
||||
* AP.
|
||||
* @return RTW_NOT_KEYED: the device has authenticated and
|
||||
* associated but has not completed
|
||||
* the key exchange. This can occur
|
||||
* if the passphrase is incorrect.
|
||||
* @return RTW_ERROR : if the interface is not ready to
|
||||
* transceive ethernet packets
|
||||
*/
|
||||
int wifi_is_ready_to_transceive(rtw_interface_t interface);
|
||||
|
||||
/**
|
||||
* @brief This function sets the current Media Access Control (MAC) address of the 802.11 device.
|
||||
* @param[in] mac: Wi-Fi MAC address.
|
||||
* @return RTW_SUCCESS or RTW_ERROR
|
||||
*/
|
||||
int wifi_set_mac_address(char * mac);
|
||||
|
||||
/**
|
||||
* @brief Retrieves the current Media Access Control (MAC) address
|
||||
* (or Ethernet hardware address) of the 802.11 device.
|
||||
* @param[in] mac: Point to the result of the mac address will be get.
|
||||
* @return RTW_SUCCESS or RTW_ERROR
|
||||
*/
|
||||
int wifi_get_mac_address(char * mac);
|
||||
|
||||
/**
|
||||
* @brief Enable Wi-Fi powersave mode.
|
||||
* @param None
|
||||
* @return RTW_SUCCESS or RTW_ERROR.
|
||||
*/
|
||||
int wifi_enable_powersave(void);
|
||||
|
||||
/**
|
||||
* @brief Disable Wi-Fi powersave mode.
|
||||
* @param None
|
||||
* @return RTW_SUCCESS or RTW_ERROR.
|
||||
*/
|
||||
int wifi_disable_powersave(void);
|
||||
|
||||
/** Gets the tx power in index units
|
||||
*
|
||||
* @param dbm : The variable to receive the tx power in index.
|
||||
*
|
||||
* @return RTW_SUCCESS : if successful
|
||||
* RTW_ERROR : if not successful
|
||||
*/
|
||||
int wifi_get_txpower(int *poweridx);
|
||||
|
||||
/**
|
||||
* @brief Set the tx power in index units.
|
||||
* @param[in] poweridx: The desired tx power in index.
|
||||
* @return RTW_SUCCESS: if tx power is successfully set
|
||||
* @return RTW_ERROR: if tx power is not successfully set
|
||||
*/
|
||||
int wifi_set_txpower(int poweridx);
|
||||
|
||||
/**
|
||||
* @brief Get the associated clients with SoftAP.
|
||||
* @param[out] client_list_buffer: The location where the client list will be stored.
|
||||
* @param[in] buffer_length: The buffer length.
|
||||
* @return RTW_SUCCESS: The result is successfully got.
|
||||
* @return RTW_ERROR: The result is not successfully got.
|
||||
*/
|
||||
int wifi_get_associated_client_list(void * client_list_buffer, unsigned short buffer_length);
|
||||
|
||||
/**
|
||||
* @brief Get the SoftAP information.
|
||||
* @param[out] ap_info: The location where the AP info will be stored.
|
||||
* @param[out] security: The security type.
|
||||
* @return RTW_SUCCESS: The result is successfully got.
|
||||
* @return RTW_ERROR: The result is not successfully got.
|
||||
*/
|
||||
int wifi_get_ap_info(rtw_bss_info_t * ap_info, rtw_security_t* security);
|
||||
|
||||
/**
|
||||
* @brief Set the country code to driver to determine the channel set.
|
||||
* @param[in] country_code: Specify the country code.
|
||||
* @return RTW_SUCCESS: If result is successfully set.
|
||||
* @return RTW_ERROR: If result is not successfully set.
|
||||
*/
|
||||
int wifi_set_country(rtw_country_code_t country_code);
|
||||
|
||||
/**
|
||||
* @brief Retrieve the latest RSSI value.
|
||||
* @param[out] pRSSI: Points to the integer to store the RSSI value gotten from driver.
|
||||
* @return RTW_SUCCESS: If the RSSI is succesfully retrieved.
|
||||
* @return RTW_ERROR: If the RSSI is not retrieved.
|
||||
*/
|
||||
int wifi_get_rssi(int *pRSSI);
|
||||
|
||||
/**
|
||||
* @brief Set the listening channel for promiscuous mode.
|
||||
* @param[in] channel: The desired channel.
|
||||
* @return RTW_SUCCESS: If the channel is successfully set.
|
||||
* @return RTW_ERROR: If the channel is not successfully set.
|
||||
* @note Do NOT need to call this function for STA mode wifi driver, since it will determine the channel from received beacon.
|
||||
*/
|
||||
int wifi_set_channel(int channel);
|
||||
|
||||
/**
|
||||
* @brief Get the current channel on STA interface.
|
||||
* @param[out] channel: A pointer to the variable where the
|
||||
* channel value will be written
|
||||
* @return RTW_SUCCESS: If the channel is successfully read.
|
||||
* @return RTW_ERROR: If the channel is not successfully read.
|
||||
*/
|
||||
int wifi_get_channel(int *channel);
|
||||
|
||||
/**
|
||||
* @brief Register interest in a multicast address.\n
|
||||
* Once a multicast address has been registered, all packets detected on the
|
||||
* medium destined for that address are forwarded to the host.
|
||||
* Otherwise they are ignored.
|
||||
* @param[in] mac: Ethernet MAC address
|
||||
* @return RTW_SUCCESS: If the address is registered successfully.
|
||||
* @return RTW_ERROR: If the address is not registered.
|
||||
*/
|
||||
int wifi_register_multicast_address(rtw_mac_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Unregister interest in a multicast address.\n
|
||||
* Once a multicast address has been unregistered, all packets detected on the
|
||||
* medium destined for that address are ignored.
|
||||
* @param[in] mac: Ethernet MAC address
|
||||
* @return RTW_SUCCESS: If the address is unregistered successfully.
|
||||
* @return RTW_ERROR: If the address is not unregistered.
|
||||
*/
|
||||
int wifi_unregister_multicast_address(rtw_mac_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Setup the adaptivity mode.
|
||||
* You can replace this weak function by the same name funcation to setup adaptivity mode you want.
|
||||
* @param None
|
||||
* @return If the function succeeds, the return value is 0.
|
||||
*/
|
||||
_WEAK void wifi_set_mib(void);
|
||||
|
||||
/**
|
||||
* @brief Setup country code.
|
||||
* You can replace this weak function by the same name funcation to setup country code you want.
|
||||
* @param None
|
||||
* @return If the function succeeds, the return value is 0.
|
||||
*/
|
||||
//----------------------------------------------------------------------------//
|
||||
_WEAK void wifi_set_country_code(void);
|
||||
|
||||
/**
|
||||
* @brief Enable Wi-Fi RF.
|
||||
* @param None
|
||||
* @return If the function succeeds, the return value is 0.
|
||||
* @note The difference between @ref wifi_rf_on() and @ref wifi_on() is that @ref wifi_rf_on() simply enable RF HAL, it does not enable the driver or allocate memory.
|
||||
*/
|
||||
int wifi_rf_on(void);
|
||||
|
||||
/**
|
||||
* @brief Disable Wi-Fi RF.
|
||||
* @param None
|
||||
* @return If the function succeeds, the return value is 0.
|
||||
* @note The difference between @ref wifi_rf_off() and @ref wifi_off() is that @ref wifi_rf_off() simply disable RF HAL, the driver and used heap memory will NOT be released.
|
||||
*/
|
||||
int wifi_rf_off(void);
|
||||
|
||||
/**
|
||||
* @brief Enable Wi-Fi.
|
||||
* - Bring the Wireless interface "Up"
|
||||
* - Initialize the driver thread which arbitrates access
|
||||
* to the SDIO/SPI bus
|
||||
*
|
||||
* @param[in] mode: Decide to enable WiFi in which mode. The optional modes are enumerated in @ref rtw_mode_t.
|
||||
* @return RTW_SUCCESS: if the WiFi chip was initialized successfully.
|
||||
* @return RTW_ERROR: if the WiFi chip was not initialized successfully.
|
||||
*/
|
||||
int wifi_on(rtw_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Disable Wi-Fi.
|
||||
*
|
||||
* @param None
|
||||
* @return RTW_SUCCESS: if deinitialization is successful.
|
||||
* @return RTW_ERROR: otherwise.
|
||||
*/
|
||||
int wifi_off(void);
|
||||
|
||||
/**
|
||||
* Turn off the Wi-Fi device
|
||||
*
|
||||
* - Bring the Wireless interface "Down"
|
||||
* - De-Initialises the driver thread which arbitrates access
|
||||
* to the SDIO/SPI bus
|
||||
*
|
||||
* @return RTW_SUCCESS if deinitialization is successful,
|
||||
* RTW_ERROR otherwise
|
||||
*/
|
||||
int wifi_off_fastly(void);
|
||||
|
||||
/**
|
||||
* @brief Set IPS/LPS mode.
|
||||
* @param[in] ips_mode: The desired IPS mode. It becomes effective when wlan enter ips.\n
|
||||
* @ref ips_mode is inactive power save mode. Wi-Fi automatically turns RF off if it is not associated to AP. Set 1 to enable inactive power save mode.
|
||||
* @param[in] lps_mode: The desired LPS mode. It becomes effective when wlan enter lps.\n
|
||||
* @ref lps_mode is leisure power save mode. Wi-Fi automatically turns RF off during the association to AP is traffic is not busy while it also automatically turns RF on to listen to beacon. Set 1 to enable leisure power save mode.
|
||||
* @return RTW_SUCCESS if setting LPS mode successful.
|
||||
* @return RTW_ERROR otherwise.
|
||||
*/
|
||||
|
||||
int wifi_set_power_mode(unsigned char ips_mode, unsigned char lps_mode);
|
||||
|
||||
/**
|
||||
* Set TDMA parameters
|
||||
*
|
||||
* @param[in] slot_period : We separate TBTT into 2 or 3 slots.
|
||||
* If we separate TBTT into 2 slots, then slot_period should be larger or equal to 50ms.
|
||||
* It means 2 slot period is
|
||||
* slot_period, 100-slot_period
|
||||
* If we separate TBTT into 3 slots, then slot_period should be less or equal to 33ms.
|
||||
* It means 3 slot period is
|
||||
* 100 - 2 * slot_period, slot_period, slot_period
|
||||
* @param[in] rfon_period_len_1: rf on period of slot 1
|
||||
* @param[in] rfon_period_len_2: rf on period of slot 2
|
||||
* @param[in] rfon_period_len_3: rf on period of slot 3
|
||||
*
|
||||
* @return RTW_SUCCESS if setting TDMA parameters successful
|
||||
* RTW_ERROR otherwise
|
||||
*/
|
||||
int wifi_set_tdma_param(unsigned char slot_period, unsigned char rfon_period_len_1, unsigned char rfon_period_len_2, unsigned char rfon_period_len_3);
|
||||
|
||||
/**
|
||||
* @brief Set LPS DTIM.
|
||||
* @param[in] dtim: In LPS, the package can be buffered at AP side.
|
||||
* STA leave LPS until dtim count of packages buffered at AP side.
|
||||
* @return RTW_SUCCESS if setting LPS dtim successful.
|
||||
* @return RTW_ERROR otherwise
|
||||
*/
|
||||
int wifi_set_lps_dtim(unsigned char dtim);
|
||||
|
||||
/**
|
||||
* @brief Get LPS DTIM.
|
||||
* @param[out] dtim: In LPS, the package can be buffered at AP side.
|
||||
* STA leave LPS until dtim count of packages buffered at AP side.
|
||||
* @return RTW_SUCCESS if getting LPS dtim successful.
|
||||
* @return RTW_ERROR otherwise.
|
||||
*/
|
||||
int wifi_get_lps_dtim(unsigned char *dtim);
|
||||
|
||||
/**
|
||||
* @brief Trigger Wi-Fi driver to start an infrastructure Wi-Fi network.
|
||||
* @warning If a STA interface is active when this function is called, the softAP will
|
||||
* start on the same channel as the STA. It will NOT use the channel provided!
|
||||
* @param[in] ssid: A null terminated string containing the SSID name of the network.
|
||||
* @param[in] security_type:
|
||||
* - RTW_SECURITY_OPEN - Open Security
|
||||
* - RTW_SECURITY_WPA_TKIP_PSK - WPA Security
|
||||
* - RTW_SECURITY_WPA2_AES_PSK - WPA2 Security using AES cipher
|
||||
* - RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers
|
||||
* - WEP security is NOT IMPLEMENTED. It is NOT SECURE!
|
||||
* @param[in] password: A byte array containing the cleartext security key for the network.
|
||||
* @param[in] ssid_len: The length of the SSID in bytes.
|
||||
* @param[in] password_len: The length of the security_key in bytes.
|
||||
* @param[in] channel: 802.11 channel number.
|
||||
* @return RTW_SUCCESS: If successfully creates an AP.
|
||||
* @return RTW_ERROR: If an error occurred.
|
||||
* @note Please make sure the Wi-Fi is enabled before invoking this function. (@ref wifi_on())
|
||||
*/
|
||||
int wifi_start_ap(
|
||||
char *ssid,
|
||||
rtw_security_t security_type,
|
||||
char *password,
|
||||
int ssid_len,
|
||||
int password_len,
|
||||
int channel);
|
||||
|
||||
/**
|
||||
* @brief Start an infrastructure Wi-Fi network with hidden SSID.
|
||||
* @warning If a STA interface is active when this function is called, the softAP will
|
||||
* start on the same channel as the STA. It will NOT use the channel provided!
|
||||
*
|
||||
* @param[in] ssid: A null terminated string containing
|
||||
* the SSID name of the network to join.
|
||||
* @param[in] security_type: Authentication type: \n
|
||||
* - RTW_SECURITY_OPEN - Open Security
|
||||
* - RTW_SECURITY_WPA_TKIP_PSK - WPA Security
|
||||
* - RTW_SECURITY_WPA2_AES_PSK - WPA2 Security using AES cipher
|
||||
* - RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers
|
||||
* - WEP security is NOT IMPLEMENTED. It is NOT SECURE!
|
||||
* @param[in] password: A byte array containing the cleartext
|
||||
* security key for the network.
|
||||
* @param[in] ssid_len: The length of the SSID in bytes.
|
||||
* @param[in] password_len: The length of the security_key in bytes.
|
||||
* @param[in] channel: 802.11 channel number
|
||||
*
|
||||
* @return RTW_SUCCESS: If successfully creates an AP.
|
||||
* @return RTW_ERROR: If an error occurred.
|
||||
*/
|
||||
int wifi_start_ap_with_hidden_ssid(
|
||||
char *ssid,
|
||||
rtw_security_t security_type,
|
||||
char *password,
|
||||
int ssid_len,
|
||||
int password_len,
|
||||
int channel);
|
||||
|
||||
/**
|
||||
* @brief Initiate a scan to search for 802.11 networks.
|
||||
*
|
||||
* @param[in] scan_type: Specifies whether the scan should
|
||||
* be Active, Passive or scan
|
||||
* Prohibited channels
|
||||
* @param[in] bss_type: Specifies whether the scan should
|
||||
* search for Infrastructure
|
||||
* networks (those using an Access
|
||||
* Point), Ad-hoc networks, or both
|
||||
* types.
|
||||
* @param[in] result_ptr: Scan specific ssid. The first 4
|
||||
* bytes is ssid lenth, and ssid name
|
||||
* append after it.
|
||||
* If no specific ssid need to scan,
|
||||
* PLEASE CLEAN result_ptr before pass
|
||||
* it into parameter.
|
||||
* @param[out] result_ptr: a pointer to a pointer to a result
|
||||
* storage structure.
|
||||
* @return RTW_SUCCESS or RTW_ERROR
|
||||
* @note The scan progressively accumulates results over time, and
|
||||
* may take between 1 and 3 seconds to complete. The results of
|
||||
* the scan will be individually provided to the callback
|
||||
* function. Note: The callback function will be executed in
|
||||
* the context of the RTW thread.
|
||||
* @note When scanning specific channels, devices with a
|
||||
* strong signal strength on nearby channels may be
|
||||
* detected
|
||||
*/
|
||||
int wifi_scan(rtw_scan_type_t scan_type,
|
||||
rtw_bss_type_t bss_type,
|
||||
void* result_ptr);
|
||||
|
||||
/**
|
||||
* @brief Initiate a scan to search for 802.11 networks, a higher level API based on wifi_scan
|
||||
* to simplify the scan operation.
|
||||
* @param[in] results_handler: The callback function which will receive and process the result data.
|
||||
* @param[in] user_data: User specified data that will be passed directly to the callback function.
|
||||
* @return RTW_SUCCESS or RTW_ERROR
|
||||
* @note Callback must not use blocking functions, since it is called from the context of the RTW thread.
|
||||
* The callback, user_data variables will be referenced after the function returns.
|
||||
* Those variables must remain valid until the scan is completed.
|
||||
* The usage of this api can reference ATWS in atcmd_wifi.c.
|
||||
*/
|
||||
int wifi_scan_networks(rtw_scan_result_handler_t results_handler, void* user_data);
|
||||
|
||||
/**
|
||||
* @brief Initiate a scan to search for 802.11 networks with specified SSID.
|
||||
* @param[in] results_handler: The callback function which will receive and process the result data.
|
||||
* @param[in] user_data: User specified data that will be passed directly to the callback function.
|
||||
* @param[in] scan_buflen: The length of the result storage structure.
|
||||
* @param[in] ssid: The SSID of target network.
|
||||
* @param[in] ssid_len: The length of the target network SSID.
|
||||
* @return RTW_SUCCESS or RTW_ERROR
|
||||
* @note Callback must not use blocking functions, since it is called from the context of the RTW thread.
|
||||
* The callback, user_data variables will be referenced after the function returns.
|
||||
* Those variables must remain valid until the scan is completed.
|
||||
*/
|
||||
int wifi_scan_networks_with_ssid(int (results_handler)(char*, int, char *, void *), void* user_data, int scan_buflen, char* ssid, int ssid_len);
|
||||
|
||||
/**
|
||||
* @brief Set the channel used to be partial scanned.
|
||||
* @param[in] channel_list: An array stores the channel list.
|
||||
* @param[in] pscan_config: the pscan_config of the channel set.
|
||||
* @param[in] length: The length of the channel_list.
|
||||
* @return RTW_SUCCESS or RTW_ERROR.
|
||||
* @note This function should be used with wifi_scan function. First, use @ref wifi_set_pscan_chan to
|
||||
* indicate which channel will be scanned, and then use @ref wifi_scan to get scanned results.
|
||||
*/
|
||||
int wifi_set_pscan_chan(__u8 * channel_list,__u8 * pscan_config, __u8 length);
|
||||
|
||||
/**
|
||||
* @brief Get current Wi-Fi setting from driver.
|
||||
* @param[in] ifname: the wlan interface name, can be WLAN0_NAME or WLAN1_NAME.
|
||||
* @param[out] pSetting: Points to the rtw_wifi_setting_t structure to store the WIFI setting gotten from driver.
|
||||
* @return RTW_SUCCESS or RTW_ERROR.
|
||||
*/
|
||||
int wifi_get_setting(const char *ifname,rtw_wifi_setting_t *pSetting);
|
||||
|
||||
/**
|
||||
* @brief Show the network information stored in a rtw_wifi_setting_t structure.
|
||||
* @param[in] ifname: the wlan interface name, can be WLAN0_NAME or WLAN1_NAME.
|
||||
* @param[in] pSetting: Points to the rtw_wifi_setting_t structure which information is gotten by @ref wifi_get_setting().
|
||||
* @return RTW_SUCCESS or RTW_ERROR.
|
||||
*/
|
||||
int wifi_show_setting(const char *ifname,rtw_wifi_setting_t *pSetting);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
Set the network mode according to the data rate its supported.
|
||||
* Driver works in BGN mode in default after driver initialization. This function is used to
|
||||
* change wireless network mode for station mode before connecting to AP.
|
||||
* @param[in] mode: Network mode to set. The value can be RTW_NETWORK_B/RTW_NETWORK_BG/RTW_NETWORK_BGN.
|
||||
* @return RTW_SUCCESS or RTW_ERROR.
|
||||
*/
|
||||
int wifi_set_network_mode(rtw_network_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Set the chip to start or stop the promiscuous mode.
|
||||
* @param[in] enabled: enabled can be set 0, 1 and 2. if enabled is zero, disable the promisc, else enable the promisc.
|
||||
* - 0 means disable the promisc.
|
||||
* - 1 means enable the promisc.
|
||||
* - 2 means enable the promisc special for length is used.
|
||||
* @param[in] callback: the callback function which will
|
||||
* receive and process the netowork data.
|
||||
* @param[in] len_used: specify if the the promisc length is used.
|
||||
* If len_used set to 1, packet length will be saved and transferred to callback function.
|
||||
*
|
||||
* @return RTW_SUCCESS or RTW_ERROR
|
||||
* @note This function can be used to implement vendor specified simple configure.
|
||||
*/
|
||||
int wifi_set_promisc(rtw_rcr_level_t enabled, void (*callback)(unsigned char*, unsigned int, void*), unsigned char len_used);
|
||||
|
||||
/**
|
||||
* @brief Let Wi-Fi enter promiscuous mode.
|
||||
* @param[in] None
|
||||
* @return None
|
||||
*/
|
||||
void wifi_enter_promisc_mode(void);
|
||||
|
||||
/** Set the wps phase
|
||||
*
|
||||
* @param is_trigger_wps[in] : to trigger wps function or not
|
||||
*
|
||||
* @return RTW_SUCCESS or RTW_ERROR
|
||||
*/
|
||||
int wifi_set_wps_phase(unsigned char is_trigger_wps);
|
||||
|
||||
/**
|
||||
* @brief Trigger Wi-Fi driver to restart an infrastructure Wi-Fi network.
|
||||
* @warning If a STA interface is active when this function is called, the softAP will
|
||||
* start on the same channel as the STA. It will NOT use the channel provided!
|
||||
* @param[in] ssid: A null terminated string containing the SSID name of the network.
|
||||
* @param[in] security_type:
|
||||
* - RTW_SECURITY_OPEN - Open Security
|
||||
* - RTW_SECURITY_WPA_TKIP_PSK - WPA Security
|
||||
* - RTW_SECURITY_WPA2_AES_PSK - WPA2 Security using AES cipher
|
||||
* - RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers
|
||||
* - WEP security is NOT IMPLEMENTED. It is NOT SECURE!
|
||||
* @param[in] password: A byte array containing the cleartext security key for the network.
|
||||
* @param[in] ssid_len: The length of the SSID in bytes.
|
||||
* @param[in] password_len: The length of the security_key in bytes.
|
||||
* @param[in] channel: 802.11 channel number.
|
||||
* @return RTW_SUCCESS: If successfully creates an AP.
|
||||
* @return RTW_ERROR: If an error occurred.
|
||||
* @note Please make sure the Wi-Fi is enabled before invoking this function. (@ref wifi_on())
|
||||
*/
|
||||
int wifi_restart_ap(
|
||||
unsigned char *ssid,
|
||||
rtw_security_t security_type,
|
||||
unsigned char *password,
|
||||
int ssid_len,
|
||||
int password_len,
|
||||
int channel);
|
||||
|
||||
/**
|
||||
* @brief Set reconnection mode with configuration.
|
||||
* @param[in] mode: Set 1/0 to enalbe/disable the reconnection mode.
|
||||
* @param[in] retry_times: The number of retry limit.
|
||||
* @param[in] timeout: The timeout value (in seconds).
|
||||
* @return 0 if success, otherwise return -1.
|
||||
* @note Defining CONFIG_AUTO_RECONNECT in "autoconf.h" needs to be done before compiling,
|
||||
* or this API won't be effective.
|
||||
* @note The difference between @ref wifi_config_autoreconnect() and @ref wifi_set_autoreconnect() is that
|
||||
* user can specify the retry times and timeout value in @ref wifi_config_autoreconnect().
|
||||
* But in @ref wifi_set_autoreconnect() these values are set with 3 retry limit and 5 seconds timeout as default.
|
||||
*/
|
||||
int wifi_config_autoreconnect(__u8 mode, __u8 retry_times, __u16 timeout);
|
||||
|
||||
/**
|
||||
* @brief Set reconnection mode with 3 retry limit and 5 seconds timeout as default.
|
||||
* @param[in] mode: Set 1/0 to enalbe/disable the reconnection mode.
|
||||
* @return 0 if success, otherwise return -1.
|
||||
* @note Defining CONFIG_AUTO_RECONNECT in "autoconf.h" needs to be done before compiling,
|
||||
* or this API won't be effective.
|
||||
* @note The difference between @ref wifi_config_autoreconnect() and @ref wifi_set_autoreconnect() is that
|
||||
* user can specify the retry times and timeout value in @ref wifi_config_autoreconnect().
|
||||
* But in @ref wifi_set_autoreconnect() these values are set with 3 retry limit and 5 seconds timeout as default.
|
||||
*/
|
||||
int wifi_set_autoreconnect(__u8 mode);
|
||||
|
||||
/**
|
||||
* @brief Get the result of setting reconnection mode.
|
||||
* @param[out] mode: Point to the result of setting reconnection mode.
|
||||
* @return 0 if success, otherwise return -1.
|
||||
* @note Defining CONFIG_AUTO_RECONNECT in "autoconf.h" needs to be done before compiling,
|
||||
* or this API won't be effective.
|
||||
*/
|
||||
int wifi_get_autoreconnect(__u8 *mode);
|
||||
|
||||
/**
|
||||
* @brief Present the device disconnect reason while connecting.
|
||||
* @param None
|
||||
* @return @ref rtw_connect_error_flag_t
|
||||
* - 0: RTW_NO_ERROR
|
||||
* - 1: RTW_NONE_NETWORK
|
||||
* - 2: RTW_CONNECT_FAIL
|
||||
* - 3: RTW_WRONG_PASSWORD
|
||||
* - 4: RTW_DHCP_FAIL
|
||||
* - 5: RTW_UNKNOWN (initial status)
|
||||
*/
|
||||
int wifi_get_last_error(void);
|
||||
|
||||
|
||||
#ifdef CONFIG_CUSTOM_IE
|
||||
#ifndef BIT
|
||||
#define BIT(x) ((__u32)1 << (x))
|
||||
#endif
|
||||
|
||||
#ifndef _CUSTOM_IE_TYPE_
|
||||
#define _CUSTOM_IE_TYPE_
|
||||
/**
|
||||
* @brief The enumeration is transmission type for wifi custom ie.
|
||||
*/
|
||||
typedef enum CUSTOM_IE_TYPE{
|
||||
PROBE_REQ = BIT(0),
|
||||
PROBE_RSP = BIT(1),
|
||||
BEACON = BIT(2),
|
||||
}rtw_custom_ie_type_t;
|
||||
#endif /* _CUSTOM_IE_TYPE_ */
|
||||
|
||||
/* ie format
|
||||
* +-----------+--------+-----------------------+
|
||||
* |element ID | length | content in length byte|
|
||||
* +-----------+--------+-----------------------+
|
||||
*
|
||||
* type: refer to CUSTOM_IE_TYPE
|
||||
*/
|
||||
#ifndef _CUS_IE_
|
||||
#define _CUS_IE_
|
||||
/**
|
||||
* @brief The structure is used to set WIFI custom ie list, and type match CUSTOM_IE_TYPE.\n
|
||||
* The ie will be transmitted according to the type.
|
||||
*/
|
||||
typedef struct _cus_ie{
|
||||
__u8 *ie;
|
||||
__u8 type;
|
||||
}rtw_custom_ie_t, *p_rtw_custom_ie_t;
|
||||
#endif /* _CUS_IE_ */
|
||||
|
||||
/**
|
||||
* @brief Setup custom ie list.
|
||||
* @warning This API can't be executed twice before deleting the previous custom ie list.
|
||||
* @param[in] cus_ie: Pointer to WIFI CUSTOM IE list.
|
||||
* @param[in] ie_num: The number of WIFI CUSTOM IE list.
|
||||
* @return 0 if success, otherwise return -1.
|
||||
* @note Defininig CONFIG_CUSTOM_IE in "autoconf.h" needs to be done before compiling,
|
||||
* or this API won't be effective.
|
||||
*/
|
||||
int wifi_add_custom_ie(void *cus_ie, int ie_num);
|
||||
|
||||
/**
|
||||
* @brief Update the item in WIFI CUSTOM IE list.
|
||||
* @param[in] cus_ie: Pointer to WIFI CUSTOM IE address.
|
||||
* @param[in] ie_index: Index of WIFI CUSTOM IE list.
|
||||
* @return 0 if success, otherwise return -1.
|
||||
* @note Defininig CONFIG_CUSTOM_IE in "autoconf.h" needs to be done before compiling,
|
||||
* or this API won't be effective.
|
||||
*/
|
||||
int wifi_update_custom_ie(void *cus_ie, int ie_index);
|
||||
|
||||
/**
|
||||
* @brief Delete WIFI CUSTOM IE list.
|
||||
* @param None
|
||||
* @return 0 if success, otherwise return -1.
|
||||
* @note Defininig CONFIG_CUSTOM_IE in "autoconf.h" needs to be done before compiling,
|
||||
* or this API won't be effective.
|
||||
*/
|
||||
int wifi_del_custom_ie(void);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PROMISC
|
||||
|
||||
/**
|
||||
* @brief Initialize packet filter related data.
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
void wifi_init_packet_filter(void);
|
||||
|
||||
/**
|
||||
* @brief Add packet filter.
|
||||
* @param[in] filter_id: The filter id.
|
||||
* @param[in] patt: Point to the filter pattern.
|
||||
* @param[in] rule: Point to the filter rule.
|
||||
* @return 0 if success, otherwise return -1.
|
||||
* @note For now, the maximum number of filters is 5.
|
||||
*/
|
||||
int wifi_add_packet_filter(unsigned char filter_id, rtw_packet_filter_pattern_t *patt, rtw_packet_filter_rule_t rule);
|
||||
|
||||
/**
|
||||
* @brief Enable the packet filter.
|
||||
* @param[in] filter_id: The filter id.
|
||||
* @return 0 if success, otherwise return -1.
|
||||
* @note The filter can be used only if it has been enabled.
|
||||
*/
|
||||
int wifi_enable_packet_filter(unsigned char filter_id);
|
||||
|
||||
/**
|
||||
* @brief Disable the packet filter.
|
||||
* @param[in] filter_id: The filter id.
|
||||
* @return 0 if success, otherwise return -1.
|
||||
*/
|
||||
int wifi_disable_packet_filter(unsigned char filter_id);
|
||||
|
||||
/**
|
||||
* @brief Remove the packet filter.
|
||||
* @param[in] filter_id: The filter id.
|
||||
* @return 0 if success, otherwise return -1.
|
||||
*/
|
||||
int wifi_remove_packet_filter(unsigned char filter_id);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get antenna infomation.
|
||||
* @param[in] antenna: Points to store the antenna value gotten from driver, 0: main, 1: aux.
|
||||
* @return 0 if success, otherwise return -1.
|
||||
*/
|
||||
#ifdef CONFIG_ANTENNA_DIVERSITY
|
||||
int wifi_get_antenna_info(unsigned char *antenna);
|
||||
#endif // #ifdef CONFIG_ANTENNA_DIVERSITY
|
||||
|
||||
void wifi_set_indicate_mgnt(int enable);
|
||||
|
||||
///@name Ameba1 Only
|
||||
///@{
|
||||
/**
|
||||
* @brief enable AP sending QoS Null0 Data to poll Sta be alive
|
||||
* @param[in] enabled: enabled can be set to 0,1.
|
||||
* - 0 means enable.
|
||||
* - 1 means disable.
|
||||
* @return None
|
||||
*/
|
||||
void wifi_set_ap_polling_sta(__u8 enabled);
|
||||
///@}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*\@}*/
|
||||
|
||||
#endif // __WIFI_API_H
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
258
component/common/api/wifi/wifi_ind.c
Normal file
258
component/common/api/wifi/wifi_ind.c
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
//----------------------------------------------------------------------------//
|
||||
#include "wifi/wifi_ind.h"
|
||||
#include "wifi/wifi_conf.h"
|
||||
#include "osdep_service.h"
|
||||
#include "platform_stdlib.h"
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
#define WIFI_INDICATE_MSG 0
|
||||
#define WIFI_MANAGER_STACKSIZE 1300
|
||||
#define WIFI_MANAGER_PRIORITY (0) //Actual priority is 4 since calling rtw_create_task
|
||||
#define WIFI_MANAGER_Q_SZ 8
|
||||
|
||||
#define WIFI_EVENT_MAX_ROW 3
|
||||
/******************************************************
|
||||
* Globals
|
||||
******************************************************/
|
||||
|
||||
static event_list_elem_t event_callback_list[WIFI_EVENT_MAX][WIFI_EVENT_MAX_ROW];
|
||||
#if CONFIG_WIFI_IND_USE_THREAD
|
||||
static rtw_worker_thread_t wifi_worker_thread;
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
#if CONFIG_WIFI_IND_USE_THREAD
|
||||
static rtw_result_t rtw_send_event_to_worker(int event_cmd, char *buf, int buf_len, int flags)
|
||||
{
|
||||
rtw_event_message_t message;
|
||||
int i;
|
||||
rtw_result_t ret = RTW_SUCCESS;
|
||||
char *local_buf = NULL;
|
||||
|
||||
if(event_cmd >= WIFI_EVENT_MAX)
|
||||
return RTW_BADARG;
|
||||
|
||||
for(i = 0; i < WIFI_EVENT_MAX_ROW; i++){
|
||||
if(event_callback_list[event_cmd][i].handler == NULL)
|
||||
continue;
|
||||
|
||||
message.function = (event_handler_t)event_callback_list[event_cmd][i].handler;
|
||||
message.buf_len = buf_len;
|
||||
if(buf_len){
|
||||
local_buf = (char*)pvPortMalloc(buf_len);
|
||||
if(local_buf == NULL)
|
||||
return RTW_NOMEM;
|
||||
memcpy(local_buf, buf, buf_len);
|
||||
//printf("\n!!!!!Allocate %p(%d) for evcmd %d\n", local_buf, buf_len, event_cmd);
|
||||
}
|
||||
message.buf = local_buf;
|
||||
message.flags = flags;
|
||||
message.user_data = event_callback_list[event_cmd][i].handler_user_data;
|
||||
|
||||
ret = rtw_push_to_xqueue(&wifi_worker_thread.event_queue, &message, 0);
|
||||
if(ret != RTW_SUCCESS){
|
||||
if(local_buf){
|
||||
printf("\r\nrtw_send_event_to_worker: enqueue cmd %d failed and free %p(%d)\n", event_cmd, local_buf, buf_len);
|
||||
vPortFree(local_buf);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
static rtw_result_t rtw_indicate_event_handle(int event_cmd, char *buf, int buf_len, int flags)
|
||||
{
|
||||
rtw_event_handler_t handle = NULL;
|
||||
int i;
|
||||
|
||||
if(event_cmd >= WIFI_EVENT_MAX)
|
||||
return RTW_BADARG;
|
||||
|
||||
for(i = 0; i < WIFI_EVENT_MAX_ROW; i++){
|
||||
handle = event_callback_list[event_cmd][i].handler;
|
||||
if(handle == NULL)
|
||||
continue;
|
||||
handle(buf, buf_len, flags, event_callback_list[event_cmd][i].handler_user_data);
|
||||
}
|
||||
|
||||
return RTW_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
void wifi_indication( rtw_event_indicate_t event, char *buf, int buf_len, int flags)
|
||||
{
|
||||
//
|
||||
// If upper layer application triggers additional operations on receiving of wext_wlan_indicate,
|
||||
// please strictly check current stack size usage (by using uxTaskGetStackHighWaterMark() )
|
||||
// , and tries not to share the same stack with wlan driver if remaining stack space is
|
||||
// not available for the following operations.
|
||||
// ex: using semaphore to notice another thread.
|
||||
switch(event)
|
||||
{
|
||||
case WIFI_EVENT_DISCONNECT:
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
printf("\n\r %s():Disconnection indication received", __FUNCTION__);
|
||||
#endif
|
||||
break;
|
||||
case WIFI_EVENT_CONNECT:
|
||||
// For WPA/WPA2 mode, indication of connection does not mean data can be
|
||||
// correctly transmitted or received. Data can be correctly transmitted or
|
||||
// received only when 4-way handshake is done.
|
||||
// Please check WIFI_EVENT_FOURWAY_HANDSHAKE_DONE event
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
// Sample: return mac address
|
||||
if(buf != NULL && buf_len == 6)
|
||||
{
|
||||
printf("\n\r%s():Connect indication received: %02x:%02x:%02x:%02x:%02x:%02x", __FUNCTION__,
|
||||
buf[0],buf[1],buf[2],buf[3],buf[4],buf[5]);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case WIFI_EVENT_FOURWAY_HANDSHAKE_DONE:
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
if(buf != NULL)
|
||||
{
|
||||
if(buf_len == strlen(IW_EXT_STR_FOURWAY_DONE))
|
||||
printf("\n\r%s():%s", __FUNCTION__, buf);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case WIFI_EVENT_SCAN_RESULT_REPORT:
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
printf("\n\r%s(): WIFI_EVENT_SCAN_RESULT_REPORT\n", __func__);
|
||||
#endif
|
||||
break;
|
||||
case WIFI_EVENT_SCAN_DONE:
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
printf("\n\r%s(): WIFI_EVENT_SCAN_DONE\n", __func__);
|
||||
#endif
|
||||
break;
|
||||
case WIFI_EVENT_RECONNECTION_FAIL:
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
if(buf != NULL){
|
||||
if(buf_len == strlen(IW_EXT_STR_RECONNECTION_FAIL))
|
||||
printf("\n\r%s", buf);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case WIFI_EVENT_NO_NETWORK:
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
printf("\n\r%s(): WIFI_EVENT_NO_NETWORK\n", __func__);
|
||||
#endif
|
||||
break;
|
||||
case WIFI_EVENT_RX_MGNT:
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
printf("\n\r%s(): WIFI_EVENT_RX_MGNT\n", __func__);
|
||||
#endif
|
||||
break;
|
||||
#if CONFIG_ENABLE_P2P
|
||||
case WIFI_EVENT_SEND_ACTION_DONE:
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
printf("\n\r%s(): WIFI_EVENT_SEND_ACTION_DONE\n", __func__);
|
||||
#endif
|
||||
break;
|
||||
#endif //CONFIG_ENABLE_P2P
|
||||
case WIFI_EVENT_STA_ASSOC:
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
printf("\n\r%s(): WIFI_EVENT_STA_ASSOC\n", __func__);
|
||||
#endif
|
||||
break;
|
||||
case WIFI_EVENT_STA_DISASSOC:
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
printf("\n\r%s(): WIFI_EVENT_STA_DISASSOC\n", __func__);
|
||||
#endif
|
||||
break;
|
||||
#ifdef CONFIG_WPS
|
||||
case WIFI_EVENT_STA_WPS_START:
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
printf("\n\r%s(): WIFI_EVENT_STA_WPS_START\n", __func__);
|
||||
#endif
|
||||
break;
|
||||
case WIFI_EVENT_WPS_FINISH:
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
printf("\n\r%s(): WIFI_EVENT_WPS_FINISH\n", __func__);
|
||||
#endif
|
||||
break;
|
||||
case WIFI_EVENT_EAPOL_RECVD:
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
printf("\n\r%s(): WIFI_EVENT_EAPOL_RECVD\n", __func__);
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
case WIFI_EVENT_BEACON_AFTER_DHCP:
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
printf("\n\r%s(): WIFI_EVENT_BEACON_AFTER_DHCP\n", __func__);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
#if CONFIG_INIC_EN
|
||||
inic_indicate_event(event, buf, buf_len, flags);
|
||||
#endif//CONFIG_INIC_EN
|
||||
|
||||
#if CONFIG_WIFI_IND_USE_THREAD
|
||||
rtw_send_event_to_worker(event, buf, buf_len, flags);
|
||||
#else
|
||||
rtw_indicate_event_handle(event, buf, buf_len, flags);
|
||||
#endif
|
||||
}
|
||||
|
||||
void wifi_reg_event_handler(unsigned int event_cmds, rtw_event_handler_t handler_func, void *handler_user_data)
|
||||
{
|
||||
int i = 0, j = 0;
|
||||
if(event_cmds < WIFI_EVENT_MAX){
|
||||
for(i=0; i < WIFI_EVENT_MAX_ROW; i++){
|
||||
if(event_callback_list[event_cmds][i].handler == NULL){
|
||||
for(j=0; j<WIFI_EVENT_MAX_ROW; j++){
|
||||
if(event_callback_list[event_cmds][j].handler == handler_func){
|
||||
return;
|
||||
}
|
||||
}
|
||||
event_callback_list[event_cmds][i].handler = handler_func;
|
||||
event_callback_list[event_cmds][i].handler_user_data = handler_user_data;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_unreg_event_handler(unsigned int event_cmds, rtw_event_handler_t handler_func)
|
||||
{
|
||||
int i;
|
||||
if(event_cmds < WIFI_EVENT_MAX){
|
||||
for(i = 0; i < WIFI_EVENT_MAX_ROW; i++){
|
||||
if(event_callback_list[event_cmds][i].handler == handler_func){
|
||||
event_callback_list[event_cmds][i].handler = NULL;
|
||||
event_callback_list[event_cmds][i].handler_user_data = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void init_event_callback_list(){
|
||||
memset(event_callback_list, 0, sizeof(event_callback_list));
|
||||
}
|
||||
|
||||
int wifi_manager_init()
|
||||
{
|
||||
#if CONFIG_WIFI_IND_USE_THREAD
|
||||
rtw_create_worker_thread(&wifi_worker_thread,
|
||||
WIFI_MANAGER_PRIORITY,
|
||||
WIFI_MANAGER_STACKSIZE,
|
||||
WIFI_MANAGER_Q_SZ);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtw_wifi_manager_deinit()
|
||||
{
|
||||
#if CONFIG_WIFI_IND_USE_THREAD
|
||||
rtw_delete_worker_thread(&wifi_worker_thread);
|
||||
#endif
|
||||
}
|
||||
|
||||
89
component/common/api/wifi/wifi_ind.h
Normal file
89
component/common/api/wifi/wifi_ind.h
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file wifi_ind.h
|
||||
* @author
|
||||
* @version
|
||||
* @brief This file provides the functions related to event handler mechanism.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* 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 _WIFI_INDICATE_H
|
||||
#define _WIFI_INDICATE_H
|
||||
|
||||
/** @addtogroup nic NIC
|
||||
* @ingroup wlan
|
||||
* @brief NIC functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "wifi_conf.h"
|
||||
|
||||
typedef void (*rtw_event_handler_t)(char *buf, int buf_len, int flags, void* handler_user_data );
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// rtw_event_indicate_t event_cmd;
|
||||
rtw_event_handler_t handler;
|
||||
void* handler_user_data;
|
||||
} event_list_elem_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize the event callback list.
|
||||
* @warning Please make sure this function has been invoked before
|
||||
* using the event handler related mechanism.
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
void init_event_callback_list(void);
|
||||
|
||||
/**
|
||||
* @brief Wlan driver indicate event to upper layer through wifi_indication.
|
||||
* @param[in] event: An event reported from driver to upper layer application. Please refer to rtw_event_indicate_t enum.
|
||||
* @param[in] buf: If it is not NUL, buf is a pointer to the buffer for message string.
|
||||
* @param[in] buf_len: The length of the buffer.
|
||||
* @param[in] flags: Indicate some extra information, sometimes it is 0.
|
||||
* @retval None
|
||||
* @note If upper layer application triggers additional operations on receiving of wext_wlan_indicate,
|
||||
* please strictly check current stack size usage (by using uxTaskGetStackHighWaterMark() ),
|
||||
* and tries not to share the same stack with wlan driver if remaining stack space is not available
|
||||
* for the following operations.
|
||||
* ex: using semaphore to notice another thread instead of handing event directly in wifi_indication().
|
||||
*/
|
||||
extern void wifi_indication( rtw_event_indicate_t event, char *buf, int buf_len, int flags);
|
||||
|
||||
/**
|
||||
* @brief Register the event listener.
|
||||
* @param[in] event_cmds : The event command number indicated.
|
||||
* @param[in] handler_func : the callback function which will
|
||||
* receive and process the event.
|
||||
* @param[in] handler_user_data : user specific data that will be
|
||||
* passed directly to the callback function.
|
||||
* @return RTW_SUCCESS : if successfully registers the event.
|
||||
* @return RTW_ERROR : if an error occurred.
|
||||
* @note Set the same event_cmds with empty handler_func will
|
||||
* unregister the event_cmds.
|
||||
*/
|
||||
extern void wifi_reg_event_handler(unsigned int event_cmds, rtw_event_handler_t handler_func, void *handler_user_data);
|
||||
|
||||
/**
|
||||
* @brief Un-register the event listener.
|
||||
* @param[in] event_cmds : The event command number indicated.
|
||||
* @param[in] handler_func : the callback function which will
|
||||
* receive and process the event.
|
||||
*
|
||||
* @return RTW_SUCCESS : if successfully un-registers the event .
|
||||
* @return RTW_ERROR : if an error occurred.
|
||||
*/
|
||||
extern void wifi_unreg_event_handler(unsigned int event_cmds, rtw_event_handler_t handler_func);
|
||||
|
||||
/*\@}*/
|
||||
|
||||
#endif //_WIFI_INDICATE_H
|
||||
|
||||
461
component/common/api/wifi/wifi_promisc.c
Normal file
461
component/common/api/wifi/wifi_promisc.c
Normal file
|
|
@ -0,0 +1,461 @@
|
|||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "main.h"
|
||||
#include "tcpip.h"
|
||||
#include "wifi/wifi_conf.h"
|
||||
|
||||
#ifndef CONFIG_WLAN
|
||||
#define CONFIG_WLAN 1
|
||||
#endif
|
||||
|
||||
#if CONFIG_WLAN
|
||||
#include <platform/platform_stdlib.h>
|
||||
|
||||
// Add extra interfaces to make release sdk able to determine promisc API linking
|
||||
void promisc_deinit(void *padapter)
|
||||
{
|
||||
#ifdef CONFIG_PROMISC
|
||||
_promisc_deinit(padapter);
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_recv_func(void *padapter, void *rframe)
|
||||
{
|
||||
// Never reach here if not define CONFIG_PROMISC
|
||||
#ifdef CONFIG_PROMISC
|
||||
return _promisc_recv_func(padapter, rframe);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_set(rtw_rcr_level_t enabled, void (*callback)(unsigned char*, unsigned int, void*), unsigned char len_used)
|
||||
{
|
||||
#ifdef CONFIG_PROMISC
|
||||
return _promisc_set(enabled, callback, len_used);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned char is_promisc_enabled(void)
|
||||
{
|
||||
#ifdef CONFIG_PROMISC
|
||||
return _is_promisc_enabled();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_get_fixed_channel(void *fixed_bssid, u8 *ssid, int *ssid_length)
|
||||
{
|
||||
#ifdef CONFIG_PROMISC
|
||||
return _promisc_get_fixed_channel(fixed_bssid, ssid, ssid_length);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
// End of Add extra interfaces
|
||||
|
||||
struct eth_frame {
|
||||
struct eth_frame *prev;
|
||||
struct eth_frame *next;
|
||||
unsigned char da[6];
|
||||
unsigned char sa[6];
|
||||
unsigned int len;
|
||||
unsigned char type;
|
||||
signed char rssi;
|
||||
};
|
||||
|
||||
#if CONFIG_INIC_CMD_RSP
|
||||
#if defined(__IAR_SYSTEMS_ICC__)||defined (__GNUC__)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
struct inic_eth_frame {
|
||||
unsigned char da[6];
|
||||
unsigned char sa[6];
|
||||
unsigned int len;
|
||||
unsigned char type;
|
||||
};
|
||||
#if defined(__IAR_SYSTEMS_ICC__)||defined (__GNUC__)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
static struct inic_eth_frame *inic_frame, *inic_frame_tail = NULL;
|
||||
static int inic_frame_cnt = 0;
|
||||
#define MAX_INIC_FRAME_NUM 50 //maximum packets for each channel
|
||||
extern void inic_c2h_msg(const char *atcmd, char status, char *msg, u16 msg_len);
|
||||
#endif
|
||||
|
||||
struct eth_buffer {
|
||||
struct eth_frame *head;
|
||||
struct eth_frame *tail;
|
||||
};
|
||||
|
||||
static struct eth_buffer eth_buffer;
|
||||
|
||||
#ifdef CONFIG_PROMISC
|
||||
#define MAX_PACKET_FILTER_INFO 5
|
||||
#define FILTER_ID_INIT_VALUE 10
|
||||
rtw_packet_filter_info_t paff_array[MAX_PACKET_FILTER_INFO]={0, 0, 0, 0, 0};
|
||||
static u8 packet_filter_enable_num = 0;
|
||||
|
||||
void promisc_init_packet_filter()
|
||||
{
|
||||
int i = 0;
|
||||
for(i=0; i<MAX_PACKET_FILTER_INFO; i++){
|
||||
paff_array[i].filter_id = FILTER_ID_INIT_VALUE;
|
||||
paff_array[i].enable = 0;
|
||||
paff_array[i].patt.mask_size = 0;
|
||||
paff_array[i].rule = RTW_POSITIVE_MATCHING;
|
||||
paff_array[i].patt.mask = NULL;
|
||||
paff_array[i].patt.pattern = NULL;
|
||||
}
|
||||
packet_filter_enable_num = 0;
|
||||
}
|
||||
|
||||
int promisc_add_packet_filter(u8 filter_id, rtw_packet_filter_pattern_t *patt, rtw_packet_filter_rule_t rule)
|
||||
{
|
||||
int i = 0;
|
||||
while(i < MAX_PACKET_FILTER_INFO){
|
||||
if(paff_array[i].filter_id == FILTER_ID_INIT_VALUE){
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if(i == MAX_PACKET_FILTER_INFO)
|
||||
return -1;
|
||||
|
||||
paff_array[i].filter_id = filter_id;
|
||||
|
||||
paff_array[i].patt.offset= patt->offset;
|
||||
paff_array[i].patt.mask_size = patt->mask_size;
|
||||
paff_array[i].patt.mask = pvPortMalloc(patt->mask_size);
|
||||
memcpy(paff_array[i].patt.mask, patt->mask, patt->mask_size);
|
||||
paff_array[i].patt.pattern= pvPortMalloc(patt->mask_size);
|
||||
memcpy(paff_array[i].patt.pattern, patt->pattern, patt->mask_size);
|
||||
|
||||
paff_array[i].rule = rule;
|
||||
paff_array[i].enable = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int promisc_enable_packet_filter(u8 filter_id)
|
||||
{
|
||||
int i = 0;
|
||||
while(i < MAX_PACKET_FILTER_INFO){
|
||||
if(paff_array[i].filter_id == filter_id)
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
if(i == MAX_PACKET_FILTER_INFO)
|
||||
return -1;
|
||||
|
||||
paff_array[i].enable = 1;
|
||||
packet_filter_enable_num++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int promisc_disable_packet_filter(u8 filter_id)
|
||||
{
|
||||
int i = 0;
|
||||
while(i < MAX_PACKET_FILTER_INFO){
|
||||
if(paff_array[i].filter_id == filter_id)
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
if(i == MAX_PACKET_FILTER_INFO)
|
||||
return -1;
|
||||
|
||||
paff_array[i].enable = 0;
|
||||
packet_filter_enable_num--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int promisc_remove_packet_filter(u8 filter_id)
|
||||
{
|
||||
int i = 0;
|
||||
while(i < MAX_PACKET_FILTER_INFO){
|
||||
if(paff_array[i].filter_id == filter_id)
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
if(i == MAX_PACKET_FILTER_INFO)
|
||||
return -1;
|
||||
|
||||
paff_array[i].filter_id = FILTER_ID_INIT_VALUE;
|
||||
paff_array[i].enable = 0;
|
||||
paff_array[i].patt.mask_size = 0;
|
||||
paff_array[i].rule = 0;
|
||||
if(paff_array[i].patt.mask){
|
||||
vPortFree(paff_array[i].patt.mask);
|
||||
paff_array[i].patt.mask = NULL;
|
||||
}
|
||||
|
||||
if(paff_array[i].patt.pattern){
|
||||
vPortFree(paff_array[i].patt.pattern);
|
||||
paff_array[i].patt.pattern = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make callback simple to prevent latency to wlan rx when promiscuous mode */
|
||||
static void promisc_callback(unsigned char *buf, unsigned int len, void* userdata)
|
||||
{
|
||||
struct eth_frame *frame = (struct eth_frame *) pvPortMalloc(sizeof(struct eth_frame));
|
||||
|
||||
if(frame) {
|
||||
frame->prev = NULL;
|
||||
frame->next = NULL;
|
||||
memcpy(frame->da, buf, 6);
|
||||
memcpy(frame->sa, buf+6, 6);
|
||||
frame->len = len;
|
||||
frame->rssi = ((ieee80211_frame_info_t *)userdata)->rssi;
|
||||
taskENTER_CRITICAL();
|
||||
|
||||
if(eth_buffer.tail) {
|
||||
eth_buffer.tail->next = frame;
|
||||
frame->prev = eth_buffer.tail;
|
||||
eth_buffer.tail = frame;
|
||||
}
|
||||
else {
|
||||
eth_buffer.head = frame;
|
||||
eth_buffer.tail = frame;
|
||||
}
|
||||
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
|
||||
struct eth_frame* retrieve_frame(void)
|
||||
{
|
||||
struct eth_frame *frame = NULL;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
|
||||
if(eth_buffer.head) {
|
||||
frame = eth_buffer.head;
|
||||
|
||||
if(eth_buffer.head->next) {
|
||||
eth_buffer.head = eth_buffer.head->next;
|
||||
eth_buffer.head->prev = NULL;
|
||||
}
|
||||
else {
|
||||
eth_buffer.head = NULL;
|
||||
eth_buffer.tail = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
static void promisc_test(int duration, unsigned char len_used)
|
||||
{
|
||||
int ch;
|
||||
unsigned int start_time;
|
||||
struct eth_frame *frame;
|
||||
eth_buffer.head = NULL;
|
||||
eth_buffer.tail = NULL;
|
||||
|
||||
wifi_enter_promisc_mode();
|
||||
wifi_set_promisc(RTW_PROMISC_ENABLE, promisc_callback, len_used);
|
||||
|
||||
for(ch = 1; ch <= 13; ch ++) {
|
||||
if(wifi_set_channel(ch) == 0)
|
||||
printf("\n\n\rSwitch to channel(%d)", ch);
|
||||
|
||||
start_time = xTaskGetTickCount();
|
||||
|
||||
while(1) {
|
||||
unsigned int current_time = xTaskGetTickCount();
|
||||
|
||||
if((current_time - start_time) < (duration * configTICK_RATE_HZ)) {
|
||||
frame = retrieve_frame();
|
||||
|
||||
if(frame) {
|
||||
int i;
|
||||
printf("\n\rDA:");
|
||||
for(i = 0; i < 6; i ++)
|
||||
printf(" %02x", frame->da[i]);
|
||||
printf(", SA:");
|
||||
for(i = 0; i < 6; i ++)
|
||||
printf(" %02x", frame->sa[i]);
|
||||
printf(", len=%d", frame->len);
|
||||
printf(", RSSI=%d", frame->rssi);
|
||||
#if CONFIG_INIC_CMD_RSP
|
||||
if(inic_frame_tail){
|
||||
if(inic_frame_cnt < MAX_INIC_FRAME_NUM){
|
||||
memcpy(inic_frame_tail->da, frame->da, 6);
|
||||
memcpy(inic_frame_tail->sa, frame->sa, 6);
|
||||
inic_frame_tail->len = frame->len;
|
||||
inic_frame_tail++;
|
||||
inic_frame_cnt++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
vPortFree((void *) frame);
|
||||
}
|
||||
else
|
||||
vTaskDelay(1); //delay 1 tick
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
#if CONFIG_INIC_CMD_RSP
|
||||
if(inic_frame){
|
||||
inic_c2h_msg("ATWM", RTW_SUCCESS, (char *)inic_frame, sizeof(struct inic_eth_frame)*inic_frame_cnt);
|
||||
memset(inic_frame, '\0', sizeof(struct inic_eth_frame)*MAX_INIC_FRAME_NUM);
|
||||
inic_frame_tail = inic_frame;
|
||||
inic_frame_cnt = 0;
|
||||
rtw_msleep_os(10);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
wifi_set_promisc(RTW_PROMISC_DISABLE, NULL, 0);
|
||||
|
||||
while((frame = retrieve_frame()) != NULL)
|
||||
vPortFree((void *) frame);
|
||||
}
|
||||
|
||||
static void promisc_callback_all(unsigned char *buf, unsigned int len, void* userdata)
|
||||
{
|
||||
struct eth_frame *frame = (struct eth_frame *) pvPortMalloc(sizeof(struct eth_frame));
|
||||
|
||||
if(frame) {
|
||||
frame->prev = NULL;
|
||||
frame->next = NULL;
|
||||
memcpy(frame->da, buf+4, 6);
|
||||
memcpy(frame->sa, buf+10, 6);
|
||||
frame->len = len;
|
||||
/*
|
||||
* type is the first byte of Frame Control Field of 802.11 frame
|
||||
* If the from/to ds information is needed, type could be reused as follows:
|
||||
* frame->type = ((((ieee80211_frame_info_t *)userdata)->i_fc & 0x0100) == 0x0100) ? 2 : 1;
|
||||
* 1: from ds; 2: to ds
|
||||
*/
|
||||
frame->type = *buf;
|
||||
frame->rssi = ((ieee80211_frame_info_t *)userdata)->rssi;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
|
||||
if(eth_buffer.tail) {
|
||||
eth_buffer.tail->next = frame;
|
||||
frame->prev = eth_buffer.tail;
|
||||
eth_buffer.tail = frame;
|
||||
}
|
||||
else {
|
||||
eth_buffer.head = frame;
|
||||
eth_buffer.tail = frame;
|
||||
}
|
||||
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
static void promisc_test_all(int duration, unsigned char len_used)
|
||||
{
|
||||
int ch;
|
||||
unsigned int start_time;
|
||||
struct eth_frame *frame;
|
||||
eth_buffer.head = NULL;
|
||||
eth_buffer.tail = NULL;
|
||||
|
||||
wifi_enter_promisc_mode();
|
||||
wifi_set_promisc(RTW_PROMISC_ENABLE_2, promisc_callback_all, len_used);
|
||||
|
||||
for(ch = 1; ch <= 13; ch ++) {
|
||||
if(wifi_set_channel(ch) == 0)
|
||||
printf("\n\n\rSwitch to channel(%d)", ch);
|
||||
|
||||
start_time = xTaskGetTickCount();
|
||||
|
||||
while(1) {
|
||||
unsigned int current_time = xTaskGetTickCount();
|
||||
|
||||
if((current_time - start_time) < (duration * configTICK_RATE_HZ)) {
|
||||
frame = retrieve_frame();
|
||||
|
||||
if(frame) {
|
||||
int i;
|
||||
printf("\n\rTYPE: 0x%x, ", frame->type);
|
||||
printf("DA:");
|
||||
for(i = 0; i < 6; i ++)
|
||||
printf(" %02x", frame->da[i]);
|
||||
printf(", SA:");
|
||||
for(i = 0; i < 6; i ++)
|
||||
printf(" %02x", frame->sa[i]);
|
||||
printf(", len=%d", frame->len);
|
||||
printf(", RSSI=%d", frame->rssi);
|
||||
#if CONFIG_INIC_CMD_RSP
|
||||
if(inic_frame_tail){
|
||||
if(inic_frame_cnt < MAX_INIC_FRAME_NUM){
|
||||
memcpy(inic_frame_tail->da, frame->da, 6);
|
||||
memcpy(inic_frame_tail->sa, frame->sa, 6);
|
||||
inic_frame_tail->len = frame->len;
|
||||
inic_frame_tail->type = frame->type;
|
||||
inic_frame_tail++;
|
||||
inic_frame_cnt++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
vPortFree((void *) frame);
|
||||
}
|
||||
else
|
||||
vTaskDelay(1); //delay 1 tick
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
#if CONFIG_INIC_CMD_RSP
|
||||
if(inic_frame){
|
||||
inic_c2h_msg("ATWM", RTW_SUCCESS, (char *)inic_frame, sizeof(struct inic_eth_frame)*inic_frame_cnt);
|
||||
memset(inic_frame, '\0', sizeof(struct inic_eth_frame)*MAX_INIC_FRAME_NUM);
|
||||
inic_frame_tail = inic_frame;
|
||||
inic_frame_cnt = 0;
|
||||
rtw_msleep_os(10);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
wifi_set_promisc(RTW_PROMISC_DISABLE, NULL, 0);
|
||||
|
||||
while((frame = retrieve_frame()) != NULL)
|
||||
vPortFree((void *) frame);
|
||||
}
|
||||
|
||||
void cmd_promisc(int argc, char **argv)
|
||||
{
|
||||
int duration;
|
||||
#if CONFIG_INIC_CMD_RSP
|
||||
inic_frame_tail = inic_frame = pvPortMalloc(sizeof(struct inic_eth_frame)*MAX_INIC_FRAME_NUM);
|
||||
if(inic_frame == NULL){
|
||||
inic_c2h_msg("ATWM", RTW_BUFFER_UNAVAILABLE_TEMPORARY, NULL, 0);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_PROMISC
|
||||
wifi_init_packet_filter();
|
||||
#endif
|
||||
if((argc == 2) && ((duration = atoi(argv[1])) > 0))
|
||||
//promisc_test(duration, 0);
|
||||
promisc_test_all(duration, 0);
|
||||
else if((argc == 3) && ((duration = atoi(argv[1])) > 0) && (strcmp(argv[2], "with_len") == 0))
|
||||
promisc_test(duration, 1);
|
||||
else
|
||||
printf("\n\rUsage: %s DURATION_SECONDS [with_len]", argv[0]);
|
||||
#if CONFIG_INIC_CMD_RSP
|
||||
if(inic_frame)
|
||||
vPortFree(inic_frame);
|
||||
inic_frame_tail = NULL;
|
||||
inic_frame_cnt = 0;
|
||||
#endif
|
||||
}
|
||||
#endif //#if CONFIG_WLAN
|
||||
1708
component/common/api/wifi/wifi_simple_config.c
Normal file
1708
component/common/api/wifi/wifi_simple_config.c
Normal file
File diff suppressed because it is too large
Load diff
20
component/common/api/wifi/wifi_simple_config.h
Normal file
20
component/common/api/wifi/wifi_simple_config.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef __WIFI_SIMPLE_CONFIG_H
|
||||
#define __WIFI_SIMPLE_CONFIG_H
|
||||
/*****************************wifi_simple_config.h****************************/
|
||||
enum sc_result {
|
||||
SC_ERROR = -1, /* default error code*/
|
||||
SC_NO_CONTROLLER_FOUND = 1, /* cannot get sta(controller) in the air which starts a simple config session */
|
||||
SC_CONTROLLER_INFO_PARSE_FAIL, /* cannot parse the sta's info */
|
||||
SC_TARGET_CHANNEL_SCAN_FAIL, /* cannot scan the target channel */
|
||||
SC_JOIN_BSS_FAIL, /* fail to connect to target ap */
|
||||
SC_DHCP_FAIL, /* fail to get ip address from target ap */
|
||||
/* fail to create udp socket to send info to controller. note that client isolation
|
||||
must be turned off in ap. we cannot know if ap has configured this */
|
||||
SC_UDP_SOCKET_CREATE_FAIL,
|
||||
SC_TERMINATE,
|
||||
SC_SUCCESS, /* default success code */
|
||||
|
||||
};
|
||||
int SC_send_simple_config_ack(u8 round);
|
||||
|
||||
#endif //__WIFI_SIMPLE_CONFIG_H
|
||||
117
component/common/api/wifi/wifi_simple_config_parser.h
Normal file
117
component/common/api/wifi/wifi_simple_config_parser.h
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
#ifndef __SIMPLE_CONFIG_H__
|
||||
#define __SIMPLE_CONFIG_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* This macro means user take simple config
|
||||
* lib to another platform such as linux, and
|
||||
* have no rom crypto libs of simple config,
|
||||
* so we take simple_config_crypto as a sw lib
|
||||
* This macro is used by Realtek internal to generate simple config lib
|
||||
* Please delete this macro after generation.
|
||||
*/
|
||||
#define SIMPLE_CONFIG_PLATFORM_LIB 0
|
||||
|
||||
#include "platform_opts.h"
|
||||
#include "autoconf.h"
|
||||
|
||||
|
||||
|
||||
/* platform related settings */
|
||||
#if (defined(CONFIG_PLATFORM_8195A)|| defined(CONFIG_PLATFORM_8711B))
|
||||
#undef u32
|
||||
#undef s32
|
||||
#undef u8
|
||||
#undef s8
|
||||
#undef u16
|
||||
#undef s16
|
||||
typedef unsigned int u32;
|
||||
typedef signed int s32;
|
||||
typedef unsigned char u8;
|
||||
typedef char s8;
|
||||
typedef unsigned short int u16;
|
||||
typedef signed short int s16;
|
||||
#else
|
||||
#include "osdep_service.h"
|
||||
#endif
|
||||
|
||||
typedef int (*simple_config_printf_fn) (char const * fmt, ...);
|
||||
typedef void* (*simple_config_memset_fn) (void *dst0, s32 Val, u32 length);
|
||||
typedef void* (*simple_config_memcpy_fn) ( void *s1, const void *s2, u32 n );
|
||||
typedef u32 (*simple_config_strlen_fn) (const char *s);
|
||||
typedef char * (*simple_config_strcpy_fn) (char *dest, const char *src);
|
||||
typedef void (*simple_config_free_fn) (u8 *pbuf, u32 sz);
|
||||
typedef u8* (*simple_config_zmalloc_fn) (u32 sz);
|
||||
typedef u8* (*simple_config_malloc_fn) (u32 sz);
|
||||
typedef int (*simple_config_memcmp_fn) (const void *av, const void *bv, u32 len);
|
||||
typedef u32 (*simple_config_ntohl_fn)(u32 x);
|
||||
|
||||
|
||||
|
||||
struct simple_config_lib_config {
|
||||
simple_config_printf_fn printf;
|
||||
simple_config_memset_fn memset;
|
||||
simple_config_memcpy_fn memcpy;
|
||||
simple_config_strlen_fn strlen;
|
||||
simple_config_strcpy_fn strcpy;
|
||||
simple_config_free_fn free;
|
||||
simple_config_zmalloc_fn zmalloc;
|
||||
simple_config_malloc_fn malloc;
|
||||
simple_config_memcmp_fn memcmp;
|
||||
simple_config_ntohl_fn _ntohl;
|
||||
|
||||
|
||||
int *is_promisc_callback_unlock;
|
||||
|
||||
};
|
||||
|
||||
#pragma pack(1)
|
||||
struct rtk_test_sc {
|
||||
/* API exposed to user */
|
||||
unsigned char ssid[32];
|
||||
unsigned char password[65];
|
||||
unsigned int ip_addr;
|
||||
};
|
||||
// for softAP mode
|
||||
typedef enum {
|
||||
SOFTAP_ERROR = -1,
|
||||
SOFTAP_INIT,
|
||||
SOFTAP_RECV_A,
|
||||
SOFTAP_HANDSHAKE_DONE,
|
||||
SOFTAP_DECODE_SUCCESS,
|
||||
} SC_softAP_status;
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct _SC_softAP_decode_ctx {
|
||||
u8 nonceA[16];
|
||||
u8 nonceB[32];
|
||||
u8 mac[6];
|
||||
SC_softAP_status softAP_decode_status;
|
||||
} SC_softAP_decode_ctx;
|
||||
|
||||
/* expose data */
|
||||
extern s32 is_promisc_callback_unlock;
|
||||
extern u8 g_bssid[6];
|
||||
extern u8 get_channel_flag;
|
||||
extern u8 g_security_mode;
|
||||
|
||||
/* expose API */
|
||||
extern s32 rtk_sc_init(char *custom_pin_code, struct simple_config_lib_config* config);
|
||||
extern int rtl_pre_parse(u8 *mac_addr, u8 *buf, void *userdata, u8 **da, u8 **sa, unsigned int *len);
|
||||
extern s32 rtk_start_parse_packet(u8 *da, u8 *sa, s32 len, void * user_data, void *backup_sc);
|
||||
extern SC_softAP_status softAP_simpleConfig_parse(unsigned char *buf, int len, void *backup_sc_ctx, void *psoftAP_ctx);
|
||||
extern void rtk_restart_simple_config(void);
|
||||
extern void rtk_sc_deinit();
|
||||
extern void wifi_enter_promisc_mode();
|
||||
extern void whc_fix_channel();
|
||||
extern void whc_unfix_channel();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __SIMPLE_CONFIG_H__*/
|
||||
1341
component/common/api/wifi/wifi_util.c
Normal file
1341
component/common/api/wifi/wifi_util.c
Normal file
File diff suppressed because it is too large
Load diff
77
component/common/api/wifi/wifi_util.h
Normal file
77
component/common/api/wifi/wifi_util.h
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef _UTIL_H
|
||||
#define _UTIL_H
|
||||
|
||||
#include <wireless.h>
|
||||
#include <wlan_intf.h>
|
||||
#include <wifi_constants.h>
|
||||
#include "wifi_structures.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
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_bssid(const char *ifname, const __u8 *bssid);
|
||||
int wext_get_bssid(const char *ifname, __u8 *bssid);
|
||||
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, __u8 *key_idx, __u8 *passphrase);
|
||||
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, rtw_country_code_t 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_register_multicast_address(const char *ifname, rtw_mac_t *mac);
|
||||
int wext_unregister_multicast_address(const char *ifname, rtw_mac_t *mac);
|
||||
int wext_set_scan(const char *ifname, char *buf, __u16 buf_len, __u16 flags);
|
||||
int wext_get_scan(const char *ifname, char *buf, __u16 buf_len);
|
||||
int wext_set_mac_address(const char *ifname, char * mac);
|
||||
int wext_get_mac_address(const char *ifname, char * mac);
|
||||
int wext_enable_powersave(const char *ifname, __u8 lps_mode, __u8 ips_mode);
|
||||
int wext_disable_powersave(const char *ifname);
|
||||
int wext_set_tdma_param(const char *ifname, __u8 slot_period, __u8 rfon_period_len_1, __u8 rfon_period_len_2, __u8 rfon_period_len_3);
|
||||
int wext_set_lps_dtim(const char *ifname, __u8 lps_dtim);
|
||||
int wext_get_lps_dtim(const char *ifname, __u8 *lps_dtim);
|
||||
int wext_get_tx_power(const char *ifname, __u8 *poweridx);
|
||||
int wext_set_txpower(const char *ifname, int poweridx);
|
||||
int wext_get_associated_client_list(const char *ifname, void * client_list_buffer, __u16 buffer_length);
|
||||
int wext_get_ap_info(const char *ifname, rtw_bss_info_t * ap_info, rtw_security_t* security);
|
||||
int wext_mp_command(const char *ifname, char *cmd, int show_msg);
|
||||
int wext_private_command(const char *ifname, char *cmd, int show_msg);
|
||||
int wext_private_command_with_retval(const char *ifname, char *cmd, char *ret_buf, int ret_len);
|
||||
void wext_wlan_indicate(unsigned int cmd, union iwreq_data *wrqu, char *extra);
|
||||
int wext_set_pscan_channel(const char *ifname, __u8 *ch, __u8 *pscan_config, __u8 length);
|
||||
int wext_set_autoreconnect(const char *ifname, __u8 mode, __u8 retry_times, __u16 timeout);
|
||||
int wext_get_autoreconnect(const char *ifname, __u8 *mode);
|
||||
int wext_set_adaptivity(rtw_adaptivity_mode_t adaptivity_mode);
|
||||
int wext_set_adaptivity_th_l2h_ini(__u8 l2h_threshold);
|
||||
int wext_get_auto_chl(const char *ifname, unsigned char *channel_set, unsigned char channel_num);
|
||||
int wext_set_sta_num(unsigned char ap_sta_num);
|
||||
int wext_del_station(const char *ifname, unsigned char* hwaddr);
|
||||
int wext_init_mac_filter(void);
|
||||
int wext_deinit_mac_filter(void);
|
||||
int wext_add_mac_filter(unsigned char* hwaddr);
|
||||
int wext_del_mac_filter(unsigned char* hwaddr);
|
||||
void wext_set_indicate_mgnt(int enable);
|
||||
#ifdef CONFIG_CUSTOM_IE
|
||||
int wext_add_custom_ie(const char *ifname, void * cus_ie, int ie_num);
|
||||
int wext_update_custom_ie(const char *ifname, void * cus_ie, int ie_index);
|
||||
int wext_del_custom_ie(const char *ifname);
|
||||
#endif
|
||||
|
||||
#define wext_handshake_done rltk_wlan_handshake_done
|
||||
|
||||
int wext_send_mgnt(const char *ifname, char *buf, __u16 buf_len, __u16 flags);
|
||||
int wext_send_eapol(const char *ifname, char *buf, __u16 buf_len, __u16 flags);
|
||||
int wext_set_gen_ie(const char *ifname, char *buf, __u16 buf_len, __u16 flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _UTIL_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue