cURL / Mailing Lists / curl-library / Single Mail

curl-library

NI_WITHSCOPEID (was Re: Debugging test cases)

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Mon, 29 Mar 2004 08:46:58 +0200 (CEST)

On Sun, 28 Mar 2004, Joe Halpin wrote:

> The problem is that getnameinfo() is failing with a return of 3, which means
> invalid argument. After poking around I found that if I unset the
> NI_WITHSCOPEID bit in the flags argument it works, and all tests pass.

I'll write up a configure test to test for this case. Does the following test
program return non-zero on Solaris 9 on Intel?

While googling on this subject, I found a patch for another project (for
Solaris 9) that made use of the NI_WITHSCOPEID only when the family is
AF_INET6. Have you tried that? To test it, you can modify the test program
below to create the socket to be AF_INET6 instead of AF_INET.

#include <sys/socket.h>
#include <netdb.h>

int main()
{
#ifdef NI_WITHSCOPEID
  struct sockaddr ss;
  int sslen;
  int rc;
  int fd = socket(AF_INET, SOCK_STREAM, 0);

  rc = getsockname(fd, (struct sockaddr *)&ss, &sslen);
  if(rc)
    return 1;

  rc = getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf),
                     NULL, 0,
                     NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID);
  if(rc)
    return 2;

  return 0; /* all is fine, use NI_WITHSCOPEID */
#else
  return 3; /* don't use NI_WITHSCOPEID, we don't have it! */
#endif
}

-- 
     Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
      Dedicated custom curl help for hire: http://haxx.se/curl.html
Received on 2004-03-29