]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ldp.c
For Babel, recognise both UDP/6696 and UDP/6697.
[tcpdump] / print-ldp.c
index f7437440d765278bb16c6007354d9c6d34685223..de3b34e5b54f94d264863f8286a1956ccd85901b 100644 (file)
@@ -16,7 +16,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.13 2005-05-03 08:21:09 hannes Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.20 2006-06-23 02:03:09 hannes Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -35,6 +35,7 @@ static const char rcsid[] _U_ =
 #include "addrtoname.h"
 
 #include "l2vpn.h"
+#include "af.h"
 
 /*
  * ldp common header
@@ -116,7 +117,7 @@ static const struct tok ldp_msg_values[] = {
     { LDP_MSG_INIT,                 "Initialization" },
     { LDP_MSG_KEEPALIVE,             "Keepalive" },
     { LDP_MSG_ADDRESS,              "Address" },
-    { LDP_MSG_ADDRESS_WITHDRAW,             "Address Widthdraw" },
+    { LDP_MSG_ADDRESS_WITHDRAW,             "Address Withdraw" },
     { LDP_MSG_LABEL_MAPPING,        "Label Mapping" },
     { LDP_MSG_LABEL_REQUEST,        "Label Request" },
     { LDP_MSG_LABEL_WITHDRAW,       "Label Withdraw" },
@@ -130,6 +131,7 @@ static const struct tok ldp_msg_values[] = {
 
 #define        LDP_TLV_FEC                  0x0100
 #define        LDP_TLV_ADDRESS_LIST         0x0101
+#define LDP_TLV_ADDRESS_LIST_AFNUM_LEN 2
 #define        LDP_TLV_HOP_COUNT            0x0103
 #define        LDP_TLV_PATH_VECTOR          0x0104
 #define        LDP_TLV_GENERIC_LABEL        0x0200
@@ -148,6 +150,7 @@ static const struct tok ldp_msg_values[] = {
 #define        LDP_TLV_FR_SESSION_PARM      0x0502
 #define LDP_TLV_FT_SESSION          0x0503
 #define        LDP_TLV_LABEL_REQUEST_MSG_ID 0x0600
+#define LDP_TLV_MTU                  0x0601 /* rfc 3988 */
 
 static const struct tok ldp_tlv_values[] = {
     { LDP_TLV_FEC,                  "FEC" },
@@ -170,6 +173,7 @@ static const struct tok ldp_tlv_values[] = {
     { LDP_TLV_FR_SESSION_PARM,       "Frame-Relay Session Parameters" },
     { LDP_TLV_FT_SESSION,            "Fault-Tolerant Session Parameters" },
     { LDP_TLV_LABEL_REQUEST_MSG_ID,  "Label Request Message ID" },
+    { LDP_TLV_MTU,                   "MTU" },
     { 0, NULL}
 };
 
@@ -214,13 +218,6 @@ static const struct tok ldp_fec_martini_ifparm_vccv_cv_values[] = {
     { 0, NULL}
 };
 
-/* RFC1700 address family numbers, same definition in print-bgp.c */
-#define AFNUM_INET     1
-#define AFNUM_INET6    2
-
-#define FALSE 0
-#define TRUE  1
-
 int ldp_msg_print(register const u_char *);
 int ldp_tlv_print(register const u_char *);
    
@@ -296,24 +293,31 @@ ldp_tlv_print(register const u_char *tptr) {
 
     case LDP_TLV_ADDRESS_LIST:
        af = EXTRACT_16BITS(tptr);
-       tptr+=2;
-       printf("\n\t      Adress Family: ");
-       if (af == AFNUM_INET) {
-           printf("IPv4, addresses:");
-           for (i=0; i<(tlv_tlen-2)/4; i++) {
+       tptr+=LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
+        tlv_tlen -= LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
+       printf("\n\t      Address Family: %s, addresses",
+               tok2str(af_values, "Unknown (%u)", af));
+        switch (af) {
+        case AFNUM_INET:
+           while(tlv_tlen >= sizeof(struct in_addr)) {
                printf(" %s",ipaddr_string(tptr));
-               tptr+=4;
+               tlv_tlen-=sizeof(struct in_addr);
+               tptr+=sizeof(struct in_addr);                
            }
-       }
+            break;
 #ifdef INET6
-       else if (af == AFNUM_INET6) {
-           printf("IPv6, addresses:");
-           for (i=0; i<(tlv_tlen-2)/16; i++) {
+        case AFNUM_INET6:
+           while(tlv_tlen >= sizeof(struct in6_addr)) {
                printf(" %s",ip6addr_string(tptr));
-               tptr+=16;
+               tlv_tlen-=sizeof(struct in6_addr);
+               tptr+=sizeof(struct in6_addr);                
            }
-       }
+            break;
 #endif
+        default:
+            /* unknown AF */
+            break;
+        }
        break;
 
     case LDP_TLV_COMMON_SESSION:
@@ -375,6 +379,8 @@ ldp_tlv_print(register const u_char *tptr) {
                 vc_info_tlv_len = *(tptr+1);
                 if (vc_info_tlv_len < 2)
                     break;
+                if (vc_info_len < vc_info_tlv_len)
+                    break;
 
                 printf("\n\t\tInterface Parameter: %s (0x%02x), len %u",
                        tok2str(ldp_fec_martini_ifparm_values,"Unknown",vc_info_tlv_type),
@@ -449,6 +455,10 @@ ldp_tlv_print(register const u_char *tptr) {
            printf(", Recovery Time: %ums", ui);
        break;
 
+    case LDP_TLV_MTU:
+       printf("\n\t      MTU: %u", EXTRACT_16BITS(tptr));
+       break;
+
 
     /*
      *  FIXME those are the defined TLVs that lack a decoder
@@ -572,6 +582,8 @@ ldp_msg_print(register const u_char *pptr) {
         case LDP_MSG_KEEPALIVE:
         case LDP_MSG_ADDRESS:
         case LDP_MSG_LABEL_MAPPING:
+        case LDP_MSG_ADDRESS_WITHDRAW:
+        case LDP_MSG_LABEL_WITHDRAW:
             while(msg_tlen >= 4) {
                 processed = ldp_tlv_print(msg_tptr);
                 if (processed == 0)
@@ -586,9 +598,7 @@ ldp_msg_print(register const u_char *pptr) {
          *  you are welcome to contribute code ;-)
          */
 
-        case LDP_MSG_ADDRESS_WITHDRAW:
         case LDP_MSG_LABEL_REQUEST:
-        case LDP_MSG_LABEL_WITHDRAW:
         case LDP_MSG_LABEL_RELEASE:
         case LDP_MSG_LABEL_ABORT_REQUEST: