X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/1a9542cfd1f59a329e8cb32fb1737e7c8a11ecd2..014c506042fb9254c759a58cee932fae1bc8a44c:/print-ldp.c diff --git a/print-ldp.c b/print-ldp.c index 896bc403..355fac9a 100644 --- a/print-ldp.c +++ b/print-ldp.c @@ -142,8 +142,10 @@ static const struct tok ldp_msg_values[] = { #define LDP_TLV_ATM_SESSION_PARM 0x0501 #define LDP_TLV_FR_SESSION_PARM 0x0502 #define LDP_TLV_FT_SESSION 0x0503 +#define LDP_TLV_TYPED_WC_FEC_CAP 0x050b /* rfc 5918 */ #define LDP_TLV_LABEL_REQUEST_MSG_ID 0x0600 #define LDP_TLV_MTU 0x0601 /* rfc 3988 */ +#define LDP_TLV_DUAL_STACK_CAP 0x0701 /* rfc 7552 */ static const struct tok ldp_tlv_values[] = { { LDP_TLV_FEC, "FEC" }, @@ -165,8 +167,41 @@ static const struct tok ldp_tlv_values[] = { { LDP_TLV_ATM_SESSION_PARM, "ATM Session Parameters" }, { LDP_TLV_FR_SESSION_PARM, "Frame-Relay Session Parameters" }, { LDP_TLV_FT_SESSION, "Fault-Tolerant Session Parameters" }, + { LDP_TLV_TYPED_WC_FEC_CAP, "Typed Wildcard FEC Capability" }, { LDP_TLV_LABEL_REQUEST_MSG_ID, "Label Request Message ID" }, { LDP_TLV_MTU, "MTU" }, + { LDP_TLV_DUAL_STACK_CAP, "Dual-Stack Capability" }, + { 0, NULL} +}; + +static const struct tok ldp_status_code_values[] = { + /* rfc 5036 */ + { 0x00000000, "Success" }, + { 0x00000001, "Bad LDP Identifier" }, + { 0x00000002, "Bad Protocol Version" }, + { 0x00000003, "Bad PDU Length" }, + { 0x00000004, "Unknown Message Type" }, + { 0x00000005, "Bad Message Length" }, + { 0x00000006, "Unknown TLV" }, + { 0x00000007, "Bad TLV Length" }, + { 0x00000008, "Malformted TLV Value" }, + { 0x00000009, "Hold Timer Expired" }, + { 0x0000000A, "Shutdown" }, + { 0x0000000B, "Loop Detected" }, + { 0x0000000C, "Unknown FEC" }, + { 0x0000000D, "No Route" }, + { 0x0000000E, "No Label Resources" }, + { 0x0000000F, "Label Resources/Available" }, + { 0x00000010, "Session Rejected/No Hello" }, + { 0x00000011, "Session Rejected/Parameters Advertisement Mode" }, + { 0x00000012, "Session Rejected/Parameters Max PDU Length" }, + { 0x00000013, "Session Rejected/Parameters Label Range" }, + { 0x00000014, "KeepAlive Timer Expired" }, + { 0x00000015, "Label Request Aborted" }, + { 0x00000016, "Missing Message Parameters" }, + { 0x00000017, "Unsupported Address Family" }, + { 0x00000018, "Session Rejected/Bad KeepAlive Time" }, + { 0x00000019, "Internal Error" }, { 0, NULL} }; @@ -211,6 +246,16 @@ static const struct tok ldp_fec_martini_ifparm_vccv_cv_values[] = { { 0, NULL} }; +/* rfc 7552 */ +#define LDP_DUAL_STACK_TRANSPORT_PREF_IPV4 0x40 +#define LDP_DUAL_STACK_TRANSPORT_PREF_IPV6 0x60 + +static const struct tok ldp_dual_stack_transport_pref_values[] = { + { LDP_DUAL_STACK_TRANSPORT_PREF_IPV4, "IPv4" }, + { LDP_DUAL_STACK_TRANSPORT_PREF_IPV6, "IPv6" }, + { 0, NULL} +}; + static u_int ldp_pdu_print(netdissect_options *, const u_char *); /* @@ -249,7 +294,7 @@ ldp_tlv_print(netdissect_options *ndo, const struct ldp_tlv_header *ldp_tlv_header; u_short tlv_type,tlv_len,tlv_tlen,af,ft_flags; - u_char fec_type; + u_char fec_type, transport_pref; u_int ui,vc_info_len, vc_info_tlv_type, vc_info_tlv_len,idx; char buf[100]; int i; @@ -307,14 +352,14 @@ ldp_tlv_print(netdissect_options *ndo, ND_PRINT("\n\t Address Family: %s, addresses", tok2str(af_values, "Unknown (%u)", af)); switch (af) { - case AFNUM_INET: + case AFNUM_IP: while(tlv_tlen >= sizeof(nd_ipv4)) { ND_PRINT(" %s", GET_IPADDR_STRING(tptr)); tlv_tlen-=sizeof(nd_ipv4); tptr+=sizeof(nd_ipv4); } break; - case AFNUM_INET6: + case AFNUM_IP6: while(tlv_tlen >= sizeof(nd_ipv6)) { ND_PRINT(" %s", GET_IP6ADDR_STRING(tptr)); tlv_tlen-=sizeof(nd_ipv6); @@ -327,12 +372,35 @@ ldp_tlv_print(netdissect_options *ndo, } break; + case LDP_TLV_HOP_COUNT: + TLV_TCHECK(1); + ND_PRINT("\n\t Hop Count: %u", GET_U_1(tptr)); + break; + + case LDP_TLV_PATH_VECTOR: + TLV_TCHECK(4); + ND_PRINT("\n\t Path Vector: %s", GET_IPADDR_STRING(tptr)); + tptr += 4; + tlv_tlen -= 4; + while (tlv_tlen >= 4) { + ND_PRINT(", %s", GET_IPADDR_STRING(tptr)); + tptr += 4; + tlv_tlen -= 4; + } + break; + case LDP_TLV_COMMON_SESSION: - TLV_TCHECK(8); + TLV_TCHECK(14); ND_PRINT("\n\t Version: %u, Keepalive: %us, Flags: [Downstream %s, Loop Detection %s]", GET_BE_U_2(tptr), GET_BE_U_2(tptr + 2), - (GET_BE_U_2(tptr + 6)&0x8000) ? "On Demand" : "Unsolicited", - (GET_BE_U_2(tptr + 6)&0x4000) ? "Enabled" : "Disabled" + (GET_BE_U_2(tptr + 4)&0x8000) ? "On Demand" : "Unsolicited", + (GET_BE_U_2(tptr + 4)&0x4000) ? "Enabled" : "Disabled" + ); + ND_PRINT("\n\t Path Vector Limit %u, Max-PDU length: %u, Receiver Label-Space-ID %s:%u", + GET_U_1(tptr+5), + GET_BE_U_2(tptr+6), + GET_IPADDR_STRING(tptr+8), + GET_BE_U_2(tptr+12) ); break; @@ -354,7 +422,7 @@ ldp_tlv_print(netdissect_options *ndo, af = GET_BE_U_2(tptr); tptr+=2; tlv_tlen-=2; - if (af == AFNUM_INET) { + if (af == AFNUM_IP) { i=decode_prefix4(ndo, tptr, tlv_tlen, buf, sizeof(buf)); if (i == -2) goto trunc; @@ -364,8 +432,7 @@ ldp_tlv_print(netdissect_options *ndo, ND_PRINT(": IPv4 prefix (invalid length)"); else ND_PRINT(": IPv4 prefix %s", buf); - } - else if (af == AFNUM_INET6) { + } else if (af == AFNUM_IP6) { i=decode_prefix6(ndo, tptr, tlv_tlen, buf, sizeof(buf)); if (i == -2) goto trunc; @@ -375,8 +442,7 @@ ldp_tlv_print(netdissect_options *ndo, ND_PRINT(": IPv6 prefix (invalid length)"); else ND_PRINT(": IPv6 prefix %s", buf); - } - else + } else ND_PRINT(": Address family %u prefix", af); break; case LDP_FEC_HOSTADDRESS: @@ -475,17 +541,20 @@ ldp_tlv_print(netdissect_options *ndo, break; case LDP_TLV_STATUS: - TLV_TCHECK(8); + TLV_TCHECK(10); ui = GET_BE_U_4(tptr); tptr+=4; - ND_PRINT("\n\t Status: 0x%02x, Flags: [%s and %s forward]", - ui&0x3fffffff, - ui&0x80000000 ? "Fatal error" : "Advisory Notification", - ui&0x40000000 ? "do" : "don't"); + ND_PRINT("\n\t Status Code: %s, Flags: [%s and %s forward]", + tok2str(ldp_status_code_values, "Unknown", ui&0x3fffffff), + ui&0x80000000 ? "Fatal error" : "Advisory Notification", + ui&0x40000000 ? "do" : "don't"); ui = GET_BE_U_4(tptr); tptr+=4; if (ui) ND_PRINT(", causing Message ID: 0x%08x", ui); + ui = GET_BE_U_2(tptr); + if (ui) + ND_PRINT(", Message Type: %s", tok2str(ldp_msg_values, "Unknown", ui)); break; case LDP_TLV_FT_SESSION: @@ -508,19 +577,31 @@ ldp_tlv_print(netdissect_options *ndo, ND_PRINT(", Recovery Time: %ums", ui); break; + case LDP_TLV_TYPED_WC_FEC_CAP: + TLV_TCHECK(1); + ND_PRINT("\n\t %s", GET_U_1(tptr)&0x80 ? "Support" : "No Support"); + break; + case LDP_TLV_MTU: TLV_TCHECK(2); ND_PRINT("\n\t MTU: %u", GET_BE_U_2(tptr)); break; + case LDP_TLV_DUAL_STACK_CAP: + TLV_TCHECK(4); + transport_pref = GET_U_1(tptr); + ND_PRINT("\n\t Transport Connection Preference: %s", + tok2str(ldp_dual_stack_transport_pref_values, + "Unknown", + transport_pref)); + break; + /* * FIXME those are the defined TLVs that lack a decoder * you are welcome to contribute code ;-) */ - case LDP_TLV_HOP_COUNT: - case LDP_TLV_PATH_VECTOR: case LDP_TLV_ATM_LABEL: case LDP_TLV_FR_LABEL: case LDP_TLV_EXTD_STATUS: @@ -663,6 +744,9 @@ ldp_pdu_print(netdissect_options *ndo, case LDP_MSG_LABEL_MAPPING: case LDP_MSG_ADDRESS_WITHDRAW: case LDP_MSG_LABEL_WITHDRAW: + case LDP_MSG_LABEL_REQUEST: + case LDP_MSG_LABEL_RELEASE: + case LDP_MSG_LABEL_ABORT_REQUEST: while(msg_tlen >= 4) { processed = ldp_tlv_print(ndo, msg_tptr, msg_tlen); if (processed == 0) @@ -672,15 +756,6 @@ ldp_pdu_print(netdissect_options *ndo, } break; - /* - * FIXME those are the defined messages that lack a decoder - * you are welcome to contribute code ;-) - */ - - case LDP_MSG_LABEL_REQUEST: - case LDP_MSG_LABEL_RELEASE: - case LDP_MSG_LABEL_ABORT_REQUEST: - default: if (ndo->ndo_vflag <= 1) print_unknown_data(ndo, msg_tptr, "\n\t ", msg_tlen);