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

📄 ldproute.c

📁 技术文件名称:MPLSv1.0软件模块测试规程
💻 C
📖 第 1 页 / 共 5 页
字号:
				MPLS_WALK_LSP_END(fec,lspCb,t_lspCb)
			}
			else
			{
				downCb = MPLS_NULL;
				MPLS_DOWNCB_SEARCH(fec,session,downCb);
				if(downCb != MPLS_NULL)
				{
                                    wait_downfeclbl_append(downCb,fec,LDP_FWD_CREATE);
				}
			}
		}
	}
	fec->nexthopAddr = routemsg->NextHop;
	fec->outIfindex  = routemsg->IfIndex;
	if(fec->nodeType != MPLS_NODE_EGRESS && fec->nodeType != MPLS_NODE_PROXY_EGRESS)
	{
		MPLS_NEXTHOP_SESSION_SEARCH(routemsg->NextHop,session)
		dismode = 0;
		if(session == MPLS_NULL)
			return;
		fec->nexthopSessionIndex = session->index;
		MPLS_SESSION_DISTRIBUT_MODE(session,dismode);
		if(dismode == DOWNSTREAMONDEMAND)
		{
			MPLS_LSPCB_CREATE(fec,lspCb);
			if(lspCb)
			{
				lspCb->lspIndex = MPLS_GET_LSP_INDEX;
				lspCb->lspType = LDP_HOP_LSP;
				lspCb->nodeType = MPLS_NODE_INGRESS;
				lspCb->downSessionIndex = session->index;
				lspCb->downifIndex			=	session->ifIndex;
				lspCb->downPeerLdpid.lsrAddress = session->peerLdpId.lsrAddress;
				lspCb->downPeerLdpid.labelSpace = session->peerLdpId.labelSpace;
				ifindex2mod_req.ifIndex 			= lspCb->downifIndex;
				ifindex2mod_req.mpls_protocol_type	= MPLS_LABEL_SWITCH_PROTOCOL_ATM;
				ifindex2mod_req.mpls_platform      	= local_platform;
				mpls_ifindex2module(&ifindex2mod_req,&ifindex2mod_ack,MPLS_INTERFACE);
				if(ifindex2mod_ack.ack == MPLS_SUCCESS)
				{
					lspCb->downAtmLabel.module = ifindex2mod_ack.mod;
					lspCb->downAtmLabel.port   = ifindex2mod_ack.port;
				}
				else
				{
                    DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"ERR get Down ATM Module & port\n");
					MPLS_ERR_LOG("ERR get Down ATM Module & port");
					/* should release up atm label */
					MPLS_FEC_LSPCB_DELETE(fec,lspCb);
					return;
				}
				MPLS_INSERT_INTO_DOWN_LSP_LIST(session->lsp_down_cb_list,lspCb,lspCb);
				
				lspCb->status    = IDLE;
				lspCb->subStatus = IDLE;
				if(!(lspCb->waitflag & 0x1))
				LspCBFsm(session,MPLS_ROUTE_ADD,MPLS_NULL,LDP_HOP_LSP,fec,lspCb);
			}
			else
            {
                DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"creat lspcb fail\n");
			    printf("creat lspcb fail\n");
			}
		}
		else
		{
			downCb = MPLS_NULL;
			MPLS_DOWNCB_SEARCH(fec,session,downCb);
			if(downCb != MPLS_NULL)
			{
                             wait_downfeclbl_append(downCb,fec,LDP_FWD_CREATE);
			}
		}
	}
	return;
}
/****************************************************************************/
/*      Product Name:   MPLS PACK1.0
 *      Module  Name:   LDP/CR_LDP
 *      File    Name:   ldppdu.h
 *      Author  Name:   weng.qing shi.zhaohui hu.yonghong
 *      Creat   Date:   2002-6-18
 *      Version     :   1.0
 *      Input       :   mplsLdpSession_t *, inbound seesion pointer;
 *                      void             *, inputEvent;
 *      Output      :   void
 *      Function    :   Label release process function
 *      Note        :   
*/      
/****************************************************************************/
void fec_entry_update(mplsLdpFecEntry * fec,IPFORWARDINGTAB * routemsg, 
                      unsigned char type)
{
	mplsLdpSession_t * session = MPLS_NULL;
	mplsLdpDownCB    * downCb  = MPLS_NULL;
	unsigned short     dismode = 0;
	
	if(fec == MPLS_NULL || routemsg == MPLS_NULL)
		return;
	fec->mplsLdpFecType = MPLS_PREFIX_FEC;
	#if 0	
	if(ntohl(routemsg->NetMask) == 0xFFFFFFFF)
	{
		fec->mplsLdpFecType = MPLS_HOSTADR_FEC;
	}
	#endif
	fec->mplsFecAddrFamily = MPLS_IPV4;
	
	if(routemsg->rt_type == MPLS_ROUTE_POLICY)
	{
		fec->owner |= MPLS_OWNER_POLICY;
		/*********************************************************************/
		/* when proxy egress used in route aggregate enviroment, nexthop does not 
		 * send label mapping message; but used in no route aggregate enviroment,
		 * downstream lsr send label mapping message.
		 * when downstream lsr is ATM label mode, for the lsp exist, we does not
		 * process,
		 * when downstream lsr is General label mode, for the lsp exist,to prevent
		 * proxy egress delete, label request to the nexthop, we does not release
		 * label from next hop; just send to XC out label is implicit null.
		 *
		 * here should check if nexthop lsr have send label mapping
		 */
		 /*********************************************************************/
		if( (fec->owner & MPLS_OWNER_ROUTE))
		{
			if((fec->nodeType == MPLS_NODE_INTERM))
			{
				/******************************************************************/
				/* judge nexthop lsr label
				*/
				/******************************************************************/
				MPLS_NEXTHOP_SESSION_SEARCH(fec->nexthopAddr,session);
				dismode = 0;
				if(session != MPLS_NULL)
				{
					MPLS_SESSION_DISTRIBUT_MODE(session,dismode);
					if(dismode == DOWNSTRAMUNSOLICITED)
					{
						downCb = MPLS_NULL;
						MPLS_DOWNCB_SEARCH(fec,session,downCb);
						if(downCb != MPLS_NULL)
						{
							/*****************************************************/
							/* add into XC link list for XC process, set downCb 
							 * XC_Delete, when process XC, should judge PROXY_EGRESS
							*/
							/*****************************************************/
							;
						}
					}
					#if 0
					else
					{
						/*****************************************************/
						/* LIC -- LIC, no process  
						*/
						/*****************************************************/
						;
					}
					#endif
				}
			}
		}
		fec->nodeType = MPLS_NODE_PROXY_EGRESS;
		/*********************************************************************/
		/* for consistency consideration, we only hunt local gen label when 
		 * actule route add; release local label when all necessary processing
		 * have done.
		*/
		/*********************************************************************/
		
	}
	else
	{
		/*********************************************************************/
		/* only route add, get local label,and when i have no local label 
		*/
		/*********************************************************************/
		fec->owner |= MPLS_OWNER_ROUTE;
		if(type == MPLS_EGRESS_TO_POLICY)
		    fec->pRes |= MPLS_EGRESS_TO_POLICY;   //when egress to
		else if (type == MPLS_DENY_POLICY)
		    fec->pRes |= MPLS_DENY_POLICY;
		else
		{
		    fec->pRes = 0;
		}    	    
//		if(fec->nodeType != MPLS_NODE_PROXY_EGRESS)
		{
			/* promise egress to first, next from lic, update  localGenLabel*/
			if((fec->nodeType == MPLS_NODE_PROXY_EGRESS)  && (routemsg->rt_type != MPLS_ROUTE_OWN))
			{
				fec->localGenLabel = 0;
			}
			if((fec->nodeType != MPLS_NODE_PROXY_EGRESS)  && (routemsg->rt_type == MPLS_ROUTE_OWN))
		    {
				MPLS_RELEASE_GEN_LABEL(fec->localGenLabel);
				fec->localGenLabel = 0;
			}
			/* 当egress targeted时,路由过来不要更新fec->nodeType */
			if((fec->owner & MPLS_OWNER_POLICY) != MPLS_OWNER_POLICY)
	     	{
			    fec->nodeType = routemsg->rt_type == MPLS_ROUTE_OWN ? \
								MPLS_NODE_EGRESS:MPLS_NODE_INTERM;
			}				
			if(fec->nodeType == MPLS_NODE_EGRESS && fec->localGenLabel == 0)
			{
				fec->localGenLabel = MPLS_IMPLICIT_NULL;
				#ifdef __BGS10_MPLS_DEBUG
				MPLS_ERR_LOG("LDP Get Local Label %d",fec->localGenLabel);
				#endif
			}
			else if(fec->localGenLabel == 0)
			{
				fec->localGenLabel = MPLS_HUNT_GEN_LABEL();
				#ifdef __BGS10_MPLS_DEBUG
				MPLS_ERR_LOG("LDP Get Local Label %d",fec->localGenLabel);
				#endif
			}
		}
		/*else*/ if(fec->localGenLabel == 0)
		{
			/*****************************************************************/
			/* localGenLabel ==0, have not local label
			*/
			/*****************************************************************/
				fec->localGenLabel = MPLS_HUNT_GEN_LABEL();
			#ifdef __BGS10_MPLS_DEBUG
			MPLS_ERR_LOG("LDP Get Local Label %d",fec->localGenLabel);
			#endif
		}
	}
	fec->nexthopAddr   = routemsg->NextHop;
	fec->outIfindex    = routemsg->IfIndex;
	
	return;	
}

