Merge pull request #4667 from Archcady/mute_debug_msg

Update and mute debug messages of REALTEK_TRL8195AM
pull/4714/head
Martin Kojtal 2017-07-13 16:47:31 +02:00 committed by GitHub
commit 43a361214a
10 changed files with 87 additions and 73 deletions

View File

@ -85,12 +85,14 @@ static rtw_result_t scan_result_handler( rtw_scan_handler_result_t* malloced_sca
return RTW_SUCCESS;
}
RTWInterface::RTWInterface()
RTWInterface::RTWInterface(bool debug)
: _dhcp(true), _ip_address(), _netmask(), _gateway()
{
emac_interface_t *emac;
int ret;
extern u32 GlobalDebugEnable;
GlobalDebugEnable = debug?1:0;
emac = wlan_emac_init_interface();
if (!emac) {
printf("Error init RTWInterface!\r\n");

View File

@ -34,7 +34,7 @@ class RTWInterface: public WiFiInterface
public:
/** RTWWlanInterface lifetime
*/
RTWInterface();
RTWInterface(bool debug=false);
~RTWInterface();
/** Set a static IP address

View File

@ -30,6 +30,12 @@
#if CONFIG_EXAMPLE_UART_ATCMD
#include "at_cmd/atcmd_wifi.h"
#endif
extern u32 GlobalDebugEnable;
#define WIFI_CONF_MSG(...) do {\
if (GlobalDebugEnable) \
printf("\r" __VA_ARGS__);\
}while(0)
#if CONFIG_INIC_EN
extern int inic_start(void);
extern int inic_stop(void);
@ -195,7 +201,7 @@ static int wifi_connect_local(rtw_network_info_t *pWifi)
break;
default:
ret = -1;
printf("\n\rWIFICONF: security type(0x%x) is not supported.\n\r", pWifi->security_type);
WIFI_CONF_MSG("\n\rWIFICONF: security type(0x%x) is not supported.\n\r", pWifi->security_type);
break;
}
if(ret == 0)
@ -244,7 +250,7 @@ static int wifi_connect_bssid_local(rtw_network_info_t *pWifi)
break;
default:
ret = -1;
printf("\n\rWIFICONF: security type(0x%x) is not supported.\n\r", pWifi->security_type);
WIFI_CONF_MSG("\n\rWIFICONF: security type(0x%x) is not supported.\n\r", pWifi->security_type);
break;
}
if(ret == 0){
@ -351,7 +357,7 @@ void restore_wifi_info_to_flash()
if(data_to_flash && p_write_reconnect_ptr){
if(wifi_get_setting((const char*)ifname[0],&setting) || setting.mode == RTW_MODE_AP){
printf("\r\n %s():wifi_get_setting fail or ap mode", __func__);
WIFI_CONF_MSG("\r\n %s():wifi_get_setting fail or ap mode", __func__);
return;
}
channel = setting.channel;
@ -515,7 +521,7 @@ int wifi_connect(
#ifdef CONFIG_ENABLE_EAP
if(get_eap_phase()){
if(rtw_down_timeout_sema( &join_result->join_sema, 60000 ) == RTW_FALSE) {
printf("RTW API: Join bss timeout\r\n");
WIFI_CONF_MSG("RTW API: Join bss timeout\r\n");
if(password_len) {
rtw_free(join_result->network_info.password);
}
@ -531,7 +537,7 @@ int wifi_connect(
else
#endif
if(rtw_down_timeout_sema( &join_result->join_sema, RTW_JOIN_TIMEOUT ) == RTW_FALSE) {
printf("RTW API: Join bss timeout\r\n");
WIFI_CONF_MSG("RTW API: Join bss timeout\r\n");
if(password_len) {
rtw_free(join_result->network_info.password);
}
@ -641,7 +647,7 @@ int wifi_connect_bssid(
if(semaphore == NULL) {
if(rtw_down_timeout_sema( &join_result->join_sema, RTW_JOIN_TIMEOUT ) == RTW_FALSE) {
printf("RTW API: Join bss timeout\r\n");
WIFI_CONF_MSG("RTW API: Join bss timeout\r\n");
if(password_len) {
rtw_free(join_result->network_info.password);
}
@ -685,7 +691,7 @@ int wifi_disconnect(void)
const __u8 null_bssid[ETH_ALEN + 2] = {0, 0, 0, 0, 0, 1, 0, 0};
if (wext_set_bssid(WLAN0_NAME, null_bssid) < 0){
printf("\n\rWEXT: Failed to set bogus BSSID to disconnect");
WIFI_CONF_MSG("\n\rWEXT: Failed to set bogus BSSID to disconnect");
ret = -1;
}
return ret;
@ -918,7 +924,7 @@ int wifi_on(rtw_mode_t mode)
static int event_init = 0;
if(rltk_wlan_running(WLAN0_IDX)) {
printf("\n\rWIFI is already running");
WIFI_CONF_MSG("\n\rWIFI is already running");
return 1;
}
@ -934,7 +940,7 @@ int wifi_on(rtw_mode_t mode)
// set wifi mib
wifi_set_mib();
printf("\n\rInitializing WIFI ...");
WIFI_CONF_MSG("\n\rInitializing WIFI ...");
for(idx=0;idx<devnum;idx++){
ret = rltk_wlan_init(idx, mode);
if(ret <0)
@ -943,7 +949,7 @@ int wifi_on(rtw_mode_t mode)
for(idx=0;idx<devnum;idx++){
ret = rltk_wlan_start(idx);
if(ret <0){
printf("\n\rERROR: Start WIFI Failed!");
WIFI_CONF_MSG("\n\rERROR: Start WIFI Failed!");
rltk_wlan_deinit();
return ret;
}
@ -951,7 +957,7 @@ int wifi_on(rtw_mode_t mode)
while(1) {
if(rltk_wlan_running(devnum-1)) {
printf("\n\rWIFI initialized\n");
WIFI_CONF_MSG("\n\rWIFI initialized\n");
/*
@ -962,7 +968,7 @@ int wifi_on(rtw_mode_t mode)
}
if(timeout == 0) {
printf("\n\rERROR: Init WIFI timeout!");
WIFI_CONF_MSG("\n\rERROR: Init WIFI timeout!");
break;
}
@ -994,7 +1000,7 @@ int wifi_off(void)
if((rltk_wlan_running(WLAN0_IDX) == 0) &&
(rltk_wlan_running(WLAN1_IDX) == 0)) {
printf("\n\rWIFI is not running");
WIFI_CONF_MSG("\n\rWIFI is not running");
return 0;
}
#if CONFIG_LWIP_LAYER
@ -1011,18 +1017,18 @@ int wifi_off(void)
if((wifi_mode == RTW_MODE_AP) || (wifi_mode == RTW_MODE_STA_AP))
wpas_wps_deinit();
#endif
printf("\n\rDeinitializing WIFI ...");
WIFI_CONF_MSG("\n\rDeinitializing WIFI ...");
rltk_wlan_deinit();
while(1) {
if((rltk_wlan_running(WLAN0_IDX) == 0) &&
(rltk_wlan_running(WLAN1_IDX) == 0)) {
printf("\n\rWIFI deinitialized");
WIFI_CONF_MSG("\n\rWIFI deinitialized");
break;
}
if(timeout == 0) {
printf("\n\rERROR: Deinit WIFI timeout!");
WIFI_CONF_MSG("\n\rERROR: Deinit WIFI timeout!");
break;
}
@ -1133,7 +1139,7 @@ int wifi_start_ap(
break;
default:
ret = -1;
printf("\n\rWIFICONF: security type is not supported");
WIFI_CONF_MSG("\n\rWIFICONF: security type is not supported");
break;
}
if(ret < 0) goto exit;
@ -1184,7 +1190,7 @@ int wifi_start_ap_with_hidden_ssid(
break;
default:
ret = -1;
printf("\n\rWIFICONF: security type is not supported");
WIFI_CONF_MSG("\n\rWIFICONF: security type is not supported");
break;
}
if(ret < 0) goto exit;
@ -1324,7 +1330,7 @@ int wifi_scan_networks_with_ssid(int (results_handler)(char*buf, int buflen, cha
scan_buf.buf_len = scan_buflen;
scan_buf.buf = (char*)rtw_malloc(scan_buf.buf_len);
if(!scan_buf.buf){
printf("\n\rERROR: Can't malloc memory(%d)", scan_buf.buf_len);
WIFI_CONF_MSG("\n\rERROR: Can't malloc memory(%d)", scan_buf.buf_len);
return RTW_NOMEM;
}
//set ssid
@ -1334,7 +1340,7 @@ int wifi_scan_networks_with_ssid(int (results_handler)(char*buf, int buflen, cha
//Scan channel
if(scan_cnt = (wifi_scan(RTW_SCAN_TYPE_ACTIVE, RTW_BSS_TYPE_ANY, &scan_buf)) < 0){
printf("\n\rERROR: wifi scan failed");
WIFI_CONF_MSG("\n\rERROR: wifi scan failed");
ret = RTW_ERROR;
}else{
if(NULL == results_handler)
@ -1432,7 +1438,7 @@ int wifi_scan_networks(rtw_scan_result_handler_t results_handler, void* user_dat
count --;
}
if(count == 0){
printf("\n\r[%d]WiFi: Scan is running. Wait 2s timeout.", rtw_get_current_time());
WIFI_CONF_MSG("\n\r[%d]WiFi: Scan is running. Wait 2s timeout.", rtw_get_current_time());
return RTW_TIMEOUT;
}
}
@ -1715,7 +1721,7 @@ int wifi_restart_ap(
}
// start ap
if(wifi_start_ap((char*)ssid, security_type, (char*)password, ssid_len, password_len, channel) < 0) {
printf("\n\rERROR: Operation failed!");
WIFI_CONF_MSG("\n\rERROR: Operation failed!");
return -1;
}
@ -1776,7 +1782,7 @@ static void wifi_autoreconnect_thread(void *param)
{
int ret = RTW_ERROR;
struct wifi_autoreconnect_param *reconnect_param = (struct wifi_autoreconnect_param *) param;
printf("\n\rauto reconnect ...\n");
WIFI_CONF_MSG("\n\rauto reconnect ...\n");
ret = wifi_connect(reconnect_param->ssid, reconnect_param->security_type, reconnect_param->password,
reconnect_param->ssid_len, reconnect_param->password_len, reconnect_param->key_id, NULL);
#if DEVICE_EMAC
@ -1797,7 +1803,7 @@ static void wifi_autoreconnect_thread(void *param)
#if LWIP_AUTOIP
uint8_t *ip = LwIP_GetIP(&xnetif[0]);
if((ip[0] == 0) && (ip[1] == 0) && (ip[2] == 0) && (ip[3] == 0)) {
printf("\n\nIPv4 AUTOIP ...");
WIFI_CONF_MSG("\n\nIPv4 AUTOIP ...");
LwIP_AUTOIP(&xnetif[0]);
}
#endif
@ -1822,7 +1828,7 @@ void wifi_autoreconnect_hdl(rtw_security_t security_type,
param.key_id = key_id;
if(!rtw_create_task(&g_wifi_auto_reconnect_task,"wifi_autoreconnect",512,TASK_PRORITY_IDEL+1,wifi_autoreconnect_thread, &param))
printf("\n\rTCP ERROR: Create TCP server task failed.");
WIFI_CONF_MSG("\n\rTCP ERROR: Create TCP server task failed.");
}
int wifi_config_autoreconnect(__u8 mode, __u8 retry_times, __u16 timeout)

View File

@ -20,6 +20,12 @@
#include <wifi/wifi_ind.h>
#include <osdep_service.h>
extern u32 GlobalDebugEnable;
#define WIFI_UTIL_MSG(...) do {\
if (GlobalDebugEnable) \
printf("\r" __VA_ARGS__);\
}while(0)
int iw_ioctl(const char *ifname, unsigned long request, struct iwreq *pwrq)
{
memcpy(pwrq->ifr_name, ifname, 5);
@ -36,7 +42,7 @@ int wext_get_ssid(const char *ifname, __u8 *ssid)
iwr.u.essid.length = 32;
if (iw_ioctl(ifname, SIOCGIWESSID, &iwr) < 0) {
printf("\n\rioctl[SIOCGIWESSID] ssid = NULL, not connected"); //do not use perror
WIFI_UTIL_MSG("\n\rioctl[SIOCGIWESSID] ssid = NULL, not connected"); //do not use perror
ret = -1;
} else {
ret = iwr.u.essid.length;
@ -65,7 +71,7 @@ int wext_set_ssid(const char *ifname, const __u8 *ssid, __u16 ssid_len)
iwr.u.essid.flags = (ssid_len != 0);
if (iw_ioctl(ifname, SIOCSIWESSID, &iwr) < 0) {
printf("\n\rioctl[SIOCSIWESSID] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCSIWESSID] error");
ret = -1;
}
@ -86,7 +92,7 @@ int wext_set_bssid(const char *ifname, const __u8 *bssid)
}
if (iw_ioctl(ifname, SIOCSIWAP, &iwr) < 0) {
printf("\n\rioctl[SIOCSIWAP] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCSIWAP] error");
ret = -1;
}
@ -108,7 +114,7 @@ int wext_set_auth_param(const char *ifname, __u16 idx, __u32 value)
iwr.u.param.value = value;
if (iw_ioctl(ifname, SIOCSIWAUTH, &iwr) < 0) {
printf("\n\rWEXT: SIOCSIWAUTH(param %d value 0x%x) failed)", idx, value);
WIFI_UTIL_MSG("\n\rWEXT: SIOCSIWAUTH(param %d value 0x%x) failed)", idx, value);
}
return ret;
@ -162,7 +168,7 @@ int wext_set_key_ext(const char *ifname, __u16 alg, const __u8 *addr, int key_id
if (iw_ioctl(ifname, SIOCSIWENCODEEXT, &iwr) < 0) {
ret = -2;
printf("\n\rioctl[SIOCSIWENCODEEXT] set key fail");
WIFI_UTIL_MSG("\n\rioctl[SIOCSIWENCODEEXT] set key fail");
}
rtw_free(ext);
@ -184,7 +190,7 @@ int wext_get_enc_ext(const char *ifname, __u16 *alg, __u8 *key_idx, __u8 *passph
iwr.u.encoding.pointer = ext;
if (iw_ioctl(ifname, SIOCGIWENCODEEXT, &iwr) < 0) {
printf("\n\rioctl[SIOCGIWENCODEEXT] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCGIWENCODEEXT] error");
ret = -1;
}
else
@ -213,7 +219,7 @@ int wext_set_passphrase(const char *ifname, const __u8 *passphrase, __u16 passph
iwr.u.passphrase.flags = (passphrase_len != 0);
if (iw_ioctl(ifname, SIOCSIWPRIVPASSPHRASE, &iwr) < 0) {
printf("\n\rioctl[SIOCSIWESSID+0x1f] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCSIWESSID+0x1f] error");
ret = -1;
}
@ -229,7 +235,7 @@ int wext_get_passphrase(const char *ifname, __u8 *passphrase)
iwr.u.passphrase.pointer = (void *) passphrase;
if (iw_ioctl(ifname, SIOCGIWPRIVPASSPHRASE, &iwr) < 0) {
printf("\n\rioctl[SIOCGIWPRIVPASSPHRASE] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCGIWPRIVPASSPHRASE] error");
ret = -1;
}
else {
@ -292,7 +298,7 @@ int wext_enable_powersave(const char *ifname, __u8 ips_mode, __u8 lps_mode)
iwr.u.data.length = pindex;
if (iw_ioctl(ifname, SIOCDEVPRIVATE, &iwr) < 0) {
printf("\n\rioctl[SIOCSIWPRIVAPESSID] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCSIWPRIVAPESSID] error");
ret = -1;
}
@ -330,7 +336,7 @@ int wext_disable_powersave(const char *ifname)
iwr.u.data.length = pindex;
if (iw_ioctl(ifname, SIOCDEVPRIVATE, &iwr) < 0) {
printf("\n\rioctl[SIOCSIWPRIVAPESSID] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCSIWPRIVAPESSID] error");
ret = -1;
}
@ -367,7 +373,7 @@ int wext_set_tdma_param(const char *ifname, __u8 slot_period, __u8 rfon_period_l
iwr.u.data.length = pindex;
if (iw_ioctl(ifname, SIOCDEVPRIVATE, &iwr) < 0) {
printf("\n\rioctl[SIOCSIWPRIVAPESSID] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCSIWPRIVAPESSID] error");
ret = -1;
}
@ -400,7 +406,7 @@ int wext_set_lps_dtim(const char *ifname, __u8 lps_dtim)
iwr.u.data.length = pindex;
if (iw_ioctl(ifname, SIOCDEVPRIVATE, &iwr) < 0) {
printf("\n\rioctl[SIOCSIWPRIVAPESSID] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCSIWPRIVAPESSID] error");
ret = -1;
}
@ -434,7 +440,7 @@ int wext_get_lps_dtim(const char *ifname, __u8 *lps_dtim)
iwr.u.data.length = pindex;
if (iw_ioctl(ifname, SIOCDEVPRIVATE, &iwr) < 0) {
printf("\n\rioctl[SIOCSIWPRIVAPESSID] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCSIWPRIVAPESSID] error");
ret = -1;
goto exit;
}
@ -443,7 +449,7 @@ int wext_get_lps_dtim(const char *ifname, __u8 *lps_dtim)
if((para[0]==3)&&(para[1]==1))
*lps_dtim = para[2];
else
printf("\n\r%s error", __func__);
WIFI_UTIL_MSG("\n\r%s error", __func__);
exit:
rtw_free(para);
@ -492,7 +498,7 @@ int wext_set_tos_value(const char *ifname, __u8 *tos_value)
iwr.u.data.length = cmd_len + 4;
if (iw_ioctl(ifname, SIOCDEVPRIVATE, &iwr) < 0) {
printf("\n\rwext_set_tos_value():ioctl[SIOCDEVPRIVATE] error");
WIFI_UTIL_MSG("\n\rwext_set_tos_value():ioctl[SIOCDEVPRIVATE] error");
ret = -1;
}
@ -518,7 +524,7 @@ int wext_get_tx_power(const char *ifname, __u8 *poweridx)
iwr.u.data.pointer = para;
iwr.u.data.length = cmd_len + 20;
if (iw_ioctl(ifname, SIOCDEVPRIVATE, &iwr) < 0) {
printf("\n\rwext_get_tx_power():ioctl[SIOCDEVPRIVATE] error");
WIFI_UTIL_MSG("\n\rwext_get_tx_power():ioctl[SIOCDEVPRIVATE] error");
ret = -1;
}
@ -577,7 +583,7 @@ int wext_set_mode(const char *ifname, int mode)
memset(&iwr, 0, sizeof(iwr));
iwr.u.mode = mode;
if (iw_ioctl(ifname, SIOCSIWMODE, &iwr) < 0) {
printf("\n\rioctl[SIOCSIWMODE] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCSIWMODE] error");
ret = -1;
}
@ -592,7 +598,7 @@ int wext_get_mode(const char *ifname, int *mode)
memset(&iwr, 0, sizeof(iwr));
if (iw_ioctl(ifname, SIOCGIWMODE, &iwr) < 0) {
printf("\n\rioctl[SIOCGIWMODE] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCGIWMODE] error");
ret = -1;
}
else
@ -612,7 +618,7 @@ int wext_set_ap_ssid(const char *ifname, const __u8 *ssid, __u16 ssid_len)
iwr.u.essid.flags = (ssid_len != 0);
if (iw_ioctl(ifname, SIOCSIWPRIVAPESSID, &iwr) < 0) {
printf("\n\rioctl[SIOCSIWPRIVAPESSID] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCSIWPRIVAPESSID] error");
ret = -1;
}
@ -629,7 +635,7 @@ int wext_set_country(const char *ifname, rtw_country_code_t country_code)
iwr.u.param.value = country_code;
if (iw_ioctl(ifname, SIOCSIWPRIVCOUNTRY, &iwr) < 0) {
printf("\n\rioctl[SIOCSIWPRIVCOUNTRY] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCSIWPRIVCOUNTRY] error");
ret = -1;
}
return ret;
@ -643,7 +649,7 @@ int wext_get_rssi(const char *ifname, int *rssi)
memset(&iwr, 0, sizeof(iwr));
if (iw_ioctl(ifname, SIOCGIWSENS, &iwr) < 0) {
printf("\n\rioctl[SIOCGIWSENS] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCGIWSENS] error");
ret = -1;
} else {
*rssi = 0 - iwr.u.sens.value;
@ -675,7 +681,7 @@ int wext_set_pscan_channel(const char *ifname, __u8 *ch, __u8 *pscan_config, __u
iwr.u.data.pointer = para;
iwr.u.data.length = (length + length + 1) + 12;
if (iw_ioctl(ifname, SIOCDEVPRIVATE, &iwr) < 0) {
printf("\n\rwext_set_pscan_channel():ioctl[SIOCDEVPRIVATE] error");
WIFI_UTIL_MSG("\n\rwext_set_pscan_channel():ioctl[SIOCDEVPRIVATE] error");
ret = -1;
}
rtw_free(para);
@ -692,7 +698,7 @@ int wext_set_channel(const char *ifname, __u8 ch)
iwr.u.freq.i = ch;
if (iw_ioctl(ifname, SIOCSIWFREQ, &iwr) < 0) {
printf("\n\rioctl[SIOCSIWFREQ] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCSIWFREQ] error");
ret = -1;
}
@ -707,7 +713,7 @@ int wext_get_channel(const char *ifname, __u8 *ch)
memset(&iwr, 0, sizeof(iwr));
if (iw_ioctl(ifname, SIOCGIWFREQ, &iwr) < 0) {
printf("\n\rioctl[SIOCGIWFREQ] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCGIWFREQ] error");
ret = -1;
}
else
@ -754,7 +760,7 @@ int wext_set_scan(const char *ifname, char *buf, __u16 buf_len, __u16 flags)
iwr.u.data.flags = flags;
iwr.u.data.length = buf_len;
if (iw_ioctl(ifname, SIOCSIWSCAN, &iwr) < 0) {
printf("\n\rioctl[SIOCSIWSCAN] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCSIWSCAN] error");
ret = -1;
}
return ret;
@ -768,7 +774,7 @@ int wext_get_scan(const char *ifname, char *buf, __u16 buf_len)
iwr.u.data.pointer = buf;
iwr.u.data.length = buf_len;
if (iw_ioctl(ifname, SIOCGIWSCAN, &iwr) < 0) {
printf("\n\rioctl[SIOCGIWSCAN] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCGIWSCAN] error");
ret = -1;
}else
ret = iwr.u.data.flags;
@ -786,7 +792,7 @@ int wext_private_command_with_retval(const char *ifname, char *cmd, char *ret_bu
buf_size = strlen(cmd) + 1; // 1 : '\0'
buf = (char*)rtw_malloc(buf_size);
if(!buf){
printf("\n\rWEXT: Can't malloc memory");
WIFI_UTIL_MSG("\n\rWEXT: Can't malloc memory");
return -1;
}
memset(buf, 0, buf_size);
@ -797,7 +803,7 @@ int wext_private_command_with_retval(const char *ifname, char *cmd, char *ret_bu
iwr.u.data.flags = 0;
if ((ret = iw_ioctl(ifname, SIOCDEVPRIVATE, &iwr)) < 0) {
printf("\n\rioctl[SIOCDEVPRIVATE] error. ret=%d\n", ret);
WIFI_UTIL_MSG("\n\rioctl[SIOCDEVPRIVATE] error. ret=%d\n", ret);
}
if(ret_buf){
if(ret_len > iwr.u.data.length)
@ -830,7 +836,7 @@ int wext_private_command(const char *ifname, char *cmd, int show_msg)
buf_size = strlen(cmd) + 1; // 1 : '\0'
buf = (char*)rtw_malloc(buf_size);
if (!buf) {
printf("\n\rWEXT: Can't malloc memory");
WIFI_UTIL_MSG("\n\rWEXT: Can't malloc memory");
return -1;
}
memset(buf, 0, buf_size);
@ -841,12 +847,12 @@ int wext_private_command(const char *ifname, char *cmd, int show_msg)
iwr.u.data.flags = 0;
if ((ret = iw_ioctl(ifname, SIOCDEVPRIVATE, &iwr)) < 0) {
printf("\n\rioctl[SIOCDEVPRIVATE] error. ret=%d\n", ret);
WIFI_UTIL_MSG("\n\rioctl[SIOCDEVPRIVATE] error. ret=%d\n", ret);
}
if (show_msg && iwr.u.data.length) {
if(iwr.u.data.length > buf_size)
printf("\n\rWEXT: Malloc memory is not enough");
printf("\n\rPrivate Message: %s", (char *) iwr.u.data.pointer);
WIFI_UTIL_MSG("\n\rWEXT: Malloc memory is not enough");
WIFI_UTIL_MSG("\n\rPrivate Message: %s", (char *) iwr.u.data.pointer);
}
rtw_free(buf);
return ret;
@ -924,7 +930,7 @@ int wext_send_eapol(const char *ifname, char *buf, __u16 buf_len, __u16 flags)
iwr.u.data.length = buf_len;
iwr.u.data.flags = flags;
if (iw_ioctl(ifname, SIOCSIWEAPOLSEND, &iwr) < 0) {
printf("\n\rioctl[SIOCSIWEAPOLSEND] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCSIWEAPOLSEND] error");
ret = -1;
}
return ret;
@ -940,7 +946,7 @@ int wext_send_mgnt(const char *ifname, char *buf, __u16 buf_len, __u16 flags)
iwr.u.data.length = buf_len;
iwr.u.data.flags = flags;
if (iw_ioctl(ifname, SIOCSIWMGNTSEND, &iwr) < 0) {
printf("\n\rioctl[SIOCSIWMGNTSEND] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCSIWMGNTSEND] error");
ret = -1;
}
return ret;
@ -956,7 +962,7 @@ int wext_set_gen_ie(const char *ifname, char *buf, __u16 buf_len, __u16 flags)
iwr.u.data.length = buf_len;
iwr.u.data.flags = flags;
if (iw_ioctl(ifname, SIOCSIWGENIE, &iwr) < 0) {
printf("\n\rioctl[SIOCSIWGENIE] error");
WIFI_UTIL_MSG("\n\rioctl[SIOCSIWGENIE] error");
ret = -1;
}
return ret;
@ -984,7 +990,7 @@ int wext_set_autoreconnect(const char *ifname, __u8 mode, __u8 retry_times, __u1
iwr.u.data.pointer = para;
iwr.u.data.length = (4) + cmd_len;
if (iw_ioctl(ifname, SIOCDEVPRIVATE, &iwr) < 0) {
printf("\n\rwext_set_autoreconnect():ioctl[SIOCDEVPRIVATE] error");
WIFI_UTIL_MSG("\n\rwext_set_autoreconnect():ioctl[SIOCDEVPRIVATE] error");
ret = -1;
}
rtw_free(para);
@ -1008,7 +1014,7 @@ int wext_get_autoreconnect(const char *ifname, __u8 *mode)
iwr.u.data.pointer = para;
iwr.u.data.length = cmd_len;
if (iw_ioctl(ifname, SIOCDEVPRIVATE, &iwr) < 0) {
printf("\n\rwext_get_autoreconnect():ioctl[SIOCDEVPRIVATE] error");
WIFI_UTIL_MSG("\n\rwext_get_autoreconnect():ioctl[SIOCDEVPRIVATE] error");
ret = -1;
}
*mode = *(__u8 *)(iwr.u.data.pointer);
@ -1037,7 +1043,7 @@ int wext_add_custom_ie(const char *ifname, void *cus_ie, int ie_num)
__u8 *para = NULL;
int cmd_len = 0;
if(ie_num <= 0 || !cus_ie){
printf("\n\rwext_add_custom_ie():wrong parameter");
WIFI_UTIL_MSG("\n\rwext_add_custom_ie():wrong parameter");
ret = -1;
return ret;
}
@ -1056,7 +1062,7 @@ int wext_add_custom_ie(const char *ifname, void *cus_ie, int ie_num)
iwr.u.data.pointer = para;
iwr.u.data.length = (4)* 2 + cmd_len;// 2 input
if (iw_ioctl(ifname, SIOCDEVPRIVATE, &iwr) < 0) {
printf("\n\rwext_add_custom_ie():ioctl[SIOCDEVPRIVATE] error");
WIFI_UTIL_MSG("\n\rwext_add_custom_ie():ioctl[SIOCDEVPRIVATE] error");
ret = -1;
}
rtw_free(para);
@ -1071,7 +1077,7 @@ int wext_update_custom_ie(const char *ifname, void * cus_ie, int ie_index)
__u8 *para = NULL;
int cmd_len = 0;
if(ie_index <= 0 || !cus_ie){
printf("\n\rwext_update_custom_ie():wrong parameter");
WIFI_UTIL_MSG("\n\rwext_update_custom_ie():wrong parameter");
ret = -1;
return ret;
}
@ -1090,7 +1096,7 @@ int wext_update_custom_ie(const char *ifname, void * cus_ie, int ie_index)
iwr.u.data.pointer = para;
iwr.u.data.length = (4)* 2 + cmd_len;// 2 input
if (iw_ioctl(ifname, SIOCDEVPRIVATE, &iwr) < 0) {
printf("\n\rwext_update_custom_ie():ioctl[SIOCDEVPRIVATE] error");
WIFI_UTIL_MSG("\n\rwext_update_custom_ie():ioctl[SIOCDEVPRIVATE] error");
ret = -1;
}
rtw_free(para);
@ -1115,7 +1121,7 @@ int wext_del_custom_ie(const char *ifname)
iwr.u.data.pointer = para;
iwr.u.data.length = cmd_len;
if (iw_ioctl(ifname, SIOCDEVPRIVATE, &iwr) < 0) {
printf("\n\rwext_del_custom_ie():ioctl[SIOCDEVPRIVATE] error");
WIFI_UTIL_MSG("\n\rwext_del_custom_ie():ioctl[SIOCDEVPRIVATE] error");
ret = -1;
}
rtw_free(para);
@ -1148,7 +1154,7 @@ int wext_enable_forwarding(const char *ifname)
iwr.u.essid.length = cmd_len + 1;
if (iw_ioctl(ifname, SIOCDEVPRIVATE, &iwr) < 0) {
printf("\n\rwext_enable_forwarding(): ioctl[SIOCDEVPRIVATE] error");
WIFI_UTIL_MSG("\n\rwext_enable_forwarding(): ioctl[SIOCDEVPRIVATE] error");
ret = -1;
}
@ -1176,7 +1182,7 @@ int wext_disable_forwarding(const char *ifname)
iwr.u.essid.length = cmd_len + 1;
if (iw_ioctl(ifname, SIOCDEVPRIVATE, &iwr) < 0) {
printf("\n\rwext_disable_forwarding(): ioctl[SIOCDEVPRIVATE] error");
WIFI_UTIL_MSG("\n\rwext_disable_forwarding(): ioctl[SIOCDEVPRIVATE] error");
ret = -1;
}
@ -1260,7 +1266,7 @@ int wext_init_mac_filter(void)
mf_list_head = (struct list_head *)rtw_malloc(sizeof(struct list_head));
if(mf_list_head == NULL){
printf("\n\r[ERROR] %s : can't allocate mf_list_head",__func__);
WIFI_UTIL_MSG("\n\r[ERROR] %s : can't allocate mf_list_head",__func__);
return -1;
}
@ -1298,7 +1304,7 @@ int wext_add_mac_filter(unsigned char* hwaddr)
rtw_mac_filter_list_t *mf_list_new;
mf_list_new = (rtw_mac_filter_list_t *)rtw_malloc(sizeof(rtw_mac_filter_list_t));
if(mf_list_new == NULL){
printf("\n\r[ERROR] %s : can't allocate mf_list_new",__func__);
WIFI_UTIL_MSG("\n\r[ERROR] %s : can't allocate mf_list_new",__func__);
return -1;
}
memcpy(mf_list_new->mac_addr,hwaddr,6);