author | jjg |
Wed, 04 Jan 2017 18:33:20 -0800 | |
changeset 43029 | 1cd1c816581e |
parent 7668 | d4a77089c587 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
7668 | 2 |
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
2 | 22 |
*/ |
23 |
||
24 |
/** |
|
25 |
* @test |
|
6002
4df5b9bcf842
6967937: Scope id no longer being set after 6931566
chegar
parents:
5506
diff
changeset
|
26 |
* @bug 6214234 6967937 |
2 | 27 |
* @summary IPv6 scope_id for local addresses not set in Solaris 10 |
28 |
*/ |
|
29 |
||
30 |
import java.net.*; |
|
31 |
import java.util.*; |
|
32 |
||
33 |
public class B6214234 { |
|
34 |
||
35 |
public static void main (String[] args) throws Exception { |
|
36 |
String osname = System.getProperty ("os.name"); |
|
37 |
String version = System.getProperty ("os.version"); |
|
38 |
if (!"SunOS".equals (osname)) { |
|
39 |
System.out.println ("Test only runs on Solaris"); |
|
40 |
return; |
|
41 |
} |
|
42 |
String[] v = version.split("\\."); |
|
43 |
int verNumber = Integer.parseInt (v[0]) * 100 + Integer.parseInt (v[1]); |
|
44 |
if (verNumber < 510) { |
|
45 |
System.out.println ("Test only runs on Solaris versions 10 or higher"); |
|
46 |
return; |
|
47 |
} |
|
48 |
Inet6Address addr = getLocalAddr(); |
|
49 |
if (addr == null) { |
|
50 |
System.out.println ("Could not find a link-local address"); |
|
51 |
return; |
|
52 |
} |
|
53 |
if (addr.getScopeId() == 0) { |
|
6002
4df5b9bcf842
6967937: Scope id no longer being set after 6931566
chegar
parents:
5506
diff
changeset
|
54 |
System.out.println("addr: "+ addr); |
2 | 55 |
throw new RuntimeException ("Non zero scope_id expected"); |
56 |
} |
|
57 |
} |
|
58 |
||
59 |
public static Inet6Address getLocalAddr () throws Exception { |
|
60 |
Enumeration e = NetworkInterface.getNetworkInterfaces(); |
|
61 |
while (e.hasMoreElements()) { |
|
62 |
NetworkInterface ifc = (NetworkInterface) e.nextElement(); |
|
63 |
Enumeration addrs = ifc.getInetAddresses(); |
|
64 |
while (addrs.hasMoreElements()) { |
|
65 |
InetAddress a = (InetAddress)addrs.nextElement(); |
|
66 |
if (a instanceof Inet6Address) { |
|
67 |
Inet6Address ia6 = (Inet6Address) a; |
|
68 |
if (ia6.isLinkLocalAddress()) { |
|
69 |
return ia6; |
|
70 |
} |
|
71 |
} |
|
72 |
} |
|
73 |
} |
|
74 |
return null; |
|
75 |
} |
|
76 |
} |