/*****************************************************************************
 Function Name   : NAS_EMM_SaveAttachAcpIe
 Description     : 存储ATTACH ACCPET中携带的信元
 Input           : pMsgStru------------ATTACH ACCEPT消息指针
 Output          : None
 Return          : VOS_VOID

 History         :
    1.lihong00150010      2012-02-27  Draft Enact

*****************************************************************************/
VOS_VOID  NAS_EMM_SaveAttachAcpIe
(
    VOS_VOID                           *pMsgStru
)
{
    NAS_EMM_CN_ATTACH_ACP_STRU         *pRcvEmmMsg = VOS_NULL_PTR;
    VOS_UINT32                          ulTimerLen = NAS_EMM_NULL;

    pRcvEmmMsg                          = (NAS_EMM_CN_ATTACH_ACP_STRU *)pMsgStru;

    /*保存ATTACH结果*/
    NAS_EMM_GLO_AD_SetAttRslt(pRcvEmmMsg->ucAttachRst);

    /*保存T3412 VALUE*/
    ulTimerLen = NAS_EMM_TimerValTransfer(pRcvEmmMsg->stT3412Value.ucUnit,
                                          pRcvEmmMsg->stT3412Value.ucTimerVal);
    NAS_LMM_ModifyPtlTimer(TI_NAS_EMM_PTL_T3412,ulTimerLen);

    /*保存TAI LIST*/
    NAS_LMM_MEM_CPY(                    NAS_EMM_GLO_AD_GetTaiListAddr(),
                                        &(pRcvEmmMsg->stTaiList),
                                        sizeof(NAS_EMM_TA_LIST_STRU));

    /*保存新的TAI List的同时更新ForbTA for Roaming和ForbTA for RPOS*/
    NAS_EMMC_UpdateForbTaList();

    /*向ESM发送ACTIVATE DEFAULT EPS BEARER REQUEST消息*/
    NAS_EMM_EsmSendDataInd(              &(pRcvEmmMsg->stMsgCon));

    /* ATTACH ACP携带GUTI,更新GUTI到EMM的全局变量中*/
    if(NAS_EMM_BIT_SLCT == pRcvEmmMsg->ucBitOpGuti)
    {
        NAS_EMM_SetGuti(&(pRcvEmmMsg->stGuti));

    }

    /* Location area identification,MS identity,EMM cause,EPLMNS收到ATTACH ACCEPT保存,
        发出ATTACH COMPLETE或后续ATTACH失败从本地保存的读取,携带给MMC */

    NAS_EMM_AttSetLai(pMsgStru);

    NAS_EMM_AttSetEplms(pMsgStru);

    NAS_EMM_AttSetMsId(pMsgStru);

    if(pRcvEmmMsg->ucBitOpEmmCau == NAS_EMM_AD_BIT_SLCT)
    {
        NAS_EMM_GLO_AD_OP_GetEmmCau() = NAS_EMM_AD_BIT_SLCT;
        NAS_EMM_GLO_AD_GetEmmCau()    = pRcvEmmMsg->ucEMMCause;
    }
    else
    {
        NAS_EMM_GLO_AD_OP_GetEmmCau()   = NAS_EMM_AD_BIT_NO_SLCT;
        NAS_EMM_GLO_AD_GetEmmCau()      = 0;
    }

    /*ATTACH ACP携带T3402,修改定时器时长*/
    if(pRcvEmmMsg->ucBitOpT3402 == NAS_EMM_AD_BIT_SLCT)
    {
        ulTimerLen = NAS_EMM_TimerValTransfer(pRcvEmmMsg->stT3402Value.ucUnit,
                                              pRcvEmmMsg->stT3402Value.ucTimerVal);
        NAS_LMM_ModifyPtlTimer(TI_NAS_EMM_PTL_T3402,ulTimerLen);

    }
    else
    {
        /*如果ATTACH ACP消息中不携带T3402信元,则恢复默认值12min*/
        NAS_LMM_ModifyPtlTimer(TI_NAS_EMM_PTL_T3402,NAS_LMM_TIMER_T3402_LEN);
    }
    /*leili modify for isr begin*/
    /*ATTACH ACP携带T3423,修改定时器时长*/
    if(pRcvEmmMsg->ucBitOpT3423 == NAS_EMM_AD_BIT_SLCT)
    {
        ulTimerLen = NAS_EMM_TimerValTransfer(pRcvEmmMsg->stT3423Value.ucUnit,
                                              pRcvEmmMsg->stT3423Value.ucTimerVal);
        NAS_LMM_ModifyPtlTimer(TI_NAS_EMM_PTL_T3423,ulTimerLen);

    }
    else
    {
        /*如果ATTACH ACP消息中不携带T3423信元,则恢复默认值为T3412时长*/
        NAS_LMM_GetPtlTimerLen(TI_NAS_EMM_PTL_T3412, &ulTimerLen);
        NAS_LMM_ModifyPtlTimer(TI_NAS_EMM_PTL_T3423,ulTimerLen);
    }
    /*leili modify for isr end*/

    /*更新Emergency number list到全局变量中*/
    NAS_EMM_SetEmergencyList(   pRcvEmmMsg->ucBitOpEmergencyList,
                                &(pRcvEmmMsg->stEmergencyNumList));

    /*更新EPS network feature support到全局变量中*/
    NAS_EMM_SetEpsNetFeature(   pRcvEmmMsg->ucBitOpEpsNetFeature,
                                pRcvEmmMsg->ucEpsNetFeature);

    /*更新Additional update result到全局变量中*/
    if(EMM_ATTACH_RST_PS == pRcvEmmMsg->ucAttachRst)
    {
        /* 仅EPS ONLY成功 则ulAdditionUpRslt保存为NAS_LMM_ADDITIONAL_UPDATE_NOT_ATTACHED */
        NAS_EMM_SetAddUpdateRslt(NAS_EMM_BIT_SLCT, NAS_LMM_ADDITIONAL_UPDATE_NOT_ATTACHED);
    }
    else
    {
        NAS_EMM_SetAddUpdateRslt(   pRcvEmmMsg->ucBitOpAdditionalUpRslt,
                                    pRcvEmmMsg->ulAdditionUpRslt);
    }

    /* lihong00150010 ims begin */
    /* 通知MMC紧急呼号码列表,网侧是否支持IMS VOICE和紧急呼,以及LTE的CS域能力 */
    /* NAS_EMM_SendGmmInfoChangeNotify(); */
    NAS_EMM_SendMmcInfoChangeNotify();
    /*NAS_EMM_SendMmInfoChangeNotify();*/
    /* lihong00150010 ims end */
}
VOS_UINT32 NAS_EMM_MsTauInitSsWaitCNCnfMsgTAURej(VOS_UINT32  ulMsgId,
                                                   VOS_VOID   *pMsgStru
                               )
{
    VOS_UINT32                          ulRslt      = NAS_EMM_FAIL;
    NAS_EMM_CN_TAU_REJ_STRU            *pstTAURej   = NAS_EMM_NULL_PTR;
    /*lifuxin00253982 clear the pclint error*/
    LNAS_STK_UPDATE_TYPE_ENUM_UINT8     uTauType = LNAS_STK_UPDATE_TYPE_BUTT;
    VOS_UINT32                          ulTimerLen = NAS_EMM_NULL;

    (VOS_VOID)ulMsgId;

    /* 打印进入该函数, INFO_LEVEL */
    NAS_EMM_TAU_LOG_NORM( "Nas_Emm_MsTauInitSsWaitCNCnfMsgTAURej is entered.");

    /* 函数输入指针参数检查, 状态匹配检查,若不匹配,退出*/
    ulRslt = NAS_EMM_TAU_CHKFSMStateMsgp(EMM_MS_TAU_INIT,EMM_SS_TAU_WAIT_CN_TAU_CNF,pMsgStru);
    if ( NAS_EMM_SUCC != ulRslt )
    {
        NAS_EMM_TAU_LOG_WARN("NAS_EMM_TAUSER_CHKFSMStateMsgp ERROR !!");
        return ulRslt;
    }

    /*停止T3416,删除RAND,RES*/
    NAS_LMM_StopPtlTimer(                TI_NAS_EMM_PTL_T3416);
    NAS_EMM_SecuClearRandRes();

    /*调用消息处理函数*/
    pstTAURej = (NAS_EMM_CN_TAU_REJ_STRU*) pMsgStru;
    /*保存TAU拒绝原因*/
    NAS_EMM_TAU_GetEmmTauCnRejCause() =  pstTAURej->ucEMMCause;

    /* 保存T3346定时器时长 */
    if (NAS_EMM_BIT_SLCT == pstTAURej->ucBitOpT3346)
    {
        /* 此次修改仅针对GCF 9.2.3.1.20a用例修改,并未做完善,所以目前仅考虑TAU REJ是完整性保护
        的场景 */
        ulTimerLen = NAS_EMM_TimerValTransfer(pstTAURej->stT3346.ucUnit,
                                               pstTAURej->stT3346.ucTimerVal);
        NAS_LMM_ModifyPtlTimer(TI_NAS_EMM_PTL_T3346,ulTimerLen);
    }

    /* xiongxianghui00253310 modify for ftmerrlog begin */
    #if (FEATURE_PTM == FEATURE_ON)
    NAS_EMM_TAUErrRecord(pMsgStru, EMM_OM_ERRLOG_TYPE_CN_REJ);
    #endif
    /* xiongxianghui00253310 modify for ftmerrlog end   */

    /* 根据当前场景考虑是否需要修改原因值 */
    NAS_LMM_AdaptRegRejCau(&NAS_EMM_TAU_GetEmmTauCnRejCause());

    switch(NAS_EMM_TAU_GetTAUtype())
    {
        case NAS_EMM_CN_TAU_TYPE_TA_UPDATING:
                uTauType = LNAS_STK_UPDATE_TYPE_TA_UPDATEING;
                break;

        case NAS_EMM_CN_TAU_TYPE_COMBINED_TA_LA_UPDATING:
                uTauType = LNAS_STK_UPDATE_TYPE_COMBINED_TALA_UPDATING ;
                break;

        case NAS_EMM_CN_TAU_TYPE_COMBINED_TA_LA_WITH_IMSI:
                uTauType = LNAS_STK_UPDATE_TYPE_COMBINED_TALA_UPDATING_WITH_IMSI_ATTACH;
                break;

        case NAS_EMM_CN_TAU_TYPE_PERIODIC_UPDATING:
                uTauType = LNAS_STK_UPDATE_TYPE_PERIODIC_UPDATING;
                break;

        default:
                NAS_EMM_TAU_LOG_ERR("NAS_EMM_SendRejEventToSTK: TAU Type error!");
                break;
    }

    /*当TAU rej时,将rej事件发送给STK*/
    NAS_EMM_SendRejEventToSTK(NAS_EMM_TAU_GetEmmTauCnRejCause(), uTauType);

    NAS_EMM_TAU_RcvTAURej(NAS_EMM_TAU_GetEmmTauCnRejCause(), pstTAURej);

    return NAS_LMM_MSG_HANDLED;
}