From: florian Date: Sat, 24 Oct 2015 16:32:26 +0000 (+0000) Subject: Sync ping6 output to ping. ping has been around for longer and so X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=fac72a2bccf8f64e0d7a47b8733e3a65cbbc2d99;p=openbsd Sync ping6 output to ping. ping has been around for longer and so defines the canonical output format. Having different output is getting in the way of a merge. This moves the output of the src address to the -v option. With the overly complicated IPv6 address selection it's sometimes usefull to have this information. OK benno@, sthen@ can live with it. --- diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index d241ce9139c..520fe1d2bfc 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping6.c,v 1.128 2015/10/17 15:43:31 florian Exp $ */ +/* $OpenBSD: ping6.c,v 1.129 2015/10/24 16:32:26 florian Exp $ */ /* $KAME: ping6.c,v 1.163 2002/10/25 02:19:06 itojun Exp $ */ /* @@ -571,7 +571,7 @@ main(int argc, char *argv[]) scmsgp = CMSG_NXTHDR(&smsghdr, scmsgp); } - if (!(options & F_SRCADDR)) { + if (!(options & F_SRCADDR) && options & F_VERBOSE) { /* * get the source address. XXX since we revoked the root * privilege, we cannot use a raw socket for this. @@ -635,10 +635,12 @@ main(int argc, char *argv[]) arc4random_buf(&tv64_offset, sizeof(tv64_offset)); arc4random_buf(&mac_key, sizeof(mac_key)); - printf("PING6(%lu=40+8+%lu bytes) ", (unsigned long)(40 + ICMP6ECHOLEN - + datalen), (unsigned long)(ICMP6ECHOLEN + datalen - 8)); - printf("%s --> ", pr_addr((struct sockaddr *)&src, sizeof(src))); - printf("%s\n", pr_addr((struct sockaddr *)&dst, sizeof(dst))); + printf("PING6 %s (", hostname); + if (options & F_VERBOSE) + printf("%s --> ", pr_addr((struct sockaddr *)&src, + sizeof(src))); + printf("%s): %d data bytes\n", pr_addr((struct sockaddr *)&dst, + sizeof(dst)), datalen); while (preload--) /* Fire off them quickies. */ (void)pinger(); @@ -1326,7 +1328,7 @@ summary(int signo) buf[0] = '\0'; - snprintf(buft, sizeof(buft), "\n--- %s ping6 statistics ---\n", + snprintf(buft, sizeof(buft), "--- %s ping6 statistics ---\n", hostname); strlcat(buf, buft, sizeof(buf)); snprintf(buft, sizeof(buft), "%ld packets transmitted, ",