summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatteo <matteo@FreeBSD.org>2008-08-27 15:01:23 +0000
committermatteo <matteo@FreeBSD.org>2008-08-27 15:01:23 +0000
commit470dc620809fc044c4478d701334cccd1de05e62 (patch)
treecd9da65cb630e44b45e43defefe5d04dc7d6f731
parent777f0de1c2519cbce4b14c92c2e3e924280ff361 (diff)
downloadFreeBSD-src-470dc620809fc044c4478d701334cccd1de05e62.zip
FreeBSD-src-470dc620809fc044c4478d701334cccd1de05e62.tar.gz
Implement -R support, similar to ping(8)'s -A.
ping(8)'s -a was mapped to -e, but -E was already taken in ping6 (old option) so rename -e to -r. Now: ping -a => ping6 -r ping -A => ping6 -R MFC after: 2 days
-rw-r--r--sbin/ping6/ping6.826
-rw-r--r--sbin/ping6/ping6.c22
2 files changed, 34 insertions, 14 deletions
diff --git a/sbin/ping6/ping6.8 b/sbin/ping6/ping6.8
index d15c76c..3897a90 100644
--- a/sbin/ping6/ping6.8
+++ b/sbin/ping6/ping6.8
@@ -29,7 +29,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 26, 2008
+.Dd August 27, 2008
.Dt PING6 8
.Os
.Sh NAME
@@ -40,7 +40,7 @@ packets to network hosts
.Sh SYNOPSIS
.Nm
.\" without ipsec, or new ipsec
-.Op Fl defHmnNoqtvwW
+.Op Fl dfHmnNoqrRtvwW
.\" old ipsec
.\" .Op Fl AdEfmnNqRtvwW
.Bk -words
@@ -148,12 +148,6 @@ option on the socket being used.
.\" .It Fl E
.\" Enables transport-mode IPsec encapsulated security payload
.\" (experimental).
-.It Fl e
-Audible.
-Include a bell
-.Tn ( ASCII
-0x07)
-character in the output when any packet is received.
.It Fl f
Flood ping.
Outputs packets as fast as they come back or one hundred times per second,
@@ -250,6 +244,22 @@ specifies IPsec policy to be used for the probe.
Quiet output.
Nothing is displayed except the summary lines at startup time and
when finished.
+.It Fl r
+Audible.
+Include a bell
+.Tn ( ASCII
+0x07)
+character in the output when any packet is received.
+.It Fl R
+Audible.
+Output a bell
+.Tn ( ASCII
+0x07)
+character when no packet is received before the next packet
+is transmitted.
+To cater for round-trip times that are longer than the interval
+between transmissions, further missing packets cause a bell only
+if the maximum number of unreceived packets has increased.
.It Fl S Ar sourceaddr
Specifies the source address of request packets.
The source address must be one of the unicast addresses of the sending node,
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c
index b29d18e..f7dba27 100644
--- a/sbin/ping6/ping6.c
+++ b/sbin/ping6/ping6.c
@@ -190,6 +190,7 @@ struct tv32 {
#define F_NOMINMTU 0x100000
#define F_ONCE 0x200000
#define F_AUDIBLE 0x400000
+#define F_MISSED 0x800000
#define F_NOUSERDATA (F_NODEADDR | F_FQDN | F_FQDNOLD | F_SUPTYPES)
u_int options;
@@ -225,6 +226,7 @@ int hoplimit = -1; /* hoplimit */
int pathmtu = 0; /* path MTU for the destination. 0 = unspec. */
/* counters */
+long nmissedmax; /* max value of ntransmitted - nreceived - 1 */
long npackets; /* max packets to transmit */
long nreceived; /* # of packets we got back */
long nrepeats; /* number of duplicates */
@@ -347,7 +349,7 @@ main(argc, argv)
#endif /*IPSEC_POLICY_IPSEC*/
#endif
while ((ch = getopt(argc, argv,
- "a:b:c:defHg:h:I:i:l:mnNop:qS:s:tvwW" ADDOPTS)) != -1) {
+ "a:b:c:dfHg:h:I:i:l:mnNop:qrRS:s:tvwW" ADDOPTS)) != -1) {
#undef ADDOPTS
switch (ch) {
case 'a':
@@ -416,9 +418,6 @@ main(argc, argv)
case 'd':
options |= F_SO_DEBUG;
break;
- case 'e':
- options |= F_AUDIBLE;
- break;
case 'f':
if (getuid()) {
errno = EPERM;
@@ -501,6 +500,12 @@ main(argc, argv)
case 'q':
options |= F_QUIET;
break;
+ case 'r':
+ options |= F_AUDIBLE;
+ break;
+ case 'R':
+ options |= F_MISSED;
+ break;
case 'S':
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_flags = AI_NUMERICHOST; /* allow hostname? */
@@ -1179,6 +1184,11 @@ main(argc, argv)
if (((options & F_ONCE) != 0 && nreceived > 0) ||
(npackets > 0 && nreceived >= npackets))
break;
+ if (ntransmitted - nreceived - 1 > nmissedmax) {
+ nmissedmax = ntransmitted - nreceived - 1;
+ if (options & F_MISSED)
+ (void)write(STDOUT_FILENO, &BBELL, 1);
+ }
}
summary();
exit(nreceived == 0 ? 2 : 0);
@@ -2770,7 +2780,7 @@ usage()
"A"
#endif
"usage: ping6 [-"
- "de"
+ "d"
#if defined(IPSEC) && !defined(IPSEC_POLICY_IPSEC)
"E"
#endif
@@ -2778,7 +2788,7 @@ usage()
#ifdef IPV6_USE_MIN_MTU
"m"
#endif
- "nNoqtvwW] "
+ "nNoqrRtvwW] "
"[-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