Home | History | Annotate | Download | only in CLI
      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 
     21 
     22 /****************************************************************************************************/
     23 /*                                                                                                  */
     24 /*      MODULE:     wipp_ctrl.c                                                                     */
     25 /*      PURPOSE:    WIPP Control utilities			                                                */
     26 /*      Note:	    This module is for LINUX compilation only!										*/
     27 /*                                                                                                  */
     28 /****************************************************************************************************/
     29 
     30 
     31 #include "TI_AdapterApiC.h"
     32 #include "osDot11.h"
     33 
     34 #include <stdlib.h>
     35 #include <fcntl.h>
     36 #include <errno.h>
     37 #include <sys/stat.h>
     38 #include <unistd.h>
     39 
     40 
     41 #include "g_tester.h"
     42 #include "console.h"
     43 #include "cu_cmd.h"
     44 #include "ticon.h"
     45 #include "ipc.h"
     46 
     47 #include "paramOut.h"
     48 
     49 /************/
     50 /* Defines */
     51 /**********/
     52 
     53 
     54 #define G_TESTER_STATUS_OK		(0)
     55 #define G_TESTER_STATUS_ERROR	(1)
     56 
     57 #define G_TESTER_GWSI_INIT_NO_ERROR						(0x00)
     58 #define G_TESTER_GWSI_INIT_ERROR_READING_FW_FILE_LENGTH	(0x01)
     59 #define G_TESTER_GWSI_INIT_ERROR_OPENING_FW_FILE		(0x02)
     60 #define G_TESTER_GWSI_INIT_ERROR_READING_EP_FILE_LENGTH	(0x03)
     61 #define G_TESTER_GWSI_INIT_ERROR_OPENING_EP_FILE		(0x04)
     62 #define G_TESTER_GWSI_INIT_ERROR_READING_EP_FILE		(0x05)
     63 #define G_TESTER_GWSI_INIT_ERROR_READING_FW_FILE		(0x06)
     64 #define G_TESTER_GWSI_INIT_ERROR_ALLOCATION_MEMORY		(0x07)
     65 
     66 #define G_TESTER_GWSI_GET_INIT_TABLE_NO_ERROR				(0x00)
     67 #define G_TESTER_GWSI_GET_INIT_TABLE_ERROR_NO_FILE_NAME		(0x01)
     68 #define G_TESTER_GWSI_GET_INIT_TABLE_ERROR_WRITING_TO_FILE	(0x02)
     69 #define G_TESTER_GWSI_GET_INIT_TABLE_ERROR_CREATING_FILE	(0x03)
     70 #define G_TESTER_GWSI_GET_INIT_TABLE_ERROR_TABLE_NOT_AVAIL	(0x04)
     71 
     72 #define G_TESTER_GWSI_CONFIG_NO_ERROR					(0x00)
     73 #define G_TESTER_GWSI_CONFIG_ERROR_READING_FILE			(0x01)
     74 #define G_TESTER_GWSI_CONFIG_ERROR_ALLOCATING_MEMORY	(0x02)
     75 #define G_TESTER_GWSI_CONFIG_ERROR_GETIING_FILE_SIZE	(0x03)
     76 #define G_TESTER_GWSI_CONFIG_ERROR_OPENING_FILE			(0x04)
     77 
     78 
     79 
     80 extern void quit_func(void);
     81 void g_tester_process_general_cmd_run_cmd(unsigned char *cmd_buffer);
     82 void g_tester_process_get_init_table(unsigned char *cmd_buffer);
     83 
     84 void g_tester_send_to_host(tiUINT8 *buffer, tiUINT32 length);
     85 void g_tester_cmd_status(void);
     86 void g_tester_bssid_list(void);
     87 void g_tester_send_received_event(unsigned int cmd_op, tiUINT8 status);
     88 void g_tester_process_gwsi_init_cmd(unsigned char *cmd_buffer);
     89 void g_tester_process_gwsi_config_cmd(unsigned char *cmd_buffer);
     90 void g_tester_process_gwsi_release_cmd(unsigned char *cmd_buffer);
     91 void g_tester_process_gwsi_cmd(unsigned char *cmd_buffer);
     92 void g_tester_register_event(tiUINT16 event_mask);
     93 void g_tester_unregister_event(tiUINT16 event_mask);
     94 void g_tester_cmd_debug_driver_print(unsigned char *cmd_buffer);
     95 void g_tester_cmd_get_version(void);
     96 void g_tester_set_rate(tiUINT8 rate_index);
     97 void g_tester_wep_add_key(unsigned char *cmd_buffer);
     98 int g_tester_gwsi_event_handler(IPC_EV_DATA* pData);
     99 void g_tester_cmd_plt_register_read(UINT32 uiRegAddress);
    100 void g_tester_cmd_plt_RxPer_GetResults(void);
    101 void g_tester_cmd_plt_mib_read(unsigned char *cmd_buffer);
    102 void g_tester_cmd_plt_mib_write(unsigned char *cmd_buffer);
    103 void g_tester_cmd_get_defaultWEPKey(void);
    104 void g_tester_Roaming_candidates_list(void);
    105 void g_tester_scAn__configApp__Display(void);
    106 void g_tester_plt_calibration_get_nvs_buffer(void);
    107 
    108 
    109 TI_HANDLE gwsi_event_id;
    110 
    111 
    112 /************************************************************************
    113 *                        g_tester_send_to_host                         *
    114 ************************************************************************
    115 DESCRIPTION:
    116 
    117   CONTEXT    :
    118 ************************************************************************/
    119 void g_tester_send_to_host(tiUINT8 *buffer, tiUINT32 length)
    120 {
    121     /* console_printf_terminal("g_tester, g_tester_send_to_host (length = %d)!\n", length); */
    122 
    123     /* Send the buffer to the host */
    124     console_send_buffer_to_host(ETHERNET_UTILS_G_TESTER_MODULE_ID, buffer, length);
    125 }
    126 
    127 /************************************************************************
    128 *                        g_tester_init			                        *
    129 ************************************************************************
    130 DESCRIPTION:
    131 
    132   CONTEXT    :
    133 ************************************************************************/
    134 void g_tester_init()
    135 {
    136     /************************************/
    137     /* Register the GWSI event handler */
    138     /**********************************/
    139 
    140     IPC_EVENT_PARAMS pEvent;
    141 
    142 
    143     pEvent.uEventType       = IPC_EVENT_GWSI;
    144     pEvent.uDeliveryType    = DELIVERY_PUSH;
    145     pEvent.pfEventCallback  = g_tester_gwsi_event_handler;
    146     pEvent.hUserParam		= 0;
    147 
    148     /* Register the event, set the pEvent.uEventID and the pEvent.uProcessID */
    149     if(!TI_RegisterEvent(g_id_adapter, &pEvent))
    150     {
    151         gwsi_event_id = pEvent.uEventID;
    152     }
    153     else
    154     {
    155         console_printf_terminal("g_tester,  g_tester_init. ERROR Registering GWSI event\n");
    156     }
    157 
    158 }
    159 
    160 /************************************************************************
    161 *                        g_tester_deinit		                        *
    162 ************************************************************************
    163 DESCRIPTION:
    164 
    165   CONTEXT    :
    166 ************************************************************************/
    167 void g_tester_deinit()
    168 {
    169     /**************************************/
    170     /* Unregister the GWSI event handler */
    171     /************************************/
    172 
    173     IPC_EVENT_PARAMS pEvent;
    174 
    175     pEvent.uEventType = IPC_EVENT_GWSI;
    176     pEvent.uEventID   = gwsi_event_id;
    177     TI_UnRegisterEvent(g_id_adapter, &pEvent);
    178 }
    179 
    180 /************************************************************************
    181 *                        wipp_control_check_command                    *
    182 ************************************************************************
    183 DESCRIPTION: Handle the wipp control specific commands
    184 
    185   CONTEXT    : main process only!
    186 ************************************************************************/
    187 unsigned char g_tester_check_command(unsigned char *input_string)
    188 {
    189     unsigned char return_value = FALSE;
    190     unsigned int cmd_op;
    191     /*ConParm_t parm;*/
    192     ConParm_t parms[12];
    193     int parms_num;
    194     unsigned char* data_string = input_string + 5;
    195 
    196     if (input_string[0] == '-')
    197     {
    198         /* Get the command opcode */
    199         cmd_op = (input_string[1] | (input_string[2] << 8));
    200 
    201         console_printf_terminal("g_tester,  g_tester_check_command (OpCode = 0x%x).\n", cmd_op);
    202 
    203         /* Notify the host that we got the event */
    204         g_tester_send_received_event(cmd_op, G_TESTER_STATUS_OK);
    205 
    206         if (G_TESTER_IS_GENERAL_GROUP_CMD(cmd_op))
    207         {
    208             /************************************/
    209             /* This command is GENERAL command */
    210             /**********************************/
    211 
    212             switch (cmd_op)
    213             {
    214             case G_TESTER_GENERAL_CMD_RUN_CMD:
    215                 g_tester_process_general_cmd_run_cmd(data_string);
    216                 break;
    217 
    218             case G_TESTER_GENERAL_CMD_GET_INIT_T:
    219                 g_tester_process_get_init_table(data_string);
    220                 break;
    221 
    222             default:
    223                 console_printf_terminal("g_tester (general switch) - unsupported command!\n");
    224                 break;
    225             }
    226         }
    227         else if (G_TESTER_IS_GWSI_GROUP_CMD(cmd_op))
    228         {
    229             /*********************************/
    230             /* This command is GWSI command */
    231             /*******************************/
    232 
    233             switch (cmd_op)
    234             {
    235             case G_TESTER_GWSI_CMD_INITIALIZE:
    236                 g_tester_process_gwsi_init_cmd(data_string);
    237                 break;
    238 
    239             case G_TESTER_GWSI_CMD_CONFIG:
    240                 g_tester_process_gwsi_config_cmd(data_string);
    241                 break;
    242 
    243             case G_TESTER_GWSI_CMD_RELEASE:
    244                 g_tester_process_gwsi_release_cmd(data_string);
    245                 break;
    246 
    247             default:
    248                 g_tester_process_gwsi_cmd(&input_string[1]);
    249                 break;
    250             }
    251         }
    252         else
    253         {
    254             /********************************/
    255             /* This command is CLI command */
    256             /******************************/
    257             switch(cmd_op)
    258             {
    259             case G_TESTER_CLI_CMD_DRIVER__START:
    260                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    261                 cmd_start_driver(parms, 1);
    262                 break;
    263 
    264             case G_TESTER_CLI_CMD_DRIVER__STOP:
    265                 cmd_stop_driver(NULL, 0);
    266                 break;
    267 
    268             case G_TESTER_CLI_CMD_DRIVER__STATUS:
    269                 g_tester_cmd_status();
    270                 break;
    271 
    272             case G_TESTER_CLI_CMD_CONNECTION__BSSID_LIST:
    273                 g_tester_bssid_list();
    274                 break;
    275 
    276             case G_TESTER_CLI_CMD_CONNECTION__CONNECT:
    277                 parms[0].value = (U32)(data_string);
    278                 data_string += 32; /*Seek to the end of the string */
    279                 parms[1].value = (U32)(data_string);
    280                 /*Find the number of none empty strings */
    281                 for(parms_num = 2; (parms_num >= 1) && (strlen((char*)parms[parms_num-1].value) == 0); parms_num--)
    282                 {
    283                 }
    284                 cmd_connect(parms, parms_num);
    285                 break;
    286 
    287             case G_TESTER_CLI_CMD_CONNECTION__DISASSOCIATE:
    288                 cmd_disassociate(NULL, 0);
    289                 break;
    290 
    291             case G_TESTER_CLI_CMD_CONNECTION__STATUS:
    292                 g_tester_cmd_status();
    293                 break;
    294 
    295             case G_TESTER_CLI_CMD_CONNECTION__FULL_BSSID_LIST:
    296                 cmd_Full_bssid_list(NULL, 0);
    297                 break;
    298 
    299             case G_TESTER_CLI_CMD_MANAGEMENT__SSID:
    300                 parms[0].value = (U32)(data_string);
    301                 parms_num =(strlen((char*)parms[0].value) == 0)?0:1;
    302                 cmd_modify_ssid(parms, parms_num);
    303                 break;
    304 
    305             case G_TESTER_CLI_CMD_MANAGEMENT__CHANNEL:
    306                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    307                 cmd_modify_channel(parms, 1);
    308                 break;
    309 
    310             case G_TESTER_CLI_CMD_MANAGEMENT__RATE:
    311                 g_tester_set_rate(input_string[5]);
    312                 break;
    313 
    314             case G_TESTER_CLI_CMD_MANAGEMENT__MODE:
    315                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    316                 cmd_modify_bss_type(parms, 1);
    317                 break;
    318 
    319             case G_TESTER_CLI_CMD_MANAGEMENT__FRAG:
    320                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    321                 cmd_modify_frag_threshold(parms, 1);
    322                 break;
    323 
    324             case G_TESTER_CLI_CMD_MANAGEMENT__RTS:
    325                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    326                 cmd_modify_rts_threshold(parms, 1);
    327                 break;
    328 
    329             case G_TESTER_CLI_CMD_MANAGEMENT__PREAMBLE:
    330                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    331                 cmd_modify_preamble(parms, 1);
    332                 break;
    333 
    334             case G_TESTER_CLI_CMD_MANAGEMENT__SLOT:
    335                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    336                 cmd_modify_short_slot(parms, 1);
    337                 break;
    338 
    339             case G_TESTER_CLI_CMD_MANAGEMENT__INFO:
    340                 cmd_get_selected_bssid_info(NULL, 0);
    341                 break;
    342 
    343             case G_TESTER_CLI_CMD_MANAGEMENT__DRIVERSTATE:
    344                 cmd_get_driver_state(NULL, 0);
    345                 break;
    346 
    347             case G_TESTER_CLI_CMD_MANAGEMENT__SIGNAL:
    348                 cmd_get_rsii_level(NULL, 0);
    349                 break;
    350 
    351             case G_TESTER_CLI_CMD_MANAGEMENT__TX_POWER_LEVEL:
    352                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    353                 cmd_show_tx_power_level_table(parms, 1);
    354                 break;
    355 
    356             case G_TESTER_CLI_CMD_MANAGEMENT__TX_POWER_DBM:
    357                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    358                 cmd_tx_power_dbm(parms, 1);
    359                 break;
    360 
    361             case G_TESTER_CLI_CMD_MANAGEMENT__802_11D_H__D_ENABLEDISABLE:
    362                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    363                 cmd_enableDisable_802_11d(parms, 1);
    364                 break;
    365 
    366             case G_TESTER_CLI_CMD_MANAGEMENT__802_11D_H__H_ENABLEDISABLE:
    367                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    368                 cmd_enableDisable_802_11h(parms, 1);
    369                 break;
    370 
    371             case G_TESTER_CLI_CMD_MANAGEMENT__802_11D_H__D_COUNTRY_2_4IE:
    372                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    373                 cmd_d_Country_2_4Ie(parms, 1);
    374                 break;
    375 
    376             case G_TESTER_CLI_CMD_MANAGEMENT__802_11D_H__D_COUNTRY_5IE:
    377                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    378                 cmd_d_Country_5Ie(parms, 1);
    379                 break;
    380 
    381             case G_TESTER_CLI_CMD_MANAGEMENT__ANTENNA__DIVERSITYPARAMS:
    382                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    383                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    384                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    385                 P_BUFFER_GET_UINT32(data_string, parms[3].value);
    386                 P_BUFFER_GET_UINT32(data_string, parms[4].value);
    387                 cmd_modify_antenna_diversity(parms, 5);
    388                 break;
    389 
    390             case G_TESTER_CLI_CMD_MANAGEMENT__BEACON__SET_BEACON_FILTER_MODE:
    391                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    392                 cmd_Beacon_Filter_Set_Desired_State(parms, 1);
    393                 break;
    394 
    395             case G_TESTER_CLI_CMD_MANAGEMENT__ADVANCED__DRAFT:
    396                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    397                 cmd_modify_ext_rates_ie(parms, 1);
    398                 break;
    399 
    400             case G_TESTER_CLI_CMD_MANAGEMENT__ADVANCED__SUPPORTED_RATES:
    401                 parms[0].value = (U32)(data_string);
    402                 parms_num =(strlen((char*)parms[0].value) == 0)?0:1;
    403                 cmd_modify_supported_rates(parms, parms_num);
    404                 break;
    405 
    406             case G_TESTER_CLI_CMD_SHOW__STATISTICS:
    407                 cmd_show_statistics(NULL, 0);
    408                 break;
    409 
    410             case G_TESTER_CLI_CMD_SHOW__TX_STATISTICS:
    411                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    412                 cmd_show_tx_statistics(parms, 1);
    413                 break;
    414 
    415             case G_TESTER_CLI_CMD_SHOW__ADVANCED:
    416                 cmd_show_advanced_params(NULL, 0);
    417                 break;
    418 
    419             case G_TESTER_CLI_CMD_PRIVACY__AUTHENTICATION:
    420                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    421                 cmd_privacy_auth(parms, 1);
    422                 break;
    423 
    424             case G_TESTER_CLI_CMD_PRIVACY__EAP:
    425                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    426                 cmd_privacy_eap(parms, 1);
    427                 break;
    428 
    429             case G_TESTER_CLI_CMD_PRIVACY__ENCRYPTION:
    430                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    431                 cmd_privacy_encrypt(parms, 1);
    432                 break;
    433 
    434             case G_TESTER_CLI_CMD_PRIVACY__KEYTYPE:
    435                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    436                 cmd_privacy_key_type(parms, 1);
    437                 break;
    438 
    439             case G_TESTER_CLI_CMD_PRIVACY__MIXEDMODE:
    440                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    441                 cmd_privacy_mixed_mode(parms, 1);
    442                 break;
    443 
    444             case G_TESTER_CLI_CMD_PRIVACY__CREDENTIALS:
    445                 parms[0].value = (U32)(data_string);
    446                 data_string += 32; /*Seek to the end of the string */
    447                 parms[1].value = (U32)(data_string);
    448                 /*Find the number of none empty strings */
    449                 for(parms_num = 2; (parms_num >= 1) && (strlen((char*)parms[parms_num-1].value) == 0); parms_num--)
    450                 {
    451                 }
    452                 cmd_privacy_credent(parms, parms_num);
    453                 break;
    454 
    455             case G_TESTER_CLI_CMD_PRIVACY__PSKPASSPHRASE:
    456                 parms[0].value = (U32)(data_string);
    457                 parms_num =(strlen((char*)parms[0].value) == 0)?0:1;
    458                 cmd_privacy_PSKPassphrase(parms, parms_num);
    459                 break;
    460 
    461             case G_TESTER_CLI_CMD_PRIVACY__CERTIFICATE:
    462                 parms[0].value = (U32)(data_string);
    463                 data_string += 32; /*Seek top the end of the string */
    464                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    465                 cmd_privacy_certificate(parms, 2);
    466                 break;
    467 
    468             case G_TESTER_CLI_CMD_PRIVACY__WPA_OPTIONS:
    469                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    470                 cmd_privacy_wpa_options(parms, 1);
    471                 break;
    472 
    473             case G_TESTER_CLI_CMD_PRIVACY__WEP__ADD:
    474                 g_tester_wep_add_key(data_string);
    475                 break;
    476 
    477             case G_TESTER_CLI_CMD_PRIVACY__WEP__REMOVE:
    478                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    479                 cmd_privacy_removekey(parms, 1);
    480                 break;
    481 
    482 #ifdef EXC_MODULE_INCLUDED
    483             case G_TESTER_CLI_CMD_PRIVACY__EXC__CONFIGURE:
    484                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    485                 cmd_privacy_exc_config(parms, 1);
    486                 break;
    487 
    488             case G_TESTER_CLI_CMD_PRIVACY__EXC__NETWORKEAP:
    489                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    490                 cmd_privacy_exc_netEap(parms, 1);
    491                 break;
    492 #endif
    493             case G_TESTER_CLI_CMD_SCAN__START:
    494                 cmd_Scan_Start(NULL, 0);
    495                 break;
    496 
    497             case G_TESTER_CLI_CMD_SCAN__STOP:
    498                 cmd_Scan_Stop(NULL, 0);
    499                 break;
    500 
    501             case G_TESTER_CLI_CMD_SCAN__CONFIGAPP__GLOBAL:
    502             {
    503                 int numOfParam;
    504                 parms[0].value = (U32)(data_string);                /*SSID*/
    505                 data_string+=33; /*seek the end of the string */
    506                 P_BUFFER_GET_UINT32(data_string, parms[1].value);   /*Scan Type*/
    507                 P_BUFFER_GET_UINT32(data_string, parms[2].value);   /*Band*/
    508                 P_BUFFER_GET_UINT32(data_string, parms[3].value);   /*Probe Request Number*/
    509                 P_BUFFER_GET_UINT32(data_string, parms[4].value);   /*Probe Request Rate*/
    510 #ifdef TI_DBG
    511                 numOfParam = 7;
    512                 P_BUFFER_GET_UINT32(data_string, parms[5].value);   /*Tid*/
    513                 P_BUFFER_GET_UINT32(data_string, parms[6].value);   /*Number of Channels*/
    514 #else
    515                 numOfParam = 6;
    516                 P_BUFFER_GET_UINT32(data_string, parms[5].value);   /* skip XML Tid*/
    517                 P_BUFFER_GET_UINT32(data_string, parms[5].value);   /*Number of Channels*/
    518 #endif
    519 
    520 				 cmd_Scan_app_global_config(parms, numOfParam);
    521             }
    522                 cmd_Scan_app_global_config(parms, 6);
    523                 break;
    524 
    525             case G_TESTER_CLI_CMD_SCAN__CONFIGAPP__CHANNEL:
    526                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    527                 parms[1].value = (U32)(data_string);
    528                 data_string += 18; /*seek the end of the string */
    529                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    530                 P_BUFFER_GET_UINT32(data_string, parms[3].value);
    531                 P_BUFFER_GET_UINT32(data_string, parms[4].value);
    532                 P_BUFFER_GET_UINT32(data_string, parms[5].value);
    533                 P_BUFFER_GET_UINT32(data_string, parms[6].value);
    534                 P_BUFFER_GET_UINT32(data_string, parms[7].value);
    535                 cmd_Scan_app_channel_config(parms, 8);
    536                 break;
    537 
    538             case G_TESTER_CLI_CMD_SCAN__CONFIGAPP__CLEAR:
    539                 cmd_Scan_app_clear(NULL, 0);
    540                 break;
    541 
    542             case G_TESTER_CLI_CMD_SCAN__CONFIGAPP__DISPLAY:
    543                 cmd_Scan_app_display(NULL, 0);
    544                 break;
    545 
    546             case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__GLOABAL:
    547                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    548                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    549                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    550                 P_BUFFER_GET_UINT32(data_string, parms[3].value);
    551                 P_BUFFER_GET_UINT32(data_string, parms[4].value);
    552                 P_BUFFER_GET_UINT32(data_string, parms[5].value);
    553                 cmd_Scan_policy_global_config(parms, 6);
    554                 break;
    555 
    556             case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BAND__MISC:
    557                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    558                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    559                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    560                 P_BUFFER_GET_UINT32(data_string, parms[3].value);
    561                 P_BUFFER_GET_UINT32(data_string, parms[4].value);
    562                 cmd_Scan_band_global_config(parms, 5);
    563                 break;
    564 
    565             case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BAND__CHANNEL:
    566                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    567                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    568                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    569                 cmd_Scan_band_channel_config(parms, 3);
    570                 break;
    571 
    572             case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BAND__TRACK:
    573                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    574                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    575                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    576                 P_BUFFER_GET_UINT32(data_string, parms[3].value);
    577                 P_BUFFER_GET_UINT32(data_string, parms[4].value);
    578                 P_BUFFER_GET_UINT32(data_string, parms[5].value);
    579                 P_BUFFER_GET_UINT32(data_string, parms[6].value);
    580                 P_BUFFER_GET_UINT32(data_string, parms[7].value);
    581                 P_BUFFER_GET_UINT32(data_string, parms[8].value);
    582                 P_BUFFER_GET_UINT32(data_string, parms[9].value);
    583                 P_BUFFER_GET_UINT32(data_string, parms[10].value);
    584                 cmd_Scan_band_track_config(parms, 11);
    585                 break;
    586 
    587             case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BAND__DISCOVERY:
    588                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    589                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    590                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    591                 P_BUFFER_GET_UINT32(data_string, parms[3].value);
    592                 P_BUFFER_GET_UINT32(data_string, parms[4].value);
    593                 P_BUFFER_GET_UINT32(data_string, parms[5].value);
    594                 P_BUFFER_GET_UINT32(data_string, parms[6].value);
    595                 P_BUFFER_GET_UINT32(data_string, parms[7].value);
    596                 P_BUFFER_GET_UINT32(data_string, parms[8].value);
    597                 P_BUFFER_GET_UINT32(data_string, parms[9].value);
    598                 P_BUFFER_GET_UINT32(data_string, parms[10].value);
    599                 cmd_Scan_band_discover_config(parms, 11);
    600                 break;
    601 
    602             case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BAND__IMMEDIATE:
    603                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    604                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    605                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    606                 P_BUFFER_GET_UINT32(data_string, parms[3].value);
    607                 P_BUFFER_GET_UINT32(data_string, parms[4].value);
    608                 P_BUFFER_GET_UINT32(data_string, parms[5].value);
    609                 P_BUFFER_GET_UINT32(data_string, parms[6].value);
    610                 P_BUFFER_GET_UINT32(data_string, parms[7].value);
    611                 P_BUFFER_GET_UINT32(data_string, parms[8].value);
    612                 P_BUFFER_GET_UINT32(data_string, parms[9].value);
    613                 P_BUFFER_GET_UINT32(data_string, parms[10].value);
    614                 cmd_Scan_band_immed_config(parms, 11);
    615                 break;
    616 
    617             case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__DISPLAY:
    618                 cmd_Scan_policy_display(NULL, 0);
    619                 break;
    620 
    621             case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__CLEAR:
    622                 cmd_Scan_policy_clear(NULL, 0);
    623                 break;
    624 
    625             case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__STORE:
    626                 cmd_Scan_policy_store(NULL, 0);
    627                 break;
    628 
    629             case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BSSLIST:
    630                 g_tester_Roaming_candidates_list();
    631                 break;
    632 
    633             case G_TESTER_CLI_CMD_ROAMING__ENABLE:
    634                 if (input_string[5] == FALSE)
    635                 {
    636                     cmd_Roaming_disable(NULL, 0);
    637                 }
    638                 else
    639                 {
    640                     cmd_Roaming_enable(NULL, 0);
    641                 }
    642                 break;
    643 
    644             case G_TESTER_CLI_CMD_ROAMING__LOW_PASS_FILTER:
    645                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    646                 cmd_Roaming_lowPassFilter(parms, 1);
    647                 break;
    648 
    649             case G_TESTER_CLI_CMD_ROAMING__QUALITY_THRESHOLD:
    650                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    651                 cmd_Roaming_qualityIndicator(parms, 1);
    652                 break;
    653 
    654             case G_TESTER_CLI_CMD_ROAMING__GET:
    655                 cmd_Roaming_getConfParams(NULL, 0);
    656                 break;
    657 
    658             case G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__TX_RETRY:
    659                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    660                 cmd_Roaming_dataRetryThreshold(parms, 1);
    661                 break;
    662 
    663             case G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__BSS_LOSS:
    664                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    665                 cmd_Roaming_numExpectedTbttForBSSLoss(parms, 1);
    666                 break;
    667 
    668             case G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__TX_RATE_THRESHOLD:
    669                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    670                 cmd_Roaming_txRateThreshold(parms, 1);
    671                 break;
    672 
    673             case G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__LOW_RSSI_THRESHOLD:
    674                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    675                 cmd_Roaming_lowRssiThreshold(parms, 1);
    676                 break;
    677 
    678             case G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__LOW_SNR_THRESHOLD:
    679                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    680                 cmd_Roaming_lowSnrThreshold(parms, 1);
    681                 break;
    682 
    683             case G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__LOW_QUALITY_FOR_SCAN:
    684                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    685                 cmd_Roaming_lowQualityForBackgroungScanCondition(parms, 1);
    686                 break;
    687 
    688             case G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__NORMAL_QUALITY_FOR_SCAN:
    689                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    690                 cmd_Roaming_normalQualityForBackgroungScanCondition(parms, 1);
    691                 break;
    692 
    693             case G_TESTER_CLI_CMD_QOS__UPSD__ADD:
    694                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    695                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    696                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    697                 P_BUFFER_GET_UINT32(data_string, parms[3].value);
    698                 P_BUFFER_GET_UINT32(data_string, parms[4].value);
    699                 P_BUFFER_GET_UINT32(data_string, parms[5].value);
    700                 cmd_add_tspec(parms, 6);
    701                 break;
    702 
    703             case G_TESTER_CLI_CMD_QOS__UPSD__GET:
    704                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    705                 cmd_get_tspec_params(parms, 1);
    706                 break;
    707 
    708             case G_TESTER_CLI_CMD_QOS__UPSD__DELETE:
    709                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    710                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    711                 cmd_delete_tspec(parms, 2);
    712                 break;
    713 
    714             case G_TESTER_CLI_CMD_QOS__UPSD__AP_PARAMS:
    715                 cmd_get_ap_qos_params(NULL, 0);
    716                 break;
    717 
    718             case G_TESTER_CLI_CMD_QOS__UPSD__AP_CAPABILITIES:
    719                 cmd_get_ap_qos_capabilities(NULL, 0);
    720                 break;
    721 
    722             case G_TESTER_CLI_CMD_QOS__UPSD__AC_STATUS:
    723                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    724                 cmd_get_ac_status(parms, 1);
    725                 break;
    726 
    727             case G_TESTER_CLI_CMD_QOS__UPSD__MEDIUM_USAGE:
    728                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    729                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    730                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    731                 cmd_medium_usage_threshold(parms, 3);
    732                 break;
    733 
    734             case G_TESTER_CLI_CMD_QOS__UPSD__PHY_RATE:
    735                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    736                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    737                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    738                 cmd_phy_rate_threshold(parms, 3);
    739                 break;
    740 
    741             case G_TESTER_CLI_CMD_QOS__UPSD__DESIRED_PS_MODE:
    742                 cmd_get_desired_ps_mode(NULL, 0);
    743                 break;
    744 
    745             case G_TESTER_CLI_CMD_QOS__CLASSIFIER__TXCLASSIFIER:
    746                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    747                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    748                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    749                 P_BUFFER_GET_UINT32(data_string, parms[3].value);
    750                 P_BUFFER_GET_UINT32(data_string, parms[4].value);
    751                 P_BUFFER_GET_UINT32(data_string, parms[5].value);
    752                 P_BUFFER_GET_UINT32(data_string, parms[6].value);
    753                 P_BUFFER_GET_UINT32(data_string, parms[7].value);
    754                 P_BUFFER_GET_UINT32(data_string, parms[8].value);
    755                 P_BUFFER_GET_UINT32(data_string, parms[9].value);
    756                 P_BUFFER_GET_UINT32(data_string, parms[10].value);
    757                 P_BUFFER_GET_UINT32(data_string, parms[11].value);
    758                 cmd_config_tx_classifier(parms, 12);
    759                 break;
    760 
    761             case G_TESTER_CLI_CMD_QOS__CLASSIFIER__INSERT:
    762                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    763                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    764                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    765                 P_BUFFER_GET_UINT32(data_string, parms[3].value);
    766                 P_BUFFER_GET_UINT32(data_string, parms[4].value);
    767                 P_BUFFER_GET_UINT32(data_string, parms[5].value);
    768                 P_BUFFER_GET_UINT32(data_string, parms[6].value);
    769                 cmd_insert_clsfr_entry(parms, 7);
    770                 break;
    771 
    772             case G_TESTER_CLI_CMD_QOS__CLASSIFIER__REMOVE:
    773                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    774                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    775                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    776                 P_BUFFER_GET_UINT32(data_string, parms[3].value);
    777                 P_BUFFER_GET_UINT32(data_string, parms[4].value);
    778                 P_BUFFER_GET_UINT32(data_string, parms[5].value);
    779                 P_BUFFER_GET_UINT32(data_string, parms[6].value);
    780                 cmd_remove_clsfr_entry(parms, 7);
    781                 break;
    782 
    783             case G_TESTER_CLI_CMD_QOS__QOSPARAMS:
    784                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    785                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    786                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    787                 P_BUFFER_GET_UINT32(data_string, parms[3].value);
    788                 cmd_set_qos_params(parms, 4);
    789                 break;
    790 
    791             case G_TESTER_CLI_CMD_QOS__POLL_AP_PACKETS:
    792                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    793                 cmd_poll_ap_packets(parms, 1);
    794                 break;
    795 
    796             case G_TESTER_CLI_CMD_QOS__RX_TIMEOUT:
    797                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    798                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    799                 cmd_set_rxTimeOut_params(parms, 2);
    800                 break;
    801 
    802             case G_TESTER_CLI_CMD_POWER__SET_POWER_MODE:
    803                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    804                 cmd_set_power_mode(parms, 1);
    805                 break;
    806 
    807             case G_TESTER_CLI_CMD_POWER__SET_POWERSAVE_POWERLEVEL:
    808                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    809                 cmd_set_PowerSave_PowerLevel(parms, 1);
    810                 break;
    811 
    812             case G_TESTER_CLI_CMD_POWER__TRAFFIC_THRESHOLDS:
    813                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    814                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    815                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    816                 cmd_traffic_intensity_threshold(parms, 3);
    817                 break;
    818 
    819             case G_TESTER_CLI_CMD_POWER__ENABLE:
    820                 cmd_enable_traffic_events(NULL, 0);
    821                 break;
    822 
    823             case G_TESTER_CLI_CMD_POWER__DISABLE:
    824                 cmd_disable_traffic_events(NULL, 0);
    825                 break;
    826 
    827             case G_TESTER_CLI_CMD_EVENTS__REGISTER:
    828                 /* Register Event */
    829                 g_tester_register_event(input_string[5] | (input_string[6] << 8));
    830                 break;
    831 
    832             case G_TESTER_CLI_CMD_EVENTS__UNREGISTER:
    833                 /* Unregister Event */
    834                 g_tester_unregister_event(input_string[5] | (input_string[6] << 8));
    835                 break;
    836 
    837 #ifdef TI_DBG
    838 
    839             case G_TESTER_CLI_CMD_FILE__LOAD:
    840                 parms[0].value = (U32)(data_string);
    841                 parms_num =(strlen((char*)parms[0].value) == 0)?0:1;
    842                 cmd_file_load(parms, parms_num);
    843                 break;
    844 
    845             case G_TESTER_CLI_CMD_BT_COEXSISTANCE__ENABLE:
    846                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    847                 cmd_bt_coe_enable(parms, 1);
    848                 break;
    849 
    850             case G_TESTER_CLI_CMD_BT_COEXSISTANCE__RATE:
    851                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    852                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    853                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    854                 P_BUFFER_GET_UINT32(data_string, parms[3].value);
    855                 P_BUFFER_GET_UINT32(data_string, parms[4].value);
    856                 P_BUFFER_GET_UINT32(data_string, parms[5].value);
    857                 P_BUFFER_GET_UINT32(data_string, parms[6].value);
    858                 P_BUFFER_GET_UINT32(data_string, parms[7].value);
    859                 cmd_bt_coe_rate(parms, 8);
    860                 break;
    861 
    862             case G_TESTER_CLI_CMD_BT_COEXSISTANCE__CONFIG:
    863 				cmd_Scan_app_clear(NULL, 0);
    864 				 g_tester_scAn__configApp__Display();
    865                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    866                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    867                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
    868                 P_BUFFER_GET_UINT32(data_string, parms[3].value);
    869                 P_BUFFER_GET_UINT32(data_string, parms[4].value);
    870                 P_BUFFER_GET_UINT32(data_string, parms[5].value);
    871                 P_BUFFER_GET_UINT32(data_string, parms[6].value);
    872                 P_BUFFER_GET_UINT32(data_string, parms[7].value);
    873                 P_BUFFER_GET_UINT32(data_string, parms[8].value);
    874                 P_BUFFER_GET_UINT32(data_string, parms[9].value);
    875                 P_BUFFER_GET_UINT32(data_string, parms[10].value);
    876                 P_BUFFER_GET_UINT32(data_string, parms[11].value);
    877                 P_BUFFER_GET_UINT32(data_string, parms[12].value);
    878                 P_BUFFER_GET_UINT32(data_string, parms[13].value);
    879                 cmd_bt_coe_config(parms, 14);
    880                 break;
    881 
    882             case G_TESTER_CLI_CMD_BT_COEXSISTANCE__STATUS:
    883                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    884                 cmd_bt_coe_get_status(parms, 1);
    885                 break;
    886 
    887 #ifdef EXC_MODULE_INCLUDED
    888             case G_TESTER_CLI_CMD_MEASUREMENT__ENABLE:
    889                 cmd_Measurement_enable(NULL, 0);
    890                 break;
    891 
    892             case G_TESTER_CLI_CMD_MEASUREMENT__DISABLE:
    893                 cmd_Measurement_disable(NULL, 0);
    894                 break;
    895 
    896             case G_TESTER_CLI_CMD_MEASUREMENT__MAX_DURATION:
    897                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    898                 cmd_Measurement_setMaxDuration(parms, 1);
    899                 break;
    900 #endif
    901             case G_TESTER_CLI_CMD_REPORT__SET:
    902                 parms[0].value = (U32)(data_string);
    903                 parms_num =(strlen((char*)parms[0].value) == 0)?0:1;
    904                 cmd_report_set(parms, parms_num);
    905                 break;
    906 
    907             case G_TESTER_CLI_CMD_REPORT__ADD:
    908                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    909                 cmd_report_add(parms, 1);
    910                 break;
    911 
    912             case G_TESTER_CLI_CMD_REPORT__CLEAR:
    913                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    914                 cmd_report_clear(parms, 1);
    915                 break;
    916 
    917             case G_TESTER_CLI_CMD_REPORT__LEVEL:
    918                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    919                 cmd_report_severity_level(parms, 1);
    920                 break;
    921 
    922             case G_TESTER_CLI_CMD_DEBUG__REGISTER:
    923                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    924                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
    925                 cmd_hw_register(parms, 2);
    926                 break;
    927 
    928             case G_TESTER_CLI_CMD_DEBUG__PRINT:
    929                 g_tester_cmd_debug_driver_print(data_string);
    930                 break;
    931 
    932             case G_TESTER_CLI_CMD_DEBUG__BUFFER:
    933                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
    934                 data_string += 9; /* seek to the end of the string */
    935                 parms[1].value = (U32)(data_string);
    936                 parms_num =(strlen((char*)parms[1].value) == 0)?1:2;
    937                 cmd_debug_buffer_put(parms, parms_num);
    938                 break;
    939 
    940             case G_TESTER_CLI_CMD_ROOT__ABOUT:
    941                 /* Driver version */
    942                 g_tester_cmd_get_version();
    943                 break;
    944 
    945             case G_TESTER_CLI_CMD_ROOT__QUIT:
    946                 quit_func();
    947                 break;
    948 #endif
    949 
    950             case G_TESTER_CLI_CMD_PLT__REGISTER__READ:
    951                 {
    952                     UINT32 RegAddress;
    953                     P_BUFFER_GET_UINT32(data_string, RegAddress);
    954                     g_tester_cmd_plt_register_read(RegAddress);
    955                 }
    956                 break;
    957 
    958             case G_TESTER_CLI_CMD_PLT__REGISTER__WRITE:
    959                 {
    960                     tiUINT32 uiRegAddress;
    961                     tiUINT32 uiRegValue;
    962                     P_BUFFER_GET_UINT32(data_string, uiRegAddress);
    963                     P_BUFFER_GET_UINT32(data_string, uiRegValue);
    964                     TI_PLT_WriteRegister(g_id_adapter, uiRegAddress, uiRegValue);
    965                 }
    966                 break;
    967 
    968             case G_TESTER_CLI_CMD_PLT_RADIO_TUNE:
    969                 {
    970                     UINT32 status;
    971                     TestCmdChannelBand_t ChannelBand;
    972                     tiUINT8 return_buffer[3];
    973                     tiUINT8 *p_return_buffer = return_buffer;
    974 
    975                     P_BUFFER_GET_UINT32(data_string, ChannelBand.band);
    976                     P_BUFFER_GET_UINT32(data_string, ChannelBand.channel);
    977                     status = TI_PLT_RadioTune(g_id_adapter, &ChannelBand);
    978                     P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_PLT_RADIO_TUNE, (UINT8)status);
    979                     g_tester_send_to_host(return_buffer, 3);
    980                 }
    981                 break;
    982 
    983             case G_TESTER_CLI_CMD_PLT__RX_PER__START:
    984                 cmd_PLT_RxPerStart(NULL, 0);
    985                 break;
    986 
    987             case G_TESTER_CLI_CMD_PLT__RX_PER__STOP:
    988                 cmd_PLT_RxPerStop(NULL, 0);
    989                 break;
    990 
    991             case G_TESTER_CLI_CMD_PLT__RX_PER__CLEAR:
    992                 cmd_PLT_RxPerClear(NULL, 0);
    993                 break;
    994 
    995             case G_TESTER_CLI_CMD_PLT__RX_PER__GET_RESULTS:
    996                 g_tester_cmd_plt_RxPer_GetResults();
    997                 break;
    998 
    999             case G_TESTER_CLI_CMD_PLT__TX__CW:
   1000                 {
   1001                     tiUINT8 return_buffer[3];
   1002                     tiUINT8 *p_return_buffer = return_buffer;
   1003                     tiUINT32 status;
   1004                     TestCmdChannelBand_t PltTxCW;
   1005                     P_BUFFER_GET_UINT32(data_string, PltTxCW.band);
   1006                     P_BUFFER_GET_UINT32(data_string, PltTxCW.channel);
   1007                     status = TI_PLT_TxCW(g_id_adapter, &PltTxCW);
   1008                     P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_PLT__TX__CW, (UINT8)status);
   1009                     g_tester_send_to_host(return_buffer, 3);
   1010                 }
   1011                 break;
   1012 
   1013             case G_TESTER_CLI_CMD_PLT__TX__CONTINUES:
   1014                 {
   1015 
   1016                     PltTxContinues_t PltTxContinues;
   1017                     P_BUFFER_GET_UINT8(data_string, PltTxContinues.band);
   1018                     P_BUFFER_GET_UINT8(data_string, PltTxContinues.chID);
   1019                     P_BUFFER_GET_UINT8(data_string, PltTxContinues.rate);
   1020                     P_BUFFER_GET_UINT8(data_string, PltTxContinues.preamble);
   1021                     P_BUFFER_GET_UINT8(data_string, PltTxContinues.InterPacketDelay);
   1022                     P_BUFFER_GET_UINT8(data_string, PltTxContinues.NumOfFrames);
   1023                     P_BUFFER_GET_UINT8(data_string, PltTxContinues.mode);
   1024 
   1025                     TI_PLT_TxContiues(g_id_adapter, &PltTxContinues);
   1026 
   1027                     if (OK == TI_PLT_TxContiues(g_id_adapter, &PltTxContinues))
   1028                         console_printf_terminal("PltTxContinues (band=%d, chID=%d, rate=%d, preamble=%d, InterPacketDelay=%d, NumOfFrames=%d, mode=0x%x)- OK\n",
   1029                         PltTxContinues.band,
   1030                         PltTxContinues.chID,
   1031                         PltTxContinues.rate,
   1032                         PltTxContinues.preamble,
   1033                         PltTxContinues.InterPacketDelay,
   1034                         PltTxContinues.NumOfFrames,
   1035                         PltTxContinues.mode);
   1036                     else
   1037                         console_printf_terminal("PltTxContinues - NOK\n");
   1038                 }
   1039                 break;
   1040 
   1041             case G_TESTER_CLI_CMD_PLT__TX__STOP:
   1042                 cmd_PLT_TxStop(NULL, 0);
   1043                 break;
   1044 
   1045             case G_TESTER_CLI_CMD_PLT__MIB__READ:
   1046                 g_tester_cmd_plt_mib_read(data_string);
   1047                 break;
   1048 
   1049             case G_TESTER_CLI_CMD_PLT__MIB__WRITE:
   1050                 g_tester_cmd_plt_mib_write(data_string);
   1051                 break;
   1052 
   1053             case G_TESTER_CLI_CMD_PRIVACY__WEP__GET:
   1054                 g_tester_cmd_get_defaultWEPKey();
   1055                 break;
   1056 
   1057             case G_TESTER_CLI_CMD_PLT__CALIBRATION__RX:
   1058                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
   1059                 P_BUFFER_GET_UINT32(data_string, parms[1].value);
   1060                 P_BUFFER_GET_UINT32(data_string, parms[2].value);
   1061                 P_BUFFER_GET_UINT32(data_string, parms[3].value);
   1062                 P_BUFFER_GET_UINT32(data_string, parms[4].value);
   1063                 cmd_PLT_RxCal(parms, 5);
   1064                 break;
   1065 
   1066             case G_TESTER_CLI_CMD_PLT__CALIBRATION__TX__START:
   1067 				P_BUFFER_GET_UINT8(data_string, parms[0].value);
   1068                 cmd_PLT_TxCalStart(parms, 1);
   1069                 break;
   1070 
   1071             case G_TESTER_CLI_CMD_PLT__CALIBRATION__TX__STOP:
   1072                 cmd_PLT_TxCalStop(NULL, 0);
   1073                 break;
   1074 
   1075             case G_TESTER_CLI_CMD_PLT__CALIBRATION__TX__GAIN_GET:
   1076                 {
   1077                     tiUINT8 return_buffer[10];
   1078                     tiUINT8 *p_return_buffer = return_buffer;
   1079 
   1080                     UINT32 status;
   1081                     PltGainGet_t PLTGainGet;
   1082                     status = TI_PLT_TxCalGainGet(g_id_adapter, &PLTGainGet);
   1083                     P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_PLT__CALIBRATION__TX__GAIN_GET, (UINT8)status);
   1084                     if (status == OK)
   1085                     {
   1086                         P_BUFFER_ADD_UINT8(p_return_buffer, PLTGainGet.TxGain);
   1087                         P_BUFFER_ADD_UINT8(p_return_buffer, PLTGainGet.TxUpperBound);
   1088                         P_BUFFER_ADD_UINT8(p_return_buffer, PLTGainGet.TxLowerBound);
   1089                     }
   1090                     g_tester_send_to_host(return_buffer, p_return_buffer-return_buffer);
   1091                 }
   1092                 break;
   1093 
   1094             case G_TESTER_CLI_CMD_PLT__CALIBRATION__TX__GAIN_ADJUST:
   1095                 P_BUFFER_GET_UINT32(data_string, parms[0].value);
   1096                 cmd_PLT_TxCalGainAdjust(parms, 1);
   1097                 break;
   1098 
   1099             case G_TESTER_CLI_CMD_PLT__CALIBRATION__GET_NVS_BUFFER:
   1100                 g_tester_plt_calibration_get_nvs_buffer();
   1101                 break;
   1102 
   1103             default:
   1104                 console_printf_terminal("g_tester - unsupported command!\n");
   1105                 break;
   1106             }
   1107         }
   1108 
   1109         return_value = TRUE;
   1110     }
   1111 
   1112     return return_value;
   1113 }
   1114 
   1115 /************************************************************************
   1116 *                        g_tester_process_general_cmd_run_cmd          *
   1117 ************************************************************************
   1118 DESCRIPTION:
   1119 
   1120   CONTEXT    : main process only!
   1121   ************************************************************************/
   1122   void g_tester_process_general_cmd_run_cmd(unsigned char *cmd_buffer)
   1123   {
   1124       tiUINT8 return_buffer[5];
   1125       tiUINT8 *p_return_buffer = return_buffer;
   1126       tiUINT16 return_value;
   1127 
   1128       console_printf_terminal("g_tester - Executing cmd line: %s\n", cmd_buffer);
   1129 
   1130       return_value = (tiUINT16)system((const char*)cmd_buffer);
   1131 
   1132       console_printf_terminal("g_tester - Execution result: 0x%x\n", return_value);
   1133 
   1134       /* Set the header */
   1135       P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_GENERAL_CMD_RUN_CMD, (UINT8)0x00);
   1136 
   1137       /* Add the result */
   1138       P_BUFFER_ADD_UINT16(p_return_buffer, return_value);
   1139 
   1140       g_tester_send_to_host(return_buffer, 5);
   1141   }
   1142 
   1143   /************************************************************************
   1144   *                        g_tester_process_get_init_table	            *
   1145   ************************************************************************
   1146   DESCRIPTION:
   1147 
   1148     CONTEXT    : main process only!
   1149   ************************************************************************/
   1150   void g_tester_process_get_init_table(unsigned char *cmd_buffer)
   1151   {
   1152       UINT8 buffer[(1024 * 5)];
   1153       UINT8 *p_return_buffer = buffer;
   1154       UINT32 length;
   1155 
   1156       UINT8 init_table_file_name_length = *(cmd_buffer + 0);
   1157       unsigned char *init_table_file_name = (cmd_buffer + 1);
   1158 
   1159       UINT8 error_code = G_TESTER_GWSI_GET_INIT_TABLE_NO_ERROR;
   1160 
   1161       int FileDescriptor;
   1162 
   1163       if (init_table_file_name_length == 0)
   1164       {
   1165           console_printf_terminal("g_tester, g_tester_process_get_init_table, Error - no file name!\n");
   1166 
   1167           error_code = G_TESTER_GWSI_GET_INIT_TABLE_ERROR_NO_FILE_NAME;
   1168       }
   1169       else
   1170       {
   1171           /* Get the Init buffer from the driver */
   1172           TI_GWSIGetInitTable(g_id_adapter, (tiUINT32 *)&buffer[0]);
   1173 
   1174           /* The first 4 bytes are the buffer length */
   1175           length = *(UINT32 *)&buffer[0];
   1176 
   1177           if (length > 0)
   1178           {
   1179               FileDescriptor = open((const char*)init_table_file_name, O_CREAT | O_WRONLY);
   1180 
   1181               if (FileDescriptor != -1)
   1182               {
   1183                   if (write(FileDescriptor, buffer, length + sizeof(UINT32) ) != length + sizeof(UINT32))
   1184                   {
   1185                       console_printf_terminal("g_tester, g_tester_process_get_init_table, Error writing to file (%d)\n", errno);
   1186 
   1187                       error_code = G_TESTER_GWSI_GET_INIT_TABLE_ERROR_WRITING_TO_FILE;
   1188                   }
   1189                   else
   1190                   {
   1191                       console_printf_terminal("g_tester, g_tester_process_get_init_table, Written 0x%x bytes to %s\n\n", (length - 4), init_table_file_name);
   1192                   }
   1193 
   1194                   close(FileDescriptor);
   1195               }
   1196               else
   1197               {
   1198                   console_printf_terminal("g_tester, g_tester_process_get_init_table, Error creating %s (%d)\n", init_table_file_name, errno);
   1199 
   1200                   error_code = G_TESTER_GWSI_GET_INIT_TABLE_ERROR_CREATING_FILE;
   1201               }
   1202           }
   1203           else
   1204           {
   1205               console_printf_terminal("g_tester, g_tester_process_get_init_table, Error - driver init table not availble!\n");
   1206 
   1207               error_code = G_TESTER_GWSI_GET_INIT_TABLE_ERROR_TABLE_NOT_AVAIL;
   1208           }
   1209       }
   1210 
   1211       /* Set the header */
   1212       P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_GENERAL_CMD_GET_INIT_T, error_code);
   1213 
   1214       g_tester_send_to_host(buffer, 3);
   1215   }
   1216 
   1217   /************************************************************************
   1218   *                        g_tester_cmd_status                           *
   1219   ************************************************************************
   1220   DESCRIPTION:
   1221 
   1222     CONTEXT    : main process only!
   1223   ************************************************************************/
   1224   void g_tester_cmd_status()
   1225   {
   1226   /***************************
   1227   Return buffer structure
   1228 
   1229     Bytes 0-1  : OpCode (0x0003)
   1230     Byte  2	   : Command Status
   1231     Byte  3	   : Status (0/1/2)
   1232     Bytes 4-9  : MAC Address
   1233     Byte  10   : SSID length
   1234     Bytes 11-42: SSID
   1235     Bytes 43-48: BSSID
   1236     Byte  49:  : Channel
   1237       ***************************/
   1238 
   1239       tiUINT8 return_buffer[50];
   1240       tiUINT8 *p_return_buffer = return_buffer;
   1241 
   1242       tiINT32 res;
   1243       tiUINT32 data;
   1244       OS_802_11_BSSID_EX	bssid_ex;
   1245       OS_802_11_MAC_ADDRESS mac_address;
   1246       OS_802_11_SSID ssid;
   1247 
   1248       /* Set the header to dummy values */
   1249       P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_DRIVER__STATUS, 0x00);
   1250 
   1251       /* Get the Driver status (Running / Stop) */
   1252       res = TI_WLAN_IsDriverRun(g_id_adapter, (tiBOOL *)&data);
   1253 
   1254       if (res == 0)
   1255       {
   1256           /* Insert the status to the return buffer */
   1257           P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)data);
   1258 
   1259           /* Get the MAC address */
   1260           res = TI_GetCurrentAddress(g_id_adapter, &mac_address);
   1261 
   1262           if (res == 0)
   1263           {
   1264               P_BUFFER_ADD_DATA(p_return_buffer, &mac_address, sizeof(mac_address));
   1265 
   1266               /* Get the SSID */
   1267               res = TI_GetCurrentSSID(g_id_adapter, &ssid);
   1268 
   1269               if (res == 0)
   1270               {
   1271                   /* killme!!!*/
   1272                   /*if (isJunkSSID((void *)&ssid))*/
   1273                   /*{*/
   1274                   /* Put '0' at the length field */
   1275                   /*	ssid.SsidLength = 0;*/
   1276                   /*}*/
   1277 
   1278                   /* Add ssid length */
   1279                   P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)ssid.SsidLength);
   1280 
   1281                   /* Add ssid */
   1282                   P_BUFFER_ADD_DATA(p_return_buffer, ssid.Ssid, sizeof(ssid.Ssid));
   1283 
   1284                   /* Get the BSSID */
   1285                   res = TI_GetSelectedBSSIDInfo(g_id_adapter, &bssid_ex);
   1286 
   1287                   if (res == 0)
   1288                   {
   1289                       /* Add the BSSID */
   1290                       P_BUFFER_ADD_DATA(p_return_buffer, &bssid_ex.MacAddress, sizeof(bssid_ex.MacAddress));
   1291 
   1292                       /* Get the Channel */
   1293                       res = TI_GetCurrentChannel(g_id_adapter, &data);
   1294 
   1295                       if (res == 0)
   1296                       {
   1297                           /* Add channel */
   1298                           P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)data);
   1299                       }
   1300                   }
   1301               }
   1302           }
   1303       }
   1304 
   1305       p_return_buffer = return_buffer;
   1306 
   1307       /* Set the G_Tester result value */
   1308       res = (res == 0) ? G_TESTER_STATUS_OK : G_TESTER_STATUS_ERROR;
   1309 
   1310       /* Set the header */
   1311       P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_DRIVER__STATUS, (UINT8)res);
   1312 
   1313       g_tester_send_to_host(return_buffer, 50);
   1314   }
   1315 
   1316   /************************************************************************
   1317   *                        g_tester_cmd_status                           *
   1318   ************************************************************************
   1319   DESCRIPTION:
   1320 
   1321     CONTEXT    : main process only!
   1322   ************************************************************************/
   1323   void g_tester_bssid_list()
   1324   {
   1325   /***************************
   1326   Return buffer structure (for header):
   1327 
   1328     Bytes 0-1  : OpCode (0x0004)
   1329     Byte  2	   : Command Status
   1330     Byte  3	   : Number of elements
   1331       ***************************/
   1332 
   1333       /***************************
   1334       Return buffer structure (for each element):
   1335 
   1336         Bytes 0-1	: OpCode (0x0005)
   1337         Byte  2	   :  Command Status
   1338         Bytes 3-8   : MAC Address
   1339         Byte  9     : Privacy
   1340         Bytes 10-13 : RSSI
   1341         Byte  14    : Infra mode
   1342         Byte  15    : Channel
   1343         Bytes 16-19 : Qos
   1344         Byte  20	: SSID length
   1345         Bytes 21-52 : SSID
   1346       ***************************/
   1347 
   1348       tiUINT8 return_buffer[55];
   1349       tiUINT8 *p_return_buffer = return_buffer;
   1350 
   1351       OS_802_11_BSSID_LIST_EX *list;/* = (OS_802_11_BSSID_LIST_EX *) data; */
   1352       OS_802_11_BSSID_EX *bssid;
   1353       tiUINT32 number_items;
   1354       tiINT32 res;
   1355       tiUINT8 index;
   1356       tiUINT32 Qos = 0;
   1357 
   1358       console_printf_terminal("g_tester,  g_tester_bssid_list()\n");
   1359 
   1360       res = TI_GetBSSIDList(g_id_adapter, &list);
   1361       if( res || !list )
   1362       {
   1363           /*************************/
   1364           /* Error retrieving data */
   1365           /***********************/
   1366 
   1367           /* Set the header */
   1368           P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_CONNECTION__BSSID_LIST, G_TESTER_STATUS_ERROR);
   1369 
   1370           /* Set dummy UINT8 */
   1371           P_BUFFER_ADD_UINT8(p_return_buffer, 0x00);
   1372 
   1373           g_tester_send_to_host(return_buffer, 4);
   1374       }
   1375       else
   1376       {
   1377           bssid = &list->Bssid[0];
   1378           number_items = list->NumberOfItems;
   1379 
   1380           /*********************/
   1381           /* Header structure */
   1382           /*******************/
   1383 
   1384           /* Set the header */
   1385           P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_CONNECTION__BSSID_LIST, G_TESTER_STATUS_OK);
   1386 
   1387           /* Set dummy UINT8 */
   1388           P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)number_items);
   1389 
   1390           g_tester_send_to_host(return_buffer, 4);
   1391 
   1392           /***********************/
   1393           /* Elements structure */
   1394           /*********************/
   1395 
   1396           for (index = 0; index < number_items; index++)
   1397           {
   1398               p_return_buffer = return_buffer;
   1399 
   1400               /* Set the header */
   1401               P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, (G_TESTER_CLI_CMD_CONNECTION__BSSID_LIST + 1), G_TESTER_STATUS_OK);
   1402 
   1403               P_BUFFER_ADD_DATA(p_return_buffer, bssid->MacAddress, sizeof(bssid->MacAddress));
   1404 
   1405               P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)bssid->Privacy);
   1406 
   1407               P_BUFFER_ADD_UINT32(p_return_buffer, bssid->Rssi);
   1408 
   1409               P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)bssid->InfrastructureMode);
   1410 
   1411               P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)Freq2Chan(bssid->Configuration.Union.channel));
   1412 
   1413               Qos = parseBssidIe(bssid);
   1414               P_BUFFER_ADD_UINT32(p_return_buffer, (tiUINT32)Qos);
   1415 
   1416               P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)bssid->Ssid.SsidLength);
   1417 
   1418               P_BUFFER_ADD_DATA(p_return_buffer, bssid->Ssid.Ssid, sizeof(bssid->Ssid.Ssid));
   1419 
   1420               g_tester_send_to_host(return_buffer, 53);
   1421 
   1422               /* Move to the next bssid */
   1423               bssid = (OS_802_11_BSSID_EX *) (((char *) bssid) + bssid->Length);
   1424           }
   1425 
   1426           free(list);
   1427       }
   1428 }
   1429 
   1430 /************************************************************************
   1431 *                        g_tester_register_event                       *
   1432 ************************************************************************
   1433 DESCRIPTION:
   1434 
   1435   CONTEXT    :
   1436   ************************************************************************/
   1437   void g_tester_register_event(tiUINT16 event_mask)
   1438   {
   1439       int index;
   1440       ConParm_t param;
   1441 
   1442       console_printf_terminal("g_tester,  g_tester_register_event (Mask = 0x%x)\n", event_mask);
   1443 
   1444       /* Go over the mask bits */
   1445       for (index = 0; index < 16; index++)
   1446       {
   1447           if ((event_mask & (1 << index)) != (tiUINT16)0x0000)
   1448           {
   1449               param.value = index;
   1450               cmd_events_register(&param, 1);
   1451           }
   1452       }
   1453   }
   1454 
   1455   /************************************************************************
   1456   *                        g_tester_unregister_event                     *
   1457   ************************************************************************
   1458   DESCRIPTION:
   1459 
   1460     CONTEXT    :
   1461   ************************************************************************/
   1462   void g_tester_unregister_event(tiUINT16 event_mask)
   1463   {
   1464       int index;
   1465       ConParm_t param;
   1466 
   1467       console_printf_terminal("g_tester,  g_tester_unregister_event (Mask = 0x%x)\n", event_mask);
   1468 
   1469       /* Go over the mask bits */
   1470       for (index = 0; index < 16; index++)
   1471       {
   1472           if ((event_mask & (1 << index)) != (tiUINT16)0x0000)
   1473           {
   1474               param.value = index;
   1475               cmd_events_unregister(&param, 1);
   1476           }
   1477       }
   1478   }
   1479 
   1480   /************************************************************************
   1481   *                        g_tester_cmd_debug_driver_print               *
   1482   ************************************************************************
   1483   DESCRIPTION:
   1484 
   1485     CONTEXT    :
   1486   ************************************************************************/
   1487   void g_tester_cmd_debug_driver_print(unsigned char *cmd_buffer)
   1488   {
   1489 #ifdef TI_DBG
   1490 
   1491       tiUINT32 *buf = (tiUINT32 *)cmd_buffer;
   1492 
   1493       ConParm_t param[2];
   1494 
   1495       param[0].value = buf[0];
   1496       param[1].value = buf[1];
   1497 
   1498       console_printf_terminal("DEBUG: values: (0x%x, 0x%x)\n", param[0].value, param[1].value);
   1499 
   1500       cmd_debug_driver_print((ConParm_t *)&param, 2);
   1501 
   1502 #endif
   1503   }
   1504 
   1505   /************************************************************************
   1506   *                        g_tester_receive_event                        *
   1507   ************************************************************************
   1508   DESCRIPTION:
   1509 
   1510     CONTEXT    :
   1511   ************************************************************************/
   1512   void g_tester_receive_event(unsigned char event_index)
   1513   {
   1514   /***************************
   1515   Return buffer structure :
   1516 
   1517     Bytes 0-1  : OpCode (0x1050)
   1518     Byte  2	   : Command Status
   1519     Byte  3	   : Event ID
   1520       ***************************/
   1521 
   1522       tiUINT8 return_buffer[55];
   1523       tiUINT8 *p_return_buffer = return_buffer;
   1524 
   1525       /* Set the header */
   1526       P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, 0x1050, G_TESTER_STATUS_OK);
   1527 
   1528       /* Set event index */
   1529       P_BUFFER_ADD_UINT8(p_return_buffer, event_index);
   1530 
   1531       g_tester_send_to_host(return_buffer, 4);
   1532   }
   1533 
   1534   /************************************************************************
   1535   *                        g_tester_send_received_event                  *
   1536   ************************************************************************
   1537   DESCRIPTION:
   1538 
   1539     CONTEXT    :
   1540   ************************************************************************/
   1541   void g_tester_send_received_event(unsigned int cmd_op, tiUINT8 status)
   1542   {
   1543   /***************************
   1544   Return buffer structure :
   1545 
   1546     Bytes 0-1  : OpCode (0xFFFF)
   1547     Byte  2-3  : Command Opcode
   1548       ***************************/
   1549 
   1550       tiUINT8 return_buffer[5];
   1551       tiUINT8 *p_return_buffer = return_buffer;
   1552 
   1553       /* Add the event opcode */
   1554       P_BUFFER_ADD_UINT16(p_return_buffer, 0x1000);
   1555 
   1556       /* Add the command opcode */
   1557       P_BUFFER_ADD_UINT16(p_return_buffer, cmd_op);
   1558 
   1559       /* Add the command opcode */
   1560       P_BUFFER_ADD_UINT8(p_return_buffer, status);
   1561 
   1562       g_tester_send_to_host(return_buffer, 5);
   1563   }
   1564 
   1565   /************************************************************************
   1566   *                        g_tester_process_gwsi_init_cmd                *
   1567   ************************************************************************
   1568   DESCRIPTION:
   1569 
   1570     CONTEXT    :
   1571   ************************************************************************/
   1572   void g_tester_process_gwsi_init_cmd(unsigned char *cmd_buffer)
   1573   {
   1574       char *firmware_file_name;
   1575       unsigned char firmware_file_name_length;
   1576       char *e2prom_file_name;
   1577       unsigned char e2prom_file_name_length;
   1578 
   1579       unsigned char *init_buffer = NULL;
   1580       UINT32 init_buffer_size;
   1581 
   1582       unsigned char host_event_buffer[3];
   1583       unsigned char *p_host_event_buffer = host_event_buffer;
   1584 
   1585       FILE *firmware_file = NULL;
   1586       FILE *e2prom_file = NULL;
   1587       UINT32 firmware_image_length = 0;
   1588       UINT32 e2prom_image_length = 0;
   1589 
   1590       unsigned char error_code = G_TESTER_GWSI_INIT_NO_ERROR;
   1591 
   1592       /* Prepare the parameters */
   1593       firmware_file_name_length = *(cmd_buffer + 0);
   1594       firmware_file_name = (char*)(cmd_buffer + 1);
   1595       e2prom_file_name_length = *(cmd_buffer + firmware_file_name_length + 2);
   1596       e2prom_file_name = (char*)(cmd_buffer + firmware_file_name_length + 3);
   1597 
   1598       console_printf_terminal("g_tester, DEBUG:0x%x, 0x%x!\n", firmware_image_length, e2prom_file_name_length);
   1599 
   1600       /***************************/
   1601       /* Open the firmware file */
   1602       /*************************/
   1603 
   1604       if ((firmware_file = fopen(firmware_file_name, "r")) != NULL)
   1605       {
   1606           /* Get firmware file length */
   1607           if (fseek(firmware_file, 0, SEEK_END) == 0)
   1608           {
   1609               firmware_image_length = ftell(firmware_file);
   1610               rewind(firmware_file);
   1611 
   1612               console_printf_terminal("g_tester, GWSI Init, Firmeware image file is %s, size = 0x%x!\n", firmware_file_name, firmware_image_length);
   1613           }
   1614           else
   1615           {
   1616               console_printf_terminal("g_tester, Error retriving firmware file length!\n");
   1617 
   1618               error_code = G_TESTER_GWSI_INIT_ERROR_READING_FW_FILE_LENGTH;
   1619           }
   1620       }
   1621       else
   1622       {
   1623           console_printf_terminal("g_tester, Error opening firmware file!\n");
   1624 
   1625           error_code = G_TESTER_GWSI_INIT_ERROR_OPENING_FW_FILE;
   1626       }
   1627 
   1628       /*************************/
   1629       /* Open the e2prom file */
   1630       /***********************/
   1631 
   1632       console_printf_terminal("DEBUG The length is : %d\n", e2prom_file_name_length);
   1633 
   1634       if ((error_code == G_TESTER_GWSI_INIT_NO_ERROR) && (e2prom_file_name_length > 0))
   1635       {
   1636           /* Open the e2prom file */
   1637           if ((e2prom_file = fopen(e2prom_file_name, "r")) != NULL)
   1638           {
   1639               /* Get firmware file length */
   1640               if (fseek(e2prom_file, 0, SEEK_END) == 0)
   1641               {
   1642                   e2prom_image_length = ftell(e2prom_file);
   1643                   rewind(e2prom_file);
   1644 
   1645                   console_printf_terminal("g_tester, GWSI Init, E2prom image file is %s, size = 0x%x!\n", e2prom_file_name, e2prom_image_length);
   1646               }
   1647               else
   1648               {
   1649                   console_printf_terminal("g_tester, Error retrieving e2prom file length!\n");
   1650 
   1651                   error_code = G_TESTER_GWSI_INIT_ERROR_READING_EP_FILE_LENGTH;
   1652               }
   1653           }
   1654           else
   1655           {
   1656               console_printf_terminal("g_tester, Error opening e2prom file!\n");
   1657 
   1658               error_code = G_TESTER_GWSI_INIT_ERROR_OPENING_EP_FILE;
   1659           }
   1660       }
   1661 
   1662       /****************************/
   1663       /* Prepare the init struct */
   1664       /**************************/
   1665 
   1666       if (error_code == G_TESTER_GWSI_INIT_NO_ERROR)
   1667       {
   1668           init_buffer_size = 16 + firmware_image_length + e2prom_image_length;
   1669 
   1670           init_buffer = malloc(init_buffer_size);
   1671 
   1672           if (init_buffer != NULL)
   1673           {
   1674               /* Set the GWSI tester command parameters */
   1675               P_BUFFER_ADD_UINT16(init_buffer, G_TESTER_GWSI_CMD_INITIALIZE);	/* Opcode */
   1676               P_BUFFER_ADD_UINT32(init_buffer, init_buffer_size);				/* Length */
   1677               P_BUFFER_ADD_UINT16(init_buffer, 0x0000);							/* Align bytes*/
   1678               P_BUFFER_ADD_UINT32(init_buffer, firmware_image_length);
   1679               P_BUFFER_ADD_UINT32(init_buffer, e2prom_image_length);
   1680 
   1681               init_buffer -= (16);
   1682 
   1683               /* Read the firmware image */
   1684               if (fread(init_buffer + (16), 1, firmware_image_length, firmware_file) == firmware_image_length)
   1685               {
   1686                   if (e2prom_image_length)
   1687                   {
   1688                       /* Read the e2prom image */
   1689                       if (fread(init_buffer + (16) + firmware_image_length, 1, e2prom_image_length, e2prom_file) != e2prom_image_length)
   1690                       {
   1691                           console_printf_terminal("g_tester, GWSI Init, Error reading e2prom image!\n");
   1692 
   1693                           error_code = G_TESTER_GWSI_INIT_ERROR_READING_EP_FILE;
   1694                       }
   1695                   }
   1696 
   1697                   if (error_code == G_TESTER_GWSI_INIT_NO_ERROR)
   1698                   {
   1699                       console_printf_terminal("g_tester, GWSI Init, Sending command to driver (size = 0x%x)!\n", init_buffer_size);
   1700 
   1701                       /* Send the command */
   1702                       TI_GWSIInitialize(g_id_adapter, (tiUINT32 *)init_buffer);
   1703                   }
   1704               }
   1705               else
   1706               {
   1707                   console_printf_terminal("g_tester, GWSI Init, Error reading firmware image!\n");
   1708 
   1709                   error_code = G_TESTER_GWSI_INIT_ERROR_READING_FW_FILE;
   1710               }
   1711           }
   1712           else
   1713           {
   1714               console_printf_terminal("g_tester, GWSI Init, Error allocating memory for init buffer!\n");
   1715 
   1716               error_code = G_TESTER_GWSI_INIT_ERROR_ALLOCATION_MEMORY;
   1717           }
   1718       }
   1719 
   1720       /************************************/
   1721       /* Fall-back -> free all resources */
   1722       /**********************************/
   1723 
   1724       if (firmware_file)
   1725       {
   1726           fclose(firmware_file);
   1727       }
   1728 
   1729       if (e2prom_file)
   1730       {
   1731           fclose(e2prom_file);
   1732       }
   1733 
   1734       if (init_buffer)
   1735       {
   1736           free(init_buffer);
   1737       }
   1738 
   1739       /****************************/
   1740       /* Send result to the host */
   1741       /**************************/
   1742 
   1743       if (error_code != G_TESTER_GWSI_INIT_NO_ERROR)
   1744       {
   1745           /*************************************************/
   1746           /* Send event with error indication to the host */
   1747           /***********************************************/
   1748 
   1749           P_BUFFER_ADD_HDR_PARAMS(p_host_event_buffer, G_TESTER_GWSI_CMD_INITIALIZE, error_code);
   1750 
   1751           g_tester_send_to_host(host_event_buffer, 3);
   1752       }
   1753 }
   1754 
   1755 /************************************************************************
   1756 *                        g_tester_process_gwsi_config_cmd              *
   1757 ************************************************************************
   1758 DESCRIPTION:
   1759 
   1760   CONTEXT    :
   1761   ************************************************************************/
   1762   void g_tester_process_gwsi_config_cmd(unsigned char *cmd_buffer)
   1763   {
   1764       char *init_file_name;
   1765       unsigned char init_file_name_length;
   1766 
   1767       unsigned char host_event_buffer[3];
   1768       unsigned char *p_host_event_buffer = host_event_buffer;
   1769 
   1770       int init_file_descriptor;
   1771       struct stat file_status_record;
   1772 
   1773       UINT8 *buffer = NULL;
   1774 
   1775       UINT8 error_code = G_TESTER_GWSI_CONFIG_NO_ERROR;
   1776 
   1777       /* Prepare the parameters */
   1778       init_file_name_length = *(cmd_buffer + 0);
   1779       init_file_name = (char*)(cmd_buffer + 1);
   1780 
   1781       init_file_descriptor = open(init_file_name, O_RDONLY);
   1782 
   1783       if (init_file_descriptor != -1)
   1784       {
   1785           if (fstat(init_file_descriptor, &file_status_record) != -1)
   1786           {
   1787               buffer = malloc(file_status_record.st_size + (sizeof(UINT16) * 2));
   1788 
   1789               if (buffer != NULL)
   1790               {
   1791                   int temp;
   1792                   if ((temp = read(init_file_descriptor, buffer + (sizeof(UINT16) * 2), file_status_record.st_size)) == file_status_record.st_size)
   1793                   {
   1794                       console_printf_terminal("g_tester, GWSI_Config, Sending config request to driver (file = %s, buffer size = 0x%x)\n", init_file_name, file_status_record.st_size + (sizeof(UINT16) * 2));
   1795 
   1796                       P_BUFFER_ADD_UINT16(buffer, G_TESTER_GWSI_CMD_CONFIG);
   1797                       P_BUFFER_ADD_UINT16(buffer, file_status_record.st_size);
   1798                       buffer -= (sizeof(UINT16) * 2);
   1799 
   1800                       /* Send the command to the driver */
   1801                       TI_GWSIConfig(g_id_adapter, (tiUINT32 *)buffer);
   1802                   }
   1803                   else
   1804                   {
   1805                       console_printf_terminal("g_tester, GWSI_Config, Error reading from file (%d)\n", errno);
   1806                       error_code = G_TESTER_GWSI_CONFIG_ERROR_READING_FILE;
   1807                   }
   1808               }
   1809               else
   1810               {
   1811                   console_printf_terminal("g_tester, GWSI_Config, Error allocating memory (%d)\n", errno);
   1812                   error_code = G_TESTER_GWSI_CONFIG_ERROR_ALLOCATING_MEMORY;
   1813               }
   1814           }
   1815           else
   1816           {
   1817               console_printf_terminal("g_tester, GWSI_Config, Error retriving file size (%d)\n", errno);
   1818               error_code = G_TESTER_GWSI_CONFIG_ERROR_GETIING_FILE_SIZE;
   1819           }
   1820       }
   1821       else
   1822       {
   1823           console_printf_terminal("g_tester, GWSI_Config, Error opening file (%d)\n", errno);
   1824           error_code = G_TESTER_GWSI_CONFIG_ERROR_OPENING_FILE;
   1825       }
   1826 
   1827       /*******************/
   1828       /* Free resources */
   1829       /*****************/
   1830 
   1831       if (init_file_descriptor != -1)
   1832       {
   1833           close(init_file_descriptor);
   1834       }
   1835 
   1836       if (buffer != NULL)
   1837       {
   1838           free(buffer);
   1839       }
   1840 
   1841       /****************************/
   1842       /* Send result to the host */
   1843       /**************************/
   1844 
   1845       if (error_code != G_TESTER_GWSI_CONFIG_NO_ERROR)
   1846       {
   1847           P_BUFFER_ADD_HDR_PARAMS(p_host_event_buffer, G_TESTER_GWSI_CMD_CONFIG, error_code);
   1848 
   1849           g_tester_send_to_host(host_event_buffer, 3);
   1850       }
   1851   }
   1852 
   1853   /************************************************************************
   1854   *                        g_tester_process_gwsi_release_cmd                     *
   1855   ************************************************************************
   1856   DESCRIPTION:
   1857 
   1858     CONTEXT    :
   1859   ************************************************************************/
   1860   void g_tester_process_gwsi_release_cmd(unsigned char *cmd_buffer)
   1861   {
   1862 
   1863       tiUINT8 return_buffer[2];
   1864       tiUINT8 *p_return_buffer = return_buffer;
   1865 
   1866       /* Add the event opcode */
   1867       P_BUFFER_ADD_UINT16(p_return_buffer, G_TESTER_GWSI_CMD_RELEASE);
   1868 
   1869       console_printf_terminal("g_tester, GWSI_Release, Sending release to driver.\n");
   1870 
   1871       /* Send the command to the driver */
   1872       TI_GWSIRelease(g_id_adapter, (tiUINT32 *)return_buffer);
   1873   }
   1874 
   1875 
   1876   /************************************************************************
   1877   *                        g_tester_process_gwsi_cmd                     *
   1878   ************************************************************************
   1879   DESCRIPTION:
   1880 
   1881     CONTEXT    :
   1882   ************************************************************************/
   1883   void g_tester_process_gwsi_cmd(unsigned char *cmd_buffer)
   1884   {
   1885       TI_GWSICommand(g_id_adapter, (tiUINT32 *)cmd_buffer);
   1886   }
   1887 
   1888   /************************************************************************
   1889   *                        g_tester_process_gwsi_cmd                     *
   1890   ************************************************************************
   1891   DESCRIPTION:
   1892 
   1893     CONTEXT    :
   1894   ************************************************************************/
   1895   void g_tester_cmd_get_version()
   1896   {
   1897   /***************************
   1898   Return buffer structure :
   1899 
   1900     Bytes 0-1  : OpCode (0x1050)
   1901     Byte  2	   : Command Status
   1902     Byte  3-6  : Driver Version
   1903     Byte  7-10 : FW Version
   1904     Byte  11-14: HW Version
   1905     Byte  15-18: NVM Version
   1906       ***************************/
   1907 
   1908       tiUINT32 ret;
   1909       tiUINT8 return_buffer[19];
   1910       tiUINT8 *p_return_buffer = return_buffer;
   1911 
   1912       TIWLN_VERSION_EX data;
   1913 
   1914       console_printf_terminal("g_tester,  g_tester_cmd_get_version.\n");
   1915 
   1916       ret = (tiUINT8)TI_GetDriverVersion(g_id_adapter, &data );
   1917 
   1918       if (ret == 0)
   1919       {
   1920           /* Set the header */
   1921           P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_ROOT__ABOUT, G_TESTER_STATUS_OK);
   1922 
   1923           /* ADD the versions */
   1924           P_BUFFER_ADD_UINT32(p_return_buffer, (UINT32)(*(UINT32 *)&data.DrvVersion));
   1925           P_BUFFER_ADD_UINT32(p_return_buffer, (UINT32)(*(UINT32 *)&data.FWVersion));
   1926           P_BUFFER_ADD_UINT32(p_return_buffer, (UINT32)(*(UINT32 *)&data.HWVersion));
   1927           P_BUFFER_ADD_UINT32(p_return_buffer, (UINT32)(*(UINT32 *)&data.NVVersion));
   1928       }
   1929       else
   1930       {
   1931           /* Set the header */
   1932           P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_ROOT__ABOUT, G_TESTER_STATUS_ERROR);
   1933       }
   1934 
   1935       g_tester_send_to_host(return_buffer, 19);
   1936   }
   1937 
   1938 
   1939   /************************************************************************
   1940   *                        g_tester_get_advanced_statistics_report       *
   1941   ************************************************************************
   1942   DESCRIPTION:
   1943 
   1944     CONTEXT    :
   1945   ************************************************************************/
   1946   void g_tester_set_rate(tiUINT8 rate_index)
   1947   {
   1948       ConParm_t param;
   1949       char rate_1mbps_rate_str[5] = "1";
   1950       char rate_2mbps_rate_str[5] = "2";
   1951       char rate_5_5mbps_rate_str[5] = "5.5";
   1952       char rate_11mbps_rate_str[5] = "11";
   1953       char rate_22mbps_rate_str[5] = "22";
   1954 
   1955       switch(rate_index)
   1956       {
   1957       case 0:
   1958           param.value = (tiUINT32)rate_1mbps_rate_str;
   1959           break;
   1960 
   1961       case 1:
   1962           param.value = (tiUINT32)rate_2mbps_rate_str;
   1963           break;
   1964 
   1965       case 2:
   1966           param.value = (tiUINT32)rate_5_5mbps_rate_str;
   1967           break;
   1968 
   1969       case 3:
   1970           param.value = (tiUINT32)rate_11mbps_rate_str;
   1971           break;
   1972 
   1973       case 4:
   1974           param.value = (tiUINT32)rate_22mbps_rate_str;
   1975           break;
   1976 
   1977       default:
   1978           param.value = (tiUINT32)rate_1mbps_rate_str;
   1979           break;
   1980       }
   1981 
   1982       cmd_modify_rate(&param, 1);
   1983   }
   1984 
   1985   /************************************************************************
   1986   *                        g_tester_wep_add_key					        *
   1987   ************************************************************************
   1988   DESCRIPTION:
   1989 
   1990     CONTEXT    :
   1991   ************************************************************************/
   1992   void g_tester_wep_add_key(unsigned char *cmd_buffer)
   1993   {
   1994       UINT8 key_length;
   1995       UINT8 key_type;
   1996       ConParm_t key_params[4];
   1997       UINT8 hex_str[] = "hex";
   1998       UINT8 text_str[] = "text";
   1999 
   2000       /* Zero the variables (because i use 8 bit in 32 bit variables) */
   2001       key_params[1].value = 0;
   2002       key_params[2].value = 0;
   2003 
   2004       /* Read parameters */
   2005       key_length = cmd_buffer[65];		/* Buffer length */
   2006       key_type = cmd_buffer[68];			/* Key type (hex = 0, text = 1) */
   2007 
   2008       /* Prepare parameters for the command */
   2009       key_params[0].value = (tiUINT32)&cmd_buffer[0];
   2010       cmd_buffer[key_length] = 0;
   2011 
   2012       key_params[1].value = (tiUINT32)cmd_buffer[66];
   2013 
   2014       key_params[2].value = (tiUINT32)cmd_buffer[67];
   2015 
   2016       if (key_type == 0)
   2017       {
   2018           key_params[3].value = (tiUINT32)&hex_str[0];
   2019       }
   2020       else
   2021       {
   2022           key_params[3].value = (tiUINT32)&text_str[0];
   2023       }
   2024 
   2025       /* Call the addkey command */
   2026       cmd_privacy_addkey(&key_params[0], 4);
   2027   }
   2028 
   2029   /************************************************************************
   2030   *                        g_tester_gwsi_event_handler			        *
   2031   ************************************************************************
   2032   DESCRIPTION:
   2033 
   2034     CONTEXT    :
   2035   ************************************************************************/
   2036   int g_tester_gwsi_event_handler(IPC_EV_DATA* pData)
   2037   {
   2038       console_printf_terminal("g_tester,  g_tester_gwsi_event_handler. (Length = %d)\n", pData->uBufferSize);
   2039 
   2040       g_tester_send_to_host(pData->uBuffer, pData->uBufferSize);
   2041 
   2042       return 0;
   2043   }
   2044 
   2045   /************************************************************************
   2046   *                        g_tester_gwsi_event_handler                  *
   2047   ************************************************************************
   2048   DESCRIPTION: Read the register value and send it back by event.
   2049 
   2050   ************************************************************************/
   2051   void g_tester_cmd_plt_register_read(UINT32 uiRegAddress)
   2052   {
   2053   /***************************
   2054   Return buffer structure :
   2055 
   2056     Bytes 0-1  : OpCode (0x0173)
   2057     Byte  2    : Command Status
   2058     Byte  3-6  : Register value
   2059       ***************************/
   2060 
   2061       tiUINT8 return_buffer[19];
   2062       tiUINT8 *p_return_buffer = return_buffer;
   2063 
   2064       UINT32 uiRegisterValue;
   2065       tiUINT32 status = TI_PLT_ReadRegister(g_id_adapter, uiRegAddress, &uiRegisterValue);
   2066 
   2067       /* Set the header */
   2068       P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_PLT__REGISTER__READ, (UINT8)status);
   2069 
   2070       /* Add the result */
   2071       P_BUFFER_ADD_UINT32(p_return_buffer, uiRegisterValue);
   2072 
   2073       g_tester_send_to_host(return_buffer, 7);
   2074   }
   2075 
   2076   /************************************************************************
   2077   *                        g_tester_gwsi_event_handler                  *
   2078   ****** ******************************************************************
   2079   DESCRIPTION: Read the PLT RX PER .
   2080 
   2081   ************************************************************************/
   2082   void g_tester_cmd_plt_RxPer_GetResults()
   2083   {
   2084   /***************************
   2085   Return buffer structure :
   2086 
   2087     Bytes 0-1   : OpCode (0x0178)
   2088     Byte  2     : Command Status
   2089     Byte  3-6   : FCSErrorCount
   2090     Byte  7-10  : TotalFrameCount
   2091     Byte  11-14 : PLCPFrameCount
   2092     Byte  15-18 : SeqNumMissCount
   2093       ***************************/
   2094 
   2095       tiUINT8 return_buffer[20];
   2096       tiUINT8 *p_return_buffer = return_buffer;
   2097 
   2098       PltRxPer_t PltRxPer;
   2099       tiUINT32 status = TI_PLT_RxPerGetResults(g_id_adapter, &PltRxPer);
   2100 
   2101       /* Set the header */
   2102       P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_PLT__RX_PER__GET_RESULTS, (UINT8)status);
   2103 
   2104       /* Add the result */
   2105       P_BUFFER_ADD_UINT32(p_return_buffer, PltRxPer.FCSErrorCount);
   2106       P_BUFFER_ADD_UINT32(p_return_buffer, PltRxPer.TotalFrameCount);
   2107       P_BUFFER_ADD_UINT32(p_return_buffer, PltRxPer.PLCPErrorCount);
   2108       P_BUFFER_ADD_UINT32(p_return_buffer, PltRxPer.SeqNumMissCount);
   2109 
   2110       g_tester_send_to_host(return_buffer, p_return_buffer - return_buffer);
   2111   }
   2112 
   2113   /************************************************************************
   2114   *                        g_tester_cmd_plt_mib_read                  *
   2115   ****** ******************************************************************
   2116   DESCRIPTION: Handle the reading of PLT over CLI MIBs .
   2117 
   2118   ************************************************************************/
   2119   void g_tester_cmd_plt_mib_read(unsigned char *cmd_buffer)
   2120   {
   2121   /***************************
   2122   Return buffer structure :
   2123 
   2124     Bytes 0-1  : OpCode (0x017C)
   2125     Byte  2    : Command Status
   2126     Byte  3-6  : aMib
   2127     Byte  7-10 : Mib Length
   2128     Bye   11-  : MIb data
   2129       ***************************/
   2130 
   2131       PLT_MIB_t* pMib = (PLT_MIB_t*)cmd_buffer;
   2132 
   2133       unsigned char return_buffer[3 + sizeof(PLT_MIB_t)];
   2134       unsigned char* p_return_buffer = return_buffer;
   2135       unsigned char* pReturnMibBuffer = return_buffer + 3;
   2136       PLT_MIB_t* pReturnMib = (PLT_MIB_t*)pReturnMibBuffer;
   2137       tiUINT32 status;
   2138       int PacketLength;
   2139 
   2140       pReturnMib->aMib =  pMib->aMib;
   2141       pReturnMib->Length = pMib->Length;
   2142       memcpy(&pReturnMib->aData, &pMib->aData, pMib->Length);
   2143 
   2144       status = TI_PLT_ReadMIB(g_id_adapter, pReturnMib);
   2145 
   2146       /* Set the event header */
   2147       P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_PLT__MIB__READ, (UINT8)status);
   2148 
   2149       /* Set the MIB data */
   2150       PacketLength = 11 + pReturnMib->Length;
   2151       g_tester_send_to_host(return_buffer, PacketLength);
   2152   }
   2153 
   2154   /************************************************************************
   2155   *                        g_tester_cmd_plt_mib_write                  *
   2156   ****** ******************************************************************
   2157   DESCRIPTION: Handle the writing of PLT over CLI MIBs .
   2158 
   2159   ************************************************************************/
   2160   void g_tester_cmd_plt_mib_write(unsigned char *cmd_buffer)
   2161   {
   2162       PLT_MIB_t* pMib = (PLT_MIB_t*)cmd_buffer;
   2163       TI_PLT_WriteMIB(g_id_adapter, pMib);
   2164   }
   2165 
   2166 
   2167 
   2168 
   2169   /************************************************************************
   2170   *                        g_tester_cmd_get_defaultWEPKey                  *
   2171   ****** ******************************************************************
   2172   DESCRIPTION: Get back the default WEP key .
   2173 
   2174   ************************************************************************/
   2175   void g_tester_cmd_get_defaultWEPKey(void)
   2176   {
   2177   /***************************
   2178   Return buffer structure :
   2179 
   2180     Bytes 0-1  : OpCode (0x117e)
   2181     Byte  2    : Command Status
   2182     Byte  3-6  : Default WEP key ID
   2183       ***************************/
   2184 
   2185       tiUINT8 return_buffer[6];
   2186       tiUINT8 *p_return_buffer = return_buffer;
   2187       tiUINT32 WepKeyId;
   2188       tiUINT32 status = TI_GetDefaultWepKey(g_id_adapter, &WepKeyId);
   2189 
   2190       /* Set the header */
   2191       P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_PRIVACY__WEP__GET, (UINT8)status);
   2192 
   2193       /* Add the result */
   2194       P_BUFFER_ADD_UINT32(p_return_buffer, WepKeyId);
   2195 
   2196       g_tester_send_to_host(return_buffer, 5);
   2197   }
   2198 
   2199   /************************************************************************
   2200   *                        g_tester_gwsi_event_handler			        *
   2201   ************************************************************************
   2202   DESCRIPTION: Send the roaming candidates table to the GTester
   2203 
   2204   ************************************************************************/
   2205   void g_tester_Roaming_candidates_list(void)
   2206   {
   2207   /***************************
   2208   Return buffer structure (for header):
   2209 
   2210     Bytes 0-1  : OpCode (0x0004)
   2211     Byte  2	   : Command Status
   2212     Byte  3	   : Number of elements
   2213       ***************************/
   2214 
   2215       /***************************
   2216       Return buffer structure (for each element):
   2217 
   2218         Bytes 0-1	: OpCode (0x113c)
   2219         Byte  2	    : Command Status
   2220         Bytes 3-8   : MAC Address
   2221         Byte  9     : Band
   2222         Byte  10    : RSSI
   2223         Byte  11    : Channel
   2224         Byte  12    : Neighbor
   2225       ***************************/
   2226       tiUINT8 return_buffer[15];
   2227       tiUINT8 *p_return_buffer = return_buffer;
   2228       bssList_t bssList;
   2229       tiINT32 res;
   2230       tiUINT8 index;
   2231 
   2232 
   2233       /* get list */
   2234       res = TI_GetScanBssList( g_id_adapter, &bssList);
   2235       if( res != TI_RESULT_OK)
   2236       {
   2237           /*************************/
   2238           /* Error retrieving data */
   2239           /***********************/
   2240 
   2241           /* Set the header */
   2242           P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_CONNECTION__BSSID_LIST, res);
   2243 
   2244           /* Set dummy UINT8 */
   2245           P_BUFFER_ADD_UINT8(p_return_buffer, 0x00);
   2246 
   2247           g_tester_send_to_host(return_buffer, 4);
   2248       }
   2249       else
   2250       {
   2251           /*********************/
   2252           /* Header structure */
   2253           /*******************/
   2254 
   2255           /* Set the header */
   2256           P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_CONNECTION__BSSID_LIST, res);
   2257 
   2258           /* Set dummy UINT8 */
   2259           P_BUFFER_ADD_UINT8(p_return_buffer, bssList.numOfEntries);
   2260 
   2261           g_tester_send_to_host(return_buffer, 4);
   2262 
   2263           /***********************/
   2264           /* Elements structure */
   2265           /*********************/
   2266 
   2267           for (index = 0; index < bssList.numOfEntries; index++)
   2268           {
   2269               p_return_buffer = return_buffer;
   2270 
   2271               /* Set the header */
   2272               P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BSSLIST, res);
   2273 
   2274               P_BUFFER_ADD_DATA(p_return_buffer, bssList.BSSList[index].BSSID.addr , sizeof(bssList.BSSList[index].BSSID));
   2275 
   2276               P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)bssList.BSSList[index].band);
   2277 
   2278               P_BUFFER_ADD_UINT8(p_return_buffer, bssList.BSSList[index].RSSI-256);  /*convert to negative number*/
   2279 
   2280               P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)bssList.BSSList[index].channel);
   2281 
   2282               P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)bssList.BSSList[index].bNeighborAP);
   2283 
   2284               g_tester_send_to_host(return_buffer, 13);
   2285 
   2286           }
   2287       }
   2288   }
   2289 
   2290   /************************************************************************
   2291   *                        g_tester_scAn__configApp__Display			        *
   2292   ************************************************************************
   2293   DESCRIPTION: Display the application scan configuration
   2294 
   2295   ************************************************************************/
   2296 void g_tester_scAn__configApp__Display(void)
   2297 {
   2298 	/***************************
   2299 	Return buffer structure (for each element):
   2300 
   2301 	Bytes 0-1	: OpCode (0x113c)
   2302 	Byte  2	    : Command Status
   2303 	Bytes 3-15  : SSID(if SSID is 12 characters)
   2304     Byte  16    : Scan type
   2305 	Byte  10    : Band
   2306 	Byte  11    : Number of prob req
   2307 	Byte  12    : rate
   2308     Byte  13    : AC
   2309 	Byte  14    : Number of channel
   2310 
   2311     for every channel:
   2312     Byte  15    : channel number
   2313 	Byte  16-21 : BSSID
   2314     Byte  21-23 : max time
   2315     Byte  23-27 : min time
   2316     Byte  28    : ET event
   2317 	Byte  29    : ET frame num
   2318     Byte  30    : Power
   2319     Byte  31-   : Same as 15-30 for every channel  grater then 1
   2320 	***************************/
   2321    int i;
   2322    scan_normalChannelEntry_t* pNormalChannel;
   2323    tiUINT8 return_buffer[512];
   2324    tiUINT8 sSSID[33];
   2325    tiUINT8 *p_return_buffer = return_buffer;
   2326 
   2327 	/* Set the header */
   2328 	P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_SCAN__CONFIGAPP__DISPLAY, 0);
   2329 
   2330     /* Data */
   2331     /* SSID*/
   2332     memset(sSSID, 0, sizeof(sSSID));
   2333     strcpy((char*)sSSID, (char*)appScanParams.desiredSsid.ssidString);
   2334     memcpy((void*)p_return_buffer, sSSID, sizeof(sSSID));
   2335     p_return_buffer += sizeof(sSSID);
   2336 
   2337 
   2338     P_BUFFER_ADD_UINT8(p_return_buffer, appScanParams.scanType);
   2339     P_BUFFER_ADD_UINT8(p_return_buffer, appScanParams.band);
   2340     P_BUFFER_ADD_UINT8(p_return_buffer, appScanParams.probeReqNumber);
   2341     P_BUFFER_ADD_UINT32(p_return_buffer, appScanParams.probeRequestRate);
   2342 #ifdef TI_DBG
   2343     P_BUFFER_ADD_UINT8(p_return_buffer, appScanParams.Tid);
   2344 #else
   2345     P_BUFFER_ADD_UINT8(p_return_buffer, 0);
   2346 #endif
   2347     P_BUFFER_ADD_UINT8(p_return_buffer,  appScanParams.numOfChannels);
   2348     for ( i = 0; i < appScanParams.numOfChannels; i++ )
   2349     {
   2350       pNormalChannel = &(appScanParams.channelEntry[ i ].normalChannelEntry);
   2351       P_BUFFER_ADD_UINT8(p_return_buffer, pNormalChannel->channel);
   2352       memcpy((void*)p_return_buffer, (void*)(pNormalChannel->bssId.addr), sizeof(pNormalChannel->bssId.addr));
   2353       p_return_buffer += sizeof(pNormalChannel->bssId);
   2354       P_BUFFER_ADD_UINT32(p_return_buffer, pNormalChannel->maxChannelDwellTime);
   2355       P_BUFFER_ADD_UINT32(p_return_buffer, pNormalChannel->minChannelDwellTime);
   2356       P_BUFFER_ADD_UINT8(p_return_buffer, pNormalChannel->earlyTerminationEvent);
   2357       P_BUFFER_ADD_UINT8(p_return_buffer, pNormalChannel->ETMaxNumOfAPframes);
   2358       P_BUFFER_ADD_UINT8(p_return_buffer, pNormalChannel->txPowerDbm);
   2359     }
   2360 	g_tester_send_to_host(return_buffer, p_return_buffer-return_buffer);
   2361 }
   2362 
   2363 /*********************************************************************
   2364 *                        g_tester_plt_calibration_get_nvs_buffer	   *
   2365 ************************************************************************
   2366 DESCRIPTION: Display the NVS update buffers
   2367 ************************************************************************/
   2368 void g_tester_plt_calibration_get_nvs_buffer()
   2369 {
   2370    tiUINT8 return_buffer[sizeof(PltNvsResultsBuffer_t) + 4];
   2371    tiUINT8 *p_return_buffer = return_buffer;
   2372    PltNvsResultsBuffer_t PltNvsResultsBuffer;
   2373    int i;
   2374    tiUINT32 status;
   2375    tiUINT32 DataSize;
   2376 
   2377    memset(&PltNvsResultsBuffer, 0, sizeof(PltNvsResultsBuffer));
   2378    status = TI_PLT_RxTxCalNVSUpdateBuffer(g_id_adapter, &PltNvsResultsBuffer);
   2379    P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_PLT__CALIBRATION__GET_NVS_BUFFER, (UINT8)status);
   2380    if (status == OK)
   2381    {
   2382        P_BUFFER_ADD_UINT32(p_return_buffer, PltNvsResultsBuffer.numOfTables);
   2383        if (PltNvsResultsBuffer.numOfTables > NVS_RESULTS_MAX_NUM_OF_TABLES)
   2384        {
   2385            printf("%s:  aData.aLength (%d) > GWSI_PLT_NVS_RESULTS_MAX_NUM_OF_TABLES(%d) \n", __FUNCTION__,
   2386                PltNvsResultsBuffer.numOfTables, NVS_RESULTS_MAX_NUM_OF_TABLES);
   2387        }
   2388        else
   2389        {
   2390            for (i=0; i<PltNvsResultsBuffer.numOfTables; i++)
   2391            {
   2392                DataSize = PltNvsResultsBuffer.tables[i].size;
   2393                P_BUFFER_ADD_UINT16(p_return_buffer, DataSize);
   2394                P_BUFFER_ADD_UINT16(p_return_buffer, PltNvsResultsBuffer.tables[i].offset);
   2395 
   2396                if (DataSize>NVS_RESULTS_MAX_UPDATE_TABLE_SIZE)
   2397                {
   2398                    printf("%s:  DataSize (%d) > NVS_RESULTS_MAX_UPDATE_TABLE_SIZE(%d) \n", __FUNCTION__,
   2399                        DataSize, NVS_RESULTS_MAX_UPDATE_TABLE_SIZE);
   2400                    continue;
   2401                }
   2402 
   2403                memcpy((PVOID)p_return_buffer,
   2404                       (PVOID)PltNvsResultsBuffer.tables[i].data,
   2405                       DataSize);
   2406                p_return_buffer += DataSize;
   2407            }
   2408        }
   2409    }
   2410    	g_tester_send_to_host(return_buffer, p_return_buffer-return_buffer);
   2411 }
   2412