Add an -o option to exit after receiving one reply. This can be used
to test whether a link is live. PR: 38573 Submitted by: David Taylor <davidt@yadt.co.uk> Obtained from: NetBSD
This commit is contained in:
parent
92dbb82a47
commit
8025c44b00
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=104339
@ -32,7 +32,7 @@
|
|||||||
.\" @(#)ping.8 8.2 (Berkeley) 12/11/93
|
.\" @(#)ping.8 8.2 (Berkeley) 12/11/93
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd September 25, 2001
|
.Dd October 2, 2002
|
||||||
.Dt PING 8
|
.Dt PING 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -42,7 +42,7 @@
|
|||||||
packets to network hosts
|
packets to network hosts
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl AQRadfnqrv
|
.Op Fl AQRadfnoqrv
|
||||||
.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
|
||||||
@ -160,6 +160,8 @@ This flag only applies if the ping destination is a multicast address.
|
|||||||
.It Fl n
|
.It Fl n
|
||||||
Numeric output only.
|
Numeric output only.
|
||||||
No attempt will be made to lookup symbolic names for host addresses.
|
No attempt will be made to lookup symbolic names for host addresses.
|
||||||
|
.It Fl o
|
||||||
|
Exit successfully after receiving one reply packet.
|
||||||
.It Fl p Ar pattern
|
.It Fl p Ar pattern
|
||||||
You may specify up to 16
|
You may specify up to 16
|
||||||
.Dq pad
|
.Dq pad
|
||||||
|
@ -137,6 +137,7 @@ int options;
|
|||||||
#endif /*IPSEC*/
|
#endif /*IPSEC*/
|
||||||
#define F_TTL 0x8000
|
#define F_TTL 0x8000
|
||||||
#define F_MISSED 0x10000
|
#define F_MISSED 0x10000
|
||||||
|
#define F_ONCE 0x20000
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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
|
||||||
@ -242,7 +243,7 @@ main(argc, argv)
|
|||||||
|
|
||||||
datap = &outpack[MINICMPLEN + PHDR_LEN];
|
datap = &outpack[MINICMPLEN + PHDR_LEN];
|
||||||
while ((ch = getopt(argc, argv,
|
while ((ch = getopt(argc, argv,
|
||||||
"AI:LQRS:T:c:adfi:l:m:np:qrs:t:v"
|
"AI:LQRS:T:c:adfi:l:m:nop:qrs:t:v"
|
||||||
#ifdef IPSEC
|
#ifdef IPSEC
|
||||||
#ifdef IPSEC_POLICY_IPSEC
|
#ifdef IPSEC_POLICY_IPSEC
|
||||||
"P:"
|
"P:"
|
||||||
@ -320,6 +321,9 @@ main(argc, argv)
|
|||||||
case 'n':
|
case 'n':
|
||||||
options |= F_NUMERIC;
|
options |= F_NUMERIC;
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
options |= F_ONCE;
|
||||||
|
break;
|
||||||
case 'p': /* fill buffer with user pattern */
|
case 'p': /* fill buffer with user pattern */
|
||||||
options |= F_PINGFILLED;
|
options |= F_PINGFILLED;
|
||||||
fill((char *)datap, optarg);
|
fill((char *)datap, optarg);
|
||||||
@ -696,7 +700,8 @@ main(argc, argv)
|
|||||||
t = &now;
|
t = &now;
|
||||||
}
|
}
|
||||||
pr_pack((char *)packet, cc, &from, t);
|
pr_pack((char *)packet, cc, &from, t);
|
||||||
if (npackets && nreceived >= npackets)
|
if (options & F_ONCE && nreceived ||
|
||||||
|
npackets && nreceived >= npackets)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (n == 0 || options & F_FLOOD) {
|
if (n == 0 || options & F_FLOOD) {
|
||||||
@ -1441,7 +1446,7 @@ static void
|
|||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
(void)fprintf(stderr, "%s\n%s\n%s\n",
|
(void)fprintf(stderr, "%s\n%s\n%s\n",
|
||||||
"usage: ping [-AQRadfnqrv] [-c count] [-i wait] [-l preload] [-m ttl]",
|
"usage: ping [-AQRadfnoqrv] [-c count] [-i wait] [-l preload] [-m ttl]",
|
||||||
" [-p pattern] "
|
" [-p pattern] "
|
||||||
#ifdef IPSEC
|
#ifdef IPSEC
|
||||||
#ifdef IPSEC_POLICY_IPSEC
|
#ifdef IPSEC_POLICY_IPSEC
|
||||||
|
Loading…
Reference in New Issue
Block a user