📄 ldpmib.c
字号:
MIB_LDP_SESSION_REQ sessionReq;
ldpMibSessionIndexReq_t * sessionIndex;
mplsLdpSession_t *sessionSet;
mplsLdpSession_t *session = MPLS_NULL;
sessionReq.operateType = flag;
switch(flag)
{
case LDP_SET: /* 置表 */
sessionSet = (mplsLdpSession_t *)input;
memcpy(&(sessionReq.req.set),sessionSet,sizeof(mplsLdpSession_t));
session = func_sessionset(&sessionReq);
break;
case LDP_SEARCH: /* 检索 */
sessionIndex = (ldpMibSessionIndexReq_t *)input;
memcpy(&(sessionReq.req.loc),sessionIndex,\
sizeof(ldpMibSessionIndexReq_t));
session = func_sessionsearch(&sessionReq);
break;
case LDP_DELETE: /* 删除 */
sessionIndex = (ldpMibSessionIndexReq_t *)input;
memcpy(&(sessionReq.req.del),sessionIndex,\
sizeof(ldpMibSessionIndexReq_t ));
session = func_sessiondel(&sessionReq);
break;
default: break;
}
return session;
}
/* ******************************************************************** */
/* FUNCTION NAME : func_sessionset( ) */
/* DESCRIPTION : set Dyanmic Data ldp To mib */
/* INPUT : MIB_LDP_SESSION_REQ *in, MIB_LDP_SESSION_ACK *ack */
/* OUTPUT : No. */
/* AUTHOR/DATE : Shi.ZhaoHui / 2001.3.26 */
/* GLOBAL : none */
/* NOTE : .... */
/********************************************************************** */
mplsLdpSession_t *func_sessionset( MIB_LDP_SESSION_REQ *in)
{
short i,temp = -1;
mplsLdpSession_t *session = MPLS_NULL;
mplsOAMLdpMessage_t oamldpmess;
for(i = 0; i < MPLSLDP_MAX; i++)
{
if((MplsLdpSessionEntry[i].RowStatus == VAL_RowStatus_active) &&
(MplsLdpSessionEntry[i].entityLdpId.lsrAddress == in -> req.set.entityLdpId.lsrAddress) &&
(MplsLdpSessionEntry[i].entityLdpId.labelSpace == in -> req.set.entityLdpId.labelSpace) &&
(MplsLdpSessionEntry[i].peerLdpId.lsrAddress == in -> req.set.peerLdpId.lsrAddress) &&
(MplsLdpSessionEntry[i].peerLdpId.labelSpace == in -> req.set.peerLdpId.labelSpace))
{
in -> req.set.index = MplsLdpSessionEntry[i].index;
memcpy((unsigned char *)&MplsLdpSessionEntry[i]+1,&(in -> req.set),sizeof(mplsLdpSession_t) );
session = (mplsLdpSession_t *)(&MplsLdpSessionEntry[i].entityLdpId);
temp = 0;
oamldpmess.msgtype = MPLS_MIB_LDP_SESSION ;
oamldpmess.data.ssnDataReq.operateType = 1;
memcpy(&(oamldpmess.data.ssnDataReq.req.set),&(in -> req.set),
sizeof(mplsLdpSession_t));
/* MPLS_PSEND(MPLS_LDP_OAM_MESSAGE,&oamldpmess,sizeof(MIB_LDP_SESSION_ACK)
+sizeof(mplsLdpOAMMessage)+sizeof(unsigned char),mlsmanagePid); */
mplsSessionRecv(&oamldpmess); /* 2003-10-9 lixia add */
break;
}
}
if(temp == 0)
return session;
for(i = 0; i < MPLSLDP_MAX; i++)
{
if(MplsLdpSessionEntry[i].RowStatus == VAL_RowStatus_null)
{
in -> req.set.index = SessionIndex;
MplsLdpSessionEntry[i].RowStatus = VAL_RowStatus_active;
memcpy((unsigned char *)&MplsLdpSessionEntry[i]+1,&(in -> req.set),sizeof(mplsLdpSession_t) );
session = (mplsLdpSession_t *)(&MplsLdpSessionEntry[i].entityLdpId);
SessionIndex--;
/*if( SessionIndex == 0 )*/
if( SessionIndex < 3 ) /* for session invalid flag, wengqing
0: SB alarm, 1: Session Down, 2: Release or Withdraw
*/
SessionIndex = mplsINDEX_MAX;
oamldpmess.msgtype = MPLS_MIB_LDP_SESSION ;
oamldpmess.data.ssnDataReq.operateType = 1;
memcpy(&(oamldpmess.data.ssnDataReq.req.set),&(in -> req.set),
sizeof(mplsLdpSession_t));
/* MPLS_PSEND(MPLS_LDP_OAM_MESSAGE,&oamldpmess,sizeof(MIB_LDP_SESSION_ACK)
+sizeof(mplsLdpOAMMessage)+sizeof(unsigned char),mlsmanagePid);*/
mplsSessionRecv(&oamldpmess); /* 2003-10-9 lixia add */
break;
}
}
return session;
}
/* ******************************************************************** */
/* FUNCTION NAME : func_sessionsearch( ) */
/* DESCRIPTION : set Dyanmic Data ldp To mib */
/* INPUT : MIB_LDP_SESSION_REQ *in, MIB_LDP_SESSION_ACK *ack */
/* OUTPUT : No. */
/* AUTHOR/DATE : Shi.ZhaoHui / 2001.3.26 */
/* GLOBAL : none */
/* NOTE : .... */
/********************************************************************** */
mplsLdpSession_t *func_sessionsearch( MIB_LDP_SESSION_REQ *in)
{
short i;
mplsLdpSession_t *session = MPLS_NULL;
switch ( in -> req.loc.indexFlag )
{
case 1 :
if(( in -> req.loc.sessionIndex < 0 )||( in -> req.loc.sessionIndex > mplsINDEX_MAX ))
{
#ifdef DEBUG_LDP
#ifdef __BGS10_MPLS_DEBUG
printf("!!! In func_Ssearch1, sessionIndex error.");
#endif
#endif
return MPLS_NULL;
}
for(i = 0; i < MPLSLDP_MAX; i++)
{
if((MplsLdpSessionEntry[i].RowStatus == VAL_RowStatus_active) &&
( MplsLdpSessionEntry[i].index == in -> req.loc.sessionIndex))
{
session = (mplsLdpSession_t *)(&MplsLdpSessionEntry[i].entityLdpId);
break;
}
}
#ifdef DEBUG_LDP
#ifdef __BGS10_MPLS_DEBUG
if(session == MPLS_NULL)
printf("!!! In func_Ssearch1, search data is not exist");
#endif
#endif
break;
case 2 :
for(i = 0; i < MPLSLDP_MAX; i++)
{
if((MplsLdpSessionEntry[i].RowStatus == VAL_RowStatus_active) &&
( MplsLdpSessionEntry[i].entityLdpId.lsrAddress == in -> req.loc.unionIndex.entityLdpId.lsrAddress) &&
( MplsLdpSessionEntry[i].entityLdpId.labelSpace == in -> req.loc.unionIndex.entityLdpId.labelSpace) &&
( MplsLdpSessionEntry[i].peerLdpId.lsrAddress == in -> req.loc.unionIndex.peerLdpId.lsrAddress)&&
( MplsLdpSessionEntry[i].peerLdpId.labelSpace == in -> req.loc.unionIndex.peerLdpId.labelSpace))
{
session = (mplsLdpSession_t *)(&MplsLdpSessionEntry[i].entityLdpId);
break;
}
}
#ifdef DEBUG_LDP
#ifdef __BGS10_MPLS_DEBUG
if(session == MPLS_NULL)
printf("!!! In func_Ssearch2, search data is not exist");
#endif
#endif
break;
case 3 :
for(i = 0; i < MPLSLDP_MAX; i++)
{
if((MplsLdpSessionEntry[i].RowStatus == VAL_RowStatus_active) &&
( MplsLdpSessionEntry[i].peerIpaddr== in -> req.loc.peerIpaddr) &&
( MplsLdpSessionEntry[i].localIpaddr == in -> req.loc.localIpaddr))
{
session = (mplsLdpSession_t *)(&MplsLdpSessionEntry[i].entityLdpId);
break;
}
}
#ifdef DEBUG_LDP
#ifdef __BGS10_MPLS_DEBUG
if(session == MPLS_NULL)
printf("!!! In func_Ssearch3, search data is not exist");
#endif
#endif
break;
default:
break;
}
return session;
}
/* ******************************************************************** */
/* FUNCTION NAME : func_sessiondel( ) */
/* DESCRIPTION : search Dyanmic Data from mib */
/* INPUT : MIB_LDP_SESSION_REQ *in, MIB_LDP_SESSION_ACK *ack */
/* OUTPUT : No. */
/* AUTHOR/DATE : Shi.ZhaoHui / 2001.3.26 */
/* GLOBAL : none */
/* NOTE : .... */
/********************************************************************** */
mplsLdpSession_t *func_sessiondel(MIB_LDP_SESSION_REQ *in)
{
short i;
mplsLdpSession_t *session = MPLS_NULL;
mplsOAMLdpMessage_t oamldpmess;
switch ( in -> req.del.indexFlag )
{
case 1 :
if(( in -> req.del.sessionIndex < 0 )||( in -> req.del.sessionIndex > mplsINDEX_MAX ))
{
#ifdef DEBUG_LDP
#ifdef __BGS10_MPLS_DEBUG
printf("!!! In func_sessiondel1, sessionIndex error.");
#endif
#endif
return MPLS_NULL;
}
for(i = 0; i < MPLSLDP_MAX; i++)
{
if((MplsLdpSessionEntry[i].RowStatus == VAL_RowStatus_active) &&
( MplsLdpSessionEntry[i].index == in -> req.del.sessionIndex))
{
MplsLdpSessionEntry[i].RowStatus = VAL_RowStatus_null;
session = (mplsLdpSession_t *)(&MplsLdpSessionEntry[i].entityLdpId);
oamldpmess.msgtype = MPLS_MIB_LDP_SESSION ;
oamldpmess.data.ssnDataReq.operateType = 3;
/* oamldpmess.data.ssnDataReq.req.del.indexFlag = 1;
oamldpmess.data.ssnDataReq.req.del.ifIndex =
(unsigned long)MplsLdpSessionEntry[i].ifIndex;
MPLS_PSEND(MPLS_LDP_OAM_MESSAGE,&oamldpmess,sizeof(MIB_LDP_SESSION_ACK)
+sizeof(mplsLdpOAMMessage)+sizeof(unsigned char),mlsmanagePid);*/
memcpy(&(oamldpmess.data.ssnDataReq.req.set),session,
sizeof(mplsLdpSession_t));
/* MPLS_PSEND(MPLS_LDP_OAM_MESSAGE,&oamldpmess,sizeof(MIB_LDP_SESSION_ACK)
+sizeof(mplsLdpOAMMessage)+sizeof(unsigned char),mlsmanagePid); */
mplsSessionRecv(&oamldpmess); /* 2003-10-9 lixia add */
memset(&MplsLdpSessionEntry[i],0,sizeof(struct_MplsLdpSessionTable));
break;
}
}
#ifdef DEBUG_LDP
#ifdef __BGS10_MPLS_DEBUG
if(session == MPLS_NULL)
printf("!!! In func_sessiondel1, del data is not exist");
#endif
#endif
break;
case 2 :
for(i = 0; i < MPLSLDP_MAX; i++)
{
if((MplsLdpSessionEntry[i].RowStatus == VAL_RowStatus_active) &&
( MplsLdpSessionEntry[i].entityLdpId.lsrAddress == in -> req.del.unionIndex.entityLdpId.lsrAddress) &&
( MplsLdpSessionEntry[i].entityLdpId.labelSpace == in -> req.del.unionIndex.entityLdpId.labelSpace) &&
( MplsLdpSessionEntry[i].peerLdpId.lsrAddress == in -> req.del.unionIndex.peerLdpId.lsrAddress)&&
( MplsLdpSessionEntry[i].peerLdpId.labelSpace == in -> req.del.unionIndex.peerLdpId.labelSpace))
{
MplsLdpSessionEntry[i].RowStatus = VAL_RowStatus_null;
session = (mplsLdpSession_t *)(&MplsLdpSessionEntry[i].entityLdpId);
oamldpmess.msgtype = MPLS_MIB_LDP_SESSION ;
oamldpmess.data.ssnDataReq.operateType = 3;
/*oamldpmess.data.ssnDataReq.req.del.indexFlag = 2;
oamldpmess.data.ssnDataReq.req.del.ifIndex =
(unsigned long)MplsLdpSessionEntry[i].ifIndex;
MPLS_PSEND(MPLS_LDP_OAM_MESSAGE,&oamldpmess,sizeof(MIB_LDP_SESSION_ACK)
+sizeof(mplsLdpOAMMessage)+sizeof(unsigned char),mlsmanagePid);*/
memcpy(&(oamldpmess.data.ssnDataReq.req.set),session,
sizeof(mplsLdpSession_t));
/* MPLS_PSEND(MPLS_LDP_OAM_MESSAGE,&oamldpmess,sizeof(MIB_LDP_SESSION_ACK)
+sizeof(mplsLdpOAMMessage)+sizeof(unsigned char),mlsmanagePid);*/
mplsSessionRecv(&oamldpmess); /* 2003-10-9 lixia add */
memset(&MplsLdpSessionEntry[i],0,sizeof(struct_MplsLdpSessionTable));
break;
}
}
#ifdef DEBUG_LDP
#ifdef __BGS10_MPLS_DEBUG
if(session == MPLS_NULL)
printf("!!! In func_search2, del data is not exist");
#endif
#endif
break;
case 3 :
for(i = 0; i < MPLSLDP_MAX; i++)
{
if((MplsLdpSessionEntry[i].RowStatus == VAL_RowStatus_active) &&
( MplsLdpSessionEntry[i].peerIpaddr == in -> req.del.peerIpaddr) &&
( MplsLdpSessionEntry[i].localIpaddr == in -> req.del.localIpaddr))
{
MplsLdpSessionEntry[i].RowStatus = VAL_RowStatus_null;
session = (mplsLdpSession_t *)(&MplsLdpSessionEntry[i].entityLdpId);
oamldpmess.msgtype = MPLS_MIB_LDP_SESSION ;
oamldpmess.data.ssnDataReq.operateType = 3;
/*oamldpmess.data.ssnDataReq.req.del.indexFlag = 3;
oamldpmess.data.ssnDataReq.req.del.ifIndex =
(unsigned long)MplsLdpSessionEntry[i].ifIndex;
MPLS_PSEND(MPLS_LDP_OAM_MESSAGE,&oamldpmess,sizeof(MIB_LDP_SESSION_ACK)
+sizeof(mplsLdpOAMMessage)+sizeof(unsigned char),mlsmanagePid);*/
memcpy(&(oamldpmess.data.ssnDataReq.req.set),session,
sizeof(mplsLdpSession_t));
/* MPLS_PSEND(MPLS_LDP_OAM_MESSAGE,&oamldpmess,sizeof(MIB_LDP_SESSION_ACK)
+sizeof(mplsLdpOAMMessage)+sizeof(unsigned char),mlsmanagePid);*/
mplsSessionRecv(&oamldpmess); /* 2003-10-9 lixia add */
memset(&MplsLdpSessionEntry[i],0,sizeof(struct_MplsLdpSessionTable));
break;
}
}
#ifdef DEBUG_LDP
#ifdef __BGS10_MPLS_DEBUG
if(session == MPLS_NULL)
printf("!!! In func_sessiondel3, del data is not exist");
#endif
#endif
break;
default:
break;
}
return session;
}
/* 对Peer表的置表、检索和删除操作
*/
mplsLdpPeer_t *MibPeer(void * input, unsigned char flag)
{
MIB_LDP_PEER_REQ peerReq;
ldpMibPeerIndexReq_t *peerIndex;
mplsLdpPeer_t *peerSet;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -