Module Name: src Committed By: christos Date: Fri Apr 24 00:42:56 UTC 2015
Modified Files: src/sbin/ping6: ping6.8 ping6.c Log Message: Add the once -o option like ping To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sbin/ping6/ping6.8 cvs rdiff -u -r1.85 -r1.86 src/sbin/ping6/ping6.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/ping6/ping6.8 diff -u src/sbin/ping6/ping6.8:1.28 src/sbin/ping6/ping6.8:1.29 --- src/sbin/ping6/ping6.8:1.28 Sun Apr 8 18:00:37 2012 +++ src/sbin/ping6/ping6.8 Thu Apr 23 20:42:56 2015 @@ -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 i 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 Index: src/sbin/ping6/ping6.c diff -u src/sbin/ping6/ping6.c:1.85 src/sbin/ping6/ping6.c:1.86 --- src/sbin/ping6/ping6.c:1.85 Tue Sep 16 21:00:41 2014 +++ src/sbin/ping6/ping6.c Thu Apr 23 20:42:56 2015 @@ -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 ( #else #include <sys/cdefs.h> #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);