Re: Is glibc getaddrinfo() working on your etch-amd64 system?

2007-11-28 Thread Bill Kelly


From: "YOSHIFUJI Hideaki / 吉藤英明" <[EMAIL PROTECTED]>


It is nothing to do with amd64, but the usage;
getaddrinfo() is not for reserve DNS lookups.
For that purpose, use getnameinfo() instead.


Thank you!

If you don't mind, I am wondering why getaddrinfo() previously
worked for reverse lookups?  Was it just an accident?

Note, I'm not trying to argue... I'm just surpised and curious.

The man page for getaddrinfo() says, "The getaddrinfo(3) function
combines the functionality provided by the getipnodebyname(3),
getipnodebyaddr(3), getservbyname(3), and getservbyport(3) functions
into a single interface."

And the man page for getipnodebyaddr() says, "The getipnodebyaddr(3)
function looks up the name of the host whose network address is
specified by the addr parameter."

So it sounds like the man page is saying that getaddrinfo()
includes the functionality of getipnodebyaddr() ?

Anyway - thank you for your help!  I'm off to inquire on the
ruby-core mailing list, because Ruby also uses getaddrinfo()
to perform reverse lookups.  (That is how my journey began:
my Ruby code stopped working when I upgraded to etch.)


Regards,

Bill



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Is glibc getaddrinfo() working on your etch-amd64 system?

2007-11-28 Thread YOSHIFUJI Hideaki / 吉藤英明
In article <[EMAIL PROTECTED]> (at Wed, 28 Nov 2007 01:28:04 -0800), "Bill 
Kelly" <[EMAIL PROTECTED]> says:

> I'm in the process of trying to debug why getaddrinfo() is
> failing to perform reverse DNS lookups on my etch-amd64
> system.  (glibc version 2.3.6.ds1-13etch2)

It is nothing to do with amd64, but the usage;
getaddrinfo() is not for reserve DNS lookups.
For that purpose, use getnameinfo() instead.

--yoshfuji

--- getaddrinfo-test.c.orig 2007-11-26 15:51:17.0 +0900
+++ getaddrinfo-test.c  2007-11-28 19:49:33.164757204 +0900
@@ -19,7 +19,6 @@
const char *host = "208.77.188.166";  // www.example.com
const char *port = NULL;
int socktype = SOCK_STREAM;
-   int flags = AI_CANONNAME;
 
struct addrinfo hints;
struct addrinfo* res = NULL;
@@ -28,14 +27,28 @@
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = socktype;
-   hints.ai_flags = flags;
+   hints.ai_flags = 0;
 
error = getaddrinfo(host, port, &hints, &res);
 
-   fprintf(stderr, "sock_addrinfo: error=%d res->ai_canonname='%s'\n", 
error, (res && res->ai_canonname)? res->ai_canonname : "NULL");
+   if (error) {
+   fprintf(stderr, "sock_addrinfo: error=%d: %s\n",
+   error, gai_strerror(error));
+   return 4;
+   }
+
+   if (res) {
+   char hostbuf[NI_MAXHOST] = "???";
+
+   error = getnameinfo(res->ai_addr, res->ai_addrlen,
+   hostbuf, sizeof(hostbuf), NULL, 0,
+   0);
+
+   fprintf(stderr, "sock_nameinfo: error=%d, host=%s\n",
+   error, hostbuf);
 
-   if (res)
freeaddrinfo(res);
+   }
 
return 0;
 }


--yoshfuji


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Is glibc getaddrinfo() working on your etch-amd64 system?

2007-11-28 Thread Eduardo M KALINOWSKI

Bill Kelly wrote:

Hi,

I'm in the process of trying to debug why getaddrinfo() is
failing to perform reverse DNS lookups on my etch-amd64
system.  (glibc version 2.3.6.ds1-13etch2)

I've posted a tiny C program here that reproduces the
problem: http://cila-search.net/~billk/debug/getaddrinfo/
( getaddrinfo-test.c )

I'm hoping some folks on this list might be willing to
compile and run the program on your systems, and see if
yours is broken the same way.

If it works properly you should see "www.example.com".
If it's broken you should see "208.77.188.166".

For example:

 $ gcc getaddrinfo-test.c
 $ ./a.out
 sock_addrinfo: error=0 res->ai_canonname='208.77.188.166'

You can cross-check with the host command on the command line:

 $ host 208.77.188.166
 166.188.77.208.in-addr.arpa domain name pointer www.example.com.

If the host command says "www.example.com" but the C program
says "208.77.188.166" then your system would appear to be
broken like mine.


Well, here indeed the program did not work:

$ ./getaddrinfo-test
sock_addrinfo: error=0 res->ai_canonname='208.77.188.166'
$ host 208.77.188.166
Name: www.example.com
Address: 208.77.188.166

libc6 version 2.6.1-1

--
Distrust all those who love you extremely upon a very slight acquaintance
and without any visible reason.
-- Lord Chesterfield

Eduardo M KALINOWSKI
[EMAIL PROTECTED]
http://move.to/hpkb


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Is glibc getaddrinfo() working on your etch-amd64 system?

2007-11-28 Thread Bill Kelly

Hi,

I'm in the process of trying to debug why getaddrinfo() is
failing to perform reverse DNS lookups on my etch-amd64
system.  (glibc version 2.3.6.ds1-13etch2)

I've posted a tiny C program here that reproduces the
problem: http://cila-search.net/~billk/debug/getaddrinfo/
( getaddrinfo-test.c )

I'm hoping some folks on this list might be willing to
compile and run the program on your systems, and see if
yours is broken the same way.

If it works properly you should see "www.example.com".
If it's broken you should see "208.77.188.166".

For example:

 $ gcc getaddrinfo-test.c
 $ ./a.out
 sock_addrinfo: error=0 res->ai_canonname='208.77.188.166'

You can cross-check with the host command on the command line:

 $ host 208.77.188.166
 166.188.77.208.in-addr.arpa domain name pointer www.example.com.

If the host command says "www.example.com" but the C program
says "208.77.188.166" then your system would appear to be
broken like mine.


Thanks for your consideration,

Regards,

Bill



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]