Reviewed by: Gary Jennejohn <gj@freebsd.org>

Submitted by:	Bruce Murphy <packrat@iinet.net.au>

Add '-a' audible flag, so terminal will beep upon receipt of a reply
packet.  Useful for debugging ethernet runs, among other things.
This commit is contained in:
Daniel O'Callaghan 1997-02-08 01:43:56 +00:00
parent b7a652ab84
commit 772dfa7231
2 changed files with 12 additions and 3 deletions

View File

@ -42,7 +42,7 @@
packets to network hosts packets to network hosts
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm ping .Nm ping
.Op Fl dfnqrvLRQ .Op Fl adfnqrvLRQ
.Op Fl c Ar count .Op Fl c Ar count
.Op Fl i Ar wait .Op Fl i Ar wait
.Op Fl I Ar interface .Op Fl I Ar interface
@ -70,6 +70,9 @@ and then an arbitrary number of ``pad'' bytes used to fill out the
packet. packet.
The options are as follows: The options are as follows:
.Bl -tag -width Ds .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 .It Fl c Ar count
Stop after sending (and receiving) Stop after sending (and receiving)
.Ar count .Ar count

View File

@ -109,6 +109,7 @@ int options;
#define F_NOLOOP 0x0400 #define F_NOLOOP 0x0400
#define F_MTTL 0x0800 #define F_MTTL 0x0800
#define F_MIF 0x1000 #define F_MIF 0x1000
#define F_AUDIBLE 0x2000
/* /*
* MAX_DUP_CHK is the number of bits in received table, i.e. the maximum * MAX_DUP_CHK is the number of bits in received table, i.e. the maximum
@ -185,8 +186,11 @@ main(argc, argv)
preload = 0; preload = 0;
datap = &outpack[8 + sizeof(struct timeval)]; 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) { switch(ch) {
case 'a':
options |= F_AUDIBLE;
break;
case 'c': case 'c':
npackets = atoi(optarg); npackets = atoi(optarg);
if (npackets <= 0) { if (npackets <= 0) {
@ -619,6 +623,8 @@ pr_pack(buf, cc, from)
(void)printf(" time=%.3f ms", triptime); (void)printf(" time=%.3f ms", triptime);
if (dupflag) if (dupflag)
(void)printf(" (DUP!)"); (void)printf(" (DUP!)");
if (options & F_AUDIBLE)
(void)printf("\a");
/* check the data */ /* check the data */
cp = (u_char*)&icp->icmp_data[8]; cp = (u_char*)&icp->icmp_data[8];
dp = &outpack[8 + sizeof(struct timeval)]; dp = &outpack[8 + sizeof(struct timeval)];
@ -1134,6 +1140,6 @@ fill(bp, patp)
usage() usage()
{ {
(void)fprintf(stderr, (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); exit(1);
} }