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

📄 ldproute.c

📁 技术文件名称:MPLSv1.0软件模块测试规程
💻 C
📖 第 1 页 / 共 5 页
字号:
			{
				MPLS_UPCB_CREATE(fec,session,upCb)
				if(upCb)
				{
					
					upCb->upSessionIndex = session->index;
					wait_uplblmsg_append(upCb,fec,MPLS_NULL,MPLS_NULL,MPLS_LBLMAP_MSGTYPE);
				    upCb->state = ESTABLISHED;
				}
			}
			MPLS_WALK_SESSION_END(session,i)
			session = MPLS_NULL;
			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,"RouteAddProc 2 ,ERR get Down ATM Module & port\n");
							MPLS_ERR_LOG("ERR get UP ATM Module & port");
							/* should release up atm label */
							MPLS_FEC_LSPCB_DELETE(fec,lspCb);
							return;
						}
						/* add into down session link list */
						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,"RouteAddProc 2,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);
					}
				}
			}
		}
		else
			{
				DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"RouteAddProc,creat fec fail\n");
			return;
	}
	}
	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        :   
* 2002.11.14 for no up & down & lspCb found, to delete fecCb        * 
/****************************************************************************/
/* 2003.12.30 fengjun 控制快删除操作中会检查FEC是否需要删除,操作重复 */
void RouteDelProc(IPFORWARDINGTAB * routemsg)
{
	unsigned short      length;
	mplsLdpFecEntry   * fec       = MPLS_NULL;
	mplsLdpSession_t  * session   = MPLS_NULL;
	mplsLdpSession_t  * downSession = MPLS_NULL;
	mplsLdpUpCB       * upCb      = MPLS_NULL;
	mplsLdpLspCB      * lspCb     = MPLS_NULL;
	mplsLdpDownCB     * downCb      = MPLS_NULL;
	unsigned short      dismode,i;
	
	if(routemsg->Dest == MPLS_LOOPBACK_ADDRESS)
		return;
	
	/* no policy check process,directly search fec */
	MPLS_NETMASK2LENGTH((routemsg->NetMask),length);

	#ifdef PSOS
	if((length == 32)&&(routemsg->rt_type == MPLS_ROUTE_OWN))
	{
		MPLS_ADDRESS_DEL(routemsg->Dest);
		InitAdrMsg(&(ldp_snd_msg.addrMsg),MPLS_ADDRWITH_MSGTYPE);
    	ldp_snd_msg.addrMsg.baseMsg.msgId        = messageId[ADDR_M];
    	AddMsgId(ADDR_M);
    	ldp_snd_msg.addrMsg.addressList.baseTlv.length = (unsigned short)(MPLS_ADDFAMFIXLEN + \
    						1*MPLS_IPv4LEN);
		MPLS_WALK_SESSION_BEGIN(session,i)
		dismode = 0;
		MPLS_SESSION_DISTRIBUT_MODE(session,dismode);
		if(dismode != DOWNSTREAMONDEMAND)
		{
			SendTcpMsg(session,MPLS_ADDRWITH_MSGTYPE,&(ldp_snd_msg.addrMsg));
		}
		MPLS_WALK_SESSION_END(session,i)
	}
	#endif
	#ifdef __BGS10_MPLS_DEBUG
	MPLS_ERR_LOG("Route Del routemsg->Dest %x, Length %d,nexthop %x",\
	             routemsg->Dest,length,routemsg->NextHop);
	#endif
	MPLS_FEC_SEARCH(routemsg->Dest,length,fec);
	if(fec == MPLS_NULL)
	{
        DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"MPLS Route Delete fec dest %x len %d not exist\n",routemsg->Dest,length);
	    MPLS_ERR_LOG("MPLS Route Delete fec not exist");
		return;
	}
	else if(fec->nexthopAddr != routemsg->NextHop)
	{ /* szh mod 2003-9-2 在删除路由时去掉对nexthop的判断,主要原因是bgp删除路由带的nexthop错误,
		只能在LDP先做一下处理 */
		if(routemsg->rt_type != MPLS_ROUTE_POLICY)
		{
	    MPLS_ERR_LOG("MPLS Route Delete NextHop Mismatch");
//	        return;
	}	
	}
	if(routemsg->rt_type != MPLS_ROUTE_POLICY)
	    {    
	        fec->owner  &= ~MPLS_OWNER_ROUTE;
	    }
	else
	{
		fec->owner  &= ~MPLS_OWNER_POLICY;
	}
	MPLS_WALK_UP_BEGIN(fec,upCb,t_upCb);
	if(upCb != MPLS_NULL)
	{
		MPLS_INDEX_TO_SESSION(session,upCb->upSessionIndex);
		switch(upCb->state)
		{
			case ESTABLISHED:
				if(session)
				{
					wait_uplblmsg_append(upCb,fec,MPLS_NULL,MPLS_NULL,MPLS_LBLWITH_MSGTYPE);
					upCb->state = RELEASE_AWAITED;
				}
				/* may delete the up control block */
				break;
			case RESPONSE_AWAITED:
				/* send to up notification: no route */
				if(session)
				{
					MPLS_SEND_NOTIFY(session,NOROUTE,upCb->msgid, MPLS_LBLREQ_MSGTYPE);
					upCb->waitflag |=0x1;
				}
				break;
			default:
				printf("mpls_err_log");;
				break;
		}	
	}
	MPLS_WALK_UP_END(fec,upCb,t_upCb)
//	MPLS_NEXTHOP_SESSION_SEARCH(routemsg->NextHop,downSession)
	MPLS_WALK_DOWN_BEGIN(fec,downCb,t_downCb);
	if(downCb != MPLS_NULL)
	{
		switch(downCb->state)
		{
			case ESTABLISHED:
				if(downSession)
				{
					if(fec->nexthopSessionIndex == downCb->downSessionIndex)
					       wait_downfeclbl_append(downCb,fec,LDP_FWD_CLOSE);
					       
				}
				downCb->waitflag |=0x1;
				wait_downlblmsg_append(downCb,fec,MPLS_LBLREL_MSGTYPE);
				
				break;
			case RESPONSE_AWAITED:
				/* send to up notification: no route */
				
				downCb->waitflag |=0x1;
				wait_downlblmsg_append(downCb,fec,MPLS_LBLABORT_MSGTYPE);
				
				break;
			default:
				printf("mpls_err_log");;
				break;
		}	
	}
	MPLS_WALK_DOWN_END(fec,downCb,t_downCb)
	if(routemsg->rt_type != MPLS_ROUTE_POLICY)
	{
	fec->nexthopSessionIndex = 0;
	}
	MPLS_WALK_LSP_BEGIN(fec,lspCb,t_lspCb)
	if(lspCb != MPLS_NULL)
	{
		/* need judge the lspCb nodeType */
		lspCb->pNexthopChange = 1;
		if(!(lspCb->waitflag & 0x1))
		LspCBFsm(MPLS_NULL,MPLS_ROUTE_DELETE,MPLS_NULL,LDP_HOP_LSP,fec,lspCb);
	}
	MPLS_WALK_LSP_END(fec,lspCb,t_lspCb)
    /* do route_add for policy route_del 2003.2.25 wengqing */	
    lspCb = MPLS_NULL;
	if(routemsg->rt_type == MPLS_ROUTE_POLICY && (fec->owner & MPLS_OWNER_ROUTE))
	{
		fec->nodeType = MPLS_NODE_INTERM;
		MPLS_NEXTHOP_SESSION_SEARCH(fec->nexthopAddr,downSession);
		if(downSession)
		{
			MPLS_SESSION_DISTRIBUT_MODE(downSession,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 = downSession->index;
					lspCb->downifIndex			=	downSession->ifIndex;
					lspCb->downPeerLdpid.lsrAddress = downSession->peerLdpId.lsrAddress;
					lspCb->downPeerLdpid.labelSpace = downSession->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;
						/* add into down session link list */
						MPLS_INSERT_INTO_DOWN_LSP_LIST(downSession->lsp_down_cb_list,lspCb,lspCb);
						lspCb->status    = IDLE;
						lspCb->subStatus = IDLE;
						if(!(lspCb->waitflag & 0x1))
						LspCBFsm(downSession,MPLS_ROUTE_ADD,MPLS_NULL,LDP_HOP_LSP,fec,lspCb);
					}
					else
					{
                        DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"RouteDelProc,ERR get Down ATM Module & port\n");
						MPLS_ERR_LOG("ERR get UP ATM Module & port");
						/* should release up atm label */
						MPLS_FEC_LSPCB_DELETE(fec,lspCb);
					}
				}
				else
				    DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"RouteDelProc,creat lspcb fail\n");
			}
		}		
	}
	/* 2002.11.14 for no up & down & lspCb found, to delete fecCb */
	/* 2004-2-5 fengjun mod 恢复删除操作但增加删除条件 */
	if(!((fec->up_cb_list).first||    \
		    (fec->down_cb_list).first||   \
		    (fec->lsp_cb_list).first||    \
		     fec->owner))
	{
	    if(!(fec->mplsFecAddrFamily))
	        return;
        MPLS_FEC_DELETE((fec->fec_key).mplsFecAddr,\
          (fec->fec_key).mplsLdpFecAddrLen,fec);		
    }
	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 RouteNexthopChangeProc(IPFORWARDINGTAB * routemsg)
{
	unsigned short      length;
	mplsLdpFecEntry   * fec       = MPLS_NULL;
	mplsLdpSession_t  * session   = MPLS_NULL;
	mplsLdpUpCB       * upCb      = MPLS_NULL;
	mplsLdpDownCB     * downCb      = MPLS_NULL;
	mplsLdpLspCB      * lspCb     = MPLS_NULL;
	unsigned short      dismode;
	unsigned short       policy_action;
	
	if(routemsg->Dest == MPLS_LOOPBACK_ADDRESS)
		return;
	
	#ifdef __BGS10_MPLS_DEBUG
	MPLS_ERR_LOG("Route nextHop Change routemsg->Dest %x, Length %d,nexthop %x",\
	             routemsg->Dest,length,routemsg->NextHop);
	#endif
	MPLS_NETMASK2LENGTH(routemsg->NetMask,length)

	policy_action = mpls_policy_filter(routemsg->Dest,routemsg->NetMask,routemsg->NextHop);
	if(policy_action == 0)        /* deny */
		return;
	else if(policy_action == 2)    /* egress to */
	    routemsg->rt_type = MPLS_ROUTE_OWN;

	MPLS_FEC_SEARCH(routemsg->Dest,length,fec)
	if(fec == MPLS_NULL)
	{
		printf("mpls_err_log");
		RouteAddProc(routemsg);
		return;
	}
	
	if(fec->nodeType != MPLS_NODE_EGRESS && fec->nodeType != MPLS_NODE_PROXY_EGRESS)
	{
		MPLS_NEXTHOP_SESSION_SEARCH(fec->nexthopAddr,session);
		dismode = 0;
		if(session != MPLS_NULL)
		{
			fec->nexthopSessionIndex = session->index;
			MPLS_SESSION_DISTRIBUT_MODE(session,dismode);
			if(dismode == DOWNSTREAMONDEMAND)
			{
				MPLS_WALK_LSP_BEGIN(fec,lspCb,t_lspCb)
				if(lspCb != MPLS_NULL)
				{
					/* need judge the lspCb nodeType */
					if(!(lspCb->waitflag & 0x1))
					LspCBFsm(session,MPLS_ROUTE_ADD,MPLS_NULL,LDP_HOP_LSP,fec,lspCb);
					if(lspCb->nodeType == INGRESS || 
					   lspCb->nodeType == MPLS_NODE_INTERM_INGRESS)
					{
                                          wait_downfeclbl_append(downCb,fec,LDP_FWD_CREATE);
					}
				}

⌨️ 快捷键说明

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