summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authordd <dd@FreeBSD.org>2007-11-20 01:58:34 +0000
committerdd <dd@FreeBSD.org>2007-11-20 01:58:34 +0000
commitef0bd1833e12eed047d40a562663a0d7122ced7a (patch)
tree53b113f05efe961b274dd519be1ad1b1ed6d3303 /sbin
parent2693df297eb672ceb5db3dd007634f56d0f05222 (diff)
downloadFreeBSD-src-ef0bd1833e12eed047d40a562663a0d7122ced7a.zip
FreeBSD-src-ef0bd1833e12eed047d40a562663a0d7122ced7a.tar.gz
Add -o option to match ping(8)
Reviewed by: dwmalone, maxim MFC after: 2 weeks
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ping6/ping6.86
-rw-r--r--sbin/ping6/ping6.c11
2 files changed, 12 insertions, 5 deletions
diff --git a/sbin/ping6/ping6.8 b/sbin/ping6/ping6.8
index 89a8168..fc59591 100644
--- a/sbin/ping6/ping6.8
+++ b/sbin/ping6/ping6.8
@@ -29,7 +29,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 17, 1998
+.Dd November 15, 2007
.Dt PING6 8
.Os
.Sh NAME
@@ -40,7 +40,7 @@ packets to network hosts
.Sh SYNOPSIS
.Nm
.\" without ipsec, or new ipsec
-.Op Fl dfHmnNqtvwW
+.Op Fl dfHmnNoqtvwW
.\" old ipsec
.\" .Op Fl AdEfmnNqRtvwW
.Bk -words
@@ -225,6 +225,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 a7ab9a1..4291057 100644
--- a/sbin/ping6/ping6.c
+++ b/sbin/ping6/ping6.c
@@ -188,6 +188,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)
u_int options;
@@ -344,7 +345,7 @@ main(argc, argv)
#endif /*IPSEC_POLICY_IPSEC*/
#endif
while ((ch = getopt(argc, argv,
- "a:b:c:dfHg:h:I:i:l:mnNp:qS:s:tvwW" ADDOPTS)) != -1) {
+ "a:b:c:dfHg:h:I:i:l:mnNop:qS:s:tvwW" ADDOPTS)) != -1) {
#undef ADDOPTS
switch (ch) {
case 'a':
@@ -485,6 +486,9 @@ main(argc, 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);
@@ -1164,7 +1168,8 @@ main(argc, argv)
*/
pr_pack(packet, cc, &m);
}
- if (npackets && nreceived >= npackets)
+ if (((options & F_ONCE) != 0 && nreceived > 0) ||
+ (npackets > 0 && nreceived >= npackets))
break;
}
summary();
@@ -2763,7 +2768,7 @@ usage()
#ifdef IPV6_USE_MIN_MTU
"m"
#endif
- "nNqtvwW] "
+ "nNoqtvwW] "
"[-a addrtype] [-b bufsiz] [-c count] [-g gateway]\n"
" [-h hoplimit] [-I interface] [-i wait] [-l preload]"
#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
OpenPOWER on IntegriCloud