📄 mpls_encdec_02.c
字号:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Res | Minimum VPI | Minimum VCI | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Res | Maximum VPI | Maximum VCI | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+***********************************************************************/ typedef struct mplsLdpAtmLblRngFlag_s { BITFIELDS_ASCENDING_3( u_int res1 :4, /* reserved : 0 on transmision */ u_int minVpi:12, /* if <12 bits right justified */ u_int minVci:16 /* if <16 bits right justified */ ) BITFIELDS_ASCENDING_3( u_int res2 :4, /* reserved : 0 on transmision */ u_int maxVpi:12, /* if <12 bits right justified */ u_int maxVci:16 /* if <16 bits right justified */ ) } mplsLdpAtmLblRngFlag_t; typedef struct mplsLdpAtmLblRng_s { union { struct mplsLdpAtmLblRngFlag_s flags; u_int 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( u_int mergeType:2, /* merge typ */ u_int numLblRng:4, /* # of label range com */ u_int dir :1, /* 0 => bidirectional */ u_int 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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+***********************************************************************/ typedef struct mplsLdpAspTlv_s { struct mplsLdpTlv_s baseTlv; union { struct mplsLdpSPFlag_s flags; u_int mark; } flags; struct mplsLdpAtmLblRng_s lblRngList[MPLS_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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+***********************************************************************/ typedef struct mplsLdpFrFlag_s { BITFIELDS_ASCENDING_3( u_int res_min:7, u_int len :2, u_int minDlci:23 ) BITFIELDS_ASCENDING_2( u_int res_max:9, u_int maxDlci:23 ) } mplsLdpFrFlag_t; typedef struct mplsLdpFrLblRng_s { union { struct mplsLdpFrFlag_s flags; u_int mark[2]; } flags; } mplsLdpFrLblRng_t;/********************************************************************** Frame Relay 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| FR Sess Parms (0x0502) | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | M | N |D| Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Frame Relay Label Range Component 1 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | ~ ~ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Frame Relay Label Range Component N | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+***********************************************************************/ typedef struct mplsLdpFspTlv_s { struct mplsLdpTlv_s baseTlv; union { struct mplsLdpSPFlag_s flags; u_int mark; } flags; struct mplsLdpFrLblRng_s lblRngList[MPLS_FRLBLMAXLEN]; } mplsLdpFspTlv_t;/*********************************************************************** Initialization Message 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| Initialization (0x0200) | Message Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Message ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Common Session Parameters TLV | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Optional Parameters | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+***********************************************************************/ typedef struct mplsLdpInitMsg_s { struct mplsLdpMsg_s baseMsg; struct mplsLdpCspTlv_s csp; struct mplsLdpAspTlv_s asp; struct mplsLdpFspTlv_s fsp; u_char cspExists:1; u_char aspExists:1; u_char fspExists:1; } mplsLdpInitMsg_t;/*********************************************************************** Status Code 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |E|F| Status Data | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+***********************************************************************/ typedef struct mplsLdpStautsFlag_s { BITFIELDS_ASCENDING_3( u_int error :1, /* E bit */ u_int forward:1, /* F bit */ u_int status :30 ) } mplsLdpStautsFlag_t;/*********************************************************************** Status (TLV) 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| Status (0x0300) | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Status Code | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Message ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Message Type | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+***********************************************************************/ typedef struct mplsLdpStatusTlv_s { struct mplsLdpTlv_s baseTlv; union { struct mplsLdpStautsFlag_s flags; u_int mark; } flags; u_int msgId; u_short msgType; } mplsLdpStatusTlv_t;/*********************************************************************** Extended Status (TLV) Encoding***********************************************************************/ typedef struct mplsLdpExStatusTlv_s { struct mplsLdpTlv_s baseTlv; u_int value; /* additional info for status */ } mplsLdpExStatusTlv_t;/*********************************************************************** Returned PDU (TLV) Encoding***********************************************************************/ typedef struct mplsLdpRetPduTlv_s { struct mplsLdpTlv_s baseTlv; struct mplsLdpHeader_s headerTlv; u_char data[MPLS_NOT_MAXSIZE]; } mplsLdpRetPduTlv_t;/*********************************************************************** Returned MSG (TLV) Encoding***********************************************************************/ typedef struct mplsLdpRetMsgTlv_s { struct mplsLdpTlv_s baseTlv; u_short msgType; u_short msgLength; u_char data[MPLS_NOT_MAXSIZE]; } mplsLdpRetMsgTlv_t;/*********************************************************************** LSPID Tlv 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| LSPID-TLV (0x0821) | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Reserved | Local CRLSP ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Ingress LSR Router ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+***********************************************************************/ typedef struct mplsLdpLspIdTlv_s { struct mplsLdpTlv_s baseTlv; u_short res; u_short localCrlspId; u_int routerId; /* ingress lsr router id */ } mplsLdpLspIdTlv_t;/*********************************************************************** Notification Message 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| Notification (0x0001) | Message Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -