From: Hannes Gredler Date: Wed, 16 Aug 2023 09:28:33 +0000 (+0000) Subject: LDP: print status TLV codes as per rfc 5036 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/f893dc1e89bfde3d92f337e57dc186eb975eeab5?ds=sidebyside LDP: print status TLV codes as per rfc 5036 --- diff --git a/print-ldp.c b/print-ldp.c index 1e8f87d3..3792a471 100644 --- a/print-ldp.c +++ b/print-ldp.c @@ -172,6 +172,37 @@ static const struct tok ldp_tlv_values[] = { { 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} +}; + #define LDP_FEC_WILDCARD 0x01 #define LDP_FEC_PREFIX 0x02 #define LDP_FEC_HOSTADDRESS 0x03 @@ -491,17 +522,21 @@ 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 ID: %s", tok2str(ldp_msg_values, "Unknown", ui)); + break; case LDP_TLV_FT_SESSION: diff --git a/tests/ldp-common-session.out b/tests/ldp-common-session.out index 8414fa36..a630c572 100644 --- a/tests/ldp-common-session.out +++ b/tests/ldp-common-session.out @@ -3,7 +3,7 @@ LDP, Label-Space-ID: 192.168.0.2:0, pdu-length: 28 Notification Message (0x0001), length: 18, Message ID: 0xfffffff9, Flags: [ignore if unknown] Status TLV (0x0300), length: 10, Flags: [ignore and don't forward if unknown] - Status: 0x0a, Flags: [Fatal error and don't forward] + Status Code: Shutdown, Flags: [Fatal error and don't forward] 2 12:23:59.828114 IP (tos 0xc0, ttl 255, id 1499, offset 0, flags [none], proto TCP (6), length 40) 192.168.0.2.58320 > 192.168.0.1.646: Flags [F.], cksum 0x7d76 (correct), seq 32, ack 1, win 2990, length 0 3 12:24:00.018513 IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 70) @@ -126,7 +126,7 @@ Generic Label TLV (0x0200), length: 4, Flags: [ignore and don't forward if unknown] Label: 20066 Status TLV (0x0300), length: 10, Flags: [ignore and don't forward if unknown] - Status: 0x0b, Flags: [Advisory Notification and don't forward], causing Message ID: 0x0000000f + Status Code: Loop Detected, Flags: [Advisory Notification and don't forward], causing Message ID: 0x0000000f, Message ID: Label Mapping LDP, Label-Space-ID: 192.168.0.2:0, pdu-length: 48 Label Release Message (0x0403), length: 38, Message ID: 0x0000000b, Flags: [ignore if unknown] FEC TLV (0x0100), length: 8, Flags: [ignore and don't forward if unknown] @@ -134,7 +134,7 @@ Generic Label TLV (0x0200), length: 4, Flags: [ignore and don't forward if unknown] Label: 20066 Status TLV (0x0300), length: 10, Flags: [ignore and don't forward if unknown] - Status: 0x0b, Flags: [Advisory Notification and don't forward], causing Message ID: 0x00000010 + Status Code: Loop Detected, Flags: [Advisory Notification and don't forward], causing Message ID: 0x00000010, Message ID: Label Mapping LDP, Label-Space-ID: 192.168.0.2:0, pdu-length: 48 Label Release Message (0x0403), length: 38, Message ID: 0x0000000c, Flags: [ignore if unknown] FEC TLV (0x0100), length: 8, Flags: [ignore and don't forward if unknown] @@ -142,7 +142,7 @@ Generic Label TLV (0x0200), length: 4, Flags: [ignore and don't forward if unknown] Label: 20066 Status TLV (0x0300), length: 10, Flags: [ignore and don't forward if unknown] - Status: 0x0b, Flags: [Advisory Notification and don't forward], causing Message ID: 0x00000011 + Status Code: Loop Detected, Flags: [Advisory Notification and don't forward], causing Message ID: 0x00000011, Message ID: Label Mapping LDP, Label-Space-ID: 192.168.0.2:0, pdu-length: 48 Label Release Message (0x0403), length: 38, Message ID: 0x0000000d, Flags: [ignore if unknown] FEC TLV (0x0100), length: 8, Flags: [ignore and don't forward if unknown] @@ -150,7 +150,7 @@ Generic Label TLV (0x0200), length: 4, Flags: [ignore and don't forward if unknown] Label: 20066 Status TLV (0x0300), length: 10, Flags: [ignore and don't forward if unknown] - Status: 0x0b, Flags: [Advisory Notification and don't forward], causing Message ID: 0x00000012 + Status Code: Loop Detected, Flags: [Advisory Notification and don't forward], causing Message ID: 0x00000012, Message ID: Label Mapping LDP, Label-Space-ID: 192.168.0.2:0, pdu-length: 48 Label Release Message (0x0403), length: 38, Message ID: 0x0000000e, Flags: [ignore if unknown] FEC TLV (0x0100), length: 8, Flags: [ignore and don't forward if unknown] @@ -158,7 +158,7 @@ Generic Label TLV (0x0200), length: 4, Flags: [ignore and don't forward if unknown] Label: 20066 Status TLV (0x0300), length: 10, Flags: [ignore and don't forward if unknown] - Status: 0x0b, Flags: [Advisory Notification and don't forward], causing Message ID: 0x00000013 + Status Code: Loop Detected, Flags: [Advisory Notification and don't forward], causing Message ID: 0x00000013, Message ID: Label Mapping 13 12:24:12.831754 IP (tos 0xc0, ttl 255, id 1520, offset 0, flags [none], proto TCP (6), length 415) 192.168.0.2.58321 > 192.168.0.1.646: Flags [P.], cksum 0xef2a (correct), seq 666:1041, ack 813, win 3000, length 375 LDP, Label-Space-ID: 192.168.0.2:0, pdu-length: 371