代码流程之从RRC_SERVICE_IND到Attach

目录

一、代码流程图

二、代码详细流程

1.cmtask_handle_sigs()

2.cm_msgr_handle()

3.mm_emm_normal_msg_handler()

4.emm_process_rrc_primitive()

5.emm_rrc_process_service_indication()

6.emm_deregistered_process_rrc_service_ind()

7.emm_attach_needed_rrc_service_ind()

8.emm_send_reg_camped_ind()

9.reg_state_main()

10.process_mmr_camped_ind()

11.reg_send_cm_camped_ind()

12.cmtask_handle_sigs()

13.cm_rpt_handle()

14.cm_wrpt_handle()

15.cmregprx_rpt_proc()

16.cmregprx_camped_ind_hdlr()

17.cmregprx_active_camped_ind_hdlr()

18.emm_chk_ta_change()

19.emm_init_attach_procedure()

20.emm_build_and_send_get_pdn_connectivity_req_ind()

21.handle_emm_message()

22.esm_build_and_send_get_pdn_connectivity_req_ind()

23.cmltecall_rpt_proc()

24.cm_mm_call_cmd_pdn_connectivity_req()

25.cmltecall_client_cmd_forward_ll()

26.cmltecall_send_requests()

27.handle_message()

28.esm_build_and_send_pkd_pdn_connectivity_req_msg()

29.cmltecall_rpt_proc()

30.cmltecall_call_control_complete_cb()

31.esm_process()

32.dispatch_cm_cmd_to_the_handler()

33.handle_message()

34.esm_proc_process_pdn_connect_req()

35.esm_build_and_send_pdn_connectivity_req_msg()

36.emm_process_esm_data_req()

37.emm_start_attach_procedure()

三、主要日志打印


一、代码流程图

      CM                  REG          SM                   MM                       RRC

                                 LTE_RRC_SERVICE_IND
    <--------------------------------------------------------------------------------
1.cmtask_handle_sigs()                                  3.mm_emm_normal_msg_handler()
      ||                                                     ||
      \/                                                     \/
2.cm_msgr_handle()                                      4.emm_process_rrc_primitive()
                                                             ||
                                                             \/
                                                        5.emm_rrc_process_service_indication()
                                                             ||
                                                             \/
                                                        6.emm_deregistered_process_rrc_service_ind()
                                                             ||
                                                             \/
                        9.reg_state_main() <-------|    7.emm_attach_needed_rrc_service_ind()
                               ||                  |         ||
                               \/                  |         \/
                        10.process_mmr_camped_ind()|----8.emm_send_reg_camped_ind()
                               ||                       18.emm_chk_ta_change()
                               \/                       19.emm_init_attach_procedure()
12.cmtask_handle_sigs()<- 11.reg_send_cm_camped_ind()        ||
      ||                                                     ||
      \/                                                     ||
13.cm_rpt_handle()                                           ||
      ||                                                     ||  
      \/                                                     ||          
14.cm_wrpt_handle()                                          ||
      ||                                                     ||
      \/                                                     ||
15.cmregprx_rpt_proc()                                       ||    
      ||                                                     \/
      \/                     21.handle_emm_message() <- 20.emm_build_and_send_get_pdn_connectivity_req_ind()
16.cmregprx_camped_ind_hdlr()            ||               
      ||                                 ||
      \/                                 ||
17.cmregprx_active_camped_ind_hdlr()     || 
                                         \/
23.cmltecall_rpt_proc() <------  22.esm_build_and_send_get_pdn_connectivity_req_ind()
      ||
      \/ 
      DS
      ||
      \/
24.cm_mm_call_cmd_pdn_connectivity_req()
      ||
      \/
25.cmltecall_client_cmd_forward_ll()
      ||
      \/
26.cmltecall_send_requests() ---> 27.handle_message()
                                         ||
                                         \/
29.cmltecall_rpt_proc() <-------  28.esm_build_and_send_pkd_pdn_connectivity_req_msg()
      ||
      \/
30.cmltecall_call_control_complete_cb()->31.esm_process()
                                         ||
                                         \/
                               32.dispatch_cm_cmd_to_the_handler()
                                         ||
                                         \/
                               33.handle_message()
                                         ||
                                         \/
                               34.esm_proc_process_pdn_connect_req()
                                         ||
                                         \/
                               35.esm_build_and_send_pdn_connectivity_req_msg()
                                          |
                                          |------->   36.emm_process_esm_data_req()
                                                            ||
                                                            \/
                                                      37.emm_start_attach_procedure()


二、代码详细流程

1.cmtask_handle_sigs()

    /*
    ** Message Router Q signal
    */
    if ( sigs & CM_MSGR_Q_SIG )
    {
      cm_msgr_handle();
    }

2.cm_msgr_handle()

    else if (CM_MSGR_MSG_LTE_RRC_SERVICE(rpt_ptr->cmd.lte_sys.lte_cell_info.msg_hdr.id))
    {
      CM_MSG_HIGH_1_EXT("MSGR RXD: LTE_RRC_SERVICE_IND, sub %d", asubs_id, asubs_id);
      cmcall_ssac_process_lte_ind(&(rpt_ptr->cmd.lte_sys.lte_cell_info), asubs_id);
      cmss_update_lte_cell_info(&(rpt_ptr->cmd.lte_sys.lte_cell_info), asubs_id);
      cmregprx_process_lte_srv_ind_and_send_avoid_list(&(rpt_ptr->cmd.lte_sys.lte_cell_info), asubs_id);
    }

3.mm_emm_normal_msg_handler()

  else if(sigs & RRC_EMM_CMD_Q_SIG)
  {
    *mm_process_msg_fn_ptr = (void *)emm_process_rrc_primitive; 
  }

4.emm_process_rrc_primitive()
 

    case LTE_RRC_SERVICE_IND:
#ifdef FEATURE_NR5G_SA
      if(mm5g_is_oos_in_connected_state() == TRUE &&
         (mm5g_is_full_rat_in_rrc_inactive_state() == FALSE) &&
         rrc_msgr_cmd->rrc_msgr_cmd.rrc_service_ind.svc_status
                                 == LTE_RRC_SVC_STATUS_AVAILABLE)
      {
        emm_pend_service_indication(
           &rrc_msgr_cmd->rrc_msgr_cmd.rrc_service_ind,
           emm_ctrl_data_ptr);
        mm5g_process_rrc_deact_req(SYS_STOP_MODE_REASON_IRAT);
        *mm_emm_dispatcher_fn_ptr = mm_emm_oos_rlf_msg_handler;
      }
      else
#endif
      {
        emm_rrc_process_service_indication(
          &rrc_msgr_cmd->rrc_msgr_cmd.rrc_service_ind,
          emm_ctrl_data_ptr) ;
      }
      break ;


5.emm_rrc_process_service_indication()

typedef enum
{
  EMM_NULL,
  EMM_DEREGISTERED,
  EMM_REGISTERED_INITIATED,
  EMM_REGISTERED,
  EMM_TRACKING_AREA_UPDATING_INITIATED,
  EMM_SERVICE_REQUEST_INITIATED,
  EMM_DEREGISTERED_INITIATED,
  EMM_INVALID_STATE // FOR INTRNAL USE ONLY
} emm_state_type; 

typedef enum
{
  EMM_DEREGISTERED_NO_IMSI,
  EMM_DEREGISTERED_PLMN_SEARCH,
  EMM_DEREGISTERED_ATTACH_NEEDED,
  EMM_DEREGISTERED_NO_CELL_AVAILABLE,
  EMM_DEREGISTERED_ATTEMPTING_TO_ATTACH,
  EMM_DEREGISTERED_NORMAL_SERVICE,
  EMM_DEREGISTERED_LIMITED_SERVICE,
  EMM_DEGEGISTERED_WAITING_PDN_CONN_REQ,
  EMM_DEGEGISTERED_ECALL_INACTIVE  
} emm_deregistered_substate_type; 
 

  MM_LOG_LF_HIGH(MM_TAG, MM_SUB, "=EMM= RRC_SERVICE_IND -PLMN (%d - %d), TAC %u"
         "  SRV REQ pending %d, "
         "  state = %d  sub_state = %d",
         mcc, mnc, rrc_service_ind->camped_svc_info.tac,
         rrc_service_ind->trans_id,
         EMM_GET_STATE(),
         EMM_GET_SUBSTATE());

  MM_LOG_HF_HIGH(MM_TAG, MM_SUB, "=EMM= RRC_SERVICE_IND - RRC active %d, Cell ID %u, IMS EMC spt %d Div Duplex %d, Detach Reqd %d"
                "CSG Id = %d,  Hybrid cell = %d,  shared num_plmn %d",
                emm_ctrl_data_ptr->rrc_active,
                rrc_service_ind->camped_svc_info.cell_identity,
                rrc_service_ind->camped_svc_info.ims_emergency_support_enabled,
                rrc_service_ind->div_duplex,
                rrc_service_ind->detach_reqd,
                rrc_service_ind->camped_svc_info.csg_info.csg_id,
                rrc_service_ind->camped_svc_info.csg_info.hybrid_cell,
                rrc_service_ind->camped_svc_info.shared_plmn_list.num_plmn);

  MM_LOG_HF_HIGH(MM_TAG, MM_SUB, "=EMM= RRC_SERVICE_IND - blind_redir_after_csfb %d, search done %d"
               " fake cell = %d lte 3gpp release ver 0X%X  ACQ Status = %d"
                "tau_pending_gw_attach %d, radio_cap_update_req %d",
                rrc_service_ind->blind_redir_after_csfb,
                rrc_service_ind->oos_search_done,
                rrc_service_ind->fake_cell,
                rrc_service_ind->lte_3gpp_release_ver,
                rrc_service_ind->acq_status,
                emm_ctrl_data_ptr->tau_pending_gw_attach,
                rrc_service_ind->radio_cap_update_req);
……
    emm_process_lte_paging_cycle(rrc_service_ind->default_paging_cycle, emm_ctrl_data_ptr);
……
  emm_set_high_priority_access(emm_ctrl_data_ptr);
……
    emm_state = EMM_GET_STATE();
    switch(emm_state)
    {
      case EMM_DEREGISTERED:      
        emm_deregistered_process_rrc_service_ind(rrc_service_ind,
                                                 emm_ctrl_data_ptr);
        break ;
      case EMM_REGISTERED_INITIATED:

6.emm_deregistered_process_rrc_service_ind()

    switch(emm_substate)
    {

      case EMM_DEGEGISTERED_WAITING_PDN_CONN_REQ:
        emm_waiting_pdn_conn_req_rrc_service_ind(rrc_service_ind,
                                                 emm_ctrl_data_ptr);
        break ;
      case EMM_DEREGISTERED_PLMN_SEARCH:
        emm_plmn_search_rrc_service_ind(rrc_service_ind,emm_ctrl_data_ptr);
        break;
      case EMM_DEREGISTERED_ATTACH_NEEDED:
        emm_attach_needed_rrc_service_ind(rrc_service_ind,emm_ctrl_data_ptr);
        break ;
      case EMM_DEREGISTERED_NO_CELL_AVAILABLE:
        emm_no_service_rrc_service_ind(rrc_service_ind,emm_ctrl_data_ptr) ;
        break ;
      case EMM_DEREGISTERED_ATTEMPTING_TO_ATTACH:
        emm_attempting_to_attach_rrc_service_ind(rrc_service_ind,
                                                 emm_ctrl_data_ptr);
        break ;
      case EMM_DEREGISTERED_NORMAL_SERVICE:
        emm_normal_service_rrc_service_ind(rrc_service_ind,emm_ctrl_data_ptr) ;
        break ;
      case EMM_DEREGISTERED_LIMITED_SERVICE:
      case EMM_DEREGISTERED_NO_IMSI:
        emm_limited_service_rrc_service_ind(rrc_service_ind,emm_ctrl_data_ptr) ;
        break ;
#ifdef FEATURE_NAS_ECALL		
	  case EMM_DEGEGISTERED_ECALL_INACTIVE:
	  	emm_ecall_inact_rrc_service_ind(rrc_service_ind,emm_ctrl_data_ptr) ;
        break ;
#endif		
      default:
        MSG_FATAL_DS(MM_SUB,"=EMM= Illigal Deregistered substate",0,0,0) ;
        break ;
    }

7.emm_attach_needed_rrc_service_ind()

……
      switch(emm_ctrl_data_ptr->reg_req_pending_ptr->network_selection_mode)
      {
        case SYS_NETWORK_SELECTION_MODE_AUTOMATIC:
        case SYS_NETWORK_SELECTION_MODE_LIMITED_ROUTINE_ACQUISITION:
          emm_failure_cause.cause_type = LTE_NAS_IRAT_INVALID_STATE;
          if(emm_policy_change_pending(rrc_service_ind) == TRUE)
          {
            emm_send_reg_attach_failed_ind();
            return;
          }
          if((((emm_is_plmn_forbidden(rrc_reported_plmn,
                                  (sys_modem_as_id_e_type)mm_sub_id) == FALSE)&&
             (emm_is_tai_forbidden(tai,emm_ctrl_data_ptr)== FALSE) &&
             (emm_check_reg_allowance_limited_routine(emm_ctrl_data_ptr, rrc_service_ind->camped_svc_info.selected_band) == TRUE)
#ifdef FEATURE_FEMTO_CSG
             && (mm_is_csg_in_white_list(rrc_reported_plmn, &rrc_reported_csg) == TRUE)
#endif 
             )
#ifdef FEATURE_FEMTO_CSG
            || (emm_is_manual_csg_selection_success(emm_ctrl_data_ptr) == TRUE)
#endif
            )
            &&
             (emm_validate_attach_plmn(emm_ctrl_data_ptr,&tai.plmn) == TRUE) &&
             (rrc_service_ind->camped_svc_info.cell_access_status != 
                                           LTE_RRC_CELL_ACCESS_EMERGENCY_ONLY)
            )
          {
            emm_send_reg_camped_ind(SYS_RAT_LTE_RADIO_ACCESS, 
                                 rrc_service_ind->camped_svc_info, MMR_POLICY_CHANGE_NONE);

            emm_check_and_update_rat_pri_list(emm_ctrl_data_ptr);

#ifdef FEATURE_NAS_ECALL 			
			if(*emm_ctrl_data_ptr->ecall_mode_type == MMR_ECALL_MODE_ECALL_ONLY &&
				emm_ctrl_data_ptr->ecall_timer_resume_attach_pending == FALSE && 
				emm_ctrl_data_ptr->reg_req_pending_ptr->type != MMR_REG_REQ_SRV_MODE_UPDATE &&
  	            emm_bit_mask_check(emm_ctrl_data_ptr->reg_req_pending_ptr->additional_info,(byte)SYS_ADDTNL_INFO_SKIP_NGECALL_PRIORITIZATION) == FALSE &&
				mm_timer_status[TIMER_T3242] == TIMER_STOPPED &&
  	            mm_timer_status[TIMER_T3243] == TIMER_STOPPED
  	           )
			{
			  // EMM will be in in dereg attach needed state, even in the case when we come from W to L, with only non EPS registration 
			  // present in W RAT. In such case, if inactivity timers are running in W, we need to re-start timers and re-start attach.
              // 24301: 5.1.5 Coordination between EMM and MM
              // If the UE is configured for eCall only mode as specified in 3GPP TS 31.102 [17] and moves from GERAN/UTRAN to E-UTRAN, the UE shall:
              // - if timer T3242 is running, start timer T3444 with the time left on T3242 and stop timer T3242;
              // - if timer T3243 is running, start timer T3445 with the time left on T3243 and stop timer T3243;
              // - if the UE is attached for non-EPS services only and timer T3242 or timer T3243 is running, perform a combined attach procedure.	
			  EMM_MOVES_TO_DEREGISTERED_STATE(EMM_DEGEGISTERED_ECALL_INACTIVE);
			  emm_ctrl_data_ptr->plmn_service_state->ecl_support = TRUE;
			  emm_ctrl_data_ptr->plmn_service_state->service_status = 
                                                        SYS_SRV_STATUS_LIMITED;
			  emm_ctrl_data_ptr->plmn_service_state->extend_srv_info = 
                                         SYS_EXTEND_SRV_INFO_FULL_SRV_POSSIBLE;											
              reg_service_report(MMR_CAUSE_FAILURE_REMAIN_ON_PLMN,FALSE,emm_ctrl_data_ptr);
			  return;
			}
			emm_restart_ecall_timers(emm_ctrl_data_ptr);
#endif
            if((emm_chk_ta_change(rrc_service_ind, emm_ctrl_data_ptr) == FALSE) &&
               ((emm_ctrl_data_ptr->emm_attach_attempt_counter >0)&&
               (emm_ctrl_data_ptr->emm_attach_attempt_counter < MAX_NUMBER_ATTACH_OF_ATTEMPTS)))
            {
              emm_init_attach_procedure(EMM_UPDATE_RECOVERY, emm_ctrl_data_ptr);
            }
            else
            {
              if (sys_plmn_match(tai.plmn,emm_ctrl_data_ptr->last_attempted_tai.plmn) != TRUE) 
              {
                emm_release_attach_pdn_conn_req(emm_ctrl_data_ptr, emm_failure_cause);
              }
              emm_init_attach_procedure(EMM_INITIAL_UPDATE, emm_ctrl_data_ptr);
            }
          }

8.emm_send_reg_camped_ind()

  mmr_camped_ind_s_type                     camped_ind;
  log_lte_nas_emm_outgoing_msg_event_type   event;

  camped_ind.message_header.message_set = MS_MM_REG;
  camped_ind.message_header.message_id  = (int)MMR_CAMPED_IND;

  camped_ind.active_rat = active_rat;

  SYS_LTE_BAND_MASK_CLR_ALL_BANDS(&camped_ind.active_band.lte_active_band);
  
  SYS_LTE_BAND_MASK_ADD_BAND(&camped_ind.active_band.lte_active_band,camped_svc_info.selected_band); 

  camped_ind.plmn = emm_convert_rrc_plmn_id_to_nas_plmn_id(camped_svc_info.selected_plmn);

  camped_ind.lac_id = (sys_lac_type)camped_svc_info.tac;
  camped_ind.policy_change_pending = policy_change_pending;
  camped_ind.high_priority_access = emm_check_high_priority(emm_db_get_ctrl_data());
  camped_ind.primary_plmn = emm_convert_rrc_plmn_id_to_nas_plmn_id(camped_svc_info.shared_plmn_list.shared_plmn[0].plmn);
  PUT_IMH_LEN( sizeof( mmr_camped_ind_s_type ) - sizeof(IMH_T), &camped_ind.message_header );


  MM_LOG_HF_HIGH(MM_TAG, MM_SUB, "MM sent MMR_CAMPED_IND RAT: %d, BAND %u",
                camped_ind.active_rat,
                camped_svc_info.selected_band);

  mm_send_message( (IMH_T*)&camped_ind, GS_QUEUE_REG );
  event.emm_out_msg = (byte)MMR_CAMPED_IND;
  nas_event_report_payload(EVENT_LTE_REG_OUTGOING_MSG,
				sizeof(event), (void*)&event,mm_message_as_id);

9.reg_state_main()

        case MMR_CAMPED_IND:
          if ( mmr_camped_ind_is_valid(&(reg_cmd_p->cmd.mmr_camped_ind)) )
          {
            reg_state_next_p = reg_state_curr_p->process_mmr_camped_ind
            (
              &(reg_cmd_p->cmd.mmr_camped_ind)
            );
          }
          else
          {
            REG_LOG_HF_HIGH(REG_TAG, REG_SUB, "=REG= MMR_CAMPED_IND - Invalid");
          }
          break;

10.process_mmr_camped_ind()

  rplmn = reg_sim_read_rplmn(reg_mode_req_service_domain_get());
……
  reg_send_cm_camped_ind
  (
#ifndef FEATURE_GSM_BAND_PREF
    msg_p->active_rat
#else
    msg_p->active_rat,
    msg_p->active_band
#endif
    ,msg_p->plmn
    ,msg_p->lac_id
#ifdef FEATURE_NR5G_SA
    ,msg_p->tac_5g
#endif
    ,msg_p->high_priority_access,
    msg_p->primary_plmn
  );

11.reg_send_cm_camped_ind()


……
  msg.message_header.message_set     = MS_CM_REG;
  msg.message_header.message_id      = (byte)CM_CAMPED_IND;
……
    REG_LOG_HF_HIGH(REG_TAG, REG_SUB, "=REG= CM_CAMPED_IND PLMN (%d - %d) "
                                   "Primary PLMN (%d - %d)",
                   mcc, mnc, primary_mcc, primary_mnc);
  }

  reg_send_message(&msg, GS_QUEUE_CM);

#ifdef FEATURE_UMTS_BMC_MSIM
  reg_send_cb_service_ind(SYS_SRV_STATUS_LIMITED,FALSE,active_rat,FALSE);
#endif

12.cmtask_handle_sigs()

    /*
    ** Report signal (MC/SD20/MN/REG/SM/RABM)
    */
    if( sigs & CM_RPT_Q_SIG )
    {
      /* Handle commands on queue till the queue is empty */
      cm_rpt_handle( );
    }

13.cm_rpt_handle()

    else if ( CMLL_RPT_IS_GW( rpt_ptr->cmd ) )
    {
      /* Lint complains about suspicious cast, should have complained on
      ** previous _handle() functions too. Probably didn't because mc_rpt_type &
      ** sd_rpt_u_type have embedded cm_hdr_type in each of its members.
      ** However, this warning should be ignored.
      */
      /*lint -save -e740 */
      cm_wrpt_handle( rpt_ptr );
      /*lint -restore */
    }

14.cm_wrpt_handle()

  /* Do phone, call, and serving system inband and SMS context processing.
  */
  (void)cmregprx_rpt_proc( rpt_ptr );
  cmph_rpt_proc(rpt_ptr);
  cmss_rpt_proc(rpt_ptr);

15.cmregprx_rpt_proc()

    case CM_CAMPED_IND:
      cmregprx_camped_ind_hdlr( cm_rpt_ptr,
                                cmregprx_info_ptr
                              );
      break;

16.cmregprx_camped_ind_hdlr()

  /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  cmregprx_stack_info_ptr = cmregprx_map_as_id_to_stack_info(
                              cmregprx_info_ptr,
                              rpt_ptr->cmd.camped_ind.as_id,
                              rpt_ptr->cmd.camped_ind.stack_id,
                              rpt_ptr->hdr.cmd
                            );
  CMREGPRX_MSG_HIGH_2("NAS->CMREG: sub %d stk %d, CM_CAMPED_IND",
                      rpt_ptr->cmd.camped_ind.as_id,
                      cmregprx_stack_info_ptr->mm_id.stk_id);

#ifdef FEATURE_CM_DEBUG_BUFFER
  cmdbg_add_to_dbg_buffer(CM_BUFF_RPT_TYPE, CM_CAMPED_IND, ((void *)&(rpt_ptr->cmd.camped_ind)));
#endif

  /* Invoke the appropriate state specific event handlers.
  */
  switch (cmregprx_stack_info_ptr->state)
  {

    case CMREGPRX_STATE_ACTIVE:
      cmregprx_active_camped_ind_hdlr( rpt_ptr,
                                       cmregprx_stack_info_ptr
                                     );
      break;

    case CMREGPRX_STATE_DORMANT:
    case CMREGPRX_STATE_INACTIVE:
    case CMREGPRX_STATE_MAX:
    default:
      /* ERR: Should receive this report only in ACTIVE state.
      */
      CMREGPRX_MSG_HIGH_1("Received camped ind in wrong state %d",
                          cmregprx_stack_info_ptr->state);

      break;

17.cmregprx_active_camped_ind_hdlr()

……
    is_stack_active = TRUE;
    CMREGPRX_MSG_HIGH_6("CMREG->PM: PM callback: sub %d stk %d, cmss stack %d, srv_status=%d, intl_srv_status=%d, no_srv_uptime=%d",
                        camp_ind.asubs_id, mm_id.stk_id, camp_ind.stack, 
                        camp_ind.srv_status,
                        ss_true_stk_ptr->srv_status,
                        cmss_get_no_srv_uptime(mm_id));
    policyman_cm_serving_info_cb(&camp_ind);
……
    sys_srv_status_e_type         srv_status = SYS_SRV_STATUS_NONE;

    cmss_get_camped_srv_info(cmregprx_stack_info_ptr->mm_id, &srv_status);
    if(cmregprx_send_plmn_info_to_pm_and_fetch_call_mode(
          cmregprx_stack_info_ptr->mm_id, srv_status))
    {
      sys_plmn_id_s_type plmn_t = rpt_ptr->cmd.camped_ind.plmn;
      sys_modem_as_id_e_type subs_id = cmregprx_stack_info_ptr->mm_id.asubs_id;

      cmmsc_set_stack_common_call_mode_per_subs(policyman_get_call_mode(subs_id, &plmn_t), subs_id);
      cmemg_send_call_mode_ind(subs_id,cmmsc_get_stack_common_call_mode_per_subs(subs_id), FALSE);
      /* update SD about new call Mode as well */
      sd_ss_update_call_mode(subs_id,
                             cmmsc_get_stack_common_call_mode_per_subs(subs_id));
    }
  }
……
  CMREGPRX_MSG_MED_0 ("Allocated camped ind and copied");
……
  /* Inform System determination of camped indication and follow return
  ** action.
  */
  cmregprx_process_sd_action( cmregprx_map_camped_ind_to_sd_ind
                                ( rpt_ptr->cmd.camped_ind.active_rat,
                                  active_band,
                                  cmregprx_stack_info_ptr
                                ),
                                cmregprx_stack_info_ptr, NULL
                              );

18.emm_chk_ta_change()
 

  MM_LOG_HF_HIGH(MM_TAG, MM_SUB,"=EMM= TAI change - %d (Srving TAI vs Last attempted TAI)",
                result);


19.emm_init_attach_procedure()

  ASSERT(emm_ctrl_data_ptr != (emm_ctrl_data_type *)NULL) ;

  if(attach_attemp_type == EMM_INITIAL_UPDATE)
  {
    emm_ctrl_data_ptr->emm_attach_rej_esm_fail_counter = 0;
    emm_ctrl_data_ptr->apn_switch = FALSE;
  }

  emm_set_rau_pending_in_conn_mode(FALSE);

  if(emm_ctrl_data_ptr->pdn_conn_req_trans_id == 
                                             EMM_INVALID_PDN_CONN_REQ_TRANS_ID)
  {
    /* Cached PDN_CONNECTIVITY_REQ is not reusable. Try to get a new one. */
    MM_LOG_HF_HIGH(MM_TAG, MM_SUB, "=EMM= Send request to get PDN_CONNECTIVITY_REQ message");
    /* Send NAS_ESM_GET_PDN_CONNECTIVITY_REQ_IND */
    emm_build_and_send_get_pdn_connectivity_req_ind(emm_ctrl_data_ptr);
    /* Update EMM state */
    EMM_MOVES_TO_DEREGISTERED_STATE(EMM_DEGEGISTERED_WAITING_PDN_CONN_REQ);
  }
  else
  {
    /* Cached PDN_CONNECTIVITY_REQ is reusable. Start attach procedure. */
      MM_LOG_HF_HIGH(MM_TAG, MM_SUB, "=EMM= Start attach procedure with cached PDN_CONNECTIVITY_REQ");
    emm_start_attach_procedure(attach_attemp_type, emm_ctrl_data_ptr);
  }

20.emm_build_and_send_get_pdn_connectivity_req_ind()

  if(emm_msgr_send((msgr_hdr_s *)&get_pdn_connectivity_req_ind,
               sizeof(get_pdn_connectivity_req_ind)) 
     != E_SUCCESS)
  {
    MSG_FATAL_DS(MM_SUB, "=EMM= Failed to send NAS_ESM_GET_PDN_CONNECTIVITY_REQ_IND!", 
               0,0,0 );
  } 
  else
  {
    MM_LOG_HF_HIGH(MM_TAG, MM_SUB, "=EMM= Sent NAS_ESM_GET_PDN_CONNECTIVITY_REQ_IND w/ Seq Num %d",
                  get_pdn_connectivity_req_ind.seq_num);
    event.emm_out_msg = (dword)NAS_ESM_GET_PDN_CONNECTIVITY_REQ_IND;
    nas_event_report_payload(EVENT_LTE_EMM_OUTGOING_MSG,
                        sizeof(event), (void*)&event,mm_message_as_id);
  }

21.handle_emm_message()

    case NAS_ESM_GET_PDN_CONNECTIVITY_REQ_IND:
      /* To start attach procedure from scratch, need to clean up all contexts */
      local_cause.local_cause = EMM_DETACHED;
      local_cause.valid = TRUE;
      esm_bcm_clean_up(mgr_ptr,local_cause
#ifdef FEATURE_NR5G_SA
      ,TRUE
#endif
                       ); 
      esm_build_and_send_get_pdn_connectivity_req_ind(
                            cmd_ptr->cmd.esm_get_pdn_connectivity_req.seq_num,
                            cmd_ptr->cmd.esm_get_pdn_connectivity_req.responding_to_page);
      break;

22.esm_build_and_send_get_pdn_connectivity_req_ind()

  e_retval = esm_msgr_send( (msgr_hdr_s*)cm_msg_ptr, sizeof(cm_get_pdn_connectivity_request_ind_s_type) );

  ASSERT(e_retval == E_SUCCESS);

  SM_LOG_LF_HIGH(SM_TAG, SM_SUB, "ESM: ESM sent MM_CM_GET_PDN_CONNECTIVITY_REQUEST_IND seq no %d,responding_to_page %d", seq_num, responding_to_page);

  event.esm_out_msg = (dword)MM_CM_GET_PDN_CONNECTIVITY_REQUEST_IND;
  nas_event_report_payload(EVENT_LTE_CM_OUTGOING_MSG,sizeof(event), (void*)&event,sm_message_as_id);


23.cmltecall_rpt_proc()

    case MM_CM_GET_PDN_CONNECTIVITY_REQUEST_IND:
      #ifdef MMODE_QTRACE
      MMODE_MSG_DBG(CM_TAG, asubs_id, "4GNAS->CM: id 0x%x, GET_PDN_CONNECTIVITY_REQUEST_IND, sub %d",
                       cm_rpt_ptr->msg_hdr.id,
                       asubs_id);
      #endif
      cmcall_event_2( NULL,
                      CM_CALL_EVENT_GET_PDN_CONN_IND,
                      cm_rpt_ptr,
                      asubs_id);


      break;

-> DS ->

24.cm_mm_call_cmd_pdn_connectivity_req()

  /* Copy command header fields. */
  call_cmd_ptr->cmd_cb_func     = cmd_cb_func;
  call_cmd_ptr->data_block_ptr  = data_block_ptr;
  call_cmd_ptr->client_id       = client_id;
  call_cmd_ptr->cmd             = CM_CALL_CMD_PDN_CONNECTIVITY_REQ;
  call_cmd_ptr->cmd_subs        = pdn_connectivity_ptr->asubs_id;

  /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /* Copy command information fields. */
  cmd_info_ptr                  = CMD_INFO_PTR( call_cmd_ptr );

  cmd_info_ptr->lte_info.sdf_id = pdn_connectivity_ptr->sdf_id;
  cmd_info_ptr->lte_info.request_type = pdn_connectivity_ptr->request_type;
  cmd_info_ptr->lte_info.as_id  = pdn_connectivity_ptr->asubs_id;

  *(&(cmd_info_ptr->lte_info.pdn_data)) = *(&(pdn_connectivity_ptr->pdn_data));


  CM_MSG_HIGH_3("cm_mm_call_cmd_pdn_connectivity_req(), lps = %d, sdf_id %d, sub %d",\
               pdn_connectivity_ptr->pdn_data.low_priority_signaling,
               pdn_connectivity_ptr->sdf_id,
               pdn_connectivity_ptr->asubs_id);

  /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /* Queue the commands to CM.
  */
  cm_cmd_queue( (cm_cmd_type *)call_cmd_ptr );

  return TRUE;

25.cmltecall_client_cmd_forward_ll()

    case CM_CALL_CMD_PDN_CONNECTIVITY_REQ:
    case CM_CALL_CMD_PDN_CONNECTIVITY_ABORT_REQ:
    case CM_CALL_CMD_PDN_DISCONNECT_REQ:
    case CM_CALL_CMD_RES_ALLOC_REQ:
    case CM_CALL_CMD_RES_ALLOC_ABORT_REQ:
    case CM_CALL_CMD_BEARER_RES_MOD_REQ:

      cmltecall_send_requests (call_cmd_ptr);

      break;

26.cmltecall_send_requests()

  #ifdef MMODE_QTRACE
  MMODE_MSG_DBG(CM_TAG, call_cmd_ptr->info.lte_info.as_id, "CM->4GNAS: sub %d, Send LTE callcmd %d, call_id %d, oprt_mode %d, active_subs %d",
                   call_cmd_ptr->info.lte_info.as_id,
                   call_cmd_ptr->cmd,
                   call_cmd_ptr->info.call_id,                   
                   cmph_ptr()->device_prop.ph_oprt_mode.oprt_mode,
                   cmph_ptr()->device_prop.msim_prop.active_subs);
  #endif
  
  switch( call_cmd_ptr->cmd )
  {
    case CM_CALL_CMD_PDN_CONNECTIVITY_REQ:

      /*
      **  Ensure that the conn_id that ESM expects does not have
      **  garbage value in this message. So CM sets 0xff, Need to discuss.
      */
      client_request->esm_pdn_connectivity_req.esm_hdr.connection_id = \
          CM_UNKNOWN_CONN_ID;

      client_request->esm_pdn_connectivity_req.esm_hdr.sdf_id = \
          call_cmd_ptr->info.lte_info.sdf_id;

      client_request->esm_pdn_connectivity_req.request_type = \
          call_cmd_ptr->info.lte_info.request_type;

      *(&client_request->esm_pdn_connectivity_req.pdn_data) = \
          *(&(call_cmd_ptr->info.lte_info.pdn_data));

      CM_MSG_HIGH_4("CM_CALL_CMD_PDN_CONNECTIVITY_REQ, epco_valid %d, lps %d, sdf_id %d, sub %d",
                   call_cmd_ptr->info.lte_info.pdn_data.ext_protocol_cfg_opt.valid,
                   call_cmd_ptr->info.lte_info.pdn_data.low_priority_signaling,
                   call_cmd_ptr->info.lte_info.sdf_id,
                   call_cmd_ptr->info.lte_info.as_id);

      (void) cm_msgr_send( NAS_ESM_PDN_CONNECTIVTY_REQ, MSGR_MM_CM,
                           (msgr_hdr_s *)client_request, sizeof(esm_msg),
                           call_cmd_ptr->info.lte_info.as_id);

      break;

27.handle_message()

    case NAS_ESM_PDN_CONNECTIVTY_REQ:
#ifdef FEATURE_LTE_REL9 
      if(esm_chk_pdn_conn_allowance(&cmd_ptr->cmd.esm_pdn_connectivity_req, 
                                     mgr_ptr) == FALSE)
      {
        esm_build_and_send_pdn_connectivity_reject_ind(
          NULL, cmd_ptr->cmd.esm_pdn_connectivity_req.esm_hdr.sdf_id,
          NULL, ESM_LOCAL_CUASE_NONE, NULL);
        return TRUE;      
      }
#endif
      event.esm_in_msg = (dword)NAS_ESM_PDN_CONNECTIVTY_REQ;
      nas_event_report_payload(EVENT_LTE_CM_INCOMING_MSG,
                      sizeof(event), (void*)&event,sm_message_as_id);
      proc_ptr = esm_get_free_proc_instance_and_pti(mgr_ptr);
      ASSERT (proc_ptr != NULL);

      if (cmd_ptr->cmd.esm_get_pdn_connectivity_req.seq_num == mgr_ptr->esm_emm_attach_seq_num)
	  {
	    mgr_ptr->esm_emm_attach_seq_num = 0xFF;
	  }

      SM_LOG_LF_HIGH(SM_TAG, SM_SUB, "ESM: Rcved PDN CONN REQ - Seq num %d, Req type %d",
                    cmd_ptr->cmd.esm_pdn_connectivity_req.pdn_data.seq_num,
                    cmd_ptr->cmd.esm_pdn_connectivity_req.request_type);

#ifdef FEATURE_LTE_UICC_CALL_CONTROL
      if(emm_check_if_pdn_conn_req_for_emergency_bearer_services(cmd_ptr->cmd.esm_pdn_connectivity_req.request_type) )
      {
        /* Skip call cotrol for emergency PDN CONN REQ */
        proc_ptr->esm_proc_state_ptr->esm_proc_process_pdn_connect_req
                           (proc_ptr,&(cmd_ptr->cmd.esm_pdn_connectivity_req));
      }
      else
      {
        /* Perform call control */
        esm_build_and_send_pkd_pdn_connectivity_req_msg(
                            proc_ptr,&(cmd_ptr->cmd.esm_pdn_connectivity_req));
      }
#else
      proc_ptr->esm_proc_state_ptr->esm_proc_process_pdn_connect_req(proc_ptr,&(cmd_ptr->cmd.esm_pdn_connectivity_req));
#endif

      /*hnam*/
      esm_proc_state_info_log.instance_id = proc_ptr->instance_id;  
      esm_proc_state_info_log.proc_state = (byte)proc_ptr->esm_proc_state_ptr->state();
      esm_proc_state_info_log.pti = (byte)proc_ptr->pti;
      esm_proc_state_info_log.sdf_id = (byte)proc_ptr->sdf_id;
      ASSERT(proc_ptr->pending_msg_ptr != NULL);
      esm_proc_state_info_log.pending_msg_id = (byte)proc_ptr->pending_msg_ptr->msg_hdr.id;

      send_esm_proc_state_log_info(&esm_proc_state_info_log);
      break;

28.esm_build_and_send_pkd_pdn_connectivity_req_msg()

  proc_ptr->pending_msg_ptr->esm_out_msg.nas_hdr.msg_id = 
                                                      PDN_CONNECTIVITY_REQUEST;
……
  /*=======================================================================
                Build PKD_PDN_CONNECTIVITY_REQ structure
  =======================================================================*/
  /*Reset the PKD_PDN_CONNECTIVITY_REQ structure*/
  
  /* Init the MSGR header*/
  msgr_init_hdr(&(cm_pkd_pdn_connectivity_req->msg_hdr),
                MSGR_NAS_ESM,MM_CM_PDN_CONNECTIVITY_PACKED_REQUEST_IND);
  /*Call the MSG_LIB function to pack this message and 
    hence send it to CM for validation*/
……
  /*=====================================================================
             Send PKD_PDN_CONNECTIVITY_REQ structure to CM
  =====================================================================*/
  e_retval = esm_msgr_send( (msgr_hdr_s*)cm_pkd_pdn_connectivity_req, sizeof(cm_pdn_connectivity_packed_request_ind_s_type) );
  ASSERT(e_retval == E_SUCCESS);
  SM_LOG_LF_HIGH(SM_TAG, SM_SUB, "ESM: ESM sent MM_CM_PDN_CONNECTIVITY_PACKED_REQUEST_IND");

29.cmltecall_rpt_proc()

    case MM_CM_PDN_CONNECTIVITY_PACKED_REQUEST_IND:
    {
……
      #ifdef MMODE_QTRACE
      MMODE_MSG_DBG(CM_TAG, asubs_id, "4GNAS->CM: id 0x%x, PDN_CONNECITIVITY_PACKED_REQUEST_IND, asubs_id=%d, pti=%d, sdf_id %d",
                       cm_rpt_ptr->msg_hdr.id,
                       lte_ps_cc_params_ptr->as_id, 
                       lte_ps_cc_params_ptr->pti,
                       lte_ps_cc_params_ptr->sdf_id);
      #endif
……
      /* Start call control */
      memset(&ps_cc_params, 0, sizeof(ps_cc_params));
      ps_cc_params.asubs_id = asubs_id;
      ps_cc_params.mode = SYS_SYS_MODE_LTE;
      ps_cc_params.call_id = CM_CALL_ID_INVALID;
      ps_cc_params.cm_cc_cb_func = cmltecall_call_control_complete_cb;
      ps_cc_params.lte_cc_ptr = lte_ps_cc_params_ptr;
      
      ret_val = cmcc_proc_mm_cc_req(&ps_cc_params);

      CM_MSG_HIGH_1("cmcc_call_control_processing_lte return %d",ret_val);

      if (!ret_val)

30.cmltecall_call_control_complete_cb()

  /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  CM_MSG_HIGH_3("cmltecall_call_control_complete_cb(), call_id=%d,status=%d,call_type=%d",
                call_id,status,call_type);

  /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

……
  /* Send NAS_ESM_PDN_CONNECT_PACKED_CNF to ESM */

  /* sdf id */
  pdn_packed_cnf->esm_pdn_connectivity_pkd_cnf.esm_hdr.sdf_id =
    gw_call_control_info_ptr->lte_ps_cc_params->sdf_id;

  /* connection_id */
  pdn_packed_cnf->esm_pdn_connectivity_pkd_cnf.esm_hdr.connection_id = 0xFF;

  CM_MSG_HIGH_3_EXT("lt cc cb: as_id=%d, ps_cc_sys_mode=%d, call_control_result=%d",
                    gw_call_control_info_ptr->lte_ps_cc_params->as_id,
                    gw_call_control_info_ptr->ps_cc_sys_mode,
                    gw_call_control_info_ptr->call_control_result,
                    gw_call_control_info_ptr->lte_ps_cc_params->as_id);

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
……
  CM_MSG_MED_2("CM->4GNAS: Send: NAS_ESM_PDN_CONNECT_PACKED_CNF, status=%d, pti=%d",
               pdn_packed_cnf->esm_pdn_connectivity_pkd_cnf.status,
               pdn_packed_cnf->esm_pdn_connectivity_pkd_cnf.pti);

  (void) cm_msgr_send( NAS_ESM_PDN_CONNECT_PACKED_CNF, MSGR_MM_CM,
                       (msgr_hdr_s *)pdn_packed_cnf, sizeof(esm_msg),
                       gw_call_control_info_ptr->lte_ps_cc_params->as_id);

31.esm_process()

  if((esm_cmd_ptr->cmd.msg_hdr.id == NAS_ESM_PDN_CONNECT_PACKED_CNF) &&
     (esm.esm_context_mgr.on_attach_def_bearer_pending == ESM_BC_ON_ATTACH_DEF_BEARER_PENDING))
  {
    SM_LOG_HF_HIGH(SM_TAG, SM_SUB, "ESM: received NAS_ESM_PDN_CONNECT_PACKED_CNF from CM");
  }
……
  switch (esm_cmd_ptr->cmd.msg_hdr.src) //Figure out based on the sender?
  {
    case MSGR_MM_CM:
      SM_LOG_HF_HIGH(SM_TAG, SM_SUB, "ESM: Message from the CM received");
      dispatch_cm_cmd_to_the_handler ( esm_cmd_ptr);
      break;

32.dispatch_cm_cmd_to_the_handler()

  //ESM_PRINT_MSG(esm_cmd_ptr);
  if(hdr_ptr->connection_id != ESM_INVALID_CON_ID)
  {
    esm.esm_context_mgr.handle_cm_message_ptr(
                              esm_cmd_ptr,&(esm.esm_context_mgr),hdr_ptr->connection_id );
  }
  else
  {
    /* There are two cases. 
    1. The connection id is invalid i.e there is no context yet
    2. The connection id is valid, but is generated by the CM. In this case also there is no context yet
    */
    result = esm.esm_proc_mgr.handle_message_ptr(esm_cmd_ptr,&(esm.esm_proc_mgr) );
    if(result == FALSE)
    {
      SM_LOG_HF_ERROR(SM_TAG,SM_SUB, "ESM: esm_dispatch_cm_cmd_to_the_handler failed\n");
    }
    if((esm_cmd_ptr->cmd.msg_hdr.id == NAS_ESM_PDN_CONNECTIVTY_REQ) &&
       (esm.esm_context_mgr.on_attach_def_bearer_pending == ESM_BC_ON_ATTACH_DEF_BEARER_NONE))
    {
      esm.esm_context_mgr.on_attach_def_bearer_pending = ESM_BC_ON_ATTACH_DEF_BEARER_PENDING;
    }
  }

根据
  mgr_ptr->handle_message_ptr = handle_message;

33.handle_message()

  switch (cmd_ptr->cmd.msg_hdr.id)
  {
    case NAS_ESM_PDN_CONNECT_PACKED_CNF:
      SM_LOG_LF_HIGH(SM_TAG, SM_SUB, "ESM: MSG_ID == NAS_ESM_PDN_CONNECT_PACKED_CNF, PACKED_CNF status = %d", cmd_ptr->cmd.esm_pdn_connectivity_pkd_cnf.status);
      proc_ptr = esm_bpm_find_uicc_proc_state_machine(mgr_ptr,
                                                      cmd_ptr->cmd.esm_pdn_connectivity_pkd_cnf.pti);
……
          /* Send PDN_CONNECTIVITY_REQ message to EMM, 
             to be encoded and sent Over The Air*/ 
          proc_ptr->esm_proc_state_ptr->esm_proc_process_pdn_connect_req(proc_ptr,&(cmd_ptr->cmd.esm_pdn_connectivity_req));    
          break;

34.esm_proc_process_pdn_connect_req()

  boolean status = FALSE;
  /*
       1. Check the message type to figure out what message is received
       2. Call the apprpriate static handler function for that message
       3. Return the proper state pointer back to the caller.
  */
  proc_ptr->sdf_id = msg_ptr->esm_hdr.sdf_id;
  esm_build_and_send_pdn_connectivity_req_msg(proc_ptr,msg_ptr);
  /* If not combined in attach procedure, start timer 3482 */
  if(proc_ptr->chk_on_attach_def_bc_setup_ptr() == TRUE)
  {
    status = esm_start_timer(ESM_TIMER_T3482,proc_ptr);
    ASSERT(status == TRUE);
  }
  proc_ptr->esm_proc_state_ptr = &esm_proc_state_active;


35.esm_build_and_send_pdn_connectivity_req_msg()

  esm_build_pdn_connectivity_msg(proc_ptr, msg_ptr, &(out_msg_ptr->esm_out_msg));

  e_retval = esm_msgr_send( &out_msg_ptr->msg_hdr, sizeof(emm_data_req_T) );
  ASSERT(e_retval == E_SUCCESS);
  SM_LOG_HF_HIGH(SM_TAG, SM_SUB, "ESM: Sends NAS_EMM_DATA_REQ carrying PDN_CONNECTIVITY_REQUEST");

36.emm_process_esm_data_req()

  MM_LOG_LF_HIGH(MM_TAG, MM_SUB,"=EMM= Rcved NAS_EMM_DATA_REQ state = %d, substate = %d,"
                 " emc_status=%d connection_state = %d, ESM message_id = %d, TIMER_T3346 = %d",
                 emm_state, emm_substate, *emm_ctrl_data_ptr->emc_srv_status,
                 EMM_GET_CONNECTION_STATE(),
                 emm_data_request->esm_out_msg.nas_hdr.msg_id,
                 mm_timer_status[TIMER_T3346]);
……
    case EMM_DEREGISTERED:
      MM_LOG_HF_HIGH(MM_TAG, MM_SUB, "=EMM= ESM DATA REQ - Msg %d, DEREG %d state, REG REQ pending %d",
                emm_data_request->esm_out_msg.nas_hdr.msg_id, 
                emm_substate,
                emm_ctrl_data_ptr->reg_req_pended_indication);

      /* Check if the data req is PDN CONNECTIVITY REQ message AND EMM is 
         waiting for it. If so, cache it and start initial type of attach 
         procedure */
      if((emm_substate == EMM_DEGEGISTERED_WAITING_PDN_CONN_REQ ||
          (emm_substate == EMM_DEREGISTERED_ATTACH_NEEDED && 
           emm_ctrl_data_ptr->reg_req_pended_indication == TRUE))
         &&
         (emm_data_request->esm_out_msg.nas_hdr.msg_id == 
                                                     PDN_CONNECTIVITY_REQUEST))
      {
        if(emm_data_request->esm_out_msg.pdn_connectivity_req.seq_num == 
                                         emm_ctrl_data_ptr->attach_pdn_seq_num)
        {
          /* Cache the PDN_CONNECTIVITY_REQ message */
          *(emm_ctrl_data_ptr->pdn_conn_req_ptr) = 
                          emm_data_request->esm_out_msg.pdn_connectivity_req;
  
          /* Save the transaction ID */
          emm_ctrl_data_ptr->pdn_conn_req_trans_id = 
                                          emm_data_request->emm_transaction_id;

          /* Start attach right away if substate is waiting pdn conn req and 
             there is no cached REG REQ to be processed. 
             Otherwise attach will be started when UE camps. */
          if((emm_substate == EMM_DEGEGISTERED_WAITING_PDN_CONN_REQ) &&
             (emm_reg_container == NULL))
          {
            if((emm_ctrl_data_ptr->emm_attach_rej_esm_fail_counter > 0)||
               (emm_ctrl_data_ptr->apn_switch == TRUE))
            {
              emm_ctrl_data_ptr->apn_switch = FALSE;
              /* Start recovery type attach procedure */
              emm_start_attach_procedure(EMM_UPDATE_RECOVERY,emm_ctrl_data_ptr);
            }
            else
            {
              /* Start initial type attach procedure */
              emm_start_attach_procedure(EMM_INITIAL_UPDATE,emm_ctrl_data_ptr);
            }
          }
        }

37.emm_start_attach_procedure()

  emm_attach_request->lte_nas_hdr.pd = EPS_MOBILITY_MANAGEMENT_MESSAGES ;

  emm_attach_request->lte_nas_hdr.msg_id = ATTACH_REQUEST ;

  emm_attach_request->security_hdr = PLAIN_NAS_MSG ;
……
    /*  supported_voice_codec info */
    MM_LOG_HF_HIGH(MM_TAG, MM_SUB, "=EMM= Attach Request supports codecs list ");
    emm_attach_request->supported_voice_codec_exists = TRUE;
    emm_attach_request->supported_voice_codec = gmm_get_supported_codec_list();
……

   MM_LOG_HF_HIGH(MM_TAG, MM_SUB, "=EMM= Start timer T3410");

   /* Start T3410 */
   mm_stop_timer(TIMER_T3410) ;
   mm_start_timer(TIMER_T3410, EMM_T3410_TIMER_DURATION);

   /* 33.401, CR 0457 
      When the ME is transitioning away from EMM-DEREGISTERED state with the intent to 
      eventually transitioning to EMM-REGISTERED state, 
      if the USIM supports EMM parameters storage, 
      the ME shall mark the stored EPS NAS security context on the USIM as invalid.  
   */
   MM_LOG_HF_HIGH(MM_TAG, MM_SUB, "=EMM= Start Attach procedure, invalidate the security context");
   emm_update_stored_security_context(emm_ctrl_data_ptr, TRUE);

   EMM_MOVES_TO_REGISTERED_INITIATED_STATE((emm_substate_type)EMM_WAITING_FOR_NW_RESPONSE) ;
   //Store UE_ID type and use it later
   emm_ctrl_data_ptr->attempted_ue_id = emm_attach_request->eps_mobile_id.ue_id;
  if (FALSE == emm_send_message(emm_ctrl_data_ptr->out_msg_ptr, 
                                sequence_number, 
                                MSGR_NAS_EMM,
                                NULL, 
                                emm_attach_request_failed, 
                                emm_ctrl_data_ptr))

三、主要日志打印

[  42/ 0/2]              QTRACE                   06:56:11.698678          MMODE/STRM/High/CM       [            cmtask.c  10803] MSGR RXD: LTE_RRC_SERVICE_IND, sub 1  2
[  47/ 0/2]              QTRACE                   06:56:11.698763          MM/LowFreq/High/MM       [   emm_rrc_handler.c   3603] DS: SUB 1 =EMM= RRC_SERVICE_IND -PLMN (460 - 0), TAC 37250  SRV REQ pending 16973828,   state = 1  sub_state = 2 2
[  47/ 1/2]              QTRACE                   06:56:11.698764          MM/HighFreq/High/MM      [   emm_rrc_handler.c   3621] DS: SUB 1 =EMM= RRC_SERVICE_IND - RRC active 0, Cell ID 188012034, IMS EMC spt 0 Div Duplex 2, Detach Reqd 0CSG Id = -1,  Hybrid cell = 0,  shared num_plmn 2 2
[  47/ 1/2]              QTRACE                   06:56:11.698765          MM/HighFreq/High/MM      [   emm_rrc_handler.c   3632] DS: SUB 1 =EMM= RRC_SERVICE_IND - blind_redir_after_csfb 0, search done 1 fake cell = 0 lte 3gpp release ver 0XC0  ACQ Status = 0tau_pending_gw_attach 0, radio_cap_update_req 0  2
[  47/ 1/2]              QTRACE                   06:56:11.698782          MM/HighFreq/High/MM      [       emm_utility.c  15394] DS: SUB 1 =MM= RRC paging cycle Value Rx 8 previous_client_id = 0 2
[  47/ 1/2]              QTRACE                   06:56:11.698787          MM/HighFreq/High/MM      [        emm_rrc_if.c   1047] DS: SUB 1 =EMM= Checking for high priority - AC 0x10 2
[  47/ 1/2]              QTRACE                   06:56:11.698793          MM/HighFreq/High/MM      [       emm_utility.c   7310] DS: SUB 1 =EMM= Sending NAS_EMM_PLMN_CHANGE_IND w/ PLMN 460-0 Primary PLMN 460-0 2
[  45/ 0/2]              QTRACE                   06:56:11.699242          PM/HighFreq/High/PM      [policyman_serving_system.c   2237] received msim CM_SS_EVENT_SRV_CHANGED 2
[  47/ 1/2]              QTRACE                   06:56:11.700770          MM/HighFreq/High/MM      [   emm_reg_handler.c   4607] DS: SUB 1 MM sent MMR_CAMPED_IND RAT: 2, BAND 39 2
[  47/ 1/2]              QTRACE                   06:56:11.700796          MM/HighFreq/High/REG     [reg_state_registering.c    316] DS: SUB 1 =REG= REG_STATE_REGISTERING 2
[  47/ 1/2]              QTRACE                   06:56:11.700803          MM/HighFreq/High/MM      [       emm_utility.c   6789] DS: SUB 1 =EMM= TAI change - 0 (Srving TAI vs Last attempted TAI) 2
[  47/ 1/2]              QTRACE                   06:56:11.700805          MM/HighFreq/High/MM      [    emm_update_lib.c   1252] DS: SUB 1 =EMM= Send request to get PDN_CONNECTIVITY_REQ message 2
[  47/ 1/2]              QTRACE                   06:56:11.700809          MM/HighFreq/High/REG     [          reg_send.c    510] DS: SUB 1 =REG= CM_CAMPED_IND PLMN (460 - 0) Primary PLMN (460 - 0) 2
[  47/ 1/2]              QTRACE                   06:56:11.700819          MM/HighFreq/High/REG     [          reg_send.c    739] DS: SUB 1 =REG= REG_SERVICE_STATE_IND 2
[  42/ 0/2]              QTRACE                   06:56:11.700828          MMODE/STRM/High/CM       [          cmregprx.c  13128] NAS->CMREG: sub 1 stk 0, CM_CAMPED_IND
[  42/ 0/2]              QTRACE                   06:56:11.700838          MMODE/STRM/High/CM       [          cmregprx.c  12270] CMREG->PM: PM callback: sub 1 stk 0, cmss stack 0, srv_status=1, intl_srv_status=0, no_srv_uptime=-1
[  42/ 0/2]              QTRACE                   06:56:11.700849          MMODE/STRM/High/CM       [          cmregprx.c  10779] send plmn info to PM and fetch call mode returns 0 sub 1 stk 0
[  42/ 0/1]              QTRACE                   06:56:11.700855          MMODE/STRM/Medium/CM     [          cmregprx.c  12333] Allocated camped ind and copied
[  42/ 0/2]              QTRACE                   06:56:11.700861          MMODE/STRM/High/CM       [          cmregprx.c   6981] mapping nas -> sd camp_ind: plmn 0x64 0xf0 0x0, lac 0x9182
[  47/ 1/2]              QTRACE                   06:56:11.700866          MM/HighFreq/High/MM      [   emm_esm_handler.c   2731] DS: SUB 1 =EMM= Sent NAS_ESM_GET_PDN_CONNECTIVITY_REQ_IND w/ Seq Num 2 2
[  42/ 0/1]              QTRACE                   06:56:11.700936          MMODE/STRM/Medium/CM     [          cmregprx.c   7086] process_sd_action 1 on sub 1 stk 0 is_gwl_mode_supp 1 is_1x_hdr_mode_supp 0 sd_mode_pref 0x2202
[  47/ 0/2]              QTRACE                   06:56:11.700960          MM/LowFreq/High/SM       [         esm_utils.c   3801] DS: SUB 1 ESM: ESM sent MM_CM_GET_PDN_CONNECTIVITY_REQUEST_IND seq no 2,responding_to_page 0 2
[  42/ 1/0]              QTRACE                   06:56:11.701738          MMODE/DEBUG/Low/CM       [         cmltecall.c   3217] 4GNAS->CM: id 0x201030e, GET_PDN_CONNECTIVITY_REQUEST_IND, sub 1 2
[  42/ 0/1]              QTRACE                   06:56:11.701751          MMODE/STRM/Medium/CM     [         cmltecall.c   1203] CM_CALL_EVENT_GET_PDN_CONN_IND, rtp = 0
[  42/ 1/0]              QTRACE                   06:56:11.701808          MMODE/DEBUG/Low/CM       [         cmltecall.c   3688] 4GNAS->CM: id 0x201030e, PROCESSED, sub 1, found 0, gw found 0, call_id 255, oprt_mode 5, active_subs 2 2
[  52/ 2/2]              QTRACE                   06:56:11.704863          DS/NonVerbose/High/OTHER [ ds3gcmif_external.c    916] Attach Request - Rx'ed CM_CALL_EVENT_GET_PDN_CONN_IND,call_mode 9 2
[  52/ 2/2]              QTRACE                   06:56:11.705315          DS/NonVerbose/High/OTHER [ds_eps_pdn_context_external.c   2410] Setting attach SM to PROCESS_GET_PDN_CONN_IND State 2
[  42/ 0/2]              QTRACE                   06:56:11.709338          MMODE/STRM/High/CM       [                cm.c   4773] cm_mm_call_cmd_pdn_connectivity_req(), lps = 0, sdf_id 0, sub 1
[  42/ 0/2]              QTRACE                   06:56:11.709451          MMODE/STRM/High/CM       [          cmregprx.c  18501] CMREGPRX Stack 0 state is 1, Substate is 1
[  42/ 1/0]              QTRACE                   06:56:11.709458          MMODE/DEBUG/Low/CM       [         cmltecall.c   1958] CM->4GNAS: sub 1, Send LTE callcmd 22, call_id 255, oprt_mode 5, active_subs 2 2
[  42/ 0/2]              QTRACE                   06:56:11.709461          MMODE/STRM/High/CM       [         cmltecall.c   1985] CM_CALL_CMD_PDN_CONNECTIVITY_REQ, epco_valid 0, lps 0, sdf_id 0, sub 1
[  47/ 1/2]              QTRACE                   06:56:11.709485          MM/HighFreq/High/SM      [           esmtask.c    666] DS: SUB 1 ESM: Message from the CM received 2
[  47/ 0/2]              QTRACE                   06:56:11.709504          MM/LowFreq/High/SM       [           esm_bpm.c   1373] DS: SUB 1 ESM: Rcved PDN CONN REQ - Seq num 2, Req type 1 2
[  47/ 0/2]              QTRACE                   06:56:11.709539          MM/LowFreq/High/SM       [         esm_utils.c   1227] DS: SUB 1 ESM: ESM sent MM_CM_PDN_CONNECTIVITY_PACKED_REQUEST_IND 2
[  42/ 1/0]              QTRACE                   06:56:11.709545          MMODE/DEBUG/Low/CM       [         cmltecall.c   3398] 4GNAS->CM: id 0x2010310, PDN_CONNECITIVITY_PACKED_REQUEST_IND, asubs_id=1, pti=2, sdf_id 0 2
[  42/ 0/2]              QTRACE                   06:56:11.709692          MMODE/STRM/High/CM       [         cmltecall.c   2426] cmltecall_call_control_complete_cb(), call_id=255,status=0,call_type=2
[  42/ 0/1]              QTRACE                   06:56:11.709697          MMODE/STRM/Medium/CM     [         cmltecall.c   2532] CM->4GNAS: Send: NAS_ESM_PDN_CONNECT_PACKED_CNF, status=0, pti=2
[  42/ 0/2]              QTRACE                   06:56:11.709712          MMODE/STRM/High/CM       [         cmltecall.c   3433] cmcc_call_control_processing_lte return 1
[  42/ 1/0]              QTRACE                   06:56:11.709713          MMODE/DEBUG/Low/CM       [         cmltecall.c   3688] 4GNAS->CM: id 0x2010310, PROCESSED, sub 1, found 0, gw found 0, call_id 255, oprt_mode 5, active_subs 2 2
[  47/ 1/2]              QTRACE                   06:56:11.709718          MM/HighFreq/High/SM      [           esmtask.c    576] DS: SUB 1 ESM: received NAS_ESM_PDN_CONNECT_PACKED_CNF from CM 2
[  47/ 1/2]              QTRACE                   06:56:11.709718          MM/HighFreq/High/SM      [           esmtask.c    666] DS: SUB 1 ESM: Message from the CM received 2
[  47/ 0/2]              QTRACE                   06:56:11.709720          MM/LowFreq/High/SM       [           esm_bpm.c   1078] DS: SUB 1 ESM: MSG_ID == NAS_ESM_PDN_CONNECT_PACKED_CNF, PACKED_CNF status = 0 2
[  47/ 1/2]              QTRACE                   06:56:11.709748          MM/HighFreq/High/SM      [         esm_utils.c   1288] DS: SUB 1 ESM: Sends NAS_EMM_DATA_REQ carrying PDN_CONNECTIVITY_REQUEST 2
[  47/ 0/2]              QTRACE                   06:56:11.709753          MM/LowFreq/High/MM       [   emm_esm_handler.c    639] DS: SUB 1 =EMM= Rcved NAS_EMM_DATA_REQ state = 1, substate = 7, emc_status=0 connection_state = 0, ESM message_id = 208, TIMER_T3346 = 0 2
[  47/ 1/2]              QTRACE                   06:56:11.709757          MM/HighFreq/High/MM      [   emm_esm_handler.c   1223] DS: SUB 1 =EMM= ESM DATA REQ - Msg 208, DEREG 7 state, REG REQ pending 0 2 
[  47/ 1/2]              QTRACE                   06:56:11.709812          MM/HighFreq/High/MM      [    emm_update_lib.c   1707] DS: SUB 1 =EMM= TMSI does not exist, including TMSI_STATUS in ATTACH_REQ 2
[3007/   2/   3/   4]    MSG                      06:56:11.709979          NAS MM/High              [          gmmutils.c   2555] DS: SUB 1 start attach epc capability = 1,gmm_attach_type:0x0
[  47/ 1/2]              QTRACE                   06:56:11.709986          MM/HighFreq/High/MM      [    emm_update_lib.c   1776] DS: SUB 1 =EMM= DRX param in Attach Request, Split Pg Cycle Code = 0xa, Non DRX Tmr Code/CN_COEFF_S1 = 0x0 2
[  47/ 1/2]              QTRACE                   06:56:11.709988          MM/HighFreq/High/MM      [    emm_update_lib.c   1809] DS: SUB 1 =EMM= Attach Request supports codecs list 2
[  47/ 1/2]              QTRACE                   06:56:11.709995          MM/HighFreq/High/MM      [    emm_update_lib.c   1894] DS: SUB 1 =EMM= Start timer T3410 2
[  47/ 1/2]              QTRACE                   06:56:11.710019          MM/HighFreq/High/MM      [    emm_update_lib.c   1906] DS: SUB 1 =EMM= Start Attach procedure, invalidate the security context 2
[0xB0ED]                 OTA LOG                  06:56:11.710521          LTE NAS EMM Plain OTA Outgoing Message Attach request Msg       2

你可能感兴趣的:(modem,网络协议)