]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ldp.c
IP: Remove an unused and deprecated option number
[tcpdump] / print-ldp.c
index 642feb241cb670eb946e63dd941b15e73516d1e7..355fac9a151f319fff16723d5ecc12acff1d9260 100644 (file)
@@ -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;
@@ -327,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]",
@@ -479,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:
@@ -512,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:
@@ -667,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)
@@ -676,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);