]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ldp.c
LDP: fix Message Type vs. Message ID for status TLV
[tcpdump] / print-ldp.c
index 1e8f87d3429afdd57f68f99c53baabbc02087240..355fac9a151f319fff16723d5ecc12acff1d9260 100644 (file)
@@ -142,6 +142,7 @@ 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 */
@@ -166,12 +167,44 @@ 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}
+};
+
 #define LDP_FEC_WILDCARD       0x01
 #define LDP_FEC_PREFIX         0x02
 #define LDP_FEC_HOSTADDRESS    0x03
@@ -339,6 +372,23 @@ 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(14);
        ND_PRINT("\n\t      Version: %u, Keepalive: %us, Flags: [Downstream %s, Loop Detection %s]",
@@ -491,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:
@@ -524,6 +577,11 @@ 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));
@@ -544,8 +602,6 @@ ldp_tlv_print(netdissect_options *ndo,
      *  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: