/drivers/net/wireless/tiwlan1251/CUDK/CLI/cu_cmd.c
C | 1587 lines | 1300 code | 207 blank | 80 comment | 125 complexity | fcb5e6f14279a95b0b28ca74c32c7a5c MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.0
Large files files are truncated, but you can click here to view the full file
- /*******************************************************************************
- **+--------------------------------------------------------------------------+**
- **| |**
- **| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/ |**
- **| |**
- **| 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. |**
- **| |**
- **+--------------------------------------------------------------------------+**
- *******************************************************************************/
- #ifdef _WINDOWS
- #endif
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <ctype.h>
- #ifndef _WINDOWS
- #include <errno.h>
- #include <stdio.h>
- #include <unistd.h>
- #include <termios.h>
- #include <sys/socket.h>
- #include <linux/if.h>
- #include <linux/wireless.h>
- #include "tnetwCommon.h"
- #endif /* __LINUX__ */
- #include "g_tester.h"
- #include "wspVer.h"
- #include "paramOut.h"
- #include "console.h"
- #include "ticon.h"
- #include "cu_cmd.h"
- #include "linux_ioctl_common.h"
- #include "802_11Defs.h"
- #ifndef _T
- #define _T(a) a
- #endif
- #ifndef _WINDOWS
- TI_HANDLE g_id_adapter = 0;
- #endif
- #define MAX_SSID_LEN 32
- #define CLI_NUM_OF_TX_CLASFR_CON 4
- scan_Params_t appScanParams;
- scan_Policy_t scanPolicy;
- /*** Roaming Manager configuration parameters ***/
- roamingMngrConfigParams_t roamingMngrConfigParams;
- static tiUINT32 events_mask = 0; // TRS:PGK
- #define NET_BASIC_MASK 0x80 /* defined in common/src/utils/utils.c */
- #define IS_BASIC_RATE(a) ((a) & NET_BASIC_MASK)
- #define RATE_2_MBPS(a) ((float)((a) & (NET_BASIC_MASK-1))/2)
- #define GET_NAME_BY_VALUE(arr, value) get_name_by_value(arr, SIZE_ARR(arr), value)
- #define CHAN_FREQ_TABLE_SIZE (sizeof(ChanFreq) / sizeof(struct CHAN_FREQ))
- #define RATE_TABLE_SIZE (sizeof(rate2Str) / sizeof(named_value_t))
- #define ET_TABLE_SIZE (sizeof(EtEvent2Str) / sizeof(named_value_t))
- /* EarlyTermination DISABLE mode - Should be same as in scan.h */
- #define SCAN_ET_COND_DISABLE 0
- #define MAX_PSK_STRING_LENGTH 63
- #define MIN_PSK_STRING_LENGTH 8
- #define PSK_HEXA_LENGTH 64
- #define PSK_BUFF_LEN 65
- static void get_bssid_list(ConParm_t parm[], U16 nParms, BOOL fullBssidList , OS_802_11_BSSID_EX *pBssid);
- static BOOL is_value_rate (tiUINT32 rate)
- {
- switch (rate)
- {
- case 1:
- case 2:
- case 5:
- case 6:
- case 9:
- case 11:
- case 12:
- case 18:
- case 22:
- case 24:
- case 36:
- case 48:
- case 54:
- return (TRUE);
- default:
- return (FALSE);
- }
- }
- static BOOL is_value_rate (tiUINT32 rate);
- struct CHAN_FREQ {
- UINT8 chan;
- UINT32 freq;
- } ChanFreq[] = {
- {1,2412000}, {2,2417000}, {3,2422000}, {4,2427000},
- {5,2432000}, {6,2437000}, {7,2442000}, {8,2447000},
- {9,2452000},
- {10,2457000}, {11,2462000}, {12,2467000}, {13,2472000},
- {14,2484000}, {36,5180000}, {40,5200000}, {44,5220000},
- {48,5240000}, {52,5260000}, {56,5280000}, {60,5300000},
- {64,5320000},
- {100,5500000}, {104,5520000}, {108,5540000}, {112,5560000},
- {116,5580000}, {120,5600000}, {124,5620000}, {128,5640000},
- {132,5660000}, {136,5680000}, {140,5700000}, {149,5745000},
- {153,5765000}, {157,5785000}, {161,5805000} };
- static named_value_t power_mode_val[] = {
- { OS_POWER_MODE_AUTO, "AUTO" },
- { OS_POWER_MODE_ACTIVE, "ACTIVE" },
- { OS_POWER_MODE_SHORT_DOZE, "SHORT_DOZE" },
- { OS_POWER_MODE_LONG_DOZE, "LONG_DOZE" }
- };
- static named_value_t power_level_val[] = {
- { OS_POWER_LEVEL_ELP, "ELP" },
- { OS_POWER_LEVEL_PD, "PD" },
- { OS_POWER_LEVEL_AWAKE, "AWAKE" }
- };
- static named_value_t encrypt_type[] = {
- { OS_ENCRYPTION_TYPE_NONE, "None" },
- { OS_ENCRYPTION_TYPE_WEP, "WEP" },
- { OS_ENCRYPTION_TYPE_TKIP, "TKIP" },
- { OS_ENCRYPTION_TYPE_AES, "AES" }
- };
- static named_value_t scanType2Str[] = {
- { SCAN_TYPE_NORMAL_PASSIVE, "Passive Normal Scan" },
- { SCAN_TYPE_NORMAL_ACTIVE, "Active Normal Scan" },
- { SCAN_TYPE_SPS, "Scheduled Passive Scan (SPS)" },
- { SCAN_TYPE_TRIGGERED_PASSIVE, "Passive Triggered Scan" },
- { SCAN_TYPE_TRIGGERED_ACTIVE, "Active Triggered Scan" }
- };
- static named_value_t band2Str[] = {
- { RADIO_BAND_2_4_GHZ, "2.4 GHz" },
- { RADIO_BAND_5_0_GHZ, "5.0 GHz" },
- { RADIO_BAND_DUAL, "Both " }
- };
- static named_value_t rate2Str[] = {
- { DRV_RATE_MASK_AUTO, "Auto " },
- { DRV_RATE_MASK_1_BARKER, "1 Mbps " },
- { DRV_RATE_MASK_2_BARKER, "2 Mbps " },
- { DRV_RATE_MASK_5_5_CCK, "5.5 Mbps" },
- { DRV_RATE_MASK_11_CCK, "11 Mbps " },
- { DRV_RATE_MASK_22_PBCC, "22 Mbps " },
- { DRV_RATE_MASK_6_OFDM, "6 Mbps " },
- { DRV_RATE_MASK_9_OFDM, "9 Mbps " },
- { DRV_RATE_MASK_12_OFDM, "12 Mbps " },
- { DRV_RATE_MASK_18_OFDM, "18 Mbps " },
- { DRV_RATE_MASK_24_OFDM, "24 Mbps " },
- { DRV_RATE_MASK_36_OFDM, "36 Mbps " },
- { DRV_RATE_MASK_48_OFDM, "48 Mbps " },
- { DRV_RATE_MASK_54_OFDM, "54 Mbps " }
- };
- static named_value_t EtEvent2Str[] = {
- { SCAN_ET_COND_DISABLE, "ET disabled " },
- { SCAN_ET_COND_BEACON, "ET on Beacon " },
- { SCAN_ET_COND_PROBE_RESP, "ET on Prb Rsp" },
- { SCAN_ET_COND_ANY_FRAME, "ET on both " }
- };
- /* used in scan_display */
- static char* rate2StrFunc(UINT32 rate)
- {
- UINT32 i;
- for ( i = 0; i < RATE_TABLE_SIZE; i++ )
- {
- if ( rate2Str[ i ].value == rate )
- return rate2Str[ i ].name;
- }
- return rate2Str[ 0 ].name;
- }
- /* used in scan_display */
- static char* EtEvent2StrFunc( UINT32 ETCond )
- {
- int i;
- for ( i = 0; i < ET_TABLE_SIZE; i++ )
- {
- if ( EtEvent2Str[ i ].value == ETCond )
- {
- return EtEvent2Str[ i ].name;
- }
- }
- return EtEvent2Str[ 0 ].name;
- }
- /* used in get_bssid_list() */
- UINT8 Freq2Chan(UINT32 freq)
- {
- UINT32 i;
- for(i=0; i<CHAN_FREQ_TABLE_SIZE; i++)
- if(ChanFreq[i].freq == freq) return ChanFreq[i].chan;
- return 0;
- }
- /* IPC events Callback */
- int cli_receive_ev(IPC_EV_DATA* pData)
- {
- tiUINT8 *buf;
- OS_802_11_QOS_TSPEC_PARAMS *AddTsResult;
- OS_802_11_AUTHENTICATION_REQUEST *request;
- OS_802_11_DISASSOCIATE_REASON_T *pDisAssoc;
- OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS *CrossParams;
- OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_CROSS_INDICATION_PARAMS *TrafficIntensityThresholdParams;
- btCoexStatus_t *btCoexStatus;
- #if defined (_WINDOWS)
- #endif
- g_tester_receive_event((tiUINT8)((IPC_EVENT_PARAMS *)pData)->uEventType);
- #if defined (_WINDOWS)
- #endif
- switch(((IPC_EVENT_PARAMS *)pData)->uEventType)
- {
- case IPC_EVENT_ASSOCIATED:
- console_printf_terminal("CLI Event - Associated\n");
- // TRS:HLC
- /*
- #if defined (_WINDOWS)
- #endif
- */
- //TRS end
- break;
- case IPC_EVENT_DISASSOCIATED:
- pDisAssoc = (OS_802_11_DISASSOCIATE_REASON_T*)pData->uBuffer;
- switch(pDisAssoc->eDisAssocType)
- {
- case OS_DISASSOC_STATUS_UNSPECIFIED:
- console_printf_terminal("CLI Event - Disassociated with unspecified reason (User/SG/Recovery)\n");
- break;
- case OS_DISASSOC_STATUS_AUTH_REJECT:
- if (pDisAssoc->uStatusCode == STATUS_PACKET_REJ_TIMEOUT)
- {
- console_printf_terminal("CLI Event - Disassociated due to no Auth response \n");
- }
- else
- {
- console_printf_terminal("CLI Event - Disassociated due to Auth response packet with reason = %d\n", pDisAssoc->uStatusCode);
- }
- break;
- case OS_DISASSOC_STATUS_ASSOC_REJECT:
- if (pDisAssoc->uStatusCode == STATUS_PACKET_REJ_TIMEOUT)
- {
- console_printf_terminal("CLI Event - Disassociated due to no Assoc response \n");
- }
- else
- {
- console_printf_terminal("CLI Event - Disassociated due to Assoc response packet with reason = %d\n", pDisAssoc->uStatusCode);
- }
- break;
- case OS_DISASSOC_STATUS_SECURITY_FAILURE:
- console_printf_terminal("CLI Event - Disassociated due to RSN failure\n");
- break;
- case OS_DISASSOC_STATUS_AP_DEAUTHENTICATE:
- console_printf_terminal("CLI Event - Disassociated due to AP deAuthenticate packet with reason = %d\n", pDisAssoc->uStatusCode);
- break;
- case OS_DISASSOC_STATUS_AP_DISASSOCIATE:
- console_printf_terminal("CLI Event - Disassociated due to AP disAssoc packet with reason = %d\n", pDisAssoc->uStatusCode);
- break;
- case OS_DISASSOC_STATUS_ROAMING_TRIGGER:
- console_printf_terminal("CLI Event - Disassociated due to roaming trigger = %d\n", pDisAssoc->uStatusCode);
- break;
- default:
- console_printf_terminal("CLI Event - Disassociated with unknown reason = %d\n", pDisAssoc->eDisAssocType);
- break;
- }
- break;
- case IPC_EVENT_LINK_SPEED:
- console_printf_terminal("CLI Event - LinkSpeed\n");
- break;
- case IPC_EVENT_AUTH_SUCC:
- console_printf_terminal("CLI Event - Authentication Success\n");
- break;
- case IPC_EVENT_SCAN_COMPLETE:
- console_printf_terminal("CLI Event - Scan Complete\n");
- break;
- case IPC_EVENT_TIMEOUT:
- console_printf_terminal("CLI Event - Timeout\n");
- break;
- case IPC_EVENT_UNBOUND:
- console_printf_terminal("CLI Event - Unbound\n");
- break;
- case IPC_EVENT_BOUND:
- console_printf_terminal("CLI Event - Bound\n");
- break;
- case IPC_EVENT_EAPOL:
- console_printf_terminal("CLI Event - EAPOL\n");
- break;
- case IPC_EVENT_MEDIA_SPECIFIC:
- buf = pData->uBuffer;
- request = (OS_802_11_AUTHENTICATION_REQUEST *) (buf + sizeof(tiUINT32));
- if( request->Flags == OS_802_11_REQUEST_PAIRWISE_ERROR ||
- request->Flags == OS_802_11_REQUEST_GROUP_ERROR)
- console_printf_terminal("CLI Event - Media_Specific\n");
- break;
- case IPC_EVENT_CCKM_START:
- console_printf_terminal("CLI Event - CCKM_Start\n");
- break;
- case IPC_EVENT_PREAUTH_EAPOL:
- console_printf_terminal("CLI Event - PreAuth EAPOL\n");
- break;
- case IPC_EVENT_LOW_SNR:
- console_printf_terminal("CLI Event - Low SNR\n");
- break;
- case IPC_EVENT_LOW_RSSI:
- console_printf_terminal("CLI Event - Low RSSI\n");
- break;
- case IPC_EVENT_EAP_AUTH_FAILURE:
- {
- OS_802_11_EAP_TYPES eapType;
- tiINT32 status;
- authStatus_e eAuthStatusReason;
- /* Cast the value to be UINT16 16 bits since it is sent this way in the EXCMngr.c */
- eAuthStatusReason = (authStatus_e)((*(pData->uBuffer)) & 0xFFFF);
- status = TI_GetEAPType( g_id_adapter, &eapType );
- if (eapType == OS_EAP_TYPE_LEAP)
- {
- console_printf_terminal("CLI Event - LEAP Authentication Failed \n");
- }
- else if (eapType == OS_EAP_TYPE_FAST)
- {
- console_printf_terminal("CLI Event - EAP-FAST Authentication Failed \n");
- }
- else if (eapType == OS_EAP_TYPE_TLS)
- {
- console_printf_terminal("CLI Event - EAP-TLS Authentication Failed \n");
- }
- switch ( eAuthStatusReason )
- {
- case RSN_AUTH_STATUS_INVALID_TYPE:
- console_printf_terminal("The reason: Invalid Authentication Type \n");
- break;
- case RSN_AUTH_STATUS_TIMEOUT:
- console_printf_terminal("The reason: Authentication Timeout \n");
- break;
- case RSN_AUTH_STATUS_CHALLENGE_FROM_AP_FAILED:
- case RSN_AUTH_STATUS_CHALLENGE_TO_AP_FAILED:
- console_printf_terminal("The reason: username or password incorrect \n");
- break;
- default:
- console_printf_terminal("The reason: unknown = %d \n", eAuthStatusReason);
- break;
- }
- }
- break;
- case IPC_EVENT_TSPEC_STATUS:
- AddTsResult = (OS_802_11_QOS_TSPEC_PARAMS *)pData->uBuffer;
- console_printf_terminal("CLI Event - IPC_EVENT_TSPEC_STATUS -- (userPriority = %d, ReasonCode = %d) \n",AddTsResult->uUserPriority,AddTsResult->uReasonCode);
- console_printf_terminal ("Tspec Parameters (as received through event handler):\n");
- console_printf_terminal ("-----------------------------------------------------\n");
- console_printf_terminal ("userPriority = %d\n",AddTsResult->uUserPriority);
- console_printf_terminal ("uNominalMSDUsize = %d\n",AddTsResult->uNominalMSDUsize);
- console_printf_terminal ("uMeanDataRate = %d\n",AddTsResult->uMeanDataRate);
- console_printf_terminal ("uMinimumPHYRate = %d\n",AddTsResult->uMinimumPHYRate);
- console_printf_terminal ("uSurplusBandwidthAllowance = %d\n",AddTsResult->uSurplusBandwidthAllowance);
- console_printf_terminal ("uAPSDFlag = %d\n",AddTsResult->uAPSDFlag);
- console_printf_terminal ("uMediumTime = %d\n\n",AddTsResult->uMediumTime);
- break;
- case IPC_EVENT_TSPEC_RATE_STATUS:
- CrossParams = (OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS *)pData->uBuffer;
- console_printf_terminal("CLI Event - IPC_EVENT_TSPEC_RATE_STATUS (AC = %d, HighLowFlag = %d, AboveOrBelow = %d)\n",CrossParams->uAC,CrossParams->uHighOrLowThresholdFlag,CrossParams->uAboveOrBelowFlag);
- break;
- case IPC_EVENT_MEDIUM_TIME_CROSS:
- CrossParams = (OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS *)pData->uBuffer;
- console_printf_terminal("CLI Event - IPC_EVENT_MEDIUM_TIME_CROSS (AC = %d, HighLowFlag = %d, AboveOrBelow = %d)\n",CrossParams->uAC,CrossParams->uHighOrLowThresholdFlag,CrossParams->uAboveOrBelowFlag);
- break;
- case IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED:
- TrafficIntensityThresholdParams = (OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_CROSS_INDICATION_PARAMS*)pData->uBuffer;
- printf("CLI Event - IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED\n");
- printf("---------------------------------------------------------\n");
- printf("Threshold crossed: %s Threshold\n", ((TrafficIntensityThresholdParams->uHighOrLowThresholdFlag == HIGH_THRESHOLD_CROSS) ? "High" : "Low"));
- printf("Direction crossed: %s\n\n", ((TrafficIntensityThresholdParams->uAboveOrBelowFlag == CROSS_ABOVE) ? "Above" : "Below"));
- break;
- case IPC_EVENT_WPA2_PREAUTHENTICATION:
- {
- ULONG *WPA2_PreAuth_Status;
- WPA2_PreAuth_Status = (ULONG *)pData->uBuffer;
- printf("CLI Event - IPC_EVENT_WPA2_PREAUTHENTICATION\n");
- printf("Status code = %lu\n",*WPA2_PreAuth_Status);
- }
- break;
- case IPC_EVENT_ROAMING_COMPLETE:
- printf("CLI Event - IPC_EVENT_ROAMING_COMPLETE \n");
- break;
- case IPC_EVENT_BT_COEX_MODE:
- btCoexStatus = (btCoexStatus_t*)pData->uBuffer;
- if (btCoexStatus->state)
- {
- console_printf_terminal("CLI Event - IPC_EVENT_BT_COEX_MODE (SG is ON, minTxRate = %d)\n",btCoexStatus->minTxRate);
- }
- else
- {
- console_printf_terminal("CLI Event - IPC_EVENT_BT_COEX_MODE (SG is OFF)\n");
- }
- break;
- default:
- console_printf_terminal("CLI Event - Unknown event\n");
- break;
- }
- return 0;
- }
- static char *print_rate(rate_e rate)
- {
- static char buf[20];
- if( rate == 0 )
- return "Auto (0)";
- sprintf(buf, "%.3g Mbps (%u%s)", RATE_2_MBPS(rate), rate,
- IS_BASIC_RATE(rate) ? " - basic" : "" );
- return buf;
- }
- static BOOL isJunkSSID(OS_802_11_SSID *ssid )
- {
- if ((ssid == NULL) || (ssid->SsidLength == 0))
- {
- return TRUE;
- }
- if (ssid->SsidLength > 2)
- {
- if ((ssid->Ssid[0] < MAX_SSID_LEN) &&
- (ssid->Ssid[1] < MAX_SSID_LEN) &&
- (ssid->Ssid[2] < MAX_SSID_LEN))
- {
- return TRUE;
- }
- }
- return FALSE;
- }
- static char *get_ssid_string(OS_802_11_SSID *ssid )
- {
- static char tmp_buf[MAX_SSID_LEN+1];
- if ((ssid == NULL) || (ssid->SsidLength == 0) || isJunkSSID(ssid))
- return "<empty>";
- if (ssid->SsidLength < SIZE_ARR(ssid->Ssid))
- ssid->Ssid[ssid->SsidLength] = 0;
- else if( ssid->SsidLength == MAX_SSID_LEN )
- {
- memcpy(tmp_buf, ssid->Ssid, MAX_SSID_LEN );
- tmp_buf[MAX_SSID_LEN] = 0;
- return tmp_buf;
- }
- else
- {
- console_printf_terminal("error: invalid ssid length (len = %u)\n", ssid->SsidLength );
- return "<error>";
- }
- return (char *) ssid->Ssid;
- }
- /* return 0 on error
- or 'mac' if success
- 'str' format: num.num.num.num.num.num (where 'num' is number from 0 to 255)
- */
- U8* str2MACAddr(char *str, U8 *mac)
- {
- const int mac_len = 6;
- int i;
- char *p = str;
- #ifndef _WINDOWS
- errno = 0;
- #endif
- console_printf_terminal("str2MAC():");
- for( i=0; i<mac_len; i++ )
- {
- mac[i] = (U8) strtoul(p, &p, 16);
- #ifndef _WINDOWS
- if( errno == ERANGE )
- return NULL;
- #endif
- console_printf_terminal("%2x.", mac[i] );
- p++;
- }
- console_printf_terminal("\n");
- return mac;
- }
- static char * print_mac_2_str(OS_802_11_MAC_ADDRESS mac)
- {
- static char buf[30];
- sprintf(buf, "%02x.%02x.%02x.%02x.%02x.%02x",
- mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
- return buf;
- }
- /* convert hex MAC addr in the form xx:xx:xx:xx:xx:xx to mac address */
- static void hexStr2MACAddr( char *hexStr, macAddress_t* mac )
- {
- size_t i;
- char *currHexStrPos = hexStr;
- UINT8 tempValue;
- /* convert hex string to lower */
- for ( i = 0; i < strlen(hexStr); i++ )
- {
- hexStr[ i ] = tolower( hexStr[ i ] );
- }
- /* convert to numbers */
- for ( i = 0; i < 6; i++ )
- {
- tempValue = 0;
- if ( *currHexStrPos >= 'a' )
- tempValue = *currHexStrPos - 'a' + 10;
- else
- tempValue = *currHexStrPos - '0';
- currHexStrPos++;
- tempValue <<= 4;
- if ( *currHexStrPos >= 'a' )
- tempValue += *currHexStrPos - 'a' + 10;
- else
- tempValue += *currHexStrPos - '0';
- currHexStrPos += 2;
- mac->addr[ i ] = tempValue;
- }
- }
- static void mac2HexStr( macAddress_t* mac, char* hexStr )
- {
- sprintf( hexStr, "%02x:%02x:%02x:%02x:%02x:%02x",
- mac->addr[0],mac->addr[1],mac->addr[2],mac->addr[3],mac->addr[4],mac->addr[5]);
- }
- char *get_name_by_value(named_value_t *arr, int arr_size, UINT32 value)
- {
- int i;
- for(i=0; i<arr_size; i++) {
- if( arr[i].value == value )
- return arr[i].name;
- }
- return "<unknow>";
- }
- void cmd_modify_supported_rates(ConParm_t parm[], U16 nParms)
- {
- rates_t data = { 0 };
- char debug_buf[256] = { 0 };
- int i;
- if( nParms == 0 )
- {
- if( !TI_GetSupportedRates(g_id_adapter, (tiUINT8*)&data, sizeof(data)) )
- {
- console_printf_terminal(" Rates: ");
- for( i=0; i<MAX_SUPPORTED_RATES && i < data.len; i++ )
- {
- console_printf_terminal("%g Mbps(%u%s)%s", RATE_2_MBPS(data.ratesString[i]),
- data.ratesString[i],
- IS_BASIC_RATE(data.ratesString[i]) ? " - basic" : "",
- (i < data.len-1) ? "," : "" );
- }
- console_printf_terminal("\n");
- }
- }
- else
- {
- char *end_p, *buf = (char *) parm[0].value;
- float val;
- console_printf_terminal("param: %s\n", buf );
- #ifndef _WINDOWS
- errno = 0;
- #endif
- for( i=0; *buf && i < MAX_SUPPORTED_RATES; i++ )
- {
- val = (float) strtod(buf, &end_p);
- if(
- #ifndef _WINDOWS
- errno ||
- #endif
- buf == end_p )
- {
- console_printf_terminal("cmd_modify_supported_rates(): invalid value - %s\n", buf );
- return;
- }
- if( val > ((1 << (sizeof(data.ratesString[i]) * 8))-1) )
- {
- console_printf_terminal("cmd_modify_supported_rates(): out of range '%.*s'\n", end_p - buf, buf );
- return;
- }
- data.ratesString[i] = (tiUINT8) (val);
- sprintf(&debug_buf[strlen(debug_buf)], "%g (%d) ", val, data.ratesString[i] );
- buf = end_p;
- while( *buf==' ' || *buf == ',' ) buf++;
- }
- if( *buf )
- {
- console_printf_terminal("too many parameters. Max=%d\n", MAX_SUPPORTED_RATES );
- return;
- }
- data.len = i;
- console_printf_terminal("**set rates (%d) :%s\n", data.len, debug_buf );
- TI_SetSupportedRates(g_id_adapter, (tiUINT8*) &data, sizeof(data));
- }
- }
- void cmd_show_status(ConParm_t parm[], U16 nParms)
- {
- tiINT32 res;
- OS_802_11_BSSID_EX BssIdInfo;
- tiUINT32 data;
- char buf[4096] = { 0 };
- OS_802_11_SSID ssid = { 0 };
- OS_802_11_MAC_ADDRESS bssid = { 0 };
- UNUSED(parm);
- UNUSED(nParms);
- buf[0] = 0;
- res = TI_WLAN_IsDriverRun(g_id_adapter, (tiBOOL *)&data);
- if( res )
- return ;
- sprintf(buf, "Status : %s\n", res ? "<error>" : (data ? "running" : "stopped") );
- sprintf(&buf[strlen(buf)], "MAC : ");
- if( !TI_GetCurrentAddress(g_id_adapter, &bssid ) )
- strcat(buf, print_mac_2_str(bssid) );
- else
- strcat(buf, "<error>");
- strcat(buf, "\nSSID : ");
- if( !TI_GetCurrentSSID(g_id_adapter, &ssid) )
- {
- if (!isJunkSSID(&ssid))
- {
- strncat(buf, get_ssid_string(&ssid),ssid.SsidLength);
- }
- else
- {
- strcat(buf,"<empty>");
- }
- }
- else
- strcat(buf, "<error>" );
- sprintf(&buf[strlen(buf)], "\nBSSID : ");
- TI_GetSelectedBSSIDInfo(g_id_adapter, &BssIdInfo);
- strcat(buf, print_mac_2_str(BssIdInfo.MacAddress));
- strcat(buf, "\nChannel : ");
- data = 0;
- if( !TI_GetCurrentChannel(g_id_adapter, &data ) )
- {
- sprintf(&buf[strlen(buf)], "%d", data );
- }
- else
- strcat(buf, "<error>");
- console_printf_terminal("==========================\n%s\n==========================\n\n", buf);
- }
- void cmd_connect(ConParm_t parm[], U16 nParms)
- {
- char buf[1] = { 0 };
- OS_802_11_MAC_ADDRESS bssid = { 0xff,0xff,0xff,0xff,0xff,0xff };
- buf[0] = 0;
- switch (nParms) {
- case 0 :
- /*
- * No SSID & No BSSID are set -
- * Use Any SSID & Any BSSID.
- */
- TI_SetBSSID(g_id_adapter, &bssid );
- TI_SetSSID(g_id_adapter, (tiUINT8 *) buf);
- break;
- case 1:
- /*
- * SSID set & BSSID insn't set -
- * Use CLI's SSID & Any BSSID.
- */
- TI_SetBSSID(g_id_adapter, &bssid );
- TI_SetSSID(g_id_adapter, (tiUINT8 *) parm[0].value);
- break;
- case 2:
- /*
- * Both SSID & BSSID are set -
- * Use CLI's SSID & BSSID.
- */
- if( !str2MACAddr((char *) parm[1].value, bssid) )
- return;
- TI_SetBSSID(g_id_adapter, &bssid);
- TI_SetSSID(g_id_adapter, (tiUINT8 *) parm[0].value);
- break;
- }
- }
- void cmd_disassociate(ConParm_t parm[], U16 nParms)
- {
- UNUSED(parm);
- UNUSED(nParms);
- TI_Disassociate(g_id_adapter);
- }
- void cmd_show_advanced_params(ConParm_t parm[], U16 nParms)
- {
- tiUINT32 mode_4x = 0, preamble = 0xfefefefe;
- OS_802_11_AUTHENTICATION_MODE auth;
- OS_802_11_ENCRYPTION_TYPES encrypt;
- tiUINT32 rts_tresh;
- tiUINT32 frag_tresh = 0xfefefefe;
- tiUINT8 tx_power = 0xfe;
- OS_802_11_POWER_PROFILE power_mode = 0;
- UNUSED(parm);
- UNUSED(nParms);
- TI_GetAuthenticationMode(g_id_adapter, &auth );
- TI_GetTxPowerDbm(g_id_adapter, (tiCHAR*) &tx_power);
- TI_GetFragmentThreshold( g_id_adapter, &frag_tresh);
- TI_GetRTSThreshold( g_id_adapter, &rts_tresh);
- TI_Get4XState( g_id_adapter, &mode_4x);
- TI_GetEncryptionType( g_id_adapter, &encrypt );
- TI_GetPowerMode(g_id_adapter, (OS_802_11_POWER_PROFILE*) &power_mode );
- console_printf_terminal(" Authentication : %u\n", auth );
- console_printf_terminal(" Power mode : %d\n", (tiUINT32) power_mode );
- console_printf_terminal(" Tx Power (Dbm/10 units) : %d\n", tx_power );
- console_printf_terminal(" Encryption : %u\n", encrypt );
- console_printf_terminal(" Preamble : <%s>\n", (preamble) ? "short" : "long");
- /* console_printf_terminal(" Tx antenna : %u\n", tx_ant );*/
- /* console_printf_terminal( " Rx antenna : %u\n", rx_ant );*/
- /* console_printf_terminal( "Ap Tx power level: n/a\n" );*/
- /* console_printf_terminal( " Tx power value : %lu\n", tx_power_val );*/
- /* console_printf_terminal( " MAC address : n/a\n" );*/
- console_printf_terminal( " 4X state : %d\n", mode_4x );
- /* console_printf_terminal( " B/G mode : n/a\n" );*/
- /* console_printf_terminal( " Country code : n/a\n" );*/
- /* console_printf_terminal( " IP address : n/a\n" );*/
- /* console_printf_terminal( " Net mask : n/a\n" );*/
- /* console_printf_terminal( " Gateway : n/a\n" );*/
- console_printf_terminal( " Frag. threshold : %u\n", frag_tresh);
- console_printf_terminal( " RTS threshold : %u\n", rts_tresh );
- console_printf_terminal( "Power mode: ");
- print_available_values(power_mode_val);
- console_printf_terminal( "Encryption type: ");
- print_available_values(encrypt_type);
- }
- void cmd_show_statistics(ConParm_t parm[], U16 nParms)
- {
- TIWLN_STATISTICS statistics = { 0 } ;
- UNUSED(parm);
- UNUSED(nParms);
- console_printf_terminal( "TI_GetStatistics(%s, data=%p, size=%d\n", (char*) g_id_adapter, &statistics, sizeof(statistics) );
- if( TI_GetStatistics( g_id_adapter, &statistics ) )
- {
- console_printf_terminal ("Error in getting TI_GetStatistics!!\n");
- return;
- }
- console_printf_terminal("******************\n");
- console_printf_terminal("Driver Statistics:\n");
- console_printf_terminal("******************\n");
- console_printf_terminal(" dot11CurrentTxRate : %s\n", print_rate(statistics.dot11CurrentTxRate) );
- console_printf_terminal(" dot11CurrentChannel : %d\n", statistics.dot11CurrentChannel );
- console_printf_terminal(" currentMACAddress : %s\n", print_mac_2_str(statistics.currentMACAddress) );
- console_printf_terminal(" dot11DesiredSSID : %s\n", get_ssid_string(&statistics.dot11DesiredSSID) );
- console_printf_terminal(" dot11BSSType : %d\n", statistics.dot11BSSType );
- console_printf_terminal(" AuthenticationMode : %d\n", statistics.AuthenticationMode );
- console_printf_terminal(" bShortPreambleUsed : %d\n", statistics.bShortPreambleUsed );
- console_printf_terminal(" RTSThreshold : %d\n", statistics.RTSThreshold );
- console_printf_terminal("FragmentationThreshold : %d\n", statistics.FragmentationThreshold );
- console_printf_terminal(" bDefaultWEPKeyDefined : %d\n", statistics.bDefaultWEPKeyDefined );
- console_printf_terminal(" WEPStatus : %d\n", statistics.WEPStatus );
- console_printf_terminal(" TxAntenna : %d\n", statistics.TxAntenna );
- console_printf_terminal(" RxAntenna : %d\n", statistics.RxAntenna );
- console_printf_terminal(" TxPowerDbm : %d\n", statistics.TxPowerDbm );
- console_printf_terminal(" PowerMode : %d\n", statistics.PowerMode );
- console_printf_terminal(" RxLevel : %d\n", statistics.RxLevel );
- /**/
- /* status & AP info*/
- /**/
- console_printf_terminal(" dot11State : %d\n", statistics.dot11State );
- /**/
- /* network layer statistics*/
- /**/
- console_printf_terminal(" RecvOk : %d\n", statistics.tiCounters.RecvOk );
- console_printf_terminal(" RecvError : %d\n", statistics.tiCounters.RecvError );
- console_printf_terminal(" DirectedBytesRecv : %d\n", statistics.tiCounters.DirectedBytesRecv );
- console_printf_terminal(" DirectedFramesRecv : %d\n", statistics.tiCounters.DirectedFramesRecv );
- console_printf_terminal(" MulticastBytesRecv : %d\n", statistics.tiCounters.MulticastBytesRecv );
- console_printf_terminal(" MulticastFramesRecv : %d\n", statistics.tiCounters.MulticastFramesRecv );
- console_printf_terminal(" BroadcastBytesRecv : %d\n", statistics.tiCounters.BroadcastBytesRecv );
- console_printf_terminal(" BroadcastFramesRecv : %d\n", statistics.tiCounters.BroadcastFramesRecv );
- console_printf_terminal(" FcsErrors : %d\n", statistics.tiCounters.FcsErrors );
- console_printf_terminal(" BeaconsRecv : %d\n", statistics.tiCounters.BeaconsRecv );
- console_printf_terminal(" AssocRejects : %d\n", statistics.tiCounters.AssocRejects );
- console_printf_terminal(" AssocTimeouts : %d\n", statistics.tiCounters.AssocTimeouts );
- console_printf_terminal(" AuthRejects : %d\n", statistics.tiCounters.AuthRejects );
- console_printf_terminal(" AuthTimeouts : %d\n", statistics.tiCounters.AuthTimeouts );
- /**/
- /* other statistics*/
- /**/
- console_printf_terminal(" dwSecuritySuit : %d\n", statistics.dwSecuritySuit );
- console_printf_terminal(" dwSecurityState : %d\n", statistics.dwSecurityState );
- console_printf_terminal(" dwSecurityAuthStatus : %d\n", statistics.dwSecurityAuthStatus );
- console_printf_terminal(" dwFeatureSuit : %d\n", statistics.dwFeatureSuit );
- }
- void cmd_show_tx_statistics(ConParm_t parm[], U16 nParms)
- {
- TIWLN_TX_STATISTICS statistics;
- UINT32 TxQid;
- UINT32 AverageDelay;
- UINT32 AverageFWDelay;
- UINT32 AverageMacDelay;
- tiINT32 status;
- UNUSED(parm);
- UNUSED(nParms);
- console_printf_terminal("TI_GetTxStatistics(%s, data=%p, size=%d\n", (char*) g_id_adapter, &statistics, sizeof(statistics) );
- /* The first parameter indicates whether to clear the statistics on read: 0 - don't clear, 1 - clear */
- if ( 0 == nParms )
- {
- status = TI_GetTxStatistics( g_id_adapter, &statistics, 0 );
- }
- else
- {
- status = TI_GetTxStatistics( g_id_adapter, &statistics, parm[0].value );
- }
- if( status )
- {
- console_printf_terminal ("Error in getting TI_GetTxStatistics!!\n");
- return;
- }
- console_printf_terminal("*********************\n");
- console_printf_terminal("Tx Queues Statistics:\n");
- console_printf_terminal("*********************\n");
- for (TxQid = 0; TxQid < MAX_NUM_OF_TX_QUEUES; TxQid++)
- {
- console_printf_terminal("\nTx Queue %d:\n", TxQid);
- console_printf_terminal("===========\n");
- console_printf_terminal(" Total Good Frames : %d\n", statistics.txCounters[TxQid].XmitOk );
- console_printf_terminal(" Unicast Bytes : %d\n", statistics.txCounters[TxQid].DirectedBytesXmit );
- console_printf_terminal(" Unicast Frames : %d\n", statistics.txCounters[TxQid].DirectedFramesXmit );
- console_printf_terminal(" Multicast Bytes : %d\n", statistics.txCounters[TxQid].MulticastBytesXmit );
- console_printf_terminal(" Multicast Frames : %d\n", statistics.txCounters[TxQid].MulticastFramesXmit );
- console_printf_terminal(" Broadcast Bytes : %d\n", statistics.txCounters[TxQid].BroadcastBytesXmit );
- console_printf_terminal(" Broadcast Frames : %d\n", statistics.txCounters[TxQid].BroadcastFramesXmit );
- console_printf_terminal(" Retry Failures : %d\n", statistics.txCounters[TxQid].RetryFailCounter );
- console_printf_terminal(" Tx Timeout Failures : %d\n", statistics.txCounters[TxQid].TxTimeoutCounter );
- console_printf_terminal(" No Link Failures : %d\n", statistics.txCounters[TxQid].NoLinkCounter );
- console_printf_terminal(" Other Failures : %d\n", statistics.txCounters[TxQid].OtherFailCounter );
- console_printf_terminal(" Max Consecutive Retry Failures : %d\n\n", statistics.txCounters[TxQid].MaxConsecutiveRetryFail );
- console_printf_terminal(" Retry histogram:\n");
- console_printf_terminal(" ----------------\n\n");
- console_printf_terminal(" Retries: %8d %8d %8d %8d %8d %8d %8d %8d\n", 0, 1, 2, 3, 4, 5, 6, 7);
- console_printf_terminal(" packets: %8d %8d %8d %8d %8d %8d %8d %8d\n\n",
- statistics.txCounters[TxQid].RetryHistogram[ 0 ],
- statistics.txCounters[TxQid].RetryHistogram[ 1 ],
- statistics.txCounters[TxQid].RetryHistogram[ 2 ],
- statistics.txCounters[TxQid].RetryHistogram[ 3 ],
- statistics.txCounters[TxQid].RetryHistogram[ 4 ],
- statistics.txCounters[TxQid].RetryHistogram[ 5 ],
- statistics.txCounters[TxQid].RetryHistogram[ 6 ],
- statistics.txCounters[TxQid].RetryHistogram[ 7 ]);
- console_printf_terminal(" Retries: %8d %8d %8d %8d %8d %8d %8d %8d\n", 8, 9, 10, 11, 12, 13, 14, 15);
- console_printf_terminal(" packets: %8d %8d %8d %8d %8d %8d %8d %8d\n\n",
- statistics.txCounters[TxQid].RetryHistogram[ 8 ],
- statistics.txCounters[TxQid].RetryHistogram[ 9 ],
- statistics.txCounters[TxQid].RetryHistogram[ 10 ],
- statistics.txCounters[TxQid].RetryHistogram[ 11 ],
- statistics.txCounters[TxQid].RetryHistogram[ 12 ],
- statistics.txCounters[TxQid].RetryHistogram[ 13 ],
- statistics.txCounters[TxQid].RetryHistogram[ 14 ],
- statistics.txCounters[TxQid].RetryHistogram[ 15 ]);
- if (statistics.txCounters[TxQid].NumPackets)
- {
- AverageDelay = statistics.txCounters[TxQid].SumTotalDelayMs / statistics.txCounters[TxQid].NumPackets;
- AverageFWDelay = statistics.txCounters[TxQid].SumFWDelayUs / statistics.txCounters[TxQid].NumPackets;
- AverageMacDelay = statistics.txCounters[TxQid].SumMacDelayUs / statistics.txCounters[TxQid].NumPackets;
- }
- else
- {
- AverageDelay = 0;
- AverageFWDelay = 0;
- AverageMacDelay = 0;
- }
- console_printf_terminal(" Total Delay ms (average/sum) : %d / %d\n", AverageDelay, statistics.txCounters[TxQid].SumTotalDelayMs);
- console_printf_terminal(" FW Delay us (average/sum) : %d / %d\n", AverageFWDelay, statistics.txCounters[TxQid].SumFWDelayUs);
- console_printf_terminal(" MAC Delay us (average/sum) : %d / %d\n\n", AverageMacDelay, statistics.txCounters[TxQid].SumMacDelayUs);
- console_printf_terminal(" Delay Ranges [msec] : Num of packets\n");
- console_printf_terminal(" ------------------- : --------------\n");
- console_printf_terminal(" 0 - 1 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_0_TO_1] );
- console_printf_terminal(" 1 - 10 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_1_TO_10] );
- console_printf_terminal(" 10 - 20 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_10_TO_20] );
- console_printf_terminal(" 20 - 40 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_20_TO_40] );
- console_printf_terminal(" 40 - 60 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_40_TO_60] );
- console_printf_terminal(" 60 - 80 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_60_TO_80] );
- console_printf_terminal(" 80 - 100 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_80_TO_100] );
- console_printf_terminal(" 100 - 200 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_100_TO_200] );
- console_printf_terminal(" Above 200 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_ABOVE_200] );
- }
- }
- void cmd_show_about(ConParm_t parm[], U16 nParms)
- {
- TIWLN_VERSION_EX data;
- UNUSED(parm);
- UNUSED(nParms);
- console_printf_terminal("Utility version: %s (%u.%u.%u)\n", SW_VERSION_STR, SW_RELEASE_DAY,
- SW_RELEASE_MONTH, SW_RELEASE_YEAR );
- if( TI_GetDriverVersion(g_id_adapter, &data ) )
- return ;
- console_printf_terminal("Driver version: %u.%u.%u.%u.%u\n", data.DrvVersion.major, data.DrvVersion.minor,
- data.DrvVersion.bugfix, data.DrvVersion.subld, data.DrvVersion.build );
- console_printf_terminal("Firmware version: %u.%u.%u.%u.%u\n", data.FWVersion.major, data.FWVersion.minor,
- data.FWVersion.bugfix, data.FWVersion.subld, data.FWVersion.build );
- console_printf_terminal("Eeprom Version: %u.%u.%u.%u.%u\n", data.HWVersion.major, data.HWVersion.minor,
- data.HWVersion.bugfix, data.HWVersion.subld, data.HWVersion.build );
- console_printf_terminal("Eeprom Version2: %u.%u.%u.%u.%u\n", data.NVVersion.major, data.NVVersion.minor,
- data.NVVersion.bugfix, data.NVVersion.subld, data.HWVersion.build );
- }
- void cmd_modify_ssid(ConParm_t parm[], U16 nParms)
- {
- OS_802_11_SSID ssid = { 0 };
- OS_802_11_MAC_ADDRESS bssid = { 0xff,0xff,0xff,0xff,0xff,0xff };
- char *ssid_str;
- if( nParms == 0 )
- {
- if(!TI_GetCurrentSSID(g_id_adapter, &ssid))
- ssid_str = get_ssid_string(&ssid);
- else
- ssid_str = "<error>";
- console_printf_terminal("SSID: %s\n", ssid_str );
- }
- else{
- /* Setting the new SSID, BRCS BSSID is set to clean pre-set BSSID */
- TI_SetBSSID(g_id_adapter, &bssid );
- TI_SetSSID(g_id_adapter, (tiUINT8 *) parm[0].value);
- }
- }
- void cmd_modify_channel(ConParm_t parm[], U16 nParms)
- {
- if( nParms == 0 )
- {
- tiUINT32 data1 = 0, data = 0;
- if( !TI_GetDesiredChannel( g_id_adapter, &data1) )
- console_printf_terminal("Channel=%d (desired: %d)\n", !TI_GetCurrentChannel(g_id_adapter, &data) ? data : -1, data1 );
- }
- else
- TI_SetDesiredChannel( g_id_adapter, parm[0].value );
- }
- void cmd_set_power_mode(ConParm_t parm[], U16 nParms)
- {
- OS_802_11_POWER_PROFILE mode = 0x12345678;
- if( nParms )
- TI_ConfigPowerManagement (g_id_adapter, parm[0].value );
- else
- {
- if( !TI_GetPowerMode(g_id_adapter, &mode ) )
- {
- console_printf_terminal("Power mode: %d\n", mode );
- print_available_values(power_mode_val);
- }
- }
- }
- void cmd_set_PowerSave_PowerLevel(ConParm_t parm[], U16 nParms)
- {
- OS_802_11_POWER_LEVELS mode;
- if( nParms )
- TI_SetPowerLevelPS (g_id_adapter, parm[0].value );
- else
- {
- if( !TI_GetPowerLevelPS(g_id_adapter, &mode ) )
- {
- console_printf_terminal("Power Level PowerSave: %d\n", mode );
- print_available_values(power_level_val);
- }
- }
- }
- void cmd_set_Default_PowerLevel(ConParm_t parm[], U16 nParms)
- {
- OS_802_11_POWER_LEVELS mode;
- if( nParms )
- TI_SetPowerLevelDefault (g_id_adapter, parm[0].value );
- else
- {
- if( !TI_GetPowerLevelDefault(g_id_adapter, &mode ) )
- {
- console_printf_terminal("Default Power Level: %d\n", mode );
- print_available_values(power_level_val);
- }
- }
- }
- void cmd_set_DozeModeInAutoPowerLevel(ConParm_t parm[], U16 nParms)
- {
- OS_802_11_POWER_PROFILE mode;
- if( nParms )
- TI_SetPowerLevelDozeMode (g_id_adapter, parm[0].value );
- else
- {
- /* set Short or Long Doze. no use of other parameters */
- if( !TI_GetPowerLevelDozeMode(g_id_adapter,&mode ) )
- {
- console_printf_terminal("Doze Mode in Auto Power Level: SHORT_DOZE - %d LONG_DOZE - %d\n",
- OS_POWER_MODE_SHORT_DOZE,OS_POWER_MODE_LONG_DOZE);
- }
- }
- }
- void cmd_Beacon_Filter_Set_Desired_State(ConParm_t parm[], U16 nParms)
- {
- /*there are two modes : feature ACTIVE & PASSIV ( or NOT ACTIVE )*/
- if( nParms )
- {
- TI_SetBeaconFilterDesiredState(g_id_adapter, parm[0].value );
- }
- else
- {
- console_printf_terminal("Use : 0 = INACTIVE , 1 = ACTIVE\n" ) ;
- }
- }
- void cmd_Beacon_Filter_Get_Desired_State(ConParm_t parm[], U16 nParms)
- {
- UINT8 desState = FALSE ;
- TI_GetBeaconFilterDesiredState(g_id_adapter, &desState ) ;
- console_printf_terminal("Desired State is %s\n", (desState == FALSE)?"FILTER INACTIVE":"FILTER ACTIVE" );
- }
- /* scan commands (new from eSTAdk 5.0) */
- void init_scan_params(void)
- {
- int i,j;
- /* init application scan default params */
- appScanParams.desiredSsid.len = 0;
- appScanParams.scanType = SCAN_TYPE_NORMAL_ACTIVE;
- appScanParams.band = RADIO_BAND_2_4_GHZ;
- appScanParams.probeReqNumber = 3;
- appScanParams.probeRequestRate = DRV_RATE_MASK_2_BARKER;
- appScanParams.numOfChannels = 11;
- for ( i = 0; i < 11; i++ )
- {
- for ( j = 0; j < 6; j++ )
- {
- appScanParams.channelEntry[ i ].normalChannelEntry.bssId.addr[ j ] = 0xff;
- }
- appScanParams.channelEntry[ i ].normalChannelEntry.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
- appScanParams.channelEntry[ i ].normalChannelEntry.ETMaxNumOfAPframes = 0;
- appScanParams.channelEntry[ i ].normalChannelEntry.maxChannelDwellTime = 60000;
- appScanParams.channelEntry[ i ].normalChannelEntry.minChannelDwellTime = 30000;
- appScanParams.channelEntry[ i ].normalChannelEntry.txPowerDbm = MAX_TX_POWER;
- appScanParams.channelEntry[ i ].normalChannelEntry.channel = i + 1;
- }
- /* init default scan policy */
- scanPolicy.normalScanInterval = 10000;
- scanPolicy.deterioratingScanInterval = 5000;
- scanPolicy.maxTrackFailures = 3;
- scanPolicy.BSSListSize = 4;
- scanPolicy.BSSNumberToStartDiscovery = 1;
- scanPolicy.numOfBands = 1;
- scanPolicy.bandScanPolicy[ 0 ].band = RADIO_BAND_2_4_GHZ;
- scanPolicy.bandScanPolicy[ 0 ].rxRSSIThreshold = -80;
- scanPolicy.bandScanPolicy[ 0 ].numOfChannles = 11;
- scanPolicy.bandScanPolicy[ 0 ].numOfChannlesForDiscovery = 3;
- for ( i = 0; i < 11; i++ )
- {
- scanPolicy.bandScanPolicy[ 0 ].channelList[ i ] = i + 1;
- }
- scanPolicy.bandScanPolicy[ 0 ].trackingMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE;
- scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
- scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
- scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
- scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.minChannelDwellTime = 15000;
- scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.bitrate = DRV_RATE_MASK_1_BARKER;
- scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
- scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.txPowerDbm = MAX_TX_POWER;
- scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE;
- scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
- scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
- scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
- scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.minChannelDwellTime = 15000;
- scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.bitrate = DRV_RATE_MASK_2_BARKER;
- scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
- scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.txPowerDbm = MAX_TX_POWER;
- scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE;
- scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
- scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
- scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
- scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.minChannelDwellTime = 15000;
- scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.bitrate = DRV_RATE_MASK_5_5_CCK;
- scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
- scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.txPowerDbm = MAX_TX_POWER;
- }
- void cmd_Scan_Start(ConParm_t parm[], U16 nParms)
- {
- TI_StartScan( g_id_adapter, &appScanParams );
- console_printf_terminal("Application scan started.\n");
- }
- void cmd_Scan_Stop(ConParm_t parm[], U16 nParms)
- {
- TI_StopScan( g_id_adapter );
- console_printf_terminal("Application scan stopped.\n");
- }
- void cmd_Scan_app_global_config(ConParm_t parm[], U16 nParms)
- {
- if ( 0 == strcmp( "<empty>", (char*)parm[0].value) )
- {
- appScanParams.desiredSsid.len = 0;
- appScanParams.desiredSsid.ssidString[ 0 ] = '\0';
- }
- else
- {
- appScanParams.desiredSsid.len = strlen((char*)parm[0].value);
- memcpy( &(appScanParams.desiredSsid.ssidString), (char*)parm[0].value, appScanParams.desiredSsid.len );
- }
- appScanParams.scanType = parm[1].value;
- appScanParams.band = parm[2].value;
- appScanParams.probeReqNumber = (UINT8)parm[3].value;
- appScanParams.probeRequestRate = parm[4].value;
- #ifdef TI_DBG
- appScanParams.Tid = (UINT8)parm[5].value;
- appScanParams.numOfChannels = (UINT8)parm[6].value;
- #else
- appScanParams.Tid = 0;
- appScanParams.numOfChannels = (UINT8)parm[5].value;
- #endif
- }
- void cmd_Scan_app_channel_config(ConParm_t parm[], U16 nParms)
- {
- scan_normalChannelEntry_t* pChannelEntry =
- &(appScanParams.channelEntry[ parm[0].value ].normalChannelEntry);
- if (parm[2].value < parm[3].value)
- {
- console_printf_terminal ("Max Dwell Time must be larger than or equal to Min Dwell Time...\n");
- return;
- }
- hexStr2MACAddr( (char*)parm[1].value, &(pChannelEntry->bssId) );
- pChannelEntry->maxChannelDwellTime = parm[2].value;
- pChannelEntry->minChannelDwellTime = parm[3].value;
- pChannelEntry->earlyTerminationEvent = parm[4].value;
- pChannelEntry->ETMaxNumOfAPframes = (UINT8)parm[5].value;
- pChannelEntry->txPowerDbm = (UINT8)parm[6].value;
- pChannelEntry->channel = (UINT8)parm[7].value;
- }
- void cmd_Scan_app_clear(ConParm_t parm[], U16 nParms)
- {
- memset( &appScanParams, 0, sizeof(scan_Params_t) );
- console_printf_terminal("Application scan parameters cleared.\n");
- }
- void cmd_Scan_app_display(ConParm_t parm[], U16 nParms)
- {
- int i;
- scan_normalChannelEntry_t* pNormalChannel;
- char bssId[18];
- bssId[17] = '\0';
- console_printf_terminal("Application Scan params:\n");
- console_printf_terminal("SSID: %s, Type: %s\n", appScanParams.desiredSsid.ssidString, scanType2Str…
Large files files are truncated, but you can click here to view the full file