On 2021/02/20 09:20, Remi Locherer wrote: > On February 19, 2021 8:56:31 PM UTC, Stuart Henderson <s...@spacehopper.org> > wrote: > >Canvassing opinions on having . and ! this way around. I'm using . for > >response, ! for no response, which makes more sense to me but it's been > >pointed out that it's the opposite of what cisco does so it might > >confuse > >some people. > > Also Junos uses "!" for sucessfull pings and "." for no response. > https://kb.juniper.net/InfoCenter/index?page=content&id=KB25251 > > And if I remember it corectly then Brocade did it the same way as Cisco. > > The "-g" flag is used differently in various ping implementations. From man > pages: > * FreeBSD: - g is sweepmi size. > * NetBSD: -g is used to specify a gateway for loose source routing. > * Illumos: same as NetBSD > * Linux: no -g > > > I like the feature and think -g is fine. I would prefer if our ping would use > "!" in the same way as Cisco. That is probably als consistent with -f where a > "." also stands for a echo request.
That's a good point about -f. I was thinking . is similar to how it looks in -f output, but really the "."s build up when there are no replies and it prints a backspace for a received response. I've had offlist replies in favour of both directions but let's go with the same polarity as junos/cisco. Any OKs? Index: ping.8 =================================================================== RCS file: /cvs/src/sbin/ping/ping.8,v retrieving revision 1.63 diff -u -p -r1.63 ping.8 --- ping.8 11 Feb 2020 18:41:39 -0000 1.63 +++ ping.8 20 Feb 2021 16:30:13 -0000 @@ -66,7 +66,7 @@ .Nd send ICMP ECHO_REQUEST packets to network hosts .Sh SYNOPSIS .Nm ping -.Op Fl DdEefHLnqRv +.Op Fl DdEefgHLnqRv .Op Fl c Ar count .Op Fl I Ar sourceaddr .Op Fl i Ar interval @@ -79,7 +79,7 @@ .Op Fl w Ar maxwait .Ar host .Nm ping6 -.Op Fl DdEefHLmnqv +.Op Fl DdEefgHLmnqv .Op Fl c Ar count .Op Fl h Ar hoplimit .Op Fl I Ar sourceaddr @@ -151,6 +151,20 @@ Only the superuser may use this option. .Bf -emphasis This can be very hard on a network and should be used with caution. .Ef +.It Fl g +Provides a visual display of packets received and lost. +For every +.Dv ECHO_REPLY +received, an exclamation mark +.Sq ! +is printed, while for every missed packet a period +.Sq \&. +is printed. +Duplicate and truncated replies are indicated with +.Sq D +and +.Sq T +respectively. .It Fl H Try reverse lookups for addresses. .It Fl h Ar hoplimit Index: ping.c =================================================================== RCS file: /cvs/src/sbin/ping/ping.c,v retrieving revision 1.243 diff -u -p -r1.243 ping.c --- ping.c 29 Dec 2020 16:40:47 -0000 1.243 +++ ping.c 20 Feb 2021 16:30:13 -0000 @@ -145,7 +145,7 @@ int options; #define F_QUIET 0x0010 #define F_RROUTE 0x0020 #define F_SO_DEBUG 0x0040 -/* 0x0080 */ +#define F_SHOWCHAR 0x0080 #define F_VERBOSE 0x0100 /* 0x0200 */ #define F_HDRINCL 0x0400 @@ -297,8 +297,8 @@ main(int argc, char *argv[]) preload = 0; datap = &outpack[ECHOLEN + ECHOTMLEN]; while ((ch = getopt(argc, argv, v6flag ? - "c:DdEefHh:I:i:Ll:mNnp:qS:s:T:V:vw:" : - "DEI:LRS:c:defHi:l:np:qs:T:t:V:vw:")) != -1) { + "c:DdEefgHh:I:i:Ll:mNnp:qS:s:T:V:vw:" : + "DEI:LRS:c:defgHi:l:np:qs:T:t:V:vw:")) != -1) { switch(ch) { case 'c': npackets = strtonum(optarg, 0, INT64_MAX, &errstr); @@ -326,6 +326,9 @@ main(int argc, char *argv[]) options |= F_FLOOD; setvbuf(stdout, NULL, _IONBF, 0); break; + case 'g': + options |= F_SHOWCHAR; + break; case 'H': options |= F_HOSTNAME; break; @@ -879,6 +882,11 @@ main(int argc, char *argv[]) if (!(options & F_FLOOD) && (options & F_AUD_MISS)) fputc('\a', stderr); + if ((options & F_SHOWCHAR) && + !(options & F_FLOOD)) { + putchar('.'); + fflush(stdout); + } } continue; } @@ -1329,7 +1337,14 @@ pr_pack(u_char *buf, int cc, struct msgh if (options & F_FLOOD) write(STDOUT_FILENO, &BSPACE, 1); - else { + else if (options & F_SHOWCHAR) { + if (dupflag) + putchar('D'); + else if (cc - ECHOLEN < datalen) + putchar('T'); + else + putchar('!'); + } else { printf("%d bytes from %s: icmp_seq=%u", cc, pr_addr(from, fromlen), ntohs(seq)); if (v6flag) @@ -1386,9 +1401,11 @@ pr_pack(u_char *buf, int cc, struct msgh pr_ipopt(hlen, buf); if (!(options & F_FLOOD)) { - putchar('\n'); - if (v6flag && (options & F_VERBOSE)) - pr_exthdrs(mhdr); + if (!(options & F_SHOWCHAR)) { + putchar('\n'); + if (v6flag && (options & F_VERBOSE)) + pr_exthdrs(mhdr); + } fflush(stdout); if (options & F_AUD_RECV) fputc('\a', stderr); @@ -2236,13 +2253,13 @@ usage(void) { if (v6flag) { fprintf(stderr, - "usage: ping6 [-DdEefHLmnqv] [-c count] [-h hoplimit] " + "usage: ping6 [-DdEefgHLmnqv] [-c count] [-h hoplimit] " "[-I sourceaddr]\n\t[-i interval] [-l preload] " "[-p pattern] [-s packetsize] [-T toskeyword]\n" "\t[-V rtable] [-w maxwait] host\n"); } else { fprintf(stderr, - "usage: ping [-DdEefHLnqRv] [-c count] [-I sourceaddr] " + "usage: ping [-DdEefgHLnqRv] [-c count] [-I sourceaddr] " "[-i interval]\n\t[-l preload] [-p pattern] [-s packetsize]" #ifndef SMALL " [-T toskeyword]"