From 772dfa72317e96ba35345ee702925b52232f98c2 Mon Sep 17 00:00:00 2001 From: Daniel O'Callaghan Date: Sat, 8 Feb 1997 01:43:56 +0000 Subject: [PATCH] Reviewed by: Gary Jennejohn Submitted by: Bruce Murphy Add '-a' audible flag, so terminal will beep upon receipt of a reply packet. Useful for debugging ethernet runs, among other things. --- sbin/ping/ping.8 | 5 ++++- sbin/ping/ping.c | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/sbin/ping/ping.8 b/sbin/ping/ping.8 index 538a0450da48..1d9a493a195c 100644 --- a/sbin/ping/ping.8 +++ b/sbin/ping/ping.8 @@ -42,7 +42,7 @@ packets to network hosts .Sh SYNOPSIS .Nm ping -.Op Fl dfnqrvLRQ +.Op Fl adfnqrvLRQ .Op Fl c Ar count .Op Fl i Ar wait .Op Fl I Ar interface @@ -70,6 +70,9 @@ and then an arbitrary number of ``pad'' bytes used to fill out the packet. The options are as follows: .Bl -tag -width Ds +.It Fl a +Audible. Include a bell (ASCII 0x07) character in the output when any packet +is received. This option is ignored if other format options are present. .It Fl c Ar count Stop after sending (and receiving) .Ar count diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index bfbf254236c9..589ba4b98e94 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -109,6 +109,7 @@ int options; #define F_NOLOOP 0x0400 #define F_MTTL 0x0800 #define F_MIF 0x1000 +#define F_AUDIBLE 0x2000 /* * MAX_DUP_CHK is the number of bits in received table, i.e. the maximum @@ -185,8 +186,11 @@ main(argc, argv) preload = 0; datap = &outpack[8 + sizeof(struct timeval)]; - while ((ch = getopt(argc, argv, "I:LQRT:c:dfh:i:l:np:qrs:v")) != EOF) + while ((ch = getopt(argc, argv, "I:LQRT:c:adfh:i:l:np:qrs:v")) != EOF) switch(ch) { + case 'a': + options |= F_AUDIBLE; + break; case 'c': npackets = atoi(optarg); if (npackets <= 0) { @@ -619,6 +623,8 @@ pr_pack(buf, cc, from) (void)printf(" time=%.3f ms", triptime); if (dupflag) (void)printf(" (DUP!)"); + if (options & F_AUDIBLE) + (void)printf("\a"); /* check the data */ cp = (u_char*)&icp->icmp_data[8]; dp = &outpack[8 + sizeof(struct timeval)]; @@ -1134,6 +1140,6 @@ fill(bp, patp) usage() { (void)fprintf(stderr, - "usage: ping [-LQRdfnqrv] [-c count] [-i wait] [-I interface]\n\t[-l preload] [-p pattern] [-s packetsize] [-T ttl] host\n"); + "usage: ping [-LQRadfnqrv] [-c count] [-i wait] [-I interface]\n\t[-l preload] [-p pattern] [-s packetsize] [-T ttl] host\n"); exit(1); }