Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/ping6 Add the once -o option like ping



details:   https://anonhg.NetBSD.org/src/rev/4aba826f0846
branches:  trunk
changeset: 337700:4aba826f0846
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Apr 24 00:42:56 2015 +0000

description:
Add the once -o option like ping

diffstat:

 sbin/ping6/ping6.8 |   8 +++++---
 sbin/ping6/ping6.c |  12 +++++++++---
 2 files changed, 14 insertions(+), 6 deletions(-)

diffs (90 lines):

diff -r 4daa60975a98 -r 4aba826f0846 sbin/ping6/ping6.8
--- a/sbin/ping6/ping6.8        Fri Apr 24 00:31:04 2015 +0000
+++ b/sbin/ping6/ping6.8        Fri Apr 24 00:42:56 2015 +0000
@@ -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 @@
 .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 @@
 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 -r 4daa60975a98 -r 4aba826f0846 sbin/ping6/ping6.c
--- a/sbin/ping6/ping6.c        Fri Apr 24 00:31:04 2015 +0000
+++ b/sbin/ping6/ping6.c        Fri Apr 24 00:42:56 2015 +0000
@@ -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 @@
 #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 @@
 #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 @@
 #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 @@
                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 @@
                }
                if (npackets && nreceived >= npackets)
                        break;
+               if (nreceived != 0 && (options & F_ONCE))
+                       break;
        }
        summary();
        exit(nreceived == 0);



Home | Main Index | Thread Index | Old Index