0N/A/*
3261N/A * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/**
0N/A * @test
2578N/A * @bug 6214234 6967937
0N/A * @summary IPv6 scope_id for local addresses not set in Solaris 10
0N/A */
0N/A
0N/Aimport java.net.*;
0N/Aimport java.util.*;
0N/A
0N/Apublic class B6214234 {
0N/A
0N/A public static void main (String[] args) throws Exception {
0N/A String osname = System.getProperty ("os.name");
0N/A String version = System.getProperty ("os.version");
0N/A if (!"SunOS".equals (osname)) {
0N/A System.out.println ("Test only runs on Solaris");
0N/A return;
0N/A }
0N/A String[] v = version.split("\\.");
0N/A int verNumber = Integer.parseInt (v[0]) * 100 + Integer.parseInt (v[1]);
0N/A if (verNumber < 510) {
0N/A System.out.println ("Test only runs on Solaris versions 10 or higher");
0N/A return;
0N/A }
0N/A Inet6Address addr = getLocalAddr();
0N/A if (addr == null) {
0N/A System.out.println ("Could not find a link-local address");
0N/A return;
0N/A }
0N/A if (addr.getScopeId() == 0) {
2578N/A System.out.println("addr: "+ addr);
0N/A throw new RuntimeException ("Non zero scope_id expected");
0N/A }
0N/A }
0N/A
0N/A public static Inet6Address getLocalAddr () throws Exception {
0N/A Enumeration e = NetworkInterface.getNetworkInterfaces();
0N/A while (e.hasMoreElements()) {
0N/A NetworkInterface ifc = (NetworkInterface) e.nextElement();
0N/A Enumeration addrs = ifc.getInetAddresses();
0N/A while (addrs.hasMoreElements()) {
0N/A InetAddress a = (InetAddress)addrs.nextElement();
0N/A if (a instanceof Inet6Address) {
0N/A Inet6Address ia6 = (Inet6Address) a;
0N/A if (ia6.isLinkLocalAddress()) {
0N/A return ia6;
0N/A }
0N/A }
0N/A }
0N/A }
0N/A return null;
0N/A }
0N/A}