]> The Tcpdump Group git mirrors - tcpdump/commitdiff
make the uptime-stamp printing optional as some implementations don't include that
authorhannes <hannes>
Sat, 9 Apr 2005 09:42:25 +0000 (09:42 +0000)
committerhannes <hannes>
Sat, 9 Apr 2005 09:42:25 +0000 (09:42 +0000)
print-chdlc.c

index 50cc539ab14624255106566207d70c3399127562..65437d1c7245a37781c18e5800f3733c41380cba 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.32.2.1 2005-04-07 23:09:32 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.32.2.2 2005-04-09 09:42:25 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -121,14 +121,12 @@ struct cisco_slarp {
                struct {
                        u_int8_t addr[4];
                        u_int8_t mask[4];
-                       u_int8_t unused[6];
                } addr;
                struct {
                        u_int8_t myseq[4];
                        u_int8_t yourseq[4];
                        u_int8_t rel[2];
-                       u_int8_t t1[2];
-                       u_int8_t t2[2];
+                        u_int8_t time[0];
                } keep;
        } un;
 };
@@ -139,6 +137,7 @@ static void
 chdlc_slarp_print(const u_char *cp, u_int length)
 {
        const struct cisco_slarp *slarp;
+        u_int sec,min,hrs,days;
 
         printf("SLARP (length: %u), ",length);
        if (length < SLARP_LEN)
@@ -158,13 +157,18 @@ chdlc_slarp_print(const u_char *cp, u_int length)
                        ipaddr_string(&slarp->un.addr.mask));
                break;
        case SLARP_KEEPALIVE:
-               printf("keepalive: mineseen=0x%08x, yourseen=0x%08x",
-                       EXTRACT_32BITS(&slarp->un.keep.myseq),
-                       EXTRACT_32BITS(&slarp->un.keep.yourseq));
-               printf(", reliability=0x%04x, t1=%d.%d",
-                       EXTRACT_16BITS(&slarp->un.keep.rel),
-                       EXTRACT_16BITS(&slarp->un.keep.t1),
-                       EXTRACT_16BITS(&slarp->un.keep.t2));
+               printf("keepalive: mineseen=0x%08x, yourseen=0x%08x, reliability=0x%04x",
+                       EXTRACT_32BITS(&slarp->un.keep.myseq),
+                       EXTRACT_32BITS(&slarp->un.keep.yourseq),
+                       EXTRACT_16BITS(&slarp->un.keep.rel));
+
+                if (length >= SLARP_LEN) { /* uptime-stamp is optional */
+                        sec = EXTRACT_32BITS(&slarp->un.keep.time) / 1000;
+                        min = sec / 60; sec -= min * 60;
+                        hrs = min / 60; min -= hrs * 60;
+                        days = hrs / 24; hrs -= days * 24;
+                        printf(", link uptime=%ud%uh%um%us",days,hrs,min,sec);
+                }
                break;
        default:
                printf("0x%02x unknown", EXTRACT_32BITS(&slarp->code));