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

📄 loopdect.c

📁 技术文件名称:MPLSv1.0软件模块测试规程
💻 C
📖 第 1 页 / 共 3 页
字号:
void sndfeclsp_mapmsg_looptlvproc_dod(mplsLdpAttr * ldppAttr,
                                      mplsLdpLblMapMsg_t * lblMapMsg,
                                      unsigned char nodetype)
{
   if(nodetype == MPLS_NODE_EGRESS) /*149.tst,150.tst */
   {
        lblMapMsg -> hopCountTlvExists = 1;
        lblMapMsg -> pathVecTlvExists = 0;
        lblMapMsg -> hopCountTlv.baseTlv.flags.flags.uBit = 0;
        lblMapMsg -> hopCountTlv.baseTlv.flags.flags.fBit = 0;
        lblMapMsg -> hopCountTlv.baseTlv.flags.flags.type = MPLS_HOPCOUNT_TLVTYPE;
        lblMapMsg -> hopCountTlv.baseTlv.length = MPLS_HOPCOUNTFIXLEN;
        lblMapMsg -> hopCountTlv.hcValue = 1;
   }
   else
   {
        if((ldppAttr -> pAttr != MPLS_NULL)&&
           (ldppAttr -> attrvalue_valid == 1))     /*  97.tst,153.tst */
        {
            lblMapMsg->pathVecTlvExists = 1;
            lblMapMsg -> pathVecTlv.baseTlv.flags.flags.uBit = 0;
            lblMapMsg -> pathVecTlv.baseTlv.flags.flags.fBit = 0;
            lblMapMsg -> pathVecTlv.baseTlv.flags.flags.type = MPLS_PATH_TLVTYPE;
            memcpy(&lblMapMsg -> pathVecTlv.lsrId[0],ldppAttr -> pAttr, ldppAttr -> len);
            lblMapMsg -> pathVecTlv.baseTlv.length = ldppAttr -> len;
            lblMapMsg -> pathVecTlv.lsrId[lblMapMsg->pathVecTlv.baseTlv.length/4]
            = lsrAttr.lsrAttribute.lsrId;
            lblMapMsg -> pathVecTlv.baseTlv.length = lblMapMsg->pathVecTlv.baseTlv.length + 4;
        }
        if(ldppAttr -> hopcount != 0)
        {
            lblMapMsg -> hopCountTlvExists = 1; /* 94.tst,96.tst,148.tst */
            lblMapMsg -> hopCountTlv.baseTlv.flags.flags.uBit = 0;
            lblMapMsg -> hopCountTlv.baseTlv.flags.flags.fBit = 0;
            lblMapMsg -> hopCountTlv.baseTlv.flags.flags.type = MPLS_HOPCOUNT_TLVTYPE;
            lblMapMsg -> hopCountTlv.baseTlv.length = MPLS_HOPCOUNTFIXLEN;
            lblMapMsg->hopCountTlv.hcValue = (ldppAttr -> hopcount + 1);
            if((ldppAttr -> pAttr == MPLS_NULL)&&
                (ldppAttr -> attrvalue_valid == 0))     /*  156.tst */
            {
                lblMapMsg -> pathVecTlvExists = 0;
            }
        }
        else  if(ldppAttr -> hopcount == 0)  /* 151.tst,155.tst,209.tst */
        {
            lblMapMsg -> hopCountTlvExists = 1;
            lblMapMsg -> hopCountTlv.baseTlv.flags.flags.uBit = 0;
            lblMapMsg -> hopCountTlv.baseTlv.flags.flags.fBit = 0;
            lblMapMsg -> hopCountTlv.baseTlv.flags.flags.type = MPLS_HOPCOUNT_TLVTYPE;
            lblMapMsg -> hopCountTlv.baseTlv.length = MPLS_HOPCOUNTFIXLEN;
            lblMapMsg -> hopCountTlv.hcValue = 0;
            if((ldppAttr -> pAttr == MPLS_NULL)&&
                (ldppAttr -> attrvalue_valid == 0))     /*  155.tst */
            {
                lblMapMsg -> pathVecTlvExists = 1;
                lblMapMsg -> pathVecTlv.baseTlv.flags.flags.uBit = 0;
                lblMapMsg -> pathVecTlv.baseTlv.flags.flags.fBit = 0;
                lblMapMsg -> pathVecTlv.baseTlv.flags.flags.type = MPLS_PATH_TLVTYPE;
                lblMapMsg -> pathVecTlv.lsrId[0] = lsrAttr.lsrAttribute.lsrId;
                lblMapMsg -> pathVecTlv.baseTlv.length = 4;
            }
        }
    }
}

