From mboxrd@z Thu Jan 1 00:00:00 1970 From: arisawa Content-Type: multipart/mixed; boundary="Apple-Mail=_6D95043A-721A-4177-BA8A-ABC51359D7A0" Message-Id: <9F5F3F78-3D28-4E9D-A405-55E9269BE394@ar.aichi-u.ac.jp> Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Date: Thu, 31 Dec 2015 10:36:36 +0900 References: <4AE7714E-C18F-4897-ACC1-4F8D35C858AE@ar.aichi-u.ac.jp> <2F96B09F-7524-473A-B883-9A7B7DD09978@ar.aichi-u.ac.jp> <18123F6C-5742-4E3D-906F-A7D4D8C40412@quintile.net> <20151230152657.GD50885@wopr.sciops.net> To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> In-Reply-To: Subject: Re: [9fans] bug or feature ? --- ip/ping -6 Topicbox-Message-UUID: 7b8e1e0a-ead9-11e9-9d60-3106f5b1d025 --Apple-Mail=_6D95043A-721A-4177-BA8A-ABC51359D7A0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii hello, I did nothing about original ping options, so they should work as they = have been. I am afraid I have removed too much. the new ping is here. test, please. --Apple-Mail=_6D95043A-721A-4177-BA8A-ABC51359D7A0 Content-Disposition: attachment; filename=ping.c Content-Type: application/octet-stream; name="ping.c" Content-Transfer-Encoding: quoted-printable /*=20ping=20for=20ip=20v4=20and=20v6=20*/=0A#include=20=0A#include=20= =0A#include=20=0A#include=20=0A#include=20=0A= #include=20=0A#include=20"icmp.h"=0A=0Aenum=20{=0A=09MAXMSG=09=09= =3D=2032,=0A=09SLEEPMS=09=09=3D=201000,=0A=0A=09SECOND=09=09=3D=20= 1000000000LL,=0A=09MINUTE=09=09=3D=2060*SECOND,=0A};=0A=0Atypedef=20= struct=20Req=20Req;=0Astruct=20Req=0A{=0A=09ushort=09seq;=09/*=20= sequence=20number=20*/=0A=09vlong=09time;=09/*=20time=20sent=20*/=0A=09= vlong=09rtt;=0A=09int=09ttl;=0A=09int=09replied;=0A=09Req=09=20*next;=0A= };=0A=0Atypedef=20struct=20{=0A=09int=09version;=0A=09char=09*net;=0A=09= int=09echocmd;=0A=09int=09echoreply;=0A=09unsigned=20iphdrsz;=0A=0A=09= void=09(*prreply)(Req=20*r,=20void=20*v);=0A=09void=09(*prlost)(ushort=20= seq,=20void=20*v);=0A}=20Proto;=0A=0A=0AReq=09*first;=09=09/*=20request=20= list=20*/=0AReq=09*last;=09=09/*=20...=20*/=0ALock=09listlock;=0A=0Achar=20= *argv0;=0A=0Aint=20addresses;=0Aint=20debug;=0Aint=20done;=0Aint=20= flood;=0Aint=20lostmsgs;=0Aint=20lostonly;=0Aint=20quiet;=0Aint=20= rcvdmsgs;=0Aint=20rint;=0Aushort=20firstseq;=0Avlong=20sum;=0Aint=20= waittime=20=3D=205000;=0A=0Astatic=20char=20*network,=20*target;=0A=0A= void=20lost(Req*,=20void*);=0Avoid=20reply(Req*,=20void*);=0A=0Astatic=20= void=0Ausage(void)=0A{=0A=09fprint(2,=0A=09=20=20=20=20"usage:=20%s=20= [-6alq]=20[-s=20msgsize]=20[-i=20millisecs]=20[-n=20#pings]=20dest\n",=0A= =09=09argv0);=0A=09exits("usage");=0A}=0A=0Astatic=20void=0Acatch(void=20= *a,=20char=20*msg)=0A{=0A=09USED(a);=0A=09if(strstr(msg,=20"alarm"))=0A=09= =09noted(NCONT);=0A=09else=20if(strstr(msg,=20"die"))=0A=09=09= exits("errors");=0A=09else=0A=09=09noted(NDFLT);=0A}=0A=0Astatic=20void=0A= prlost4(ushort=20seq,=20void=20*v)=0A{=0A=09Ip4hdr=20*ip4=20=3D=20v;=0A=0A= =09print("lost=20%ud:=20%V=20->=20%V\n",=20seq,=20ip4->src,=20ip4->dst);=0A= }=0A=0Astatic=20void=0Aprlost6(ushort=20seq,=20void=20*v)=0A{=0A=09= Ip6hdr=20*ip6=20=3D=20v;=0A=0A=09print("lost=20%ud:=20%I=20->=20%I\n",=20= seq,=20ip6->src,=20ip6->dst);=0A}=0A=0Astatic=20void=0Aprreply4(Req=20= *r,=20void=20*v)=0A{=0A=09Ip4hdr=20*ip4=20=3D=20v;=0A=0A=09print("%ud:=20= %V=20->=20%V=20rtt=20%lld=20=C2=B5s,=20avg=20rtt=20%lld=20=C2=B5s,=20ttl=20= =3D=20%d\n",=0A=09=09r->seq=20-=20firstseq,=20ip4->src,=20ip4->dst,=20= r->rtt,=20sum/rcvdmsgs,=0A=09=09r->ttl);=0A}=0A=0Astatic=20void=0A= prreply6(Req=20*r,=20void=20*v)=0A{=0A=09Ip6hdr=20*ip6=20=3D=20v;=0A=0A=09= print("%ud:=20%I=20->=20%I=20rtt=20%lld=20=C2=B5s,=20avg=20rtt=20%lld=20= =C2=B5s,=20ttl=20=3D=20%d\n",=0A=09=09r->seq=20-=20firstseq,=20ip6->src,=20= ip6->dst,=20r->rtt,=20sum/rcvdmsgs,=0A=09=09r->ttl);=0A}=0A=0Astatic=20= Proto=20v4pr=20=3D=20{=0A=094,=09=09"icmp",=0A=09EchoRequest,=09= EchoReply,=0A=09IPV4HDR_LEN,=0A=09prreply4,=09prlost4,=0A};=0Astatic=20= Proto=20v6pr=20=3D=20{=0A=096,=09=09"icmpv6",=0A=09EchoRequestV6,=09= EchoReplyV6,=0A=09IPV6HDR_LEN,=0A=09prreply6,=09prlost6,=0A};=0A=0A= static=20Proto=20*proto=20=3D=20&v4pr;=0A=0A=0AIcmphdr=20*=0A= geticmp(void=20*v)=0A{=0A=09char=20*p=20=3D=20v;=0A=0A=09return=20= (Icmphdr=20*)(p=20+=20proto->iphdrsz);=0A}=0A=0Avoid=0Aclean(ushort=20= seq,=20vlong=20now,=20void=20*v)=0A{=0A=09int=20ttl;=0A=09Req=20**l,=20= *r;=0A=0A=09ttl=20=3D=200;=0A=09if=20(v)=20{=0A=09=09if=20= (proto->version=20=3D=3D=204)=0A=09=09=09ttl=20=3D=20((Ip4hdr=20= *)v)->ttl;=0A=09=09else=0A=09=09=09ttl=20=3D=20((Ip6hdr=20*)v)->ttl;=0A=09= }=0A=09lock(&listlock);=0A=09last=20=3D=20nil;=0A=09for(l=20=3D=20= &first;=20*l;=20){=0A=09=09r=20=3D=20*l;=0A=0A=09=09if(v=20&&=20r->seq=20= =3D=3D=20seq){=0A=09=09=09r->rtt=20=3D=20now-r->time;=0A=09=09=09r->ttl=20= =3D=20ttl;=0A=09=09=09reply(r,=20v);=0A=09=09}=0A=0A=09=09if(now-r->time=20= >=20MINUTE){=0A=09=09=09*l=20=3D=20r->next;=0A=09=09=09r->rtt=20=3D=20= now-r->time;=0A=09=09=09if(v)=0A=09=09=09=09r->ttl=20=3D=20ttl;=0A=09=09=09= if(r->replied=20=3D=3D=200)=0A=09=09=09=09lost(r,=20v);=0A=09=09=09= free(r);=0A=09=09}else{=0A=09=09=09last=20=3D=20r;=0A=09=09=09l=20=3D=20= &r->next;=0A=09=09}=0A=09}=0A=09unlock(&listlock);=0A}=0A=0Astatic=20= uchar=20loopbacknet[IPaddrlen]=20=3D=20{=0A=090,=200,=200,=200,=0A=090,=20= 0,=200,=200,=0A=090,=200,=200xff,=200xff,=0A=09127,=200,=200,=200=0A};=0A= static=20uchar=20loopbackmask[IPaddrlen]=20=3D=20{=0A=090xff,=200xff,=20= 0xff,=200xff,=0A=090xff,=200xff,=200xff,=200xff,=0A=090xff,=200xff,=20= 0xff,=200xff,=0A=090xff,=200,=200,=200=0A};=0A=0A/*=0A=20*=20find=20= first=20ip=20addr=20suitable=20for=20proto=20and=0A=20*=20that=20isn't=20= the=20friggin=20loopback=20address.=0A=20*=20deprecate=20link-local=20= and=20multicast=20addresses.=0A=20*/=0Astatic=20int=0Amyipvnaddr(uchar=20= *ip,=20Proto=20*proto,=20char=20*net)=0A{=0A=09int=20ipisv4,=20wantv4;=0A= =09Ipifc=20*nifc;=0A=09Iplifc=20*lifc;=0A=09uchar=20mynet[IPaddrlen],=20= linklocal[IPaddrlen];=0A=09static=20Ipifc=20*ifc;=0A=0A=09= ipmove(linklocal,=20IPnoaddr);=0A=09wantv4=20=3D=20proto->version=20=3D=3D= =204;=0A=09ifc=20=3D=20readipifc(net,=20ifc,=20-1);=0A=09for(nifc=20=3D=20= ifc;=20nifc;=20nifc=20=3D=20nifc->next)=0A=09=09for(lifc=20=3D=20= nifc->lifc;=20lifc;=20lifc=20=3D=20lifc->next){=0A=09=09=09= maskip(lifc->ip,=20loopbackmask,=20mynet);=0A=09=09=09if(ipcmp(mynet,=20= loopbacknet)=20=3D=3D=200)=0A=09=09=09=09continue;=0A=09=09=09= if(ISIPV6MCAST(lifc->ip)=20||=20ISIPV6LINKLOCAL(lifc->ip))=20{=0A=09=09=09= =09ipmove(linklocal,=20lifc->ip);=0A=09=09=09=09continue;=0A=09=09=09}=0A= =09=09=09ipisv4=20=3D=20isv4(lifc->ip)=20!=3D=200;=0A=09=09=09= if(ipcmp(lifc->ip,=20IPnoaddr)=20!=3D=200=20&&=20wantv4=20=3D=3D=20= ipisv4){=0A=09=09=09=09ipmove(ip,=20lifc->ip);=0A=09=09=09=09return=200;=0A= =09=09=09}=0A=09=09}=0A=09/*=20no=20global=20unicast=20addrs=20found,=20= fall=20back=20to=20link-local,=20if=20any=20*/=0A=09ipmove(ip,=20= linklocal);=0A=09return=20ipcmp(ip,=20IPnoaddr)=20=3D=3D=200?=20-1:=200;=0A= }=0A=0Avoid=0Asender(int=20fd,=20int=20msglen,=20int=20interval,=20int=20= n)=0A{=0A=09int=20i,=20extra;=0A=09ushort=20seq;=0A=09char=20= buf[64*1024+512];=0A=09uchar=20me[IPaddrlen],=20mev4[IPv4addrlen];=0A=09= Icmphdr=20*icmp;=0A=09Req=20*r;=0A=0A=09srand(time(0));=0A=09firstseq=20= =3D=20seq=20=3D=20rand();=0A=0A=09icmp=20=3D=20geticmp(buf);=0A=09= memset(buf,=200,=20proto->iphdrsz=20+=20ICMP_HDRSIZE);=0A=09for(i=20=3D=20= proto->iphdrsz=20+=20ICMP_HDRSIZE;=20i=20<=20msglen;=20i++)=0A=09=09= buf[i]=20=3D=20i;=0A=09icmp->type=20=3D=20proto->echocmd;=0A=09= icmp->code=20=3D=200;=0A=0A=09/*=20arguably=20the=20kernel=20should=20= fill=20in=20the=20right=20src=20addr.=20*/=0A=09myipvnaddr(me,=20proto,=20= network);=0A=09if=20(proto->version=20=3D=3D=204)=20{=0A=09=09= v6tov4(mev4,=20me);=0A=09=09memmove(((Ip4hdr=20*)buf)->src,=20mev4,=20= IPv4addrlen);=0A=09}=20else=0A=09=09ipmove(((Ip6hdr=20*)buf)->src,=20= me);=0A=09if=20(addresses)=0A=09=09print("\t%I=20->=20%s\n",=20me,=20= target);=0A=0A=09if(rint=20!=3D=200=20&&=20interval=20<=3D=200)=0A=09=09= rint=20=3D=200;=0A=09extra=20=3D=200;=0A=09for(i=20=3D=200;=20i=20<=20n;=20= i++){=0A=09=09if(i=20!=3D=200){=0A=09=09=09if(rint=20!=3D=200)=0A=09=09=09= =09extra=20=3D=20nrand(interval);=0A=09=09=09sleep(interval=20+=20= extra);=0A=09=09}=0A=09=09r=20=3D=20malloc(sizeof=20*r);=0A=09=09if=20(r=20= =3D=3D=20nil)=0A=09=09=09continue;=0A=09=09hnputs(icmp->seq,=20seq);=0A=09= =09r->seq=20=3D=20seq;=0A=09=09r->next=20=3D=20nil;=0A=09=09r->replied=20= =3D=200;=0A=09=09r->time=20=3D=20nsec();=09/*=20avoid=20early=20free=20= in=20reply!=20*/=0A=09=09lock(&listlock);=0A=09=09if(first=20=3D=3D=20= nil)=0A=09=09=09first=20=3D=20r;=0A=09=09else=0A=09=09=09last->next=20=3D=20= r;=0A=09=09last=20=3D=20r;=0A=09=09unlock(&listlock);=0A=09=09r->time=20= =3D=20nsec();=0A=09=09if(write(fd,=20buf,=20msglen)=20<=20msglen){=0A=09=09= =09fprint(2,=20"%s:=20write=20failed:=20%r\n",=20argv0);=0A=09=09=09= return;=0A=09=09}=0A=09=09seq++;=0A=09}=0A=09done=20=3D=201;=0A}=0A=0A= void=0Arcvr(int=20fd,=20int=20msglen,=20int=20interval,=20int=20nmsg)=0A= {=0A=09int=20i,=20n,=20munged;=0A=09ushort=20x;=0A=09vlong=20now;=0A=09= char=20err[ERRMAX];=0A=09uchar=20buf[64*1024+512];=0A=09Icmphdr=20*icmp;=0A= =09Req=20*r;=0A=0A=09sum=20=3D=200;=0A=09while(lostmsgs+rcvdmsgs=20<=20= nmsg){=0A=09=09alarm((nmsg-lostmsgs-rcvdmsgs)*interval+waittime);=0A=09=09= n=20=3D=20read(fd,=20buf,=20sizeof=20buf);=0A=09=09alarm(0);=0A=09=09= if(n=20=3D=3D=200)=0A=09=09=09strcpy(err,=20"got=20eof");=0A=09=09else=20= if(n=20<=200)=0A=09=09=09rerrstr(err,=20sizeof(err));=0A=09=09now=20=3D=20= nsec();=0A=09=09if(n=20<=3D=200){=0A=09=09=09print("%s\n",=20err);=0A=09=09= =09clean(0,=20now+MINUTE,=20nil);=0A=09=09=09if(strstr(err,=20= "interrupted")=20=3D=3D=20nil)=0A=09=09=09=09sleep(waittime);=0A=09=09=09= continue;=0A=09=09}=0A=09=09if(n=20<=20msglen){=0A=09=09=09print("bad=20= len=20%d/%d\n",=20n,=20msglen);=0A=09=09=09continue;=0A=09=09}=0A=09=09= icmp=20=3D=20geticmp(buf);=0A=09=09munged=20=3D=200;=0A=09=09for(i=20=3D=20= proto->iphdrsz=20+=20ICMP_HDRSIZE;=20i=20<=20msglen;=20i++)=0A=09=09=09= if(buf[i]=20!=3D=20(uchar)i)=0A=09=09=09=09munged++;=0A=09=09if(munged)=0A= =09=09=09print("corrupted=20reply\n");=0A=09=09x=20=3D=20= nhgets(icmp->seq);=0A=09=09if(icmp->type=20!=3D=20proto->echoreply=20||=20= icmp->code=20!=3D=200)=20{=0A=09=09=09print("bad=20type/code/sequence=20= %d/%d/%d=20(want=20%d/%d/%d)\n",=0A=09=09=09=09icmp->type,=20icmp->code,=20= x,=0A=09=09=09=09proto->echoreply,=200,=20x);=0A=09=09=09continue;=0A=09=09= }=0A=09=09clean(x,=20now,=20buf);=0A=09}=0A=0A=09lock(&listlock);=0A=09= for(r=20=3D=20first;=20r;=20r=20=3D=20r->next)=0A=09=09if(r->replied=20= =3D=3D=200)=0A=09=09=09lostmsgs++;=0A=09unlock(&listlock);=0A=0A=09= if(!quiet=20&&=20lostmsgs)=0A=09=09print("%d=20out=20of=20%d=20messages=20= lost\n",=20lostmsgs,=0A=09=09=09lostmsgs+rcvdmsgs);=0A}=0A=0Astatic=20= int=0Aisdottedquad(char=20*name)=0A{=0A=09int=20dot=20=3D=200,=20digit=20= =3D=200;=0A=0A=09for=20(;=20*name=20!=3D=20'\0';=20name++)=0A=09=09if=20= (*name=20=3D=3D=20'.')=0A=09=09=09dot++;=0A=09=09else=20if=20= (isdigit(*name))=0A=09=09=09digit++;=0A=09=09else=0A=09=09=09return=200;=0A= =09return=20dot=20&&=20digit;=0A}=0A=0Astatic=20int=0Aisv6lit(char=20= *name)=0A{=0A=09int=20colon=20=3D=200,=20hex=20=3D=200;=0A=0A=09for=20(;=20= *name=20!=3D=20'\0';=20name++)=0A=09=09if=20(*name=20=3D=3D=20':')=0A=09=09= =09colon++;=0A=09=09else=20if=20(isxdigit(*name))=0A=09=09=09hex++;=0A=09= =09else=0A=09=09=09return=200;=0A=09return=20colon;=0A}=0A=0Achar=20*=0A= nametoip(char=20*cs,=20char=20*name,=20int=20ipver)=0A{=0A=09int=20n,fd;=0A= =09char=20buf[128],=20*p,=20*addr,=20*ip;=0A=0A=09if(isdottedquad(name)=20= ||=20isv6lit(name))=0A=09=09return=20strdup(name);=0A=09if(cs=20=3D=3D=20= nil)=0A=09=09cs=20=3D=20"/net/cs";=0A=09fd=20=3D=20open(cs,=20ORDWR);=0A=09= if(fd=20<=200)=0A=09=09sysfatal("cannot=20open=20%s:=20%r",=20cs);=0A=09= addr=20=3D=20smprint("tcp!%s!1",=20name);=0A=09if(write(fd,=20addr,=20= strlen(addr))=20!=3D=20strlen(addr)){=0A=09=09close(fd);=0A=09=09= sysfatal("cannot=20write=20%s=20to%s:=20%r",=20addr,=20cs);=0A=09}=0A=09= free(addr);=0A=09seek(fd,=200,=200);=0A=09while((n=20=3D=20read(fd,=20= buf,=20sizeof(buf)-1))=20>=200){=0A=09=09buf[n]=20=3D=200;=0A=09=09ip=20= =3D=20strchr(buf,'=20');=0A=09=09ip++;=0A=09=09p=20=3D=20strchr(ip,'!');=0A= =09=09*p=20=3D=200;=0A=09=09if(ipver=20=3D=3D=204=20&&=20= isdottedquad(ip)){=0A=09=09=09close(fd);=0A=09=09=09return=20strdup(ip);=0A= =09=09}=0A=09=09if(ipver=20=3D=3D=206=20&&=20isv6lit(ip)){=0A=09=09=09= close(fd);=0A=09=09=09return=20strdup(ip);=0A=09=09}=0A=09}=0A=09= close(fd);=0A=09return=20nil;=0A}=0A=0Avoid=0Amain(int=20argc,=20char=20= **argv)=0A{=0A=09int=20fd,=20msglen,=20interval,=20nmsg;=0A=09char=20= *ds;=0A=0A=09nsec();=09=09/*=20make=20sure=20time=20file=20is=20already=20= open=20*/=0A=0A=09fmtinstall('V',=20eipfmt);=0A=09fmtinstall('I',=20= eipfmt);=0A=0A=09msglen=20=3D=20interval=20=3D=200;=0A=09nmsg=20=3D=20= MAXMSG;=0A=09ARGBEGIN=20{=0A=09case=20'6':=0A=09=09proto=20=3D=20&v6pr;=0A= =09=09break;=0A=09case=20'a':=0A=09=09addresses=20=3D=201;=0A=09=09= break;=0A=09case=20'd':=0A=09=09debug++;=0A=09=09break;=0A=09case=20'f':=0A= =09=09flood=20=3D=201;=0A=09=09break;=0A=09case=20'i':=0A=09=09interval=20= =3D=20atoi(EARGF(usage()));=0A=09=09if(interval=20<=200)=0A=09=09=09= usage();=0A=09=09break;=0A=09case=20'l':=0A=09=09lostonly++;=0A=09=09= break;=0A=09case=20'n':=0A=09=09nmsg=20=3D=20atoi(EARGF(usage()));=0A=09=09= if(nmsg=20<=200)=0A=09=09=09usage();=0A=09=09break;=0A=09case=20'q':=0A=09= =09quiet=20=3D=201;=0A=09=09break;=0A=09case=20'r':=0A=09=09rint=20=3D=20= 1;=0A=09=09break;=0A=09case=20's':=0A=09=09msglen=20=3D=20= atoi(EARGF(usage()));=0A=09=09break;=0A=09case=20'w':=0A=09=09waittime=20= =3D=20atoi(EARGF(usage()));=0A=09=09if(waittime=20<=200)=0A=09=09=09= usage();=0A=09=09break;=0A=09default:=0A=09=09usage();=0A=09=09break;=0A=09= }=20ARGEND;=0A=0A=09if(msglen=20<=20proto->iphdrsz=20+=20ICMP_HDRSIZE)=0A= =09=09msglen=20=3D=20proto->iphdrsz=20+=20ICMP_HDRSIZE;=0A=09if(msglen=20= <=2064)=0A=09=09msglen=20=3D=2064;=0A=09if(msglen=20>=3D=2064*1024)=0A=09= =09msglen=20=3D=2064*1024-1;=0A=09if(interval=20<=3D=200=20&&=20!flood)=0A= =09=09interval=20=3D=20SLEEPMS;=0A=0A=09if(argc=20<=201)=0A=09=09= usage();=0A=0A=09notify(catch);=0A=0A=09target=20=3D=20= nametoip(nil,argv[0],proto->version);=0A=0A=09if(isdottedquad(target))=0A= =09=09proto=20=3D=20&v4pr;=0A=09else=0A=09if(isv6lit(target))=0A=09=09= proto=20=3D=20&v6pr;=0A=0A=09ds=20=3D=20netmkaddr(target,=20proto->net,=20= "1");=0A=09fd=20=3D=20dial(ds,=200,=200,=200);=0A=09if(fd=20<=200){=0A=09= =09fprint(2,=20"%s:=20couldn't=20dial=20%s:=20%r\n",=20argv0,=20ds);=0A=09= =09exits("dialing");=0A=09}=0A=0A=09if=20(!quiet)=0A=09=09print("sending=20= %d=20%d=20byte=20messages=20%d=20ms=20apart=20to=20%s\n",=0A=09=09=09= nmsg,=20msglen,=20interval,=20ds);=0A=0A=09= switch(rfork(RFPROC|RFMEM|RFFDG)){=0A=09case=20-1:=0A=09=09fprint(2,=20= "%s:=20can't=20fork:=20%r\n",=20argv0);=0A=09=09exits("forking");=0A=09= case=200:=0A=09=09rcvr(fd,=20msglen,=20interval,=20nmsg);=0A=09=09= exits(0);=0A=09default:=0A=09=09sender(fd,=20msglen,=20interval,=20= nmsg);=0A=09=09wait();=0A=09=09exits(lostmsgs=20?=20"lost=20messages"=20= :=20"");=0A=09}=0A}=0A=0Avoid=0Areply(Req=20*r,=20void=20*v)=0A{=0A=09= r->rtt=20/=3D=201000LL;=0A=09sum=20+=3D=20r->rtt;=0A=09if(!r->replied)=0A= =09=09rcvdmsgs++;=0A=09if(!quiet=20&&=20!lostonly)=0A=09=09if(addresses)=0A= =09=09=09(*proto->prreply)(r,=20v);=0A=09=09else=0A=09=09=09print("%ud:=20= rtt=20%lld=20=C2=B5s,=20avg=20rtt=20%lld=20=C2=B5s,=20ttl=20=3D=20%d\n",=0A= =09=09=09=09r->seq=20-=20firstseq,=20r->rtt,=20sum/rcvdmsgs,=20r->ttl);=0A= =09r->replied=20=3D=201;=0A}=0A=0Avoid=0Alost(Req=20*r,=20void=20*v)=0A{=0A= =09if(!quiet)=0A=09=09if(addresses=20&&=20v=20!=3D=20nil)=0A=09=09=09= (*proto->prlost)(r->seq=20-=20firstseq,=20v);=0A=09=09else=0A=09=09=09= print("lost=20%ud\n",=20r->seq=20-=20firstseq);=0A=09lostmsgs++;=0A}=0A= --Apple-Mail=_6D95043A-721A-4177-BA8A-ABC51359D7A0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > 2015/12/31 7:43=E3=80=81Kenny Lasse Hoff Levinsen = =E3=81=AE=E3=83=A1=E3=83=BC=E3=83=AB=EF=BC=9A >=20 > It is not a common factor if you ping broadcast. That is, the local = address is common, the remote is not. >=20 > joushou >=20 >> On 30 Dec 2015, at 20:05, Steve Simon wrote: >>=20 >> I would display the IP address once only, rather on every line; as it = is a common factor. >>=20 >> -Steve >>=20 >>=20 >>> On 30 Dec 2015, at 15:26, Kurt H Maier wrote: >>>=20 >>>> On Wed, Dec 30, 2015 at 03:05:33PM +0000, Steve Simon wrote: >>>> If I where redesigning ping I wouldn't repeat any info that is = common on each line - I.e. ip addresses or the column titles: rtt, ave = etc. >>>>=20 >>>> consider plan9's ps(1) which has no column titles. they are = described in the man page and are obvious from the context once you have = read the man page once. >>>>=20 >>>> Having said this, I understand that tradition is also a strong = guiding principal. >>>>=20 >>>> -Steve >>>=20 >>> I have no opinion on the labeling, but dropping the IPs from the = output >>> would make this tool useless for logging data. >>>=20 >>> khm >>=20 >=20 >=20 --Apple-Mail=_6D95043A-721A-4177-BA8A-ABC51359D7A0--