getaddrinfo() behavior different between XP SP2 and Vista

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I'm using getaddrinfo() to return all assigned IP addresses (both IPv4 and
IPv6) for my local machine. I see that on XP, getaddrinfo() only returns ::1
as an assigned IPv6 address (along that are a number assigned). However, on
Vista, getaddrinfo() will return all IPv6 addresses assigned--which is what
I'd expect and what I'm looking for. Has anyone seen this behavior? Has
anybody used getaddrinfo() to return all assigned IPv6 addresses?

Supporting information follows
1. Test code that uses getaddrinfo() to return assigned IP addresses.
2. Run of test code on XP with ipconfig information
3. Run of test code on Vista with ipconfig information



1. Test Code


#include "stdafx.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <winsock2.h>
#include <ws2tcpip.h>


#using <mscorlib.dll>

using namespace System;

int main(int argc, char **argv)
{
char hostname[80], addrstr[80];
struct addrinfo hints, *res, *resloop;
int err;

WSAData data;
WSAStartup(MAKEWORD(2,0), &data);

memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_PASSIVE;
hints.ai_family = PF_UNSPEC;

if ((err = gethostname(hostname,sizeof(hostname))) !=0) {
printf("gethostname error %d\n",err);
return 1;
}

printf("\nHostname: %s\n\n",hostname);

if ((err = getaddrinfo(hostname, NULL, &hints, &res)) != 0) {
printf("getaddrinfo error %d\n", err);
return 1;
}

for (resloop = res; resloop; resloop = resloop->ai_next) {
if ((err = getnameinfo(resloop->ai_addr, resloop->ai_addrlen, addrstr,
sizeof(addrstr),
NULL, NULL, NI_NUMERICHOST|NI_NUMERICSERV)) !=0) {
printf("getnameinfo error %d\n",err);
}
printf("IP address: %s\n", addrstr);
}

freeaddrinfo(res);
WSACleanup();

return 0;
}



2. Run of test code on Windows XP Professional Version 2002 SP 2 with
ipconfig information (some infomation removed for posting)

Note that only ::1 is returned although a number of IPv6 addresses are
configured.



C:\>getaddrinfoTest

Hostname: SfiorelliGX620

IP address: ::1
IP address: 192.168.x.x

C:\>ipconfig/all


Windows IP Configuration

Host Name . . . . . . . . . . . . : SfiorelliGX620

Ethernet adapter Local Area Connection:

Description . . . . . . . . . . . : Broadcom NetXtreme Gigabit
Ethernet
Physical Address. . . . . . . . . : 00-13-72-B3-DA-73
Dhcp Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IP Address. . . . . . . . . . . . : 192.168.x.x
Subnet Mask . . . . . . . . . . . : 255.255.252.0
IP Address. . . . . . . . . . . . : 3ffe::1
IP Address. . . . . . . . . . . . : fe80::213:72ff:feb3:da73%4

Tunnel adapter Teredo Tunneling Pseudo-Interface:

Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Teredo Tunneling Pseudo-Interface
Physical Address. . . . . . . . . : FF-FF-FF-FF-FF-FF-FF-FF
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : fe80::ffff:ffff:fffd%5
Default Gateway . . . . . . . . . :
NetBIOS over Tcpip. . . . . . . . : Disabled

Tunnel adapter Automatic Tunneling Pseudo-Interface:


Physical Address. . . . . . . . . : C0-A8-04-D3
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : fe80::5efe:192.168.x.x%2
Default Gateway . . . . . . . . . :
NetBIOS over Tcpip. . . . . . . . : Disabled




3. Run of test code on Vista Business with ipconfig information

Note that all configured IPv6 addresses are returned from getaddrinfo().


c:\>getaddrinfoTest

Hostname: Bugno

IP address: fe80::21f3:90dc:9113:3114%8
IP address: 3ffe::3
IP address: fe80::5efe:192.168.x.x%10
IP address: 192.168.x.x

c:\>ipconfig/all

Windows IP Configuration

Host Name . . . . . . . . . . . . : Bugno
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Local Area Connection:

Description . . . . . . . . . . . : 3Com 3C920 Integrated Fast Ethernet
Controller (3C905C-TX Compatible)
Physical Address. . . . . . . . . : 00-06-5B-4A-9D-D9
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IPv6 Address. . . . . . . . . . . : 3ffe::3(Preferred)
Link-local IPv6 Address . . . . . : fe80::21f3:90dc:9113:3114%8(Preferred)
IPv4 Address. . . . . . . . . . . : 192.168.x.x(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Thursday, April 19, 2007 3:02:39 AM
Lease Expires . . . . . . . . . . : Saturday, July 07, 2007 3:05:45 AM
NetBIOS over Tcpip. . . . . . . . : Enabled

Tunnel adapter Local Area Connection* 6:

Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::5efe:192.168.x.x%10(Preferred)
Default Gateway . . . . . . . . . :
NetBIOS over Tcpip. . . . . . . . : Disabled

Tunnel adapter Local Area Connection* 7:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Teredo Tunneling Pseudo-Interface
Physical Address. . . . . . . . . : 02-00-54-55-4E-01
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes




.



Relevant Pages

  • Re: getaddrinfo() behavior different between XP SP2 and Vista
    ... IPv6) for my local machine. ... getaddrinfo() will return all IPv6 addresses assigned--which is ... Ethernet adapter Local Area Connection: ... Tunnel adapter Automatic Tunneling Pseudo-Interface: ...
    (microsoft.public.win32.programmer.networks)
  • Re: getaddrinfo() behavior different between XP SP2 and Vista
    ... I see only one related service--the IPv6 helper service. ... Ethernet adapter Local Area Connection: ... Tunnel adapter Automatic Tunneling Pseudo-Interface: ...
    (microsoft.public.win32.programmer.networks)
  • Re: http://www.ntp.org/ => a blank page?
    ... getaddrinfo() which is used by all newer apps returns both IPv4 and IPv6 ... policy and they do not come into play. ... respond on the point of site policies coming into play. ...
    (comp.protocols.time.ntp)
  • Re: Any way to bypass nameserver call in IPV6 ???
    ... >their code from using gethostbynameto using getaddrinfo(). ... My guess is that you would need to put IPv6 ... says that any hostname with two or more dots in it is already a FQDN ... The remaining "nameserver" lines are normal ones. ...
    (comp.unix.aix)
  • Re: http://www.ntp.org/ => a blank page?
    ... cannot change getaddrinfo() unless you implement your own and there is ... I take your word that RFC 3484 is being discussed on namedroppers. ... "All IPv6 nodes, including both hosts and routers, must implement ... The stack has no knowledge of whether it can connect to a global IPv6 ...
    (comp.protocols.time.ntp)