📄 ldpque.c
字号:
return;
case CRPVC_REQ:
DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP," === CRPVC_REQ mpls_xcreq_queue_timeout === \n");
printf(" === CRPVC_REQ mpls_xcreq_queue_timeout === ");
crpvc_to_release(&(req_index->union_req.crpvc_req));
return;
case RLSBW_REQ:
DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP," === RLSBW_REQ mpls_xcreq_queue_timeout === \n");
printf(" === RLSBW_REQ mpls_xcreq_queue_timeout === ");
break;
case RLSPVC_REQ:
DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP," === RLSPVC_REQ mpls_xcreq_queue_timeout === \n");
printf(" === RLSPVC_REQ mpls_xcreq_queue_timeout === ");
break;
default:
break;
}
/* 继续处理队列中的对头请求 */
mpls_reset_xc_req();
mpls_process_xc_req();
}
return;
}
#endif
/**PROC+********************************************************************/
/* Name: mpls_xcreq_next */
/* Author: hu.yonghong */
/* Purpose: process next req in queue. */
/* Returns: Nothing. */
/* Params: None. */
/* 2003.1.26 huyonghong get current CR req_num in queue */
/**PROC-********************************************************************/
void mpls_xcreq_next()
{
MPLS_LQE *xc_lqe;
int rtcode;
XC_REQ *req_index;
unsigned long lspIndex;
if(!MPLS_EMPTY_LIST(xc_req.req_queue))
{
/* 将对头请求出队列,释放空间 */
xc_lqe = MPLS_GET_FIRST_LQE(xc_req.req_queue);
MPLS_ASSERT(xc_lqe != MPLS_NULL);
req_index = (XC_REQ *)(xc_lqe->self);
lspIndex = ldp_get_crque_num(req_index);
MPLS_REMOVE_FROM_LIST(*xc_lqe);
MPLS_MEM_FREE((xc_lqe->self),mem_mgr[IUMEM_LDP_XC_QUE]);
MPLS_MEM_FREE((xc_lqe),mem_mgr[IUMEM_LDP_XC_QUE_LQE]);
/* 队列请求个数减一 */
xc_req.req_num--;
MPLS_ASSERT(xc_req.req_num >= 0);
if(!(lspIndex & 0x80000000))
cur_crreq_num--;
MPLS_ASSERT(cur_crreq_num >= 0);
/* 取消定时器 */
if(xc_req.timerid > 0)
{
MPLS_CLEAR_TIMER(xc_req.timerid,ldptime_q,rtcode);
MPLS_ASSERT(rtcode == 1);
if(rtcode)
xc_req.timerid = 0;
}
/* 继续处理队列中的对头请求 */
mpls_reset_xc_req();
mpls_process_xc_req();
}
return;
}
/**PROC+********************************************************************/
/* Name: mpls_reset_xc_req */
/* Author: hu.yonghong */
/* Purpose: Reset request information for mpls cross-connect request. */
/* Returns: Nothing. */
/* Params: None. */
/* */
/**PROC-********************************************************************/
void mpls_reset_xc_req()
{
/* Reset request information for the cross-connect request. */
xc_req.req_in_progress = 0;
xc_req.index = 0;
xc_req.timerid = 0;
return;
}
/**PROC+********************************************************************/
/* Name: delete_lspindex_xcque */
/* Author: hu.yonghong */
/* Purpose: If corresponding req in Queue,remove it and free the space. */
/* Returns: Nothing. */
/* Params: lspIndex. */
/* */
/**PROC-********************************************************************/
void delete_lspindex_xcque(unsigned long lspIndex)
{
MPLS_LQE *xc_lqe = MPLS_NULL;
/* 查找对应的请求,将请求出队列,释放空间 */
if(!MPLS_EMPTY_LIST(xc_req.req_queue))
{
search_lspindex_xcque(lspIndex,xc_lqe);
if(xc_lqe != MPLS_NULL)
{
MPLS_REMOVE_FROM_LIST(*xc_lqe);
MPLS_MEM_FREE((xc_lqe->self),mem_mgr[IUMEM_LDP_XC_QUE]);
MPLS_MEM_FREE((xc_lqe),mem_mgr[IUMEM_LDP_XC_QUE_LQE]);
/* 队列请求个数减一 */
xc_req.req_num--;
MPLS_ASSERT(xc_req.req_num >= 0);
if(!(lspIndex & 0x80000000))
cur_crreq_num--;
MPLS_ASSERT(cur_crreq_num >= 0);
}
}
return;
}
#if 0
void delete_lqe_xcque(unsigned char *lqe_loc)
{
MPLS_LQE *xc_lqe = MPLS_NULL;
/* 查找对应的请求,将请求出队列,释放空间 */
if(!MPLS_EMPTY_LIST(xc_req.req_queue))
{
xc_lqe = (MPLS_LQE *)lqe_loc;
if(xc_lqe != MPLS_NULL)
{
MPLS_REMOVE_FROM_LIST(*xc_lqe);
MPLS_MEM_FREE((xc_lqe->self),mem_mgr[IUMEM_LDP_XC_QUE]);
MPLS_MEM_FREE((xc_lqe),mem_mgr[IUMEM_LDP_XC_QUE_LQE]);
/* 队列请求个数减一 */
xc_req.req_num--;
MPLS_ASSERT(xc_req.req_num >= 0);
}
}
return;
}
#endif
/**PROC+********************************************************************/
/* Name: search_lspindex_xcque */
/* Author: hu.yonghong */
/* Purpose: Search the req in Queue with lspIndex. */
/* Returns: Nothing. */
/* Params: lspIndex,xc_lqe. */
/* */
/**PROC-********************************************************************/
void search_lspindex_xcque(unsigned long lspIndex,MPLS_LQE *xc_lqe)
{
XC_REQ *req_index = MPLS_NULL;
unsigned long matchIndex;
xc_lqe = (MPLS_LQE *)MPLS_LIST_NEXT(xc_req.req_queue);
while(!MPLS_LIST_ROOT(*xc_lqe))
{
req_index = (XC_REQ *)xc_lqe->self;
switch(req_index->req_type)
{
case BANDWIDTH_REQ:
matchIndex = req_index->union_req.bw_req.IngressId;
break;
case CRPVC_REQ :
matchIndex = req_index->union_req.crpvc_req.IngressId;
break;
case RLSBW_REQ:
matchIndex = req_index->union_req.rlsbw_req.IngressId;
break;
case RLSPVC_REQ:
matchIndex = req_index->union_req.rlspvc_req.IngressId;
break;
default:
break;
}
if(matchIndex == lspIndex)
break;
xc_lqe = (MPLS_LQE *)MPLS_LIST_NEXT(*xc_lqe);
}
return;
}
/* 2003-11-21 lixia add for abnormal return */
short mpls_xc_req_replace(void *xcreq,
unsigned char xcreq_type)
{
XC_REQ *req_index;
MPLS_LQE *xc_lqe1;
MPLS_LQE *xc_lqe2;
int rtcode;
unsigned long lspIndex;
if(!MPLS_EMPTY_LIST(xc_req.req_queue))
{
/* 将对头请求出队列,释放空间 */
xc_lqe1 = MPLS_GET_FIRST_LQE(xc_req.req_queue);
MPLS_ASSERT(xc_lqe1 != MPLS_NULL);
req_index = (XC_REQ *)(xc_lqe1->self);
lspIndex = ldp_get_crque_num(req_index);
MPLS_REMOVE_FROM_LIST(*xc_lqe1);
MPLS_MEM_FREE((xc_lqe1->self),mem_mgr[IUMEM_LDP_XC_QUE]);
MPLS_MEM_FREE((xc_lqe1),mem_mgr[IUMEM_LDP_XC_QUE_LQE]);
/* 2003-11-21 lixia add for abnormal return */
xc_req.req_num--;
MPLS_ASSERT(xc_req.req_num >= 0);
if(!(lspIndex & 0x80000000))
cur_crreq_num--;
MPLS_ASSERT(cur_crreq_num >= 0);
/* add end */
/* 取消定时器 */
if(xc_req.timerid > 0)
{
MPLS_CLEAR_TIMER(xc_req.timerid,ldptime_q,rtcode);
MPLS_ASSERT(rtcode == 1);
if(rtcode)
xc_req.timerid = 0;
}
/*为释放请求分配空间*/
MPLS_MEM_ALLOC(xc_lqe2,(MPLS_LQE *),sizeof(MPLS_LQE),mem_mgr[IUMEM_LDP_XC_QUE_LQE]);
if(xc_lqe2 == MPLS_NULL)
{
DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"!!! sorry,can not allocate memory for xc_lqe2 !!!\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_index2 !!!\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 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_lqe2,req_index);
MPLS_INSERT_AFTER(xc_req.req_queue,*xc_lqe2);
/* 2003-11-21 lixia add for abnormal return */
/*队列中请求个数增1*/
xc_req.req_num++;
if(!(lspIndex & 0x80000000))
cur_crreq_num++;
/*add end*/
/* 开始处理对头请求 */
mpls_reset_xc_req();
mpls_process_xc_req();
return REQ_QUEUE_OK;
}
}
/* 2003.1.26 huyonghong
* get current CR req_num in queue */
unsigned long ldp_get_crque_num(XC_REQ *req_index)
{
unsigned long matchIndex = 0;
switch(req_index->req_type)
{
case BANDWIDTH_REQ:
matchIndex = req_index->union_req.bw_req.IngressId;
break;
case CRPVC_REQ :
matchIndex = req_index->union_req.crpvc_req.IngressId;
break;
case RLSBW_REQ:
matchIndex = req_index->union_req.rlsbw_req.IngressId;
break;
case RLSPVC_REQ:
matchIndex = req_index->union_req.rlspvc_req.IngressId;
break;
default:
break;
}
return matchIndex;
}
/**************************************************************************/
/*同标记整合模块的缓冲函数 */
/**************************************************************************/
/**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_feclabel_req_append(void *req,unsigned char req_type)
{
FECLABEL_REQ *req_index;
MPLS_LQE *feclabel_lqe = MPLS_NULL;
/* 判断队列是否满? */
if(feclabel_req.req_num >= MAX_LDP_FECLABEL_QUE)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -