--- a/jdk/src/windows/native/java/net/NetworkInterface_winXP.c Sat Sep 14 19:21:07 2013 +0100
+++ b/jdk/src/windows/native/java/net/NetworkInterface_winXP.c Thu Oct 03 19:06:43 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -82,7 +82,6 @@
IP_ADAPTER_ADDRESSES *adapterInfo;
ULONG len;
adapterInfo = (IP_ADAPTER_ADDRESSES *)malloc (bufsize);
-
if (adapterInfo == NULL) {
JNU_ThrowByName(env, "java/lang/OutOfMemoryError", "Native heap allocation failure");
return -1;
@@ -160,8 +159,12 @@
ptr = adapterInfo;
ret = NULL;
while (ptr != NULL) {
- // IPv4 interface
- if (ptr->Ipv6IfIndex == index) {
+ // in theory the IPv4 index and the IPv6 index can be the same
+ // where an interface is enabled for v4 and v6
+ // IfIndex == 0 IPv4 not available on this interface
+ // Ipv6IfIndex == 0 IPv6 not available on this interface
+ if (((ptr->IfIndex != 0)&&(ptr->IfIndex == index)) ||
+ ((ptr->Ipv6IfIndex !=0) && (ptr->Ipv6IfIndex == index))) {
ret = (IP_ADAPTER_ADDRESSES *) malloc(sizeof(IP_ADAPTER_ADDRESSES));
if (ret == NULL) {
free(adapterInfo);
@@ -172,6 +175,7 @@
//copy the memory and break out of the while loop.
memcpy(ret, ptr, sizeof(IP_ADAPTER_ADDRESSES));
break;
+
}
ptr=ptr->Next;
}
@@ -192,7 +196,6 @@
int tun=0, net=0;
*netifPP = NULL;
-
/*
* Get the IPv4 interfaces. This information is the same
* as what previous JDK versions would return.
@@ -264,7 +267,7 @@
* set the index to the IPv6 index and add the
* IPv6 addresses
*/
- nif->index = ptr->Ipv6IfIndex;
+ nif->ipv6Index = ptr->Ipv6IfIndex;
c = getAddrsFromAdapter(ptr, &nif->addrs);
nif->naddrs += c;
break;
@@ -309,6 +312,9 @@
strcpy (nif->name, newname);
wcscpy ((PWCHAR)nif->displayName, ptr->FriendlyName);
nif->dNameIsUnicode = TRUE;
+
+ // the java.net.NetworkInterface abstraction only has index
+ // so the Ipv6IfIndex needs to map onto index
nif->index = ptr->Ipv6IfIndex;
nif->ipv6Index = ptr->Ipv6IfIndex;
nif->hasIpv6Address = TRUE;
@@ -487,7 +493,6 @@
(*env)->SetObjectField(env, netifObj, ni_nameID, name);
(*env)->SetObjectField(env, netifObj, ni_displayNameID, displayName);
(*env)->SetIntField(env, netifObj, ni_indexID, ifs->index);
-
/*
* Get the IP addresses for this interface if necessary
* Note that 0 is a valid number of addresses.