diff options
author | jfrijters <jfrijters> | 2014-11-18 17:35:39 +0300 |
---|---|---|
committer | jfrijters <jfrijters> | 2014-11-18 17:35:39 +0300 |
commit | b5a87ffc9f2e32e00a5c6ac5a50bc84e8cda6c1a (patch) | |
tree | 7276be4c5dfdbd8c10a1f13a24d617d8b419ff7a /openjdk/java | |
parent | a5dc47c4899dd992bd39c3e0112748fdd0211b45 (diff) |
Implemented isAdapterIpv6Enabled().
Diffstat (limited to 'openjdk/java')
-rw-r--r-- | openjdk/java/net/TwoStacksPlainDatagramSocketImpl_c.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/openjdk/java/net/TwoStacksPlainDatagramSocketImpl_c.java b/openjdk/java/net/TwoStacksPlainDatagramSocketImpl_c.java index a42fd569..d84a427b 100644 --- a/openjdk/java/net/TwoStacksPlainDatagramSocketImpl_c.java +++ b/openjdk/java/net/TwoStacksPlainDatagramSocketImpl_c.java @@ -1595,7 +1595,19 @@ private static InetAddress[] getNetworkInterfaceAddresses(final NetworkInterface } static int isAdapterIpv6Enabled(JNIEnv env, int index) { - return 1; + return java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<Integer>() { + public Integer run() { + try { + for (java.util.Enumeration<InetAddress> e = NetworkInterface.getByIndex(index).getInetAddresses(); e.hasMoreElements(); ) { + if (e.nextElement() instanceof Inet6Address) { + return 1; + } + } + } catch (SocketException x) { + } + return 0; + } + }).intValue(); } private static NetworkInterface Java_java_net_NetworkInterface_getByIndex(JNIEnv env, int ni_class, int index) |