PageRenderTime 58ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 1ms

/drivers/net/wireless/tiwlan1251/CUDK/CLI/cu_cmd.c

https://bitbucket.org/cyanogenmod/cm-kernel
C | 4896 lines | 4071 code | 671 blank | 154 comment | 594 complexity | fcb5e6f14279a95b0b28ca74c32c7a5c MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0

Large files files are truncated, but you can click here to view the full file

  1. /*******************************************************************************
  2. **+--------------------------------------------------------------------------+**
  3. **| |**
  4. **| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/ |**
  5. **| |**
  6. **| Licensed under the Apache License, Version 2.0 (the "License"); |**
  7. **| you may not use this file except in compliance with the License. |**
  8. **| You may obtain a copy of the License at |**
  9. **| |**
  10. **| http://www.apache.org/licenses/LICENSE-2.0 |**
  11. **| |**
  12. **| Unless required by applicable law or agreed to in writing, software |**
  13. **| distributed under the License is distributed on an "AS IS" BASIS, |**
  14. **| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
  15. **| See the License for the specific language governing permissions and |**
  16. **| limitations under the License. |**
  17. **| |**
  18. **+--------------------------------------------------------------------------+**
  19. *******************************************************************************/
  20. #ifdef _WINDOWS
  21. #endif
  22. #include <stdio.h>
  23. #include <string.h>
  24. #include <stdlib.h>
  25. #include <ctype.h>
  26. #ifndef _WINDOWS
  27. #include <errno.h>
  28. #include <stdio.h>
  29. #include <unistd.h>
  30. #include <termios.h>
  31. #include <sys/socket.h>
  32. #include <linux/if.h>
  33. #include <linux/wireless.h>
  34. #include "tnetwCommon.h"
  35. #endif /* __LINUX__ */
  36. #include "g_tester.h"
  37. #include "wspVer.h"
  38. #include "paramOut.h"
  39. #include "console.h"
  40. #include "ticon.h"
  41. #include "cu_cmd.h"
  42. #include "linux_ioctl_common.h"
  43. #include "802_11Defs.h"
  44. #ifndef _T
  45. #define _T(a) a
  46. #endif
  47. #ifndef _WINDOWS
  48. TI_HANDLE g_id_adapter = 0;
  49. #endif
  50. #define MAX_SSID_LEN 32
  51. #define CLI_NUM_OF_TX_CLASFR_CON 4
  52. scan_Params_t appScanParams;
  53. scan_Policy_t scanPolicy;
  54. /*** Roaming Manager configuration parameters ***/
  55. roamingMngrConfigParams_t roamingMngrConfigParams;
  56. static tiUINT32 events_mask = 0; // TRS:PGK
  57. #define NET_BASIC_MASK 0x80 /* defined in common/src/utils/utils.c */
  58. #define IS_BASIC_RATE(a) ((a) & NET_BASIC_MASK)
  59. #define RATE_2_MBPS(a) ((float)((a) & (NET_BASIC_MASK-1))/2)
  60. #define GET_NAME_BY_VALUE(arr, value) get_name_by_value(arr, SIZE_ARR(arr), value)
  61. #define CHAN_FREQ_TABLE_SIZE (sizeof(ChanFreq) / sizeof(struct CHAN_FREQ))
  62. #define RATE_TABLE_SIZE (sizeof(rate2Str) / sizeof(named_value_t))
  63. #define ET_TABLE_SIZE (sizeof(EtEvent2Str) / sizeof(named_value_t))
  64. /* EarlyTermination DISABLE mode - Should be same as in scan.h */
  65. #define SCAN_ET_COND_DISABLE 0
  66. #define MAX_PSK_STRING_LENGTH 63
  67. #define MIN_PSK_STRING_LENGTH 8
  68. #define PSK_HEXA_LENGTH 64
  69. #define PSK_BUFF_LEN 65
  70. static void get_bssid_list(ConParm_t parm[], U16 nParms, BOOL fullBssidList , OS_802_11_BSSID_EX *pBssid);
  71. static BOOL is_value_rate (tiUINT32 rate)
  72. {
  73. switch (rate)
  74. {
  75. case 1:
  76. case 2:
  77. case 5:
  78. case 6:
  79. case 9:
  80. case 11:
  81. case 12:
  82. case 18:
  83. case 22:
  84. case 24:
  85. case 36:
  86. case 48:
  87. case 54:
  88. return (TRUE);
  89. default:
  90. return (FALSE);
  91. }
  92. }
  93. static BOOL is_value_rate (tiUINT32 rate);
  94. struct CHAN_FREQ {
  95. UINT8 chan;
  96. UINT32 freq;
  97. } ChanFreq[] = {
  98. {1,2412000}, {2,2417000}, {3,2422000}, {4,2427000},
  99. {5,2432000}, {6,2437000}, {7,2442000}, {8,2447000},
  100. {9,2452000},
  101. {10,2457000}, {11,2462000}, {12,2467000}, {13,2472000},
  102. {14,2484000}, {36,5180000}, {40,5200000}, {44,5220000},
  103. {48,5240000}, {52,5260000}, {56,5280000}, {60,5300000},
  104. {64,5320000},
  105. {100,5500000}, {104,5520000}, {108,5540000}, {112,5560000},
  106. {116,5580000}, {120,5600000}, {124,5620000}, {128,5640000},
  107. {132,5660000}, {136,5680000}, {140,5700000}, {149,5745000},
  108. {153,5765000}, {157,5785000}, {161,5805000} };
  109. static named_value_t power_mode_val[] = {
  110. { OS_POWER_MODE_AUTO, "AUTO" },
  111. { OS_POWER_MODE_ACTIVE, "ACTIVE" },
  112. { OS_POWER_MODE_SHORT_DOZE, "SHORT_DOZE" },
  113. { OS_POWER_MODE_LONG_DOZE, "LONG_DOZE" }
  114. };
  115. static named_value_t power_level_val[] = {
  116. { OS_POWER_LEVEL_ELP, "ELP" },
  117. { OS_POWER_LEVEL_PD, "PD" },
  118. { OS_POWER_LEVEL_AWAKE, "AWAKE" }
  119. };
  120. static named_value_t encrypt_type[] = {
  121. { OS_ENCRYPTION_TYPE_NONE, "None" },
  122. { OS_ENCRYPTION_TYPE_WEP, "WEP" },
  123. { OS_ENCRYPTION_TYPE_TKIP, "TKIP" },
  124. { OS_ENCRYPTION_TYPE_AES, "AES" }
  125. };
  126. static named_value_t scanType2Str[] = {
  127. { SCAN_TYPE_NORMAL_PASSIVE, "Passive Normal Scan" },
  128. { SCAN_TYPE_NORMAL_ACTIVE, "Active Normal Scan" },
  129. { SCAN_TYPE_SPS, "Scheduled Passive Scan (SPS)" },
  130. { SCAN_TYPE_TRIGGERED_PASSIVE, "Passive Triggered Scan" },
  131. { SCAN_TYPE_TRIGGERED_ACTIVE, "Active Triggered Scan" }
  132. };
  133. static named_value_t band2Str[] = {
  134. { RADIO_BAND_2_4_GHZ, "2.4 GHz" },
  135. { RADIO_BAND_5_0_GHZ, "5.0 GHz" },
  136. { RADIO_BAND_DUAL, "Both " }
  137. };
  138. static named_value_t rate2Str[] = {
  139. { DRV_RATE_MASK_AUTO, "Auto " },
  140. { DRV_RATE_MASK_1_BARKER, "1 Mbps " },
  141. { DRV_RATE_MASK_2_BARKER, "2 Mbps " },
  142. { DRV_RATE_MASK_5_5_CCK, "5.5 Mbps" },
  143. { DRV_RATE_MASK_11_CCK, "11 Mbps " },
  144. { DRV_RATE_MASK_22_PBCC, "22 Mbps " },
  145. { DRV_RATE_MASK_6_OFDM, "6 Mbps " },
  146. { DRV_RATE_MASK_9_OFDM, "9 Mbps " },
  147. { DRV_RATE_MASK_12_OFDM, "12 Mbps " },
  148. { DRV_RATE_MASK_18_OFDM, "18 Mbps " },
  149. { DRV_RATE_MASK_24_OFDM, "24 Mbps " },
  150. { DRV_RATE_MASK_36_OFDM, "36 Mbps " },
  151. { DRV_RATE_MASK_48_OFDM, "48 Mbps " },
  152. { DRV_RATE_MASK_54_OFDM, "54 Mbps " }
  153. };
  154. static named_value_t EtEvent2Str[] = {
  155. { SCAN_ET_COND_DISABLE, "ET disabled " },
  156. { SCAN_ET_COND_BEACON, "ET on Beacon " },
  157. { SCAN_ET_COND_PROBE_RESP, "ET on Prb Rsp" },
  158. { SCAN_ET_COND_ANY_FRAME, "ET on both " }
  159. };
  160. /* used in scan_display */
  161. static char* rate2StrFunc(UINT32 rate)
  162. {
  163. UINT32 i;
  164. for ( i = 0; i < RATE_TABLE_SIZE; i++ )
  165. {
  166. if ( rate2Str[ i ].value == rate )
  167. return rate2Str[ i ].name;
  168. }
  169. return rate2Str[ 0 ].name;
  170. }
  171. /* used in scan_display */
  172. static char* EtEvent2StrFunc( UINT32 ETCond )
  173. {
  174. int i;
  175. for ( i = 0; i < ET_TABLE_SIZE; i++ )
  176. {
  177. if ( EtEvent2Str[ i ].value == ETCond )
  178. {
  179. return EtEvent2Str[ i ].name;
  180. }
  181. }
  182. return EtEvent2Str[ 0 ].name;
  183. }
  184. /* used in get_bssid_list() */
  185. UINT8 Freq2Chan(UINT32 freq)
  186. {
  187. UINT32 i;
  188. for(i=0; i<CHAN_FREQ_TABLE_SIZE; i++)
  189. if(ChanFreq[i].freq == freq) return ChanFreq[i].chan;
  190. return 0;
  191. }
  192. /* IPC events Callback */
  193. int cli_receive_ev(IPC_EV_DATA* pData)
  194. {
  195. tiUINT8 *buf;
  196. OS_802_11_QOS_TSPEC_PARAMS *AddTsResult;
  197. OS_802_11_AUTHENTICATION_REQUEST *request;
  198. OS_802_11_DISASSOCIATE_REASON_T *pDisAssoc;
  199. OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS *CrossParams;
  200. OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_CROSS_INDICATION_PARAMS *TrafficIntensityThresholdParams;
  201. btCoexStatus_t *btCoexStatus;
  202. #if defined (_WINDOWS)
  203. #endif
  204. g_tester_receive_event((tiUINT8)((IPC_EVENT_PARAMS *)pData)->uEventType);
  205. #if defined (_WINDOWS)
  206. #endif
  207. switch(((IPC_EVENT_PARAMS *)pData)->uEventType)
  208. {
  209. case IPC_EVENT_ASSOCIATED:
  210. console_printf_terminal("CLI Event - Associated\n");
  211. // TRS:HLC
  212. /*
  213. #if defined (_WINDOWS)
  214. #endif
  215. */
  216. //TRS end
  217. break;
  218. case IPC_EVENT_DISASSOCIATED:
  219. pDisAssoc = (OS_802_11_DISASSOCIATE_REASON_T*)pData->uBuffer;
  220. switch(pDisAssoc->eDisAssocType)
  221. {
  222. case OS_DISASSOC_STATUS_UNSPECIFIED:
  223. console_printf_terminal("CLI Event - Disassociated with unspecified reason (User/SG/Recovery)\n");
  224. break;
  225. case OS_DISASSOC_STATUS_AUTH_REJECT:
  226. if (pDisAssoc->uStatusCode == STATUS_PACKET_REJ_TIMEOUT)
  227. {
  228. console_printf_terminal("CLI Event - Disassociated due to no Auth response \n");
  229. }
  230. else
  231. {
  232. console_printf_terminal("CLI Event - Disassociated due to Auth response packet with reason = %d\n", pDisAssoc->uStatusCode);
  233. }
  234. break;
  235. case OS_DISASSOC_STATUS_ASSOC_REJECT:
  236. if (pDisAssoc->uStatusCode == STATUS_PACKET_REJ_TIMEOUT)
  237. {
  238. console_printf_terminal("CLI Event - Disassociated due to no Assoc response \n");
  239. }
  240. else
  241. {
  242. console_printf_terminal("CLI Event - Disassociated due to Assoc response packet with reason = %d\n", pDisAssoc->uStatusCode);
  243. }
  244. break;
  245. case OS_DISASSOC_STATUS_SECURITY_FAILURE:
  246. console_printf_terminal("CLI Event - Disassociated due to RSN failure\n");
  247. break;
  248. case OS_DISASSOC_STATUS_AP_DEAUTHENTICATE:
  249. console_printf_terminal("CLI Event - Disassociated due to AP deAuthenticate packet with reason = %d\n", pDisAssoc->uStatusCode);
  250. break;
  251. case OS_DISASSOC_STATUS_AP_DISASSOCIATE:
  252. console_printf_terminal("CLI Event - Disassociated due to AP disAssoc packet with reason = %d\n", pDisAssoc->uStatusCode);
  253. break;
  254. case OS_DISASSOC_STATUS_ROAMING_TRIGGER:
  255. console_printf_terminal("CLI Event - Disassociated due to roaming trigger = %d\n", pDisAssoc->uStatusCode);
  256. break;
  257. default:
  258. console_printf_terminal("CLI Event - Disassociated with unknown reason = %d\n", pDisAssoc->eDisAssocType);
  259. break;
  260. }
  261. break;
  262. case IPC_EVENT_LINK_SPEED:
  263. console_printf_terminal("CLI Event - LinkSpeed\n");
  264. break;
  265. case IPC_EVENT_AUTH_SUCC:
  266. console_printf_terminal("CLI Event - Authentication Success\n");
  267. break;
  268. case IPC_EVENT_SCAN_COMPLETE:
  269. console_printf_terminal("CLI Event - Scan Complete\n");
  270. break;
  271. case IPC_EVENT_TIMEOUT:
  272. console_printf_terminal("CLI Event - Timeout\n");
  273. break;
  274. case IPC_EVENT_UNBOUND:
  275. console_printf_terminal("CLI Event - Unbound\n");
  276. break;
  277. case IPC_EVENT_BOUND:
  278. console_printf_terminal("CLI Event - Bound\n");
  279. break;
  280. case IPC_EVENT_EAPOL:
  281. console_printf_terminal("CLI Event - EAPOL\n");
  282. break;
  283. case IPC_EVENT_MEDIA_SPECIFIC:
  284. buf = pData->uBuffer;
  285. request = (OS_802_11_AUTHENTICATION_REQUEST *) (buf + sizeof(tiUINT32));
  286. if( request->Flags == OS_802_11_REQUEST_PAIRWISE_ERROR ||
  287. request->Flags == OS_802_11_REQUEST_GROUP_ERROR)
  288. console_printf_terminal("CLI Event - Media_Specific\n");
  289. break;
  290. case IPC_EVENT_CCKM_START:
  291. console_printf_terminal("CLI Event - CCKM_Start\n");
  292. break;
  293. case IPC_EVENT_PREAUTH_EAPOL:
  294. console_printf_terminal("CLI Event - PreAuth EAPOL\n");
  295. break;
  296. case IPC_EVENT_LOW_SNR:
  297. console_printf_terminal("CLI Event - Low SNR\n");
  298. break;
  299. case IPC_EVENT_LOW_RSSI:
  300. console_printf_terminal("CLI Event - Low RSSI\n");
  301. break;
  302. case IPC_EVENT_EAP_AUTH_FAILURE:
  303. {
  304. OS_802_11_EAP_TYPES eapType;
  305. tiINT32 status;
  306. authStatus_e eAuthStatusReason;
  307. /* Cast the value to be UINT16 16 bits since it is sent this way in the EXCMngr.c */
  308. eAuthStatusReason = (authStatus_e)((*(pData->uBuffer)) & 0xFFFF);
  309. status = TI_GetEAPType( g_id_adapter, &eapType );
  310. if (eapType == OS_EAP_TYPE_LEAP)
  311. {
  312. console_printf_terminal("CLI Event - LEAP Authentication Failed \n");
  313. }
  314. else if (eapType == OS_EAP_TYPE_FAST)
  315. {
  316. console_printf_terminal("CLI Event - EAP-FAST Authentication Failed \n");
  317. }
  318. else if (eapType == OS_EAP_TYPE_TLS)
  319. {
  320. console_printf_terminal("CLI Event - EAP-TLS Authentication Failed \n");
  321. }
  322. switch ( eAuthStatusReason )
  323. {
  324. case RSN_AUTH_STATUS_INVALID_TYPE:
  325. console_printf_terminal("The reason: Invalid Authentication Type \n");
  326. break;
  327. case RSN_AUTH_STATUS_TIMEOUT:
  328. console_printf_terminal("The reason: Authentication Timeout \n");
  329. break;
  330. case RSN_AUTH_STATUS_CHALLENGE_FROM_AP_FAILED:
  331. case RSN_AUTH_STATUS_CHALLENGE_TO_AP_FAILED:
  332. console_printf_terminal("The reason: username or password incorrect \n");
  333. break;
  334. default:
  335. console_printf_terminal("The reason: unknown = %d \n", eAuthStatusReason);
  336. break;
  337. }
  338. }
  339. break;
  340. case IPC_EVENT_TSPEC_STATUS:
  341. AddTsResult = (OS_802_11_QOS_TSPEC_PARAMS *)pData->uBuffer;
  342. console_printf_terminal("CLI Event - IPC_EVENT_TSPEC_STATUS -- (userPriority = %d, ReasonCode = %d) \n",AddTsResult->uUserPriority,AddTsResult->uReasonCode);
  343. console_printf_terminal ("Tspec Parameters (as received through event handler):\n");
  344. console_printf_terminal ("-----------------------------------------------------\n");
  345. console_printf_terminal ("userPriority = %d\n",AddTsResult->uUserPriority);
  346. console_printf_terminal ("uNominalMSDUsize = %d\n",AddTsResult->uNominalMSDUsize);
  347. console_printf_terminal ("uMeanDataRate = %d\n",AddTsResult->uMeanDataRate);
  348. console_printf_terminal ("uMinimumPHYRate = %d\n",AddTsResult->uMinimumPHYRate);
  349. console_printf_terminal ("uSurplusBandwidthAllowance = %d\n",AddTsResult->uSurplusBandwidthAllowance);
  350. console_printf_terminal ("uAPSDFlag = %d\n",AddTsResult->uAPSDFlag);
  351. console_printf_terminal ("uMediumTime = %d\n\n",AddTsResult->uMediumTime);
  352. break;
  353. case IPC_EVENT_TSPEC_RATE_STATUS:
  354. CrossParams = (OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS *)pData->uBuffer;
  355. console_printf_terminal("CLI Event - IPC_EVENT_TSPEC_RATE_STATUS (AC = %d, HighLowFlag = %d, AboveOrBelow = %d)\n",CrossParams->uAC,CrossParams->uHighOrLowThresholdFlag,CrossParams->uAboveOrBelowFlag);
  356. break;
  357. case IPC_EVENT_MEDIUM_TIME_CROSS:
  358. CrossParams = (OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS *)pData->uBuffer;
  359. console_printf_terminal("CLI Event - IPC_EVENT_MEDIUM_TIME_CROSS (AC = %d, HighLowFlag = %d, AboveOrBelow = %d)\n",CrossParams->uAC,CrossParams->uHighOrLowThresholdFlag,CrossParams->uAboveOrBelowFlag);
  360. break;
  361. case IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED:
  362. TrafficIntensityThresholdParams = (OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_CROSS_INDICATION_PARAMS*)pData->uBuffer;
  363. printf("CLI Event - IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED\n");
  364. printf("---------------------------------------------------------\n");
  365. printf("Threshold crossed: %s Threshold\n", ((TrafficIntensityThresholdParams->uHighOrLowThresholdFlag == HIGH_THRESHOLD_CROSS) ? "High" : "Low"));
  366. printf("Direction crossed: %s\n\n", ((TrafficIntensityThresholdParams->uAboveOrBelowFlag == CROSS_ABOVE) ? "Above" : "Below"));
  367. break;
  368. case IPC_EVENT_WPA2_PREAUTHENTICATION:
  369. {
  370. ULONG *WPA2_PreAuth_Status;
  371. WPA2_PreAuth_Status = (ULONG *)pData->uBuffer;
  372. printf("CLI Event - IPC_EVENT_WPA2_PREAUTHENTICATION\n");
  373. printf("Status code = %lu\n",*WPA2_PreAuth_Status);
  374. }
  375. break;
  376. case IPC_EVENT_ROAMING_COMPLETE:
  377. printf("CLI Event - IPC_EVENT_ROAMING_COMPLETE \n");
  378. break;
  379. case IPC_EVENT_BT_COEX_MODE:
  380. btCoexStatus = (btCoexStatus_t*)pData->uBuffer;
  381. if (btCoexStatus->state)
  382. {
  383. console_printf_terminal("CLI Event - IPC_EVENT_BT_COEX_MODE (SG is ON, minTxRate = %d)\n",btCoexStatus->minTxRate);
  384. }
  385. else
  386. {
  387. console_printf_terminal("CLI Event - IPC_EVENT_BT_COEX_MODE (SG is OFF)\n");
  388. }
  389. break;
  390. default:
  391. console_printf_terminal("CLI Event - Unknown event\n");
  392. break;
  393. }
  394. return 0;
  395. }
  396. static char *print_rate(rate_e rate)
  397. {
  398. static char buf[20];
  399. if( rate == 0 )
  400. return "Auto (0)";
  401. sprintf(buf, "%.3g Mbps (%u%s)", RATE_2_MBPS(rate), rate,
  402. IS_BASIC_RATE(rate) ? " - basic" : "" );
  403. return buf;
  404. }
  405. static BOOL isJunkSSID(OS_802_11_SSID *ssid )
  406. {
  407. if ((ssid == NULL) || (ssid->SsidLength == 0))
  408. {
  409. return TRUE;
  410. }
  411. if (ssid->SsidLength > 2)
  412. {
  413. if ((ssid->Ssid[0] < MAX_SSID_LEN) &&
  414. (ssid->Ssid[1] < MAX_SSID_LEN) &&
  415. (ssid->Ssid[2] < MAX_SSID_LEN))
  416. {
  417. return TRUE;
  418. }
  419. }
  420. return FALSE;
  421. }
  422. static char *get_ssid_string(OS_802_11_SSID *ssid )
  423. {
  424. static char tmp_buf[MAX_SSID_LEN+1];
  425. if ((ssid == NULL) || (ssid->SsidLength == 0) || isJunkSSID(ssid))
  426. return "<empty>";
  427. if (ssid->SsidLength < SIZE_ARR(ssid->Ssid))
  428. ssid->Ssid[ssid->SsidLength] = 0;
  429. else if( ssid->SsidLength == MAX_SSID_LEN )
  430. {
  431. memcpy(tmp_buf, ssid->Ssid, MAX_SSID_LEN );
  432. tmp_buf[MAX_SSID_LEN] = 0;
  433. return tmp_buf;
  434. }
  435. else
  436. {
  437. console_printf_terminal("error: invalid ssid length (len = %u)\n", ssid->SsidLength );
  438. return "<error>";
  439. }
  440. return (char *) ssid->Ssid;
  441. }
  442. /* return 0 on error
  443. or 'mac' if success
  444. 'str' format: num.num.num.num.num.num (where 'num' is number from 0 to 255)
  445. */
  446. U8* str2MACAddr(char *str, U8 *mac)
  447. {
  448. const int mac_len = 6;
  449. int i;
  450. char *p = str;
  451. #ifndef _WINDOWS
  452. errno = 0;
  453. #endif
  454. console_printf_terminal("str2MAC():");
  455. for( i=0; i<mac_len; i++ )
  456. {
  457. mac[i] = (U8) strtoul(p, &p, 16);
  458. #ifndef _WINDOWS
  459. if( errno == ERANGE )
  460. return NULL;
  461. #endif
  462. console_printf_terminal("%2x.", mac[i] );
  463. p++;
  464. }
  465. console_printf_terminal("\n");
  466. return mac;
  467. }
  468. static char * print_mac_2_str(OS_802_11_MAC_ADDRESS mac)
  469. {
  470. static char buf[30];
  471. sprintf(buf, "%02x.%02x.%02x.%02x.%02x.%02x",
  472. mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  473. return buf;
  474. }
  475. /* convert hex MAC addr in the form xx:xx:xx:xx:xx:xx to mac address */
  476. static void hexStr2MACAddr( char *hexStr, macAddress_t* mac )
  477. {
  478. size_t i;
  479. char *currHexStrPos = hexStr;
  480. UINT8 tempValue;
  481. /* convert hex string to lower */
  482. for ( i = 0; i < strlen(hexStr); i++ )
  483. {
  484. hexStr[ i ] = tolower( hexStr[ i ] );
  485. }
  486. /* convert to numbers */
  487. for ( i = 0; i < 6; i++ )
  488. {
  489. tempValue = 0;
  490. if ( *currHexStrPos >= 'a' )
  491. tempValue = *currHexStrPos - 'a' + 10;
  492. else
  493. tempValue = *currHexStrPos - '0';
  494. currHexStrPos++;
  495. tempValue <<= 4;
  496. if ( *currHexStrPos >= 'a' )
  497. tempValue += *currHexStrPos - 'a' + 10;
  498. else
  499. tempValue += *currHexStrPos - '0';
  500. currHexStrPos += 2;
  501. mac->addr[ i ] = tempValue;
  502. }
  503. }
  504. static void mac2HexStr( macAddress_t* mac, char* hexStr )
  505. {
  506. sprintf( hexStr, "%02x:%02x:%02x:%02x:%02x:%02x",
  507. mac->addr[0],mac->addr[1],mac->addr[2],mac->addr[3],mac->addr[4],mac->addr[5]);
  508. }
  509. char *get_name_by_value(named_value_t *arr, int arr_size, UINT32 value)
  510. {
  511. int i;
  512. for(i=0; i<arr_size; i++) {
  513. if( arr[i].value == value )
  514. return arr[i].name;
  515. }
  516. return "<unknow>";
  517. }
  518. void cmd_modify_supported_rates(ConParm_t parm[], U16 nParms)
  519. {
  520. rates_t data = { 0 };
  521. char debug_buf[256] = { 0 };
  522. int i;
  523. if( nParms == 0 )
  524. {
  525. if( !TI_GetSupportedRates(g_id_adapter, (tiUINT8*)&data, sizeof(data)) )
  526. {
  527. console_printf_terminal(" Rates: ");
  528. for( i=0; i<MAX_SUPPORTED_RATES && i < data.len; i++ )
  529. {
  530. console_printf_terminal("%g Mbps(%u%s)%s", RATE_2_MBPS(data.ratesString[i]),
  531. data.ratesString[i],
  532. IS_BASIC_RATE(data.ratesString[i]) ? " - basic" : "",
  533. (i < data.len-1) ? "," : "" );
  534. }
  535. console_printf_terminal("\n");
  536. }
  537. }
  538. else
  539. {
  540. char *end_p, *buf = (char *) parm[0].value;
  541. float val;
  542. console_printf_terminal("param: %s\n", buf );
  543. #ifndef _WINDOWS
  544. errno = 0;
  545. #endif
  546. for( i=0; *buf && i < MAX_SUPPORTED_RATES; i++ )
  547. {
  548. val = (float) strtod(buf, &end_p);
  549. if(
  550. #ifndef _WINDOWS
  551. errno ||
  552. #endif
  553. buf == end_p )
  554. {
  555. console_printf_terminal("cmd_modify_supported_rates(): invalid value - %s\n", buf );
  556. return;
  557. }
  558. if( val > ((1 << (sizeof(data.ratesString[i]) * 8))-1) )
  559. {
  560. console_printf_terminal("cmd_modify_supported_rates(): out of range '%.*s'\n", end_p - buf, buf );
  561. return;
  562. }
  563. data.ratesString[i] = (tiUINT8) (val);
  564. sprintf(&debug_buf[strlen(debug_buf)], "%g (%d) ", val, data.ratesString[i] );
  565. buf = end_p;
  566. while( *buf==' ' || *buf == ',' ) buf++;
  567. }
  568. if( *buf )
  569. {
  570. console_printf_terminal("too many parameters. Max=%d\n", MAX_SUPPORTED_RATES );
  571. return;
  572. }
  573. data.len = i;
  574. console_printf_terminal("**set rates (%d) :%s\n", data.len, debug_buf );
  575. TI_SetSupportedRates(g_id_adapter, (tiUINT8*) &data, sizeof(data));
  576. }
  577. }
  578. void cmd_show_status(ConParm_t parm[], U16 nParms)
  579. {
  580. tiINT32 res;
  581. OS_802_11_BSSID_EX BssIdInfo;
  582. tiUINT32 data;
  583. char buf[4096] = { 0 };
  584. OS_802_11_SSID ssid = { 0 };
  585. OS_802_11_MAC_ADDRESS bssid = { 0 };
  586. UNUSED(parm);
  587. UNUSED(nParms);
  588. buf[0] = 0;
  589. res = TI_WLAN_IsDriverRun(g_id_adapter, (tiBOOL *)&data);
  590. if( res )
  591. return ;
  592. sprintf(buf, "Status : %s\n", res ? "<error>" : (data ? "running" : "stopped") );
  593. sprintf(&buf[strlen(buf)], "MAC : ");
  594. if( !TI_GetCurrentAddress(g_id_adapter, &bssid ) )
  595. strcat(buf, print_mac_2_str(bssid) );
  596. else
  597. strcat(buf, "<error>");
  598. strcat(buf, "\nSSID : ");
  599. if( !TI_GetCurrentSSID(g_id_adapter, &ssid) )
  600. {
  601. if (!isJunkSSID(&ssid))
  602. {
  603. strncat(buf, get_ssid_string(&ssid),ssid.SsidLength);
  604. }
  605. else
  606. {
  607. strcat(buf,"<empty>");
  608. }
  609. }
  610. else
  611. strcat(buf, "<error>" );
  612. sprintf(&buf[strlen(buf)], "\nBSSID : ");
  613. TI_GetSelectedBSSIDInfo(g_id_adapter, &BssIdInfo);
  614. strcat(buf, print_mac_2_str(BssIdInfo.MacAddress));
  615. strcat(buf, "\nChannel : ");
  616. data = 0;
  617. if( !TI_GetCurrentChannel(g_id_adapter, &data ) )
  618. {
  619. sprintf(&buf[strlen(buf)], "%d", data );
  620. }
  621. else
  622. strcat(buf, "<error>");
  623. console_printf_terminal("==========================\n%s\n==========================\n\n", buf);
  624. }
  625. void cmd_connect(ConParm_t parm[], U16 nParms)
  626. {
  627. char buf[1] = { 0 };
  628. OS_802_11_MAC_ADDRESS bssid = { 0xff,0xff,0xff,0xff,0xff,0xff };
  629. buf[0] = 0;
  630. switch (nParms) {
  631. case 0 :
  632. /*
  633. * No SSID & No BSSID are set -
  634. * Use Any SSID & Any BSSID.
  635. */
  636. TI_SetBSSID(g_id_adapter, &bssid );
  637. TI_SetSSID(g_id_adapter, (tiUINT8 *) buf);
  638. break;
  639. case 1:
  640. /*
  641. * SSID set & BSSID insn't set -
  642. * Use CLI's SSID & Any BSSID.
  643. */
  644. TI_SetBSSID(g_id_adapter, &bssid );
  645. TI_SetSSID(g_id_adapter, (tiUINT8 *) parm[0].value);
  646. break;
  647. case 2:
  648. /*
  649. * Both SSID & BSSID are set -
  650. * Use CLI's SSID & BSSID.
  651. */
  652. if( !str2MACAddr((char *) parm[1].value, bssid) )
  653. return;
  654. TI_SetBSSID(g_id_adapter, &bssid);
  655. TI_SetSSID(g_id_adapter, (tiUINT8 *) parm[0].value);
  656. break;
  657. }
  658. }
  659. void cmd_disassociate(ConParm_t parm[], U16 nParms)
  660. {
  661. UNUSED(parm);
  662. UNUSED(nParms);
  663. TI_Disassociate(g_id_adapter);
  664. }
  665. void cmd_show_advanced_params(ConParm_t parm[], U16 nParms)
  666. {
  667. tiUINT32 mode_4x = 0, preamble = 0xfefefefe;
  668. OS_802_11_AUTHENTICATION_MODE auth;
  669. OS_802_11_ENCRYPTION_TYPES encrypt;
  670. tiUINT32 rts_tresh;
  671. tiUINT32 frag_tresh = 0xfefefefe;
  672. tiUINT8 tx_power = 0xfe;
  673. OS_802_11_POWER_PROFILE power_mode = 0;
  674. UNUSED(parm);
  675. UNUSED(nParms);
  676. TI_GetAuthenticationMode(g_id_adapter, &auth );
  677. TI_GetTxPowerDbm(g_id_adapter, (tiCHAR*) &tx_power);
  678. TI_GetFragmentThreshold( g_id_adapter, &frag_tresh);
  679. TI_GetRTSThreshold( g_id_adapter, &rts_tresh);
  680. TI_Get4XState( g_id_adapter, &mode_4x);
  681. TI_GetEncryptionType( g_id_adapter, &encrypt );
  682. TI_GetPowerMode(g_id_adapter, (OS_802_11_POWER_PROFILE*) &power_mode );
  683. console_printf_terminal(" Authentication : %u\n", auth );
  684. console_printf_terminal(" Power mode : %d\n", (tiUINT32) power_mode );
  685. console_printf_terminal(" Tx Power (Dbm/10 units) : %d\n", tx_power );
  686. console_printf_terminal(" Encryption : %u\n", encrypt );
  687. console_printf_terminal(" Preamble : <%s>\n", (preamble) ? "short" : "long");
  688. /* console_printf_terminal(" Tx antenna : %u\n", tx_ant );*/
  689. /* console_printf_terminal( " Rx antenna : %u\n", rx_ant );*/
  690. /* console_printf_terminal( "Ap Tx power level: n/a\n" );*/
  691. /* console_printf_terminal( " Tx power value : %lu\n", tx_power_val );*/
  692. /* console_printf_terminal( " MAC address : n/a\n" );*/
  693. console_printf_terminal( " 4X state : %d\n", mode_4x );
  694. /* console_printf_terminal( " B/G mode : n/a\n" );*/
  695. /* console_printf_terminal( " Country code : n/a\n" );*/
  696. /* console_printf_terminal( " IP address : n/a\n" );*/
  697. /* console_printf_terminal( " Net mask : n/a\n" );*/
  698. /* console_printf_terminal( " Gateway : n/a\n" );*/
  699. console_printf_terminal( " Frag. threshold : %u\n", frag_tresh);
  700. console_printf_terminal( " RTS threshold : %u\n", rts_tresh );
  701. console_printf_terminal( "Power mode: ");
  702. print_available_values(power_mode_val);
  703. console_printf_terminal( "Encryption type: ");
  704. print_available_values(encrypt_type);
  705. }
  706. void cmd_show_statistics(ConParm_t parm[], U16 nParms)
  707. {
  708. TIWLN_STATISTICS statistics = { 0 } ;
  709. UNUSED(parm);
  710. UNUSED(nParms);
  711. console_printf_terminal( "TI_GetStatistics(%s, data=%p, size=%d\n", (char*) g_id_adapter, &statistics, sizeof(statistics) );
  712. if( TI_GetStatistics( g_id_adapter, &statistics ) )
  713. {
  714. console_printf_terminal ("Error in getting TI_GetStatistics!!\n");
  715. return;
  716. }
  717. console_printf_terminal("******************\n");
  718. console_printf_terminal("Driver Statistics:\n");
  719. console_printf_terminal("******************\n");
  720. console_printf_terminal(" dot11CurrentTxRate : %s\n", print_rate(statistics.dot11CurrentTxRate) );
  721. console_printf_terminal(" dot11CurrentChannel : %d\n", statistics.dot11CurrentChannel );
  722. console_printf_terminal(" currentMACAddress : %s\n", print_mac_2_str(statistics.currentMACAddress) );
  723. console_printf_terminal(" dot11DesiredSSID : %s\n", get_ssid_string(&statistics.dot11DesiredSSID) );
  724. console_printf_terminal(" dot11BSSType : %d\n", statistics.dot11BSSType );
  725. console_printf_terminal(" AuthenticationMode : %d\n", statistics.AuthenticationMode );
  726. console_printf_terminal(" bShortPreambleUsed : %d\n", statistics.bShortPreambleUsed );
  727. console_printf_terminal(" RTSThreshold : %d\n", statistics.RTSThreshold );
  728. console_printf_terminal("FragmentationThreshold : %d\n", statistics.FragmentationThreshold );
  729. console_printf_terminal(" bDefaultWEPKeyDefined : %d\n", statistics.bDefaultWEPKeyDefined );
  730. console_printf_terminal(" WEPStatus : %d\n", statistics.WEPStatus );
  731. console_printf_terminal(" TxAntenna : %d\n", statistics.TxAntenna );
  732. console_printf_terminal(" RxAntenna : %d\n", statistics.RxAntenna );
  733. console_printf_terminal(" TxPowerDbm : %d\n", statistics.TxPowerDbm );
  734. console_printf_terminal(" PowerMode : %d\n", statistics.PowerMode );
  735. console_printf_terminal(" RxLevel : %d\n", statistics.RxLevel );
  736. /**/
  737. /* status & AP info*/
  738. /**/
  739. console_printf_terminal(" dot11State : %d\n", statistics.dot11State );
  740. /**/
  741. /* network layer statistics*/
  742. /**/
  743. console_printf_terminal(" RecvOk : %d\n", statistics.tiCounters.RecvOk );
  744. console_printf_terminal(" RecvError : %d\n", statistics.tiCounters.RecvError );
  745. console_printf_terminal(" DirectedBytesRecv : %d\n", statistics.tiCounters.DirectedBytesRecv );
  746. console_printf_terminal(" DirectedFramesRecv : %d\n", statistics.tiCounters.DirectedFramesRecv );
  747. console_printf_terminal(" MulticastBytesRecv : %d\n", statistics.tiCounters.MulticastBytesRecv );
  748. console_printf_terminal(" MulticastFramesRecv : %d\n", statistics.tiCounters.MulticastFramesRecv );
  749. console_printf_terminal(" BroadcastBytesRecv : %d\n", statistics.tiCounters.BroadcastBytesRecv );
  750. console_printf_terminal(" BroadcastFramesRecv : %d\n", statistics.tiCounters.BroadcastFramesRecv );
  751. console_printf_terminal(" FcsErrors : %d\n", statistics.tiCounters.FcsErrors );
  752. console_printf_terminal(" BeaconsRecv : %d\n", statistics.tiCounters.BeaconsRecv );
  753. console_printf_terminal(" AssocRejects : %d\n", statistics.tiCounters.AssocRejects );
  754. console_printf_terminal(" AssocTimeouts : %d\n", statistics.tiCounters.AssocTimeouts );
  755. console_printf_terminal(" AuthRejects : %d\n", statistics.tiCounters.AuthRejects );
  756. console_printf_terminal(" AuthTimeouts : %d\n", statistics.tiCounters.AuthTimeouts );
  757. /**/
  758. /* other statistics*/
  759. /**/
  760. console_printf_terminal(" dwSecuritySuit : %d\n", statistics.dwSecuritySuit );
  761. console_printf_terminal(" dwSecurityState : %d\n", statistics.dwSecurityState );
  762. console_printf_terminal(" dwSecurityAuthStatus : %d\n", statistics.dwSecurityAuthStatus );
  763. console_printf_terminal(" dwFeatureSuit : %d\n", statistics.dwFeatureSuit );
  764. }
  765. void cmd_show_tx_statistics(ConParm_t parm[], U16 nParms)
  766. {
  767. TIWLN_TX_STATISTICS statistics;
  768. UINT32 TxQid;
  769. UINT32 AverageDelay;
  770. UINT32 AverageFWDelay;
  771. UINT32 AverageMacDelay;
  772. tiINT32 status;
  773. UNUSED(parm);
  774. UNUSED(nParms);
  775. console_printf_terminal("TI_GetTxStatistics(%s, data=%p, size=%d\n", (char*) g_id_adapter, &statistics, sizeof(statistics) );
  776. /* The first parameter indicates whether to clear the statistics on read: 0 - don't clear, 1 - clear */
  777. if ( 0 == nParms )
  778. {
  779. status = TI_GetTxStatistics( g_id_adapter, &statistics, 0 );
  780. }
  781. else
  782. {
  783. status = TI_GetTxStatistics( g_id_adapter, &statistics, parm[0].value );
  784. }
  785. if( status )
  786. {
  787. console_printf_terminal ("Error in getting TI_GetTxStatistics!!\n");
  788. return;
  789. }
  790. console_printf_terminal("*********************\n");
  791. console_printf_terminal("Tx Queues Statistics:\n");
  792. console_printf_terminal("*********************\n");
  793. for (TxQid = 0; TxQid < MAX_NUM_OF_TX_QUEUES; TxQid++)
  794. {
  795. console_printf_terminal("\nTx Queue %d:\n", TxQid);
  796. console_printf_terminal("===========\n");
  797. console_printf_terminal(" Total Good Frames : %d\n", statistics.txCounters[TxQid].XmitOk );
  798. console_printf_terminal(" Unicast Bytes : %d\n", statistics.txCounters[TxQid].DirectedBytesXmit );
  799. console_printf_terminal(" Unicast Frames : %d\n", statistics.txCounters[TxQid].DirectedFramesXmit );
  800. console_printf_terminal(" Multicast Bytes : %d\n", statistics.txCounters[TxQid].MulticastBytesXmit );
  801. console_printf_terminal(" Multicast Frames : %d\n", statistics.txCounters[TxQid].MulticastFramesXmit );
  802. console_printf_terminal(" Broadcast Bytes : %d\n", statistics.txCounters[TxQid].BroadcastBytesXmit );
  803. console_printf_terminal(" Broadcast Frames : %d\n", statistics.txCounters[TxQid].BroadcastFramesXmit );
  804. console_printf_terminal(" Retry Failures : %d\n", statistics.txCounters[TxQid].RetryFailCounter );
  805. console_printf_terminal(" Tx Timeout Failures : %d\n", statistics.txCounters[TxQid].TxTimeoutCounter );
  806. console_printf_terminal(" No Link Failures : %d\n", statistics.txCounters[TxQid].NoLinkCounter );
  807. console_printf_terminal(" Other Failures : %d\n", statistics.txCounters[TxQid].OtherFailCounter );
  808. console_printf_terminal(" Max Consecutive Retry Failures : %d\n\n", statistics.txCounters[TxQid].MaxConsecutiveRetryFail );
  809. console_printf_terminal(" Retry histogram:\n");
  810. console_printf_terminal(" ----------------\n\n");
  811. console_printf_terminal(" Retries: %8d %8d %8d %8d %8d %8d %8d %8d\n", 0, 1, 2, 3, 4, 5, 6, 7);
  812. console_printf_terminal(" packets: %8d %8d %8d %8d %8d %8d %8d %8d\n\n",
  813. statistics.txCounters[TxQid].RetryHistogram[ 0 ],
  814. statistics.txCounters[TxQid].RetryHistogram[ 1 ],
  815. statistics.txCounters[TxQid].RetryHistogram[ 2 ],
  816. statistics.txCounters[TxQid].RetryHistogram[ 3 ],
  817. statistics.txCounters[TxQid].RetryHistogram[ 4 ],
  818. statistics.txCounters[TxQid].RetryHistogram[ 5 ],
  819. statistics.txCounters[TxQid].RetryHistogram[ 6 ],
  820. statistics.txCounters[TxQid].RetryHistogram[ 7 ]);
  821. console_printf_terminal(" Retries: %8d %8d %8d %8d %8d %8d %8d %8d\n", 8, 9, 10, 11, 12, 13, 14, 15);
  822. console_printf_terminal(" packets: %8d %8d %8d %8d %8d %8d %8d %8d\n\n",
  823. statistics.txCounters[TxQid].RetryHistogram[ 8 ],
  824. statistics.txCounters[TxQid].RetryHistogram[ 9 ],
  825. statistics.txCounters[TxQid].RetryHistogram[ 10 ],
  826. statistics.txCounters[TxQid].RetryHistogram[ 11 ],
  827. statistics.txCounters[TxQid].RetryHistogram[ 12 ],
  828. statistics.txCounters[TxQid].RetryHistogram[ 13 ],
  829. statistics.txCounters[TxQid].RetryHistogram[ 14 ],
  830. statistics.txCounters[TxQid].RetryHistogram[ 15 ]);
  831. if (statistics.txCounters[TxQid].NumPackets)
  832. {
  833. AverageDelay = statistics.txCounters[TxQid].SumTotalDelayMs / statistics.txCounters[TxQid].NumPackets;
  834. AverageFWDelay = statistics.txCounters[TxQid].SumFWDelayUs / statistics.txCounters[TxQid].NumPackets;
  835. AverageMacDelay = statistics.txCounters[TxQid].SumMacDelayUs / statistics.txCounters[TxQid].NumPackets;
  836. }
  837. else
  838. {
  839. AverageDelay = 0;
  840. AverageFWDelay = 0;
  841. AverageMacDelay = 0;
  842. }
  843. console_printf_terminal(" Total Delay ms (average/sum) : %d / %d\n", AverageDelay, statistics.txCounters[TxQid].SumTotalDelayMs);
  844. console_printf_terminal(" FW Delay us (average/sum) : %d / %d\n", AverageFWDelay, statistics.txCounters[TxQid].SumFWDelayUs);
  845. console_printf_terminal(" MAC Delay us (average/sum) : %d / %d\n\n", AverageMacDelay, statistics.txCounters[TxQid].SumMacDelayUs);
  846. console_printf_terminal(" Delay Ranges [msec] : Num of packets\n");
  847. console_printf_terminal(" ------------------- : --------------\n");
  848. console_printf_terminal(" 0 - 1 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_0_TO_1] );
  849. console_printf_terminal(" 1 - 10 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_1_TO_10] );
  850. console_printf_terminal(" 10 - 20 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_10_TO_20] );
  851. console_printf_terminal(" 20 - 40 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_20_TO_40] );
  852. console_printf_terminal(" 40 - 60 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_40_TO_60] );
  853. console_printf_terminal(" 60 - 80 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_60_TO_80] );
  854. console_printf_terminal(" 80 - 100 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_80_TO_100] );
  855. console_printf_terminal(" 100 - 200 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_100_TO_200] );
  856. console_printf_terminal(" Above 200 : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_ABOVE_200] );
  857. }
  858. }
  859. void cmd_show_about(ConParm_t parm[], U16 nParms)
  860. {
  861. TIWLN_VERSION_EX data;
  862. UNUSED(parm);
  863. UNUSED(nParms);
  864. console_printf_terminal("Utility version: %s (%u.%u.%u)\n", SW_VERSION_STR, SW_RELEASE_DAY,
  865. SW_RELEASE_MONTH, SW_RELEASE_YEAR );
  866. if( TI_GetDriverVersion(g_id_adapter, &data ) )
  867. return ;
  868. console_printf_terminal("Driver version: %u.%u.%u.%u.%u\n", data.DrvVersion.major, data.DrvVersion.minor,
  869. data.DrvVersion.bugfix, data.DrvVersion.subld, data.DrvVersion.build );
  870. console_printf_terminal("Firmware version: %u.%u.%u.%u.%u\n", data.FWVersion.major, data.FWVersion.minor,
  871. data.FWVersion.bugfix, data.FWVersion.subld, data.FWVersion.build );
  872. console_printf_terminal("Eeprom Version: %u.%u.%u.%u.%u\n", data.HWVersion.major, data.HWVersion.minor,
  873. data.HWVersion.bugfix, data.HWVersion.subld, data.HWVersion.build );
  874. console_printf_terminal("Eeprom Version2: %u.%u.%u.%u.%u\n", data.NVVersion.major, data.NVVersion.minor,
  875. data.NVVersion.bugfix, data.NVVersion.subld, data.HWVersion.build );
  876. }
  877. void cmd_modify_ssid(ConParm_t parm[], U16 nParms)
  878. {
  879. OS_802_11_SSID ssid = { 0 };
  880. OS_802_11_MAC_ADDRESS bssid = { 0xff,0xff,0xff,0xff,0xff,0xff };
  881. char *ssid_str;
  882. if( nParms == 0 )
  883. {
  884. if(!TI_GetCurrentSSID(g_id_adapter, &ssid))
  885. ssid_str = get_ssid_string(&ssid);
  886. else
  887. ssid_str = "<error>";
  888. console_printf_terminal("SSID: %s\n", ssid_str );
  889. }
  890. else{
  891. /* Setting the new SSID, BRCS BSSID is set to clean pre-set BSSID */
  892. TI_SetBSSID(g_id_adapter, &bssid );
  893. TI_SetSSID(g_id_adapter, (tiUINT8 *) parm[0].value);
  894. }
  895. }
  896. void cmd_modify_channel(ConParm_t parm[], U16 nParms)
  897. {
  898. if( nParms == 0 )
  899. {
  900. tiUINT32 data1 = 0, data = 0;
  901. if( !TI_GetDesiredChannel( g_id_adapter, &data1) )
  902. console_printf_terminal("Channel=%d (desired: %d)\n", !TI_GetCurrentChannel(g_id_adapter, &data) ? data : -1, data1 );
  903. }
  904. else
  905. TI_SetDesiredChannel( g_id_adapter, parm[0].value );
  906. }
  907. void cmd_set_power_mode(ConParm_t parm[], U16 nParms)
  908. {
  909. OS_802_11_POWER_PROFILE mode = 0x12345678;
  910. if( nParms )
  911. TI_ConfigPowerManagement (g_id_adapter, parm[0].value );
  912. else
  913. {
  914. if( !TI_GetPowerMode(g_id_adapter, &mode ) )
  915. {
  916. console_printf_terminal("Power mode: %d\n", mode );
  917. print_available_values(power_mode_val);
  918. }
  919. }
  920. }
  921. void cmd_set_PowerSave_PowerLevel(ConParm_t parm[], U16 nParms)
  922. {
  923. OS_802_11_POWER_LEVELS mode;
  924. if( nParms )
  925. TI_SetPowerLevelPS (g_id_adapter, parm[0].value );
  926. else
  927. {
  928. if( !TI_GetPowerLevelPS(g_id_adapter, &mode ) )
  929. {
  930. console_printf_terminal("Power Level PowerSave: %d\n", mode );
  931. print_available_values(power_level_val);
  932. }
  933. }
  934. }
  935. void cmd_set_Default_PowerLevel(ConParm_t parm[], U16 nParms)
  936. {
  937. OS_802_11_POWER_LEVELS mode;
  938. if( nParms )
  939. TI_SetPowerLevelDefault (g_id_adapter, parm[0].value );
  940. else
  941. {
  942. if( !TI_GetPowerLevelDefault(g_id_adapter, &mode ) )
  943. {
  944. console_printf_terminal("Default Power Level: %d\n", mode );
  945. print_available_values(power_level_val);
  946. }
  947. }
  948. }
  949. void cmd_set_DozeModeInAutoPowerLevel(ConParm_t parm[], U16 nParms)
  950. {
  951. OS_802_11_POWER_PROFILE mode;
  952. if( nParms )
  953. TI_SetPowerLevelDozeMode (g_id_adapter, parm[0].value );
  954. else
  955. {
  956. /* set Short or Long Doze. no use of other parameters */
  957. if( !TI_GetPowerLevelDozeMode(g_id_adapter,&mode ) )
  958. {
  959. console_printf_terminal("Doze Mode in Auto Power Level: SHORT_DOZE - %d LONG_DOZE - %d\n",
  960. OS_POWER_MODE_SHORT_DOZE,OS_POWER_MODE_LONG_DOZE);
  961. }
  962. }
  963. }
  964. void cmd_Beacon_Filter_Set_Desired_State(ConParm_t parm[], U16 nParms)
  965. {
  966. /*there are two modes : feature ACTIVE & PASSIV ( or NOT ACTIVE )*/
  967. if( nParms )
  968. {
  969. TI_SetBeaconFilterDesiredState(g_id_adapter, parm[0].value );
  970. }
  971. else
  972. {
  973. console_printf_terminal("Use : 0 = INACTIVE , 1 = ACTIVE\n" ) ;
  974. }
  975. }
  976. void cmd_Beacon_Filter_Get_Desired_State(ConParm_t parm[], U16 nParms)
  977. {
  978. UINT8 desState = FALSE ;
  979. TI_GetBeaconFilterDesiredState(g_id_adapter, &desState ) ;
  980. console_printf_terminal("Desired State is %s\n", (desState == FALSE)?"FILTER INACTIVE":"FILTER ACTIVE" );
  981. }
  982. /* scan commands (new from eSTAdk 5.0) */
  983. void init_scan_params(void)
  984. {
  985. int i,j;
  986. /* init application scan default params */
  987. appScanParams.desiredSsid.len = 0;
  988. appScanParams.scanType = SCAN_TYPE_NORMAL_ACTIVE;
  989. appScanParams.band = RADIO_BAND_2_4_GHZ;
  990. appScanParams.probeReqNumber = 3;
  991. appScanParams.probeRequestRate = DRV_RATE_MASK_2_BARKER;
  992. appScanParams.numOfChannels = 11;
  993. for ( i = 0; i < 11; i++ )
  994. {
  995. for ( j = 0; j < 6; j++ )
  996. {
  997. appScanParams.channelEntry[ i ].normalChannelEntry.bssId.addr[ j ] = 0xff;
  998. }
  999. appScanParams.channelEntry[ i ].normalChannelEntry.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
  1000. appScanParams.channelEntry[ i ].normalChannelEntry.ETMaxNumOfAPframes = 0;
  1001. appScanParams.channelEntry[ i ].normalChannelEntry.maxChannelDwellTime = 60000;
  1002. appScanParams.channelEntry[ i ].normalChannelEntry.minChannelDwellTime = 30000;
  1003. appScanParams.channelEntry[ i ].normalChannelEntry.txPowerDbm = MAX_TX_POWER;
  1004. appScanParams.channelEntry[ i ].normalChannelEntry.channel = i + 1;
  1005. }
  1006. /* init default scan policy */
  1007. scanPolicy.normalScanInterval = 10000;
  1008. scanPolicy.deterioratingScanInterval = 5000;
  1009. scanPolicy.maxTrackFailures = 3;
  1010. scanPolicy.BSSListSize = 4;
  1011. scanPolicy.BSSNumberToStartDiscovery = 1;
  1012. scanPolicy.numOfBands = 1;
  1013. scanPolicy.bandScanPolicy[ 0 ].band = RADIO_BAND_2_4_GHZ;
  1014. scanPolicy.bandScanPolicy[ 0 ].rxRSSIThreshold = -80;
  1015. scanPolicy.bandScanPolicy[ 0 ].numOfChannles = 11;
  1016. scanPolicy.bandScanPolicy[ 0 ].numOfChannlesForDiscovery = 3;
  1017. for ( i = 0; i < 11; i++ )
  1018. {
  1019. scanPolicy.bandScanPolicy[ 0 ].channelList[ i ] = i + 1;
  1020. }
  1021. scanPolicy.bandScanPolicy[ 0 ].trackingMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE;
  1022. scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
  1023. scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
  1024. scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
  1025. scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.minChannelDwellTime = 15000;
  1026. scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.bitrate = DRV_RATE_MASK_1_BARKER;
  1027. scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
  1028. scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.txPowerDbm = MAX_TX_POWER;
  1029. scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE;
  1030. scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
  1031. scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
  1032. scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
  1033. scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.minChannelDwellTime = 15000;
  1034. scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.bitrate = DRV_RATE_MASK_2_BARKER;
  1035. scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
  1036. scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.txPowerDbm = MAX_TX_POWER;
  1037. scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE;
  1038. scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
  1039. scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
  1040. scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
  1041. scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.minChannelDwellTime = 15000;
  1042. scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.bitrate = DRV_RATE_MASK_5_5_CCK;
  1043. scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
  1044. scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.txPowerDbm = MAX_TX_POWER;
  1045. }
  1046. void cmd_Scan_Start(ConParm_t parm[], U16 nParms)
  1047. {
  1048. TI_StartScan( g_id_adapter, &appScanParams );
  1049. console_printf_terminal("Application scan started.\n");
  1050. }
  1051. void cmd_Scan_Stop(ConParm_t parm[], U16 nParms)
  1052. {
  1053. TI_StopScan( g_id_adapter );
  1054. console_printf_terminal("Application scan stopped.\n");
  1055. }
  1056. void cmd_Scan_app_global_config(ConParm_t parm[], U16 nParms)
  1057. {
  1058. if ( 0 == strcmp( "<empty>", (char*)parm[0].value) )
  1059. {
  1060. appScanParams.desiredSsid.len = 0;
  1061. appScanParams.desiredSsid.ssidString[ 0 ] = '\0';
  1062. }
  1063. else
  1064. {
  1065. appScanParams.desiredSsid.len = strlen((char*)parm[0].value);
  1066. memcpy( &(appScanParams.desiredSsid.ssidString), (char*)parm[0].value, appScanParams.desiredSsid.len );
  1067. }
  1068. appScanParams.scanType = parm[1].value;
  1069. appScanParams.band = parm[2].value;
  1070. appScanParams.probeReqNumber = (UINT8)parm[3].value;
  1071. appScanParams.probeRequestRate = parm[4].value;
  1072. #ifdef TI_DBG
  1073. appScanParams.Tid = (UINT8)parm[5].value;
  1074. appScanParams.numOfChannels = (UINT8)parm[6].value;
  1075. #else
  1076. appScanParams.Tid = 0;
  1077. appScanParams.numOfChannels = (UINT8)parm[5].value;
  1078. #endif
  1079. }
  1080. void cmd_Scan_app_channel_config(ConParm_t parm[], U16 nParms)
  1081. {
  1082. scan_normalChannelEntry_t* pChannelEntry =
  1083. &(appScanParams.channelEntry[ parm[0].value ].normalChannelEntry);
  1084. if (parm[2].value < parm[3].value)
  1085. {
  1086. console_printf_terminal ("Max Dwell Time must be larger than or equal to Min Dwell Time...\n");
  1087. return;
  1088. }
  1089. hexStr2MACAddr( (char*)parm[1].value, &(pChannelEntry->bssId) );
  1090. pChannelEntry->maxChannelDwellTime = parm[2].value;
  1091. pChannelEntry->minChannelDwellTime = parm[3].value;
  1092. pChannelEntry->earlyTerminationEvent = parm[4].value;
  1093. pChannelEntry->ETMaxNumOfAPframes = (UINT8)parm[5].value;
  1094. pChannelEntry->txPowerDbm = (UINT8)parm[6].value;
  1095. pChannelEntry->channel = (UINT8)parm[7].value;
  1096. }
  1097. void cmd_Scan_app_clear(ConParm_t parm[], U16 nParms)
  1098. {
  1099. memset( &appScanParams, 0, sizeof(scan_Params_t) );
  1100. console_printf_terminal("Application scan parameters cleared.\n");
  1101. }
  1102. void cmd_Scan_app_display(ConParm_t parm[], U16 nParms)
  1103. {
  1104. int i;
  1105. scan_normalChannelEntry_t* pNormalChannel;
  1106. char bssId[18];
  1107. bssId[17] = '\0';
  1108. console_printf_terminal("Application Scan params:\n");
  1109. 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