/***********************************************************************/
/* FUNCTION NAME  : sndfeclsp_mapmsg_looptlvproc_du()
/* DESCRIPTION:   : send label request message(du), hop count tlv
                    and path vector tlv to message
/*  INPUT         : mplsLdpAttr        * ldppAttr,
                    mplsLdpLblMapMsg_t * lblMapMsg,
                    unsigned char       nodetype
/*  OUTPUT        : void
/*  AUTHOR/DATE   : shi.zhaohui/ 02.07.1
/*  GLOBAL        : none
/* History        :
/************************************************************************/
void sndfeclsp_mapmsg_looptlvproc_du(mplsLdpAttr * ldppAttr,
                            mplsLdpLblMapMsg_t * lblMapMsg, unsigned char nodetype)
{
    if((nodetype == MPLS_NODE_EGRESS) || (nodetype == MPLS_NODE_PROXY_EGRESS)) /* 150.tst,152.tst */
    {
        lblMapMsg -> hopCountTlvExists = 1;
        lblMapMsg -> pathVecTlvExists = 0;
        lblMapMsg -> hopCountTlv.baseTlv.flags.flags.uBit = 0;
        lblMapMsg -> hopCountTlv.baseTlv.flags.flags.fBit = 0;
        lblMapMsg -> hopCountTlv.baseTlv.flags.flags.type = MPLS_HOPCOUNT_TLVTYPE;
        lblMapMsg -> hopCountTlv.baseTlv.length = MPLS_HOPCOUNTFIXLEN;
        lblMapMsg -> hopCountTlv.hcValue = 1;
    }
    else if(ldppAttr  == MPLS_NULL)
    {
    	lblMapMsg -> hopCountTlvExists = 1;
        lblMapMsg -> hopCountTlv.baseTlv.flags.flags.uBit = 0;
        lblMapMsg -> hopCountTlv.baseTlv.flags.flags.fBit = 0;
        lblMapMsg -> hopCountTlv.baseTlv.flags.flags.type = MPLS_HOPCOUNT_TLVTYPE;
        lblMapMsg -> hopCountTlv.baseTlv.length = MPLS_HOPCOUNTFIXLEN;
        lblMapMsg -> hopCountTlv.hcValue = 0;
        lblMapMsg -> pathVecTlvExists = 1;
        lblMapMsg -> pathVecTlv.baseTlv.flags.flags.uBit = 0;
        lblMapMsg -> pathVecTlv.baseTlv.flags.flags.fBit = 0;
        lblMapMsg -> pathVecTlv.baseTlv.flags.flags.type = MPLS_PATH_TLVTYPE;
        lblMapMsg -> pathVecTlv.lsrId[0] = lsrAttr.lsrAttribute.lsrId;
        lblMapMsg -> pathVecTlv.baseTlv.length = 4;
    }    	
	else
	{
        if((ldppAttr -> pAttr != MPLS_NULL)&&
           (ldppAttr -> attrvalue_valid == 1)) /*  97.tst,153.tst */
        {
            lblMapMsg->pathVecTlvExists = 1;
            lblMapMsg -> pathVecTlv.baseTlv.flags.flags.uBit = 0;
            lblMapMsg -> pathVecTlv.baseTlv.flags.flags.fBit = 0;
            lblMapMsg -> pathVecTlv.baseTlv.flags.flags.type = MPLS_PATH_TLVTYPE;
            memcpy(&lblMapMsg -> pathVecTlv.lsrId[0],ldppAttr -> pAttr, ldppAttr -> len);
            lblMapMsg -> pathVecTlv.baseTlv.length = ldppAttr -> len;
            lblMapMsg -> pathVecTlv.lsrId[lblMapMsg->pathVecTlv.baseTlv.length/4]
            = lsrAttr.lsrAttribute.lsrId;
            lblMapMsg -> pathVecTlv.baseTlv.length = lblMapMsg->pathVecTlv.baseTlv.length + 4;
        }
        if(ldppAttr -> hopcount != 0)/* 94.tst,96.tst,148.tst*/
        {
            lblMapMsg -> hopCountTlvExists = 1;
            lblMapMsg -> hopCountTlv.baseTlv.flags.flags.uBit = 0;
            lblMapMsg -> hopCountTlv.baseTlv.flags.flags.fBit = 0;
            lblMapMsg -> hopCountTlv.baseTlv.flags.flags.type = MPLS_HOPCOUNT_TLVTYPE;
            lblMapMsg -> hopCountTlv.baseTlv.length = MPLS_HOPCOUNTFIXLEN;
            lblMapMsg->hopCountTlv.hcValue = (ldppAttr -> hopcount + 1);
            if((ldppAttr -> pAttr == MPLS_NULL)&&
                (ldppAttr -> attrvalue_valid == 0))
            {
                //lblMapMsg -> pathVecTlvExists = 0;
                lblMapMsg -> pathVecTlvExists = 1;
                lblMapMsg -> pathVecTlv.baseTlv.flags.flags.uBit = 0;
                lblMapMsg -> pathVecTlv.baseTlv.flags.flags.fBit = 0;
                lblMapMsg -> pathVecTlv.baseTlv.flags.flags.type = MPLS_PATH_TLVTYPE;
                lblMapMsg -> pathVecTlv.lsrId[0] = lsrAttr.lsrAttribute.lsrId;
                lblMapMsg -> pathVecTlv.baseTlv.length = 4;
            }
        }
        else  if(ldppAttr -> hopcount == 0)  /* 152.tst, 151.tst,209.tst*/
        {
            lblMapMsg -> hopCountTlvExists = 1;
            lblMapMsg -> hopCountTlv.baseTlv.flags.flags.uBit = 0;
            lblMapMsg -> hopCountTlv.baseTlv.flags.flags.fBit = 0;
            lblMapMsg -> hopCountTlv.baseTlv.flags.flags.type = MPLS_HOPCOUNT_TLVTYPE;
            lblMapMsg -> hopCountTlv.baseTlv.length = MPLS_HOPCOUNTFIXLEN;
            lblMapMsg -> hopCountTlv.hcValue = 0;
            if((ldppAttr -> pAttr == MPLS_NULL)&&
                (ldppAttr -> attrvalue_valid == 0))    /* 154.tst */
            {
                lblMapMsg -> pathVecTlvExists = 1;
                lblMapMsg -> pathVecTlv.baseTlv.flags.flags.uBit = 0;
                lblMapMsg -> pathVecTlv.baseTlv.flags.flags.fBit = 0;
                lblMapMsg -> pathVecTlv.baseTlv.flags.flags.type = MPLS_PATH_TLVTYPE;
                lblMapMsg -> pathVecTlv.lsrId[0] = lsrAttr.lsrAttribute.lsrId;
                lblMapMsg -> pathVecTlv.baseTlv.length = 4;
            }
        }
    }
}

/***********************************************************************/
/* FUNCTION NAME  : recfeclsp_mapmsg_looptlvproc_dod()
/* DESCRIPTION:   : receive label mapping message(dod), hop count tlv
                    and path vector tlv process
/*  INPUT         : mplsLdpAttr        * ldppAttr,
                    mplsLdpLblMapMsg_t * lblMapMsg,
                    unsigned long      msgid
/*  OUTPUT        : void
/*  AUTHOR/DATE   : shi.zhaohui/ 02.07.1
/*  GLOBAL        : none
/* History        :
/************************************************************************/
unsigned char  recfeclsp_mapmsg_looptlvproc_dod(mplsLdpLblMapMsg_t  * lblMapMsg,
                                       mplsLdpAttr         * ldppAttr,
                                       unsigned short        status)
{
	unsigned short len;
	short          rtcode;
	
	len = lblMapMsg->pathVecTlv.baseTlv.length;
    if(status != ESTABLISHED) /* first receive mapping message */
    {
        if(lblMapMsg->hopCountTlvExists == 1)
        {
            if(lblMapMsg->hopCountTlv.hcValue != 0)
            {   /* 94.tst,96.tst,156.tst,158.tst,159.tst,160.tst */
			    ldppAttr -> hopcount = lblMapMsg->hopCountTlv.hcValue;
			    ldppAttr -> hopvalue_valid = 1;
            }
			else if(lblMapMsg->hopCountTlv.hcValue == 0)  /* 155.tst,209.tst */
			{
			    ldppAttr -> hopcount = 0;
			    ldppAttr -> hopvalue_valid = 1;
			}
		}
		else
		{ /* 151.tst*/
		    ldppAttr -> hopcount = 0;
		    ldppAttr -> hopvalue_valid = 0; /* 0: rec map msg have no hop count tlv */
		}
        if(lblMapMsg->pathVecTlvExists == 1)
        {
            #ifdef MPLS_LOOP_MEM_PVTLV
            rtcode = ldp_pathvector_malloc(ldppAttr,lblMapMsg->pathVecTlv.baseTlv.length);
    		if(rtcode != MPLS_TRUE)
			{
                DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_LSP, "recfeclsp_mapmsg_looptlvproc_dod,ldppAttr -> pAttr, out of memory\n");
			    printf("ldppAttr -> pAttr, out of memory");
			}
			else /* 95.tst,153.tst*/
			{
			    memcpy(ldppAttr -> pAttr,&(lblMapMsg->pathVecTlv.lsrId[0]),\
	                    lblMapMsg->pathVecTlv.baseTlv.length);
		        ldppAttr -> len = lblMapMsg->pathVecTlv.baseTlv.length ;
		        ldppAttr -> attrvalue_valid = 1; /* 1: rec map msg have path vector tlv */
		    }
		    #endif
	    }
	    else  /* 155.tst  */
	    {
	    	if(ldppAttr -> pAttr != MPLS_NULL)
	    	{
                ldp_pathvector_free(ldppAttr);
	    	}
        }
        return 0;
    }
    else  if(status == ESTABLISHED)/* has received mapping message */
    {
        if((lblMapMsg->hopCountTlvExists == 0)&&
           (ldppAttr -> hopvalue_valid == 0)&&
           (lblMapMsg->pathVecTlvExists == 1))
        {
        	if(ldppAttr -> len == len)
            {
	            if(!memcmp((ldppAttr -> pAttr),&(lblMapMsg->pathVecTlv.lsrId[0]),ldppAttr -> len))
	            {
	                /* no action 95.tst */
	                return 0;
	            }
	        }
            else  /* 97.tst*/
            {
                lblMapMsg->pathVecTlvExists = 1;
                lblMapMsg -> pathVecTlv.baseTlv.flags.flags.uBit = 0;
                lblMapMsg -> pathVecTlv.baseTlv.flags.flags.fBit = 0;
                lblMapMsg -> pathVecTlv.baseTlv.flags.flags.type = MPLS_PATH_TLVTYPE;
                lblMapMsg -> pathVecTlv.lsrId[lblMapMsg->pathVecTlv.baseTlv.length/4] =
                    lsrAttr.lsrAttribute.lsrId;
                lblMapMsg -> pathVecTlv.baseTlv.length = lblMapMsg->pathVecTlv.baseTlv.length +4;
            }
        }
        else
        {   if(lblMapMsg->pathVecTlvExists == 1)
            {
                lblMapMsg->pathVecTlvExists = 1;
                lblMapMsg -> pathVecTlv.baseTlv.flags.flags.uBit = 0;
                lblMapMsg -> pathVecTlv.baseTlv.flags.flags.fBit = 0;
                lblMapMsg -> pathVecTlv.baseTlv.flags.flags.type = MPLS_PATH_TLVTYPE;
                lblMapMsg -> pathVecTlv.lsrId[lblMapMsg->pathVecTlv.baseTlv.length/4] =
                    lsrAttr.lsrAttribute.lsrId;
                lblMapMsg -> pathVecTlv.baseTlv.length =
                    lblMapMsg->pathVecTlv.baseTlv.length +4;
            }
            if((lblMapMsg->hopCountTlvExists == 1)&&
                (ldppAttr -> hopcount == lblMapMsg->hopCountTlv.hcValue)&&
                (ldppAttr -> hopcount != 0))
            {
                if((lblMapMsg-> pathVecTlvExists == 0)&&
                  (ldppAttr -> attrvalue_valid == 0)) /* 94.tst */
                {
                    /* no action */
                    return 0;
                }
                else if(ldppAttr -> attrvalue_valid == 1)
                {
                    if(lblMapMsg-> pathVecTlvExists == 0)  /* 157.tst */
                    {
                        lblMapMsg->pathVecTlvExists = 0;
                        lblMapMsg -> pathVecTlv.lsrId[0] = 0;
                        lblMapMsg -> pathVecTlv.baseTlv.length = 0;
                        lblMapMsg->hopCountTlv.hcValue = lblMapMsg->hopCountTlv.hcValue +1;
                    }
                    else
                    {
                    	if(ldppAttr -> len == len)
                    	{
	                    	if(!memcmp((ldppAttr -> pAttr),&(lblMapMsg->pathVecTlv.lsrId[0]),ldppAttr -> len))
				            {
				                /* no action 95.tst */
				                return 0;
				            }
				        }
                    }
                }
            }
            else  if((lblMapMsg->hopCountTlvExists == 1)&&
                (ldppAttr -> hopcount < lblMapMsg->hopCountTlv.hcValue)) /* 96.tst */
            {
                lblMapMsg -> hopCountTlvExists = 1;
                lblMapMsg -> hopCountTlv.baseTlv.flags.flags.uBit = 0;
                lblMapMsg -> hopCountTlv.baseTlv.flags.flags.fBit = 0;
                lblMapMsg -> hopCountTlv.baseTlv.flags.flags.type = MPLS_HOPCOUNT_TLVTYPE;
                lblMapMsg -> hopCountTlv.baseTlv.length = MPLS_HOPCOUNTFIXLEN;
                lblMapMsg -> hopCountTlv.hcValue = lblMapMsg->hopCountTlv.hcValue +1;
                if(lblMapMsg->pathVecTlvExists == 0) /* 158.tst,160.tst */
                {
                    lblMapMsg->pathVecTlvExists = 1;
                    lblMapMsg -> pathVecTlv.baseTlv.flags.flags.uBit = 0;
                	lblMapMsg -> pathVecTlv.baseTlv.flags.flags.fBit = 0;
                	lblMapMsg -> pathVecTlv.baseTlv.flags.flags.type = MPLS_PATH_TLVTYPE;
                    lblMapMsg -> pathVecTlv.lsrId[0] = lsrAttr.lsrAttribute.lsrId;
                    lblMapMsg -> pathVecTlv.baseTlv.length = 4;
                }
            }
            else  if((lblMapMsg->hopCountTlvExists == 1)&&
                    (ldppAttr -> hopcount > lblMapMsg->hopCountTlv.hcValue))
            {
                if(lblMapMsg->hopCountTlv.hcValue != 0)  /* 96.tst */
                {
                    lblMapMsg -> hopCountTlvExists = 1;
                    lblMapMsg -> hopCountTlv.baseTlv.flags.flags.uBit = 0;
                    lblMapMsg -> hopCountTlv.baseTlv.flags.flags.fBit = 0;
                    lblMapMsg -> hopCountTlv.baseTlv.flags.flags.type = MPLS_HOPCOUNT_TLVTYPE;
                    lblMapMsg -> hopCountTlv.baseTlv.length = MPLS_HOPCOUNTFIXLEN;
                    lblMapMsg -> hopCountTlv.hcValue = lblMapMsg->hopCountTlv.hcValue +1;

⌨️ 快捷键说明

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