]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-isoclns.c
provide multiline output for PIM Joins/Grafts/Graft-Acks
[tcpdump] / print-isoclns.c
index de1eb13e116f0c65f51c3ca70928356ea16803cd..736555b371ec0b0068a9144242da14b564251769 100644 (file)
@@ -26,7 +26,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.113 2003-12-20 22:24:51 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.118 2004-03-18 10:58:17 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -80,6 +80,7 @@ static struct tok osi_nlpid_values[] = {
 
 #define ISIS_PDU_TYPE_MASK      0x1F
 #define ESIS_PDU_TYPE_MASK      0x1F
+#define CLNP_PDU_TYPE_MASK      0x1F
 #define ISIS_LAN_PRIORITY_MASK  0x7F
 
 #define ISIS_PDU_L1_LAN_IIH    15
@@ -141,7 +142,6 @@ static struct tok isis_pdu_values[] = {
 #define ISIS_TLV_SHARED_RISK_GROUP   138 /* draft-ietf-isis-gmpls-extensions */
 #define ISIS_TLV_NORTEL_PRIVATE1     176
 #define ISIS_TLV_NORTEL_PRIVATE2     177
-#define ISIS_TLV_HOLDTIME            198 /* ES-IS */
 #define ISIS_TLV_RESTART_SIGNALING   211 /* draft-ietf-isis-restart-01 */
 #define ISIS_TLV_MT_IS_REACH         222 /* draft-ietf-isis-wg-multi-topology-05 */
 #define ISIS_TLV_MT_SUPPORTED        229 /* draft-ietf-isis-wg-multi-topology-05 */
@@ -151,7 +151,7 @@ static struct tok isis_pdu_values[] = {
 #define ISIS_TLV_MT_IP6_REACH        237 /* draft-ietf-isis-wg-multi-topology-05 */
 #define ISIS_TLV_PTP_ADJ             240 /* rfc3373 */
 #define ISIS_TLV_IIH_SEQNR           241 /* draft-shen-isis-iih-sequence-00 */
-#define ISIS_TLV_VENDOR_PRIVATE      250 /* draft-ietf-isis-proprietary-tlv-00 */
+#define ISIS_TLV_VENDOR_PRIVATE      250 /* draft-ietf-isis-experimental-tlv-01 */
 
 static struct tok isis_tlv_values[] = {
     { ISIS_TLV_AREA_ADDR,         "Area address(es)"},
@@ -222,6 +222,7 @@ static struct tok esis_option_values[] = {
 #define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW           9 /* draft-ietf-isis-traffic-05 */
 #define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW        10 /* draft-ietf-isis-traffic-05 */
 #define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW        11 /* draft-ietf-isis-traffic-05 */
+#define ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE          12 /* draft-ietf-tewg-diff-te-proto-06 */
 #define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC            18 /* draft-ietf-isis-traffic-05 */
 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* draft-ietf-isis-gmpls-extensions */
 #define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR    21 /* draft-ietf-isis-gmpls-extensions */
@@ -235,6 +236,7 @@ static struct tok isis_ext_is_reach_subtlv_values[] = {
     { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW,            "Maximum link bandwidth" },
     { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW,          "Reservable link bandwidth" },
     { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW,          "Unreserved bandwidth" },
+    { ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE,            "Diffserv TE" },
     { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC,              "Traffic Engineering Metric" },
     { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE,   "Link Protection Type" },
     { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR,      "Interface Switching Capability" },
@@ -365,6 +367,7 @@ struct isis_tlv_ptp_adj {
 };
 
 static int osi_cksum(const u_int8_t *, u_int);
+static int clnp_print(const u_int8_t *, u_int);
 static void esis_print(const u_int8_t *, u_int);
 static int isis_print(const u_int8_t *, u_int);
 
@@ -506,12 +509,13 @@ void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
             return;
         }
 
-        printf("OSI, %s",tok2str(osi_nlpid_values,"Unknown NLPID (0x%02x)",*p));
+        printf("%s",tok2str(osi_nlpid_values,"Unknown NLPID (0x%02x)",*p));
         
        switch (*p) {
 
        case NLPID_CLNP:
-               (void)printf(", length %u", length);
+               if (!clnp_print(p, length))
+                        print_unknown_data(p,"\n\t",caplen);
                break;
 
        case NLPID_ESIS:
@@ -535,6 +539,116 @@ void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
        }
 }
 
+#define        CLNP_PDU_ER      1
+#define        CLNP_PDU_DT     28
+#define        CLNP_PDU_MD     29
+#define        CLNP_PDU_ERQ    30
+#define        CLNP_PDU_ERP    31
+
+static struct tok clnp_pdu_values[] = {
+    { CLNP_PDU_ER,  "Error Report"},
+    { CLNP_PDU_MD,  "MD"},
+    { CLNP_PDU_DT,  "Data"},
+    { CLNP_PDU_ERQ, "Echo Request"},
+    { CLNP_PDU_ERP, "Echo Response"},
+    { 0, NULL }
+};
+
+struct clnp_header_t {
+    u_int8_t nlpid;
+    u_int8_t length_indicator;
+    u_int8_t version;
+    u_int8_t lifetime; /* units of 500ms */
+    u_int8_t type;
+    u_int8_t segment_length[2];
+    u_int8_t cksum[2];
+};
+
+/*
+ * clnp_print
+ * Decode CLNP packets.  Return 0 on error.
+ */
+
+static int clnp_print (const u_int8_t *pptr, u_int length)
+{
+       const u_int8_t *optr,*source_address,*dest_address;
+        u_int li,source_address_length,dest_address_length, clnp_pdu_type;
+       const struct clnp_header_t *clnp_header;
+
+       clnp_header = (const struct clnp_header_t *) pptr;
+        li = clnp_header->length_indicator;
+        optr = pptr;
+
+        /*
+         * Sanity checking of the header.
+         */
+
+        /* FIXME */
+
+        clnp_pdu_type = clnp_header->type & CLNP_PDU_TYPE_MASK;
+
+        pptr += sizeof(struct clnp_header_t);
+        dest_address_length = *pptr;
+        dest_address = pptr + 1;
+
+        pptr += (1 + dest_address_length);
+        source_address_length = *pptr;
+        source_address = pptr +1;
+
+        pptr += (1 + source_address_length);
+
+        if (vflag < 1) {
+            printf(", %s > %s, length %u",
+                   print_nsap(source_address, source_address_length),
+                   print_nsap(dest_address, dest_address_length),
+                   length);
+            return (1);
+        }
+        printf(", length %u", length);
+
+    printf("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, PDU length: %u, checksum: 0x%04x ",
+           tok2str(clnp_pdu_values,
+                   "unknown (%u)",
+                   clnp_pdu_type),
+           clnp_header->length_indicator,
+           clnp_header->version,
+           clnp_header->lifetime/2,
+           (clnp_header->lifetime%2)*5,
+           EXTRACT_16BITS(clnp_header->segment_length),
+           EXTRACT_16BITS(clnp_header->cksum));
+
+        /* do not attempt to verify the checksum if it is zero */
+        if (EXTRACT_16BITS(clnp_header->cksum) == 0)
+                printf("(unverified)");
+            else printf("(%s)", osi_cksum(optr, li) ? "incorrect" : "correct");
+
+        printf("\n\tsource address (length %u): %s\n\tdest   address (length %u): %s",
+               source_address_length,
+               print_nsap(source_address, source_address_length),
+               dest_address_length,
+               print_nsap(dest_address, dest_address_length));
+
+        /* dump the remaining header data */
+        print_unknown_data(pptr,"\n\t",clnp_header->length_indicator-(pptr-optr));
+
+        switch (clnp_pdu_type) {
+
+        case   CLNP_PDU_ER:
+        case   CLNP_PDU_DT:
+        case   CLNP_PDU_MD:
+        case   CLNP_PDU_ERQ:
+        case   CLNP_PDU_ERP:
+
+        default:
+            /* dump the PDU specific data */
+            print_unknown_data(optr+clnp_header->length_indicator,"\n\t  ",length-clnp_header->length_indicator);
+
+        }
+
+        return (1);
+}
+
+
 #define        ESIS_PDU_REDIRECT       6
 #define        ESIS_PDU_ESH            2
 #define        ESIS_PDU_ISH            4
@@ -578,7 +692,12 @@ esis_print(const u_int8_t *pptr, u_int length)
         /*
          * Sanity checking of the header.
          */
-        
+
+        if (esis_header->nlpid != NLPID_ESIS) {
+            printf(", nlpid 0x%02x packet not supported", esis_header->nlpid);
+            return;
+        }
+
         if (esis_header->version != ESIS_VERSION) {
             printf(", version %d packet not supported", esis_header->version);
             return;
@@ -711,10 +830,6 @@ esis_print(const u_int8_t *pptr, u_int length)
 
             switch (op) {
 
-            case ISIS_TLV_AREA_ADDR:
-                printf("\n\t    %s", print_nsap(tptr, opli));
-                break;
-
             case ESIS_OPTION_ES_CONF_TIME:
                 printf("%us", EXTRACT_16BITS(tptr));
                 break;
@@ -923,7 +1038,7 @@ trunctlv:
 static int
 isis_print_is_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *ident) {
 
-        int priority_level;
+        int priority_level,bandwidth_constraint;
         union { /* int to float conversion buffer for several subTLVs */
             float f; 
             u_int32_t i;
@@ -968,6 +1083,21 @@ isis_print_is_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *i
                tptr+=4;
             }
             break;
+        case ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE:
+            printf("%sBandwidth Constraints Model ID: (%u)",ident, *tptr);
+            tptr+=4;
+            /* for now lets just print the first 8 BCs -
+             * FIXME is this dep. on the BC model ?
+             */
+            for (bandwidth_constraint = 0; bandwidth_constraint < 8; bandwidth_constraint++) {
+                bw.i = EXTRACT_32BITS(tptr);
+                printf("%s  Bandwidth constraint %d: %.3f Mbps",
+                       ident,
+                       bandwidth_constraint,
+                       bw.f*8/1000000 );
+               tptr+=4;
+            }
+            break;
         case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC:
             printf(", %u", EXTRACT_24BITS(tptr));
             break;