Source-Changes-HG archive

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

[src/trunk]: src/sbin/ping Support for ping -a: beep when packet received.



details:   https://anonhg.NetBSD.org/src/rev/f0dde81278a6
branches:  trunk
changeset: 473797:f0dde81278a6
user:      sommerfeld <sommerfeld%NetBSD.org@localhost>
date:      Sat Jun 19 19:15:22 1999 +0000

description:
Support for ping -a: beep when packet received.
Slightly tweaked from version submitted by andrew%untraceable.net@localhost in PR7815

diffstat:

 sbin/ping/ping.8 |   9 +++++++--
 sbin/ping/ping.c |  20 +++++++++++++++++---
 2 files changed, 24 insertions(+), 5 deletions(-)

diffs (93 lines):

diff -r a49c515b736b -r f0dde81278a6 sbin/ping/ping.8
--- a/sbin/ping/ping.8  Sat Jun 19 18:50:28 1999 +0000
+++ b/sbin/ping/ping.8  Sat Jun 19 19:15:22 1999 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: ping.8,v 1.29 1999/06/12 17:17:16 tron Exp $
+.\"    $NetBSD: ping.8,v 1.30 1999/06/19 19:15:22 sommerfeld Exp $
 .\"
 .\" Copyright (c) 1985, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -44,7 +44,7 @@
 .Sh SYNOPSIS
 .Nm ""
 .Bk -words
-.Op Fl dfnoqrvDPQRL
+.Op Fl adfnoqrvDPQRL
 .Ek
 .Bk -words
 .Op Fl c Ar count
@@ -96,6 +96,11 @@
 packet.
 The options are as follows:
 .Bl -tag -width Ds
+.It Fl a
+Emit an audible beep (by sending an ascii BEL character to the
+standard error output) after each non-duplicate response is received.
+This is disabled for flood pings as it would probably cause temporary
+insanity.
 .It Fl c Ar count
 Stop after sending (and waiting the specified delay to receive)
 .Ar count
diff -r a49c515b736b -r f0dde81278a6 sbin/ping/ping.c
--- a/sbin/ping/ping.c  Sat Jun 19 18:50:28 1999 +0000
+++ b/sbin/ping/ping.c  Sat Jun 19 19:15:22 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ping.c,v 1.48 1999/04/17 01:17:15 mjl Exp $    */
+/*     $NetBSD: ping.c,v 1.49 1999/06/19 19:15:22 sommerfeld Exp $     */
 
 /*
  * Copyright (c) 1989, 1993
@@ -62,7 +62,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ping.c,v 1.48 1999/04/17 01:17:15 mjl Exp $");
+__RCSID("$NetBSD: ping.c,v 1.49 1999/06/19 19:15:22 sommerfeld Exp $");
 #endif
 
 #include <stdio.h>
@@ -121,6 +121,7 @@
 #define F_ONCE         0x1000          /* exit(0) after receiving 1 reply */
 #define F_MCAST                0x2000          /* multicast target */
 #define F_MCAST_NOLOOP 0x4000          /* no multicast loopback */
+#define F_AUDIBLE      0x8000          /* audible output */
 
 
 /* MAX_DUP_CHK is the number of bits in received table, the
@@ -245,8 +246,11 @@
        __progname = argv[0];
 #endif
        while ((c = getopt(argc, argv,
-                          "c:dDfg:h:i:I:l:Lnop:PqQrRs:t:T:vw:")) != -1) {
+                          "ac:dDfg:h:i:I:l:Lnop:PqQrRs:t:T:vw:")) != -1) {
                switch (c) {
+               case 'a':
+                       pingflags |= F_AUDIBLE;
+                       break;
                case 'c':
                        npackets = strtol(optarg, &p, 0);
                        if (*p != '\0' || npackets <= 0)
@@ -359,6 +363,9 @@
 #endif
        sec_to_timeval(interval, &interval_tv);
 
+       if ((pingflags & (F_AUDIBLE|F_FLOOD)) == (F_AUDIBLE|F_FLOOD))
+               warnx("Sorry, no audible output for flood pings");
+
        if (npackets != 0) {
                npackets += preload;
        } else {
@@ -790,6 +797,13 @@
        (void)printf(" ttl=%d", ttl);
        if (pingflags & F_TIMING)
                (void)printf(" time=%.3f ms", triptime*1000.0);
+
+       /*
+        * Send beep to stderr, since that's more likely than stdout
+        * to go to a terminal..
+        */
+       if (pingflags & F_AUDIBLE && !dupflag)
+               (void)fprintf(stderr,"\a");
 }
 
 



Home | Main Index | Thread Index | Old Index