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

📄 loopdect.c

📁 技术文件名称:MPLSv1.0软件模块测试规程
💻 C
📖 第 1 页 / 共 3 页
字号:
                    if(lblMapMsg->pathVecTlvExists == 0) /* 159.tst */
                    {
                        lblMapMsg->pathVecTlvExists = 0;
                    }
                }
                else
                {
                    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(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;
                    }
                }
            }
        }
        return 1; /* attr change, need send mapping message */
    }
}

/***********************************************************************/
/* FUNCTION NAME  : recfeclsp_mapmsg_looptlvproc_du()
/* DESCRIPTION:   : receive label mapping message(du), 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_du(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,148.tst, */
            {
			    ldppAttr -> hopcount = lblMapMsg->hopCountTlv.hcValue;
			    ldppAttr -> hopvalue_valid = 1;
			    lblMapMsg->hopCountTlv.hcValue += 1;
            }
			else if(lblMapMsg->hopCountTlv.hcValue == 0)  /* 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)
			{
			    printf("ldppAttr -> pAttr, out of memory");
			}
			else /* 95.tst,97.tst,153.tst*/
			{
			    lblMapMsg -> pathVecTlv.baseTlv.flags.flags.uBit = 0;
                lblMapMsg -> pathVecTlv.baseTlv.flags.flags.fBit = 0;
                lblMapMsg -> pathVecTlv.baseTlv.flags.flags.type = MPLS_PATH_TLVTYPE;
			    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 */
		        lblMapMsg -> pathVecTlv.lsrId[lblMapMsg->pathVecTlv.baseTlv.length/4] =
                    lsrAttr.lsrAttribute.lsrId;
                lblMapMsg -> pathVecTlv.baseTlv.length =
                    lblMapMsg->pathVecTlv.baseTlv.length +4;
		    }
		    #endif
	    }
	    else if(lblMapMsg->pathVecTlvExists == 0)
		{
		    ldppAttr -> pAttr = MPLS_NULL;
			ldppAttr -> attrvalue_valid = 0; /* 0: rec map msg have no path vector tlv */
		}
		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)
            {
            	if((ldppAttr -> pAttr) && (ldppAttr -> len == lblMapMsg->pathVecTlv.baseTlv.length))
	            {
	            	if(ldppAttr -> len == len)
            		{
		            	if(!memcmp((ldppAttr -> pAttr),&(lblMapMsg->pathVecTlv.lsrId[0]),ldppAttr -> len))
			            {
			                /* no action 95.tst */
			                if((lblMapMsg->hopCountTlvExists == 1)&&
				                (ldppAttr -> hopcount == lblMapMsg->hopCountTlv.hcValue)&&
				                (ldppAttr -> hopcount != 0))
				            {
				            	return 0;
				            }
				            else
				            {
				            	lblMapMsg -> pathVecTlv.lsrId[lblMapMsg->pathVecTlv.baseTlv.length/4] =
			                    	lsrAttr.lsrAttribute.lsrId;
			                	lblMapMsg -> pathVecTlv.baseTlv.length =
			                    lblMapMsg->pathVecTlv.baseTlv.length +4;
				            }
			            }
			        }
		            else
		            {
		            	#ifdef MPLS_LOOP_MEM_PVTLV
			            if(ldppAttr -> pAttr)
			            {
                            ldp_pathvector_free(ldppAttr);
			            }
                        rtcode = ldp_pathvector_malloc(ldppAttr,lblMapMsg->pathVecTlv.baseTlv.length);
		                if(rtcode != MPLS_TRUE)
						{
						    printf("ldppAttr -> pAttr, out of memory");
						}
						else /* 95.tst,97.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
		
		                lblMapMsg->pathVecTlvExists = 1;
		                lblMapMsg -> pathVecTlv.lsrId[lblMapMsg->pathVecTlv.baseTlv.length/4] =
		                    lsrAttr.lsrAttribute.lsrId;
		                lblMapMsg -> pathVecTlv.baseTlv.length =
		                    lblMapMsg->pathVecTlv.baseTlv.length +4;
		            }
		        }
		        else
		        {
		            #ifdef MPLS_LOOP_MEM_PVTLV
		            if(ldppAttr -> pAttr)
		            {
            	        ldp_pathvector_free(ldppAttr);
		            }
                    rtcode = ldp_pathvector_malloc(ldppAttr,lblMapMsg->pathVecTlv.baseTlv.length);
		            if(rtcode != MPLS_TRUE)
					{
					    printf("ldppAttr -> pAttr, out of memory");
					}
					else /* 95.tst,97.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
	
	                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 -> pAttr != MPLS_NULL)&&
                       (ldppAttr -> attrvalue_valid == 1))
                {
                    if(lblMapMsg->pathVecTlvExists == 0)  /*  166.tst */
                    {
                    	if(ldppAttr -> pAttr)
                    	{
                	        ldp_pathvector_free(ldppAttr);
                    	}
                        lblMapMsg->pathVecTlvExists = 0;
                        lblMapMsg -> pathVecTlv.lsrId[0] = 0;
                        lblMapMsg -> pathVecTlv.baseTlv.length = 0;
                        lblMapMsg -> hopCountTlv.hcValue = lblMapMsg->hopCountTlv.hcValue + 1;
                    }
                    else /* 97.tst */
                    {
                    	lblMapMsg->hopCountTlv.hcValue += 1;
                    }
                }
            }
            else  if((lblMapMsg->hopCountTlvExists == 1)&&
                    (ldppAttr -> hopcount > lblMapMsg->hopCountTlv.hcValue)) /* 96.tst */
            {
                if(lblMapMsg->hopCountTlv.hcValue != 0)
                {
					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) 
                    {
                    	#ifdef MPLS_LOOP_MEM_PVTLV
			            if(ldppAttr -> pAttr)
			            {
                	        ldp_pathvector_free(ldppAttr);
			            }
						#endif
						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;
                        lblMapMsg->pathVecTlvExists = 0;                /* 164.tst */
                    }
                }
                else
                {
                    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(lblMapMsg->pathVecTlvExists == 0)  /* 162.tst 164.tst*/
                    {
			            #ifdef MPLS_LOOP_MEM_PVTLV
			            if(ldppAttr -> pAttr)
			            {
                	        ldp_pathvector_free(ldppAttr);
			            }
						#endif
                        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;
                    }
                }
                ldppAttr -> hopcount = lblMapMsg->hopCountTlv.hcValue;
            }
            else  if((lblMapMsg->hopCountTlvExists == 1)&&
                   (ldppAttr -> hopcount < lblMapMsg->hopCountTlv.hcValue)) /* 96.tst */
            {
			    ldppAttr -> hopcount = lblMapMsg->hopCountTlv.hcValue;
                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) /* 163.tst,165.tst */
                {
		            #ifdef MPLS_LOOP_MEM_PVTLV
		            if(ldppAttr -> pAttr)
		            {
                        ldp_pathvector_free(ldppAttr);
		            }
					#endif
                    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;
                }
            }
        }
        return 1;/* attr change, need send mapping message */
    }
}

⌨️ 快捷键说明

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