freebsd-src/sbin/ping
Jose Luis Duran b86e4812cc ping: pr_iph() improvements
Very early on, the Src/Dst IP addresses were printed in hex notation
(%08x), which will always be 8-characters wide.  It was later changed to
use a dot-decimal notation.  Depending on the IP address length, the Src
and Dst headers may require a different padding.  Use the source and
destination IP lengths as padding for the headers.

Also, print an Opts (options) header, if there are options present.  It
has been abbreviated to Opts to match the length of the previous Data
header, removed in ef9e6dc7ee.

Print the header info such that no trailing spaces are produced.  As
some git workflows may automatically trim them, and make the tests fail
(see 25b86f8559).

Before

    Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
     4  f  00 007c 0001   0 0000  40  01 d868 192.0.2.1  192.0.2.2␣

After

    Vr HL TOS  Len   ID Flg  off TTL Pro  cks       Src       Dst
     4  f  00 007c 0001   0 0000  40  01 d868 192.0.2.1 192.0.2.2

And with options:

Before

    Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
     4  f  00 007c 0001   0 0000  40  01 d868 192.0.2.1  192.0.2.2 01...

After

    Vr HL TOS  Len   ID Flg  off TTL Pro  cks       Src       Dst Opts
     4  f  00 007c 0001   0 0000  40  01 d868 192.0.2.1 192.0.2.2 01...

Reviewed by:	markj
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/863
Differential Revision:	https://reviews.freebsd.org/D39561
2023-10-11 13:48:28 -04:00
..
tests ping: pr_iph() improvements 2023-10-11 13:48:28 -04:00
main.c ping: Unify ping/ping6 statistics section 2023-10-11 13:48:28 -04:00
main.h ping: Unify ping/ping6 statistics section 2023-10-11 13:48:28 -04:00
Makefile Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile.depend Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile.depend.options Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
ping.8 ping: The -C option is also supported for IPv6. 2023-09-19 10:47:11 +02:00
ping.c ping: pr_iph() improvements 2023-10-11 13:48:28 -04:00
ping.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
ping6.c ping: Unify ping/ping6 statistics section 2023-10-11 13:48:28 -04:00
ping6.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
utils.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
utils.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00