/****************************************************************************/
/*      Product Name:   MPLS PACK1.0
 *      Module  Name:   LDP/CR_LDP
 *      File    Name:   ldppdu.h
 *      Author  Name:   weng.qing shi.zhaohui hu.yonghong
 *      Creat   Date:   2002-6-18
 *      Version     :   1.0
 *      Input       :   mplsLdpSession_t *, inbound seesion pointer;
 *                      void             *, inputEvent;
 *      Output      :   void
 *      Function    :   Label release process function
 *      Note        :   add j: because DoD and DU label distribution mode, performance is different;
 *                       when fec is full, sessionup only scan j, not all, else other session may down
 *                       wengqing modify 2002/12/16
*/      
/****************************************************************************/
void SessionUp(mplsLdpSession_t * session)
{
	mplsLdpFecEntry    * fecCb = MPLS_NULL;
	mplsLdpUpCB        * upCb  = MPLS_NULL;
	mplsLdpLspCB       * lspCb = MPLS_NULL;
	mpls_local_addr    * addrEntry = MPLS_NULL;
	mpls_fec_search *pSearch = MPLS_NULL;
	unsigned short       dismode;
	MPLS_BOOL            belong_to;
	unsigned short       i = 0,j = 0;
	
	InitAdrMsg(&(ldp_snd_msg.addrMsg),MPLS_ADDR_MSGTYPE);
    ldp_snd_msg.addrMsg.baseMsg.msgId  = messageId[ADDR_M];
    AddMsgId(ADDR_M);
	WALK_ADDRESS_BEGIN(addrEntry)
	if(addrEntry)
	{
		if(i < MPLS_MAXNUMBERADR)
		{
			ldp_snd_msg.addrMsg.addressList.address[i++] = addrEntry->addr_key;
		}
		else
		{
			ldp_snd_msg.addrMsg.addressList.baseTlv.length = (unsigned short)(MPLS_ADDFAMFIXLEN + \
													MPLS_MAXNUMBERADR*MPLS_IPv4LEN);
	    	SendTcpMsg(session,MPLS_ADDR_MSGTYPE,&(ldp_snd_msg.addrMsg));
	    	InitAdrMsg(&(ldp_snd_msg.addrMsg),MPLS_ADDR_MSGTYPE);
	    	ldp_snd_msg.addrMsg.baseMsg.msgId     = messageId[ADDR_M];
	    	AddMsgId(ADDR_M);
	    	i = 0;
	    }
	}
	WALK_ADDRESS_END
	if(i > 0)
	{
		InitAdrMsg(&(ldp_snd_msg.addrMsg),MPLS_ADDR_MSGTYPE);
    	ldp_snd_msg.addrMsg.baseMsg.msgId     = messageId[ADDR_M];
    	AddMsgId(ADDR_M);
		ldp_snd_msg.addrMsg.addressList.baseTlv.length = (unsigned short)(MPLS_ADDFAMFIXLEN + \
												(i)*MPLS_IPv4LEN);
    	SendTcpMsg(session,MPLS_ADDR_MSGTYPE,&(ldp_snd_msg.addrMsg));
	}	
	i = 0;	
	dismode = 0;
	MPLS_SESSION_DISTRIBUT_MODE(session,dismode);
	j = (dismode == DOWNSTREAMONDEMAND) ? 32 : 512;
	WALK_FEC_BEGIN(fecCb)
	if(fecCb != MPLS_NULL)
	{
        /* wengqing 2003.3.27 在session up时判断是否还有要删的块未处理,
                          若有,则定时5s再来检查,没有要删的块才开始新建立 */		
        if(g_up_lsp_list.first != MPLS_NULL || g_down_lsp_list.first != MPLS_NULL || fec_lspcb_scan.timer != 0)
		{
			MPLS_FEC_SEARCH_CREATE(g_fec_search_list,pSearch)
			if(pSearch)
			{
				pSearch->session = session;
				pSearch->addr    = fecCb->fec_key.mplsFecAddr;
				pSearch->addrLen = fecCb->fec_key.mplsLdpFecAddrLen;
				printf("2 set delay timer 5s");
				MPLS_SET_TIMER(50,(void *)ldpFecSearchCheck,(void *)pSearch,ldptime_q,pSearch->tmier);
				if(pSearch->tmier == 0)
				{
                    DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"SessionUP,MPLS_FEC_SEARCH_CREATE SET_TIMER Fail\n");
					MPLS_ERR_LOG("MPLS_FEC_SEARCH_CREATE SET_TIMER Fail");
					MPLS_FEC_SEARCH_DELETE(g_fec_search_list,pSearch);
				}
			}
			break;
		}		
	    if(++i >= j)
		{
			MPLS_FEC_SEARCH_CREATE(g_fec_search_list,pSearch)
			if(pSearch)
			{
				pSearch->session = session;
				pSearch->addr    = fecCb->fec_key.mplsFecAddr;
				pSearch->addrLen = fecCb->fec_key.mplsLdpFecAddrLen;
				MPLS_SET_TIMER(10,(void *)ldpFecSearchCheck,(void *)pSearch,ldptime_q,pSearch->tmier);
				if(pSearch->tmier == 0)
				{
                    DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"SessionUp 2 MPLS_FEC_SEARCH_CREATE SET_TIMER Fail\n");
					MPLS_ERR_LOG("MPLS_FEC_SEARCH_CREATE SET_TIMER Fail");
					MPLS_FEC_SEARCH_DELETE(g_fec_search_list,pSearch);
				}
			}
			break;
		}
		if(dismode == DOWNSTREAMONDEMAND)
		{
			if((fecCb->owner 	& MPLS_OWNER_ROUTE) && \
			   (fecCb->nodeType  != MPLS_NODE_EGRESS) && \
			   (fecCb->nodeType  != MPLS_NODE_PROXY_EGRESS) &&(!(fecCb->pRes & MPLS_DENY_POLICY)))
			{
			
				belong_to = MPLS_FALSE;
				MPLS_NEXTHOP_SESSION_BELONG(fecCb->nexthopAddr,session,belong_to);
				if(belong_to == MPLS_TRUE && session->index != fecCb->nexthopSessionIndex)
				{
					#if 1
					fecCb->nexthopSessionIndex = session->index;
					MPLS_LSPCB_CREATE(fecCb,lspCb);
					if(lspCb)
					{
						lspCb->lspIndex = MPLS_GET_LSP_INDEX;

⌨️ 快捷键说明

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