/*****************************************************************************
 Function Name  : NAS_LMM_FSM_PopState
 Discription    : 将CCB状态栈中栈顶的状态弹出堆栈,填入当前状态。在流程模块调用
                  RRC_FSM_EndProcess时由MAIN模块自动完成,该接口不对外提供。
 Input          : 状态机栈地址
 Output         : None
 Return         : None
 History:
      1.  hanlufeng 41410  Draft Enact

*****************************************************************************/
VOS_VOID NAS_LMM_FSM_PopState( NAS_LMM_PARALLEL_FSM_ENUM_UINT16 enParalFsmId )
{

    NAS_LMM_FSM_STATE_STACK_STRU       *pstFsmStack;        /* 状态机栈地址 */
    NAS_LMM_FSM_STATE_STRU             *pstCurFsm;          /* 状态机地址 */
    NAS_LMM_FSM_STATE_STRU             *pstFsmStackTop;     /* 指向栈顶状态 */


    /* 入口检查 */
    if ( NAS_LMM_PARA_FSM_ID_INVALID(enParalFsmId))
    {
        NAS_LMM_PUBM_LOG1_ERR("NAS_LMM_FSM_PopState, FsmId error, FsmId", enParalFsmId);
        return;
    }

    /* 获取EMM状态机当前状态的地址和状态机栈的地址 */
    pstCurFsm      = NAS_LMM_GetCurFsmAddr(enParalFsmId);
    pstFsmStack    = NAS_LMM_GetFsmStackAddr(enParalFsmId);


    /* 栈越界 */
    if ( (pstFsmStack->ucStackDepth) > NAS_LMM_MAX_STACK_DEPTH )
    {
        NAS_LMM_PUBM_LOG1_ERR("NAS_LMM_FSM_PopState, The stack depth overflow, ucStackDepth",
                            (pstFsmStack->ucStackDepth));
        return;
    }

    /* 栈已空 */
    if ( 0 == (pstFsmStack->ucStackDepth) )
    {
        NAS_LMM_PUBM_LOG_ERR("NAS_LMM_FSM_PopState, The stack is empty!");
        return;
    }


    /* 获取栈顶第一个有效状态的位置,即栈顶的下一个位置 */
    pstFsmStack->ucStackDepth--;

    /* 获取栈顶第一个有效状态 */
    pstFsmStackTop  = &((pstFsmStack->astFsmStack)[pstFsmStack->ucStackDepth]);

    /* 设置当前状态机 */
    pstCurFsm->enFsmId     = pstFsmStackTop->enFsmId;
    pstCurFsm->enMainState = pstFsmStackTop->enMainState;
    pstCurFsm->enSubState  = pstFsmStackTop->enSubState;
    pstCurFsm->enStaTId    = pstFsmStackTop->enStaTId;

    return;
}
/*****************************************************************************
 Function Name  : NAS_LMM_FSM_PushState
 Discription    : 当前状态机压栈,不修改状态。即入栈后,当前状态仍保持入栈前
                  的状态,状态修改的工作由执行入栈操作的模块显式执行。
 Input          : 状态机栈地址
 Output         : None
 Return         : None
 History:
      1.  hanlufeng 41410  Draft Enact

*****************************************************************************/
VOS_VOID NAS_LMM_FSM_PushState( NAS_LMM_PARALLEL_FSM_ENUM_UINT16 enParalFsmId)
{

    NAS_LMM_FSM_STATE_STACK_STRU       *pstFsmStack;        /* 状态机栈地址 */
    NAS_LMM_FSM_STATE_STRU             *pstCurFsm;          /* 状态机地址 */
    NAS_LMM_FSM_STATE_STRU             *pstFsmStackTop;     /* 指向栈顶状态 */



    /* 入口检查 */
    if ( NAS_LMM_PARA_FSM_ID_INVALID(enParalFsmId))
    {
        NAS_LMM_PUBM_LOG1_ERR("NAS_EMM_FSM_PushState, The input is illegal! enParalFsmId",
                            enParalFsmId);

        return;
    }

    /* 获取EMM状态机当前状态的地址和状态机栈的地址 */
    pstCurFsm      = NAS_LMM_GetCurFsmAddr(NAS_LMM_PARALLEL_FSM_EMM);
    pstFsmStack    = NAS_LMM_GetFsmStackAddr(NAS_LMM_PARALLEL_FSM_EMM);


    /* 状态机栈是否已满 */
    if ( pstFsmStack->ucStackDepth >= NAS_LMM_MAX_STACK_DEPTH )
    {
        NAS_LMM_PUBM_LOG1_ERR("NAS_EMM_FSM_PushState, The stack depth overflow!, ucStackDepth",
                            pstFsmStack->ucStackDepth);

        /* 栈满应该有些出错处理 */

        return;
    }


    /* 获取状态栈栈顶地址 */
    pstFsmStackTop              = &((pstFsmStack->astFsmStack)[pstFsmStack->ucStackDepth]);

    /* 入栈 */
    pstFsmStackTop->enFsmId     = pstCurFsm->enFsmId;
    pstFsmStackTop->enMainState = pstCurFsm->enMainState;
    pstFsmStackTop->enSubState  = pstCurFsm->enSubState;
    pstFsmStackTop->enStaTId    = pstCurFsm->enStaTId;

    /* 栈深度加 1 */
    pstFsmStack->ucStackDepth++;

    return;
}
VOS_VOID    NAS_LMM_FSM_PushTimer(  NAS_LMM_PARALLEL_FSM_ENUM_UINT16 enParalFsmId)
{
    NAS_LMM_FSM_STATE_STRU              *pstCurFsm;          /* 状态机地址 */


    /* 入口检查 */
    if ( NAS_LMM_PARA_FSM_ID_INVALID(    enParalFsmId))
    {
        NAS_LMM_PUBM_LOG1_ERR(           "NAS_LMM_FSM_PushTimer, The input is illegal! enParalFsmId",
                                        enParalFsmId);

        return;
    }

    pstCurFsm                           = NAS_LMM_GetCurFsmAddr(NAS_LMM_PARALLEL_FSM_EMM);

    /* 停当前状态运行的状态保护定时器*/
    NAS_LMM_StopStateTimer(              pstCurFsm->enStaTId);

    return;
}
VOS_VOID    NAS_LMM_FSM_PopTimer(  NAS_LMM_PARALLEL_FSM_ENUM_UINT16 enParalFsmId)
{
    NAS_LMM_FSM_STATE_STRU               *pstCurFsm;          /* 状态机地址 */


    /* 入口检查 */
    if ( NAS_LMM_PARA_FSM_ID_INVALID(    enParalFsmId))
    {
        NAS_LMM_PUBM_LOG1_ERR(           "NAS_LMM_FSM_PushTimer, The input is illegal! enParalFsmId",
                                        enParalFsmId);

        return;
    }

    pstCurFsm                           = NAS_LMM_GetCurFsmAddr(NAS_LMM_PARALLEL_FSM_EMM);

    /* 继续当前状态运行的状态保护定时器,即
        g_stMmMainContext.stNasEmmFsm.astCurFsm.enStaTId*/
    NAS_LMM_StartStateTimer(             pstCurFsm->enStaTId);

    return;

}
示例#5
0
VOS_UINT32  NAS_EMM_MsgPreProcess(  NAS_EMM_EVENT_TYPE_ENUM_UINT32      ulEt,
                                    MsgBlock                           *pMsg )
{
    VOS_UINT32                          ulRet;
    LRRC_LMM_DATA_IND_STRU               *pstTmpRcvMsg       = NAS_EMM_NULL_PTR;
    VOS_UINT8                          *pRcvMsg            = NAS_EMM_NULL_PTR;
    VOS_UINT8                           ucPD               = NAS_EMM_NULL;
    VOS_UINT8                           ucAirMsg           = NAS_EMM_NULL;
    VOS_UINT8                           ucKeyEvent         = NAS_EMM_NULL;
    NAS_LMM_FSM_STATE_STRU              *pstFsmCtx          = NAS_LMM_NULL_PTR;

    ulRet = NAS_LMM_MSG_DISCARD;

    /*结构化消息,取出消息体*/
    pstTmpRcvMsg = (LRRC_LMM_DATA_IND_STRU*)pMsg;
    pRcvMsg      = pstTmpRcvMsg->stNasMsg.aucNasMsg;

    if(ID_LRRC_LMM_DATA_IND == pstTmpRcvMsg->enMsgId)
    {
        /*取出PD*/
        ucPD = pRcvMsg[NAS_EMM_NULL]& EMM_CN_MSG_PDMASK;

        /* 如果是ESM消息直接上报ESM */
        if  (EMM_CN_MSG_PD_ESM == ucPD)
        {
            /* 转发给ESM消息 */
            NAS_EMM_EsmSendDataInd((NAS_EMM_CN_MSGCON_STRU *)&(pstTmpRcvMsg->stNasMsg));
            return  NAS_LMM_MSG_HANDLED;
        }
        /* 如果是TC消息直接上报TC */
        if  (EMM_CN_MSG_PD_TC == ucPD)
        {
            /* 转发给TC消息 */
            NAS_EMM_TcSendDataInd((NAS_EMM_CN_MSGCON_STRU *)&(pstTmpRcvMsg->stNasMsg));
            return  NAS_LMM_MSG_HANDLED;
        }

        /*空口消息上报*/
        if(EMM_CN_MSG_PD_EMM == ucPD)
        {
            NAS_LMM_FindAirMsgId(pRcvMsg[NAS_LMM_CN_MSG_MT_POS], &ucAirMsg, &ucKeyEvent);

            NAS_LMM_SendOmtAirMsg(NAS_EMM_OMT_AIR_MSG_DOWN,
                                        ucAirMsg,
                                        (NAS_MSG_STRU*)&(pstTmpRcvMsg->stNasMsg));

            if (NAS_EMM_NULL != ucKeyEvent)
            {
                NAS_LMM_SendOmtKeyEvent(ucKeyEvent);
            }

            NAS_LMM_MEM_SET(&g_stCnDecodeMsgStru, 0, sizeof(NAS_EMM_CN_MSG_STRU));

            ulRet = NAS_EMM_DecodeCnMsg(pMsg, &g_stCnDecodeMsgStru);

            if(NAS_EMM_FAIL == ulRet )
            {/* 若解码出错,打印报警 */

                NAS_LMM_PUBM_LOG1_ERR("NAS_EMM_MsgProcessInFsm, ulEventType = ", ulEt);

                /*发送EMM STATUS, 接收到不识别的消息 */
                NAS_EMM_SendMsgEmmStatus( NAS_LMM_CAUSE_MSG_NONEXIST_NOTIMPLEMENTE );
                return NAS_LMM_MSG_HANDLED;
            }

            /* 对EMM INFO 和 EMM STATUS 进行处理 */
            ulRet = NAS_EMM_PreProcMsgDataInd();
            return  ulRet;

        }

        ulRet                       = NAS_LMM_MSG_DISCARD;
    }

    /* SM异常消息的处理*/
    if(ID_EMM_ESM_REL_REQ == pstTmpRcvMsg->enMsgId)
    {

        /* 获取状态机地址,用于取状态 */
        pstFsmCtx = NAS_LMM_GetCurFsmAddr(NAS_LMM_PARALLEL_FSM_EMM);

        switch(pstFsmCtx->enMainState)
        {
            case EMM_MS_REG:
            case EMM_MS_REG_INIT:
            case EMM_MS_TAU_INIT:
            case EMM_MS_SER_INIT:
                 NAS_EMM_SmRabmAbnarmalProc();
                 break;
            default:
                 NAS_LMM_PUBM_LOG1_INFO("current MS discard abnormal MSG=========>>>>",
                                        pstTmpRcvMsg->enMsgId);
                 break;
        }
        ulRet                           = NAS_LMM_MSG_HANDLED;
    }

    return  ulRet;
}
VOS_VOID  NAS_LMM_PrintFsmTimer(NAS_LMM_PARALLEL_FSM_ENUM_UINT16         enParallelFsmId)
{
    NAS_LMM_FSM_STATE_STRU              *pstCurFsm;          /* 状态机地址 */
    NAS_LMM_TIMER_CTRL_STRU             *pstTimerSta;        /* 状态定时器 */
    NAS_LMM_TIMER_CTRL_STRU             *pstTimerPtl;        /* 协议定时器 */
    VOS_UINT16                          usPtlTid;


    /* 入口检查 */
    if ( NAS_LMM_PARA_FSM_ID_INVALID(enParallelFsmId))
    {
        NAS_LMM_PUBM_LOG1_ERR("NAS_LMM_FSM_PushTimer, The input is illegal! enParalFsmId",
                             enParallelFsmId);

        return;
    }

    pstCurFsm      = NAS_LMM_GetCurFsmAddr(NAS_LMM_PARALLEL_FSM_EMM);
    pstTimerSta    = NAS_LMM_GetMmTimerStaCtrlAddrByIdx(pstCurFsm->enStaTId);

    /*判断当前状态定时器状态为停止和挂起*/
    if(VOS_NULL_PTR == pstTimerSta->psthTimer)
    {
        /*状态定时器处于挂起状态*/
        if((NAS_LMM_TIMER_SS_SUSPENDING == pstTimerSta->ucTimerSs)
           && (NAS_LMM_TIMER_RS_RUNNING == pstTimerSta->ucTimerRs))
        {
            NAS_LMM_PUBM_LOG1_WARN("NAS_LMM_PrintFsmTimer: State Timer is suspended! enStaTId:",
                                  pstCurFsm->enStaTId);
        }
        /*状态定时器处于停止状态*/
        else
        {
            NAS_LMM_PUBM_LOG1_WARN("NAS_LMM_PrintFsmTimer: State Timer is stoped! enStaTId:",
                                  pstCurFsm->enStaTId);
        }

    }
    /*状态定时器处于运行状态*/

    /*协议定时器*/
    for(usPtlTid = TI_NAS_LMM_PTL_TI_PUB_BOUNDARY_START+1; usPtlTid < NAS_LMM_PTL_TI_BUTT; usPtlTid++)
    {
        pstTimerPtl    = NAS_LMM_GetMmTimerPtlCtrlAddrByIdx(usPtlTid);

        /*协议定时器处于运行状态*/
        if(VOS_NULL_PTR != pstTimerPtl->psthTimer)
        {
            NAS_LMM_PUBM_LOG1_NORM("NAS_LMM_PrintFsmTimer: Ptl Timer is running! PtlTid:",
                                  usPtlTid);
        }
        /*协议定时器处于停止状态*/
        else
        {
            NAS_LMM_PUBM_LOG1_NORM("NAS_LMM_PrintFsmTimer: Ptl Timer is stoped! PtlTid:",
                                  usPtlTid);
        }
    }

    return;
}