diff options
author | phk <phk@FreeBSD.org> | 2001-05-24 09:17:52 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2001-05-24 09:17:52 +0000 |
commit | f77345ea800c2b51c9688ef79af6b5826eb2712e (patch) | |
tree | 8cb3f23c7687335518af5fef193b04a543065fd4 /sbin/ping/ping.c | |
parent | 4474a53d43ac9275a9eb0a2fda8efa7f9c18fe0d (diff) | |
download | FreeBSD-src-f77345ea800c2b51c9688ef79af6b5826eb2712e.zip FreeBSD-src-f77345ea800c2b51c9688ef79af6b5826eb2712e.tar.gz |
Add a -A option to ping which beeps when packets are lost.
PR: 11818
Submitted by: Marc Evans marc@destek.net
Diffstat (limited to 'sbin/ping/ping.c')
-rw-r--r-- | sbin/ping/ping.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 3b573c6..1209dc8 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -135,6 +135,7 @@ int options; #endif /*IPSEC_POLICY_IPSEC*/ #endif /*IPSEC*/ #define F_TTL 0x8000 +#define F_MISSED 0x10000 /* * MAX_DUP_CHK is the number of bits in received table, i.e. the maximum @@ -150,6 +151,7 @@ int datalen = DEFDATALEN; int s; /* socket file descriptor */ u_char outpack[MAXPACKET]; char BSPACE = '\b'; /* characters written for flood */ +char BBELL = '\a'; /* characters written for MISSED and AUDIBLE */ char DOT = '.'; char *hostname; char *shostname; @@ -236,7 +238,7 @@ main(argc, argv) datap = &outpack[8 + PHDR_LEN]; while ((ch = getopt(argc, argv, - "I:LQRS:T:c:adfi:l:m:np:qrs:t:v" + "AI:LQRS:T:c:adfi:l:m:np:qrs:t:v" #ifdef IPSEC #ifdef IPSEC_POLICY_IPSEC "P:" @@ -245,6 +247,9 @@ main(argc, argv) )) != -1) { switch(ch) { + case 'A': + options |= F_MISSED; + break; case 'a': options |= F_AUDIBLE; break; @@ -695,6 +700,9 @@ main(argc, argv) intvl.tv_sec = MAXWAIT; } (void)gettimeofday(&last, NULL); + + if (ntransmitted != nreceived+1 && options & F_MISSED) + (void)write(STDOUT_FILENO, &BBELL, 1); } } finish(); @@ -855,7 +863,7 @@ pr_pack(buf, cc, from, tv) if (dupflag) (void)printf(" (DUP!)"); if (options & F_AUDIBLE) - (void)printf("\a"); + (void)write(STDOUT_FILENO, &BBELL, 1); /* check the data */ cp = (u_char*)&icp->icmp_data[PHDR_LEN]; dp = &outpack[8 + PHDR_LEN]; |