📄 ldpmain.c
字号:
}
else /* sbp 2002-12-18 for route changing... */
{
fecMsg->OperateType = DELETE_PVC_TYPE;
fecMsg->Fec.statusCode = 0;
fecPid.module = selfLdpPid.module;
ASEND(MPLS_FEC_STUDY,fecMsg,sizeof(FecMsg),fecPid);
}
break;
default:
printf("==== Module %d,Receive MPLS_FEC_SETUP,OperateType %d ====",
selfLdpPid.module,fecMsg->OperateType);
break;
}
return;
}
#if 0
void FecElemChange(FecMsg * fecMsg)
{
unsigned long len,lenTmp;
mplsLdpLblMapMsg_t lblMapMsg;
if ( fecMsg->Fec.RouteType == EGRESS )
{
if (fecMsg->Fec.downLspCBStru.no == LDP_EMPTY)
return;
if(fecMsg->Fec.fecElemNum>0)
{
InitLblMapMsg(&lblMapMsg);
AddMsgId(LBLMAP_M);
lblMapMsg.baseMsg.msgId = messageId[LBLMAP_M];
lblMapMsg.fecTlv.numberFecElements = fecMsg->Fec.fecElemNum;
memcpy(lblMapMsg.fecTlv.fecElArray,fecMsg->Fec.fecElArray,\
CONTENT_MAX_LENGTH);
memcpy(lblMapMsg.fecTlv.fecElemTypes, fecMsg->Fec.fecElemTypes,\
(sizeof(unsigned short) * MPLS_MAXNUMFECELEMENT));
lenTmp = FuncFecLen(fecMsg->Fec);
lblMapMsg.fecTlv.baseTlv.length = (unsigned short)(lenTmp);
lblMapMsg.lspidTlv.localCrlspId = fecMsg->Fec.lspidTlv.localCrlspId;
lblMapMsg.lspidTlv.routerId = fecMsg->Fec.lspidTlv.routerId ;
lblMapMsg.trafficTlvExists = 1;
memcpy(&(lblMapMsg.trafficTlv),&(fecMsg->Fec.Traffic),
sizeof(mplsLdpTrafficTlv_t));
lenTmp = sizeof(mplsLdpTrafficTlv_t) - MPLS_TLVFIXLEN;
lblMapMsg.trafficTlv.baseTlv.length = (unsigned short)(lenTmp);
lblMapMsg.atmLblTlvExists = 0;
DownLspCBFsm(fecMsg->Fec.downLspCBStru.no,MPLS_LBLMAP_MSGTYPE,&lblMapMsg);
}
else if(fecMsg->Fec.fecElemNum==0)
DownLspCBFsm(fecMsg->Fec.downLspCBStru.no,MPLS_LBLWITH_MSGTYPE,NULL);
}
}
#endif
#if 1
void InitLdpData()
{
/*init allEntity*/
allEntity.num = 2;
allEntity.entity[0].ldpId.lsrAddress = 0x01010101;
allEntity.entity[0].ldpId.labelSpace = 0;
allEntity.entity[0].index = 512;
allEntity.entity[0].ifArray = 512;
allEntity.entity[0].ifNumber = 1;
allEntity.entity[0].protocolVersion = 1;
allEntity.entity[0].adminStatus = 1;
allEntity.entity[0].operStatus = 1;
allEntity.entity[0].wellKnownDiscoveryPort = 646;
allEntity.entity[0].maxPduLength = 4096;
allEntity.entity[0].keepAliveHoldTimer = 45;
allEntity.entity[0].helloHoldTimer = 15;
allEntity.entity[0].failedInitSessiontrapenable = 71;
allEntity.entity[0].failedInitSessionThreshold = 8;
allEntity.entity[0].labelDistributionMethod = DOWNSTRAMUNSOLICITED;
allEntity.entity[0].labelretentionmode = 1;
allEntity.entity[0].pvLimitMismatchtrapenabled = 0;
allEntity.entity[0].pathvectorlimit = 255;
allEntity.entity[0].hopcountlimit = 255;
allEntity.entity[0].targetedPeer = 0;
allEntity.entity[0].targetedPeerAddrType = 1;
allEntity.entity[0].targetedPeerAddr = 0;
allEntity.entity[0].optionalParameters = 1;
allEntity.entity[0].loopDetectionCapable = LOOPDETECT_HOPANDPV;
allEntity.entity[0].atmMergeCap = 2;
allEntity.entity[0].atmVcDirectionality = 1;
allEntity.entity[0].atmLsrConnectivity = 1;
allEntity.entity[0].defaultControlVpi = 0;
allEntity.entity[0].defaultControlVci = 32;
allEntity.entity[0].unlabTrafVpi = 0;
allEntity.entity[0].unlabTrafVci = 32;
allEntity.entity[0].transportAddr = 0; /* by hyh */
allEntity.entity[0].helloSendTimer = 50; /* send hello time negotiated */
allEntity.entity[0].csn = 1;
allEntity.entity[0].hellotmd = 0; /* 发送hello定时器 */
allEntity.entity[1].ldpId.lsrAddress = 0x01010101;
allEntity.entity[1].ldpId.labelSpace = 0;
allEntity.entity[1].index = 1536;
allEntity.entity[1].ifArray = 1536;
allEntity.entity[1].ifNumber = 1;
allEntity.entity[1].protocolVersion = 1;
allEntity.entity[1].adminStatus = 1;
allEntity.entity[1].operStatus = 1;
allEntity.entity[1].wellKnownDiscoveryPort = 646;
allEntity.entity[1].maxPduLength = 4096;
allEntity.entity[1].keepAliveHoldTimer = 45;
allEntity.entity[1].helloHoldTimer = 15;
allEntity.entity[1].failedInitSessiontrapenable = 71;
allEntity.entity[1].failedInitSessionThreshold = 8;
allEntity.entity[1].labelDistributionMethod = DOWNSTRAMUNSOLICITED;
allEntity.entity[1].labelretentionmode = 1;
allEntity.entity[1].pvLimitMismatchtrapenabled = 0;
allEntity.entity[1].pathvectorlimit = 255;
allEntity.entity[1].hopcountlimit = 255;
allEntity.entity[1].targetedPeer = 0;
allEntity.entity[1].targetedPeerAddrType = 1;
allEntity.entity[1].targetedPeerAddr = 0;
allEntity.entity[1].optionalParameters = 1;
allEntity.entity[1].loopDetectionCapable = LOOPDETECT_HOPANDPV;
allEntity.entity[1].atmMergeCap = 2;
allEntity.entity[1].atmVcDirectionality = 1;
allEntity.entity[1].atmLsrConnectivity = 1;
allEntity.entity[1].defaultControlVpi = 0;
allEntity.entity[1].defaultControlVci = 32;
allEntity.entity[1].unlabTrafVpi = 0;
allEntity.entity[1].unlabTrafVci = 32;
allEntity.entity[1].transportAddr = 0; /* by hyh */
allEntity.entity[1].helloSendTimer = 50; /* send hello time negotiated */
allEntity.entity[1].csn = 1;
allEntity.entity[1].hellotmd = 0; /* 发送hello定时器 */
/*init allInterface*/
allInterface.num = 2;
allInterface.interface[0].ifIndex = 512;
allInterface.interface[0].ifIpAddress = 0xc8010105;
allInterface.interface[0].entityLdpId.lsrAddress = 0x01010101;
allInterface.interface[0].entityLdpId.labelSpace = 0;
allInterface.interface[0].genlblRngListmin = 0; /* general label min range */
allInterface.interface[0].genlblRngListmax = 0; /* general label max range */
allInterface.interface[0].adminStatus = 1;
allInterface.interface[0].operStatus = 1;
allInterface.interface[1].ifIndex = 1536;
allInterface.interface[1].ifIpAddress = 0xd2010105;
allInterface.interface[1].entityLdpId.lsrAddress = 0x01010101;
allInterface.interface[1].entityLdpId.labelSpace = 0;
allInterface.interface[1].genlblRngListmin = 0; /* general label min range */
allInterface.interface[1].genlblRngListmax = 0; /* general label max range */
allInterface.interface[1].adminStatus = 1;
allInterface.interface[1].operStatus = 1;
lsrAttr.lsrAttribute.lsrId = 0x01010101;
/* lsrAttr.PlatformType = ;
lsrAttr.lsrAttribute.labelRetentionMode = ;
lsrAttr.lsrAttribute.loopDetectionForPV = ;
lsrAttr.lsrAttribute.pathVectorLimit = ;
lsrAttr.lsrAttribute.edgeId = ;
*/
}
#endif
void ProcFecInquire(FecMsg * fecMsg)
{
mplsLdpLspCB * pLsp = MPLS_NULL;
mplsLdpFecEntry * pFec = MPLS_NULL;
mplsLdpCrLsp * pCrfec = MPLS_NULL;
mplsLdpSession_t * session= MPLS_NULL;
unsigned short preLen;
if(fecMsg->Fec.TlvExists.flags.lspidTlvExists == 1)
{
MPLS_CRFECCB_SEARCH(fecMsg->Fec.lspidTlv.routerId,\
fecMsg->Fec.lspidTlv.localCrlspId,pCrfec);
if(pCrfec)
{
if(fecMsg->Fec.NextHop == 0xffffffff)
{
MPLS_MEMCPY(&fec_msg,fecMsg,sizeof(FecMsg));
fec_msg.OperateType = RESPONSE_TYPE;
fec_msg.Fec.statusCode = NOROUTE;
fecPid.module = selfLdpPid.module;
/* ASEND(MPLS_FEC_STUDY,&fec_msg,sizeof(FecMsg),fecPid); *//* sbp 2002-12-26 移到输入节点,见下面 */
if( pCrfec->crlspCb.nodeType == MPLS_NODE_INGRESS)
{
ASEND(MPLS_FEC_STUDY,&fec_msg,sizeof(FecMsg),fecPid); /* sbp 2002-12-26 从上面移过来的,见上面 */
ldp_del_lspCB((char *)pCrfec,&pCrfec->crlspCb);
}
else
{
/******************************************************/
/* send to up notification message, should check fengjun
*/
/******************************************************/
MPLS_INDEX_TO_SESSION(session,pCrfec->crlspCb.upSessionIndex);
if(session)
{
MPLS_REMOVE_FROM_SESSION_UP_LSP_LIST(session->lsp_up_cb_list,\
&(pCrfec->crlspCb));
MPLS_SEND_NOTIFY(session,NOROUTE,pCrfec->crlspCb.upMsgid, \
MPLS_LBLREQ_MSGTYPE);
}
ldp_del_lspCB((char *)pCrfec,&pCrfec->crlspCb);
}
}
else
{
pCrfec->crlspCb.nodeType = fecMsg->Fec.RouteType;
pCrfec->nexthopAddr = fecMsg->Fec.NextHop;
pCrfec->outIfindex = fecMsg->Fec.ifIndex;
if(pCrfec->crlspCb.nodeType == MPLS_NODE_EGRESS)
{
if(pCrfec->crlspCb.upAtmLabel.module == 0 && \
pCrfec->crlspCb.upAtmLabel.port == 0)
{
/***********************************************/
/* DU income,
*/
/***********************************************/
}
else
{
/***********************************************/
/* DoD income,
*/
/***********************************************/
if(!((&(pCrfec->crlspCb))->waitflag & 0x1))
LspCBFsm(MPLS_NULL,MPLS_FEC_SETUP,fecMsg, \
LDP_CR_LSP,pCrfec,&(pCrfec->crlspCb));
}
}
else
{
/***********************************************/
/* Intermediate or ingress node
*/
/***********************************************/
session = MPLS_NULL;
MPLS_NEXTHOP_SESSION_SEARCH(fecMsg->Fec.NextHop,session);
if(!session)
{
session = MPLS_NULL;
if(pCrfec->crlspCb.nodeType == MPLS_NODE_INGRESS)
{
ldp_del_lspCB((char *)pCrfec,&pCrfec->crlspCb);
}
else
{
MPLS_INDEX_TO_SESSION(session,pCrfec->crlspCb.upSessionIndex);
if(session)
{
MPLS_REMOVE_FROM_SESSION_UP_LSP_LIST(session->lsp_up_cb_list,\
&(pCrfec->crlspCb));
MPLS_SEND_NOTIFY(session,NOROUTE,pCrfec->crlspCb.upMsgid,\
MPLS_LBLREQ_MSGTYPE);
}
ldp_del_lspCB((char *)pCrfec,&pCrfec->crlspCb);
}
/* wengqing 2002.12.16, only ingress node, send to fec message */
if(pCrfec->crlspCb.nodeType == MPLS_NODE_INGRESS)
{
MPLS_MEMCPY(&fec_msg,fecMsg,sizeof(FecMsg));
fec_msg.OperateType = RESPONSE_TYPE;
fec_msg.Fec.statusCode = NOROUTE;
fecPid.module = selfLdpPid.module;
ASEND(MPLS_FEC_STUDY,&fec_msg,sizeof(FecMsg),fecPid);
}
return;
}
if((pCrfec->crlspCb.upAtmLabel.module == 0 && \
pCrfec->crlspCb.upAtmLabel.port == 0)||
(pCrfec->crlspCb.nodeType == MPLS_NODE_INGRESS))
{
/***********************************************/
/* Ingress, DU income, judge outbound label distribution
* mode, if DoD, set lspfsm; else, I process
*/
/***********************************************/
if(session->labelAdvertisement == DOWNSTREAMONDEMAND)
{
if(pCrfec->crlspCb.nodeType != MPLS_NODE_INGRESS)
{
pCrfec->crlspCb.nodeType = MPLS_NODE_INTERM_INGRESS;
}
fecMsg->OperateType = INQUIRE_TYPE;
if(!((&(pCrfec->crlspCb))->waitflag & 0x1))
LspCBFsm(MPLS_NULL,MPLS_FEC_SETUP,fecMsg, \
LDP_CR_LSP,pCrfec,&(pCrfec->crlspCb));
}
else
{
/*******************************************/
/* DU outbound,directly send outbound request
*/
/*******************************************/
;
}
}
else
{
/***********************************************/
/* DoD income, judge outbound label distribution
* mode, if DoD, set lspfem; else, set lspfsm,
* get lspfsm
*/
/***********************************************/
if(session->labelAdvertisement != DOWNSTREAMONDEMAND)
{
pCrfec->crlspCb.nodeType = MPLS_NODE_INTERM_EGRESS;
}
if(!((&(pCrfec->crlspCb))->waitflag & 0x1))
LspCBFsm(MPLS_NULL,MPLS_FEC_SETUP,fecMsg, \
LDP_CR_LSP,pCrfec,&(pCrfec->crlspCb));
}
}
}
}
else
{
DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_CR,"ProcFecInquire,MPLS LDP routerId%x,lspId%d,no entry\n",\
fecMsg->Fec.lspidTlv.routerId,\
fecMsg->Fec.lspidTlv.localCrlspId);
MPLS_ERR_LOG("MPLS LDP routerId%x,lspId%d,no entry",\
fecMsg->Fec.lspidTlv.routerId,\
fecMsg->Fec.lspidTlv.localCrlspId);
}
}
else
{
/*******************************************/
/* hop by hop FEC type
*/
/*******************************************/
if(fecMsg->Fec.NextHop == 0xffffffff)
{
DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"==ldpmain destaddr:%x, nexthop:%x, preLen:%d\n", \
fecMsg->Fec.fecElArray[0].addressEl.address,
fecMsg->Fec.NextHop,
fecMsg->Fec.fecElArray[0].addressEl.preLen);
MPLS_ERR_LOG( \
"==ldpmain destaddr:%x, nexthop:%x, preLen:%d", \
fecMsg->Fec.fecElArray[0].addressEl.address,
fecMsg->Fec.NextHop,
fecMsg->Fec.fecElArray[0].addressEl.preLen);
return;
}
pFec = MPLS_NULL;
/* add by hyh */
preLen = fecMsg->Fec.fecElemTypes[0] == MPLS_HOSTADR_FEC ? \
32: fecMsg->Fec.fecElArray[0].addressEl.preLen;
/* end add */
MPLS_FEC_SEARCH(fecMsg->Fec.fecElArray[0].addressEl.address,preLen,pFec);
if(pFec)
{
if(fecMsg->Fec.NextHop == 0xffffffff)
{
printf("pFec destaddr:%x, nexthop:%x,preLen:%d",
pFec->fec_key.mplsFecAddr,
pFec->nexthopAddr,preLen);
DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP,"pFec destaddr:%x, nexthop:%x,preLen:%d\n",
pFec->fec_key.mplsFecAddr,
pFec->nexthopAddr,preLen);
}
pLsp = MPLS_NULL;
MPLS_WALK_LSP_BEGIN(pFec,pLsp,t_lspCb)
if(pLsp)
{
if(fecMsg->Fec.lspIndex == pLsp->lspIndex)
{
if(!(pLsp->waitflag & 0x1))
LspCBFsm(MPLS_NULL,MPLS_FEC_SETUP,fecMsg, \
LDP_HOP_LSP,pFec,pLsp);
break;
}
}
MPLS_WALK_LSP_END(pFec,pLsp,t_lspCb)
}
else
{
MPLS_ERR_LOG( \
"==ldpmain FEC INQUIRE_TYPE addr %x,prelen %d,not exist", \
fecMsg->Fec.fecElArray[0].addressEl.address, \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -