⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ldpsess.c

📁 技术文件名称:MPLSv1.0软件模块测试规程
💻 C
📖 第 1 页 / 共 5 页
字号:
        session->subState   =   NONIDLE;
        ProcTcpConRetry(session);
    }
    return;   
}

/******************************************************************************/
/*function:     TcpConAwaited_TcpTimeout                                      */
/*Author:       weng.qing   hu.yonghong                                       */
/*decription:                                                                 */
/*              delete session tcp relavent timer                             */
/*              Retry tcp connect                                             */
/******************************************************************************/
void TcpConAwaited_TcpTimeout(mplsLdpSession_t * session)
{
    int 		rtcode;
    if(session->role == ACTIVE)
    {
        /* delete Tcp Timer */
		if(session->tmidCon > 0)
		{
			MPLS_CLEAR_TIMER(session->tmidCon,ldptime_q,rtcode);
			session->tmidCon = 0;
        }
        /* Retry Tcp Connect Request */
        session->state      =   NONEXISTENT;
        session->subState   =   NONIDLE;
        ProcTcpConRetry(session);
    }
    return;   
}


/******************************************************************************/
/*function:     ProcInit_Initial                                              */
/*Author:       weng.qing    hu.yonghong                                      */
/*decription:                                                                 */
/*              delete session tcp relavent timer                             */
/*              Retry tcp connect                                             */
/******************************************************************************/
short  ProcInit_Initial(mplsLdpSession_t * session, void * inputEvent)
{
    ldpMibHelloIndexReq_t           helIndex;
	mplsLdpHello_t 					*hello = MPLS_NULL;
    mplsLdpInitMsg_t              	*initMsg;
    unsigned short                  loop;
    int			rtcode;
    initMsg 		= (mplsLdpInitMsg_t *)inputEvent;

    /* entityLdpId & peerLdpId check hello Adjacency table */
    helIndex.unionIndex.entityLdpId  = session->entityLdpId;
    helIndex.unionIndex.ifIndex		 = session->ifIndex;
    helIndex.unionIndex.peerLdpId    = session->peerLdpId;
    helIndex.indexFlag               = 2;
    hello = (mplsLdpHello_t *)MibHello(&helIndex, LDP_SEARCH);
    
    if (hello == NULL)
    {
    	DelTmid(session);
        ProcCloseSes(session,
        			 SREJNOHELLO,
        			 initMsg->baseMsg.msgId,
        			 initMsg->baseMsg.flags.flags.msgType);
        printf("in ProcInit_Initial,can not find hello \n");
        DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_SESSION,"in ProcInit_Initial,can not find hello \n");
        return LDP_FALSE; 
    }      
	            
    /* reset Keepalive maintain timer */
	if(session->life_timerid > 0)
	{
		MPLS_CLEAR_TIMER(session->life_timerid,ldptime_q,rtcode);
		session->life_timerid = 0;
	}
	MPLS_SET_TIMER(session->keepAliveHoldTime,
					(void *)sessTimeout,
					session,
					ldptime_q,
					session->life_timerid);
    
    /* negotiate session parameter */
    initMsg = (mplsLdpInitMsg_t *)inputEvent;
    if(InitNegotiate(session,initMsg) == LDP_FALSE)     
               /* negotiate fail  */
    {
		if(session->life_timerid > 0)
		{
			MPLS_CLEAR_TIMER(session->life_timerid,ldptime_q,rtcode);
			session->life_timerid = 0;
		}
        DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_SESSION,"ProcInit_Initial,Init Msg Negotiate Error!!!\n");
        printf("ProcInit_Initial,Init Msg Negotiate Error!!!\n");
        SendTcpRel(session); 
        return LDP_FALSE;
    }
    if( session->role   ==   PASSIVE )
    {
        /*send INIT & KEEPALIVE message */
        
        if  (SendInitKeepalMsg(session) == LDP_FALSE)   
        {
            DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_SESSION,"====ProcInit_Initial,Session %d,MODULE :%d  SEND INITKeepAlMSG FAIL ====\n",session->ifIndex,
	    	                selfLdpPid.module);
        	printf("====Session %d,MODULE :%d  SEND INITKeepAlMSG FAIL ====\n",session->ifIndex,
	    	                selfLdpPid.module);
            return LDP_FALSE;       
        }
        else
        {
        	#ifdef SESSION_DEBUG
	            #ifdef __BGS10_MPLS_DEBUG
	    	        printf("====MODULE :%d  SEND INITKeepAlMSG ====\n",
	    	                selfLdpPid.module);
	    	    #endif
    		#endif
        }
        
    }	
    /*state transit */
    session->state      = OPENREC;
    session->subState   = NONIDLE;
    return  LDP_TRUE;
}


/******************************************************************************/
/*function:     ProcessTcpRelInd                                              */
/*Author:       weng.qing    hu.yonghong                                      */
/*decription:                                                                 */
/*              kill session tcp relavent timer                               */
/*              kill session maintain timer,delete session maintain timerId   */
/*              kill session send timer,delete session send timerId           */
/*              delete peer table                                             */
/******************************************************************************/
void ProcessTcpRelInd( mplsLdpSession_t * session )
{

    /* delete session maintain timer */
    /* delete & kill keepAlive send timer */
	DelTmid(session);

    /* delete peer addr table */
    if( delPeerAddrTable( session ) == LDP_TRUE )
    {
        #ifdef SESSION_DEBUG
                #ifdef __BGS10_MPLS_DEBUG
    		        printf("====MODULE :%d   DELETE PEERADDR TABLE ====\n",
    		                selfLdpPid.module);
		        #endif
		    #endif    
    }
    else
    {
        printf("====Session %d,in ProcessTcpRelInd,MODULE :%d   DELETE PEERADDR TABLE fail====\n",session->ifIndex,
    		                selfLdpPid.module);
        DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_SESSION,
        "====Session %d,in ProcessTcpRelInd,MODULE :%d   DELETE PEERADDR TABLE fail====\n",session->ifIndex,
    		                selfLdpPid.module);
    }
    /*
    	now we decide to delete up and downstream control block when receive 
    	Release_Ind from TCP
    */
    if (session->state == OPERATIONAL)
    {
    	FuncSendLost(session);
    }
        /* check if session have hello adjacency */
    if ( checkSessionHello( session ) != 0 )
    {
	    ProcTcpConRetry(session);
	}    
    return;
}

/*Modify:       hu.yonghong 2002-7-3 15:55	*/
void procInit_OpenSent(mplsLdpSession_t * session, void * inputEvent)
{
    mplsLdpInitMsg_t                * initMsg;
    short							ss;
    int			rtcode,rtcode1;
    
    /* reset Keepalive maintain timer */
	if(session->life_timerid > 0)
	{
		MPLS_CLEAR_TIMER(session->life_timerid,ldptime_q,rtcode);
		session->life_timerid = 0;
	}
	MPLS_SET_TIMER(session->keepAliveHoldTime,
					(void *)sessTimeout,
					session,
					ldptime_q,
					session->life_timerid);

    /*negotiate session parameter */
    initMsg = (mplsLdpInitMsg_t *)inputEvent;
    ss		=	InitNegotiate(session,initMsg);
    if  ( ss == LDP_FALSE)            
    {
		if(session->life_timerid > 0)
		{
			MPLS_CLEAR_TIMER(session->life_timerid,ldptime_q,rtcode1);
			session->life_timerid = 0;
		}
		session->life_timerid = 0;
        DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_SESSION,"procInit_OpenSent,Init Msg Negotiate Error!!!\n");
        printf("procInit_OpenSent,Init Msg Negotiate Error!!!\n");
        SendTcpRel(session);
        return;
    }
    /*send KEEPALIVE message*/
    ss		=	SendKeepalMsg(session);
    if  ( ss == LDP_FALSE)  
    {
        DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_SESSION,"====procInit_OpenSent,Session %d,MODULE :%d  SEND KeepAlMSG FAIL====\n",session->ifIndex,
	                selfLdpPid.module);
        printf("====Session %d,MODULE :%d  SEND KeepAlMSG FAIL====\n",session->ifIndex,
	                selfLdpPid.module);
        return;
    }
    else
    {
        printf("====MODULE :%d  SEND KeepAlMSG ====\n",
	                selfLdpPid.module);
    }
        
	/*state transit */
	session->state      =   OPENREC;
	session->subState   =   NONIDLE;
	
	return;
}



/* state OPENREC process Keepalive message */
/*Modify:       hu.yonghong 2002-7-3 */

void  ProcKeepal_OpenRec(mplsLdpSession_t * session)
{	                
    int			rtcode;
    /* reset Keepalive maintain timer */
	if(session->life_timerid > 0)
	{
		MPLS_CLEAR_TIMER(session->life_timerid,ldptime_q,rtcode);
		session->life_timerid = 0;
	}
	MPLS_SET_TIMER(session->keepAliveHoldTime,
					(void *)sessTimeout,
					session,
					ldptime_q,
					session->life_timerid);
    /* state transit */
    session->state      	=   OPERATIONAL;
    session->subState       =   NONIDLE;
    #ifdef SESSION_DEBUG
        #ifdef __BGS10_MPLS_DEBUG
        	printf("====MODULE :%d IFINDEX:%d SESSION OPERATIONAL =======\n",
        	        selfLdpPid.module,session->ifIndex);
    	#endif
    #endif
    /* reset session connect retry num 2001/09/04 */
    session->tcpConRetry    =   0;
    SessionUp(session);
    return;
}

short ProcAddr_Operat( mplsLdpSession_t * session, unsigned short eventType, void * inputEvent)
{
    unsigned short					ii;   	                
    mplsLdpAdrMsg_t               * adrMsg;
    int			rtcode;
    sessionPeerAddr_t               adrSettmp;
    sessionPeerAddr_t               *adrSet = MPLS_NULL;
    ldpMibPeerAddrIndexReq_t        adrIndex;
    MIB_LDP_SESSION_PEERADDR_ACK 	adrAck;
    sessionPeerAddr_t				*peerAddr = MPLS_NULL;
    
    /* reset Keepalive maintain timer */
	if(session->life_timerid > 0)
	{
		MPLS_CLEAR_TIMER(session->life_timerid,ldptime_q,rtcode);
		session->life_timerid = 0;
	}
	MPLS_SET_TIMER(session->keepAliveHoldTime,
					(void *)sessTimeout,
					session,
					ldptime_q,
					session->life_timerid);
    
    /* process address message */
    adrMsg      = (mplsLdpAdrMsg_t *)inputEvent;
    if(adrMsg->adrListTlvExists == 0 )
    {
    	MPLS_SEND_NOTIFY(session,MISSPARAMETER,adrMsg->baseMsg.msgId, \
					adrMsg->baseMsg.flags.flags.msgType);
    	return;
    }
    if( adrMsg->addressList.addrFamily != 0x0001 )
    {
    	DelTmid(session);
        ProcCloseSes(session,
        			 MALFORMTLVVAL,
        			 adrMsg->baseMsg.msgId,
        			 adrMsg->baseMsg.flags.flags.msgType);
		return LDP_FALSE;
	}
	/* add by hyh,check address value between MPLS_IPADDR_MIN and MPLS_IPADDR_MAX*/
    for (ii=0; ii<MPLS_MAXNUMBERADR; ii++)
    {
        if (adrMsg->addressList.address[ii] == 0)
            break;
		if(((adrMsg->addressList.address[ii] != 0)&&
			(adrMsg->addressList.address[ii] < MPLS_IPADDR_MIN))||
			(adrMsg->addressList.address[ii] > MPLS_IPADDR_MAX))
		{
	    	DelTmid(session);
	        ProcCloseSes(session,
	        			 MALFORMTLVVAL,
	        			 adrMsg->baseMsg.msgId,
	        			 adrMsg->baseMsg.flags.flags.msgType);
			return LDP_FALSE;
		}
	}
    if  (eventType == MPLS_ADDR_MSGTYPE)
    {
        adrSettmp.nextHopAddressType = adrMsg->addressList.addrFamily;    
        adrSettmp.sessionIndex       = session->index;
        memcpy(&(adrSettmp.ldpId),&(session->peerLdpId),sizeof(mplsLdpId_t));
        
        for (ii=0; ii<MPLS_MAXNUMBERADR; ii++)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -