Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/ping Add support for printing out messages about missin...



details:   https://anonhg.NetBSD.org/src/rev/da1c86240c6c
branches:  trunk
changeset: 535229:da1c86240c6c
user:      matt <matt%NetBSD.org@localhost>
date:      Mon Aug 12 18:24:53 2002 +0000

description:
Add support for printing out messages about missing packet gaps.  This is
done with the -v switch.  If -q is also given with -v, then only the
packet gap messages will be printed along with summary after each gap
message.

diffstat:

 sbin/ping/ping.c |  22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diffs (43 lines):

diff -r a041468ad33f -r da1c86240c6c sbin/ping/ping.c
--- a/sbin/ping/ping.c  Mon Aug 12 18:08:13 2002 +0000
+++ b/sbin/ping/ping.c  Mon Aug 12 18:24:53 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ping.c,v 1.65 2002/08/01 08:56:59 itojun Exp $ */
+/*     $NetBSD: ping.c,v 1.66 2002/08/12 18:24:53 matt Exp $   */
 
 /*
  * Copyright (c) 1989, 1993
@@ -62,7 +62,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ping.c,v 1.65 2002/08/01 08:56:59 itojun Exp $");
+__RCSID("$NetBSD: ping.c,v 1.66 2002/08/12 18:24:53 matt Exp $");
 #endif
 
 #include <stdio.h>
@@ -1016,6 +1016,24 @@
                                     tot_len, opack_ip->ip_len);
                }
 
+               if (!dupflag) {
+                       static u_int16_t last_seqno = 0xffff;
+                       u_int16_t seqno = ntohs((u_int16_t)icp->icmp_seq);
+                       u_int16_t gap = seqno - (last_seqno + 1);
+                       if (gap > 0 && gap < 0x8000 &&
+                           (pingflags & F_VERBOSE)) {
+                               (void)printf("[*** sequence gap of %u "
+                                   "packets from %u ... %u ***]\n", gap,
+                                   (u_int16_t) (last_seqno + 1),
+                                   (u_int16_t) (seqno - 1));
+                               if (pingflags & F_QUIET)
+                                       summary(0);
+                       }
+
+                       if (gap < 0x8000)
+                               last_seqno = seqno;
+               }
+
                if (pingflags & F_QUIET)
                        return;
 



Home | Main Index | Thread Index | Old Index