author | jboes |
Fri, 08 Nov 2019 11:15:16 +0000 | |
changeset 59029 | 3786a0962570 |
parent 54811 | 9db7c0f561a6 |
permissions | -rw-r--r-- |
19866
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
1 |
/* |
53426 | 2 |
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. |
19866
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
4 |
* |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
8 |
* |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
13 |
* accompanied this code). |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
14 |
* |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
18 |
* |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
21 |
* questions. |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
22 |
*/ |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
23 |
|
53426 | 24 |
import java.io.IOException; |
25 |
import java.io.UncheckedIOException; |
|
26 |
import java.net.MulticastSocket; |
|
27 |
import java.net.NetworkInterface; |
|
19866
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
28 |
|
53426 | 29 |
import jdk.test.lib.NetworkConfiguration; |
54770
62b6e7587b1f
8220673: Add test library support for determining platform IP support
aeubanks
parents:
53426
diff
changeset
|
30 |
import jdk.test.lib.net.IPSupport; |
53426 | 31 |
|
32 |
/** |
|
19866
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
33 |
* @test |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
34 |
* @bug 6458027 |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
35 |
* @summary Disabling IPv6 on a specific network interface causes problems. |
53426 | 36 |
* @library /test/lib |
37 |
* @build jdk.test.lib.NetworkConfiguration |
|
38 |
* jdk.test.lib.Platform |
|
39 |
* @run main SetGetNetworkInterfaceTest |
|
40 |
* @run main/othervm -Djava.net.preferIPv4Stack=true SetGetNetworkInterfaceTest |
|
41 |
*/ |
|
42 |
public class SetGetNetworkInterfaceTest { |
|
19866
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
43 |
|
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
44 |
public static void main(String[] args) throws Exception { |
54811
9db7c0f561a6
8223652: Rename IPSupport.skipIfCurrentConfigurationIsInvalid() to IPSupport.throwSkippedExceptionIfNonOperational()
aeubanks
parents:
54770
diff
changeset
|
45 |
IPSupport.throwSkippedExceptionIfNonOperational(); |
53426 | 46 |
NetworkConfiguration nc = NetworkConfiguration.probe(); |
47 |
try (MulticastSocket ms = new MulticastSocket()) { |
|
48 |
nc.multicastInterfaces(true).forEach(nif -> setGetNetworkInterface(ms, nif)); |
|
19866
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
49 |
} catch (IOException e) { |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
50 |
e.printStackTrace(); |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
51 |
} |
53426 | 52 |
System.out.println("Test passed."); |
19866
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
53 |
} |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
54 |
|
53426 | 55 |
static void setGetNetworkInterface(MulticastSocket ms, NetworkInterface nif) { |
56 |
try { |
|
57 |
System.out.println(NetworkConfiguration.interfaceInformation(nif)); |
|
58 |
ms.setNetworkInterface(nif); |
|
59 |
NetworkInterface msNetIf = ms.getNetworkInterface(); |
|
60 |
if (nif.equals(msNetIf)) { |
|
61 |
System.out.println(" OK"); |
|
19866
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
62 |
} else { |
53426 | 63 |
System.out.println("FAILED!!!"); |
64 |
System.out.println(NetworkConfiguration.interfaceInformation(msNetIf)); |
|
65 |
throw new RuntimeException("Test Fail"); |
|
19866
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
66 |
} |
53426 | 67 |
System.out.println("------------------"); |
68 |
} catch (IOException e) { |
|
69 |
throw new UncheckedIOException(e); |
|
19866
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
70 |
} |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
71 |
} |
f5e8a8275078
6458027: Disabling IPv6 on a specific network interface causes problems
msheppar
parents:
diff
changeset
|
72 |
} |