📄 ldplspfsm.c
字号:
resend_time = ldp_get_random(MPLS_RANDOM_TIME_RANGE,abort_time);
MPLS_SET_TIMER(resend_time,(void *)ldp_req_timout,LspCBVar,ldptime_q,LspCBVar->timerid); /* lixia mod 2003-11-6 */
}
/*向下游节点发送request*/
wait_lsplblmsg_append(LspCBVar,pEntry,MPLS_NULL,MPLS_NULL,MPLS_LBLREQ_MSGTYPE);
}
/*add by fengjun for guangzhou */
short ProcLblReq_status1(mplsLdpSession_t *session,void *pEntry, mplsLdpLspCB *LspCBVar, void * inputEvent)
{
/* 发学路由请求,子状态切为FEC_INDEX_REQ_AWAITED */
mplsLdpLblReqMsg_t *lblReqMsg;
FecMsg fecMsg;
lblReqMsg = (mplsLdpLblReqMsg_t *)inputEvent;
MPLS_MEMSET(&fecMsg,0,sizeof(FecMsg));
if (LspCBVar->subStatus != IDLE)
return LDP_FALSE;
if((LspCBVar->lspType == LDP_HOP_LSP)&&(LspCBVar->nodeType == MPLS_NODE_INTERM))
{
/*ATM---ATM:请求预留资源(子状态切为BANDWITH_REQ_AWAITED)*/
LspCBVar->subStatus = BANDWITH_REQ_AWAITED;
if(LspCBVar->lspType == LDP_HOP_LSP)
return Xcbandwithreq(LspCBVar,pEntry);
/*add by fengjun for guangzhou
return wait_xc_append(LspCBVar,pEntry,0x0);
add by fengjun for guangzhou */
else
return CR_wait_xc_append(LspCBVar,pEntry,0x0);
}
else
{
/*发学路由请求,学习建路业务板信息,子状态切为FEC_INDEX_REQ_AWAITED*/
fecMsg.OperateType = INQUIRE_TYPE;
seg_fec_msg(&fecMsg,lblReqMsg);
fecMsg.Fec.lspIndex = LspCBVar->lspIndex;
LspCBVar->subStatus = FEC_INDEX_REQ_AWAITED;
#if 1
ldp_inquirertepro(&fecMsg,session->ifIndex);
ProcFecInquire(&fecMsg);
#endif
#ifdef __BGS10_MPLS_DEBUG
printf("==== Module %d,MPLS_PSEND MPLS_FEC_STUDY INQUIRE ====",selfLdpPid.module);
#endif
return LDP_TRUE;
}
}/*ProcLblReq_status1*/
short ProcRouteAdd_status1(void *pEntry, mplsLdpLspCB *LspCBVar)
{
/* 发学路由请求,子状态切为FEC_INDEX_REQ_AWAITED */
FecMsg fecMsg;
mplsLdpFecEntry *fecEntry;
fecEntry = (mplsLdpFecEntry *)pEntry;
MPLS_MEMSET(&fecMsg,0,sizeof(FecMsg));
if ((LspCBVar->subStatus != IDLE)||
(LspCBVar->nodeType != MPLS_NODE_INGRESS))
return LDP_FALSE;
/*发学路由请求,学习建路业务板信息,子状态切为FEC_INDEX_REQ_AWAITED*/
fecMsg.OperateType = INQUIRE_TYPE;
fecMsg.Fec.TlvExists.flags.fecTlvExists = 1;
fecMsg.Fec.fecElemNum = 1;
fecMsg.Fec.fecElArray[0].addressEl.address = fecEntry->fec_key.mplsFecAddr;
fecMsg.Fec.fecElArray[0].addressEl.preLen = fecEntry->fec_key.mplsLdpFecAddrLen;
fecMsg.Fec.fecElArray[0].addressEl.addressFam = fecEntry->mplsFecAddrFamily;
fecMsg.Fec.fecElArray[0].addressEl.type = fecEntry->mplsLdpFecType;
fecMsg.Fec.lspIndex = LspCBVar->lspIndex;
LspCBVar->subStatus = FEC_INDEX_REQ_AWAITED;
#if 1
ldp_inquirertepro(&fecMsg,0xffff);
ProcFecInquire(&fecMsg);
#endif
#ifdef __BGS10_MPLS_DEBUG
printf("==== MPLS_PSEND MPLS_FEC_STUDY INQUIRE,FEC %x,lspIndex %x ====",
fecEntry->fec_key.mplsFecAddr,LspCBVar->lspIndex);
#endif
return LDP_TRUE;
}/*ProcRouteAdd_status1*/
/*2003.1.28 Huyonghong 对聚合,更新下游模块和端口 */
short ProcFecInquireOk (void * inputEvent)
{
/*1.如果查路由失败,发notify,删除lspCB*/
/*2.由路由判断是否egress*/
/*2.1.egress:分配下游标记,上游标记,请求建立PVC,主状态切为RESPONSE_AWAITED,
子状态切为CREATE_PVC_REQ_AWAITED*/
/*2.2.非egress:请求预留资源(子状态切为BANDWITH_REQ_AWAITED)*/
FecMsg *fecMsg;
mplsLdpFecEntry *pFecEntry = NULL;
mplsLdpCrLsp *pCrEntry = NULL;
char *pEntry = NULL;
mplsLdpLspCB *LspCBVar = NULL;
mplsLdpLspCB *LspCV = NULL;
mplsLdpLspCB * lspCb_t = MPLS_NULL;
mpls_sb_list * sb_list;
unsigned short preLen;
short rtcode=0;
unsigned long nexthop;
STRUC_MPLS_AD_RLSPVC_REQ pvclabel;
release_pvc_tab_t *rel_pvc = MPLS_NULL;
unsigned long module = 0 ;
MPLS_MEMSET(&pvclabel, 0, sizeof(STRUC_MPLS_AD_RLSPVC_REQ));
p_s_f = MPLS_NULL; /*2004-5-11 lixia mod for label req fail*/
fecMsg = (FecMsg *)inputEvent;
preLen = fecMsg->Fec.fecElemTypes[0] == MPLS_HOSTADR_FEC ? \
32: fecMsg->Fec.fecElArray[0].addressEl.preLen;
/*查找lspCB*/
if(fecMsg->Fec.TlvExists.flags.lspidTlvExists == 1)
{
pCrEntry = (mplsLdpCrLsp *)ldp_search_crentry_from_lspidtlv(fecMsg->Fec.lspidTlv);
if(pCrEntry == NULL)
return LDP_FALSE;
pEntry = (char *)pCrEntry;
LspCBVar = &(pCrEntry->crlspCb);
}
else
{
pFecEntry = ldp_search_fecentry(preLen,
fecMsg->Fec.fecElArray[0].addressEl.address);
if(pFecEntry == NULL)
{
DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"ProcFecInquireOk,ldp_search_fecentry fail\n");
MPLS_ERR_LOG("ldp_search_fecentry fail");
return LDP_FALSE;
}
pEntry = (char *)pFecEntry;
LspCBVar = ldp_search_lspcb_from_index(pFecEntry,fecMsg->Fec.lspIndex);
if(LspCBVar == NULL)
{
DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"ProcFecInquireOk,ldp_search_lspcb_from_index fail\n");
MPLS_ERR_LOG("ldp_search_lspcb_from_index fail");
return LDP_FALSE;
}
}
/* 查找路由成功 */
/*取到建路业务板信息,填到LspCB中*/
if(ldp_fec2lspCB(LspCBVar,fecMsg) == LDP_FALSE)
{
DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"ProcFecInquireOk,ldp_fec2lspCB fail\n");
MPLS_ERR_LOG("ldp_fec2lspCB fail");
return LDP_FALSE;
}
if(LspCBVar->nodeType != MPLS_NODE_INTERM)
{
sb_list = MPLS_NULL;
MPLS_SB_SEARCH(fecMsg->Fec.sbModule,fecMsg->Fec.sbPort,sb_list);
if(!sb_list)
{
MPLS_SB_CREATE(fecMsg->Fec.sbModule,fecMsg->Fec.sbPort,sb_list)
}
if(sb_list)
{
if(LspCBVar->nodeType == MPLS_NODE_EGRESS)
{
MPLS_INSERT_INTO_DOWN_LSP_LIST(sb_list->lsp_down_cb_list,LspCBVar,LspCBVar);
}
else if(LspCBVar->nodeType == MPLS_NODE_INGRESS)
{
MPLS_INSERT_INTO_UP_LSP_LIST(sb_list->lsp_up_cb_list,LspCBVar,LspCBVar);
}
}
}
/*判断是否egress*/
if(LspCBVar->nodeType == MPLS_NODE_EGRESS)
{
/************************************************************/
/* wengqing add for fec aggregate
*/
/************************************************************/
/* 当存在FEC聚合时,同一FEC可能使用同一标记,Label Release无法区分,此处为了防止这种情况,
加以防止;当存在相同路径向量时,不接纳新的Label Request*/
if(LspCBVar->lspType == LDP_HOP_LSP)
{
pFecEntry = (mplsLdpFecEntry *)(LspCBVar->selffec);
MPLS_WALK_LSP_BEGIN(pFecEntry,LspCV,t_lspCb)
if(LspCV != MPLS_NULL && LspCV != LspCBVar) /* for protect */
{
#ifdef __BGS10_MPLS_DEBUG
printf(" !!!!!!!! input protect !!!!!!!!!!!!!");
#endif
if((LspCV->pAttr.hopcount == LspCBVar->pAttr.hopcount) && \
(LspCV->pAttr.len == LspCBVar->pAttr.len) && \
(!MPLS_MEMCMP(LspCV->pAttr.pAttr,LspCBVar->pAttr.pAttr,LspCBVar->pAttr.len))
)
{
sb_list = MPLS_NULL;
MPLS_SB_SEARCH(LspCBVar->downAtmLabel.module,\
LspCBVar->downAtmLabel.port,sb_list);
if(!sb_list)
{
MPLS_REMOVE_FROM_SESSION_DOWN_LSP_LIST(g_down_lsp_list,LspCBVar);
}
else
{
MPLS_REMOVE_FROM_SESSION_DOWN_LSP_LIST_A(sb_list->lsp_down_cb_list,LspCBVar);
if(!(sb_list->lsp_down_cb_list.first ||sb_list->lsp_up_cb_list.first))
MPLS_SB_DELETE(LspCBVar->downAtmLabel.module,\
LspCBVar->downAtmLabel.port,sb_list)
}
LspCBVar->errorcode = PROTECTERROR;
SndNotMsg(LspCBVar->upSessionIndex,INTERNALERROR,LspCBVar->upMsgid,\
MPLS_LBLREQ_MSGTYPE);
if(LspCBVar->waitflag & 0xe0)
{
LspCBVar->waitflag |= 0x1;
}
else
{
ldp_del_lspCB((char *)pFecEntry,LspCBVar);
}
/* 保护多块时,防止建立不起来 */
if(!(LspCV->waitflag & 0x1))
{
/* 2003.4.23 wengqing 增加保护,如果ldpcb的链表乱掉,将该链表加入到待删除链中 */
#if MPLS_PROTECT
if(LspCV->up_lsp_session_list.prev)
{
if((LspCV->up_lsp_session_list.prev)->up_lsp_session_list.next != LspCV)
{
// LspCV->up_lsp_session_list.prev = MPLS_NULL;
lspCb_t = LspCV;
while(lspCb_t->up_lsp_session_list.next)
{
lspCb_t = lspCb_t->up_lsp_session_list.next;
}
lspcb_scan ++;
/*MPLS_INSERT_INTO_UP_LSP_LIST(g_up_lsp_list,
LspCV, \
lspCb_t);*/
MplsInsertIntoupGlobalList(g_up_lsp_list,LspCV->upSessionIndex,LspCV,lspCb_t);
return LDP_FALSE;
}
}
else if(LspCV->down_lsp_session_list.prev)
{
if((LspCV->down_lsp_session_list.prev)->down_lsp_session_list.next != LspCV)
{
// LspCV->down_lsp_session_list.prev = MPLS_NULL;
lspCb_t = LspCV;
while(lspCb_t->down_lsp_session_list.next)
{
lspCb_t = lspCb_t->down_lsp_session_list.next;
}
lspcb_scan ++;
/*MPLS_INSERT_INTO_DOWN_LSP_LIST(g_down_lsp_list,
LspCV, \
lspCb_t);*/
MplsInsertIntodownGlobalList(g_down_lsp_list,LspCV->downSessionIndex,LspCV,lspCb_t);
return LDP_FALSE;
}
}
#endif
LspCBFsm(MPLS_NULL,MPLS_ROUTE_DELETE,MPLS_NULL,LspCV->lspType, \
LspCV->selffec,LspCV);
}
return LDP_FALSE;
}
}
MPLS_WALK_LSP_END(fec,LspCV,t_lspCb)
}
if(LspCBVar->lspType == LDP_HOP_LSP && aggr_enable != 0 && \
LspCBVar->pAttr.len > 0)
{
if(pFecEntry->owner == MPLS_OWNER_POLICY ||
((pFecEntry->owner &MPLS_OWNER_ROUTE)&&
(pFecEntry->pRes & MPLS_EGRESS_TO_POLICY)))
{
if(LspCBVar->downAtmLabel.module)
nexthop = LspCBVar->downAtmLabel.module;
else
nexthop = LspCBVar->downAtmLabel.port;
}
else
{
nexthop = 0xffffffff;
}
p_s_f = MPLS_NULL;
for(p_s_f = aggr_body.first; p_s_f; p_s_f = p_s_f->next)
{
if( (p_s_f->upAtmLabel.module == LspCBVar->upAtmLabel.module) && \
(p_s_f->upAtmLabel.port == LspCBVar->upAtmLabel.port) && \
(p_s_f->attr.hopcount == LspCBVar->pAttr.hopcount) && \
(p_s_f->attr.len == LspCBVar->pAttr.len) && \
(!MPLS_MEMCMP(p_s_f->attr.pAttr,LspCBVar->pAttr.pAttr,LspCBVar->pAttr.len))&& \
( p_s_f->nexthop == nexthop))
break;
}
if(p_s_f)
{
if(p_s_f->upAtmLabel.vpi == 0 && p_s_f->upAtmLabel.vci == 0)
{
LspCBVar->errorcode = EGRESS_CRPVCFAIL;
SndNotMsg(LspCBVar->upSessionIndex,INTERNALERROR,LspCBVar->upMsgid,\
MPLS_LBLREQ_MSGTYPE);
printf("in ProcFecInquireOk,vpi,vci is 0, the first pvc not established !!!!! \n");
DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"in ProcFecInquireOk,vpi,vci is 0, the first pvc not established !!!!! \n");
if(LspCBVar->waitflag & 0xe0)
{
LspCBVar->waitflag |= 0x1;
}
else
{
ldp_del_lspCB(pEntry,LspCBVar);
}
return LDP_FALSE;
}
else
{
LspCBVar->upAtmLabel.vpi = p_s_f->upAtmLabel.vpi;
LspCBVar->upAtmLabel.vci = p_s_f->upAtmLabel.vci;
/* update down module and port */
if(LspCBVar->downAtmLabel.module != p_s_f->downAtmLabel.module||
LspCBVar->downAtmLabel.port != p_s_f->downAtmLabel.port)
{
sb_list = MPLS_NULL;
MPLS_SB_SEARCH(LspCBVar->downAtmLabel.module,\
LspCBVar->downAtmLabel.port,sb_list);
if(!sb_list)
{
MPLS_REMOVE_FROM_SESSION_DOWN_LSP_LIST(g_down_lsp_list,LspCBVar);
}
else
{
MPLS_REMOVE_FROM_SESSION_DOWN_LSP_LIST_A(sb_list->lsp_down_cb_list,LspCBVar);
if(!(sb_list->lsp_down_cb_list.first ||sb_list->lsp_up_cb_list.first))
MPLS_SB_DELETE(LspCBVar->downAtmLabel.module,\
LspCBVar->downAtmLabel.port,sb_list)
}
/* refresh lspcb */
LspCBVar->downAtmLabel.module = p_s_f->downAtmLabel.module;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -