]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-isoclns.c
Fix spaces
[tcpdump] / print-isoclns.c
index f79f240406f5cccf226551b0b30e30b53e5fc096..b9935ebd2f2cea5675e413d2d26527b07e2255cf 100644 (file)
@@ -29,7 +29,7 @@
 /*
  * specification:
  *
- * CLNP: ISO 8473
+ * CLNP: ISO 8473 (respective ITU version is at http://www.itu.int/rec/T-REC-X.233/en/)
  * ES-IS: ISO 9542
  * IS-IS: ISO 10589
  */
@@ -50,7 +50,6 @@
 #include "oui.h"
 #include "signature.h"
 
-static const char tstr[] = " [|isis]";
 
 /*
  * IS-IS is defined in ISO 10589.  Look there for protocol definitions.
@@ -680,10 +679,7 @@ void
 isoclns_print(netdissect_options *ndo, const u_char *p, u_int length)
 {
        ndo->ndo_protocol = "isoclns";
-       if (!ND_TTEST_1(p)) { /* enough bytes on the wire ? */
-               ND_PRINT("|OSI");
-               return;
-       }
+       ND_TCHECK_1(p); /* enough bytes on the wire ? */
 
        if (ndo->ndo_eflag)
                ND_PRINT("OSI NLPID %s (0x%02x): ", tok2str(nlpid_values, "Unknown", EXTRACT_U_1(p)), EXTRACT_U_1(p));
@@ -732,6 +728,9 @@ isoclns_print(netdissect_options *ndo, const u_char *p, u_int length)
                        print_unknown_data(ndo, p, "\n\t", length);
                break;
        }
+       return;
+trunc:
+       nd_print_trunc(ndo);
 }
 
 #define        CLNP_PDU_ER      1
@@ -780,6 +779,7 @@ clnp_print(netdissect_options *ndo,
        const struct clnp_segment_header_t *clnp_segment_header;
         uint8_t rfd_error,rfd_error_major,rfd_error_minor;
 
+       ndo->ndo_protocol = "clnp";
        clnp_header = (const struct clnp_header_t *) pptr;
         ND_TCHECK_SIZE(clnp_header);
 
@@ -903,7 +903,7 @@ clnp_print(netdissect_options *ndo,
         }
 
         /* now walk the options */
-        while (li_remaining >= 2) {
+        while (li_remaining != 0) {
             u_int op, opli;
             const uint8_t *tptr;
 
@@ -1058,6 +1058,18 @@ clnp_print(netdissect_options *ndo,
                 break;
             }
 
+        /* The cases above break from the switch block if they see and print
+         * a CLNP header in the Data part. For an Error Report PDU this is
+         * described in Section 7.9.6 of ITU X.233 (1997 E), also known as
+         * ISO/IEC 8473-1:1998(E). It is not clear why in this code the same
+         * applies to an Echo Response PDU, as the standard does not specify
+         * the contents -- could be a proprietary extension or a bug. In either
+         * case, if the Data part does not contain a CLNP header, its structure
+         * is considered unknown and the decoding falls through to print the
+         * contents as-is.
+         */
+        ND_FALL_THROUGH;
+
         case   CLNP_PDU_DT:
         case   CLNP_PDU_MD:
         case   CLNP_PDU_ERQ:
@@ -1073,7 +1085,7 @@ clnp_print(netdissect_options *ndo,
         return (1);
 
  trunc:
-    ND_PRINT("[|clnp]");
+    nd_print_trunc(ndo);
     return (1);
 
 }
@@ -1108,6 +1120,7 @@ esis_print(netdissect_options *ndo,
        u_int li, version, esis_pdu_type, source_address_length, source_address_number;
        const struct esis_header_t *esis_header;
 
+       ndo->ndo_protocol = "esis";
        if (!ndo->ndo_eflag)
                ND_PRINT("ES-IS");
 
@@ -1385,8 +1398,10 @@ esis_print(netdissect_options *ndo,
                 print_unknown_data(ndo, pptr, "\n\t  ", opli);
             pptr += opli;
         }
+        return;
+
 trunc:
-        ND_PRINT("[|esis]");
+       nd_print_trunc(ndo);
 }
 
 static void
@@ -1398,7 +1413,7 @@ isis_print_mcid(netdissect_options *ndo,
   ND_TCHECK_SIZE(mcid);
   ND_PRINT("ID: %u, Name: ", EXTRACT_U_1(mcid->format_id));
 
-  if (fn_printzp(ndo, mcid->name, 32, ndo->ndo_snapend))
+  if (nd_printzp(ndo, mcid->name, 32, ndo->ndo_snapend))
     goto trunc;
 
   ND_PRINT("\n\t              Lvl: %u", EXTRACT_BE_U_2(mcid->revision_lvl));
@@ -1407,9 +1422,10 @@ isis_print_mcid(netdissect_options *ndo,
 
   for(i=0;i<16;i++)
     ND_PRINT("%.2x ", mcid->digest[i]);
+  return;
 
 trunc:
-  ND_PRINT("%s", tstr);
+  nd_print_trunc(ndo);
 }
 
 static int
@@ -1530,8 +1546,7 @@ isis_print_mt_port_cap_subtlv(netdissect_options *ndo,
   return 0;
 
   trunc:
-    ND_PRINT("\n\t\t");
-    ND_PRINT("%s", tstr);
+    nd_print_trunc(ndo);
     return(1);
 }
 
@@ -1659,8 +1674,7 @@ isis_print_mt_capability_subtlv(netdissect_options *ndo,
   return 0;
 
   trunc:
-    ND_PRINT("\n\t\t");
-    ND_PRINT("%s", tstr);
+    nd_print_trunc(ndo);
     return(1);
 }
 
@@ -1824,8 +1838,7 @@ isis_print_ip_reach_subtlv(netdissect_options *ndo,
     return(1);
 
 trunc:
-    ND_PRINT("%s", ident);
-    ND_PRINT("%s", tstr);
+    nd_print_trunc(ndo);
     return(0);
 }
 
@@ -2270,6 +2283,7 @@ isis_print(netdissect_options *ndo,
     u_int i,vendor_id;
     int sigcheck;
 
+    ndo->ndo_protocol = "isis";
     packet_len=length;
     optr = p; /* initialize the _o_riginal pointer to the packet start -
                  need it for parsing the checksum TLV and authentication
@@ -2846,7 +2860,7 @@ isis_print(netdissect_options *ndo,
 
            switch (EXTRACT_U_1(tptr)) {
            case ISIS_SUBTLV_AUTH_SIMPLE:
-               if (fn_printzp(ndo, tptr + 1, tlv_len - 1, ndo->ndo_snapend))
+               if (nd_printzp(ndo, tptr + 1, tlv_len - 1, ndo->ndo_snapend))
                    goto trunc;
                break;
            case ISIS_SUBTLV_AUTH_MD5:
@@ -2974,7 +2988,7 @@ isis_print(netdissect_options *ndo,
 
        case ISIS_TLV_HOSTNAME:
            ND_PRINT("\n\t      Hostname: ");
-           if (fn_printzp(ndo, tptr, tmp, ndo->ndo_snapend))
+           if (nd_printzp(ndo, tptr, tmp, ndo->ndo_snapend))
                goto trunc;
            break;
 
@@ -3231,7 +3245,7 @@ isis_print(netdissect_options *ndo,
     return (1);
 
 trunc:
-    ND_PRINT("%s", tstr);
+    nd_print_trunc(ndo);
     return (1);
 }
 
@@ -3263,10 +3277,3 @@ osi_print_cksum(netdissect_options *ndo, const uint8_t *pptr,
                 }
         }
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */