VOS_UINT32 NAS_EMM_AnyStateMsgGtReCmd(VOS_UINT32  ulMsgId,
                                      VOS_VOID  *pMsgStru)
{
    NAS_EMM_GUTI_REALLOCATION_CMD_STRU *pstGutiCmdMsg = NAS_EMM_NULL_PTR;
    NAS_EMM_GUTI_STRU                  *pstGuti;
    VOS_UINT32                          ulRst;

    (VOS_VOID)ulMsgId;

    /*解析消息,获取网侧发来的GUTI*/
    pstGutiCmdMsg = (NAS_EMM_GUTI_REALLOCATION_CMD_STRU *)pMsgStru;
    pstGuti       = (NAS_EMM_GUTI_STRU *) &pstGutiCmdMsg->stGuti;

    /*更新全局变量GUTI*/
    NAS_LMM_MEM_CPY_S(  NAS_LMM_GetEmmInfoUeidGutiAddr(),
                        sizeof(NAS_LMM_GUTI_STRU),
                        pstGuti,
                        sizeof(NAS_LMM_GUTI_STRU));

    NAS_LMM_GetEmmInfoUeidAddr()->bitOpGuti = NAS_EMM_BIT_SLCT;
    /*如果更新了Tai List,存储最新Tai List */
    if(VOS_TRUE == pstGutiCmdMsg->ucBitOpTaiList)
    {
        if(NAS_LMM_SUCC == NAS_EMM_TaiListSet(&pstGutiCmdMsg->stTaiList))
        {
            NAS_EMM_GUTI_NORMAL_LOG("NAS_EMM_AnyStateMsgGtReCmd: TaiList update is success!");
            TLPS_PRINT2LAYER_INFO(NAS_EMM_AnyStateMsgGtReCmd_ENUM,LNAS_SUCC);

            /*保存新的TAI List的同时更新ForbTA for Roaming和ForbTA for RPOS*/
            NAS_EMMC_UpdateForbTaList();
        }
        else
        {
            NAS_EMM_GUTI_ERROR_LOG("NAS_EMM_AnyStateMsgGtReCmd: TaiList update is fail!");
            TLPS_PRINT2LAYER_ERROR(NAS_EMM_AnyStateMsgGtReCmd_ENUM,LNAS_FAIL);
        }
    }

    /* 判断没有放到函数NAS_LMM_WritePsLoc中来做,是由于紧急注册被拒或者尝试
       次数达到5次时还是要删除参数 ,协议只规定是紧急注册成功后才不写卡或者
       NV项 */
    if ((NAS_LMM_REG_STATUS_EMC_REGING != NAS_LMM_GetEmmInfoRegStatus())
        && (NAS_LMM_REG_STATUS_EMC_REGED != NAS_LMM_GetEmmInfoRegStatus()))
    {
        /*保存PS LOC信息*/ /*存储最新guti,last Ta,update state */
        NAS_LMM_WritePsLoc(NAS_NV_ITEM_UPDATE);
    }

    /*发出内部消息MRRC_DATA_REQ,携带GUTI REALLOCAITON CMPL*/
    ulRst = NAS_EMM_GutiMrrcDataReq();
    if(NAS_EMM_OK != ulRst)
    {
        NAS_EMM_GUTI_ERROR_LOG("NAS_EMM_AnyStateMsgGtReCmd: NAS_EMM_GutiMrrcDataReq err!");
        TLPS_PRINT2LAYER_ERROR(NAS_EMM_AnyStateMsgGtReCmd_ENUM,LNAS_ERROR);
    }

    return NAS_LMM_MSG_HANDLED;
}
VOS_VOID    NAS_EMM_AttDataUpdate(VOS_UINT32 ulDeleteRplmn)
{

    /*设置 EPS update status为EU3*/
    NAS_LMM_GetMmAuxFsmAddr()->ucEmmUpStat = EMM_US_ROAMING_NOT_ALLOWED_EU3;

    /*删除GUTI*/
    NAS_EMM_ClearGuti();

    /*删除LVR TAI*/
    if (NAS_EMM_DELETE_RPLMN == ulDeleteRplmn)
    {
        NAS_EMM_ClearLVRTai();
    }
    else
    {
        NAS_EMM_SetLVRTacInvalid();
    }

    /*删除KSIasme*/
    /*NAS_EMM_ClearCurSecuCntxt();*/
    NAS_EMM_ClearAllSecuCntxt();

    if((NAS_LMM_CAUSE_PLMN_NOT_ALLOW == NAS_EMM_GLO_AD_GetAttRejCau()) ||
            (NAS_LMM_CAUSE_TA_NOT_ALLOW == NAS_EMM_GLO_AD_GetAttRejCau()) ||
            (NAS_LMM_CAUSE_ROAM_NOT_ALLOW == NAS_EMM_GLO_AD_GetAttRejCau()) ||
            (NAS_LMM_CAUSE_EPS_SERV_NOT_ALLOW_IN_PLMN == NAS_EMM_GLO_AD_GetAttRejCau()) ||
            (NAS_LMM_CAUSE_NO_SUITABL_CELL == NAS_EMM_GLO_AD_GetAttRejCau()))
    {

        /*清除ATTACH ATTEMPTING COUNTER计数器*/
        NAS_EMM_GLO_AD_GetAttAtmpCnt()      = 0;
    }

    /* 将无效的安全上下文直接在函数内部写卡 */
    NAS_LMM_WriteEpsSecuContext(NAS_NV_ITEM_UPDATE);
    /*保存PS LOC信息*/
    NAS_LMM_WritePsLoc(NAS_NV_ITEM_UPDATE);

    return;

}
VOS_UINT32  NAS_EMM_MsRegInitSsWtCnAttCnfMsgCnAttachAcp(VOS_UINT32  ulMsgId,
        VOS_VOID   *pMsgStru)
{
    NAS_EMM_CN_ATTACH_ACP_STRU         *pRcvEmmMsg;
    NAS_LMM_NETWORK_INFO_STRU          *pMmNetInfo = VOS_NULL_PTR;
#if (VOS_OS_VER != VOS_WIN32)
    static VOS_UINT32  s_ulAttachAcpCnt = 1;
#endif

    (VOS_VOID)ulMsgId;

    pRcvEmmMsg                          = (NAS_EMM_CN_ATTACH_ACP_STRU *)pMsgStru;

    /*打印进入该函数*/
    NAS_EMM_ATTACH_LOG_NORM("NAS_EMM_MsRegInitSsWtCnAttCnfMsgCnAttachAcp is entered");

    /*检查状态是否匹配,若不匹配,退出*/
    if (NAS_EMM_AD_CHK_STAT_INVALID(EMM_MS_REG_INIT,EMM_SS_ATTACH_WAIT_CN_ATTACH_CNF))
    {
        /*打印出错信息*/
        NAS_EMM_ATTACH_LOG_WARN("NAS_EMM_MsRegInitSsWtCnAttCnfMsgCnAttachAcp: STATE ERR!");
        return  NAS_LMM_MSG_DISCARD;
    }

    /* 如果ATTACH ACP消息内容不合法,不处理消息,直接丢弃*/
    if (NAS_EMM_PARA_INVALID == NAS_EMM_CnAttachAcpMsgChk(pRcvEmmMsg))
    {
        NAS_EMM_ATTACH_LOG_ERR("NAS_EMM_MsRegInitSsWtCnAttCnfMsgCnAttachAcp: NAS_EMM_CN_ATTACH_ACC_STRU para err!");
        return  NAS_LMM_ERR_CODE_PARA_INVALID;

    }


    /*停止定时器T3410*/
    NAS_LMM_StopStateTimer(          TI_NAS_EMM_T3410);

    /* 存储ATTACH ACCPET中携带的信元 */
    NAS_EMM_SaveAttachAcpIe(pMsgStru);


    /*清除ATTACH ATTEMPTING COUNTER和TRACKING AREA UPDATING ATTEMPT计数器*/
    /*NAS_EMM_GLO_AD_GetAttAtmpCnt()      = 0;*/
    NAS_EMM_TAU_SaveEmmTAUAttemptCnt(NAS_EMM_TAU_ATTEMPT_CNT_ZERO);

    /*注册成功后,注册前的TAU/SERVICE/DETACH模块记录的历史信息不应该影响后续流程
      清除TAU/service/detach资源
    */
    NAS_EMM_TAU_ClearResouce();
    NAS_EMM_SER_ClearResource();
    NAS_EMM_Detach_ClearResourse();

    /*联合注册仅EPS ONLY成功*/
    if ((MMC_LMM_ATT_TYPE_COMBINED_EPS_IMSI == NAS_EMM_GLO_GetCnAttReqType()) &&
            (EMM_ATTACH_RST_PS == pRcvEmmMsg->ucAttachRst))
    {
        NAS_EMM_ProcEpsOnlySucc(pMsgStru);
    }
    else
    {
        /*设置EPS UPDATE STAUS为EU1*/
        NAS_LMM_GetMmAuxFsmAddr()->ucEmmUpStat = EMM_US_UPDATED_EU1;

        /*启动定时器TI_NAS_EMM_WAIT_ESM_BEARER_CNF*/
        NAS_LMM_StartStateTimer(         TI_NAS_EMM_WAIT_ESM_BEARER_CNF);

        /*修改状态:进入主状态REG_INIT子状态ATTACH_WAIT_ESM_BEARER_CNF*/
        NAS_EMM_AdStateConvert(             EMM_MS_REG_INIT,
                                            EMM_SS_ATTACH_WAIT_ESM_BEARER_CNF,
                                            TI_NAS_EMM_WAIT_ESM_BEARER_CNF);
    }

    /* lihong00150010 emergency tau&service begin */
    /* 参照标杆做法,在收到ATTACH ACCEPT时就更新GUTI, LAST VISIT TAI,EU值,
       并写卡或者NV */
    pMmNetInfo                          = NAS_LMM_GetEmmInfoNetInfoAddr();
    NAS_EMM_SetLVRTai(                  &pMmNetInfo->stPresentNetId);

    /* 判断没有放到函数NAS_LMM_WritePsLoc中来做,是由于紧急注册被拒或者尝试次数
       达到5次时还是要删除参数 ,协议只规定是紧急注册成功后才不写卡或者NV项 */
    if (NAS_LMM_REG_STATUS_EMC_REGING != NAS_LMM_GetEmmInfoRegStatus())
    {
        /*保存PS LOC信息*/
        NAS_LMM_WritePsLoc(NAS_NV_ITEM_UPDATE);
    }
    /* lihong00150010 emergency tau&service end */

    /* 清除接入技术变化标识,在这里清除不考虑ATTACH失败的原因值
          因为要么必然转入了DEREG态,要么MME已经查询完UE无线能力*/
    NAS_EMM_ClearUeRadioAccCapChgFlag();

#if (VOS_OS_VER != VOS_WIN32)
    if(1 == s_ulAttachAcpCnt)
    {
        (VOS_VOID)ddmPhaseScoreBoot("UE attach success",__LINE__);
        s_ulAttachAcpCnt++;
    }
#endif

    return NAS_LMM_MSG_HANDLED;
}
VOS_VOID NAS_EMM_TAU_TAUReqRejectCasue15()
{
    NAS_MM_TA_STRU                     stCurrentTa;
    NAS_MM_TA_LIST_STRU                *pstTaiList;

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

    NAS_LMM_SetEmmInfoRegDomain(NAS_LMM_REG_DOMAIN_PS);
    /*设置EU3 ROAMING NOT ALLOWED*/
    NAS_LMM_GetMmAuxFsmAddr()->ucEmmUpStat = EMM_US_ROAMING_NOT_ALLOWED_EU3;
    /* lihong00150010 emergency tau&service begin */
    if (NAS_LMM_REG_STATUS_EMC_REGED != NAS_LMM_GetEmmInfoRegStatus())
    {
        /*保存PS LOC信息*/
        NAS_LMM_WritePsLoc(NAS_NV_ITEM_UPDATE);
    }
    /* lihong00150010 emergency tau&service end */
    /*重置TAU计数器*/
    NAS_EMM_TAU_SaveEmmTAUAttemptCnt(NAS_EMM_TAU_ATTEMPT_CNT_ZERO);

    /*Remove current TA from TAI List*/
    NAS_EMM_GetCurrentTa(&stCurrentTa);

    pstTaiList = NAS_LMM_GetEmmInfoNetInfoTaiListAddr();
    NAS_LMM_DeleteTaFromTaList(&stCurrentTa, pstTaiList, NAS_MM_MAX_TA_NUM);

    if (NAS_EMMC_USER_SPEC_PLMN_YES == NAS_EMMC_GetUserSpecPlmnFlag())
    {
        NAS_EMM_AddForbTa(&stCurrentTa,NAS_LMM_GetEmmInfoNetInfoForbTaForRej15Addr());
    }
    else
    {
        /*store the current TAI in the list of
                "forbidden tracking areas for roaming"*/
        NAS_EMM_AddForbTa(&stCurrentTa,NAS_LMM_GetEmmInfoNetInfoForbTaForRoamAddr());
        NAS_EMMC_SendRrcCellSelectionReq(LRRC_LNAS_FORBTA_CHANGE);
    }

    /* lihong00150010 emergency tau&service begin */
    if (NAS_EMM_TAU_START_CAUSE_ESM_EMC_PDN_REQ == NAS_EMM_TAU_GetEmmTAUStartCause())
    {
        NAS_EMM_TAU_LOG_INFO("NAS_EMM_TAU_TAUReqRejectCasue15:CAUSE_ESM_EMC_PDN_REQ");

        NAS_EMM_EmcPndReqTauAbnormalCommProc(   NAS_EMM_MmcSendTauActionResultIndRej,
                                                (VOS_VOID*)NAS_EMM_NULL_PTR,
                                                EMM_SS_DEREG_LIMITED_SERVICE);
    }
    else
    {
        /*发送EMM_ESM_STATUS_IND(去注册)*/
    	NAS_EMM_TAU_SendEsmStatusInd(EMM_ESM_ATTACH_STATUS_ATTACHED);

        /*转换EMM状态机MS_REG+SS_REG_LIMITED_SERVICE*/
        NAS_EMM_TAUSER_FSMTranState(EMM_MS_REG,
                                    EMM_SS_REG_LIMITED_SERVICE,
                                    TI_NAS_EMM_STATE_NO_TIMER);

        /****检查冲突标志并做相应的处理********************************************/
        /* 上报TAU结果在冲突中处理 */
        NAS_EMM_TAU_RelCause1315CollisionProc(NAS_EMM_MmcSendTauActionResultIndRej,
                        (VOS_VOID*)NAS_EMM_NULL_PTR);
    }
    /* lihong00150010 emergency tau&service end */

    NAS_EMM_WaitNetworkRelInd();

    return;
}
VOS_VOID NAS_EMM_TAU_TAUReqRejectCasue15()
{
    NAS_MM_TA_STRU                     stCurrentTa;
    NAS_MM_TA_LIST_STRU                *pstTaiList;
    MMC_LMM_LTE_NO_SUBSCRIBE_PLMN_LIST_STRU  stLteNoSubsPlmnList;

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

    NAS_LMM_SetEmmInfoRegDomain(NAS_LMM_REG_DOMAIN_PS);
    /*设置EU3 ROAMING NOT ALLOWED*/
    NAS_LMM_GetMmAuxFsmAddr()->ucEmmUpStat = EMM_US_ROAMING_NOT_ALLOWED_EU3;
    /* lihong00150010 emergency tau&service begin */
    if (NAS_LMM_REG_STATUS_EMC_REGED != NAS_LMM_GetEmmInfoRegStatus())
    {
        /*保存PS LOC信息*/
        NAS_LMM_WritePsLoc(NAS_NV_ITEM_UPDATE);
    }
    /* lihong00150010 emergency tau&service end */
    /*重置TAU计数器*/
    NAS_EMM_TAU_SaveEmmTAUAttemptCnt(NAS_EMM_TAU_ATTEMPT_CNT_ZERO);

    /*被15拒绝,当前PLMN只有一个*/
    stLteNoSubsPlmnList.ulPlmnNum = 1;
    /*拷贝当前PLMN*/
    NAS_LMM_MEM_CPY(&(stLteNoSubsPlmnList.astPlmnId[0]),
                     NAS_LMM_GetEmmInfoPresentPlmnAddr(),
                     sizeof(MMC_LMM_PLMN_ID_STRU));

    if((NAS_EMM_BIT_SLCT == NAS_EMM_TAU_GetEmmTauCnEmmExtRejCauseOp())
       &&(NAS_EMM_EUTRAN_NOT_ALLOWED == NAS_EMM_TAU_GetEmmTauCnEmmExtRejCause()))
    {
        /*被15原因值拒绝而且当前有扩展原因值,指示USIM未在LTE开户,走正常的LTE未开户流程*/
        NAS_EMM_SetLteNoSubscribeExtCauseFlag(NAS_EMM_EUTRAN_NOT_ALLOWED);
        NAS_LMM_LteNoSubscribeWithExtCauseHandle(&stLteNoSubsPlmnList);
    }
    else
    {
        /*被15原因值拒绝但是没有带扩展原因值,走LTE未开户定制流程*/
        NAS_LMM_LteNoSubscribeWithOutExtCauseHandle(&stLteNoSubsPlmnList);
    }


    /*Remove current TA from TAI List*/
    NAS_EMM_GetCurrentTa(&stCurrentTa);

    pstTaiList = NAS_LMM_GetEmmInfoNetInfoTaiListAddr();
    NAS_LMM_DeleteTaFromTaList(&stCurrentTa, pstTaiList, NAS_MM_MAX_TA_NUM);

    if (NAS_EMMC_USER_SPEC_PLMN_YES == NAS_EMMC_GetUserSpecPlmnFlag())
    {
        NAS_EMM_AddForbTa(&stCurrentTa,NAS_LMM_GetEmmInfoNetInfoForbTaForRej15Addr());
    }
    else
    {
        /*store the current TAI in the list of
                "forbidden tracking areas for roaming"*/
        NAS_EMM_AddForbTa(&stCurrentTa,NAS_LMM_GetEmmInfoNetInfoForbTaForRoamAddr());
        NAS_EMMC_SendRrcCellSelectionReq(LRRC_LNAS_FORBTA_CHANGE);
    }

    /* lihong00150010 emergency tau&service begin */
    if (NAS_EMM_TAU_START_CAUSE_ESM_EMC_PDN_REQ == NAS_EMM_TAU_GetEmmTAUStartCause())
    {
        NAS_EMM_TAU_LOG_INFO("NAS_EMM_TAU_TAUReqRejectCasue15:CAUSE_ESM_EMC_PDN_REQ");

        NAS_EMM_EmcPndReqTauAbnormalCommProc(   NAS_EMM_MmcSendTauActionResultIndRej,
                                                (VOS_VOID*)NAS_EMM_NULL_PTR,
                                                EMM_SS_DEREG_LIMITED_SERVICE);
    }
    else
    {
        /*发送EMM_ESM_STATUS_IND(去注册)*/
    	NAS_EMM_TAU_SendEsmStatusInd(EMM_ESM_ATTACH_STATUS_ATTACHED);

        /*转换EMM状态机MS_REG+SS_REG_LIMITED_SERVICE*/
        NAS_EMM_TAUSER_FSMTranState(EMM_MS_REG,
                                    EMM_SS_REG_LIMITED_SERVICE,
                                    TI_NAS_EMM_STATE_NO_TIMER);

        /****检查冲突标志并做相应的处理********************************************/
        /* 上报TAU结果在冲突中处理 */
        NAS_EMM_TAU_RelCause1315CollisionProc(NAS_EMM_MmcSendTauActionResultIndRej,
                        (VOS_VOID*)NAS_EMM_NULL_PTR);
    }
    /* lihong00150010 emergency tau&service end */

    NAS_EMM_WaitNetworkRelInd();

    return;
}