CARPLAY版本整理
This commit is contained in:
2385
MXC_A27-PCB4.5-270T/lib/wlan/RTL8189FTV/api/wifi/wifi_conf.c
Normal file
2385
MXC_A27-PCB4.5-270T/lib/wlan/RTL8189FTV/api/wifi/wifi_conf.c
Normal file
File diff suppressed because it is too large
Load Diff
1050
MXC_A27-PCB4.5-270T/lib/wlan/RTL8189FTV/api/wifi/wifi_conf.h
Normal file
1050
MXC_A27-PCB4.5-270T/lib/wlan/RTL8189FTV/api/wifi/wifi_conf.h
Normal file
File diff suppressed because it is too large
Load Diff
285
MXC_A27-PCB4.5-270T/lib/wlan/RTL8189FTV/api/wifi/wifi_ind.c
Normal file
285
MXC_A27-PCB4.5-270T/lib/wlan/RTL8189FTV/api/wifi/wifi_ind.c
Normal file
@ -0,0 +1,285 @@
|
||||
//----------------------------------------------------------------------------//
|
||||
#include <stdint.h>
|
||||
#include "wifi/wifi_ind.h"
|
||||
#include "wifi/wifi_conf.h"
|
||||
#include "osdep_service.h"
|
||||
#include "basic_types.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);
|
||||
//DBG_INFO("!!!!!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){
|
||||
DBG_INFO("rtw_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_result_t)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.
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
switch(event)
|
||||
{
|
||||
case WIFI_EVENT_DISCONNECT:
|
||||
DBG_INFO("%s():Disconnection indication received", __FUNCTION__);
|
||||
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
|
||||
// Sample: return mac address
|
||||
if(buf != NULL && buf_len == 6)
|
||||
{
|
||||
DBG_INFO("%s():Connect indication received: %02x:%02x:%02x:%02x:%02x:%02x", __FUNCTION__,
|
||||
buf[0],buf[1],buf[2],buf[3],buf[4],buf[5]);
|
||||
}
|
||||
break;
|
||||
case WIFI_EVENT_FOURWAY_HANDSHAKE_DONE:
|
||||
if(buf != NULL)
|
||||
{
|
||||
if(buf_len == strlen(IW_EXT_STR_FOURWAY_DONE))
|
||||
DBG_INFO("%s():%s", __FUNCTION__, buf);
|
||||
}
|
||||
break;
|
||||
case WIFI_EVENT_SCAN_RESULT_REPORT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_SCAN_RESULT_REPORT\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_SCAN_DONE:
|
||||
DBG_INFO("%s(): WIFI_EVENT_SCAN_DONE\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_RECONNECTION_FAIL:
|
||||
if(buf != NULL){
|
||||
if(buf_len == strlen(IW_EXT_STR_RECONNECTION_FAIL))
|
||||
DBG_INFO("%s", buf);
|
||||
}
|
||||
break;
|
||||
case WIFI_EVENT_NO_NETWORK:
|
||||
DBG_INFO("%s(): WIFI_EVENT_NO_NETWORK\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_RX_MGNT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_RX_MGNT\n", __func__);
|
||||
break;
|
||||
#if CONFIG_ENABLE_P2P
|
||||
case WIFI_EVENT_SEND_ACTION_DONE:
|
||||
DBG_INFO("%s(): WIFI_EVENT_SEND_ACTION_DONE\n", __func__);
|
||||
break;
|
||||
#endif //CONFIG_ENABLE_P2P
|
||||
case WIFI_EVENT_STA_ASSOC:
|
||||
DBG_INFO("%s(): WIFI_EVENT_STA_ASSOC\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_STA_DISASSOC:
|
||||
DBG_INFO("%s(): WIFI_EVENT_STA_DISASSOC\n", __func__);
|
||||
break;
|
||||
#if CONFIG_WPS
|
||||
case WIFI_EVENT_STA_WPS_START:
|
||||
DBG_INFO("%s(): WIFI_EVENT_STA_WPS_START\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_WPS_FINISH:
|
||||
DBG_INFO("%s(): WIFI_EVENT_WPS_FINISH\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_EAPOL_RECVD:
|
||||
DBG_INFO("%s(): WIFI_EVENT_EAPOL_RECVD\n", __func__);
|
||||
break;
|
||||
#endif
|
||||
case WIFI_EVENT_BEACON_AFTER_DHCP:
|
||||
DBG_INFO("%s(): WIFI_EVENT_BEACON_AFTER_DHCP\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_IP_CHANGED:
|
||||
DBG_INFO("%s(): WIFI_EVENT_IP_CHANNGED\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_ICV_ERROR:
|
||||
DBG_INFO("%s(): WIFI_EVENT_ICV_ERROR\n", __func__);
|
||||
case WIFI_EVENT_CHALLENGE_FAIL:
|
||||
DBG_INFO("%s(): WIFI_EVENT_CHALLENGE_FAIL\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_SCAN_START:
|
||||
DBG_INFO("%s(): WIFI_EVENT_SCAN_START\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_SCAN_FAILED:
|
||||
DBG_INFO("%s(): WIFI_EVENT_SCAN_FAILED\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_AUTHENTICATION:
|
||||
DBG_INFO("%s(): WIFI_EVENT_AUTHENTICATION\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_AUTH_REJECT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_AUTH_REJECT\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_DEAUTH:
|
||||
DBG_INFO("%s(): WIFI_EVENT_DEAUTH\n", __func__);
|
||||
break;
|
||||
|
||||
case WIFI_EVENT_AUTH_TIMEOUT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_AUTH_TIMEOUT\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_ASSOCIATING:
|
||||
DBG_INFO("%s(): WIFI_EVENT_ASSOCIATING\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_ASSOCIATED:
|
||||
DBG_INFO("%s(): WIFI_EVENT_ASSOCIATED\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_ASSOC_REJECT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_ASSOC_REJECT\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_ASSOC_TIMEOUT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_ASSOC_TIMEOUT\n", __func__);
|
||||
break;
|
||||
|
||||
case WIFI_EVENT_HANDSHAKE_FAILED:
|
||||
DBG_INFO("%s(): WIFI_EVENT_HANDSHAKE_FAILED\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_4WAY_HANDSHAKE:
|
||||
DBG_INFO("%s(): WIFI_EVENT_4WAY_HANDSHAKE\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_GROUP_HANDSHAKE:
|
||||
DBG_INFO("%s(): WIFI_EVENT_GROUP_HANDSHAKE\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_GROUP_HANDSHAKE_DONE:
|
||||
DBG_INFO("%s(): WIFI_EVENT_GROUP_HANDSHAKE_DONE\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_CONN_TIMEOUT:
|
||||
DBG_INFO("%s(): WIFI_CONN_TIMEOUT\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_LEAVE_BUSY_TRAFFIC:
|
||||
DBG_INFO("%s(): WIFI_EVENT_LEAVE_BUSY_TRAFFIC\n", __func__);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#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
|
||||
}
|
||||
|
104
MXC_A27-PCB4.5-270T/lib/wlan/RTL8189FTV/api/wifi/wifi_ind.h
Normal file
104
MXC_A27-PCB4.5-270T/lib/wlan/RTL8189FTV/api/wifi/wifi_ind.h
Normal file
@ -0,0 +1,104 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
* @file wifi_ind.h
|
||||
* @author
|
||||
* @version
|
||||
* @brief This file provides the functions related to event handler mechanism.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _WIFI_INDICATE_H
|
||||
#define _WIFI_INDICATE_H
|
||||
|
||||
/** @addtogroup nic NIC
|
||||
* @ingroup wlan
|
||||
* @brief NIC functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "wifi_conf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*\@}*/
|
||||
|
||||
#endif //_WIFI_INDICATE_H
|
||||
|
445
MXC_A27-PCB4.5-270T/lib/wlan/RTL8189FTV/api/wifi/wifi_promisc.c
Normal file
445
MXC_A27-PCB4.5-270T/lib/wlan/RTL8189FTV/api/wifi/wifi_promisc.c
Normal file
@ -0,0 +1,445 @@
|
||||
#include <osdep_service.h>
|
||||
#include "wifi/wifi_conf.h"
|
||||
#ifndef CONFIG_WLAN
|
||||
#define CONFIG_WLAN 1
|
||||
#endif
|
||||
|
||||
#if CONFIG_WLAN
|
||||
#include <basic_types.h>
|
||||
|
||||
extern void _promisc_deinit(void *padapter);
|
||||
extern int _promisc_recv_func(void *padapter, void *rframe);
|
||||
extern int _promisc_set(rtw_rcr_level_t enabled, void (*callback)(unsigned char*, unsigned int, void*), unsigned char len_used);
|
||||
extern unsigned char _is_promisc_enabled(void);
|
||||
extern int _promisc_get_fixed_channel(void * fixed_bssid, u8 *ssid, int * ssid_length);
|
||||
extern void _promisc_filter_by_ap_and_phone_mac(u8 enable, void *ap_mac, void *phone_mac);
|
||||
// Add extra interfaces to make release sdk able to determine promisc API linking
|
||||
void promisc_deinit(void *padapter)
|
||||
{
|
||||
#if CONFIG_PROMISC
|
||||
_promisc_deinit(padapter);
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_recv_func(void *padapter, void *rframe)
|
||||
{
|
||||
// Never reach here if not define CONFIG_PROMISC
|
||||
#if CONFIG_PROMISC
|
||||
return _promisc_recv_func(padapter, rframe);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_recv_lens_func(void *padapter, u8 *payload, u8 plen)
|
||||
{
|
||||
// Never reach here if not define CONFIG_PROMISC
|
||||
#if CONFIG_PROMISC
|
||||
#if CONFIG_UNSUPPORT_PLCPHDR_RPT
|
||||
return _promisc_recv_lens_func(padapter, payload, plen);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_filter_with_len(u16 len)
|
||||
{
|
||||
// Never reach here if not define CONFIG_PROMISC
|
||||
#if CONFIG_PROMISC
|
||||
#if CONFIG_UNSUPPORT_PLCPHDR_RPT
|
||||
return _promisc_filter_with_len(len);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_set(rtw_rcr_level_t enabled, void (*callback)(unsigned char*, unsigned int, void*), unsigned char len_used)
|
||||
{
|
||||
#if CONFIG_PROMISC
|
||||
return _promisc_set(enabled, callback, len_used);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned char is_promisc_enabled(void)
|
||||
{
|
||||
#if CONFIG_PROMISC
|
||||
return _is_promisc_enabled();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_get_fixed_channel(void *fixed_bssid, u8 *ssid, int *ssid_length)
|
||||
{
|
||||
#if CONFIG_PROMISC
|
||||
return _promisc_get_fixed_channel(fixed_bssid, ssid, ssid_length);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void promisc_filter_by_ap_and_phone_mac(u8 enable, void *ap_mac, void *phone_mac)
|
||||
{
|
||||
#if CONFIG_PROMISC
|
||||
_promisc_filter_by_ap_and_phone_mac(enable, ap_mac, phone_mac);
|
||||
#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;
|
||||
};
|
||||
|
||||
struct eth_buffer {
|
||||
struct eth_frame *head;
|
||||
struct eth_frame *tail;
|
||||
};
|
||||
|
||||
static struct eth_buffer eth_buffer;
|
||||
|
||||
#if 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 = rtw_malloc(patt->mask_size);
|
||||
memcpy(paff_array[i].patt.mask, patt->mask, patt->mask_size);
|
||||
paff_array[i].patt.pattern= rtw_malloc(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){
|
||||
rtw_free(paff_array[i].patt.mask);
|
||||
paff_array[i].patt.mask = NULL;
|
||||
}
|
||||
|
||||
if(paff_array[i].patt.pattern){
|
||||
rtw_free(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 *) rtw_malloc(sizeof(struct eth_frame));
|
||||
_lock lock;
|
||||
_irqL irqL;
|
||||
|
||||
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;
|
||||
|
||||
rtw_enter_critical(&lock, &irqL);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
rtw_exit_critical(&lock, &irqL);
|
||||
}
|
||||
}
|
||||
|
||||
struct eth_frame* retrieve_frame(void)
|
||||
{
|
||||
struct eth_frame *frame = NULL;
|
||||
_lock lock;
|
||||
_irqL irqL;
|
||||
|
||||
rtw_enter_critical(&lock, &irqL);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
rtw_exit_critical(&lock, &irqL);
|
||||
|
||||
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)
|
||||
DBG_INFO("Switch to channel(%d)", ch);
|
||||
|
||||
start_time = rtw_get_current_time();
|
||||
|
||||
while(1) {
|
||||
unsigned int current_time = rtw_get_current_time();
|
||||
|
||||
if(rtw_systime_to_ms(current_time - start_time) < duration) {
|
||||
frame = retrieve_frame();
|
||||
|
||||
if(frame) {
|
||||
int i;
|
||||
DBG_INFO("DA:");
|
||||
for(i = 0; i < 6; i ++)
|
||||
printk(" %02x", frame->da[i]);
|
||||
printk(", SA:");
|
||||
for(i = 0; i < 6; i ++)
|
||||
printk(" %02x", frame->sa[i]);
|
||||
printk(", len=%d", frame->len);
|
||||
printk(", RSSI=%d", frame->rssi);
|
||||
rtw_free((void *) frame);
|
||||
}
|
||||
else
|
||||
rtw_mdelay_os(1); //delay 1 tick
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wifi_set_promisc(RTW_PROMISC_DISABLE, NULL, 0);
|
||||
|
||||
while((frame = retrieve_frame()) != NULL)
|
||||
rtw_free((void *) frame);
|
||||
}
|
||||
|
||||
static void promisc_callback_all(unsigned char *buf, unsigned int len, void* userdata)
|
||||
{
|
||||
struct eth_frame *frame = (struct eth_frame *) rtw_malloc(sizeof(struct eth_frame));
|
||||
_lock lock;
|
||||
_irqL irqL;
|
||||
|
||||
if(frame) {
|
||||
frame->prev = NULL;
|
||||
frame->next = NULL;
|
||||
#if CONFIG_UNSUPPORT_PLCPHDR_RPT
|
||||
if(((ieee80211_frame_info_t *)userdata)->type == RTW_RX_UNSUPPORT){
|
||||
//NOTICE: buf structure now is rtw_rx_info_t.
|
||||
frame->type = 0xFF;
|
||||
memset(frame->da, 0, 6);
|
||||
memset(frame->sa, 0, 6);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
memcpy(frame->da, buf+4, 6);
|
||||
memcpy(frame->sa, buf+10, 6);
|
||||
frame->type = *buf;
|
||||
}
|
||||
|
||||
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->rssi = ((ieee80211_frame_info_t *)userdata)->rssi;
|
||||
|
||||
rtw_enter_critical(&lock, &irqL);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
rtw_exit_critical(&lock, &irqL);
|
||||
}
|
||||
}
|
||||
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)
|
||||
DBG_INFO("Switch to channel(%d)", ch);
|
||||
|
||||
start_time = rtw_get_current_time();
|
||||
|
||||
while(1) {
|
||||
unsigned int current_time = rtw_get_current_time();
|
||||
|
||||
if(rtw_systime_to_ms(current_time - start_time) < duration) {
|
||||
frame = retrieve_frame();
|
||||
|
||||
if(frame) {
|
||||
int i;
|
||||
DBG_INFO("TYPE: 0x%x, ", frame->type);
|
||||
printk("DA:");
|
||||
for(i = 0; i < 6; i ++)
|
||||
printk(" %02x", frame->da[i]);
|
||||
printk(", SA:");
|
||||
for(i = 0; i < 6; i ++)
|
||||
printk(" %02x", frame->sa[i]);
|
||||
printk(", len=%d", frame->len);
|
||||
printk(", RSSI=%d", frame->rssi);
|
||||
rtw_free((void *) frame);
|
||||
}
|
||||
else
|
||||
rtw_mdelay_os(1); //delay 1 tick
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wifi_set_promisc(RTW_PROMISC_DISABLE, NULL, 0);
|
||||
|
||||
while((frame = retrieve_frame()) != NULL)
|
||||
rtw_free((void *) frame);
|
||||
}
|
||||
|
||||
void cmd_promisc(int argc, char **argv)
|
||||
{
|
||||
int duration;
|
||||
#if 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
|
||||
DBG_INFO("Usage: %s DURATION_SECONDS [with_len]", argv[0]);
|
||||
}
|
||||
#endif //#if CONFIG_WLAN
|
1836
MXC_A27-PCB4.5-270T/lib/wlan/RTL8189FTV/api/wifi/wifi_util.c
Normal file
1836
MXC_A27-PCB4.5-270T/lib/wlan/RTL8189FTV/api/wifi/wifi_util.c
Normal file
File diff suppressed because it is too large
Load Diff
121
MXC_A27-PCB4.5-270T/lib/wlan/RTL8189FTV/api/wifi/wifi_util.h
Normal file
121
MXC_A27-PCB4.5-270T/lib/wlan/RTL8189FTV/api/wifi/wifi_util.h
Normal file
@ -0,0 +1,121 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef _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_mfp_support(const char *ifname, __u8 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);
|
||||
#if CONFIG_MULTICAST
|
||||
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_enable_multicast_address_filter(const char *ifname);
|
||||
int wext_disable_multicast_address_filter(const char *ifname);
|
||||
#endif
|
||||
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_set_lps_level(const char *ifname, __u8 lps_level);
|
||||
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_SW_MAILBOX_EN
|
||||
int wext_mailbox_to_wifi(const char *ifname, char *buf, __u16 buf_len);
|
||||
#endif
|
||||
#if 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);
|
||||
int wext_get_drv_ability(const char *ifname, __u32 *ability);
|
||||
int wext_enable_forwarding(const char *ifname);
|
||||
int wext_disable_forwarding(const char *ifname);
|
||||
int wext_set_ch_deauth(const char *ifname, __u8 enable);
|
||||
|
||||
#if CONFIG_WOWLAN
|
||||
int wext_wowlan_ctrl(const char *ifname, int enable);
|
||||
int wext_wowlan_set_pattern(const char *ifname, wowlan_pattern_t pattern);
|
||||
int wext_wowlan_unicast_wake_ctrl(const char *ifname, unsigned char enable);
|
||||
#endif
|
||||
int wext_enable_rawdata_recv(const char *ifname, void *fun);
|
||||
int wext_disable_rawdata_recv(const char *ifname);
|
||||
int wext_send_rawdata(const char *ifname,const unsigned char* frame_buf, unsigned int frame_len);
|
||||
int wext_enable_adaptivity(const char *ifname);
|
||||
int wext_disable_adaptivity(const char *ifname);
|
||||
int wext_get_real_time_data_rate_info(const char *ifname, unsigned char *prate, unsigned char *pshort_gi, unsigned char *pbandwidth);
|
||||
int wext_get_snr(const char *ifname, unsigned char *ofdm_snr, unsigned char *ht_snr);
|
||||
int wext_set_retry_limit(const char *ifname, unsigned char retry_limit);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _UTIL_H */
|
||||
|
1521
MXC_A27-PCB4.5-270T/lib/wlan/RTL8189FTV/api/wifi_interactive_mode.c
Normal file
1521
MXC_A27-PCB4.5-270T/lib/wlan/RTL8189FTV/api/wifi_interactive_mode.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user