Add a -A option to ping which beeps when packets are lost.
PR: 11818 Submitted by: Marc Evans marc@destek.net
This commit is contained in:
parent
5e4440632e
commit
ca517ad854
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=77119
@ -42,7 +42,7 @@
|
|||||||
packets to network hosts
|
packets to network hosts
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl QRadfnqrv
|
.Op Fl AQRadfnqrv
|
||||||
.Op Fl c Ar count
|
.Op Fl c Ar count
|
||||||
.Op Fl i Ar wait
|
.Op Fl i Ar wait
|
||||||
.Op Fl l Ar preload
|
.Op Fl l Ar preload
|
||||||
@ -79,6 +79,12 @@ and then an arbitrary number of
|
|||||||
.Dq pad
|
.Dq pad
|
||||||
bytes used to fill out the packet. The options are as follows:
|
bytes used to fill out the packet. The options are as follows:
|
||||||
.Bl -tag -width indent
|
.Bl -tag -width indent
|
||||||
|
.It Fl A
|
||||||
|
Audible.
|
||||||
|
Include a bell
|
||||||
|
.Pq ASCII 0x07
|
||||||
|
character in the output when no packet is received before the next packet
|
||||||
|
is transmitted.
|
||||||
.It Fl a
|
.It Fl a
|
||||||
Audible.
|
Audible.
|
||||||
Include a bell
|
Include a bell
|
||||||
|
@ -135,6 +135,7 @@ int options;
|
|||||||
#endif /*IPSEC_POLICY_IPSEC*/
|
#endif /*IPSEC_POLICY_IPSEC*/
|
||||||
#endif /*IPSEC*/
|
#endif /*IPSEC*/
|
||||||
#define F_TTL 0x8000
|
#define F_TTL 0x8000
|
||||||
|
#define F_MISSED 0x10000
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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
|
||||||
@ -150,6 +151,7 @@ int datalen = DEFDATALEN;
|
|||||||
int s; /* socket file descriptor */
|
int s; /* socket file descriptor */
|
||||||
u_char outpack[MAXPACKET];
|
u_char outpack[MAXPACKET];
|
||||||
char BSPACE = '\b'; /* characters written for flood */
|
char BSPACE = '\b'; /* characters written for flood */
|
||||||
|
char BBELL = '\a'; /* characters written for MISSED and AUDIBLE */
|
||||||
char DOT = '.';
|
char DOT = '.';
|
||||||
char *hostname;
|
char *hostname;
|
||||||
char *shostname;
|
char *shostname;
|
||||||
@ -236,7 +238,7 @@ main(argc, argv)
|
|||||||
|
|
||||||
datap = &outpack[8 + PHDR_LEN];
|
datap = &outpack[8 + PHDR_LEN];
|
||||||
while ((ch = getopt(argc, argv,
|
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
|
||||||
#ifdef IPSEC_POLICY_IPSEC
|
#ifdef IPSEC_POLICY_IPSEC
|
||||||
"P:"
|
"P:"
|
||||||
@ -245,6 +247,9 @@ main(argc, argv)
|
|||||||
)) != -1)
|
)) != -1)
|
||||||
{
|
{
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
|
case 'A':
|
||||||
|
options |= F_MISSED;
|
||||||
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
options |= F_AUDIBLE;
|
options |= F_AUDIBLE;
|
||||||
break;
|
break;
|
||||||
@ -695,6 +700,9 @@ main(argc, argv)
|
|||||||
intvl.tv_sec = MAXWAIT;
|
intvl.tv_sec = MAXWAIT;
|
||||||
}
|
}
|
||||||
(void)gettimeofday(&last, NULL);
|
(void)gettimeofday(&last, NULL);
|
||||||
|
|
||||||
|
if (ntransmitted != nreceived+1 && options & F_MISSED)
|
||||||
|
(void)write(STDOUT_FILENO, &BBELL, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
@ -855,7 +863,7 @@ pr_pack(buf, cc, from, tv)
|
|||||||
if (dupflag)
|
if (dupflag)
|
||||||
(void)printf(" (DUP!)");
|
(void)printf(" (DUP!)");
|
||||||
if (options & F_AUDIBLE)
|
if (options & F_AUDIBLE)
|
||||||
(void)printf("\a");
|
(void)write(STDOUT_FILENO, &BBELL, 1);
|
||||||
/* check the data */
|
/* check the data */
|
||||||
cp = (u_char*)&icp->icmp_data[PHDR_LEN];
|
cp = (u_char*)&icp->icmp_data[PHDR_LEN];
|
||||||
dp = &outpack[8 + PHDR_LEN];
|
dp = &outpack[8 + PHDR_LEN];
|
||||||
|
Loading…
Reference in New Issue
Block a user