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

📄 ldpque.c

📁 技术文件名称:MPLSv1.0软件模块测试规程
💻 C
📖 第 1 页 / 共 5 页
字号:
/*************************** LdpQue.c ********************************/
/* 目的:增加消息缓冲队列,停等确认                                   */ 
/* 作者: hu.yonghong                                                 */
/* 日期: 2002-5-30                                                   */
/* 2003.1.26 Huyonhhong if bandwidth/crpvc req timeout,send release it*/
/*                      else process next req                         */
/* 2003.2.20 hyh modify if C timeout and req is release,send untill C response */ 
/* 2003.3.24 hyh modify asend rtcode if lic card offline */
/* 2003.3.27 hyh ldp在收到C会响应时判断是否拷版本,拷版本则延时500ms处理下一请求,否则直接处理 */
/* 2003.4.3 hyh 添加策略的处理函数 */
/* 2003.4.11 hyh mpls_delete_from_policy_tab时更新policy_node */
/* 2003.4.21 hyh 在每次路由振荡后的第一条配置后增加提示命令 */
/* 2003-9-23 lixia add for rel fail                         */
/* szh mod 2003-10-20 减少LDP向A076发送的消息改成函数调用          */
/* 2003-10-21 lixia mod mpls_process_xc_req,mpls_xc_req_confirm  */
/* 2003-11-6 lixia mod mpls_insert_into_policy_tab */
/* 2003-11-21 lixia mod mpls_xc_req_replace for abnormal return */
/* 2003-11-21 lixia mod mpls_xc_req_confirm for the error of NOLSPCB when create pvc successfully   */
/* 2003-12-10 lixia mod for debug mpls   */
/*********************************************************************/
#include"ldpvars.h"

extern unsigned char WritingFileFlag;     /* 拷版本为1,否则为0;在R060中定义 */
unsigned long  Realfail=0;     /*2003-10-10 lixia add */


/**************************************************************************/
/* Init function definition                                               */
/**************************************************************************/
void mpls_init_queue()
{
    /* 跟C进程接口队列初始化 */
    MPLS_MEMSET(&xc_req, 0, sizeof(MPLS_REQ));
    MPLS_INIT_ROOT(xc_req.req_queue);
    xc_req.req_num = 0;
    mpls_reset_xc_req();
    
    /* 跟转发进程(标记整合)接口队列初始化 */
   	GET_PID("Snark_Task",&sbForwardPid);   
   	sbForwardPid.module = selfLdpPid.module;
    MPLS_MEMSET(&feclabel_req, 0, sizeof(MPLS_REQ));
    MPLS_INIT_ROOT(feclabel_req.req_queue);
    feclabel_req_index = 0;
    feclabel_req.req_num = 0;
    mpls_reset_feclabel_req();

    /* 跟FEC接口队列初始化 */
    MPLS_MEMSET(&fec_req, 0, sizeof(MPLS_REQ));
    MPLS_INIT_ROOT(fec_req.req_queue);
    fec_req_index = 0;
    fec_req.req_num = 0;
    mpls_reset_fec_req();
	
    /* 跟A041进程接口队列初始化 */
    MPLS_MEMSET(&mpls_lblmsg_req, 0, sizeof(MPLS_REQ));
    MPLS_INIT_ROOT(mpls_lblmsg_req.req_queue);
    lblmsg_req_index = 0;
    mpls_lblmsg_req.req_num = 0;
    mpls_reset_lblmsg_req();

    /* 策略链表初始化 */
    MPLS_MEMSET(&g_policy_list, 0, sizeof(mpls_policy_list));
        
    /* 未成功删除Pvc链表初始化 lixia add 2003-9-22  */
    MPLS_MEMSET(&g_relpvc_list, 0, sizeof(mpls_relpvc_list));
    
       
    return;	
}

/**PROC+********************************************************************/
/* Name:    mpls_xc_req_append                                             */
/* Author:	hu.yonghong                                                    */
/* Purpose: add request information in queue                               */
/*          for mpls cross-connect request.                                */
/* Returns: Nothing.                                                       */
/* Params:  None.                                                          */
/* Note:    insert the req in the queue tail,do processing                 */
/**PROC-********************************************************************/
short mpls_xc_req_append(void *xcreq,
						unsigned char xcreq_type,
						unsigned char *lqe_loc,
						unsigned char loc_need)
{
  	XC_REQ		     *req_index;
  	MPLS_LQE         *xc_lqe;

  	/* 判断队列是否满? */  
  	if(xc_req.req_num >= MAX_LDP_XC_QUE)
  	{
        DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"******!!! append sorry,xc_req_queue is full !!!******\n");
  		printf("******!!! sorry,xc_req_queue is full !!!******");
    	return REQ_QUEUE_FULL;
  	}
  	/*为请求分配空间*/
  	MPLS_MEM_ALLOC(xc_lqe,(MPLS_LQE *),sizeof(MPLS_LQE),mem_mgr[IUMEM_LDP_XC_QUE_LQE]);
  	if(xc_lqe == MPLS_NULL)
  	{
        DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"!!! sorry,can not allocate memory for xc_lqe !!!\n");
	  	printf("!!! sorry,can not allocate memory for xc_req_queue !!!");
	    return REQ_MEMORY_FAIL;
  	}

  	MPLS_MEM_ALLOC(req_index,(XC_REQ *),sizeof(XC_REQ),mem_mgr[IUMEM_LDP_XC_QUE]);
  	if(req_index == MPLS_NULL)
  	{
        DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"!!! sorry,can not allocate memory for req_index !!!\n");
	  	printf("!!! sorry,can not allocate memory for xc_req_queue !!!");
	    return REQ_MEMORY_FAIL;
  	}
	req_index->req_type = xcreq_type;
  	switch(req_index->req_type)
  	{
  		case BANDWIDTH_REQ:
	  	  	MPLS_MEMCPY(&(req_index->union_req.bw_req),xcreq,sizeof(STRUC_MPLS_AD_BANDWIDTH_REQ));
	  		break;
  		case CRPVC_REQ:
	  	  	MPLS_MEMCPY(&(req_index->union_req.crpvc_req),xcreq,sizeof(STRUC_MPLS_AD_CRPVC_REQ));
  	  		break;
  		case RLSBW_REQ:
  	  		MPLS_MEMCPY(&(req_index->union_req.rlsbw_req),xcreq,sizeof(STRUC_MPLS_AD_RLSBW_REQ));
  	  		break;
  		case RLSPVC_REQ:
  	  		MPLS_MEMCPY(&(req_index->union_req.rlspvc_req),xcreq,sizeof(STRUC_MPLS_AD_RLSPVC_REQ));
  	  		break;
  		default:
  	  		break;
  	}

  	/* 为请求初始化一个队列节点,分配空间,将其加入到相应队列的尾部 */
  	MPLS_INIT_LQE(*xc_lqe,req_index);
  	MPLS_INSERT_BEFORE(xc_req.req_queue,*xc_lqe);
  	if(loc_need)
  		lqe_loc = MPLS_LIST_PREV(xc_req.req_queue);
  	
	/*队列中请求个数增1*/
  	xc_req.req_num++;
  	
  	/* 开始处理对头请求 */
 	if(xc_req.req_in_progress == 0)
 	mpls_process_xc_req();

	return REQ_QUEUE_OK;
}

/**PROC+********************************************************************/
/* Name:    mpls_process_xc_req                                            */
/* Author:	hu.yonghong                                                    */
/* Purpose: process request information for mpls cross-connect request.    */
/* Returns: Nothing.                                                       */
/* Params:  None.                                                          */
/* Note:    process the head req in queue                                  */
/* 2003-10-21 lixia mod for unsuccessful send                              */
/**PROC-********************************************************************/
void mpls_process_xc_req()
{
  	XC_REQ     				*req_index;
  	unsigned long			rtcode;
        STRUC_AD_MPLS_RLSPVC_ACK  rel_ack;   /*2003-10-17 lixia add*/ 
        PID                FixBugPid;  
    
        GET_PID("Fix_Bug",&FixBugPid); 
  	
  	/* if some xc_req is processing or the xc_req queue is empty,return */
  	if((xc_req.req_in_progress == 1)||
     	((req_index = (XC_REQ *)MPLS_NEXT_IN_LIST(xc_req.req_queue)) == MPLS_NULL))
    	return ;

  	xc_req.req_in_progress = 1 ;

  	/* set timer */   
	MPLS_SET_TIMER(XC_CONF_TIME,(void *)mpls_xcreq_queue_timeout,0,ldptime_q,xc_req.timerid);
  	switch(req_index->req_type)
  	{
	  	case BANDWIDTH_REQ:
	      	pvcPid.module 	 = req_index->union_req.bw_req.L_module;
	      	rtcode = ASEND(MPLS_AD_BANDWIDTH_REQ, &(req_index->union_req.bw_req), sizeof(STRUC_MPLS_AD_BANDWIDTH_REQ),pvcPid);     
		    #ifdef __BGS10_MPLS_DEBUG
					printf(	"==== Module %d  send MPLS_AD_BANDWIDTH_REQ.localLspId::%d,IngressId:%x,LspCBNo %x====\n",
				         	selfLdpPid.module,
				          req_index->union_req.bw_req.localLspId,
				          req_index->union_req.bw_req.IngressId,
				          req_index->union_req.bw_req.LspCBNo);
					printf(	"====H_MODULE:%d,H_PORT:%d,====\n",
				          req_index->union_req.bw_req.H_module,
				          req_index->union_req.bw_req.H_port);
					printf(	"====L_MODULE:%d,L_PORT:%d,====\n",
				          req_index->union_req.bw_req.L_module,
				          req_index->union_req.bw_req.L_port);
/*					printf(	"====ServiceCategory:%d,TrafficDescrParam1:%ld====Param2: %d===\n",
				          req_index->union_req.bw_req.ServiceCategory,
				    	  req_index->union_req.bw_req.TrafficDescrParam,
				    	  req_index->union_req.bw_req.TrafficDescrParam2);*/
			#endif

  	  		break;

  		case CRPVC_REQ:
	      	pvcPid.module 		= req_index->union_req.crpvc_req.L_module;
		  	rtcode = ASEND(MPLS_AD_CREATEPVC_REQ, &(req_index->union_req.crpvc_req),sizeof(STRUC_MPLS_AD_CRPVC_REQ), pvcPid);
			#ifdef __BGS10_MPLS_DEBUG
				printf("==== Module %d  send MPLS_AD_CREATEPVC_REQ.localLspId::%d,IngressId:%x,LspCBNo %x,rtcode %d====\n",
				    selfLdpPid.module,
				    req_index->union_req.crpvc_req.localLspId,
				    req_index->union_req.crpvc_req.IngressId,
				    req_index->union_req.crpvc_req.LspCBNo,
				    rtcode);
				printf("====H_MODULE:%d,H_PORT:%d,H_vpi:%d,H_vci:%d====\n",
				    req_index->union_req.crpvc_req.H_module,
				    req_index->union_req.crpvc_req.H_port,
				    req_index->union_req.crpvc_req.H_vpi,
				    req_index->union_req.crpvc_req.H_vci);
				printf("====L_MODULE:%d,L_PORT:%d,L_vpi:%d,L_vci:%d====\n",
				    req_index->union_req.crpvc_req.L_module,
				    req_index->union_req.crpvc_req.L_port,
				    req_index->union_req.crpvc_req.L_vpi,
				    req_index->union_req.crpvc_req.L_vci);
/*				printf("====ServiceCategory:%d,TrafficDescrParam1:%ld====Param2: %d,Param3:%d,Param4:%d,Param5:%d,TrafficDescrType:%d===\n",
				    req_index->union_req.crpvc_req.ServiceCategory,
				    req_index->union_req.crpvc_req.TrafficDescrParam1,
				    req_index->union_req.crpvc_req.TrafficDescrParam2,
				    req_index->union_req.crpvc_req.TrafficDescrParam3,
				    req_index->union_req.crpvc_req.TrafficDescrParam4,
				    req_index->union_req.crpvc_req.TrafficDescrParam5,
				    req_index->union_req.crpvc_req.TrafficDescrType);*/
			#endif
  	  		break;

  		case RLSBW_REQ:
	      	pvcPid.module 		= req_index->union_req.rlsbw_req.L_module;
	      	rtcode = ASEND(MPLS_AD_RLSBW_REQ,&(req_index->union_req.rlsbw_req),sizeof(STRUC_MPLS_AD_RLSBW_REQ),pvcPid);
	        #ifdef __BGS10_MPLS_DEBUG
				printf("==== Module %d,SEND MPLS_AD_RLSBW_REQ IngressId:%x,localLspId:%d=====",
				    selfLdpPid.module,
				    req_index->union_req.rlsbw_req.IngressId,
				    req_index->union_req.rlsbw_req.localLspId);
			    printf("==== L_module:%d,L_port:%d,H_module:%d,H_port:%d,LspCBNo:%x====",
			        req_index->union_req.rlsbw_req.L_module,
			        req_index->union_req.rlsbw_req.L_port,
			        req_index->union_req.rlsbw_req.H_module,
			        req_index->union_req.rlsbw_req.H_port,
			        req_index->union_req.rlsbw_req.LspCBNo);
			#endif
  	  		break;

  		case RLSPVC_REQ:
	      	pvcPid.module 		 = req_index->union_req.rlspvc_req.L_module;
	      	rtcode = ASEND(MPLS_AD_RLSPVC_REQ, &(req_index->union_req.rlspvc_req),sizeof(STRUC_MPLS_AD_RLSPVC_REQ), pvcPid);
			#ifdef __BGS10_MPLS_DEBUG
				printf("==== Module %d  send MPLS_AD_RLSEPVC_REQ.localLspId::%d,IngressId:%x,LspCBNo:%x====\n",
				    selfLdpPid.module,
				    req_index->union_req.rlspvc_req.localLspId,
				    req_index->union_req.rlspvc_req.IngressId,
				    req_index->union_req.rlspvc_req.LspCBNo);
				printf("====H_MODULE:%d,H_PORT:%d,H_vpi:%d,H_vci:%d====\n",
				    req_index->union_req.rlspvc_req.H_module,
				    req_index->union_req.rlspvc_req.H_port,
				    req_index->union_req.rlspvc_req.H_vpi,
				    req_index->union_req.rlspvc_req.H_vci);
				printf("====L_MODULE:%d,L_PORT:%d,L_vpi:%d,L_vci:%d====\n",
				    req_index->union_req.rlspvc_req.L_module,
				    req_index->union_req.rlspvc_req.L_port,
				    req_index->union_req.rlspvc_req.L_vpi,
				    req_index->union_req.rlspvc_req.L_vci);
				printf("====flag:%x====\n",req_index->union_req.rlspvc_req.reflag);
		           
			#endif
	  	  	break;

  		default:
  	  		break;
  	}
  
    if(rtcode == 0x6014)	/* 发送不成功,立即删队头请求,处理下一个请求 */
    {
        if(req_index->req_type==RLSPVC_REQ)   /*释放不成功,放入队列中继续发送*/
        {
        	
        /*	printf("==== send MPLS_AD_RLSEPVC_REQ fail,localLspId::%d,IngressId:%x,LspCBNo:%x====\n",req_index->union_req.rlspvc_req.localLspId,
				    		req_index->union_req.rlspvc_req.IngressId,req_index->union_req.rlspvc_req.LspCBNo);
			printf("====H_MODULE:%d,H_PORT:%d,H_vpi:%d,H_vci:%d====\n",
				    		req_index->union_req.rlspvc_req.H_module,req_index->union_req.rlspvc_req.H_port,req_index->union_req.rlspvc_req.H_vpi,req_index->union_req.rlspvc_req.H_vci);
			printf("====L_MODULE:%d,L_PORT:%d,L_vpi:%d,L_vci:%d====\n",
				    		req_index->union_req.rlspvc_req.L_module,req_index->union_req.rlspvc_req.L_port,req_index->union_req.rlspvc_req.L_vpi,req_index->union_req.rlspvc_req.L_vci);
        	printf("===realease flag is %d,realease num is %d===\n",req_index->union_req.rlspvc_req.reflag,req_index->union_req.rlspvc_req.renum);*/
        	rel_ack.LsrAck = SEND_RELPVC_FAIL;
		rel_ack.localLspId = req_index->union_req.rlspvc_req.localLspId;
		rel_ack.IngressId = req_index->union_req.rlspvc_req.IngressId; 
		rel_ack.L_module =  req_index->union_req.rlspvc_req.L_module;
		rel_ack.L_port = req_index->union_req.rlspvc_req.L_port;
		rel_ack.L_vpi = req_index->union_req.rlspvc_req.L_vpi;
		rel_ack.L_vci = req_index->union_req.rlspvc_req.L_vci;
		rel_ack.H_module = req_index->union_req.rlspvc_req.H_module;
		rel_ack.H_port = req_index->union_req.rlspvc_req.H_port;
		rel_ack.H_vpi = req_index->union_req.rlspvc_req.H_vpi;
		rel_ack.H_vci = req_index->union_req.rlspvc_req.H_vci;
		rel_ack.LspCBNo = req_index->union_req.rlspvc_req.LspCBNo;
		rel_ack.flag = 0; 
		rel_ack.reflag = rel_ack.reflag|0x01; 
		if (!(req_index->union_req.rlspvc_req.reflag&0x01))
		{
		    rel_ack.renum = RESEND_RELPVC_NUM-1;
				/*printf("==== first send MPLS_AD_RLSEPVC_REQ fail,localLspId::%d,IngressId:%x,LspCBNo:%x====\n",req_index->union_req.rlspvc_req.localLspId,
				    		req_index->union_req.rlspvc_req.IngressId,req_index->union_req.rlspvc_req.LspCBNo);
				printf("====H_MODULE:%d,H_PORT:%d,H_vpi:%d,H_vci:%d====\n",
				    		req_index->union_req.rlspvc_req.H_module,req_index->union_req.rlspvc_req.H_port,req_index->union_req.rlspvc_req.H_vpi,req_index->union_req.rlspvc_req.H_vci);
				printf("====L_MODULE:%d,L_PORT:%d,L_vpi:%d,L_vci:%d====\n",
				    		req_index->union_req.rlspvc_req.L_module,req_index->union_req.rlspvc_req.L_port,req_index->union_req.rlspvc_req.L_vpi,req_index->union_req.rlspvc_req.L_vci);*/
		    Realfail++;
		    if(g_relpvc_list.num !=0)	   
	     		mpls_insert_into_relpvc_tab(&rel_ack);    		
    		    else
    		    {
    			mpls_insert_into_relpvc_tab(&rel_ack);
    	    		ASEND(MPLS_RELPVC,&rel_ack,sizeof(STRUC_AD_MPLS_RLSPVC_ACK),FixBugPid); 
    	            }
    		}
		if ((req_index->union_req.rlspvc_req.reflag &0x01)&&(req_index->union_req.rlspvc_req.renum >0)) 
		{
		    rel_ack.renum = req_index->union_req.rlspvc_req.renum;
				/*printf("==== %d send MPLS_AD_RLSEPVC_REQ fail,localLspId::%d,IngressId:%x,LspCBNo:%x====\n",RESEND_RELPVC_NUM-rel_ack.renum,req_index->union_req.rlspvc_req.localLspId,
				    		req_index->union_req.rlspvc_req.IngressId,req_index->union_req.rlspvc_req.LspCBNo);

⌨️ 快捷键说明

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