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

📄 encdec.h

📁 路由器协议平台mpls协议的设计与实现源代码。
💻 H
📖 第 1 页 / 共 5 页
字号:
#define MPLS_TLVTYPEERROR        -63
#define MPLS_MSGTYPEERROR        -64
#define MPLS_FECERROR            -65
#define MPLS_ENC_TRAFFICERROR    -66
#define MPLS_ENC_LSPIDERROR      -68  
#define MPLS_ENC_RESCLSERROR     -70 
#define MPLS_ENC_PREEMPTERROR    -72  
#define MPLS_ENC_PINNINGERROR    -74
#define MPLS_ENC_UNKERROR		 -81
#define MPLS_DEC_UNKERROR		 -82
/**********************************************************************
   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                        |
   +                               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
**********************************************************************/
/* draft-ietf-mpls-ldp-11.txt page 32 */
   typedef struct mplsLdpHeader_s
   {
      unsigned short protocolVersion;
      unsigned short pduLength;      /* length excluding the version and length */
      unsigned long  lsrAddress;     /* IP address assigned to LSR              */
      unsigned 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.
draft-ietf-mpls-ldp-11.txt page 47
**********************************************************************/

   typedef struct mplsLdpMsgFlag_s
   {
      BITFIELDS_ASCENDING_2( unsigned short uBit   :1,
	                     unsigned short msgType:15 )
   } mplsLdpMsgFlag_t;

   typedef struct mplsLdpMsg_s
   {
     union {
              struct mplsLdpMsgFlag_s   flags;
              unsigned short                    mark;
           }    flags;

     unsigned short     msgLength; /* msgId + mandatory param + optional param */
     unsigned long      msgId;    /* used to identify the notification msg 
                            apply to this 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.
      
      this is not correct,wether the unknown tlv is stored,U set,F set.
      draft-ietf-mpls-ldp-11.txt page 34
**********************************************************************/

   typedef struct mplsLdpTlvFlag_s
   {
      BITFIELDS_ASCENDING_3( 
                            unsigned short uBit:1,
	                        unsigned short fBit:1,
	                        unsigned short type:14 
	                        )
   } mplsLdpTlvFlag_t;

   typedef struct mplsLdpTlv_s
   {
      union {  struct mplsLdpTlvFlag_s  flags;
               unsigned short                   mark;
            } flags;

      unsigned short length;   /* length of the value field */
 
   } mplsLdpTlv_t;

 


/***********************************************************************
   Lbl request message id Tlv encoding
   draft-ietf-mpls-ldp-11.txt page 69
***********************************************************************/

   typedef struct mplsLdpLblMsgIdTlv_s
   {
      struct mplsLdpTlv_s baseTlv;
      unsigned long  msgId;

   } mplsLdpLblMsgIdTlv_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                        |
       +                               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |                               |
       -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-++
       draft-ietf-mpls-ldp-11.txt page 57
***********************************************************************/

   typedef struct mplsLdpCspFlag_s
   {
      BITFIELDS_ASCENDING_4( unsigned short lad:1,  /* 1 = downstream on demand  */
                             unsigned short ld :1,  /* loop detection            */
                             unsigned short res:6,  /* reserved                  */
                             unsigned short pvl:8   /* path vec limit            */
                            )	
   } mplsLdpCspFlag_t;

   typedef struct mplsLdpCspTlv_s
   {
      struct mplsLdpTlv_s baseTlv;
      unsigned short             protocolVersion;
      unsigned short             holdTime;        /* proposed keep alive interval */
 
      union {  struct mplsLdpCspFlag_s flags;
               unsigned short                 mark;
            } flags;
 
      unsigned short         maxPduLen;
      unsigned long          rcvLsrAddress;
      unsigned 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
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     |  Res  |    Minimum VPI        |      Minimum VCI              |
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     |  Res  |    Maximum VPI        |      Maximum VCI              |
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     draft-ietf-mpls-ldp-11.txt page 61
***********************************************************************/

   typedef struct mplsLdpAtmLblRngFlag_s
   {
      BITFIELDS_ASCENDING_3( unsigned long res1  :4,  /* reserved : 0 on transmision */
                             unsigned long minVpi:12, /* if <12 bits right justified */
                             unsigned long minVci:16  /* if <16 bits right justified */
                           )
      BITFIELDS_ASCENDING_3( unsigned long res2  :4,  /* reserved : 0 on transmision */
                             unsigned long maxVpi:12, /* if <12 bits right justified */
                             unsigned long maxVci:16  /* if <16 bits right justified */
                           )
   } mplsLdpAtmLblRngFlag_t;

   typedef struct mplsLdpAtmLblRng_s
   {
      union {
               struct mplsLdpAtmLblRngFlag_s flags;
               unsigned long                      mark[2];
            } flags;
   } mplsLdpAtmLblRng_t;



/*********************************************************************** 
 Flags for ATM Session Parameters TLV and 
	   Frame Relay Session Parameters TLV

 Note: both types of session parameters have the same type of flags;
       use then the same struct
***********************************************************************/

   typedef struct mplsLdpSPFlag_s
   {
      BITFIELDS_ASCENDING_4( unsigned long mergeType:2, /* merge typ            */
                             unsigned long numLblRng:4, /* # of label range com */
                             unsigned long dir      :1, /* 0 => bidirectional   */
                             unsigned long res      :25 
                           )
   } mplsLdpSPFlag_t;


/*********************************************************************** 
   ATM 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|   ATM Sess Parms (0x0501) |      Length                   |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  | M |   N   |D|                        Reserved                 |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                 ATM Label Range Component 1                   |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                                                               |
  ~                                                               ~
  |                                                               |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                 ATM Label Range Component N                   |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  draft-ietf-mpls-ldp-11.txt page 60
***********************************************************************/

   typedef struct mplsLdpAspTlv_s
   {
      struct mplsLdpTlv_s baseTlv;
      union {  struct mplsLdpSPFlag_s flags;
               unsigned long                  mark;
            } flags;
      struct mplsLdpAtmLblRng_s lblRngList[MPLS_LDP_ATMLBLMAXLEN];

   } mplsLdpAspTlv_t;




/***********************************************************************
   Frame Relay 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
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    | Reserved    |Len|                     Minimum DLCI            |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    | Reserved        |                     Maximum DLCI            |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    draft-ietf-mpls-ldp-11.txt page 64
***********************************************************************/

   typedef struct mplsLdpFrFlag_s
   {
      BITFIELDS_ASCENDING_3( unsigned long res_min:7,
                             unsigned long len    :2,
                             unsigned long minDlci:23 )
      BITFIELDS_ASCENDING_2( unsigned long res_max:9,
                             unsigned long maxDlci:23 )
   } mplsLdpFrFlag_t;
 
   typedef struct mplsLdpFrLblRng_s
   {
      union {

⌨️ 快捷键说明

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