From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <0fcc387289a4a346cbd5bf450171a0d0@plan9.jp> To: 9fans@cse.psu.edu Subject: Re: [9fans] csipinfo From: Joel “chesky” Salomon Date: Wed, 18 Oct 2006 14:44:52 -0400 In-Reply-To: <61d9157e8f6994d999d7f257cd2b05b4@coraid.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Topicbox-Message-UUID: ccc6a934-ead1-11e9-9d60-3106f5b1d025 > had to go around the list ... can't post from here. >=20 > i think you're making this too hard. what you want is more > of a dns query. this is very easy to do. something like > (this might not complie -- i just typed it out.) >=20 > char* > gethostbyaddr(char *net, char *addr) > { > char buf[64]; > int fd, l; >=20 > if(net =3D=3D 0) > net=3D"/net"; > snprint(buf, sizeof buf, "%s/dns", net); > fd =3D open(buf, ORDWR); > if(fd < 0) > return 0; > snprint(buf, sizeof buf, "%s ptr", addr); > if(write(fd, buf, strlen(buf)) < 0) > return 0; > l =3D read(fd, buf, sizeof buf); > if(l < 0 || l =3D=3D sizeof buf) > return 0; > return strdup(buf); > } >=20 > - erik Thanks, this finally looks like what I need. Two points though: 1. Is 64 bytes sufficient for the domain name? Searching the =E2=80=99n= et I=E2=80=99ve found other numbers =E2=80=94 according to it should be 1005; links to a name about 140 bytes long and firefox handles it just fine. 2. Why the second part of =E2=80=9Cif(l < 0 || l =3D=3D sizeof buf)=E2=80= =9D? I=E2=80=99ll bang on this a bit and see if I can make it set errstr appro= priately. --Joel