ping6: Rename options for better consistency with ping

Now equivalent options have the same flags, and nonequivalent options have
different flags.  This is a prelude to merging the two commands.

Submitted by:	Ján Sučan <sucanjan@gmail.com>
MFC:		Never
Sponsored by:	Google LLC (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21345
This commit is contained in:
Alan Somers 2019-08-23 15:22:20 +00:00
parent 5469a751a2
commit 208ae7b7b4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=351423
6 changed files with 69 additions and 64 deletions

View file

@ -26,6 +26,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW:
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
20190823:
Several of ping6's options have been renamed for better consistency
with ping. If you use any of -ARWXaghmrtwx, you must update your
scripts. See ping6(8) for details.
20190727:
The vfs.fusefs.sync_unmount and vfs.fusefs.init_backgrounded sysctls
and the "-o sync_unmount" and "-o init_backgrounded" mount options have

View file

@ -29,7 +29,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd September 22, 2014
.Dd August 22, 2019
.Dt PING6 8
.Os
.Sh NAME
@ -40,23 +40,17 @@ packets to network hosts
.Sh SYNOPSIS
.Nm
.\" without ipsec, or new ipsec
.Op Fl DdfHmnNoqrRtvwW
.Op Fl aAdDfHnNoOquvyY
.\" old ipsec
.\" .Op Fl ADdEfmnNqRtvwW
.Bk -words
.Op Fl a Ar addrtype
.Ek
.Bk -words
.Op Fl b Ar bufsiz
.Ek
.Bk -words
.Op Fl c Ar count
.Ek
.Bk -words
.Op Fl g Ar gateway
.Ek
.Bk -words
.Op Fl h Ar hoplimit
.Op Fl e Ar gateway
.Ek
.Bk -words
.Op Fl I Ar interface
@ -65,15 +59,15 @@ packets to network hosts
.Op Fl i Ar wait
.Ek
.Bk -words
.Op Fl x Ar waittime
.Ek
.Bk -words
.Op Fl X Ar timeout
.Op Fl k Ar addrtype
.Ek
.Bk -words
.Op Fl l Ar preload
.Ek
.Bk -words
.Op Fl m Ar hoplimit
.Ek
.Bk -words
.\" new ipsec
.Op Fl P Ar policy
.Ek
@ -87,6 +81,12 @@ packets to network hosts
.Op Fl s Ar packetsize
.Ek
.Bk -words
.Op Fl t Ar timeout
.Ek
.Bk -words
.Op Fl W Ar waittime
.Ek
.Bk -words
.Op Ar hops ...
.Ek
.Bk -words
@ -110,10 +110,10 @@ header formatted as documented in RFC2463.
The options are as follows:
.Bl -tag -width Ds
.\" old ipsec
.\" .It Fl A
.\" .It Fl Z
.\" Enables transport-mode IPsec authentication header
.\" (experimental).
.It Fl a Ar addrtype
.It Fl k Ar addrtype
Generate ICMPv6 Node Information Node Addresses query, rather than echo-request.
.Ar addrtype
must be a string constructed of the following characters.
@ -172,7 +172,7 @@ Only the super-user may use this option.
.Bf -emphasis
This can be very hard on a network and should be used with caution.
.Ef
.It Fl g Ar gateway
.It Fl e Ar gateway
Specifies to use
.Ar gateway
as the next hop to the destination.
@ -182,7 +182,7 @@ Specifies to try reverse-lookup of IPv6 addresses.
The
.Nm
utility does not try reverse-lookup unless the option is specified.
.It Fl h Ar hoplimit
.It Fl m Ar hoplimit
Set the IPv6 hoplimit.
.It Fl I Ar interface
Source packets with the given interface address.
@ -197,12 +197,12 @@ The default is to wait for one second between each packet.
This option is incompatible with the
.Fl f
option.
.It Fl x Ar waittime
.It Fl W Ar waittime
Time in milliseconds to wait for a reply for each packet sent.
If a reply arrives later,
the packet is not printed as replied,
but considered as replied when calculating statistics.
.It Fl X Ar timeout
.It Fl t Ar timeout
Specify a timeout,
in seconds,
before ping exits regardless of how many packets have been received.
@ -214,12 +214,12 @@ is specified,
sends that many packets as fast as possible before falling into its normal
mode of behavior.
Only the super-user may use this option.
.It Fl m
.It Fl u
By default,
.Nm
asks the kernel to fragment packets to fit into the minimum IPv6 MTU.
The
.Fl m
.Fl u
option
will suppress the behavior in the following two levels:
when the option is specified once, the behavior will be disabled for
@ -270,13 +270,13 @@ 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
.It Fl a
Audible.
Include a bell
.Tn ( ASCII
0x07)
character in the output when any packet is received.
.It Fl R
.It Fl A
Audible.
Output a bell
.Tn ( ASCII
@ -301,12 +301,12 @@ header data.
You may need to specify
.Fl b
as well to extend socket buffer size.
.It Fl t
.It Fl O
Generate ICMPv6 Node Information supported query types query,
rather than echo-request.
.Fl s
has no effect if
.Fl t
.Fl O
is specified.
.It Fl v
Verbose output.
@ -314,20 +314,20 @@ Verbose output.
packets other than
.Tn ECHO_RESPONSE
that are received are listed.
.It Fl w
.It Fl y
Generate ICMPv6 Node Information DNS Name query, rather than echo-request.
.Fl s
has no effect if
.Fl w
.Fl y
is specified.
.It Fl W
.It Fl Y
Same as
.Fl w ,
.Fl y ,
but with old packet format based on 03 draft.
This option is present for backward compatibility.
.Fl s
has no effect if
.Fl w
.Fl y
is specified.
.It Ar hops
IPv6 addresses for intermediate nodes,

View file

@ -347,14 +347,14 @@ main(int argc, char *argv[])
#ifdef IPSEC_POLICY_IPSEC
#define ADDOPTS "P:"
#else
#define ADDOPTS "AE"
#define ADDOPTS "ZE"
#endif /*IPSEC_POLICY_IPSEC*/
#endif
while ((ch = getopt(argc, argv,
"a:b:c:DdfHg:h:I:i:l:mnNop:qrRS:s:tvwWx:X:" ADDOPTS)) != -1) {
"k:b:c:DdfHe:m:I:i:l:unNop:qaAS:s:OvyYW:t:" ADDOPTS)) != -1) {
#undef ADDOPTS
switch (ch) {
case 'a':
case 'k':
{
char *cp;
@ -431,13 +431,13 @@ main(int argc, char *argv[])
options |= F_FLOOD;
setbuf(stdout, (char *)NULL);
break;
case 'g':
case 'e':
gateway = optarg;
break;
case 'H':
options |= F_HOSTNAME;
break;
case 'h': /* hoplimit */
case 'm': /* hoplimit */
hoplimit = strtol(optarg, &e, 10);
if (*optarg == '\0' || *e != '\0')
errx(1, "illegal hoplimit %s", optarg);
@ -481,7 +481,7 @@ main(int argc, char *argv[])
if (preload < 0 || *optarg == '\0' || *e != '\0')
errx(1, "illegal preload value -- %s", optarg);
break;
case 'm':
case 'u':
#ifdef IPV6_USE_MIN_MTU
mflag++;
break;
@ -506,10 +506,10 @@ main(int argc, char *argv[])
case 'q':
options |= F_QUIET;
break;
case 'r':
case 'a':
options |= F_AUDIBLE;
break;
case 'R':
case 'A':
options |= F_MISSED;
break;
case 'S':
@ -543,22 +543,22 @@ main(int argc, char *argv[])
MAXDATALEN);
}
break;
case 't':
case 'O':
options &= ~F_NOUSERDATA;
options |= F_SUPTYPES;
break;
case 'v':
options |= F_VERBOSE;
break;
case 'w':
case 'y':
options &= ~F_NOUSERDATA;
options |= F_FQDN;
break;
case 'W':
case 'Y':
options &= ~F_NOUSERDATA;
options |= F_FQDNOLD;
break;
case 'x':
case 'W':
t = strtod(optarg, &e);
if (*e || e == optarg || t > (double)INT_MAX)
err(EX_USAGE, "invalid timing interval: `%s'",
@ -566,7 +566,7 @@ main(int argc, char *argv[])
options |= F_WAITTIME;
waittime = (int)t;
break;
case 'X':
case 't':
alarmtimeout = strtoul(optarg, &e, 0);
if ((alarmtimeout < 1) || (alarmtimeout == ULONG_MAX))
errx(EX_USAGE, "invalid timeout: `%s'",
@ -590,7 +590,7 @@ main(int argc, char *argv[])
errx(1, "invalid security policy");
break;
#else
case 'A':
case 'Z':
options |= F_AUTHHDR;
break;
case 'E':
@ -1835,7 +1835,7 @@ pr_exthdrs(struct msghdr *mhdr)
bufsize = CONTROLLEN - ((caddr_t)CMSG_DATA(cm) - (caddr_t)bufp);
if (bufsize <= 0)
continue;
continue;
switch (cm->cmsg_type) {
case IPV6_HOPOPTS:
printf(" HbH Options: ");
@ -2783,7 +2783,7 @@ nigroup(char *name, int nig_oldmcprefix)
}
if (valid != 1)
return NULL; /*XXX*/
if (nig_oldmcprefix) {
/* draft-ietf-ipngwg-icmp-name-lookup */
bcopy(digest, &in6.s6_addr[12], 4);
@ -2803,27 +2803,27 @@ usage(void)
{
(void)fprintf(stderr,
#if defined(IPSEC) && !defined(IPSEC_POLICY_IPSEC)
"A"
"Z"
#endif
"usage: ping6 [-"
"Dd"
"aADd"
#if defined(IPSEC) && !defined(IPSEC_POLICY_IPSEC)
"E"
#endif
"fH"
"fHnNoOq"
#ifdef IPV6_USE_MIN_MTU
"m"
"u"
#endif
"nNoqrRtvwW] "
"[-a addrtype] [-b bufsiz] [-c count] [-g gateway]\n"
" [-h hoplimit] [-I interface] [-i wait] [-l preload]"
"vyY] "
"[-b bufsiz] [-c count] [-e gateway]\n"
" [-I interface] [-i wait] [-k addrtype] [-l preload] "
"[-m hoplimit]\n"
" [-p pattern]"
#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
" [-P policy]"
#endif
"\n"
" [-p pattern] [-S sourceaddr] [-s packetsize] "
"[-x waittime]\n"
" [-X timeout] [hops ...] host\n");
" [-S sourceaddr] [-s packetsize]\n"
" [-t timeout] [-W waittime] [hops ...] host\n");
exit(1);
}

View file

@ -3,6 +3,6 @@
PACKAGE= tests
ATF_TESTS_SH+= ping6_test
${PACKAGE}FILES+= ping6_c1_s8_X1.out
${PACKAGE}FILES+= ping6_c1_s8_t1.out
.include <bsd.test.mk>

View file

@ -27,21 +27,21 @@
#
# $FreeBSD$
atf_test_case ping6_c1_s8_X1
ping6_c1_s8_X1_head() {
atf_test_case ping6_c1_s8_t1
ping6_c1_s8_t1_head() {
atf_set "descr" "Stop after receiving 1 ECHO_RESPONSE packet"
}
ping6_c1_s8_X1_body() {
ping6_c1_s8_t1_body() {
if ! getaddrinfo -f inet6 localhost 1>/dev/null 2>&1; then
atf_skip "IPv6 is not configured"
fi
atf_check -s exit:0 -o save:std.out -e empty \
ping6 -c 1 -s 8 -X 1 localhost
check_ping_statistics std.out $(atf_get_srcdir)/ping6_c1_s8_X1.out
ping6 -c 1 -s 8 -t 1 localhost
check_ping_statistics std.out $(atf_get_srcdir)/ping6_c1_s8_t1.out
}
atf_init_test_cases() {
atf_add_test_case ping6_c1_s8_X1
atf_add_test_case ping6_c1_s8_t1
}
check_ping_statistics() {