diff --git a/sbin/ping6/ping6.8 b/sbin/ping6/ping6.8 index b73c411e00a0..a8d082965622 100644 --- a/sbin/ping6/ping6.8 +++ b/sbin/ping6/ping6.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: ping6.8,v 1.28 2012/04/08 22:00:37 wiz Exp $ +.\" $NetBSD: ping6.8,v 1.29 2015/04/24 00:42:56 christos Exp $ .\" $KAME: ping6.8,v 1.57 2002/05/26 13:18:25 itojun Exp $ .\" .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -28,7 +28,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd May 18, 2006 +.Dd April 23, 2015 .Dt PING6 8 .Os .Sh NAME @@ -39,7 +39,7 @@ packets to network hosts .Sh SYNOPSIS .Nm ping6 .\" without IPsec, or new IPsec -.Op Fl dfHmnNqRtvwW +.Op Fl dfHmnNoqRtvwW .\" old IPsec .\" .Op Fl AdEfnNqRtvwW .Op Fl a Ar addrtype @@ -193,6 +193,8 @@ Since node information multicast group is a link-local multicast group, outgoing interface needs to be specified by .Fl I option. +.It Fl o +Exit successfully after receiving one reply packet. .It Fl p Ar pattern You may specify up to 16 .Dq pad diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index 588bac77d3fd..bfa5d2285353 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -1,4 +1,4 @@ -/* $NetBSD: ping6.c,v 1.85 2014/09/17 01:00:41 ozaki-r Exp $ */ +/* $NetBSD: ping6.c,v 1.86 2015/04/24 00:42:56 christos Exp $ */ /* $KAME: ping6.c,v 1.164 2002/11/16 14:05:37 itojun Exp $ */ /* @@ -77,7 +77,7 @@ static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93"; #else #include #ifndef lint -__RCSID("$NetBSD: ping6.c,v 1.85 2014/09/17 01:00:41 ozaki-r Exp $"); +__RCSID("$NetBSD: ping6.c,v 1.86 2015/04/24 00:42:56 christos Exp $"); #endif #endif @@ -189,6 +189,7 @@ struct tv32 { #define F_NIGROUP 0x40000 #define F_SUPTYPES 0x80000 #define F_NOMINMTU 0x100000 +#define F_ONCE 0x200000 #define F_NOUSERDATA (F_NODEADDR | F_FQDN | F_FQDNOLD | F_SUPTYPES) static u_int options; @@ -327,7 +328,7 @@ main(int argc, char *argv[]) #endif /*IPSEC_POLICY_IPSEC*/ #endif while ((ch = getopt(argc, argv, - "a:b:c:dfHg:h:I:i:l:mnNp:qRS:s:tvwW" ADDOPTS)) != -1) { + "a:b:c:dfHg:h:I:i:l:mnNop:qRS:s:tvwW" ADDOPTS)) != -1) { #undef ADDOPTS switch (ch) { case 'a': @@ -468,6 +469,9 @@ main(int argc, char *argv[]) case 'N': options |= F_NIGROUP; break; + case 'o': + options |= F_ONCE; + break; case 'p': /* fill buffer with user pattern */ options |= F_PINGFILLED; fill((char *)datap, optarg); @@ -1102,6 +1106,8 @@ main(int argc, char *argv[]) } if (npackets && nreceived >= npackets) break; + if (nreceived != 0 && (options & F_ONCE)) + break; } summary(); exit(nreceived == 0);