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

📄 mpls_encdec_02.c

📁 Linux平台下
💻 C
📖 第 1 页 / 共 5 页
字号:
#define MPLS_VCIFPARAM_HDR       2       /* size of TL in a VC Intf Param TLV */#define MPLS_FEC_ELEMTYPELEN     1       #define MPLS_FEC_PRELENLEN       1       #define MPLS_FEC_ADRFAMLEN       2       #define MPLS_FEC_CRLSPLEN        4       /* length of cr lsp fec        */#define MPLS_FEC_MARTINILEN      8       /* length of the min martin fec*/#define MPLS_MAXHOPSNUMBER       20      /* max # hops in path vector   */#define MPLS_MAXNUMFECELEMENT    10      /* max # of fec elements       */#define MPLS_VCIFPARAM_MTU       0x1#define MPLS_VCIFPARAM_ATMCONCAT 0x2#define MPLS_VCIFPARAM_INFO      0x3#define MPLS_VCIFPARAM_CEMBYTES  0x4#define MPLS_VCIFPARAM_CEMOPTION 0x5/* for label request message */#define MPLS_LBLREQ_MSGTYPE      0x0401  /* label request msg           */#define MPLS_LBLMSGID_TLVTYPE    0x0601  /* lbl return msg id tlv       *//* for label withdraw and release messages */#define MPLS_LBLWITH_MSGTYPE     0x0402  /* label withdraw msg          */#define MPLS_LBLREL_MSGTYPE      0x0403  /* label release msg           *//* for ER tlvs */#define MPLS_ER_TLVTYPE          0x0800  /* constraint routing tlv      */#define MPLS_TRAFFIC_TLVTYPE     0x0810  /* traffic parameters tlv      */#define MPLS_PDR_TLVTYPE         0x0811  /* traffic peak data rate tlv  */#define MPLS_CDR_TLVTYPE         0x0812  /* committed data rate tlv     */#define MPLS_CBT_TLVTYPE         0x0813  /* committed burst tolerance   */#define MPLS_PREEMPT_TLVTYPE     0x0820  /* preemption tlv              */#define MPLS_LSPID_TLVTYPE       0x0821  /* lspid tlv                   */#define MPLS_RESCLASS_TLVTYPE    0x0822  /* resource class tlv          */#define MPLS_PINNING_TLVTYPE     0x0823  /* route pinning tlv           */#define MPLS_ERHOP_IPV4_TLVTYPE  0x801   /* explicit routing ipv4 tlv   */#define MPLS_ERHOP_IPV6_TLVTYPE  0x802   /* explicit routing ipv6 tlv   */#define MPLS_ERHOP_AS_TLVTYPE    0x803   /* explicit routing autonomous				 	    system number tlv           */#define MPLS_ERHOP_LSPID_TLVTYPE 0x804   /* explicit routing lspid tlv  */#define MPLS_ERHOP_IPV4_FIXLEN   8       /* fix length in bytes         */#define MPLS_ERHOP_IPV6_FIXLEN   20      /* fix length in bytes         */#define MPLS_ERHOP_AS_FIXLEN     4       /* fix length in bytes         */#define MPLS_ERHOP_LSPID_FIXLEN  8       /* fix length in bytes         */#define MPLS_IPV6ADRLENGTH       16#define MPLS_MAX_ER_HOPS         20      /* decent number of hops; 				 	    change if required          */#define MPLS_PREEMPTTLV_FIXLEN   4       /* setPrio + holdPrio + res    */#define MPLS_LSPIDTLV_FIXLEN     8       /* res + crlspId + routerId    */#define MPLS_TRAFFICPARAMLENGTH  4       /* traffic parameters length   *//* for label abort request message */#define MPLS_LBLABORT_MSGTYPE 0x0404     /* label abort request msg     *//* * Error codes */#define MPLS_ENC_BUFFTOOSMALL    -1#define MPLS_DEC_BUFFTOOSMALL    -2#define MPLS_ENC_TLVERROR        -3#define MPLS_DEC_TLVERROR        -4#define MPLS_ENC_ATMLBLERROR     -5#define MPLS_DEC_ATMLBLERROR     -6#define MPLS_ENC_BASEMSGERROR    -7#define MPLS_DEC_BASEMSGERROR    -8#define MPLS_ENC_CSPERROR        -9#define MPLS_DEC_CSPERROR        -10#define MPLS_ENC_ASPERROR        -11#define MPLS_DEC_ASPERROR        -12#define MPLS_ENC_FSPERROR        -13#define MPLS_DEC_FSPERROR        -14#define MPLS_ENC_STATUSERROR     -16#define MPLS_DEC_STATUSERROR     -17#define MPLS_ENC_EXSTATERROR     -18#define MPLS_DEC_EXSTATERROR     -19#define MPLS_ENC_RETPDUERROR     -20#define MPLS_DEC_RETPDUERROR     -21#define MPLS_ENC_RETMSGERROR     -22#define MPLS_DEC_RETMSGERROR     -23#define MPLS_PDU_LENGTH_ERROR    -24#define MPLS_ENC_CHPERROR        -25#define MPLS_DEC_CHPERROR        -26#define MPLS_ENC_CSNERROR        -27#define MPLS_DEC_CSNERROR        -28#define MPLS_ENC_TRADRERROR      -29#define MPLS_DEC_TRADRERROR      -30#define MPLS_ENC_ADRLISTERROR    -31#define MPLS_DEC_ADRLISTERROR    -32#define MPLS_WC_FECERROR         -33#define MPLS_PATHVECTORERROR     -34#define MPLS_ENC_FECERROR        -35#define MPLS_DEC_FECERROR        -36#define MPLS_ENC_GENLBLERROR     -37#define MPLS_DEC_GENLBLERROR     -38#define MPLS_ENC_MAPATMERROR     -39#define MPLS_DEC_MAPATMERROR     -40#define MPLS_ENC_FRLBLERROR      -41#define MPLS_DEC_FRLBLERROR      -42#define MPLS_ENC_COSERROR        -43#define MPLS_DEC_COSERROR        -44#define MPLS_ENC_HOPCOUNTERROR   -45#define MPLS_DEC_HOPCOUNTERROR   -46#define MPLS_ENC_PATHVECERROR    -47#define MPLS_DEC_PATHVECERROR    -48#define MPLS_ENC_LBLMSGIDERROR   -49#define MPLS_DEC_LBLMSGIDERROR   -50#define MPLS_ENC_HDRTLVERROR     -51#define MPLS_DEC_HDRTLVERROR     -52#define MPLS_ENC_FECELEMERROR    -53#define MPLS_DEC_FECELEMERROR    -54#define MPLS_ENC_FSPLBLERROR     -55#define MPLS_DEC_FSPLBLERROR     -56#define MPLS_ENC_ERHOPERROR      -57#define MPLS_DEC_ERHOPERROR      -58#define MPLS_ENC_ERTLVERROR      -59#define MPLS_DEC_ERTLVERROR      -60#define MPLS_ENC_ERHOPLENERROR   -61#define MPLS_DEC_ERHOPLENERROR   -62#define MPLS_TLVTYPEERROR        -63#define MPLS_MSGTYPEERROR        -64#define MPLS_FECERROR            -65#define MPLS_ENC_TRAFFICERROR    -66#define MPLS_DEC_TRAFFICERROR    -67#define MPLS_ENC_LSPIDERROR      -68 #define MPLS_DEC_LSPIDERROR      -69 #define MPLS_ENC_RESCLSERROR     -70 #define MPLS_DEC_RESCLSERROR     -71 #define MPLS_ENC_PREEMPTERROR    -72 #define MPLS_DEC_PREEMPTERROR    -73 #define MPLS_ENC_PINNINGERROR    -74#define MPLS_DEC_PINNINGERROR    -75#define MPLS_FLOATTYPEERROR      -76#define MPLS_FECTLVERROR         -77#define MPLS_IPV4LENGTHERROR     -78#define MPLS_ER_HOPSNUMERROR     -79/**********************************************************************   LDP header      0                   1                   2                   3    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+   |  Version                      |         PDU Length            |   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+   |                         LDP Identifier                        |   +                               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+   |                               |   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+**********************************************************************/   typedef struct mplsLdpHeader_s   {      u_short protocolVersion;      u_short pduLength;      /* length excluding the version and length */      u_int   lsrAddress;     /* IP address assigned to LSR              */      u_short labelSpace;     /* within LSR                              */    } mplsLdpHeader_t; /**********************************************************************   LDP Messages (All LDP messages have the following format:)    0                   1                   2                   3    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+   |U|   Message Type              |      Message Length           |   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+   |                     Message ID                                |   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+   |                                                               |   +                                                               +   |                     Mandatory Parameters                      |   +                                                               +   |                                                               |   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+   |                                                               |   +                                                               +   |                     Optional Parameters                       |   +                                                               +   |                                                               |   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+Note: the U flag is ignored for now. There is not check for its value.**********************************************************************/   typedef struct mplsLdpMsgFlag_s   {      BITFIELDS_ASCENDING_2( u_short uBit   :1,	                     u_short msgType:15 )   } mplsLdpMsgFlag_t;   typedef struct mplsLdpMsg_s   {     union {  struct mplsLdpMsgFlag_s flags;              u_short                 mark;           } flags;     u_short   msgLength; /* msgId + mandatory param + optional param */     u_int     msgId;     /* used to identify the notification msg    */    } mplsLdpMsg_t;/**********************************************************************   Type-Length-Value Encoding    0                   1                   2                   3    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+   |U|F|        Type               |            Length             |   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+   |                                                               |   |                             Value                             |   ~                                                               ~   |                                                               |   |                               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+   |                               |   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+Note: the decode functions for tlv do not check the values for      F flag. They check only the value of the U flag; if      it is set will ignore the tlv and keep processing the message;      otherwise will ignore the message and return error. Please note       that the unknown tlv which is skipped will not be stored anywhere.**********************************************************************/   typedef struct mplsLdpTlvFlag_s   {      BITFIELDS_ASCENDING_3( u_short uBit:1,	                     u_short fBit:1,	                     u_short type:14 )   } mplsLdpTlvFlag_t;   typedef struct mplsLdpTlv_s   {      union {  struct mplsLdpTlvFlag_s flags;               u_short                 mark;            } flags;      u_short length;   /* length of the value field */    } mplsLdpTlv_t; /**********************************************************************  Common Session Parameters TLV        0                   1                   2                   3        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+       |U|F| Common Sess Parms (0x0500)|      Length                   |       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+       | Protocol Version              |      Keep Alive Time          |       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+       |A|D| Reserved  |     PVLim     |      Max PDU Length           |       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+       |                 Receiver LDP Identifer                        |       +                               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+       |                               |       -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-++***********************************************************************/   typedef struct mplsLdpCspFlag_s   {      BITFIELDS_ASCENDING_4( u_short lad:1,  /* 1 = downstream on demand  */                             u_short ld :1,  /* loop detection            */                             u_short res:6,  /* reserved                  */                             u_short pvl:8   /* path vec limit            */             )	   } mplsLdpCspFlag_t;   typedef struct mplsLdpCspTlv_s   {      struct mplsLdpTlv_s baseTlv;      u_short             protocolVersion;      u_short             holdTime;        /* proposed keep alive interval */       union {  struct mplsLdpCspFlag_s flags;               u_short                 mark;            } flags;       u_short         maxPduLen;      u_int           rcvLsrAddress;      u_short         rcvLsId;    } mplsLdpCspTlv_t;/***********************************************************************    ATM Label Range Component     0                   1                   2                   3     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1

⌨️ 快捷键说明

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