]> The Tcpdump Group git mirrors - tcpdump/commitdiff
add support for AIS/RDI OAM cell payload printing, hexdump location/source ID for...
authorhannes <hannes>
Wed, 8 Feb 2006 16:18:56 +0000 (16:18 +0000)
committerhannes <hannes>
Wed, 8 Feb 2006 16:18:56 +0000 (16:18 +0000)
print-atm.c
util.c

index b7a1c341c242d7bfa1a05268829ef2bceb7d3ad5..05fca9de9ac0e2c1ace1575a0bb0cc890f686f77 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.45 2006-02-08 01:43:00 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.46 2006-02-08 16:18:56 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -378,7 +378,7 @@ int
 oam_print (const u_char *p, u_int length, u_int hec) {
 
     u_int32_t cell_header;
-    u_int16_t vpi, vci, cksum, cksum_shouldbe;
+    u_int16_t vpi, vci, cksum, cksum_shouldbe, idx;
     u_int8_t  cell_type, func_type, payload, clp;
 
     union {
@@ -426,28 +426,41 @@ oam_print (const u_char *p, u_int length, u_int hec) {
                        oam_ptr.oam_fm_loopback->loopback_indicator & OAM_FM_LOOPBACK_INDICATOR_MASK),
                EXTRACT_LE_32BITS(&oam_ptr.oam_fm_loopback->correlation_tag));
         printf("\n\tLocation-ID ");
-        safeputs((const char *)&oam_ptr.oam_fm_loopback->loopback_id,
-                 sizeof(oam_ptr.oam_fm_loopback->loopback_id));
+        for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->loopback_id); idx++) {
+            printf("0x%02x ", oam_ptr.oam_fm_loopback->loopback_id[idx]);
+        }
         printf("\n\tSource-ID   ");
-        safeputs((const char *)&oam_ptr.oam_fm_loopback->source_id,
-                 sizeof(oam_ptr.oam_fm_loopback->source_id));
+        for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->source_id); idx++) {
+            printf("0x%02x ", oam_ptr.oam_fm_loopback->source_id[idx]);
+        }
+        break;
+
+    case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_AIS):
+    case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_RDI):
+        oam_ptr.oam_fm_ais_rdi = (const struct oam_fm_ais_rdi_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN);
+        printf("\n\tFailure-type 0x%02x", oam_ptr.oam_fm_ais_rdi->failure_type);
+        printf("\n\tLocation-ID ");
+        for (idx = 0; idx < sizeof(oam_ptr.oam_fm_ais_rdi->failure_location); idx++) {
+            printf("0x%02x ", oam_ptr.oam_fm_ais_rdi->failure_location[idx]);
+        }
         break;
+
+    case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_CONTCHECK):
+        break;
+
     default:
         break;
     }
 
     /* crc10 checksum verification */
     gen_crc10_table();
-    cksum = EXTRACT_16BITS(p + OAM_CELLTYPE_FUNCTYPE_LEN + OAM_FUNCTION_SPECIFIC_LEN) & OAM_CRC10_MASK;
+    cksum = EXTRACT_16BITS(p + OAM_CELLTYPE_FUNCTYPE_LEN + OAM_FUNCTION_SPECIFIC_LEN)
+        & OAM_CRC10_MASK;
     cksum_shouldbe = verify_crc10_cksum(0, p, OAM_PAYLOAD_LEN);
     
-    printf("\n\tcksum 0x%03x", cksum);
-
-    if (cksum_shouldbe == 0) {
-        printf(" (correct)");
-    } else {
-        printf(" (incorrect (-> 0x%03x))", cksum_shouldbe);
-    }
+    printf("\n\tcksum 0x%03x (%scorrect)",
+           cksum,
+           cksum_shouldbe == 0 ? "" : "in");
 
     return 1;
 }
diff --git a/util.c b/util.c
index cb4f2aaa768ce16a5fd07261f14c6d0ee4b1e9cd..5746b0949c14fb778621563f38ebd1246a63577f 100644 (file)
--- a/util.c
+++ b/util.c
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.106 2006-02-08 01:38:16 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.107 2006-02-08 16:18:56 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -545,5 +545,5 @@ safeputchar(int c)
        if (ch < 0x80 && isprint(ch))
                printf("%c", ch);
        else
-               printf("\\0x%02x ", ch);
+               printf("\\0x%02x", ch);
 }