summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--luni/src/main/native/java_net_NetworkInterface.c5
-rw-r--r--luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp5
-rw-r--r--luni/src/test/java/tests/api/java/net/MulticastSocketTest.java1
3 files changed, 6 insertions, 5 deletions
diff --git a/luni/src/main/native/java_net_NetworkInterface.c b/luni/src/main/native/java_net_NetworkInterface.c
index 379ccdf..db6d503 100644
--- a/luni/src/main/native/java_net_NetworkInterface.c
+++ b/luni/src/main/native/java_net_NetworkInterface.c
@@ -546,8 +546,9 @@ int sockGetNetworkInterfaces(struct NetworkInterfaceArray_struct * array) {
/* since this function can return multiple entries for the same name, only do it for the first one with any given name */
if((NULL == lastName) || (strncmp(lastName, ifc.ifc_req[counter].ifr_name, IFNAMSIZ) != 0)) {
- /* get the index for the interface. This is only truely necessary on platforms that support IPV6 */
- interfaces[currentAdapterIndex].index = 0;
+ /* get the index for the interface */
+ interfaces[currentAdapterIndex].index =
+ ifc.ifc_req[counter].ifr_ifindex;
/* get the name and display name for the adapter */
/* there only seems to be one name so use it for both the name and the display name */
nameLength = strlen(ifc.ifc_req[counter].ifr_name);
diff --git a/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp b/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp
index 339c62c..7b6023a 100644
--- a/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp
+++ b/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp
@@ -3316,8 +3316,9 @@ static void osNetworkSystem_setSocketOptionImpl(JNIEnv* env, jclass clazz,
if ((anOption >> 16) & BROKEN_MULTICAST_IF) {
return;
}
- // This call is IPv4 only.
- if (getSocketAddressFamily(handle) != AF_INET) {
+ // This call is IPv4 only. The socket may be IPv6, but the address
+ // that identifies the interface to join must be an IPv4 address.
+ if (sockVal.ss_family != AF_INET) {
throwSocketException(env, SOCKERR_BADAF);
return;
}
diff --git a/luni/src/test/java/tests/api/java/net/MulticastSocketTest.java b/luni/src/test/java/tests/api/java/net/MulticastSocketTest.java
index 997055b..1429063 100644
--- a/luni/src/test/java/tests/api/java/net/MulticastSocketTest.java
+++ b/luni/src/test/java/tests/api/java/net/MulticastSocketTest.java
@@ -1099,7 +1099,6 @@ public class MulticastSocketTest extends SocketTestCase {
method = "setNetworkInterface",
args = {java.net.NetworkInterface.class}
)
- @KnownFailure("No interfaces if there's no debugger connected")
public void test_setNetworkInterfaceLjava_net_NetworkInterface()
throws IOException, InterruptedException {
String msg = null;