Getting WSANO_DATA error when using getnameinfo()




I'm porting an existing application to be IP agnostic. As such, I'm using
two books as reference:

* Migrating to IPv6
* IPv6 Network Programming

(I'm giving you the whole story here. Feel free to skim.)

I had some old IPv4 code that did a fully qualified domain name lookup:

inline DWORD GetFQDNString(LPCTSTR sIPAddr, CString&
sFullyQualifiedDomainName)
{
hostent* host;
unsigned int addr;

addr = inet_addr(CAnsiString(sIPAddr));
host = gethostbyaddr((char*)&addr, sizeof(long), AF_INET);
if (WSAGetLastError() != 0)
{
// the call failed
return WSAGetLastError();
}

sFullyQualifiedDomainName.Append(CString(host->h_name));
return ERROR_SUCCESS;
}

According to what I've read and from using the nifty checkv4.exe utility, I
needed to replace hostent, inet_addr() and gethostbyaddr(). I came up with
this code (which isn't it's final form, but more of a debugging jobbie.)

inline void IPv6FQDN(const char* ip)
{

struct addrinfo hints, *res;
static struct sockaddr_storage ss;
int error;

memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo(ip, NULL, &hints, &res);

memcpy(&ss, res->ai_addr, res->ai_addrlen);
freeaddrinfo(res);

char hbuf[NI_MAXHOST];
error = getnameinfo((sockaddr*)&ss, sizeof(ss), hbuf, sizeof(hbuf),
NULL, 0, NI_NAMEREQD);

if (error)
{
printf("IP: %s error: %d\n", ip, error);
} else {
printf("IP: %s FQDN: %s\n", ip, hbuf);
}
}

Then I set up an IPv6 network using virtual machines according to this
guide:
http://www.microsoft.com/downloads/details.aspx?FamilyID=fd7e1354-3a3b-43fd-955f-11edd39551d7&displaylang=en

If you don't feel like reading through that whole thing, I'll sum it up for
you: There's a DNS server, two clients and two routers. It's set up first
as three IPv4 subnets and then augmented with global IPv6 addresses.

I called my IPv6FQDN function six times from client1:

IPv6FQDN("client1");
IPv6FQDN("2001:db8:0:1:20c:29ff:fea1:c54c"); // client1's IPv6 address
IPv6FQDN("10.0.1.3"); // client1's IPv4 address

IPv6FQDN("client2");
IPv6FQDN("2001:db8:0:3:20c:29ff:fe5c:ef75"); // client2's IPv6 address
IPv6FQDN("10.0.3.2"); // client2's IPv4 address

Out of those six calls, only the call to client1's IPv4 address succeeded
(by returning "client1"). The rest returned 11004, WSANO_DATA.

That would lead me to believe that there's a problem with my DNS server.
Admittedly, I know next to nothing about how DNS stuff works. But in the
course of running through that guide, I set up AAAA records for client1 &
client2. After reading the description for WSANO_DATA, I added A records for
them too, but that didn't change anything.

So now I'm left wondering if the problem is with my code (and I tried a
bunch of rewrites and variations on it always with the same error), or with
my network setup, or both. Is there a way to monitor requests coming into
the DNS server? Maybe that would show the problem. Any guidance would be
appreciated. Thanks for reading!
.



Relevant Pages

  • Re: /etc/exports and IPv6 networks
    ... I spent a fair amount of time today reading through the man pages and ... source code and could not find any way of specifying an IPv6 network ...
    (freebsd-net)
  • Re: /etc/exports and IPv6 networks
    ... I spent a fair amount of time today reading through the man pages and ... source code and could not find any way of specifying an IPv6 network ... always been while copying a kernel module. ...
    (freebsd-net)
  • /etc/exports and IPv6 networks
    ... I spent a fair amount of time today reading through the man pages and ... source code and could not find any way of specifying an IPv6 network ...
    (freebsd-net)