getaddrinfo() behavior different between XP SP2 and Vista
- From: SteveFiorelli <SteveFiorelli@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 6 Jul 2007 15:06:01 -0700
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
.
- Follow-Ups:
- Re: getaddrinfo() behavior different between XP SP2 and Vista
- From: Arkady Frenkel
- Re: getaddrinfo() behavior different between XP SP2 and Vista
- Prev by Date: Re: Multicasts on a VPN adapter
- Next by Date: Re: C++ and Berkeley Sockets
- Previous by thread: WlanSetProfile...how to create an adhoc connection
- Next by thread: Re: getaddrinfo() behavior different between XP SP2 and Vista
- Index(es):
Relevant Pages
|