/*****************************************************************************
 Function Name   : NAS_ERABM_RcvCdsErabmServiceNotify
 Description     : ERABM模块CDS_ERABM_SERVICE_NOTIFY消息分发处理
 Input           : CDS_ERABM_SERVICE_NOTIFY_STRU *pRcvMsg-----------消息指针
 Output          : VOS_VOID
 Return          : VOS_VOID

 History         :
     1.lihong00150010      2011-12-06  Draft Enact
     2.lihong00150010      2012-12-14  Modify:Emergency

*****************************************************************************/
VOS_VOID  NAS_ERABM_RcvCdsErabmServiceNotify
(
    const CDS_ERABM_SERVICE_NOTIFY_STRU    *pRcvMsg
)
{
    /*打印进入该函数*/
    NAS_ERABM_INFO_LOG("NAS_ERABM_RcvCdsErabmServiceNotify is entered.");

    (VOS_VOID)pRcvMsg;

    /* 承载没有对应的DRB的场景下,并且定时器没有启动时,向EMM发起请求 */
    if (NAS_ERABM_SUCCESS == NAS_ERABM_IsAllActtiveBearerWithoutDrb())
    {
        if(NAS_ERABM_TIMER_STATE_STOPED != NAS_ERABM_IsTimerRunning(NAS_ERABM_WAIT_RB_REEST_TIMER))
        {
            NAS_ERABM_NORM_LOG("NAS_ERABM_RcvCdsErabmServiceNotify:Reest timer started!" );
            return ;
        }

        /*发送EMM_ERABM_REEST_REQ消息后,设置服务请求启动*/
        NAS_ERABM_SetEmmSrState(NAS_ERABM_SERVICE_STATE_INIT);
		/* lihong00150010 emergency tau&service begin */
        if (VOS_TRUE == NAS_ERABM_IsEmcService(pRcvMsg->ucRabId))
        {
            NAS_ERABM_SndRabmEmmReestReq(VOS_TRUE);

            NAS_ERABM_TimerStart(   NAS_ERABM_WAIT_RB_REEST_LENGTH,
                                    NAS_ERABM_WAIT_RB_REEST_TIMER,
                                    VOS_TRUE);
        }
        else
        {
            NAS_ERABM_SndRabmEmmReestReq(VOS_FALSE);

            NAS_ERABM_TimerStart(   NAS_ERABM_WAIT_RB_REEST_LENGTH,
                                    NAS_ERABM_WAIT_RB_REEST_TIMER,
                                    VOS_FALSE);
        }
		/* lihong00150010 emergency tau&service end */
    }
    else
    {
        NAS_ERABM_NORM_LOG("NAS_ERABM_RcvCdsErabmServiceNotify:Already in Connect state!" );
        NAS_ERABM_SetEmmSrState(NAS_ERABM_SERVICE_STATE_TERMIN);

        /* 通知CDS启动二次过滤 */
        NAS_ERABM_SndErabmCdsSndBuffDataInd(CDS_ERABM_SEND_BUFF_DATA_ALLOWED_TYPE_SERVICE_SUCC);
    }
}
/*lint -e961*/
VOS_VOID  NAS_ERABM_RcvRabmEmmReestInd(const EMM_ERABM_REEST_IND_STRU *pRcvMsg )
{
    if (NAS_ERABM_L_MODE_STATUS_NORMAL != NAS_ERABM_GetLModeStatus())
    {
        NAS_ERABM_WARN_LOG("NAS_ERABM_RcvRabmEmmReestInd:Rabm is already suspended!");
        return ;
    }

    switch(pRcvMsg->enReEstState)
    {
        /*case EMM_ERABM_REEST_STATE_SUCC:*/
        case EMM_ERABM_REEST_STATE_FAIL:

            /*打印进入该函数*/
            NAS_ERABM_LOG1("NAS_ERABM_RcvRabmEmmReestInd: receive Emm Reset result: .",
                          pRcvMsg->enReEstState);
            /*SERVICE流程结束*,停止定时器*/
            NAS_ERABM_TimerStop(NAS_ERABM_WAIT_RB_REEST_TIMER);
            NAS_ERABM_SetEmmSrState(NAS_ERABM_SERVICE_STATE_TERMIN);
            /* 如果在正常模式下 */
            if (NAS_ERABM_MODE_TYPE_NORMAL == NAS_ERABM_GetMode())
            {
                /* 通知L2释放缓存的数据包 */
                /*APPITF_FreeAllofRabmBuf();*/

                /* 通知CDS释放缓存的数据包 */
                NAS_ERABM_SndErabmCdsFreeBuffDataInd();

                /* 清除上行数据阻塞标志*/
                NAS_ERABM_SetUpDataPending(EMM_ERABM_NO_UP_DATA_PENDING);
            }
            else if (NAS_ERABM_TIMER_STATE_STOPED == NAS_ERABM_IsTimerRunning(NAS_ERABM_WAIT_TC_FREE_BUFFER_TIMER))
            /*环回模式下不清理缓存,保持原上行数据Pending状态*/
            {
                NAS_ERABM_INFO_LOG("NAS_ERABM_RcvRabmEmmReestInd: NAS_ERABM_WAIT_TC_FREE_BUFFER_TIMER start.");
                /* lihong00150010 emergency tau&service begin */
                NAS_ERABM_TimerStart(   NAS_ERABM_WAIT_TC_FREE_BUFFER_LENGTH,
                                        NAS_ERABM_WAIT_TC_FREE_BUFFER_TIMER,
                                        NAS_ERABM_WAIT_TC_FREE_BUFFER_TIMER);
            }   /* lihong00150010 emergency tau&service end */
            else
            {
                NAS_ERABM_INFO_LOG("NAS_ERABM_RcvRabmEmmReestInd: NAS_ERABM_WAIT_TC_FREE_BUFFER_TIMER is running.");
            }
            break;

        case EMM_ERABM_REEST_STATE_INITIATE:

            /*打印进入该函数*/
            NAS_ERABM_INFO_LOG("NAS_ERABM_RcvRabmEmmReestInd: receive EMM_ERABM_REEST_STATE_INITIATE .");
            /*SERVICE流程启动,启动定时器*/
            if (NAS_ERABM_SERVICE_STATE_TERMIN == NAS_ERABM_GetEmmSrState())
            {/* lihong00150010 emergency tau&service begin */
                NAS_ERABM_TimerStart(   NAS_ERABM_WAIT_RB_REEST_LENGTH,
                                        NAS_ERABM_WAIT_RB_REEST_TIMER,
                                        VOS_FALSE);
                NAS_ERABM_SetEmmSrState(NAS_ERABM_SERVICE_STATE_INIT);
            }/* lihong00150010 emergency tau&service end */
            break;

        default:
            NAS_ERABM_WARN_LOG("NAS_ERABM_RcvRabmEmmReestInd:WARNNING: EstState illegal!");
            break;
    }
}