/*      XAPP coding test function c file        */
/*      created by Liu Wei  2006-01-13          */
/*      Version 1.0                             */
/*      -------------------------------------   */

#include "xapp_main.h"
#include "xapp_coding_test.h"
extern int xapp_test_state;

u32  time_count2 = 0, time_count3 ,time_count4=0;

void test_pass()
{    
	  if( time_count4++ >200 ) 
	  {
	  	time_count4 =0;
     test_xapp.fsm_state = 0;
     test_xapp.test_result = 1;
     if( !test_xapp.xapp_type )
     	send_mapp_close(test_xapp.did);
     else
     	send_capp_close(test_xapp.did);
    }
}

void test_fail()
{
	  if( time_count4++ >200 ) 
	  {
     test_xapp.fsm_state = 0;
     test_xapp.test_result = 2;
      if( !test_xapp.xapp_type )
     	send_mapp_close(test_xapp.did);
     else
     	send_capp_close(test_xapp.did);
     }
}

void MAPP_Test_SendPara_Proc()
{
     struct MapOprData_struct *data_ptr;
     struct MapOprSrv_struct *srv_ptr;
     struct MapSP_Arg *sp_arg;
     struct MapSP_Res *sp_res;

     int  did;

     test_xapp.test_result = 0;
     if(test_xapp.ms_mode == 1) // master
     {
          switch (test_xapp.fsm_state)
          {
          case 0:

               did = map_get_dialogueid(test_xapp.local_ssn);
               if(did && map_check_sendopr(did) && map_check_sendcom(did))
               {
                    u8   bcd_buf_h[ISDN_LEN * 2];

                    test_xapp.xapp_type = 0;

                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    test_xapp.did = did;
                    srv_ptr->dialogue_id = test_xapp.did;
                    srv_ptr->invoke_id = map_get_invokeid(did);
                    srv_ptr->message_flag = MAP_REQUEST;
                    srv_ptr->message_type = test_xapp.operation_type;
                    srv_ptr->version = 1;
                    srv_ptr->port_id = 0;
                    srv_ptr->version = 1;

                    sp_arg = &srv_ptr->msg_list.sp_arg;
                    sp_arg->param_flag = 0x03;
                    sp_arg->ReqPara_num = 2;
                    sp_arg->ReqPara[0] = 1;
                    sp_arg->ReqPara[1] = 2;
                    sp_arg->sub_id.choice_flag = 1;
                    AsciiToBcd(bcd_buf_h, "46002215712701", IMSI_LEN * 2);
                    memcpy(sp_arg->sub_id.id_choice.imsi, bcd_buf_h, IMSI_LEN);

                    send_mapp_open_req(did);

                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send SendparaArg !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did) && recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))    // wait response
               {
                    if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != SendParam)
                    {
                         printf("-->>: Recv Sendpara Res decode err!\r\n");
                         test_fail();

                         return;
                    }
                    printf("-->>:Recv Sendpara Res !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 2:
               if(map_check_sendcom(test_xapp.did))
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
     else if(test_xapp.ms_mode == 2)    // slaver
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn))
               {
                    test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id;
                    send_mapp_open_conf();
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))
               {
                    if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != SendParam)
                    {
                         printf("-->>: Recv Sendpara Arg decode err!\r\n");
                         test_fail();

                         return;
                    }
                    printf("-->>: Recv Sendpara Arg !\r\n");
                    test_xapp.fsm_state++;
                    test_xapp.invoke_id = test_xapp.xapp.mapp.data_ptr.invoke_id;
                    test_xapp.operation_type = test_xapp.xapp.mapp.data_ptr.message_type;
               }
               break;
          case 2:
               if(map_check_sendopr(test_xapp.did))
               {
                    struct Sub_data_struct *sub_data;

                    test_xapp.xapp_type = 0;

                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    srv_ptr->invoke_id = test_xapp.invoke_id;
                    srv_ptr->message_flag = MAP_RESPONSE;
                    srv_ptr->message_type = test_xapp.operation_type;
                    srv_ptr->port_id = 0;
                    srv_ptr->version = 1;

                    sp_res = &srv_ptr->msg_list.sp_res;

                    sp_res->param_flag = 0x0f;
                    sp_res->sendparamlist_num = 2;
                    sp_res->sendparalist[0].choice_flag = 1;
                    memcpy(sp_res->sendparalist[0].SP_Res_Choice.imsi, "460022157127015", IMSI_LEN);
                    sp_res->sendparalist[1].choice_flag = 4;

                    sub_data = &sp_res->sendparalist[1].SP_Res_Choice.sub_data;
                    sub_data->param_flag = 0xFF;
                    memcpy(sub_data->msisdn, "8675557127015", ISDN_LEN);
                    sub_data->category = 1;
                    sub_data->sub_status = 0;
                    sub_data->bearer_data= 1234;
                    sub_data->tele_data=12;
                    sub_data->zc_list.list_len = 2;
                    strcpy(sub_data->zc_list.zone_code[0], "HI");
                    strcpy(sub_data->zc_list.zone_code[1], "OK");
                    sub_data->odb_data.param_flag = 0x03;
                    sub_data->odb_data.odb_general = 0x1234;
                    sub_data->odb_data.odb_hplmn = 0xFEDC;
                    //sub_data->ss_info_num = 4; if 4 the map total length 192, mtp3 not support(<256)
                    //sub_data->ss_info_num = 2;

                    sub_data->ss_info.param_flag = 1;
                    
                    sub_data->ss_info.call_info.param_flag = 0x03;
                    sub_data->ss_info.call_info.ss_code[0] = 4;
                    sub_data->ss_info.call_info.ss_code[1] = 4;
                    sub_data->ss_info.call_info.ss_status[0] = 2;
                    sub_data->ss_info.call_info.ss_status[1] = 4;
                    sub_data->ss_info.call_info.bs_code[0].bearer_code = 1;
                    sub_data->ss_info.call_info.bs_code[0].tele_code = 2;
                    sub_data->ss_info.call_info.bs_code[1].bearer_code = 3;
                    sub_data->ss_info.call_info.bs_code[1].tele_code = 4; 
					
					/*
                    sub_data->ss_info[1].choice_flag = 4;
                    sub_data->ss_info[1].choice.cug_info.param_flag = 0x03;
                    sub_data->ss_info[1].choice.cug_info.feat_list.list_len = 1;
                    sub_data->ss_info[1].choice.cug_info.feat_list.cug_feat[0].param_flag = 0x07;
                    sub_data->ss_info[1].choice.cug_info.feat_list.cug_feat[0].bs.choice_flag = 1;
                    sub_data->ss_info[1].choice.cug_info.feat_list.cug_feat[0].bs.choice.bear_service = 1;
                    sub_data->ss_info[1].choice.cug_info.feat_list.cug_feat[0].cug_indicator = 1234;
                    sub_data->ss_info[1].choice.cug_info.feat_list.cug_feat[0].cug_restric = 12;
                    sub_data->ss_info[1].choice.cug_info.subs_list.list_len = 1;
                    sub_data->ss_info[1].choice.cug_info.subs_list.cug_subs[0].param_flag = 0x0f;
                    sub_data->ss_info[1].choice.cug_info.subs_list.cug_subs[0].bs.choice_flag = 1;
                    sub_data->ss_info[1].choice.cug_info.subs_list.cug_subs[0].bs.choice.bear_service = 1;
                    sub_data->ss_info[1].choice.cug_info.subs_list.cug_subs[0].cug_index = 1111;
                    memcpy(sub_data->ss_info[1].choice.cug_info.subs_list.cug_subs[0].cug_lock, "1234", 4);
                    sub_data->ss_info[1].choice.cug_info.subs_list.cug_subs[0].cug_opt = 0;
                    */
                    /*
                    sub_data->ss_info.fwd_info.param_flag = 0x01;
                    sub_data->ss_info.fwd_info.ss_code[0] = 1;
                    sub_data->ss_info.fwd_info.fwd_feat[0].param_flag = 0x3F;
                    sub_data->ss_info.fwd_info.fwd_feat[0].bs_code.param_flag = 1;
                    sub_data->ss_info.fwd_info.fwd_feat[0].bs_code.tele_code = 1;
                    sub_data->ss_info.fwd_info.fwd_feat[0].ss_status = 1;
                    memcpy(sub_data->ss_info.fwd_info.fwd_feat[0].fwdto_num+1, "8675557127016", ISDN_LEN);
                    sub_data->ss_info.fwd_info.fwd_feat[0].fwdto_num[0] = ISDN_LEN;
                    sub_data->ss_info.fwd_info.fwd_feat[0].norc_time = 1;
                    sub_data->ss_info.fwd_info.fwd_feat[0].fwd_option = 2;


                    sub_data->ss_info.ss_data.param_flag = 0x01;
                    sub_data->ss_info.ss_data.ss_code[0] = 1;
                    sub_data->ss_info.ss_data.ss_status[0] = 1;
                    sub_data->ss_info.ss_data.bs_code[0].param_flag = 3;
                    sub_data->ss_info.ss_data.bs_code[0].tele_code = 2;
                    sub_data->ss_info.ss_data.bs_code[0].bearer_code = 2;
                    sub_data->ss_info.ss_data.subs_opt[0].choice_flag = 1;
                    sub_data->ss_info.ss_data.subs_opt[0].choice.clires_opt = 2;
                    */
                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send SendparaRes !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 3:
               if(map_check_sendcom(test_xapp.did))
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
}

void MAPP_Test_NotSubPresent_Proc()
{

     struct MapOprData_struct *data_ptr;
     struct MapOprSrv_struct *srv_ptr;
     struct MapNP_Arg *np_arg;

     int  did;

     test_xapp.test_result = 0;
     if(test_xapp.ms_mode == 1) // master
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               did = map_get_dialogueid(test_xapp.local_ssn);
               if(did && map_check_sendopr(did) && map_check_sendcom(did))
               {
                    u8   bcd_buf_h[ISDN_LEN * 2];

                    test_xapp.xapp_type = 0;
                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    test_xapp.did = did;
                    srv_ptr->dialogue_id = test_xapp.did;
                    srv_ptr->invoke_id = map_get_invokeid(test_xapp.did);
                    srv_ptr->message_flag = MAP_REQUEST;
                    srv_ptr->message_type = test_xapp.operation_type;
                    srv_ptr->version = 1;
                    srv_ptr->port_id = 0;
                    srv_ptr->version = 1;

                    np_arg = &srv_ptr->msg_list.np_arg;
                    np_arg->param_flag = 0x01;
                    AsciiToBcd(bcd_buf_h, "460022157127012", IMSI_LEN * 2);
                    memcpy(np_arg->imsi, bcd_buf_h, IMSI_LEN);
                    np_arg->imsi[IMSI_LEN - 1] = np_arg->imsi[IMSI_LEN - 1] | 0xf0;

                    send_mapp_open_req(did);
                    build_xapp_msg();
                    printf("<<--: Send NotSubPresent ,not need to response !\r\n");
                    send_mapp_oprdata(data_ptr, 1);
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3)
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
     else if(test_xapp.ms_mode == 2)    // slaver
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn))
               {
                    test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id;
                    send_mapp_open_conf();
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))
               {
                    if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != NoteSubPrnt)
                    {
                         printf("-->>: Recv NotSubPresent decode err!\r\n");
                         test_fail();
                         return;
                    }
                    printf("-->>: Recv NotSubPresent ,not need to response !\r\n");
                    test_xapp.fsm_state++;
               }
          case 2:
               if(map_check_sendcom(test_xapp.did))
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
}

void MAPP_Test_ProcessUSSD_Proc()
{
     struct MapOprData_struct *data_ptr;
     struct MapOprSrv_struct *srv_ptr;
     struct MapPUSSD_Arg *ussd_arg;
     struct MapPUSSD_Res *ussd_res;

     int  did;

     test_xapp.test_result = 0;
     if(test_xapp.ms_mode == 1) // master
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               did = map_get_dialogueid(test_xapp.local_ssn);
               if(did && map_check_sendopr(did) && map_check_sendcom(did))
               {
                    test_xapp.xapp_type = 0;
                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    test_xapp.did = did;
                    srv_ptr->dialogue_id = test_xapp.did;
                    srv_ptr->invoke_id = map_get_invokeid(test_xapp.did);
                    srv_ptr->message_flag = MAP_REQUEST;
                    srv_ptr->message_type = test_xapp.operation_type;

                    srv_ptr->version = 1;
                    srv_ptr->port_id = 0;
                    srv_ptr->version = 1;

                    ussd_arg = &srv_ptr->msg_list.pussd_arg;
                    ussd_arg->ussd_len = 3;
                    memcpy(ussd_arg->ussd_data, "123", 3);
                    ussd_arg->param_flag = 1;

                    send_mapp_open_req(did);
                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send ProcessUSSD Arg!\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did) && recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))    // wait response
               {
                    if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != ProcUnstrctSSData)
                    {
                         printf("-->>: Recv ProcessUSSD Res decode err!\r\n");
                         return;
                    }
                    printf("-->>: Recv ProcessUSSD Res !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 2:
               if(map_check_sendcom(test_xapp.did))
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
     else if(test_xapp.ms_mode == 2)    // slaver
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn))
               {
                    test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id;
                    send_mapp_open_conf();
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))
               {
                    if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != ProcUnstrctSSData)
                    {
                         printf("-->>: Recv ProcessUSSD arg decode err!\r\n");
                         test_fail();
                         return;
                    }
                    printf("-->>: Recv ProcessUSSD arg !\r\n");
                    test_xapp.invoke_id = test_xapp.xapp.mapp.data_ptr.invoke_id;
                    test_xapp.operation_type = test_xapp.xapp.mapp.data_ptr.message_type;
                    test_xapp.fsm_state++;
               }
               break;
          case 2:
               if(map_check_sendopr(test_xapp.did))
               {
                    test_xapp.xapp_type = 0;

                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    srv_ptr->invoke_id = test_xapp.invoke_id;
                    srv_ptr->message_flag = MAP_RESPONSE;
                    srv_ptr->message_type = test_xapp.operation_type;
                    srv_ptr->port_id = 0;
                    srv_ptr->version = 1;

                    ussd_res = &srv_ptr->msg_list.pussd_res;

                    ussd_res->ussd_len = 3;
                    memcpy(ussd_res->ussd_data, "123", 3);
                    ussd_res->param_flag = 1;

                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send ProcessUSSD Res !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 3:
               recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did);
               if(map_check_sendcom(test_xapp.did))
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
}

void MAPP_Test_BeginSubActivity()
{

     struct MapOprData_struct *data_ptr;
     struct MapOprSrv_struct *srv_ptr;
     struct MapBSA_Arg *bsa_arg;

     int  did;

     test_xapp.test_result = 0;
     if(test_xapp.ms_mode == 1) // master
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               did = map_get_dialogueid(test_xapp.local_ssn);
               if(did && map_check_sendopr(did) && map_check_sendcom(did))
               {
                    u8   bcd_buf_h[ISDN_LEN * 2];

                    test_xapp.xapp_type = 0;
                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    test_xapp.did = did;
                    srv_ptr->dialogue_id = test_xapp.did;
                    srv_ptr->invoke_id = map_get_invokeid(test_xapp.did);
                    srv_ptr->message_flag = MAP_REQUEST;
                    srv_ptr->message_type = test_xapp.operation_type;
                    srv_ptr->version = 1;
                    srv_ptr->port_id = 0;
                    srv_ptr->version = 1;

                    bsa_arg = &srv_ptr->msg_list.bsa_arg;
                    bsa_arg->param_flag = 0x03;
                    AsciiToBcd(bcd_buf_h, "46002215712701", IMSI_LEN * 2);
                    memcpy(bsa_arg->imsi, bcd_buf_h, IMSI_LEN);
                    bsa_arg->orgenty_num_len = 9;
                    memcpy(bsa_arg->orgenty_num, "123456789", 9);

                    send_mapp_open_req(did);
                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send BegineSubActivity ,not need to response !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3)
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
     else if(test_xapp.ms_mode == 2)    // slaver
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn))
               {
                    test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id;
                    send_mapp_open_conf();
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))
               {
                    if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != BeginSubAct)
                    {
                         printf("-->>: Recv BegineSubActivity decode err!\r\n");
                         test_fail();
                         return;
                    }
                    printf("-->>: Recv BegineSubActivity ,not need to response !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 2:
               if(map_check_sendcom(test_xapp.did))
               {
                    test_pass();
               }
               break;
          default:
               break;
          }

     }
}

void MAPP_Test_RegisterSS()
{
     struct MapOprData_struct *data_ptr;
     struct MapOprSrv_struct *srv_ptr;
     struct MapRSS_Arg *regss_arg;
     struct MapRSS_Res *regss_res;
     struct MapComSrv_struct map_com;
     /*
     u8     isdn1[9] = {0x96, 0x64, 0x00, 0x22, 
     	                  0x51, 0x17 ,0x72, 0x10, 0xF5};
     u8     isdn2[9] = {0x91, 0x68, 0x57, 0x55, 
     	                  0x17, 0x22, 0x00, 0xF1};
     */
     char dst_ref[54], local_ref[54];
     u8   imsi[9]     , isdn[9];

     int  did;

     test_xapp.test_result = 0;
     if(test_xapp.ms_mode == 1) // master
     {
          switch (test_xapp.fsm_state)
          {
          case 0:

               did = map_get_dialogueid(test_xapp.local_ssn);
               if(did && map_check_sendopr(did) && map_check_sendcom(did))
               {
                    test_xapp.xapp_type = 0;
                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    test_xapp.did = did;
                    srv_ptr->dialogue_id = test_xapp.did;
                    srv_ptr->invoke_id = map_get_invokeid(test_xapp.did);
                    srv_ptr->message_flag = MAP_REQUEST;
                    srv_ptr->message_type = test_xapp.operation_type;

                    srv_ptr->version = 1;
                    srv_ptr->port_id = 0;
                    srv_ptr->version = 1;

                    regss_arg = &srv_ptr->msg_list.rss_arg;
	
                    regss_arg->param_flag   = 0x1F;
                    regss_arg->ss_code      = 0x28;
                    regss_arg->bs_code.param_flag = 0x01    ;
                    regss_arg->bs_code.tele_code  = 0x0a    ;
                    regss_arg->fwdto_num[0] = ISDN_LEN; 
                    memcpy( regss_arg->fwdto_num+1 , "12345678", 8 ); 
                    regss_arg->norc_time    = 30  ;
                    regss_arg->default_prio = 20  ;

                     

							     map_com.message_type = MAP_OPEN;
							     map_com.message_flag = MAP_REQUEST;
							     map_com.port_id = 0;
							     map_com.dialogue_id = test_xapp.did;
							     map_com.dlg_list.open_arg.acn_data.acn = 18;
							     map_com.dlg_list.open_arg.acn_data.acn_ver = 1; 
							     memcpy(&map_com.dlg_list.open_arg.local_add, &test_xapp.local_add, sizeof(SCCP_ADDR));
							     memcpy(&map_com.dlg_list.open_arg.peer_add, &test_xapp.peer_add, sizeof(SCCP_ADDR));
							     map_com.dlg_list.open_arg.peerref_len  = IMSI_LEN+1;
							     map_com.dlg_list.open_arg.localref_len = ISDN_LEN;
							     strcpy( local_ref , "8675557127001");
							     isdn_ston( isdn , local_ref);
							     map_com.dlg_list.open_arg.local_reference[0] = 0x91;
							     isdn_ntoa( (u8 *)&map_com.dlg_list.open_arg.local_reference+1 ,  isdn);
							     strcpy( dst_ref , "460022157127001");
							     imsi_ston( imsi , dst_ref);
							     map_com.dlg_list.open_arg.peer_reference[0] = 0x96;
							     imsi_ntoa( (u8 *)&map_com.dlg_list.open_arg.peer_reference+1 ,  imsi);
							     map_com.dlg_list.open_arg.param_flag = 0x1F;
							     send_mapp_comdata(&map_com, 1);
							     printf("<<--: Send OpenReq !\r\n");
							     
                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send Register SS Arg!\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did) && recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))    // wait response
               {
                    if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != RegSS)
                    {
                         printf("-->>: Recv Register SS Res decode err!\r\n");
                         return;
                    }
                    printf("-->>: Recv Register SS Res !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 2:
               if(map_check_sendcom(test_xapp.did))
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
     else if(test_xapp.ms_mode == 2)    // slaver
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn))
               {
               	    struct	MapOpen_Arg			*open_ptr;
               	    
                    test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id;
                    open_ptr = (MapOpen_Arg *) &test_xapp.xapp.mapp.com_ptr.dlg_list.open_arg;
                    if( (open_ptr->param_flag & 0x14) == 0x14)
                    {
                    	   char dst_ref[54], local_ref[54];
                    	   u8   imsi[9]     , isdn[9];
                    	   isdn_aton( isdn , open_ptr->local_reference+1);
                    	   isdn_ntos( local_ref , isdn );
                    	   imsi_aton( imsi , open_ptr->peer_reference+1);
                    	   imsi_ntos( dst_ref , imsi );
                    	   printf("dst ref: %s local_ref :%s\n",dst_ref, local_ref);
               	   
                    }
                    send_mapp_open_conf();
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))
               {
                    if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != RegSS)
                    {
                         printf("-->>: Recv Register SS arg decode err!\r\n");
                         test_fail();
                         return;
                    }
                    printf("-->>: Recv Register SS arg!\r\n");
                    test_xapp.invoke_id = test_xapp.xapp.mapp.data_ptr.invoke_id;
                    test_xapp.operation_type = test_xapp.xapp.mapp.data_ptr.message_type;
                    test_xapp.fsm_state++;
               }
               break;
          case 2:
               if(map_check_sendopr(test_xapp.did))
               {
                    test_xapp.xapp_type = 0;

                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    srv_ptr->invoke_id = test_xapp.invoke_id;
                    srv_ptr->message_flag = MAP_RESPONSE;
                    srv_ptr->message_type = test_xapp.operation_type;
                    srv_ptr->port_id = 0;
                    srv_ptr->version = 1;

                    regss_res = &srv_ptr->msg_list.rss_res;
                    regss_res->param_flag = 0x01;
                    regss_res->ss_info.choice_flag = 0x01;
                    regss_res->ss_info.choice.fwd_info.param_flag = 0x01;
                    regss_res->ss_info.choice.fwd_info.ss_code = 1;
                    regss_res->ss_info.choice.fwd_info.fwd_feat.param_flag = 0x3F;
                    regss_res->ss_info.choice.fwd_info.fwd_feat.bs_code.param_flag = 1;
                    regss_res->ss_info.choice.fwd_info.fwd_feat.bs_code.tele_code = 1;
                    regss_res->ss_info.choice.fwd_info.fwd_feat.ss_status = 1;
                    memcpy(regss_res->ss_info.choice.fwd_info.fwd_feat.fwdto_num+1, "8675557127016", ISDN_LEN);
                    regss_res->ss_info.choice.fwd_info.fwd_feat.fwdto_num[0] = ISDN_LEN;
                    regss_res->ss_info.choice.fwd_info.fwd_feat.norc_time = 1;
                    regss_res->ss_info.choice.fwd_info.fwd_feat.fwd_option = 2;

                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send Register SS res !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 3:
               recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did);
               if(map_check_sendcom(test_xapp.did))
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
}

void MAPP_Test_PeformHandOver()
{
     struct MapOprData_struct *data_ptr;
     struct MapOprSrv_struct *srv_ptr;
     struct MapHO_Arg *ho_arg;
     struct MapHO_Res *ho_res;

     int  did;

     test_xapp.test_result = 0;
     if(test_xapp.ms_mode == 1) // master
     {
          switch (test_xapp.fsm_state)
          {
          case 0:

               did = map_get_dialogueid(test_xapp.local_ssn);
               if(did && map_check_sendopr(did) && map_check_sendcom(did))
               {
                    test_xapp.xapp_type = 0;
                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    test_xapp.did = did;
                    srv_ptr->dialogue_id = test_xapp.did;
                    srv_ptr->invoke_id = map_get_invokeid(test_xapp.did);
                    srv_ptr->message_flag = MAP_REQUEST;
                    srv_ptr->message_type = test_xapp.operation_type;

                    srv_ptr->version = 1;
                    srv_ptr->port_id = 0;
                    srv_ptr->version = 1;

                    ho_arg = &srv_ptr->msg_list.ho_arg;
                    ho_arg->param_flag = 0x3F;
                    memcpy(ho_arg->tgt_cellID, "1234567", 7);
                    memcpy(ho_arg->srv_cellID, "7654321", 7);
                    memcpy(ho_arg->chl_type, "0123456789", 7);
                    memcpy(ho_arg->class_mark, "12", 2);
                    ho_arg->ho_priority = 1;
                    memcpy(ho_arg->kc, "12345678", 8);

                    send_mapp_open_req(did);
                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send PerformHandOver Arg!\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did) && recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))    // wait response
               {
                    if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != PerformHo)
                    {
                         printf("-->>: Recv PerformHandOver Res decode err!\r\n");
                         return;
                    }
                    printf("-->>: Recv PerformHandOver Res !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 2:
               if(map_check_sendcom(test_xapp.did))
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
     else if(test_xapp.ms_mode == 2)    // slaver
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn))
               {
                    test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id;
                    send_mapp_open_conf();
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))
               {
                    if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != PerformHo)
                    {
                         printf("-->>: Recv PerformHandOver arg decode err!\r\n");
                         test_fail();
                         return;
                    }
                    printf("-->>: Recv PerformHandOver arg!\r\n");
                    test_xapp.invoke_id = test_xapp.xapp.mapp.data_ptr.invoke_id;
                    test_xapp.operation_type = test_xapp.xapp.mapp.data_ptr.message_type;
                    test_xapp.fsm_state++;
               }
               break;
          case 2:
               if(map_check_sendopr(test_xapp.did))
               {
                    test_xapp.xapp_type = 0;

                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    srv_ptr->invoke_id = test_xapp.invoke_id;
                    srv_ptr->message_flag = MAP_RESPONSE;
                    srv_ptr->message_type = test_xapp.operation_type;
                    srv_ptr->port_id = 0;
                    srv_ptr->version = 1;

                    ho_res = &srv_ptr->msg_list.ho_res;
                    ho_res->ho_num_len = 9;
                    memcpy(ho_res->ho_num, "123456789", 9);
                    ho_res->access_singal_info.protocol_id = 2;
                    ho_res->access_singal_info.singal_info_len = 3;
                    memcpy(ho_res->access_singal_info.signal_info, "123", 3);

                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send PerformHandOver res !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 3:
               recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did);
               if(map_check_sendcom(test_xapp.did))
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
}



void MAPP_Test_CancelLoc_Proc(u8 ver)
{
     struct MapOprData_struct *data_ptr;
     struct MapOprSrv_struct *srv_ptr;
     struct MapCL_Arg *cl_arg;
     struct MapCL_Res *cl_res;


     int  did;

     test_xapp.test_result = 0;
     if(test_xapp.ms_mode == 1) // master 
     {
          switch (test_xapp.fsm_state)
          {
          case 0:

               did = map_get_dialogueid(test_xapp.local_ssn);
               if(did && map_check_sendopr(did) && map_check_sendcom(did))
               {
                    test_xapp.xapp_type = 0;

                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    test_xapp.did = did;
                    srv_ptr->dialogue_id = test_xapp.did;
                    srv_ptr->invoke_id = map_get_invokeid(did);
                    srv_ptr->message_flag = MAP_REQUEST;
                    srv_ptr->message_type = test_xapp.operation_type;
                    srv_ptr->port_id = 0;
                    srv_ptr->version = 3;

                    cl_arg = &srv_ptr->msg_list.cl_arg;
                   	cl_arg->param_flag = 0x03;
                   	cl_arg->id.choice_flag = 2;
                   	memcpy( cl_arg->id.choice.imsi_withlmsi.imsi ,"1234", IMSI_LEN);
                   	memcpy( cl_arg->id.choice.imsi_withlmsi.lmsi , "1234",LMSI_LEN); 
                   	cl_arg->type = 1;

                    send_mapp_open_req(did);

                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send CancelLocation !\r\n");
                    test_xapp.fsm_state++;
					if( ver == 1)
					{
						test_xapp.fsm_state = 2;
						printf(" Cancellocation V1 ,need not to response !\r\n"); 
					}
               }
               break;
          case 1:
               if(recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did) && recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))    // wait response
               {
					u8   isok = extract_xapp_msg(); 
                    if( isok != ROK || test_xapp.xapp.mapp.data_ptr.message_type != CancelLoc)
                    {
                         printf("-->>: Recv CancelLocation Res decode err!\r\n");
                         test_fail();
                         return;
                    }
                    printf("-->>:Recv CancelLocation Res !\r\n"); 
                    test_xapp.fsm_state++;
               }
               break;
          case 2:
               if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3)
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
     else if(test_xapp.ms_mode == 2)    // slaver
     {
          switch (test_xapp.fsm_state)
          {
		  case 0:
			  if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn))
			  {
				  test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id;
				  send_mapp_open_conf();
				  test_xapp.fsm_state++;
			  }
			  break;
          case 1:
               if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))
               {
				   u8  isok = extract_xapp_msg(); 
                    if( isok != ROK || test_xapp.xapp.mapp.data_ptr.message_type != CancelLoc)
                    {
                         printf("-->>: Recv Cancellocation Arg decode err!\r\n");
                         test_fail();
                         return; 
                    }
                    printf("-->>: Recv Cancellocation Arg !\r\n");
                    test_xapp.fsm_state++;
                    test_xapp.invoke_id = test_xapp.xapp.mapp.data_ptr.invoke_id;
                    test_xapp.operation_type = test_xapp.xapp.mapp.data_ptr.message_type;
                    if( test_xapp.xapp.mapp.map_opr.version == 1)
                    {
                    	test_xapp.fsm_state = 3;
						 printf("Cancellocation V1 ,need not to response !\r\n"); 
                    }
               }
               break;
          case 2:
               if(map_check_sendopr(test_xapp.did))
               {

                    test_xapp.xapp_type = 0;
                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    srv_ptr->invoke_id = test_xapp.invoke_id;
                    srv_ptr->message_flag = MAP_RESPONSE;
                    srv_ptr->message_type = test_xapp.operation_type;
                    srv_ptr->port_id = 0;
                    //srv_ptr->version = 3;

                    cl_res = &srv_ptr->msg_list.cl_res;

                    cl_res->param_flag = 0x00;
                    
                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send SendparaRes !\r\n"); 
                    test_xapp.fsm_state++;
               }
               break;
          case 3:
               if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3)
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
}




void MAPP_Test_PerformSubsequenthandover()  
{

     struct MapOprData_struct *data_ptr;
     struct MapOprSrv_struct *srv_ptr;
     struct MapPFSHO_Arg *ho_arg;
     struct MapPFSHO_Res *ho_res;

     int  did;

     test_xapp.test_result = 0;
     if(test_xapp.ms_mode == 1) // master
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               did = map_get_dialogueid(test_xapp.local_ssn);
               if(did && map_check_sendopr(did) && map_check_sendcom(did))
               {

                    test_xapp.xapp_type = 0;
                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    test_xapp.did = did;
                    srv_ptr->dialogue_id = test_xapp.did;
                    srv_ptr->invoke_id = map_get_invokeid(test_xapp.did);
                    srv_ptr->message_flag = MAP_REQUEST;
                    srv_ptr->message_type = test_xapp.operation_type;
                    srv_ptr->version = 1;
                    srv_ptr->port_id = 0;
                    srv_ptr->version = 1;

                    ho_arg = &srv_ptr->msg_list.pfsho_arg;
					ho_arg->param_flag = 0x0f;
					
					
					memcpy( ho_arg->target_id , "1234567",GCID_LEN);
					memcpy( ho_arg->service_id , "1234567",GCID_LEN);
					ho_arg->msc_num[0]= ISDN_LEN;
					memcpy( ho_arg->msc_num+1 , "01234567" ,ISDN_LEN);
					memcpy( ho_arg->classmark_info ,"12" ,2 );



                    send_mapp_open_req(did);
                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send Preformsubsequent handover Arg!\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did) && recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))    // wait response
               {
                    if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != PerformSubsHo)
                    {
                         printf("-->>: Recv Preformsubsequent handover Res decode err!\r\n");
                         test_fail();

                         return;
                    }
                    printf("-->>:Recv Preformsubsequent handover Res !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 2:
               if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3)
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
     else if(test_xapp.ms_mode == 2)    // slaver
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn))
               {
                    test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id;
                    send_mapp_open_conf();
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))
               {
                    if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != PerformSubsHo)
                    {
                         printf("-->>: Recv Preformsubsequent handover Arg decode err!\r\n");
                         test_fail();
                         return;
                    }
                    printf("-->>: Recv Preformsubsequent handover Arg\r\n");
                    test_xapp.fsm_state++;
               }
               break;
		   case 2:
               if(map_check_sendopr(test_xapp.did))
               {
                    test_xapp.xapp_type = 0;
                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    srv_ptr->invoke_id = test_xapp.invoke_id;
                    srv_ptr->message_flag = MAP_RESPONSE;
                    srv_ptr->message_type = test_xapp.operation_type;
                    srv_ptr->port_id = 0;
                    //srv_ptr->version = 3;

                    ho_res = &srv_ptr->msg_list.pfsho_res;

					ho_res->param_flag = 1;
					ho_res->access_sig_info.param_flag = 3;
					ho_res->access_sig_info.prt_id =1;
					ho_res->access_sig_info.siginfo.siginfo_len =2 ;
                    memcpy( ho_res->access_sig_info.siginfo.signal_info , "12",2);
					
                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send Preformsubsequent handover Res !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 3:
               if(map_check_sendcom(test_xapp.did))
               {
                    test_pass();
               }
               break;
          default:
               break;
          }

     }
}


void MAPP_Test_noteinernalhandover()
{

     struct MapOprData_struct *data_ptr;
     struct MapOprSrv_struct *srv_ptr;
     struct MapNIHO_Arg *ho_arg;

     int  did;

     test_xapp.test_result = 0;
     if(test_xapp.ms_mode == 1) // master
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               did = map_get_dialogueid(test_xapp.local_ssn);
               if(did && map_check_sendopr(did) && map_check_sendcom(did))
               {

                    test_xapp.xapp_type = 0;
                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    test_xapp.did = did;
                    srv_ptr->dialogue_id = test_xapp.did;
                    srv_ptr->invoke_id = map_get_invokeid(test_xapp.did);
                    srv_ptr->message_flag = MAP_REQUEST;
                    srv_ptr->message_type = test_xapp.operation_type;
                    srv_ptr->version = 1;
                    srv_ptr->port_id = 0;
                    srv_ptr->version = 1;

                    ho_arg = &srv_ptr->msg_list.niho_arg;
                    ho_arg->param_flag = 0x07;
					ho_arg->ho_type =1;
					memcpy(ho_arg->target_id , "1234567" , GCID_LEN);
                    ho_arg->channel_id.param_flag = 3;
					ho_arg->channel_id.prt_id =2;
					ho_arg->channel_id.siginfo.siginfo_len =2;
					memcpy( ho_arg->channel_id.siginfo.signal_info , "12" ,2 );

                    send_mapp_open_req(did);
                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send noteinernalhandover ,not need to response !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3)
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
     else if(test_xapp.ms_mode == 2)    // slaver
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn))
               {
                    test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id;
                    send_mapp_open_conf();
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))
               {
                    if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != NoteInterHo)
                    {
                         printf("-->>: Recv noteinernalhandover decode err!\r\n");
                         test_fail();
                         return;
                    }
                    printf("-->>: Recv noteinernalhandover ,not need to response !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 2:
               if(map_check_sendcom(test_xapp.did))
               {
                    test_pass();
               }
               break;
          default:
               break;
          }

     }
}


void MAPP_Test_tracesubscriberactivity()
{

     struct MapOprData_struct *data_ptr;
     struct MapOprSrv_struct *srv_ptr;
     struct MapTSA_Arg *tsa_arg;

     int  did;

     test_xapp.test_result = 0;
     if(test_xapp.ms_mode == 1) // master
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               did = map_get_dialogueid(test_xapp.local_ssn);
               if(did && map_check_sendopr(did) && map_check_sendcom(did))
               {
                    u8   bcd_buf_h[ISDN_LEN * 2];

                    test_xapp.xapp_type = 0;
                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    test_xapp.did = did;
                    srv_ptr->dialogue_id = test_xapp.did;
                    srv_ptr->invoke_id = map_get_invokeid(test_xapp.did);
                    srv_ptr->message_flag = MAP_REQUEST;
                    srv_ptr->message_type = test_xapp.operation_type;
                    srv_ptr->version = 1;
                    srv_ptr->port_id = 0;
                    srv_ptr->version = 1;

                    tsa_arg = &srv_ptr->msg_list.tsa_arg;
                    tsa_arg->param_flag = 0x1f;
                    AsciiToBcd(bcd_buf_h, "46002215712701", IMSI_LEN * 2);
                    memcpy(tsa_arg->imsi, bcd_buf_h, IMSI_LEN);
					memcpy( tsa_arg->trace_ref , "12",2);
					tsa_arg->trace_type = 1;
					tsa_arg->omc_id_len =2;
					memcpy( tsa_arg->omc_id ,"12", 2 );
					memcpy( tsa_arg->call_ref , "123" ,3 );

                    send_mapp_open_req(did);
                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send tracesubscriberactivity ,not need to response !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3)
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
     else if(test_xapp.ms_mode == 2)    // slaver
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn))
               {
                    test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id;
                    send_mapp_open_conf();
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))
               {
                    if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != TraceSubAct)
                    {
                         printf("-->>: Recv tracesubscriberactivityy decode err!\r\n");
                         test_fail();
                         return;
                    }
                    printf("-->>: Recv tracesubscriberactivity ,not need to response !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 2:
               if(map_check_sendcom(test_xapp.did))
               {
                    test_pass();
               }
               break;
          default:
               break;
          }

     }
}

void MAPP_Test_FowardSM()
{

     struct MapOprData_struct *data_ptr;
     struct MapOprSrv_struct *srv_ptr;
     struct MapFSM_Arg *fsm_arg;

     int  did;

     test_xapp.test_result = 0;
     if(test_xapp.ms_mode == 1) // master
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               did = map_get_dialogueid(test_xapp.local_ssn);
               if(did && map_check_sendopr(did) && map_check_sendcom(did))
               {

                    test_xapp.xapp_type = 0;
                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    test_xapp.did = did;
                    srv_ptr->dialogue_id = test_xapp.did;
                    srv_ptr->invoke_id = map_get_invokeid(test_xapp.did);
                    srv_ptr->message_flag = MAP_REQUEST;
                    srv_ptr->message_type = test_xapp.operation_type;
                    srv_ptr->version = 1;
                    srv_ptr->port_id = 0;
                    srv_ptr->version = 1;

                    fsm_arg = &srv_ptr->msg_list.fsm_arg;
                    fsm_arg->param_flag = 0x0f;
					fsm_arg->more_msgtosend =1;
					fsm_arg->sm_rp_da_choice = 5;
					fsm_arg->sm_rp_da.noms_rp_da =1;

					fsm_arg->sm_rp_oa_choice =1;
					fsm_arg->sm_rp_oa.msisdn[0 ] = ISDN_LEN;
					fsm_arg->sm_rp_oa.msisdn[0] =ISDN_LEN;
					memcpy(fsm_arg->sm_rp_oa.msisdn+1 , "12345678" , ISDN_LEN );

					fsm_arg->sm_rp_ui_len =2;
					memcpy(fsm_arg->sm_rp_ui , "12",2);

                    send_mapp_open_req(did);
                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send FowardSM ,not need to response !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3)
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
     else if(test_xapp.ms_mode == 2)    // slaver
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn))
               {
                    test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id;
                    send_mapp_open_conf();
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))
               {
                    if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != FwdSM)
                    {
                         printf("-->>: Recv FowardSM decode err!\r\n");
                         test_fail();
                         return;
                    }
                    printf("-->>: Recv FowardSM ,not need to response !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 2:
               if(map_check_sendcom(test_xapp.did))
               {
                    test_pass();
               }
               break;
          default:
               break;
          }

     }
}

void MAPP_Test_SendRoutinginfoforSM()
{

     struct MapOprData_struct *data_ptr;
     struct MapOprSrv_struct *srv_ptr;
     struct MapRIFSMV1_Arg *ssm_arg;
	 struct MapRIFSMV1_Res *ssm_res;

     int  did;

     test_xapp.test_result = 0;
     if(test_xapp.ms_mode == 1) // master
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               did = map_get_dialogueid(test_xapp.local_ssn);
               if(did && map_check_sendopr(did) && map_check_sendcom(did))
               {
                    test_xapp.xapp_type = 0;
                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    test_xapp.did = did;
                    srv_ptr->dialogue_id = test_xapp.did;
                    srv_ptr->invoke_id = map_get_invokeid(test_xapp.did);
                    srv_ptr->message_flag = MAP_REQUEST;
                    srv_ptr->message_type = test_xapp.operation_type;
                    srv_ptr->version = 1;
                    srv_ptr->port_id = 0;
                    srv_ptr->version = 1;

                    ssm_arg = &srv_ptr->msg_list.rifsm_v1_arg;
					ssm_arg->param_flag = 0x0f;
					ssm_arg->msisdn[0] = ISDN_LEN;
					memcpy(ssm_arg->msisdn+1,"12345678", ISDN_LEN);
					ssm_arg->sc_add[0]= ISDN_LEN;
					memcpy(ssm_arg->sc_add+1,"12345678",ISDN_LEN);
                    ssm_arg->sm_rp_pri =1;
					ssm_arg->tele_service =1;

                    send_mapp_open_req(did);
                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send sendrounting info sm arg !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
		  case 1:
			  if(recv_mapp_comdata(&test_xapp.xapp.mapp.com_ptr, test_xapp.did) && recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))    // wait response
			  {
				  u8   isok = extract_xapp_msg(); 
				  if( isok != ROK || test_xapp.xapp.mapp.data_ptr.message_type != SndRoutInfoForSM)
				  {
					  printf("-->>: Recv sendrounting info sm decode err!\r\n");
					  test_fail();
					  return;
				  }
				  printf("-->>: Recv sendrounting info sm  arg !\r\n");
				  test_xapp.fsm_state++;
			  }
			  break;
          case 2:
               if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3)
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
     else if(test_xapp.ms_mode == 2)    // slaver
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               if(get_mapp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn))
               {
                    test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id;
                    send_mapp_open_conf();
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(recv_mapp_oprdata(&test_xapp.xapp.mapp.data_ptr, test_xapp.did))
               {
                    if( extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != SndRoutInfoForSM)
                    {
                         printf("-->>: Recv sendrounting info sm decode err!\r\n");
                         test_fail();
                         return;
                    }
                    printf("-->>: Recv sendrounting info sm  arg !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
		  case 2:
               if(map_check_sendopr(test_xapp.did))
               {
               		u8   bcd_buf_h[ISDN_LEN * 2];
               		
                    test_xapp.xapp_type = 0;
                    data_ptr = &test_xapp.xapp.mapp.data_ptr;
                    srv_ptr = &test_xapp.xapp.mapp.map_opr;

                    srv_ptr->invoke_id = test_xapp.invoke_id;
                    srv_ptr->message_flag = MAP_RESPONSE;
                    srv_ptr->message_type = test_xapp.operation_type;
                    srv_ptr->port_id = 0;
                    //srv_ptr->version = 3;

                    ssm_res = &srv_ptr->msg_list.rifsm_v1_res;
					ssm_res->param_flag = 0x03;
					AsciiToBcd(bcd_buf_h, "46002215712701", IMSI_LEN * 2);
                    memcpy(ssm_res->imsi, bcd_buf_h, IMSI_LEN);
					ssm_res->loc_info.param_flag = 0x02;
					memcpy(ssm_res->loc_info.imsi, bcd_buf_h, IMSI_LEN);
					ssm_res->loc_info.choice_flag = 1;
					ssm_res->loc_info.choice.roaming_num[0] = 8;
					memcpy( ssm_res->loc_info.choice.roaming_num+1  , "87654321", 9 );
					
                    build_xapp_msg();
                    send_mapp_oprdata(data_ptr, 1);
                    printf("<<--: Send sendrounting info sm  Res !\r\n");
                    test_xapp.fsm_state++;
               }
               break;
          case 3:
               if(map_check_sendcom(test_xapp.did))
               {
                    test_pass();
               }
               break;
          default:
               break;
          }

     }
}

  


void CAPP_Test_InitialDP()
{
     struct CapInitialDP *init_dp;
     struct MapOprData_struct *data_ptr;
     struct CapArg *cap_opr;
     int  did;

     test_xapp.test_result = 0;
     if(test_xapp.ms_mode == 1) // master
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               did = cap_get_dialogueid(test_xapp.local_ssn);
               if(did && cap_check_sendopr(did) && cap_check_sendcom(did))
               {
                    int  len;

                    //pcapmsg = &test_xapp.xapp.capp.capmsg;
                    cap_opr = &test_xapp.xapp.capp.cap_opr;
                    data_ptr = &test_xapp.xapp.capp.data_ptr;

                    test_xapp.xapp_type = 1;
                    test_xapp.did = did;
                    cap_opr->dialogue_id = test_xapp.did;
                    cap_opr->invoke_id = test_xapp.invoke_id = map_get_invokeid(did);
                    cap_opr->message_flag = MAP_REQUEST;
                    cap_opr->ocode = test_xapp.operation_type;
                    cap_opr->version = 0;
                    init_dp = &cap_opr->msg_list.initialDPArg;

                    init_dp->serviceKey = 1;
                    init_dp->optional_flag = 0x0007;
                    init_dp->calledPartyNumber[0] = 4;
                    memcpy(&init_dp->calledPartyNumber[1], "1234", 4);
                    init_dp->callingPartyNumber[0] = 4;
                    memcpy(&init_dp->callingPartyNumber[1], "1234", 4);
                    init_dp->callingPartysCategory = 2;
                    send_capp_open_req(50, 1, did);

                    len = build_xapp_msg();
                    printf("<<--: Send InitialDP ,not need to response !\r\n");
                    send_capp_oprdata(data_ptr, 1);
                    //send_capp_oprdata(pcapmsg,len);  
                    test_xapp.fsm_state++;
                    /*                                                              
                       init_dp->serviceKey = 1;
                       init_dp->optional_flag = 0x947D;   
                       memcpy( init_dp->calledPartyNumber , "46002215712701",IMSI_LEN*2);
                       //memcpy( init_dp->callingPartyNumber , "46002215712701",IMSI_LEN*2);
                       init_dp->callingPartysCategory = 2;
                       //memcpy( init_dp->iPSSPCapabilities ,"123",3);
                       memcpy( init_dp->locationNumber , "46002215712701" , IMSI_LEN*2);
                       memcpy( init_dp->originalCalledPartyID , "123456" , 6);
                       memcpy( init_dp->highLayerCompatibility , "123" , 3);
                       //memcpy( init_dp->additionalCallingPartyNumber , "46002215712701" , IMSI_LEN*2);
                       memcpy( init_dp->redirectingPartyID , "123" , 3);
                       //memcpy( init_dp->redirectionInformation , "123456" , 6);
                       memcpy( init_dp->iMSI , "46002215712701" , IMSI_LEN*2);
                       //init_dp->subscriberState_ch = 'a';
                       init_dp->ext_basicServiceCode_ch = 'b';                                                                      
                       //memcpy( init_dp->callReferenceNumber , "46002215712701" , IMSI_LEN*2);
                       //CapBearerCapability                bearerCapability;                                                       
                       //CapEventTypeBCSM           eventTypeBCSM;                                                          
                       //CapSubscriberState         subscriberState;                                                        
                       //CapLocationInformation     locationInformation;                                    
                       //CapExt_BasicServiceCode    ext_basicServiceCode;           
                       send_capp_open_req( test_xapp.operation_type , 1 , did );
                       build_xapp_msg();
                       printf("<<--: Send InitialDP ,not need to response !\r\n");
                       send_capp_oprdata((u8 *)&pcapmsg->msgContent[5]);
                       test_xapp.fsm_state++;
                     */
               }
               break;
          case 1:
               if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3)
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
     else if(test_xapp.ms_mode == 2)    // slaver
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               if(get_capp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn))
               {
                    test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id;
                    send_capp_open_conf(test_xapp.operation_type, 1, did);
                    test_xapp.fsm_state++;
               }
               if((time_count3++ % 100) == 13)
               {
                    printf("Timer expired!\r\n");
                    test_fail();
                    return;
               }
               break;
          case 1:
               if(recv_capp_oprdata(&test_xapp.xapp.capp.data_ptr, test_xapp.did))
               {
                    if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != CAP_OC_InitialDP)
                    {
                         printf("-->>: Recv InitialDP decode err!\r\n");
                         test_fail();
                         return;
                    }
                    printf("-->>: Recv InitialDP ,not need to response !\r\n");
                    test_xapp.fsm_state++;
               }
               if((time_count3++ % 100) == 13)
               {
                    printf("Timer expired!\r\n");
                    test_fail();
                    return;
               }
          case 2:
               if(map_check_sendcom(test_xapp.did))
               {
                    test_pass();
               }
               if((time_count3++ % 100) == 13)
               {
                    printf("Timer expired!\r\n");
                    test_fail();
                    return;
               }
               break;
          default:
               break;
          }
     }
}

void CAPP_Test_ActivityTest()   //NULL
{

}

void CAPP_Test_Connect()
{
	/*
     struct CapConnect_v1 *connect;
     struct MapOprData_struct *data_ptr;
     struct CapArg *cap_opr;
     int  did;

     test_xapp.test_result = 0;
     if(test_xapp.ms_mode == 1) // master
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               did = cap_get_dialogueid(test_xapp.local_ssn);
               if(did && cap_check_sendopr(did) && cap_check_sendcom(did))
               {
                    int  len;

                    cap_opr = &test_xapp.xapp.capp.cap_opr;
                    data_ptr = &test_xapp.xapp.capp.data_ptr;

                    test_xapp.xapp_type = 1;
                    test_xapp.did = did;
                    cap_opr->dialogue_id = test_xapp.did;
                    cap_opr->invoke_id = test_xapp.invoke_id = map_get_invokeid(did);
                    cap_opr->message_flag = MAP_REQUEST;
                    cap_opr->ocode = test_xapp.operation_type;
                    cap_opr->version = 0;

                    connect = &cap_opr->msg_list.connectArg_v1;

                    connect->destinationRoutingAddress[0] = 4;
                    memcpy(&connect->destinationRoutingAddress[1], "1234", 4);
                    connect->optional_flag = 0xC3;
                    connect->originalCalledPartyID[0] = 4;
                    memcpy(&connect->originalCalledPartyID[1], "1234", 4);
                    connect->genericNumbers_v1_len = 1;
                    connect->genericNumber_v1[0][0] = 4;
                    memcpy(&connect->genericNumber_v1[0][1], "1234", 4);
                    connect->suppressionOfAnnouncement = 1;
                    connect->oCSIApplicable = 0;

                    send_capp_open_req(50, 1, did);

                    len = build_xapp_msg();
                    printf("<<--: Send Connect ,not need to response !\r\n");
                    send_capp_oprdata(data_ptr, 1);
                    test_xapp.fsm_state++;

               }
               break;
          case 1:
               if(map_check_sendcom(test_xapp.did) && (time_count3++ % 10) == 3)
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
     else if(test_xapp.ms_mode == 2)    // slaver
     {
          switch (test_xapp.fsm_state)
          {
          case 0:
               if(get_capp_open(&test_xapp.xapp.mapp.com_ptr, test_xapp.local_ssn))
               {
                    test_xapp.did = test_xapp.xapp.mapp.com_ptr.dialogue_id;
                    send_capp_open_conf(test_xapp.operation_type, 1, did);
                    test_xapp.fsm_state++;
               }
               break;
          case 1:
               if(recv_capp_oprdata(&test_xapp.xapp.capp.data_ptr, test_xapp.did))
               {
                    if(extract_xapp_msg() != ROK || test_xapp.xapp.mapp.data_ptr.message_type != CAP_OC_Connect)
                    {
                         printf("-->>: Recv Connect decode err!\r\n");
                         test_fail();
                         return;
                    }
                    printf("-->>: Recv Connect ,not need to response !\r\n");
                    test_xapp.fsm_state++;
               }
          case 2:
               if(map_check_sendcom(test_xapp.did))
               {
                    test_pass();
               }
               break;
          default:
               break;
          }
     }
    
    */
}

void CAPP_Test_Continue()       //NULL
{

}

void CAPP_Test_EventReportBCSM()        //==V2
{

}

void CAPP_Test_ReleaseCall()    //==V2
{

}

void CAPP_Test_RequestReportBCSMEvent() //==V2
{

}

void Test_fsm()
{
     if(test_xapp.operation_type || (!test_xapp.operation_type && test_cmd == CAPP_TEST_INITDP))
     {
          switch (test_xapp.operation_type)
          {

        /*-------------->>>>>>>>>>>>>  MAP V1	Test	<<<<<<<<<<<<<<<<<<<<<-------------*/
          case SendParam:      // send parameters
               MAPP_Test_SendPara_Proc();
               break;
          case NoteSubPrnt:    // not subscriber present
               MAPP_Test_NotSubPresent_Proc();
               break;
          case ProcUnstrctSSData:      // process unstructure SS data
               MAPP_Test_ProcessUSSD_Proc();
               break;
          case BeginSubAct:    // beging subscriber activity
               MAPP_Test_BeginSubActivity();
               break;
          case PerformHo:      // perform handover
               MAPP_Test_PeformHandOver();
               break;
          case RegSS:
          	   MAPP_Test_RegisterSS();
          	   break;
         case  PerformSubsHo:
               MAPP_Test_PerformSubsequenthandover();  
               break;
          case NoteInterHo:
               MAPP_Test_noteinernalhandover();
               break;
          case TraceSubAct:
               MAPP_Test_tracesubscriberactivity();
               break;
          case FwdSM:
          	   MAPP_Test_FowardSM();
               break;
          case SndRoutInfoForSM:
          	   MAPP_Test_SendRoutinginfoforSM();
			   break;
		  case CancelLoc:
				if( test_cmd == MAPP_TEST_CANCELLOCv3 )
					MAPP_Test_CancelLoc_Proc(3); 
				else
				    MAPP_Test_CancelLoc_Proc(1); 
               break;
          case CAP_OC_InitialDP:
               CAPP_Test_InitialDP();
               break;
          case CAP_OC_ActivityTest:
               CAPP_Test_ActivityTest();
               break;
          case CAP_OC_Connect:
               CAPP_Test_Connect();
               break;
          case CAP_OC_Continue:
               CAPP_Test_Continue();
               break;
          case CAP_OC_EventReportBCSM:
               CAPP_Test_EventReportBCSM();
               break;
          case CAP_OC_ReleaseCall:
               CAPP_Test_ReleaseCall();
               break;
          case CAP_OC_RequestReportBCSMEvent:
               CAPP_Test_RequestReportBCSMEvent();
               break;

        /*-------------->>>>>>>>>>>>>  MAP V1	Test	<<<<<<<<<<<<<<<<<<<<<-------------*/
          default:
               break;
          }
     }

}

void Test_func()
{
     if(test_xapp.ms_mode > 0 && !test_xapp.test_result && test_xapp.test_result != 7)
     {
          switch (test_cmd)
          {

          case 0:
               //printf("time_count2 :%d",time_count2);
               if(test_xapp.ms_mode == 2)
               {
                    printf("\r\n\r\nStart xapp Test ......\r\n\r\n");
                    //test_cmd = MAPP_TEST_SENDPARA;
                    test_cmd = MAPP_TEST_REGISTERSS;
                    break;
               }
               else if((time_count2++) == test_xapp.wait_time)
               {
                    printf("\r\n\r\nStart xapp Test ......\r\n\r\n");
                    //test_cmd = MAPP_TEST_SENDPARA;
                    test_cmd = MAPP_TEST_REGISTERSS;
               }
               break;
          case MAPP_TEST_SENDPARA:
               //test_xapp.operation_type = NoteSubPrnt;
               test_xapp.operation_type = SendParam;
               break;
          case MAPP_TEST_NOTSUBPRE:
               test_xapp.operation_type = NoteSubPrnt;
               break;
          case MAPP_TEST_PROCUSSD:
               test_xapp.operation_type = ProcUnstrctSSData;
               break;
          case MAPP_TEST_BEGINACT:
               test_xapp.operation_type = BeginSubAct;
               break;
          case MAPP_TEST_HANDOVER:
               test_xapp.operation_type = PerformHo;
               break;
          case MAPP_TEST_PERFORMSUBSEQUENTHANDOVER:
               test_xapp.operation_type = PerformSubsHo;
               break; 
          case MAPP_TEST_NOTEINERNALHANDOVER:
               test_xapp.operation_type = NoteInterHo;
               break;
          case MAPP_TEST_REGISTERSS:
               test_xapp.operation_type = RegSS; 
               break;
          case MAPP_TEST_TRACESUBSCRIBERACTIVITY:
               test_xapp.operation_type = TraceSubAct;
               break;
          case MAPP_TEST_FOWARDSM:
               test_xapp.operation_type = FwdSM;
               break;
          case MAPP_TEST_SENDROUTINGINFOFORSM:
               test_xapp.operation_type = SndRoutInfoForSM;
               break;
		  case MAPP_TEST_CANCELLOC:
		  case MAPP_TEST_CANCELLOCv3:
			  test_xapp.operation_type = CancelLoc;
			  break;
          case CAPP_TEST_INITDP:
               test_xapp.operation_type = CAP_OC_InitialDP;
               break;

               //case CAPP_TEST_ACTTEST:
               //             test_xapp.operation_type = CAP_OC_ActivityTest ;
               //             break;
          case CAPP_TEST_CONNECT:
               test_xapp.operation_type = CAP_OC_Connect;
               break;
               //case CAPP_TEST_CONTINUE:
               //               test_xapp.operation_type = CAP_OC_Continue;
               //               break;
               //case CAPP_TEST_REPORTBCSM:
               //         test_xapp.operation_type = CAP_OC_EventReportBCSM;
               //              break;
               //case CAPP_TEST_CALLREL:
               //         test_xapp.operation_type = CAP_OC_ReleaseCall;
               //               break;
          case CAPP_TEST_REQREPORTBCSM:
               test_xapp.operation_type = CAP_OC_RequestReportBCSMEvent;
               break;
          case XAPP_TEST_LAST_IDLE:
               break;
          default:
               break;
          }
          Test_fsm();
     }

}
