summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2009-09-30 17:51:26 -0700
committerLorenzo Colitti <lorenzo@google.com>2009-09-30 17:51:26 -0700
commitbeeef8aef21e383d32d362a688b5d5bf0b0428b4 (patch)
treec43ee74f24ba2f45a85d05108f81f286ab2d1562
parent0074d5b9f8f1dfa68766ac62f0a67cdc87bdd1da (diff)
downloadlibcore-beeef8aef21e383d32d362a688b5d5bf0b0428b4.zip
libcore-beeef8aef21e383d32d362a688b5d5bf0b0428b4.tar.gz
libcore-beeef8aef21e383d32d362a688b5d5bf0b0428b4.tar.bz2
More multicast fixes.
1. Make native code properly set network interface indexes that are used for new-style multicast socket options. 2. For IP_MULTICAST_IF, check that the address is IPv4, not the socket. 3. Remove a @KnownFailure annotation for a test that now passes. This removes one test error and changes it into a more benign failure. The remaining test failures seem to be due to Linux bening permissive about which interfaces you can receive multicast traffic on, which is probably good enough for now. Change-Id: Id1fddee338addcfce821672b983485c7dd4983d4
-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;