locked
getnameinfo fails on POS Ready 2009 RRS feed

  • Question

  • I have the following code that works on XP sp2, XPe sp2 but not on POS Ready 2009 (i.e. XP sp3)  (code abridged):

    WSAStartup(1_1, &wsaData);

    if (0==gethostname(szHostName, sizeof(szHostname)) {

      struct addrinfo hints, *res;

      // memset hints to zero, set hints.ai_family to aF_UNSPEC and ai_socktype to SOCK_STREAM

      if (0==getaddrinfo(szHostName, NULL, & hints, & res)) {

        char addr[NI_MAXHOST];

        if (0==getnameinfo(res->ai_addr, (socklen_t)res->ai_addrlen, addr, NI_MAXHOST, NULL, 0, NI_NAMEREQD)) {

          // Success, save addr to a variable w/ larger scope

        }

        else {

          // Failure

      }

    WSACleanup();

    On XPe, getaddrinfo returns a ai_addr->sa_family of 23 (IPv6) and getnameinfo successfully finds the fully qualified host name.

    On POS Ready, getaddrinfo returns an ai_addr->sa_family of 23 (IPv6) but getnameinfo returns 11004 which resolves to "The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for." 

    If, on POS Ready, I reset the ai_addr->sa_family to 2 (AF_INET), getnameinfo successfully finds the fully qualified host name.

    The only difference, other than service packs and products, that I can find is that XPe lists the Teredo Tunneling Pseudo-Interface only but POS Ready lists the Teredo Tunneling Pseodo-Interface and the Automatic Tunneling Pseudo-Interface (from ipconfig /all).

    I've uninstalled IPv6 on the POS Ready system and that seems to solve the problem, however I can't support IPv6 in that configuration. 

    Any ideas on what to look at or configure to get this to work on POS Ready 2009?

    Thanks, Tom

    Tuesday, August 10, 2010 4:04 PM

Answers

  • Hi Tom,

    I tried your sample code in a program here.  I assume it's job is simply to return the fully qualified machine name and didn't go any further on it.  I also used a minimum install POSReady with no config changes which has the Teredo Tunneling Pseudo-Interface.

    The bad news is that it worked.  I tried a few variations including setting Winsock version to 2.2, setting ai_family to AF_INET6 but I was unable to repro yet.

    The possible differences with my system is that POSReady is running within Virtual PC (on Win7), all with latest updates, and connected to our domain.  It's technically possible that something is changing a critical component allowing it to work, or maybe it's part of our DNS.

    I'll try to get others to try out my binary to see what happens.  If you have the ability to introduce some of my above differences and try again, let us know how it goes.

    Brendan

    Thursday, August 26, 2010 8:28 PM

All replies

  • Hi Tom,

    I'm not sure if this will help, but try stopping the IPV6 Helper Service, run ipconfig /renew, and ipconfig /all again to see if this is the configuration you're after.  If so, try your program again.

    Let us know if this makes a difference or if you've tried this already.  If it's still not working, I'll try to see if I can repro.

    Brendan

    Friday, August 13, 2010 5:48 PM
  • Hi Brendan,

    Thanks for your response.

    I attempted what you suggested but I still get both tunnelling interfaces and getnameinfo still fails when handed a family of IPv6 and works when handed a family of IPv4.

    I know there are other ways of getting the hostname on Windows but this code is also shared w/ UNIX/Linux build targets too.

    What I'd really like to know is 1) if having both pseudo tunneling interfaces is causing the problem; 2) How can I disable one (automatic seems to be the problematic one) of them and not the other?

    Thanks,

    Tom

    Friday, August 13, 2010 8:33 PM
  • Tom,

    I suspect you are missing the Network Services optional component in POSReady 2009.  Please go into Control Panel, Add or Remove Programs then select Add or Remove Windows Components and add the optional component then try again.  Please let us know the results.

    Terry Warwick
    Microsoft

    Tuesday, August 17, 2010 3:28 AM
  • Hi Terry,

    Thank you for your input and I apologize for taking a while to get back to you.

    This is a pretty bare-bones setup.  I did install the Networking Services component.  Rebooted.  Same issue.  Ran ipconfig release/renew sequence.  Same issue.

    I'm still seeing two Tunnel adapter interfaces after running ipconfig /all.  I did not have this problem on a XPe (sp2) system and it only reported on Tunnel adapter interface (Teredo, no Automatic).  I'm not sure if that is the cause or not, but it is a difference between the two systems.

    Any (more) ideas?

    Thanks, Tom

    Tuesday, August 24, 2010 6:10 PM
  • Hi Tom,

    I tried your sample code in a program here.  I assume it's job is simply to return the fully qualified machine name and didn't go any further on it.  I also used a minimum install POSReady with no config changes which has the Teredo Tunneling Pseudo-Interface.

    The bad news is that it worked.  I tried a few variations including setting Winsock version to 2.2, setting ai_family to AF_INET6 but I was unable to repro yet.

    The possible differences with my system is that POSReady is running within Virtual PC (on Win7), all with latest updates, and connected to our domain.  It's technically possible that something is changing a critical component allowing it to work, or maybe it's part of our DNS.

    I'll try to get others to try out my binary to see what happens.  If you have the ability to introduce some of my above differences and try again, let us know how it goes.

    Brendan

    Thursday, August 26, 2010 8:28 PM